@idlizer/arktscgen 2.1.9-arktscgen-5 → 2.1.9-arktscgen-8
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 +151 -0
- package/build/libarkts-copy/native/meson.build +11 -12
- package/build/libarkts-copy/native/meson_options.txt +1 -1
- package/build/libarkts-copy/native/mingw.cross +14 -0
- package/build/libarkts-copy/native/src/bridges.cc +77 -1
- package/build/libarkts-copy/native/src/common.cc +5 -5
- package/build/libarkts-copy/native/src/generated/bridges.cc +312 -33
- package/build/libarkts-copy/package.json +24 -20
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +19 -1
- package/build/libarkts-copy/src/arkts-api/ChainExpressionFilter.ts +2 -1
- package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +18 -12
- package/build/libarkts-copy/src/arkts-api/ProgramProvider.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +15 -26
- package/build/libarkts-copy/src/arkts-api/index.ts +2 -4
- package/build/libarkts-copy/src/arkts-api/node-utilities/BlockStatement.ts +0 -4
- package/build/libarkts-copy/src/arkts-api/node-utilities/CallExpression.ts +1 -22
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDefinition.ts +7 -8
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassProperty.ts +1 -22
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSFunctionType.ts +2 -5
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSImportDeclaration.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSModule.ts +44 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSParameterExpression.ts +1 -4
- package/build/libarkts-copy/src/arkts-api/node-utilities/MethodDefinition.ts +3 -7
- package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +10 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +11 -7
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +3 -6
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +13 -12
- package/build/libarkts-copy/src/arkts-api/peers/Config.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +35 -4
- package/build/libarkts-copy/src/arkts-api/plugins.ts +12 -3
- package/build/libarkts-copy/src/arkts-api/static/global.ts +2 -2
- package/build/libarkts-copy/src/{wrapper-compat/arkts-api → arkts-api}/static/globalUtils.ts +4 -4
- package/build/libarkts-copy/src/arkts-api/static/profiler.ts +0 -8
- package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +57 -0
- package/build/libarkts-copy/src/arkts-api/utilities/nativePtrDecoder.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +6 -8
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +153 -29
- package/build/libarkts-copy/src/arkts-api/visitor.ts +16 -10
- package/build/libarkts-copy/src/checkSdk.ts +15 -0
- package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +343 -321
- package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +93 -12
- package/build/libarkts-copy/src/generated/factory.ts +38 -25
- package/build/libarkts-copy/src/generated/index.ts +2 -0
- package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +15 -3
- package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/CallExpression.ts +10 -2
- package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +11 -2
- package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +20 -4
- package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +10 -2
- package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +12 -9
- package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSIntrinsicNode.ts +77 -0
- package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSModule.ts +3 -1
- package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +29 -5
- package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +12 -3
- package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +14 -2
- package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/OverloadDeclaration.ts +103 -0
- package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/Program.ts +8 -0
- package/build/libarkts-copy/src/generated/peers/Property.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +26 -9
- package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +12 -3
- package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSImportType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSInferType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +12 -3
- package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSThisType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +29 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TryStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +11 -3
- package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +1 -1
- package/build/libarkts-copy/src/index.ts +1 -4
- package/build/libarkts-copy/src/plugin-utils.ts +37 -37
- package/build/libarkts-copy/src/reexport-for-generated.ts +7 -0
- package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +14 -14
- package/build/libarkts-copy/src/ts-api/index.ts +1 -1
- package/build/libarkts-copy/src/ts-api/types.ts +56 -56
- package/build/libarkts-copy/src/ts-api/utilities/private.ts +6 -6
- package/build/libarkts-copy/src/ts-api/utilities/public.ts +3 -3
- package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +4 -4
- package/build/libarkts-copy/src/utils.ts +13 -159
- package/build/libarkts-copy/src/wrapper-compat/README.md +4 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/index.ts +3 -4
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrayExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrowFunctionExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/AssignmentExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/BlockStatement.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/CallExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDefinition.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassProperty.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSFunctionType.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSImportDeclaration.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSParameterExpression.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ExpressionStatement.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/IfStatement.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MemberExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MethodDefinition.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/NumberLiteral.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ObjectExpression.ts +3 -3
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/Property.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ScriptFunction.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/StructDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSInterfaceDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeParameter.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TryStatement.ts +3 -3
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclarator.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Diagnostic.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticKind.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/ImportPathManager.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Program.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourceRange.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SuggestionInfo.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/to-be-generated/MemberExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/types.ts +10 -11
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/nativePtrDecoder.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/private.ts +4 -4
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/public.ts +6 -6
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/visitor.ts +10 -10
- package/lib/index.js +7194 -7097
- package/package.json +2 -2
- package/templates/Es2pandaNativeModule.ts +1 -1
- package/templates/bridges.cc +5 -0
- package/build/libarkts-copy/src/arkts-api/CheckedBackFilter.ts +0 -131
- package/build/libarkts-copy/src/arkts-api/CompileWithCache.ts +0 -193
- package/build/libarkts-copy/src/arkts-api/InferVoidReturnType.ts +0 -89
- package/build/libarkts-copy/src/arkts-api/SetBaseOverloads.ts +0 -44
- package/build/libarkts-copy/src/arkts-api/node-utilities/AnnotationUsage.ts +0 -29
- package/build/libarkts-copy/src/arkts-api/node-utilities/ArrowFunctionExpression.ts +0 -49
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDeclaration.ts +0 -54
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +0 -68
- package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclaration.ts +0 -54
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/ArktsObject.ts +0 -45
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Config.ts +0 -53
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Context.ts +0 -60
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourcePosition.ts +0 -38
|
@@ -41,12 +41,12 @@ export class global {
|
|
|
41
41
|
global._config = undefined
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
//
|
|
44
|
+
// Improve: rename to contextPeer
|
|
45
45
|
public static get context(): KNativePointer {
|
|
46
46
|
return global.compilerContext?.peer ?? throwError('Global.context not initialized')
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
//
|
|
49
|
+
// Improve: rename to context when the pointer valued one is eliminated
|
|
50
50
|
public static compilerContext: Context
|
|
51
51
|
|
|
52
52
|
private static _es2panda: Es2pandaNativeModule | undefined = undefined
|
package/build/libarkts-copy/src/{wrapper-compat/arkts-api → arkts-api}/static/globalUtils.ts
RENAMED
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
import { KNativePointer } from "@koalaui/interop";
|
|
17
17
|
import { Context } from "../peers/Context";
|
|
18
18
|
import { global } from "./global";
|
|
19
|
-
import {
|
|
19
|
+
import { NodeCache } from "../node-cache"
|
|
20
20
|
|
|
21
21
|
export function getOrUpdateGlobalContext(peer: KNativePointer): Context {
|
|
22
22
|
if (!global.compilerContext || global.context !== peer) {
|
|
23
|
-
|
|
24
|
-
global.compilerContext = new Context(peer)
|
|
23
|
+
NodeCache.clear();
|
|
24
|
+
global.compilerContext = new Context(peer);
|
|
25
25
|
}
|
|
26
|
-
return global.compilerContext
|
|
26
|
+
return global.compilerContext;
|
|
27
27
|
}
|
|
@@ -43,7 +43,6 @@ interface PerformanceData {
|
|
|
43
43
|
|
|
44
44
|
visitedNodes: number
|
|
45
45
|
createdNodes: number
|
|
46
|
-
restartTime: number
|
|
47
46
|
proceedTime: number
|
|
48
47
|
totalTime: number
|
|
49
48
|
|
|
@@ -67,7 +66,6 @@ export class Profiler implements PerformanceData {
|
|
|
67
66
|
filePath: string = ""
|
|
68
67
|
visitedNodes: number = 0
|
|
69
68
|
createdNodes: number = 0
|
|
70
|
-
restartTime: number = 0
|
|
71
69
|
proceedTime: number = 0
|
|
72
70
|
totalTime: number = 0
|
|
73
71
|
pluginsByName: Record<string, PluginData> = {}
|
|
@@ -115,10 +113,6 @@ export class Profiler implements PerformanceData {
|
|
|
115
113
|
this.getPluginData(pluginName, state).transformTimeDeps += consumedTime
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
restarted(consumedTime: number) {
|
|
119
|
-
this.restartTime += consumedTime
|
|
120
|
-
}
|
|
121
|
-
|
|
122
116
|
proceededToState(consumedTime: number) {
|
|
123
117
|
this.proceedTime += consumedTime
|
|
124
118
|
}
|
|
@@ -129,7 +123,6 @@ export class Profiler implements PerformanceData {
|
|
|
129
123
|
|
|
130
124
|
this.visitedNodes = 0
|
|
131
125
|
this.createdNodes = 0
|
|
132
|
-
this.restartTime = 0
|
|
133
126
|
this.proceedTime = 0
|
|
134
127
|
this.totalTime = 0
|
|
135
128
|
this.pluginsByName = {}
|
|
@@ -168,7 +161,6 @@ export class Profiler implements PerformanceData {
|
|
|
168
161
|
filePath: this.filePath,
|
|
169
162
|
visitedNodes: savedData.data.map(it => it.visitedNodes).reduce((sum, it) => sum + it),
|
|
170
163
|
createdNodes: savedData.data.map(it => it.createdNodes).reduce((sum, it) => sum + it),
|
|
171
|
-
restartTime: savedData.data.map(it => it.restartTime).reduce((sum, it) => sum + it),
|
|
172
164
|
proceedTime: savedData.data.map(it => it.proceedTime).reduce((sum, it) => sum + it),
|
|
173
165
|
totalTime: savedData.data.map(it => it.totalTime).reduce((sum, it) => sum + it),
|
|
174
166
|
pluginsByName: {}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type {
|
|
17
|
+
ETSModule,
|
|
18
|
+
MethodDefinition,
|
|
19
|
+
ScriptFunction,
|
|
20
|
+
} from "../../generated"
|
|
21
|
+
import { Es2pandaModuleFlag } from "../../generated/Es2pandaEnums"
|
|
22
|
+
import { global, KNativePointer } from "../../reexport-for-generated"
|
|
23
|
+
|
|
24
|
+
export function extension_ETSModuleGetNamespaceFlag(this: ETSModule): Es2pandaModuleFlag {
|
|
25
|
+
return (this.isETSScript ? Es2pandaModuleFlag.MODULE_FLAG_ETSSCRIPT : 0)
|
|
26
|
+
+ (this.isNamespace ? Es2pandaModuleFlag.MODULE_FLAG_NAMESPACE : 0)
|
|
27
|
+
+ (this.isNamespaceChainLastNode ? Es2pandaModuleFlag.MODULE_FLAG_NAMESPACE_CHAIN_LAST_NODE : 0)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function extension_MethodDefinitionSetChildrenParentPtr(this: MethodDefinition) {
|
|
31
|
+
global.es2panda._AstNodeSetChildrenParentPtr(global.context, this.peer)
|
|
32
|
+
const overloads = this.overloads
|
|
33
|
+
for (const overload of overloads) {
|
|
34
|
+
overload.setBaseOverloadMethod(this)
|
|
35
|
+
overload.parent = this // overloads are not listed as children in native
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function extension_MethodDefinitionOnUpdate(this: MethodDefinition, original: MethodDefinition): void {
|
|
40
|
+
this.setChildrenParentPtr()
|
|
41
|
+
// Improve: Update modifiers only for specific AST nodes in the generated factory code
|
|
42
|
+
this.modifierFlags = original.modifierFlags
|
|
43
|
+
global.generatedEs2panda._AstNodeSetOriginalNode(global.context, this.peer, original.originalPeer)
|
|
44
|
+
global.generatedEs2panda._AstNodeSetParent(global.context, this.peer, global.generatedEs2panda._AstNodeParent(global.context, original.peer))
|
|
45
|
+
const originalBase = original.baseOverloadMethod
|
|
46
|
+
if (originalBase) {
|
|
47
|
+
this.setBaseOverloadMethod(originalBase)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function extension_ScriptFunctionGetPreferredReturnTypePointer(this: ScriptFunction): KNativePointer {
|
|
52
|
+
return global.es2panda._Checker_ScriptFunctionGetPreferredReturnType(global.context, this.peer)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function extension_ScriptFunctionSetPreferredReturnTypePointer(this: ScriptFunction, typePointer: KNativePointer): void {
|
|
56
|
+
global.es2panda._Checker_ScriptFunctionSetPreferredReturnType(global.context, this.peer, typePointer)
|
|
57
|
+
}
|
|
@@ -61,7 +61,7 @@ export class NativePtrDecoder extends ArrayDecoder<pointer> {
|
|
|
61
61
|
return global.interop._GetPtrVectorSize(blob)
|
|
62
62
|
}
|
|
63
63
|
disposeArray(blob: pointer): void {
|
|
64
|
-
//
|
|
64
|
+
// Improve:
|
|
65
65
|
}
|
|
66
66
|
getArrayElement(blob: pointer, index: int32): pointer {
|
|
67
67
|
return global.interop._GetPtrVectorElement(blob, index)
|
|
@@ -47,15 +47,15 @@ export function assertValidPeer(peer: KPtr, expectedKind: Es2pandaAstNodeType):
|
|
|
47
47
|
if (global.validatePeerTypes) {
|
|
48
48
|
const peerType = global.generatedEs2panda._AstNodeTypeConst(global.context, peer)
|
|
49
49
|
if (peerType === Es2pandaAstNodeType.AST_NODE_TYPE_STRUCT_DECLARATION && expectedKind === Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DECLARATION) {
|
|
50
|
-
//
|
|
50
|
+
// Improve: Struct is a child class of Class
|
|
51
51
|
return
|
|
52
52
|
}
|
|
53
53
|
if (peerType === Es2pandaAstNodeType.AST_NODE_TYPE_ETS_IMPORT_DECLARATION && expectedKind === Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_DECLARATION) {
|
|
54
|
-
//
|
|
54
|
+
// Improve: ETSImportDeclaration is a child of a ImportDeclaration
|
|
55
55
|
return
|
|
56
56
|
}
|
|
57
57
|
if (peerType === Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE && expectedKind === Es2pandaAstNodeType.AST_NODE_TYPE_BLOCK_STATEMENT) {
|
|
58
|
-
//
|
|
58
|
+
// Improve: ETSModule is a child of a BlockStatement
|
|
59
59
|
return
|
|
60
60
|
}
|
|
61
61
|
if (peerType !== expectedKind) {
|
|
@@ -122,12 +122,12 @@ export function unpackString(peer: KNativePointer): string {
|
|
|
122
122
|
return global.interop._RawUtf8ToString(peer)
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
//
|
|
125
|
+
// Improve: use direct string arguments instead.
|
|
126
126
|
export function passString(str: string | undefined): string {
|
|
127
127
|
return str ?? ""
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
//
|
|
130
|
+
// Improve: use direct string arguments instead.
|
|
131
131
|
export function passStringArray(strings: readonly string[]): string[] {
|
|
132
132
|
return withStringArray(strings, (it: string[]) => it)
|
|
133
133
|
}
|
|
@@ -146,9 +146,7 @@ export function updateNodeByNode<T extends ArktsObject>(node: T, original: T): T
|
|
|
146
146
|
if (original.peer === nullptr) {
|
|
147
147
|
throwError('update called on NULLPTR')
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
global.generatedEs2panda._AstNodeSetParent(global.context, node.peer, global.generatedEs2panda._AstNodeParent(global.context, original.peer))
|
|
151
|
-
global.es2panda._AstNodeSetChildrenParentPtr(global.context, node.peer)
|
|
149
|
+
node.onUpdate(original)
|
|
152
150
|
return node
|
|
153
151
|
}
|
|
154
152
|
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
import { global } from "../static/global"
|
|
17
17
|
import { isNumber, throwError, withWarning } from "../../utils"
|
|
18
|
-
import { KNativePointer, nullptr } from "@koalaui/interop"
|
|
19
|
-
import { passNode, passNodeArray, unpackNodeArray, unpackNonNullableNode } from "./private"
|
|
20
|
-
import { Es2pandaContextState, Es2pandaModifierFlags } from "../../generated/Es2pandaEnums"
|
|
18
|
+
import { KNativePointer, nullptr, KInt} from "@koalaui/interop"
|
|
19
|
+
import { passNode, passNodeArray, unpackNodeArray, unpackNonNullableNode, passString, unpackString } from "./private"
|
|
20
|
+
import { Es2pandaContextState, Es2pandaModifierFlags, Es2pandaMethodDefinitionKind, Es2pandaPrimitiveType } from "../../generated/Es2pandaEnums"
|
|
21
21
|
import type { AstNode } from "../peers/AstNode"
|
|
22
22
|
import { isSameNativeObject } from "../peers/ArktsObject"
|
|
23
23
|
import {
|
|
@@ -30,13 +30,30 @@ import {
|
|
|
30
30
|
isMemberExpression,
|
|
31
31
|
isScriptFunction,
|
|
32
32
|
isIdentifier,
|
|
33
|
-
isETSModule
|
|
33
|
+
isETSModule,
|
|
34
|
+
ImportSpecifier,
|
|
35
|
+
Program,
|
|
36
|
+
isObjectExpression,
|
|
37
|
+
ETSImportDeclaration,
|
|
38
|
+
isProperty,
|
|
39
|
+
isTSInterfaceDeclaration,
|
|
40
|
+
isNumberLiteral,
|
|
41
|
+
Property,
|
|
42
|
+
MemberExpression,
|
|
43
|
+
isMethodDefinition,
|
|
44
|
+
TypeNode,
|
|
34
45
|
} from "../../generated"
|
|
35
46
|
import { Config } from "../peers/Config"
|
|
36
47
|
import { Context } from "../peers/Context"
|
|
37
48
|
import { NodeCache } from "../node-cache"
|
|
38
49
|
import { listPrograms } from "../plugins"
|
|
50
|
+
import { factory } from "../factory/nodeFactory"
|
|
39
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Improve: Replace or remove with better naming
|
|
54
|
+
*
|
|
55
|
+
* @deprecated
|
|
56
|
+
*/
|
|
40
57
|
export function createETSModuleFromContext(): ETSModule {
|
|
41
58
|
let program = global.es2panda._ContextProgram(global.context)
|
|
42
59
|
if (program == nullptr) {
|
|
@@ -50,6 +67,12 @@ export function createETSModuleFromContext(): ETSModule {
|
|
|
50
67
|
return new ETSModule(ast)
|
|
51
68
|
}
|
|
52
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Now used only in tests
|
|
72
|
+
* Improve: Remove or replace with better method
|
|
73
|
+
*
|
|
74
|
+
* @deprecated
|
|
75
|
+
*/
|
|
53
76
|
export function createETSModuleFromSource(
|
|
54
77
|
source: string,
|
|
55
78
|
state: Es2pandaContextState = Es2pandaContextState.ES2PANDA_STATE_PARSED,
|
|
@@ -70,22 +93,10 @@ export function metaDatabase(fileName: string): string {
|
|
|
70
93
|
return `${fileName}.meta.json`
|
|
71
94
|
}
|
|
72
95
|
|
|
73
|
-
export function updateETSModuleByStatements(
|
|
74
|
-
node: ETSModule,
|
|
75
|
-
statements: readonly AstNode[],
|
|
76
|
-
): ETSModule {
|
|
77
|
-
if (isSameNativeObject(statements, node.statements)) {
|
|
78
|
-
return node
|
|
79
|
-
}
|
|
80
|
-
global.generatedEs2panda._BlockStatementSetStatements(global.context, node.peer, passNodeArray(statements), statements.length)
|
|
81
|
-
return node
|
|
82
|
-
}
|
|
83
|
-
|
|
84
96
|
export function checkErrors() {
|
|
85
97
|
if (global.es2panda._ContextState(global.context) === Es2pandaContextState.ES2PANDA_STATE_ERROR) {
|
|
86
|
-
console.log()
|
|
87
|
-
global.es2panda._DestroyConfig(global.config)
|
|
88
|
-
console.log()
|
|
98
|
+
console.log(unpackString(global.es2panda._GetAllErrorMessages(global.context)))
|
|
99
|
+
// global.es2panda._DestroyConfig(global.config)
|
|
89
100
|
process.exit(1)
|
|
90
101
|
}
|
|
91
102
|
}
|
|
@@ -102,27 +113,38 @@ export function proceedToState(state: Es2pandaContextState): void {
|
|
|
102
113
|
checkErrors()
|
|
103
114
|
}
|
|
104
115
|
|
|
105
|
-
|
|
106
|
-
|
|
116
|
+
/** @deprecated Use {@link rebindContext} instead */
|
|
117
|
+
export function rebindSubtree(node: AstNode): void {
|
|
118
|
+
global.es2panda._AstNodeRebind(global.context, node.peer)
|
|
119
|
+
checkErrors()
|
|
107
120
|
}
|
|
108
121
|
|
|
122
|
+
/** @deprecated Use {@link recheckSubtree} instead */
|
|
109
123
|
export function recheckSubtree(node: AstNode): void {
|
|
110
124
|
global.es2panda._AstNodeRecheck(global.context, node.peer)
|
|
111
125
|
checkErrors()
|
|
112
126
|
}
|
|
113
127
|
|
|
114
|
-
export function
|
|
115
|
-
global.es2panda._AstNodeRebind(
|
|
128
|
+
export function rebindContext(context: KNativePointer = global.context): void {
|
|
129
|
+
global.es2panda._AstNodeRebind(
|
|
130
|
+
context,
|
|
131
|
+
global.es2panda._ProgramAst(
|
|
132
|
+
context,
|
|
133
|
+
global.es2panda._ContextProgram(
|
|
134
|
+
context
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
)
|
|
116
138
|
checkErrors()
|
|
117
139
|
}
|
|
118
140
|
|
|
119
|
-
export function recheckContext(context: KNativePointer): void {
|
|
141
|
+
export function recheckContext(context: KNativePointer = global.context): void {
|
|
120
142
|
global.es2panda._AstNodeRecheck(
|
|
121
143
|
context,
|
|
122
144
|
global.es2panda._ProgramAst(
|
|
123
145
|
context,
|
|
124
146
|
global.es2panda._ContextProgram(
|
|
125
|
-
context
|
|
147
|
+
context,
|
|
126
148
|
)
|
|
127
149
|
)
|
|
128
150
|
)
|
|
@@ -131,9 +153,58 @@ export function recheckContext(context: KNativePointer): void {
|
|
|
131
153
|
|
|
132
154
|
export function getDecl(node: AstNode): AstNode | undefined {
|
|
133
155
|
if (isMemberExpression(node)) {
|
|
134
|
-
return
|
|
156
|
+
return getDeclFromArrayOrObjectMember(node)
|
|
157
|
+
}
|
|
158
|
+
if (isObjectExpression(node)) {
|
|
159
|
+
return getPeerObjectDecl(passNode(node))
|
|
160
|
+
}
|
|
161
|
+
const decl = getPeerDecl(passNode(node))
|
|
162
|
+
if (!!decl) {
|
|
163
|
+
return decl
|
|
135
164
|
}
|
|
136
|
-
|
|
165
|
+
if (!!node.parent && isProperty(node.parent)) {
|
|
166
|
+
return getDeclFromProperty(node.parent)
|
|
167
|
+
}
|
|
168
|
+
return undefined
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function getDeclFromProperty(node: Property): AstNode | undefined {
|
|
172
|
+
if (!node.key) {
|
|
173
|
+
return undefined
|
|
174
|
+
}
|
|
175
|
+
if (!!node.parent && !isObjectExpression(node.parent)) {
|
|
176
|
+
return getPeerDecl(passNode(node.key))
|
|
177
|
+
}
|
|
178
|
+
return getDeclFromObjectExpressionProperty(node)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function getDeclFromObjectExpressionProperty(node: Property): AstNode | undefined {
|
|
182
|
+
const declNode = getPeerObjectDecl(passNode(node.parent))
|
|
183
|
+
if (!declNode || !node.key || !isIdentifier(node.key)) {
|
|
184
|
+
return undefined
|
|
185
|
+
}
|
|
186
|
+
let body: readonly AstNode[] = []
|
|
187
|
+
if (isClassDefinition(declNode)) {
|
|
188
|
+
body = declNode.body
|
|
189
|
+
} else if (isTSInterfaceDeclaration(declNode)) {
|
|
190
|
+
body = declNode.body?.body ?? []
|
|
191
|
+
}
|
|
192
|
+
return body.find(
|
|
193
|
+
(statement) =>
|
|
194
|
+
isMethodDefinition(statement) &&
|
|
195
|
+
statement.kind === Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_GET &&
|
|
196
|
+
!!statement.id &&
|
|
197
|
+
!!node.key &&
|
|
198
|
+
isIdentifier(node.key) &&
|
|
199
|
+
statement.id.name === node.key.name
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function getDeclFromArrayOrObjectMember(node: MemberExpression): AstNode | undefined {
|
|
204
|
+
if (isNumberLiteral(node.property)) {
|
|
205
|
+
return node.object ? getDecl(node.object) : undefined
|
|
206
|
+
}
|
|
207
|
+
return node.property ? getDecl(node.property) : undefined
|
|
137
208
|
}
|
|
138
209
|
|
|
139
210
|
export function getPeerDecl(peer: KNativePointer): AstNode | undefined {
|
|
@@ -144,6 +215,14 @@ export function getPeerDecl(peer: KNativePointer): AstNode | undefined {
|
|
|
144
215
|
return unpackNonNullableNode(decl)
|
|
145
216
|
}
|
|
146
217
|
|
|
218
|
+
export function getPeerObjectDecl(peer: KNativePointer): AstNode | undefined {
|
|
219
|
+
const decl = global.es2panda._ClassVariableDeclaration(global.context, peer);
|
|
220
|
+
if (decl === nullptr) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
return unpackNonNullableNode(decl)
|
|
224
|
+
}
|
|
225
|
+
|
|
147
226
|
export function getAnnotations(node: AstNode): readonly AnnotationUsage[] {
|
|
148
227
|
if (!isFunctionDeclaration(node) && !isScriptFunction(node) && !isClassDefinition(node)) {
|
|
149
228
|
throwError('for now annotations allowed only for: functionDeclaration, scriptFunction, classDefinition')
|
|
@@ -153,7 +232,7 @@ export function getAnnotations(node: AstNode): readonly AnnotationUsage[] {
|
|
|
153
232
|
|
|
154
233
|
export function getOriginalNode(node: AstNode): AstNode {
|
|
155
234
|
if (node === undefined) {
|
|
156
|
-
//
|
|
235
|
+
// Improve: fix this
|
|
157
236
|
throwError('there is no arkts pair of ts node (unable to getOriginalNode)')
|
|
158
237
|
}
|
|
159
238
|
if (node.originalPeer === nullptr) {
|
|
@@ -166,7 +245,7 @@ export function getFileName(): string {
|
|
|
166
245
|
return global.filePath
|
|
167
246
|
}
|
|
168
247
|
|
|
169
|
-
//
|
|
248
|
+
// Improve: It seems like Definition overrides AstNode modifiers
|
|
170
249
|
// with it's own modifiers which is completely unrelated set of flags.
|
|
171
250
|
// Use this function if you need
|
|
172
251
|
// the language level modifiers: public, declare, export, etc.
|
|
@@ -174,7 +253,7 @@ export function classDefinitionFlags(node: ClassDefinition): Es2pandaModifierFla
|
|
|
174
253
|
return global.generatedEs2panda._AstNodeModifiers(global.context, node.peer)
|
|
175
254
|
}
|
|
176
255
|
|
|
177
|
-
//
|
|
256
|
+
// Improve: ClassProperty's optional flag is set by AstNode's modifiers flags.
|
|
178
257
|
export function classPropertySetOptional(node: ClassProperty, value: boolean): ClassProperty {
|
|
179
258
|
if (value) {
|
|
180
259
|
node.modifierFlags |= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL;
|
|
@@ -239,3 +318,48 @@ export function collectDependencies(files: string[], configPath: string): string
|
|
|
239
318
|
}
|
|
240
319
|
return Array.from(result)
|
|
241
320
|
}
|
|
321
|
+
|
|
322
|
+
export function generateTsDeclarationsFromContext(
|
|
323
|
+
outputDeclEts: string,
|
|
324
|
+
outputEts: string,
|
|
325
|
+
exportAll: boolean,
|
|
326
|
+
isolated: boolean
|
|
327
|
+
): KInt {
|
|
328
|
+
return global.es2panda._GenerateTsDeclarationsFromContext(
|
|
329
|
+
global.context,
|
|
330
|
+
passString(outputDeclEts),
|
|
331
|
+
passString(outputEts),
|
|
332
|
+
exportAll,
|
|
333
|
+
isolated
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export function setAllParents(ast: AstNode): void {
|
|
338
|
+
global.es2panda._AstNodeUpdateAll(global.context, ast.peer);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function getProgramFromAstNode(node: AstNode): Program {
|
|
342
|
+
return new Program(global.es2panda._AstNodeProgram(global.context, node.peer))
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function importDeclarationInsert(node: ETSImportDeclaration, program: Program): void {
|
|
346
|
+
global.es2panda._InsertETSImportDeclarationAndParse(global.context, program.peer, node.peer)
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function tryConvertCheckerTypeToTypeNode(typePeer: KNativePointer | undefined): TypeNode | undefined {
|
|
350
|
+
if (!typePeer) {
|
|
351
|
+
return undefined
|
|
352
|
+
}
|
|
353
|
+
const str = unpackString(global.es2panda._Checker_TypeToString(global.context, typePeer))
|
|
354
|
+
if (str == "void") {
|
|
355
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID)
|
|
356
|
+
}
|
|
357
|
+
if (str == "String" || str == "StringerNode") {
|
|
358
|
+
return factory.createETSTypeReference(
|
|
359
|
+
factory.createETSTypeReferencePart(
|
|
360
|
+
factory.createIdentifier(str)
|
|
361
|
+
)
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
return undefined
|
|
365
|
+
}
|
|
@@ -65,13 +65,13 @@ import {
|
|
|
65
65
|
isUpdateExpression,
|
|
66
66
|
isVariableDeclaration,
|
|
67
67
|
isVariableDeclarator,
|
|
68
|
-
isWhileStatement
|
|
68
|
+
isWhileStatement,
|
|
69
|
+
Statement
|
|
69
70
|
} from "../generated"
|
|
70
71
|
import { Es2pandaImportKinds } from "../generated/Es2pandaEnums"
|
|
71
72
|
import { factory } from "./factory/nodeFactory"
|
|
72
73
|
import { AstNode } from "./peers/AstNode"
|
|
73
74
|
import { global } from "./static/global"
|
|
74
|
-
import { updateETSModuleByStatements } from "./utilities/public"
|
|
75
75
|
|
|
76
76
|
type Visitor = (node: AstNode, options?: object) => AstNode
|
|
77
77
|
|
|
@@ -124,7 +124,7 @@ export class GlobalInfo {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
//
|
|
127
|
+
// Improve: rethink (remove as)
|
|
128
128
|
function nodeVisitor<T extends AstNode | undefined>(node: T, visitor: Visitor): T {
|
|
129
129
|
if (node === undefined) {
|
|
130
130
|
return node
|
|
@@ -132,7 +132,7 @@ function nodeVisitor<T extends AstNode | undefined>(node: T, visitor: Visitor):
|
|
|
132
132
|
return visitor(node) as T
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
//
|
|
135
|
+
// Improve: rethink (remove as)
|
|
136
136
|
function nodesVisitor<T extends AstNode, TIn extends readonly T[] | undefined>(nodes: TIn, visitor: Visitor): T[] | TIn {
|
|
137
137
|
if (nodes === undefined) {
|
|
138
138
|
return nodes
|
|
@@ -146,9 +146,12 @@ export function visitEachChild(
|
|
|
146
146
|
): AstNode {
|
|
147
147
|
global.profiler.nodeVisited()
|
|
148
148
|
if (isETSModule(node)) {
|
|
149
|
-
return
|
|
149
|
+
return factory.updateETSModule(
|
|
150
150
|
node,
|
|
151
|
-
nodesVisitor(node.statements, visitor)
|
|
151
|
+
nodesVisitor(node.statements, visitor),
|
|
152
|
+
nodeVisitor(node.ident, visitor),
|
|
153
|
+
node.getNamespaceFlag(),
|
|
154
|
+
node.program,
|
|
152
155
|
)
|
|
153
156
|
}
|
|
154
157
|
if (isCallExpression(node)) {
|
|
@@ -218,7 +221,8 @@ export function visitEachChild(
|
|
|
218
221
|
nodeVisitor(node.super, visitor),
|
|
219
222
|
nodesVisitor(node.body, visitor),
|
|
220
223
|
node.modifiers,
|
|
221
|
-
node.modifierFlags
|
|
224
|
+
node.modifierFlags,
|
|
225
|
+
node.annotations,
|
|
222
226
|
)
|
|
223
227
|
}
|
|
224
228
|
if (isMethodDefinition(node)) {
|
|
@@ -243,7 +247,8 @@ export function visitEachChild(
|
|
|
243
247
|
node.flags,
|
|
244
248
|
node.modifierFlags,
|
|
245
249
|
nodeVisitor(node.id, visitor),
|
|
246
|
-
nodesVisitor(node.annotations, visitor)
|
|
250
|
+
nodesVisitor(node.annotations, visitor),
|
|
251
|
+
node.getPreferredReturnTypePointer(),
|
|
247
252
|
)
|
|
248
253
|
}
|
|
249
254
|
if (isETSParameterExpression(node)) {
|
|
@@ -419,6 +424,7 @@ export function visitEachChild(
|
|
|
419
424
|
return factory.updateETSUnionType(
|
|
420
425
|
node,
|
|
421
426
|
nodesVisitor(node.types, visitor),
|
|
427
|
+
nodesVisitor(node.annotations, visitor),
|
|
422
428
|
)
|
|
423
429
|
}
|
|
424
430
|
if (isETSFunctionType(node)) {
|
|
@@ -427,7 +433,7 @@ export function visitEachChild(
|
|
|
427
433
|
nodeVisitor(node.typeParams, visitor),
|
|
428
434
|
nodesVisitor(node.params, visitor),
|
|
429
435
|
nodeVisitor(node.returnType, visitor),
|
|
430
|
-
false, //
|
|
436
|
+
false, // Improve: how to get it?
|
|
431
437
|
node.flags,
|
|
432
438
|
nodesVisitor(node.annotations, visitor),
|
|
433
439
|
)
|
|
@@ -563,7 +569,7 @@ export function visitEachChild(
|
|
|
563
569
|
node.requiredParams,
|
|
564
570
|
)
|
|
565
571
|
}
|
|
566
|
-
/**
|
|
572
|
+
/** Improve: fix this case!
|
|
567
573
|
if (isClassStaticBlock(node)) {
|
|
568
574
|
return factory.updateClassStaticBlock(
|
|
569
575
|
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2025 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
1
16
|
import * as fs from "fs"
|
|
2
17
|
import * as path from "path"
|
|
3
18
|
|