xbintsc 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/binder/binder.d.ts +35 -1
- package/dist/src/binder/binder.js +138 -0
- package/dist/src/binder/binder.js.map +1 -1
- package/dist/src/codegen/generator/calls.d.ts +4 -0
- package/dist/src/codegen/generator/calls.js +104 -32
- package/dist/src/codegen/generator/calls.js.map +1 -1
- package/dist/src/codegen/generator/context.d.ts +2 -0
- package/dist/src/codegen/generator/context.js +36 -0
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/expressions.d.ts +4 -1
- package/dist/src/codegen/generator/expressions.js +73 -2
- package/dist/src/codegen/generator/expressions.js.map +1 -1
- package/dist/src/codegen/generator/module.d.ts +5 -1
- package/dist/src/codegen/generator/module.js +106 -6
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.d.ts +2 -0
- package/dist/src/codegen/generator/state.js +41 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/statements.js +9 -1
- package/dist/src/codegen/generator/statements.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +4 -0
- package/dist/src/codegen/generator/tables.js +33 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/compiler.js +23 -7
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/modules.d.ts +24 -0
- package/dist/src/driver/modules.js +347 -0
- package/dist/src/driver/modules.js.map +1 -0
- package/dist/src/parser/expressions.js +3 -0
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +1 -1
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/e2e/compile.test.js +86 -0
- package/dist/tests/e2e/compile.test.js.map +1 -1
- package/package.json +1 -1
- package/runtime/rt.h +55 -4
- package/runtime/rt_internal.h +63 -0
- package/runtime/xt_builtins.c +47 -1
- package/runtime/xt_containers.c +95 -8
- package/runtime/xt_io.c +113 -0
- package/runtime/xt_promise.c +292 -0
- package/runtime/xt_stdlib.c +59 -5
- package/runtime/xt_stdlib2.c +1043 -0
- package/src/binder/binder.ts +196 -0
- package/src/codegen/generator/calls.ts +111 -33
- package/src/codegen/generator/context.ts +35 -1
- package/src/codegen/generator/expressions.ts +79 -2
- package/src/codegen/generator/module.ts +111 -6
- package/src/codegen/generator/state.ts +43 -0
- package/src/codegen/generator/statements.ts +7 -1
- package/src/codegen/generator/tables.ts +35 -0
- package/src/driver/compiler.ts +28 -7
- package/src/driver/modules.ts +377 -0
- package/src/parser/expressions.ts +3 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source-level module bundler.
|
|
3
|
+
*
|
|
4
|
+
* xbintsc does not run a linker for modules, so `import`/`export` are lowered
|
|
5
|
+
* at the driver by merging every reachable module into a single source file.
|
|
6
|
+
* Each module's top-level bindings are renamed to a globally unique name and
|
|
7
|
+
* imported names are rewritten to the (renamed) exported binding.
|
|
8
|
+
*
|
|
9
|
+
* This is intentionally simple: it supports named imports/exports, `export
|
|
10
|
+
* default` for declarations, and `export ... from`. Namespace imports and
|
|
11
|
+
* `export *` are approximated, and circular graphs are reported as an error.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
15
|
+
import { dirname, resolve } from "node:path";
|
|
16
|
+
import {
|
|
17
|
+
ModifierKind,
|
|
18
|
+
SyntaxKind,
|
|
19
|
+
type ExportAssignment,
|
|
20
|
+
type ExportDeclaration,
|
|
21
|
+
type Identifier,
|
|
22
|
+
type ImportDeclaration,
|
|
23
|
+
type Node,
|
|
24
|
+
type SourceFileNode,
|
|
25
|
+
type Statement,
|
|
26
|
+
type VariableDeclaration,
|
|
27
|
+
type VariableDeclarationList,
|
|
28
|
+
type VariableStatement,
|
|
29
|
+
} from "../ast/nodes.js";
|
|
30
|
+
import { bind, SymbolKind, type BindResult, type SymbolInfo } from "../binder/binder.js";
|
|
31
|
+
import { DiagnosticBag, DiagnosticCode } from "../diagnostics/diagnostic.js";
|
|
32
|
+
import { SourceFile } from "../diagnostics/source.js";
|
|
33
|
+
import { Parser } from "../parser/parser.js";
|
|
34
|
+
|
|
35
|
+
interface ModuleRecord {
|
|
36
|
+
readonly path: string;
|
|
37
|
+
readonly text: string;
|
|
38
|
+
readonly sourceFile: SourceFileNode;
|
|
39
|
+
readonly bind: BindResult;
|
|
40
|
+
readonly prefix: string;
|
|
41
|
+
/** exported name -> final (renamed) local name */
|
|
42
|
+
readonly exports: Map<string, string>;
|
|
43
|
+
/** original local name of every top-level symbol */
|
|
44
|
+
readonly originalNames: Map<number, string>;
|
|
45
|
+
/** final name of every top-level symbol */
|
|
46
|
+
readonly finalNames: Map<number, string>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface BundleResult {
|
|
50
|
+
readonly sourceFile: SourceFileNode;
|
|
51
|
+
readonly text: string;
|
|
52
|
+
readonly moduleCount: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const RESOLVE_SUFFIXES = ["", ".ts", ".tsx", ".mts", ".cts", "/index.ts", "/index.tsx"];
|
|
56
|
+
|
|
57
|
+
function resolveModule(fromDir: string, specifier: string): string | undefined {
|
|
58
|
+
const base = resolve(fromDir, specifier);
|
|
59
|
+
for (const suffix of RESOLVE_SUFFIXES) {
|
|
60
|
+
const candidate = base + suffix;
|
|
61
|
+
if (existsSync(candidate) && statSync(candidate).isFile()) return candidate;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function hasModifier(node: Node, kind: ModifierKind): boolean {
|
|
67
|
+
const modifiers = (node as { modifiers?: { modifierKind: ModifierKind }[] }).modifiers;
|
|
68
|
+
return !!modifiers && modifiers.some((modifier) => modifier.modifierKind === kind);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function declarationName(node: Node): Identifier | undefined {
|
|
72
|
+
switch (node.kind) {
|
|
73
|
+
case SyntaxKind.FunctionDeclaration:
|
|
74
|
+
case SyntaxKind.ClassDeclaration:
|
|
75
|
+
case SyntaxKind.EnumDeclaration:
|
|
76
|
+
case SyntaxKind.InterfaceDeclaration:
|
|
77
|
+
case SyntaxKind.TypeAliasDeclaration:
|
|
78
|
+
case SyntaxKind.ModuleDeclaration:
|
|
79
|
+
return (node as { name?: Identifier }).name;
|
|
80
|
+
case SyntaxKind.VariableDeclaration:
|
|
81
|
+
return (node as VariableDeclaration).name;
|
|
82
|
+
default:
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Load, parse and bind the entry module and every module it imports. */
|
|
88
|
+
function loadGraph(entryPath: string, diagnostics: DiagnosticBag): ModuleRecord[] | undefined {
|
|
89
|
+
const records = new Map<string, ModuleRecord>();
|
|
90
|
+
const order: ModuleRecord[] = [];
|
|
91
|
+
const visiting = new Set<string>();
|
|
92
|
+
let counter = 0;
|
|
93
|
+
let failed = false;
|
|
94
|
+
|
|
95
|
+
const load = (path: string): ModuleRecord | undefined => {
|
|
96
|
+
const existing = records.get(path);
|
|
97
|
+
if (existing) return existing;
|
|
98
|
+
if (visiting.has(path)) {
|
|
99
|
+
diagnostics.error(DiagnosticCode.CodegenError, `Circular import detected involving '${path}'`);
|
|
100
|
+
failed = true;
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
if (!existsSync(path)) {
|
|
104
|
+
diagnostics.error(DiagnosticCode.CodegenError, `Cannot find module '${path}'`);
|
|
105
|
+
failed = true;
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
visiting.add(path);
|
|
109
|
+
const text = readFileSync(path, "utf8");
|
|
110
|
+
const file = new SourceFile(path, text);
|
|
111
|
+
const parser = new Parser(file, diagnostics);
|
|
112
|
+
const sourceFile = parser.parseSourceFile();
|
|
113
|
+
const bindResult = bind(sourceFile);
|
|
114
|
+
const record: ModuleRecord = {
|
|
115
|
+
path,
|
|
116
|
+
text,
|
|
117
|
+
sourceFile,
|
|
118
|
+
bind: bindResult,
|
|
119
|
+
prefix: `m${counter++}_`,
|
|
120
|
+
exports: new Map(),
|
|
121
|
+
originalNames: new Map(),
|
|
122
|
+
finalNames: new Map(),
|
|
123
|
+
};
|
|
124
|
+
records.set(path, record);
|
|
125
|
+
|
|
126
|
+
for (const statement of sourceFile.statements) {
|
|
127
|
+
const specifier = moduleSpecifierOf(statement);
|
|
128
|
+
if (!specifier) continue;
|
|
129
|
+
const dependency = resolveModule(dirname(path), specifier);
|
|
130
|
+
if (!dependency) {
|
|
131
|
+
diagnostics.error(
|
|
132
|
+
DiagnosticCode.CodegenError,
|
|
133
|
+
`Cannot resolve module '${specifier}' from '${path}'`,
|
|
134
|
+
statement,
|
|
135
|
+
path,
|
|
136
|
+
);
|
|
137
|
+
failed = true;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
load(dependency);
|
|
141
|
+
}
|
|
142
|
+
visiting.delete(path);
|
|
143
|
+
order.push(record);
|
|
144
|
+
return record;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
load(entryPath);
|
|
148
|
+
if (failed) return undefined;
|
|
149
|
+
return order;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function moduleSpecifierOf(statement: Statement): string | undefined {
|
|
153
|
+
if (statement.kind === SyntaxKind.ImportDeclaration) {
|
|
154
|
+
return (statement as ImportDeclaration).moduleSpecifier.value;
|
|
155
|
+
}
|
|
156
|
+
if (statement.kind === SyntaxKind.ExportDeclaration) {
|
|
157
|
+
const specifier = (statement as ExportDeclaration).moduleSpecifier;
|
|
158
|
+
if (specifier) return specifier.value;
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Rewrite a symbol's declaration and every reference to `finalName`. */
|
|
164
|
+
function renameSymbol(symbol: SymbolInfo, finalName: string): void {
|
|
165
|
+
for (const declaration of symbol.declarations) {
|
|
166
|
+
const name = declarationName(declaration);
|
|
167
|
+
if (name) (name as { text: string }).text = finalName;
|
|
168
|
+
}
|
|
169
|
+
for (const reference of symbol.references) (reference as { text: string }).text = finalName;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Rewrite just the references of a symbol (used for imported names). */
|
|
173
|
+
function renameReferences(symbol: SymbolInfo, finalName: string): void {
|
|
174
|
+
for (const reference of symbol.references) (reference as { text: string }).text = finalName;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function moduleScope(record: ModuleRecord) {
|
|
178
|
+
return record.bind.scopes.get(record.sourceFile);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function topLevelSymbols(record: ModuleRecord): SymbolInfo[] {
|
|
182
|
+
const scope = moduleScope(record);
|
|
183
|
+
if (!scope) return [];
|
|
184
|
+
return [...scope.symbols.values()];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Merge every module's statements into a single file. Dependencies come first
|
|
189
|
+
* (post-order over the import graph), the entry module last.
|
|
190
|
+
*/
|
|
191
|
+
export function bundleModules(entryPath: string, diagnostics: DiagnosticBag): BundleResult | undefined {
|
|
192
|
+
const records = loadGraph(entryPath, diagnostics);
|
|
193
|
+
if (!records) return undefined;
|
|
194
|
+
|
|
195
|
+
const byPath = new Map(records.map((record) => [record.path, record]));
|
|
196
|
+
const dependencyOf = (record: ModuleRecord, specifier: string): ModuleRecord | undefined => {
|
|
197
|
+
const resolved = resolveModule(dirname(record.path), specifier);
|
|
198
|
+
return resolved ? byPath.get(resolved) : undefined;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// Phase 1: record every top-level binding and pick a unique final name.
|
|
202
|
+
for (const record of records) {
|
|
203
|
+
for (const symbol of topLevelSymbols(record)) {
|
|
204
|
+
record.originalNames.set(symbol.id, symbol.name);
|
|
205
|
+
if (symbol.kind === SymbolKind.Import) continue;
|
|
206
|
+
record.finalNames.set(symbol.id, record.prefix + symbol.name);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Phase 2: collect each module's exported names.
|
|
211
|
+
for (const record of records) {
|
|
212
|
+
const scope = moduleScope(record);
|
|
213
|
+
if (!scope) continue;
|
|
214
|
+
const symbolByName = scope.symbols;
|
|
215
|
+
for (const statement of record.sourceFile.statements) {
|
|
216
|
+
if (statement.kind === SyntaxKind.ExportDeclaration) {
|
|
217
|
+
const declaration = statement as ExportDeclaration;
|
|
218
|
+
if (declaration.exportClause && declaration.exportClause.kind === SyntaxKind.NamedExports) {
|
|
219
|
+
for (const specifier of declaration.exportClause.elements) {
|
|
220
|
+
const localName = specifier.propertyName?.text ?? specifier.name.text;
|
|
221
|
+
const exportedName = specifier.name.text;
|
|
222
|
+
if (declaration.moduleSpecifier) {
|
|
223
|
+
const dependency = dependencyOf(record, declaration.moduleSpecifier.value);
|
|
224
|
+
const target = dependency?.exports.get(localName);
|
|
225
|
+
if (target) record.exports.set(exportedName, target);
|
|
226
|
+
} else {
|
|
227
|
+
const symbol = symbolByName.get(localName);
|
|
228
|
+
if (symbol) {
|
|
229
|
+
const finalName = record.finalNames.get(symbol.id) ?? symbol.name;
|
|
230
|
+
record.exports.set(exportedName, finalName);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
} else if (!declaration.exportClause && declaration.moduleSpecifier) {
|
|
235
|
+
// `export * from "..."`: copy every re-exported name.
|
|
236
|
+
const dependency = dependencyOf(record, declaration.moduleSpecifier.value);
|
|
237
|
+
if (dependency) for (const [name, value] of dependency.exports) record.exports.set(name, value);
|
|
238
|
+
}
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (statement.kind === SyntaxKind.ExportAssignment) {
|
|
242
|
+
record.exports.set("default", `${record.prefix}default`);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (hasModifier(statement, ModifierKind.Default)) {
|
|
246
|
+
const name = declarationName(statement) ?? declarationName((statement as { declaration?: Node }).declaration ?? statement);
|
|
247
|
+
if (name) {
|
|
248
|
+
const symbol = symbolByName.get(name.text);
|
|
249
|
+
if (symbol) record.exports.set("default", record.finalNames.get(symbol.id) ?? symbol.name);
|
|
250
|
+
}
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (hasModifier(statement, ModifierKind.Export)) {
|
|
254
|
+
const names = exportedNames(statement);
|
|
255
|
+
for (const name of names) {
|
|
256
|
+
const symbol = symbolByName.get(name);
|
|
257
|
+
if (symbol) record.exports.set(name, record.finalNames.get(symbol.id) ?? symbol.name);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Phase 3: rewrite imported names and record re-exports.
|
|
264
|
+
for (const record of records) {
|
|
265
|
+
const scope = moduleScope(record);
|
|
266
|
+
if (!scope) continue;
|
|
267
|
+
for (const statement of record.sourceFile.statements) {
|
|
268
|
+
if (statement.kind !== SyntaxKind.ImportDeclaration) continue;
|
|
269
|
+
const declaration = statement as ImportDeclaration;
|
|
270
|
+
const dependency = dependencyOf(record, declaration.moduleSpecifier.value);
|
|
271
|
+
const clause = declaration.importClause;
|
|
272
|
+
if (!clause || !dependency) continue;
|
|
273
|
+
if (clause.name) {
|
|
274
|
+
const target = dependency.exports.get("default") ?? dependency.exports.get("default");
|
|
275
|
+
const local = scope.symbols.get(clause.name.text);
|
|
276
|
+
if (target && local) renameReferences(local, target);
|
|
277
|
+
}
|
|
278
|
+
const bindings = clause.namedBindings;
|
|
279
|
+
if (bindings && bindings.kind === SyntaxKind.NamedImports) {
|
|
280
|
+
for (const specifier of bindings.elements) {
|
|
281
|
+
const importedName = specifier.propertyName?.text ?? specifier.name.text;
|
|
282
|
+
const target = dependency.exports.get(importedName);
|
|
283
|
+
const local = scope.symbols.get(specifier.name.text);
|
|
284
|
+
if (target && local) renameReferences(local, target);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Phase 4: concatenate statements, dropping imports and pure export wrappers.
|
|
291
|
+
const merged: Statement[] = [];
|
|
292
|
+
const first = records[records.length - 1]!;
|
|
293
|
+
for (const record of records) {
|
|
294
|
+
for (const statement of record.sourceFile.statements) {
|
|
295
|
+
if (statement.kind === SyntaxKind.ImportDeclaration) continue;
|
|
296
|
+
if (statement.kind === SyntaxKind.ExportDeclaration) {
|
|
297
|
+
const declaration = statement as ExportDeclaration;
|
|
298
|
+
const inner = (declaration as unknown as { declaration?: Statement }).declaration;
|
|
299
|
+
if (inner) merged.push(inner);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (statement.kind === SyntaxKind.ExportAssignment) {
|
|
303
|
+
const assignment = statement as ExportAssignment;
|
|
304
|
+
merged.push(exportAssignmentToStatement(record, assignment));
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
merged.push(statement);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Phase 5: rename every top-level binding (declaration + references) to its
|
|
312
|
+
// unique final name, now that import references have been rewritten.
|
|
313
|
+
for (const record of records) {
|
|
314
|
+
for (const symbol of topLevelSymbols(record)) {
|
|
315
|
+
if (symbol.kind === SymbolKind.Import) continue;
|
|
316
|
+
const finalName = record.finalNames.get(symbol.id);
|
|
317
|
+
if (finalName) renameSymbol(symbol, finalName);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const sourceFile: SourceFileNode = {
|
|
322
|
+
kind: SyntaxKind.SourceFile,
|
|
323
|
+
statements: merged,
|
|
324
|
+
fileName: first.path,
|
|
325
|
+
text: records.map((record) => record.text).join("\n"),
|
|
326
|
+
start: 0,
|
|
327
|
+
end: 0,
|
|
328
|
+
};
|
|
329
|
+
return { sourceFile, text: sourceFile.text, moduleCount: records.length };
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function exportedNames(statement: Statement): string[] {
|
|
333
|
+
const names: string[] = [];
|
|
334
|
+
if (statement.kind === SyntaxKind.VariableStatement) {
|
|
335
|
+
for (const declaration of (statement as VariableStatement).declarationList.declarations) {
|
|
336
|
+
if (declaration.name) names.push(declaration.name.text);
|
|
337
|
+
}
|
|
338
|
+
} else {
|
|
339
|
+
const name = declarationName(statement);
|
|
340
|
+
if (name) names.push(name.text);
|
|
341
|
+
}
|
|
342
|
+
return names;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** Turn `export default expr` into a synthetic `const` declaration. */
|
|
346
|
+
function exportAssignmentToStatement(record: ModuleRecord, assignment: ExportAssignment): Statement {
|
|
347
|
+
const name: Identifier = {
|
|
348
|
+
kind: SyntaxKind.Identifier,
|
|
349
|
+
text: `${record.prefix}default`,
|
|
350
|
+
start: assignment.start,
|
|
351
|
+
end: assignment.start,
|
|
352
|
+
};
|
|
353
|
+
record.exports.set("default", name.text);
|
|
354
|
+
const declaration: VariableDeclaration = {
|
|
355
|
+
kind: SyntaxKind.VariableDeclaration,
|
|
356
|
+
name,
|
|
357
|
+
exclamation: false,
|
|
358
|
+
initializer: assignment.expression,
|
|
359
|
+
start: assignment.start,
|
|
360
|
+
end: assignment.end,
|
|
361
|
+
};
|
|
362
|
+
const list: VariableDeclarationList = {
|
|
363
|
+
kind: SyntaxKind.VariableDeclarationList,
|
|
364
|
+
declarationKind: "const" as const,
|
|
365
|
+
declarations: [declaration],
|
|
366
|
+
start: assignment.start,
|
|
367
|
+
end: assignment.end,
|
|
368
|
+
};
|
|
369
|
+
const statement: VariableStatement = {
|
|
370
|
+
kind: SyntaxKind.VariableStatement,
|
|
371
|
+
declarationList: list,
|
|
372
|
+
modifiers: [],
|
|
373
|
+
start: assignment.start,
|
|
374
|
+
end: assignment.end,
|
|
375
|
+
};
|
|
376
|
+
return statement;
|
|
377
|
+
}
|
|
@@ -348,6 +348,9 @@ export const expressionMethods: ExpressionMethods = {
|
|
|
348
348
|
case TokenKind.ThisKeyword:
|
|
349
349
|
this.nextToken();
|
|
350
350
|
return { kind: SyntaxKind.ThisKeyword, start: token.start, end: token.end };
|
|
351
|
+
case TokenKind.SuperKeyword:
|
|
352
|
+
this.nextToken();
|
|
353
|
+
return { kind: SyntaxKind.Identifier, text: "super", start: token.start, end: token.end };
|
|
351
354
|
case TokenKind.OpenParen: {
|
|
352
355
|
this.nextToken();
|
|
353
356
|
const expression = this.parseExpression();
|