@idlizer/arktscgen 2.1.10-arktscgen-7 → 2.1.10-arktscgen-10
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/build/libarkts-copy/generator/options.json5 +107 -99
- package/build/libarkts-copy/native/meson.build +22 -14
- package/build/libarkts-copy/native/mingw.cross +1 -1
- package/build/libarkts-copy/native/src/bridges.cpp +1 -298
- package/build/libarkts-copy/native/src/common.cpp +286 -76
- package/build/libarkts-copy/native/src/common.h +0 -15
- package/build/libarkts-copy/package.json +12 -16
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +28 -61
- package/build/libarkts-copy/src/arkts-api/index.ts +0 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/OpaqueTypeNode.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +14 -0
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +25 -58
- package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +8 -13
- package/build/libarkts-copy/src/arkts-api/plugins.ts +3 -2
- package/build/libarkts-copy/src/arkts-api/static/global.ts +8 -1
- package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +9 -12
- package/build/libarkts-copy/src/arkts-api/utilities/performance.ts +99 -9
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +3 -0
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +68 -148
- package/build/libarkts-copy/src/arkts-api/visitor.ts +17 -3
- package/build/libarkts-copy/src/index.ts +0 -1
- package/build/libarkts-copy/src/plugin-utils.ts +2 -1
- package/build/libarkts-copy/src/reexport-for-generated.ts +2 -1
- package/build/libarkts-copy/src/utils.ts +4 -0
- package/lib/index.js +4599 -4366
- package/package.json +3 -4
- package/templates/Es2pandaNativeModule.ts +1 -0
- package/templates/peer.ts +1 -0
|
@@ -20,9 +20,7 @@ import {
|
|
|
20
20
|
passNode,
|
|
21
21
|
unpackNodeArray,
|
|
22
22
|
unpackNonNullableNode,
|
|
23
|
-
passString,
|
|
24
23
|
unpackString,
|
|
25
|
-
passStringArray,
|
|
26
24
|
unpackNode,
|
|
27
25
|
} from './private';
|
|
28
26
|
import {
|
|
@@ -30,20 +28,18 @@ import {
|
|
|
30
28
|
Es2pandaModifierFlags,
|
|
31
29
|
Es2pandaMethodDefinitionKind,
|
|
32
30
|
Es2pandaAstNodeType,
|
|
33
|
-
Es2pandaPluginDiagnosticType,
|
|
34
31
|
} from '../../../generated/Es2pandaEnums';
|
|
35
32
|
import type { AstNode } from '../peers/AstNode';
|
|
36
33
|
import {
|
|
37
|
-
|
|
34
|
+
AnnotationAllowed,
|
|
38
35
|
Identifier,
|
|
39
36
|
isConditionalExpression,
|
|
40
37
|
SourcePosition,
|
|
41
|
-
SourceRange,
|
|
42
|
-
SuggestionInfo,
|
|
43
38
|
VariableDeclarator,
|
|
44
39
|
} from '../../../generated';
|
|
45
40
|
import {
|
|
46
|
-
|
|
41
|
+
AnnotationUsage,
|
|
42
|
+
compiler,
|
|
47
43
|
ClassDefinition,
|
|
48
44
|
ClassProperty,
|
|
49
45
|
ETSModule,
|
|
@@ -63,7 +59,6 @@ import {
|
|
|
63
59
|
MemberExpression,
|
|
64
60
|
isMethodDefinition,
|
|
65
61
|
TypeNode,
|
|
66
|
-
DiagnosticKind
|
|
67
62
|
} from '../../../generated';
|
|
68
63
|
import { Config } from '../peers/Config';
|
|
69
64
|
import { Context } from '../peers/Context';
|
|
@@ -77,15 +72,8 @@ import { traceGlobal } from '../../tracer';
|
|
|
77
72
|
* @deprecated
|
|
78
73
|
*/
|
|
79
74
|
export function createETSModuleFromContext(): ETSModule {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
throw new Error(`Program is null for context ${global.context.toString(16)}`);
|
|
83
|
-
}
|
|
84
|
-
const ast = global.generatedEs2panda._ProgramAst(global.context, program);
|
|
85
|
-
if (ast === nullptr || ast === null) {
|
|
86
|
-
throw new Error(`AST is null for program ${program.toString(16)}`);
|
|
87
|
-
}
|
|
88
|
-
return new ETSModule(ast, Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE);
|
|
75
|
+
const program = compiler.contextProgram();
|
|
76
|
+
return program.getAstCasted();
|
|
89
77
|
}
|
|
90
78
|
|
|
91
79
|
/**
|
|
@@ -103,13 +91,8 @@ export function createETSModuleFromSource(
|
|
|
103
91
|
}
|
|
104
92
|
global.compilerContext = Context.createFromString(source);
|
|
105
93
|
proceedToState(state);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
throw new Error(`Program is null for ${source} 0x${global.compilerContext.peer.toString(16)}`);
|
|
109
|
-
return new ETSModule(
|
|
110
|
-
global.generatedEs2panda._ProgramAst(global.context, program),
|
|
111
|
-
Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE
|
|
112
|
-
);
|
|
94
|
+
const program = compiler.contextProgram();
|
|
95
|
+
return program.getAstCasted();
|
|
113
96
|
}
|
|
114
97
|
|
|
115
98
|
export function metaDatabase(fileName: string): string {
|
|
@@ -117,26 +100,31 @@ export function metaDatabase(fileName: string): string {
|
|
|
117
100
|
return `${fileName}.meta.json`;
|
|
118
101
|
}
|
|
119
102
|
|
|
120
|
-
export function checkErrors() {
|
|
121
|
-
if (
|
|
103
|
+
export function checkErrors(proceedTo?: string) {
|
|
104
|
+
if (compiler.contextState() === Es2pandaContextState.ES2PANDA_STATE_ERROR) {
|
|
122
105
|
traceGlobal(() => `Terminated due to compilation errors occured`);
|
|
123
|
-
console.log(unpackString(global.generatedEs2panda._GetAllErrorMessages(global.context)));
|
|
124
|
-
// global.es2panda._DestroyConfig(global.config)
|
|
125
|
-
throw new Error(`Compilation error`)
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function format(value: number): string {
|
|
130
|
-
return `${(value / 1024 / 1024 / 1024).toFixed(4)} GB`
|
|
131
|
-
}
|
|
132
106
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
107
|
+
const errorMessage = compiler.contextErrorMessage();
|
|
108
|
+
if (errorMessage === undefined) {
|
|
109
|
+
throwError(`Could not get ContextErrorMessage`);
|
|
110
|
+
}
|
|
111
|
+
const allErrorMessages = compiler.getAllErrorMessages();
|
|
112
|
+
if (allErrorMessages === undefined) {
|
|
113
|
+
throwError(`Could not get AllErrorMessages`);
|
|
114
|
+
}
|
|
115
|
+
const actionMsg = proceedTo ? " to " + proceedTo : ""
|
|
116
|
+
throwError([`Failed to proceed${actionMsg}`, errorMessage, allErrorMessages].join(`\n`));
|
|
117
|
+
}
|
|
136
118
|
}
|
|
137
119
|
|
|
138
|
-
export function proceedToState(state: Es2pandaContextState): void {
|
|
139
|
-
if (
|
|
120
|
+
export function proceedToState(state: Es2pandaContextState, _contextPtr?: KNativePointer, ignoreErrors = false): void {
|
|
121
|
+
if (compiler.contextState() === Es2pandaContextState.ES2PANDA_STATE_ERROR) {
|
|
122
|
+
NodeCache.clear();
|
|
123
|
+
if (!ignoreErrors) {
|
|
124
|
+
checkErrors(Es2pandaContextState[state]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (state <= compiler.contextState()) {
|
|
140
128
|
return;
|
|
141
129
|
}
|
|
142
130
|
NodeCache.clear();
|
|
@@ -146,17 +134,16 @@ export function proceedToState(state: Es2pandaContextState): void {
|
|
|
146
134
|
traceGlobal(() => `Proceeding to state ${Es2pandaContextState[state]}: done`);
|
|
147
135
|
const after = Date.now();
|
|
148
136
|
global.profiler.proceededToState(after - before);
|
|
149
|
-
if (
|
|
150
|
-
|
|
137
|
+
if (!ignoreErrors) {
|
|
138
|
+
checkErrors(Es2pandaContextState[state]);
|
|
151
139
|
}
|
|
152
|
-
checkErrors();
|
|
153
140
|
}
|
|
154
141
|
|
|
155
142
|
/** @deprecated Use {@link rebindContext} instead */
|
|
156
143
|
export function rebindSubtree(node: AstNode): void {
|
|
157
144
|
NodeCache.clear();
|
|
158
145
|
traceGlobal(() => `Rebind: start`);
|
|
159
|
-
|
|
146
|
+
compiler.astNodeRebind(node);
|
|
160
147
|
traceGlobal(() => `Rebind: done`);
|
|
161
148
|
checkErrors();
|
|
162
149
|
}
|
|
@@ -165,18 +152,14 @@ export function rebindSubtree(node: AstNode): void {
|
|
|
165
152
|
export function recheckSubtree(node: AstNode): void {
|
|
166
153
|
NodeCache.clear();
|
|
167
154
|
traceGlobal(() => `Recheck: start`);
|
|
168
|
-
|
|
155
|
+
compiler.astNodeRecheck(node);
|
|
169
156
|
traceGlobal(() => `Recheck: done`);
|
|
170
|
-
checkErrors();
|
|
171
157
|
}
|
|
172
158
|
|
|
173
159
|
export function rebindContext(context: KNativePointer = global.context): void {
|
|
174
160
|
NodeCache.clear();
|
|
175
161
|
traceGlobal(() => `Rebind: start`);
|
|
176
|
-
|
|
177
|
-
context,
|
|
178
|
-
global.generatedEs2panda._ProgramAst(context, global.generatedEs2panda._ContextProgram(context))
|
|
179
|
-
);
|
|
162
|
+
compiler.astNodeRebind(compiler.contextProgram().getAstCasted());
|
|
180
163
|
traceGlobal(() => `Rebind: done`);
|
|
181
164
|
checkErrors();
|
|
182
165
|
}
|
|
@@ -184,10 +167,7 @@ export function rebindContext(context: KNativePointer = global.context): void {
|
|
|
184
167
|
export function recheckContext(context: KNativePointer = global.context): void {
|
|
185
168
|
NodeCache.clear();
|
|
186
169
|
traceGlobal(() => `Recheck: start`);
|
|
187
|
-
|
|
188
|
-
context,
|
|
189
|
-
global.generatedEs2panda._ProgramAst(context, global.generatedEs2panda._ContextProgram(context))
|
|
190
|
-
);
|
|
170
|
+
compiler.astNodeRecheck(compiler.contextProgram().getAstCasted());
|
|
191
171
|
traceGlobal(() => `Recheck: done`);
|
|
192
172
|
checkErrors();
|
|
193
173
|
}
|
|
@@ -256,10 +236,6 @@ export function getPeerDecl(peer: KNativePointer): AstNode | undefined {
|
|
|
256
236
|
return unpackNonNullableNode(decl);
|
|
257
237
|
}
|
|
258
238
|
|
|
259
|
-
export function declarationFromIdentifier(node: Identifier): AstNode | undefined {
|
|
260
|
-
return unpackNode(global.generatedEs2panda._DeclarationFromIdentifier(global.context, node.peer));
|
|
261
|
-
}
|
|
262
|
-
|
|
263
239
|
export function resolveGensymVariableDeclaratorForDefaultParam(node: VariableDeclarator): Identifier | undefined {
|
|
264
240
|
const init = node.init;
|
|
265
241
|
if (
|
|
@@ -280,6 +256,14 @@ export function resolveGensymVariableDeclaratorForOptionalCall(node: VariableDec
|
|
|
280
256
|
return undefined;
|
|
281
257
|
}
|
|
282
258
|
|
|
259
|
+
export function getPeerIdentifierDecl(peer: KNativePointer): AstNode | undefined {
|
|
260
|
+
const decl = global.generatedEs2panda._DeclarationFromIdentifier(global.context, peer);
|
|
261
|
+
if (decl === nullptr) {
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
return unpackNonNullableNode(decl);
|
|
265
|
+
}
|
|
266
|
+
|
|
283
267
|
export function getPeerObjectDecl(peer: KNativePointer): AstNode | undefined {
|
|
284
268
|
const decl = global.es2panda._ClassVariableDeclaration(global.context, peer);
|
|
285
269
|
if (decl === nullptr) {
|
|
@@ -288,11 +272,28 @@ export function getPeerObjectDecl(peer: KNativePointer): AstNode | undefined {
|
|
|
288
272
|
return unpackNonNullableNode(decl);
|
|
289
273
|
}
|
|
290
274
|
|
|
275
|
+
export function getPeerMemberDecl(peer: KNativePointer): AstNode | undefined {
|
|
276
|
+
const decl = global.es2panda._DeclarationFromMemberExpression(global.context, peer);
|
|
277
|
+
if (decl === nullptr) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
return unpackNonNullableNode(decl);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function getPeerPropertyDecl(peer: KNativePointer): AstNode | undefined {
|
|
284
|
+
const decl = global.es2panda._DeclarationFromProperty(global.context, peer);
|
|
285
|
+
if (decl === nullptr) {
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
return unpackNonNullableNode(decl);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
|
|
291
292
|
export function getAnnotations(node: AstNode): readonly AnnotationUsage[] {
|
|
292
293
|
if (!isFunctionDeclaration(node) && !isScriptFunction(node) && !isClassDefinition(node)) {
|
|
293
294
|
throwError('for now annotations allowed only for: functionDeclaration, scriptFunction, classDefinition');
|
|
294
295
|
}
|
|
295
|
-
return
|
|
296
|
+
return new AnnotationAllowed(node.peer).annotations
|
|
296
297
|
}
|
|
297
298
|
|
|
298
299
|
export function getOriginalNode(node: AstNode): AstNode {
|
|
@@ -320,7 +321,7 @@ export function getJsDoc(node: AstNode): string | undefined {
|
|
|
320
321
|
// Use this function if you need
|
|
321
322
|
// the language level modifiers: public, declare, export, etc.
|
|
322
323
|
export function classDefinitionFlags(node: ClassDefinition): Es2pandaModifierFlags {
|
|
323
|
-
return
|
|
324
|
+
return node.modifierFlags
|
|
324
325
|
}
|
|
325
326
|
|
|
326
327
|
// Improve: ClassProperty's optional flag is set by AstNode's modifiers flags.
|
|
@@ -376,25 +377,6 @@ export function findStdlib(): string {
|
|
|
376
377
|
return `${sdk}/ets/stdlib`;
|
|
377
378
|
}
|
|
378
379
|
|
|
379
|
-
export function generateTsDeclarationsFromContext(
|
|
380
|
-
outputDeclEts: string,
|
|
381
|
-
outputEts: string,
|
|
382
|
-
exportAll: boolean,
|
|
383
|
-
isolated: boolean,
|
|
384
|
-
recordFile: string,
|
|
385
|
-
genAnnotations: boolean
|
|
386
|
-
): KInt {
|
|
387
|
-
return global.generatedEs2panda._GenerateTsDeclarationsFromContext(
|
|
388
|
-
global.context,
|
|
389
|
-
passString(outputDeclEts),
|
|
390
|
-
passString(outputEts),
|
|
391
|
-
exportAll,
|
|
392
|
-
isolated,
|
|
393
|
-
recordFile,
|
|
394
|
-
genAnnotations
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
380
|
export function setAllParents(ast: AstNode): void {
|
|
399
381
|
global.es2panda._AstNodeUpdateAll(global.context, ast.peer);
|
|
400
382
|
}
|
|
@@ -404,21 +386,21 @@ export function getProgramFromAstNode(node: AstNode): Program {
|
|
|
404
386
|
}
|
|
405
387
|
|
|
406
388
|
export function importDeclarationInsert(node: ETSImportDeclaration, program: Program): void {
|
|
407
|
-
|
|
389
|
+
compiler.insertETSImportDeclarationAndParse(program, node);
|
|
408
390
|
}
|
|
409
391
|
|
|
410
392
|
export function signatureReturnType(signature: KNativePointer): KNativePointer {
|
|
411
393
|
if (!signature) {
|
|
412
394
|
return nullptr;
|
|
413
395
|
}
|
|
414
|
-
return global.
|
|
396
|
+
return global.generatedEs2panda._SignatureReturnType(global.context, signature);
|
|
415
397
|
}
|
|
416
398
|
|
|
417
399
|
export function convertCheckerTypeToTypeNode(typePeer: KNativePointer | undefined): TypeNode | undefined {
|
|
418
400
|
if (!typePeer) {
|
|
419
401
|
return undefined;
|
|
420
402
|
}
|
|
421
|
-
return factory.createOpaqueTypeNode(global.
|
|
403
|
+
return factory.createOpaqueTypeNode(global.generatedEs2panda._TypeClone(global.context, typePeer));
|
|
422
404
|
}
|
|
423
405
|
|
|
424
406
|
export function originalSourcePositionString(node: AstNode | undefined) {
|
|
@@ -437,10 +419,6 @@ export function originalSourcePositionString(node: AstNode | undefined) {
|
|
|
437
419
|
return `[${program.absoluteName}${sourcePosition.toString()}]`;
|
|
438
420
|
}
|
|
439
421
|
|
|
440
|
-
export function generateStaticDeclarationsFromContext(outputPath: string): KInt {
|
|
441
|
-
return global.generatedEs2panda._GenerateStaticDeclarationsFromContext(global.context, passString(outputPath));
|
|
442
|
-
}
|
|
443
|
-
|
|
444
422
|
export function createTypeNodeFromTsType(node: AstNode): AstNode | undefined {
|
|
445
423
|
const typeAnnotation = global.es2panda._CreateTypeNodeFromTsType(global.context, node.peer);
|
|
446
424
|
if (typeAnnotation === nullptr) {
|
|
@@ -449,62 +427,6 @@ export function createTypeNodeFromTsType(node: AstNode): AstNode | undefined {
|
|
|
449
427
|
return unpackNonNullableNode(typeAnnotation);
|
|
450
428
|
}
|
|
451
429
|
|
|
452
|
-
export function createSourcePosition(index: KUInt, line: KUInt): SourcePosition {
|
|
453
|
-
return new SourcePosition(global.generatedEs2panda._CreateSourcePosition(global.context, index, line));
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
export function createSourceRange(start: SourcePosition, end: SourcePosition): SourceRange {
|
|
457
|
-
return new SourceRange(global.generatedEs2panda._CreateSourceRange(global.context, start.peer, end.peer));
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
export function createDiagnosticInfo(
|
|
461
|
-
kind: DiagnosticKind,
|
|
462
|
-
position: SourcePosition,
|
|
463
|
-
...args: string[]
|
|
464
|
-
): DiagnosticInfo {
|
|
465
|
-
return new DiagnosticInfo(
|
|
466
|
-
global.generatedEs2panda._CreateDiagnosticInfo(
|
|
467
|
-
global.context,
|
|
468
|
-
kind.peer,
|
|
469
|
-
passStringArray(args),
|
|
470
|
-
args.length,
|
|
471
|
-
position.peer
|
|
472
|
-
)
|
|
473
|
-
);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
export function createSuggestionInfo(
|
|
477
|
-
kind: DiagnosticKind,
|
|
478
|
-
substitutionCode: string,
|
|
479
|
-
title: string,
|
|
480
|
-
range: SourceRange,
|
|
481
|
-
...args: string[]
|
|
482
|
-
): SuggestionInfo {
|
|
483
|
-
return new SuggestionInfo(
|
|
484
|
-
global.generatedEs2panda._CreateSuggestionInfo(
|
|
485
|
-
global.context,
|
|
486
|
-
kind.peer,
|
|
487
|
-
passStringArray(args),
|
|
488
|
-
args.length,
|
|
489
|
-
substitutionCode,
|
|
490
|
-
title,
|
|
491
|
-
range.peer
|
|
492
|
-
)
|
|
493
|
-
);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
export function createDiagnosticKind(message: string, type: Es2pandaPluginDiagnosticType): DiagnosticKind {
|
|
497
|
-
return new DiagnosticKind(global.es2panda._CreateDiagnosticKind(global.context, message, type));
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
export function logDiagnostic(kind: DiagnosticKind, pos: SourcePosition, ...args: string[]): void {
|
|
501
|
-
global.es2panda._LogDiagnostic(global.context, kind.peer, passStringArray(args), args.length, pos.peer);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
export function logDiagnosticWithSuggestion(diagnosticInfo: DiagnosticInfo, suggestionInfo: SuggestionInfo): void {
|
|
505
|
-
global.generatedEs2panda._LogDiagnosticWithSuggestion(global.context, diagnosticInfo.peer, suggestionInfo.peer);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
430
|
export function filterNodes(node: AstNode, filter: string, deeperAfterMatch: boolean): AstNode[] {
|
|
509
431
|
return unpackNodeArray(global.es2panda._FilterNodes(global.context, passNode(node), filter, deeperAfterMatch));
|
|
510
432
|
}
|
|
@@ -521,10 +443,8 @@ export function filterNodesByTypes(node: AstNode, types: Es2pandaAstNodeType[]):
|
|
|
521
443
|
return unpackNodeArray(global.es2panda._FilterNodes3(global.context, passNode(node), typesArray, types.length));
|
|
522
444
|
}
|
|
523
445
|
|
|
524
|
-
export function
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
export function MemFinalize() {
|
|
529
|
-
global.es2panda._MemFinalize()
|
|
446
|
+
export function jumpFromETSTypeReferenceToTSTypeAliasDeclarationTypeAnnotation(node: AstNode): AstNode | undefined {
|
|
447
|
+
return unpackNode(
|
|
448
|
+
global.es2panda._JumpFromETSTypeReferenceToTSTypeAliasDeclarationTypeAnnotation(global.context, passNode(node))
|
|
449
|
+
);
|
|
530
450
|
}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
ArrayExpression,
|
|
20
20
|
ArrowFunctionExpression,
|
|
21
21
|
AssignmentExpression,
|
|
22
|
+
AwaitExpression,
|
|
22
23
|
BinaryExpression,
|
|
23
24
|
BlockExpression,
|
|
24
25
|
BlockStatement,
|
|
@@ -764,6 +765,7 @@ function visitClassProperty(node: ClassProperty, visitor: Visitor): ClassPropert
|
|
|
764
765
|
result.onUpdate(node);
|
|
765
766
|
return result;
|
|
766
767
|
}
|
|
768
|
+
node.setKey(newKey);
|
|
767
769
|
node.setValue(newValue);
|
|
768
770
|
node.setTypeAnnotation(newTypeAnnotation);
|
|
769
771
|
node.setAnnotations(newAnnotations);
|
|
@@ -773,12 +775,12 @@ function visitClassProperty(node: ClassProperty, visitor: Visitor): ClassPropert
|
|
|
773
775
|
|
|
774
776
|
function visitProperty(node: Property, visitor: Visitor): Property {
|
|
775
777
|
global.updateTracker.push();
|
|
778
|
+
const oldKey = node.key;
|
|
776
779
|
const newKey = nodeVisitor(node.key, visitor);
|
|
777
780
|
const newValue = nodeVisitor(node.value, visitor);
|
|
778
781
|
if (global.updateTracker.check()) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
return result;
|
|
782
|
+
node.setKey(newKey);
|
|
783
|
+
node.setValue(newValue);
|
|
782
784
|
}
|
|
783
785
|
return node;
|
|
784
786
|
}
|
|
@@ -957,6 +959,17 @@ function visitClassStaticBlock(node: ClassStaticBlock, visitor: Visitor): ClassS
|
|
|
957
959
|
return node;
|
|
958
960
|
}
|
|
959
961
|
|
|
962
|
+
function visitAwaitExpression(node: AwaitExpression, visitor: Visitor): AwaitExpression {
|
|
963
|
+
global.updateTracker.push();
|
|
964
|
+
const newArgument = nodeVisitor(node.argument, visitor);
|
|
965
|
+
if (global.updateTracker.check()) {
|
|
966
|
+
const result = factory.createAwaitExpression(newArgument);
|
|
967
|
+
result.onUpdate(node);
|
|
968
|
+
return result;
|
|
969
|
+
}
|
|
970
|
+
return node;
|
|
971
|
+
}
|
|
972
|
+
|
|
960
973
|
const visitsTable: (((node: any, visitor: Visitor) => any) | undefined)[] = [];
|
|
961
974
|
|
|
962
975
|
export function initVisitsTable(): void {
|
|
@@ -1017,6 +1030,7 @@ export function initVisitsTable(): void {
|
|
|
1017
1030
|
visitsTable[Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER_DECLARATION] = visitTSTypeParameterDeclaration;
|
|
1018
1031
|
visitsTable[Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER_INSTANTIATION] = visitTSTypeParameterInstantiation;
|
|
1019
1032
|
visitsTable[Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_STATIC_BLOCK] = visitClassStaticBlock;
|
|
1033
|
+
visitsTable[Es2pandaAstNodeType.AST_NODE_TYPE_AWAIT_EXPRESSION] = visitAwaitExpression;
|
|
1020
1034
|
}
|
|
1021
1035
|
|
|
1022
1036
|
initVisitsTable();
|
|
@@ -33,7 +33,6 @@ export * from './arkts-api/node-utilities/ArkTsConfig';
|
|
|
33
33
|
export * from './arkts-api/peers/AstNode';
|
|
34
34
|
export * from './arkts-api/peers/Config';
|
|
35
35
|
export * from './arkts-api/peers/Context';
|
|
36
|
-
export { GlobalContext } from './arkts-api/peers/Context';
|
|
37
36
|
export * from './arkts-api/peers/ExternalSource';
|
|
38
37
|
export * from './arkts-api/peers/ImportPathManager';
|
|
39
38
|
export * from './arkts-api/peers/Options';
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
ProgramProvider,
|
|
26
26
|
CompilationOptions,
|
|
27
27
|
PluginContextImpl,
|
|
28
|
+
Es2pandaCompilationMode,
|
|
28
29
|
} from './arkts-api';
|
|
29
30
|
import { Tracer } from './tracer';
|
|
30
31
|
import { global } from "./arkts-api/static/global";
|
|
@@ -114,7 +115,7 @@ export function runTransformer(
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
function isProgramForCodegeneration(program: Program, isMainProgram: boolean): boolean {
|
|
117
|
-
if (
|
|
118
|
+
if (arktsGlobal.configObj?.compilationMode != Es2pandaCompilationMode.COMPILATION_MODE_GEN_ABC_FOR_EXTERNAL_SOURCE) {
|
|
118
119
|
return isMainProgram;
|
|
119
120
|
}
|
|
120
121
|
return program.isGenAbcForExternal;
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
export { KNativePointer } from '@koalaui/interop';
|
|
16
|
+
export { ArktsObject, isSameNativeObject } from './arkts-api/peers/ArktsObject';
|
|
16
17
|
export { AstNode } from './arkts-api/peers/AstNode';
|
|
17
18
|
export { Config } from './arkts-api/peers/Config';
|
|
18
19
|
export { Context, GlobalContext } from './arkts-api/peers/Context';
|
|
19
|
-
export { ArktsObject, isSameNativeObject } from './arkts-api/peers/ArktsObject';
|
|
20
20
|
export { NodeCache } from './arkts-api/node-cache';
|
|
21
|
+
export { ExternalSource } from './arkts-api/peers/ExternalSource';
|
|
21
22
|
export {
|
|
22
23
|
passNode,
|
|
23
24
|
unpackNonNullableNode,
|
|
@@ -245,3 +245,7 @@ export function filterSource(text: string): string {
|
|
|
245
245
|
// console.error(dumperUnwrappers.reduceRight((code, f) => f(code), text).split('\n').map((it, index) => `${`${index + 1}`.padStart(4)} |${it}`).join('\n'))
|
|
246
246
|
return dumperUnwrappers.reduceRight((code, f) => f(code), text);
|
|
247
247
|
}
|
|
248
|
+
|
|
249
|
+
export function getEnumName(enumType: any, value: number): string | undefined {
|
|
250
|
+
return enumType[value];
|
|
251
|
+
}
|