@idlizer/arktscgen 2.1.10-arktscgen-4 → 2.1.10-arktscgen-6
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 +24 -47
- package/build/libarkts-copy/native/meson.build +26 -10
- package/build/libarkts-copy/native/meson_options.txt +9 -3
- package/build/libarkts-copy/native/mingw.cross +2 -0
- package/build/libarkts-copy/native/src/bridges.cc +55 -159
- package/build/libarkts-copy/native/src/common.cc +316 -97
- package/build/libarkts-copy/native/src/common.h +22 -22
- package/build/libarkts-copy/native/src/memoryTracker.cc +5 -5
- package/build/libarkts-copy/native/src/memoryTracker.h +5 -5
- package/build/libarkts-copy/package.json +31 -25
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +139 -116
- package/build/libarkts-copy/src/InteropNativeModule.ts +18 -15
- package/build/libarkts-copy/src/arkts-api/AbstractVisitor.ts +24 -19
- package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +30 -31
- package/build/libarkts-copy/src/arkts-api/ProgramProvider.ts +30 -18
- package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +30 -12
- package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +38 -29
- package/build/libarkts-copy/src/arkts-api/index.ts +23 -24
- package/build/libarkts-copy/src/arkts-api/node-cache.ts +22 -13
- package/build/libarkts-copy/src/arkts-api/node-utilities/ArkTsConfig.ts +8 -8
- package/build/libarkts-copy/src/arkts-api/node-utilities/ArrayExpression.ts +9 -21
- package/build/libarkts-copy/src/arkts-api/node-utilities/AssignmentExpression.ts +12 -14
- package/build/libarkts-copy/src/arkts-api/node-utilities/BlockStatement.ts +5 -5
- package/build/libarkts-copy/src/arkts-api/node-utilities/CallExpression.ts +26 -24
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDefinition.ts +62 -32
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassProperty.ts +14 -13
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSFunctionType.ts +24 -21
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSImportDeclaration.ts +10 -12
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSModule.ts +14 -18
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSParameterExpression.ts +15 -16
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSStructDeclaration.ts +5 -8
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSTuple.ts +6 -12
- package/build/libarkts-copy/src/arkts-api/node-utilities/MemberExpression.ts +12 -11
- package/build/libarkts-copy/src/arkts-api/node-utilities/MethodDefinition.ts +14 -33
- package/build/libarkts-copy/src/arkts-api/node-utilities/NumberLiteral.ts +12 -23
- package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +17 -21
- package/build/libarkts-copy/src/arkts-api/node-utilities/OpaqueTypeNode.ts +9 -8
- package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +21 -16
- package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +52 -53
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +22 -32
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeParameter.ts +12 -14
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeReferencePart.ts +10 -12
- package/build/libarkts-copy/src/arkts-api/node-utilities/TryStatement.ts +10 -9
- package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclarator.ts +10 -12
- package/build/libarkts-copy/src/arkts-api/peers/ArktsObject.ts +8 -8
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +53 -65
- package/build/libarkts-copy/src/arkts-api/peers/Config.ts +18 -25
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +35 -42
- package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +9 -9
- package/build/libarkts-copy/src/arkts-api/peers/ImportPathManager.ts +6 -8
- package/build/libarkts-copy/src/arkts-api/peers/Options.ts +8 -8
- package/build/libarkts-copy/src/arkts-api/plugins.ts +205 -32
- package/build/libarkts-copy/src/arkts-api/static/global.ts +35 -36
- package/build/libarkts-copy/src/arkts-api/static/globalUtils.ts +5 -5
- package/build/libarkts-copy/src/arkts-api/static/profiler.ts +107 -91
- package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +54 -37
- package/build/libarkts-copy/src/arkts-api/utilities/nativePtrDecoder.ts +86 -69
- package/build/libarkts-copy/src/arkts-api/utilities/performance.ts +41 -24
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +69 -62
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +254 -175
- package/build/libarkts-copy/src/arkts-api/visitor.ts +599 -756
- package/build/libarkts-copy/src/arkts-api/wrapper-compat.ts +8 -8
- package/build/libarkts-copy/src/checkSdk.ts +15 -18
- package/build/libarkts-copy/src/index.ts +29 -29
- package/build/libarkts-copy/src/memo-node-cache.ts +143 -0
- package/build/libarkts-copy/src/plugin-utils.ts +64 -45
- package/build/libarkts-copy/src/reexport-for-generated.ts +13 -10
- package/build/libarkts-copy/src/tracer.ts +76 -70
- package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +134 -274
- package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +23 -23
- package/build/libarkts-copy/src/ts-api/index.ts +27 -35
- package/build/libarkts-copy/src/ts-api/static/enums.ts +3 -3
- package/build/libarkts-copy/src/ts-api/types.ts +535 -395
- package/build/libarkts-copy/src/ts-api/utilities/private.ts +116 -113
- package/build/libarkts-copy/src/ts-api/utilities/public.ts +18 -18
- package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +33 -49
- package/build/libarkts-copy/src/utils.ts +103 -80
- package/build/libarkts-copy/tsconfig.json +3 -2
- package/lib/index.js +2713 -7729
- package/package.json +53 -52
- package/templates/Es2pandaNativeModule.ts +1 -0
- package/templates/peer.ts +1 -0
- package/build/libarkts-copy/native/src/generated/bridges.cc +0 -16375
- package/build/libarkts-copy/src/arkts-api/peers/DiagnosticKind.ts +0 -24
- package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +0 -1344
- package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +0 -5192
- package/build/libarkts-copy/src/generated/factory.ts +0 -1285
- package/build/libarkts-copy/src/generated/index.ts +0 -222
- package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +0 -44
- package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +0 -54
- package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +0 -45
- package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +0 -165
- package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +0 -84
- package/build/libarkts-copy/src/generated/peers/ArkTsConfig.ts +0 -73
- package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +0 -109
- package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +0 -119
- package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +0 -65
- package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +0 -111
- package/build/libarkts-copy/src/generated/peers/AstDumper.ts +0 -49
- package/build/libarkts-copy/src/generated/peers/AstVerifier.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/AstVisitor.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +0 -110
- package/build/libarkts-copy/src/generated/peers/BindingProps.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +0 -72
- package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +0 -94
- package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +0 -78
- package/build/libarkts-copy/src/generated/peers/CallExpression.ts +0 -129
- package/build/libarkts-copy/src/generated/peers/CatchClause.ts +0 -74
- package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +0 -68
- package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +0 -76
- package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +0 -365
- package/build/libarkts-copy/src/generated/peers/ClassElement.ts +0 -76
- package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +0 -137
- package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +0 -66
- package/build/libarkts-copy/src/generated/peers/CodeGen.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +0 -82
- package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +0 -78
- package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/Declaration.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/Decorator.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/DiagnosticInfo.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +0 -60
- package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +0 -66
- package/build/libarkts-copy/src/generated/peers/DynamicImportData.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +0 -102
- package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +0 -90
- package/build/libarkts-copy/src/generated/peers/ETSIntrinsicNode.ts +0 -69
- package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/ETSModule.ts +0 -129
- package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +0 -75
- package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +0 -79
- package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +0 -75
- package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +0 -59
- package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +0 -189
- package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +0 -55
- package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +0 -59
- package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +0 -89
- package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +0 -66
- package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +0 -78
- package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +0 -75
- package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +0 -63
- package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +0 -66
- package/build/libarkts-copy/src/generated/peers/ErrorLogger.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +0 -66
- package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +0 -64
- package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +0 -94
- package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +0 -82
- package/build/libarkts-copy/src/generated/peers/Expression.ts +0 -84
- package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +0 -67
- package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +0 -69
- package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +0 -72
- package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +0 -67
- package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +0 -106
- package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +0 -74
- package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +0 -70
- package/build/libarkts-copy/src/generated/peers/IRNode.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/Identifier.ts +0 -162
- package/build/libarkts-copy/src/generated/peers/IfStatement.ts +0 -78
- package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +0 -87
- package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/ImportSource.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +0 -73
- package/build/libarkts-copy/src/generated/peers/IndexInfo.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/LabelPair.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +0 -68
- package/build/libarkts-copy/src/generated/peers/Literal.ts +0 -53
- package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +0 -45
- package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +0 -53
- package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +0 -115
- package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +0 -152
- package/build/libarkts-copy/src/generated/peers/NamedType.ts +0 -84
- package/build/libarkts-copy/src/generated/peers/NewExpression.ts +0 -64
- package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +0 -78
- package/build/libarkts-copy/src/generated/peers/ObjectDescriptor.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +0 -94
- package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/OverloadDeclaration.ts +0 -101
- package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +0 -65
- package/build/libarkts-copy/src/generated/peers/Program.ts +0 -206
- package/build/libarkts-copy/src/generated/peers/Property.ts +0 -92
- package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +0 -65
- package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +0 -75
- package/build/libarkts-copy/src/generated/peers/ScopeFindResult.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +0 -310
- package/build/libarkts-copy/src/generated/peers/ScriptFunctionData.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/SignatureInfo.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +0 -48
- package/build/libarkts-copy/src/generated/peers/SourceRange.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +0 -83
- package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +0 -120
- package/build/libarkts-copy/src/generated/peers/Statement.ts +0 -44
- package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +0 -66
- package/build/libarkts-copy/src/generated/peers/SuggestionInfo.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +0 -70
- package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +0 -71
- package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +0 -84
- package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +0 -70
- package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +0 -71
- package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +0 -73
- package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +0 -112
- package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +0 -76
- package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +0 -75
- package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +0 -69
- package/build/libarkts-copy/src/generated/peers/TSImportType.ts +0 -72
- package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +0 -73
- package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +0 -64
- package/build/libarkts-copy/src/generated/peers/TSInferType.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +0 -160
- package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +0 -72
- package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +0 -79
- package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +0 -71
- package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +0 -68
- package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +0 -66
- package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +0 -74
- package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +0 -80
- package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +0 -71
- package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +0 -75
- package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSThisType.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +0 -151
- package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +0 -71
- package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +0 -71
- package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +0 -121
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +0 -75
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +0 -68
- package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +0 -70
- package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +0 -69
- package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +0 -69
- package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +0 -68
- package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +0 -62
- package/build/libarkts-copy/src/generated/peers/TryStatement.ts +0 -89
- package/build/libarkts-copy/src/generated/peers/TypeNode.ts +0 -81
- package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +0 -44
- package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +0 -45
- package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +0 -61
- package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +0 -70
- package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +0 -58
- package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +0 -68
- package/build/libarkts-copy/src/generated/peers/VReg.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +0 -50
- package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +0 -113
- package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +0 -79
- package/build/libarkts-copy/src/generated/peers/VerificationContext.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/VerifierMessage.ts +0 -40
- package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +0 -71
- package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +0 -64
|
@@ -13,13 +13,35 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { global } from
|
|
17
|
-
import { isNumber, throwError, withWarning } from
|
|
18
|
-
import { KNativePointer, nullptr, KInt, KUInt} from
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
import { global } from '../static/global';
|
|
17
|
+
import { isNumber, throwError, withWarning } from '../../utils';
|
|
18
|
+
import { KNativePointer, nullptr, KInt, KUInt } from '@koalaui/interop';
|
|
19
|
+
import {
|
|
20
|
+
passNode,
|
|
21
|
+
unpackNodeArray,
|
|
22
|
+
unpackNonNullableNode,
|
|
23
|
+
passString,
|
|
24
|
+
unpackString,
|
|
25
|
+
passStringArray,
|
|
26
|
+
unpackNode,
|
|
27
|
+
} from './private';
|
|
28
|
+
import {
|
|
29
|
+
Es2pandaContextState,
|
|
30
|
+
Es2pandaModifierFlags,
|
|
31
|
+
Es2pandaMethodDefinitionKind,
|
|
32
|
+
Es2pandaAstNodeType,
|
|
33
|
+
Es2pandaPluginDiagnosticType,
|
|
34
|
+
} from '../../../generated/Es2pandaEnums';
|
|
35
|
+
import type { AstNode } from '../peers/AstNode';
|
|
36
|
+
import {
|
|
37
|
+
DiagnosticInfo,
|
|
38
|
+
Identifier,
|
|
39
|
+
isConditionalExpression,
|
|
40
|
+
SourcePosition,
|
|
41
|
+
SourceRange,
|
|
42
|
+
SuggestionInfo,
|
|
43
|
+
VariableDeclarator,
|
|
44
|
+
} from '../../../generated';
|
|
23
45
|
import {
|
|
24
46
|
type AnnotationUsage,
|
|
25
47
|
ClassDefinition,
|
|
@@ -41,168 +63,172 @@ import {
|
|
|
41
63
|
MemberExpression,
|
|
42
64
|
isMethodDefinition,
|
|
43
65
|
TypeNode,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
66
|
+
DiagnosticKind
|
|
67
|
+
} from '../../../generated';
|
|
68
|
+
import { Config } from '../peers/Config';
|
|
69
|
+
import { Context } from '../peers/Context';
|
|
70
|
+
import { NodeCache } from '../node-cache';
|
|
71
|
+
import { factory } from '../factory/nodeFactory';
|
|
72
|
+
import { traceGlobal } from '../../tracer';
|
|
51
73
|
|
|
52
74
|
/**
|
|
53
75
|
* Improve: Replace or remove with better naming
|
|
54
|
-
*
|
|
76
|
+
*
|
|
55
77
|
* @deprecated
|
|
56
78
|
*/
|
|
57
79
|
export function createETSModuleFromContext(): ETSModule {
|
|
58
|
-
let program = global.generatedEs2panda._ContextProgram(global.context)
|
|
59
|
-
if (program
|
|
60
|
-
throw new Error(`Program is null for context ${global.context.toString(16)}`)
|
|
80
|
+
let program = global.generatedEs2panda._ContextProgram(global.context);
|
|
81
|
+
if (program === nullptr || program === null) {
|
|
82
|
+
throw new Error(`Program is null for context ${global.context.toString(16)}`);
|
|
61
83
|
}
|
|
62
|
-
const ast = global.generatedEs2panda._ProgramAst(global.context, program)
|
|
63
|
-
if (ast
|
|
64
|
-
throw new Error(`AST is null for program ${program.toString(16)}`)
|
|
65
|
-
|
|
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)}`);
|
|
66
87
|
}
|
|
67
|
-
return new ETSModule(ast, Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE)
|
|
88
|
+
return new ETSModule(ast, Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE);
|
|
68
89
|
}
|
|
69
90
|
|
|
70
91
|
/**
|
|
71
92
|
* Now used only in tests
|
|
72
93
|
* Improve: Remove or replace with better method
|
|
73
|
-
*
|
|
94
|
+
*
|
|
74
95
|
* @deprecated
|
|
75
96
|
*/
|
|
76
97
|
export function createETSModuleFromSource(
|
|
77
98
|
source: string,
|
|
78
|
-
state: Es2pandaContextState = Es2pandaContextState.ES2PANDA_STATE_PARSED
|
|
99
|
+
state: Es2pandaContextState = Es2pandaContextState.ES2PANDA_STATE_PARSED
|
|
79
100
|
): ETSModule {
|
|
80
101
|
if (!global.configIsInitialized()) {
|
|
81
|
-
global.config = Config.createDefault().peer
|
|
102
|
+
global.config = Config.createDefault().peer;
|
|
82
103
|
}
|
|
83
|
-
global.compilerContext = Context.createFromString(source)
|
|
84
|
-
proceedToState(state)
|
|
85
|
-
let program = global.generatedEs2panda._ContextProgram(global.compilerContext.peer)
|
|
86
|
-
if (program
|
|
87
|
-
throw new Error(`Program is null for ${source} 0x${global.compilerContext.peer.toString(16)}`)
|
|
88
|
-
return new ETSModule(
|
|
104
|
+
global.compilerContext = Context.createFromString(source);
|
|
105
|
+
proceedToState(state);
|
|
106
|
+
let program = global.generatedEs2panda._ContextProgram(global.compilerContext.peer);
|
|
107
|
+
if (program === nullptr)
|
|
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
|
+
);
|
|
89
113
|
}
|
|
90
114
|
|
|
91
115
|
export function metaDatabase(fileName: string): string {
|
|
92
|
-
if (fileName.endsWith(
|
|
93
|
-
return `${fileName}.meta.json
|
|
116
|
+
if (fileName.endsWith('.meta.json')) throw new Error(`Must pass source, not database: ${fileName}`);
|
|
117
|
+
return `${fileName}.meta.json`;
|
|
94
118
|
}
|
|
95
119
|
|
|
96
120
|
export function checkErrors() {
|
|
97
121
|
if (global.es2panda._ContextState(global.context) === Es2pandaContextState.ES2PANDA_STATE_ERROR) {
|
|
98
|
-
traceGlobal(() => `Terminated due to compilation errors occured`)
|
|
99
|
-
console.log(unpackString(global.generatedEs2panda._GetAllErrorMessages(global.context)))
|
|
122
|
+
traceGlobal(() => `Terminated due to compilation errors occured`);
|
|
123
|
+
console.log(unpackString(global.generatedEs2panda._GetAllErrorMessages(global.context)));
|
|
100
124
|
// global.es2panda._DestroyConfig(global.config)
|
|
101
|
-
|
|
125
|
+
throw new Error(`Compilation error`)
|
|
102
126
|
}
|
|
103
127
|
}
|
|
104
128
|
|
|
129
|
+
function format(value: number): string {
|
|
130
|
+
return `${(value / 1024 / 1024 / 1024).toFixed(4)} GB`
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Improve: move to profiler
|
|
134
|
+
function dumpMemoryProfilerInfo(str: string) {
|
|
135
|
+
console.log(str, format(process.memoryUsage().rss));
|
|
136
|
+
}
|
|
137
|
+
|
|
105
138
|
export function proceedToState(state: Es2pandaContextState): void {
|
|
106
139
|
if (state <= global.es2panda._ContextState(global.context)) {
|
|
107
|
-
return
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
NodeCache.clear();
|
|
143
|
+
const before = Date.now();
|
|
144
|
+
traceGlobal(() => `Proceeding to state ${Es2pandaContextState[state]}: start`);
|
|
145
|
+
global.es2panda._ProceedToState(global.context, state);
|
|
146
|
+
traceGlobal(() => `Proceeding to state ${Es2pandaContextState[state]}: done`);
|
|
147
|
+
const after = Date.now();
|
|
148
|
+
global.profiler.proceededToState(after - before);
|
|
149
|
+
if (state == Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED) {
|
|
150
|
+
dumpMemoryProfilerInfo("Memory usage (rss) after proceed to bin:")
|
|
108
151
|
}
|
|
109
|
-
|
|
110
|
-
const before = Date.now()
|
|
111
|
-
traceGlobal(() => `Proceeding to state ${Es2pandaContextState[state]}: start`)
|
|
112
|
-
global.es2panda._ProceedToState(global.context, state)
|
|
113
|
-
traceGlobal(() => `Proceeding to state ${Es2pandaContextState[state]}: done`)
|
|
114
|
-
const after = Date.now()
|
|
115
|
-
global.profiler.proceededToState(after-before)
|
|
116
|
-
checkErrors()
|
|
152
|
+
checkErrors();
|
|
117
153
|
}
|
|
118
154
|
|
|
119
155
|
/** @deprecated Use {@link rebindContext} instead */
|
|
120
156
|
export function rebindSubtree(node: AstNode): void {
|
|
121
|
-
NodeCache.clear()
|
|
122
|
-
traceGlobal(() => `Rebind: start`)
|
|
123
|
-
global.es2panda._AstNodeRebind(global.context, node.peer)
|
|
124
|
-
traceGlobal(() => `Rebind: done`)
|
|
125
|
-
checkErrors()
|
|
157
|
+
NodeCache.clear();
|
|
158
|
+
traceGlobal(() => `Rebind: start`);
|
|
159
|
+
global.es2panda._AstNodeRebind(global.context, node.peer);
|
|
160
|
+
traceGlobal(() => `Rebind: done`);
|
|
161
|
+
checkErrors();
|
|
126
162
|
}
|
|
127
163
|
|
|
128
164
|
/** @deprecated Use {@link recheckSubtree} instead */
|
|
129
165
|
export function recheckSubtree(node: AstNode): void {
|
|
130
|
-
NodeCache.clear()
|
|
131
|
-
traceGlobal(() => `Recheck: start`)
|
|
132
|
-
global.generatedEs2panda._AstNodeRecheck(global.context, node.peer)
|
|
133
|
-
traceGlobal(() => `Recheck: done`)
|
|
134
|
-
checkErrors()
|
|
166
|
+
NodeCache.clear();
|
|
167
|
+
traceGlobal(() => `Recheck: start`);
|
|
168
|
+
global.generatedEs2panda._AstNodeRecheck(global.context, node.peer);
|
|
169
|
+
traceGlobal(() => `Recheck: done`);
|
|
170
|
+
checkErrors();
|
|
135
171
|
}
|
|
136
172
|
|
|
137
173
|
export function rebindContext(context: KNativePointer = global.context): void {
|
|
138
|
-
NodeCache.clear()
|
|
139
|
-
traceGlobal(() => `Rebind: start`)
|
|
174
|
+
NodeCache.clear();
|
|
175
|
+
traceGlobal(() => `Rebind: start`);
|
|
140
176
|
global.es2panda._AstNodeRebind(
|
|
141
177
|
context,
|
|
142
|
-
global.generatedEs2panda._ProgramAst(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
)
|
|
147
|
-
)
|
|
148
|
-
)
|
|
149
|
-
traceGlobal(() => `Rebind: done`)
|
|
150
|
-
checkErrors()
|
|
178
|
+
global.generatedEs2panda._ProgramAst(context, global.generatedEs2panda._ContextProgram(context))
|
|
179
|
+
);
|
|
180
|
+
traceGlobal(() => `Rebind: done`);
|
|
181
|
+
checkErrors();
|
|
151
182
|
}
|
|
152
183
|
|
|
153
184
|
export function recheckContext(context: KNativePointer = global.context): void {
|
|
154
|
-
NodeCache.clear()
|
|
155
|
-
traceGlobal(() => `Recheck: start`)
|
|
185
|
+
NodeCache.clear();
|
|
186
|
+
traceGlobal(() => `Recheck: start`);
|
|
156
187
|
global.generatedEs2panda._AstNodeRecheck(
|
|
157
188
|
context,
|
|
158
|
-
global.generatedEs2panda._ProgramAst(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)
|
|
163
|
-
)
|
|
164
|
-
)
|
|
165
|
-
traceGlobal(() => `Recheck: done`)
|
|
166
|
-
checkErrors()
|
|
189
|
+
global.generatedEs2panda._ProgramAst(context, global.generatedEs2panda._ContextProgram(context))
|
|
190
|
+
);
|
|
191
|
+
traceGlobal(() => `Recheck: done`);
|
|
192
|
+
checkErrors();
|
|
167
193
|
}
|
|
168
194
|
|
|
169
195
|
export function getDecl(node: AstNode): AstNode | undefined {
|
|
170
196
|
if (isMemberExpression(node)) {
|
|
171
|
-
return getDeclFromArrayOrObjectMember(node)
|
|
197
|
+
return getDeclFromArrayOrObjectMember(node);
|
|
172
198
|
}
|
|
173
199
|
if (isObjectExpression(node)) {
|
|
174
|
-
return getPeerObjectDecl(passNode(node))
|
|
200
|
+
return getPeerObjectDecl(passNode(node));
|
|
175
201
|
}
|
|
176
|
-
const decl = getPeerDecl(passNode(node))
|
|
202
|
+
const decl = getPeerDecl(passNode(node));
|
|
177
203
|
if (!!decl) {
|
|
178
|
-
return decl
|
|
204
|
+
return decl;
|
|
179
205
|
}
|
|
180
206
|
if (!!node.parent && isProperty(node.parent)) {
|
|
181
|
-
return getDeclFromProperty(node.parent)
|
|
207
|
+
return getDeclFromProperty(node.parent);
|
|
182
208
|
}
|
|
183
|
-
return undefined
|
|
209
|
+
return undefined;
|
|
184
210
|
}
|
|
185
211
|
|
|
186
212
|
function getDeclFromProperty(node: Property): AstNode | undefined {
|
|
187
213
|
if (!node.key) {
|
|
188
|
-
return undefined
|
|
214
|
+
return undefined;
|
|
189
215
|
}
|
|
190
216
|
if (!!node.parent && !isObjectExpression(node.parent)) {
|
|
191
|
-
return getPeerDecl(passNode(node.key))
|
|
217
|
+
return getPeerDecl(passNode(node.key));
|
|
192
218
|
}
|
|
193
|
-
return getDeclFromObjectExpressionProperty(node)
|
|
219
|
+
return getDeclFromObjectExpressionProperty(node);
|
|
194
220
|
}
|
|
195
221
|
|
|
196
222
|
function getDeclFromObjectExpressionProperty(node: Property): AstNode | undefined {
|
|
197
|
-
const declNode = getPeerObjectDecl(passNode(node.parent))
|
|
223
|
+
const declNode = getPeerObjectDecl(passNode(node.parent));
|
|
198
224
|
if (!declNode || !node.key || !isIdentifier(node.key)) {
|
|
199
|
-
return undefined
|
|
225
|
+
return undefined;
|
|
200
226
|
}
|
|
201
|
-
let body: readonly AstNode[] = []
|
|
227
|
+
let body: readonly AstNode[] = [];
|
|
202
228
|
if (isClassDefinition(declNode)) {
|
|
203
|
-
body = declNode.body
|
|
229
|
+
body = declNode.body;
|
|
204
230
|
} else if (isTSInterfaceDeclaration(declNode)) {
|
|
205
|
-
body = declNode.body?.body ?? []
|
|
231
|
+
body = declNode.body?.body ?? [];
|
|
206
232
|
}
|
|
207
233
|
return body.find(
|
|
208
234
|
(statement) =>
|
|
@@ -212,42 +238,46 @@ function getDeclFromObjectExpressionProperty(node: Property): AstNode | undefine
|
|
|
212
238
|
!!node.key &&
|
|
213
239
|
isIdentifier(node.key) &&
|
|
214
240
|
statement.id.name === node.key.name
|
|
215
|
-
)
|
|
241
|
+
);
|
|
216
242
|
}
|
|
217
243
|
|
|
218
244
|
function getDeclFromArrayOrObjectMember(node: MemberExpression): AstNode | undefined {
|
|
219
245
|
if (isNumberLiteral(node.property)) {
|
|
220
|
-
return node.object ? getDecl(node.object) : undefined
|
|
246
|
+
return node.object ? getDecl(node.object) : undefined;
|
|
221
247
|
}
|
|
222
|
-
return node.property ? getDecl(node.property) : undefined
|
|
248
|
+
return node.property ? getDecl(node.property) : undefined;
|
|
223
249
|
}
|
|
224
250
|
|
|
225
251
|
export function getPeerDecl(peer: KNativePointer): AstNode | undefined {
|
|
226
|
-
const decl = global.generatedEs2panda._DeclarationFromIdentifier(global.context, peer)
|
|
252
|
+
const decl = global.generatedEs2panda._DeclarationFromIdentifier(global.context, peer);
|
|
227
253
|
if (decl === nullptr) {
|
|
228
|
-
return undefined
|
|
254
|
+
return undefined;
|
|
229
255
|
}
|
|
230
|
-
return unpackNonNullableNode(decl)
|
|
256
|
+
return unpackNonNullableNode(decl);
|
|
231
257
|
}
|
|
232
258
|
|
|
233
259
|
export function declarationFromIdentifier(node: Identifier): AstNode | undefined {
|
|
234
|
-
return unpackNode(global.generatedEs2panda._DeclarationFromIdentifier(global.context, node.peer))
|
|
260
|
+
return unpackNode(global.generatedEs2panda._DeclarationFromIdentifier(global.context, node.peer));
|
|
235
261
|
}
|
|
236
262
|
|
|
237
263
|
export function resolveGensymVariableDeclaratorForDefaultParam(node: VariableDeclarator): Identifier | undefined {
|
|
238
|
-
const init = node.init
|
|
239
|
-
if (
|
|
240
|
-
|
|
264
|
+
const init = node.init;
|
|
265
|
+
if (
|
|
266
|
+
isConditionalExpression(init) &&
|
|
267
|
+
isIdentifier(init.consequent) &&
|
|
268
|
+
init.consequent.name.startsWith('gensym%%_')
|
|
269
|
+
) {
|
|
270
|
+
return init.consequent;
|
|
241
271
|
}
|
|
242
|
-
return undefined
|
|
272
|
+
return undefined;
|
|
243
273
|
}
|
|
244
274
|
|
|
245
275
|
export function resolveGensymVariableDeclaratorForOptionalCall(node: VariableDeclarator): Identifier | undefined {
|
|
246
|
-
const init = node.init
|
|
247
|
-
if (isIdentifier(node.id) && node.id.name.startsWith(
|
|
248
|
-
return init
|
|
276
|
+
const init = node.init;
|
|
277
|
+
if (isIdentifier(node.id) && node.id.name.startsWith('gensym%%_') && isIdentifier(init)) {
|
|
278
|
+
return init;
|
|
249
279
|
}
|
|
250
|
-
return undefined
|
|
280
|
+
return undefined;
|
|
251
281
|
}
|
|
252
282
|
|
|
253
283
|
export function getPeerObjectDecl(peer: KNativePointer): AstNode | undefined {
|
|
@@ -255,43 +285,42 @@ export function getPeerObjectDecl(peer: KNativePointer): AstNode | undefined {
|
|
|
255
285
|
if (decl === nullptr) {
|
|
256
286
|
return undefined;
|
|
257
287
|
}
|
|
258
|
-
return unpackNonNullableNode(decl)
|
|
288
|
+
return unpackNonNullableNode(decl);
|
|
259
289
|
}
|
|
260
290
|
|
|
261
291
|
export function getAnnotations(node: AstNode): readonly AnnotationUsage[] {
|
|
262
292
|
if (!isFunctionDeclaration(node) && !isScriptFunction(node) && !isClassDefinition(node)) {
|
|
263
|
-
throwError('for now annotations allowed only for: functionDeclaration, scriptFunction, classDefinition')
|
|
293
|
+
throwError('for now annotations allowed only for: functionDeclaration, scriptFunction, classDefinition');
|
|
264
294
|
}
|
|
265
|
-
return unpackNodeArray(global.es2panda._AnnotationAllowedAnnotations(global.context, node.peer, nullptr))
|
|
295
|
+
return unpackNodeArray(global.es2panda._AnnotationAllowedAnnotations(global.context, node.peer, nullptr));
|
|
266
296
|
}
|
|
267
297
|
|
|
268
298
|
export function getOriginalNode(node: AstNode): AstNode {
|
|
269
299
|
if (node === undefined) {
|
|
270
300
|
// Improve: fix this
|
|
271
|
-
throwError('there is no arkts pair of ts node (unable to getOriginalNode)')
|
|
301
|
+
throwError('there is no arkts pair of ts node (unable to getOriginalNode)');
|
|
272
302
|
}
|
|
273
303
|
if (node.originalPeer === nullptr) {
|
|
274
|
-
return node
|
|
304
|
+
return node;
|
|
275
305
|
}
|
|
276
|
-
return unpackNonNullableNode(node.originalPeer)
|
|
306
|
+
return unpackNonNullableNode(node.originalPeer);
|
|
277
307
|
}
|
|
278
308
|
|
|
279
309
|
export function getFileName(): string {
|
|
280
|
-
return global.filePath
|
|
310
|
+
return global.filePath;
|
|
281
311
|
}
|
|
282
312
|
|
|
283
313
|
export function getJsDoc(node: AstNode): string | undefined {
|
|
284
|
-
const result = unpackString(global.generatedEs2panda._JsdocStringFromDeclaration(global.context, node.peer))
|
|
285
|
-
return result === 'Empty Jsdoc' ? undefined : result
|
|
314
|
+
const result = unpackString(global.generatedEs2panda._JsdocStringFromDeclaration(global.context, node.peer));
|
|
315
|
+
return result === 'Empty Jsdoc' ? undefined : result;
|
|
286
316
|
}
|
|
287
317
|
|
|
288
|
-
|
|
289
318
|
// Improve: It seems like Definition overrides AstNode modifiers
|
|
290
319
|
// with it's own modifiers which is completely unrelated set of flags.
|
|
291
320
|
// Use this function if you need
|
|
292
321
|
// the language level modifiers: public, declare, export, etc.
|
|
293
322
|
export function classDefinitionFlags(node: ClassDefinition): Es2pandaModifierFlags {
|
|
294
|
-
return global.generatedEs2panda._AstNodeModifiers(global.context, node.peer)
|
|
323
|
+
return global.generatedEs2panda._AstNodeModifiers(global.context, node.peer);
|
|
295
324
|
}
|
|
296
325
|
|
|
297
326
|
// Improve: ClassProperty's optional flag is set by AstNode's modifiers flags.
|
|
@@ -311,58 +340,59 @@ export function hasModifierFlag(node: AstNode, flag: Es2pandaModifierFlags): boo
|
|
|
311
340
|
if (isClassDefinition(node)) {
|
|
312
341
|
modifiers = classDefinitionFlags(node);
|
|
313
342
|
} else {
|
|
314
|
-
modifiers = node.modifierFlags
|
|
343
|
+
modifiers = node.modifierFlags;
|
|
315
344
|
}
|
|
316
345
|
return (modifiers & flag) === flag;
|
|
317
346
|
}
|
|
318
347
|
|
|
319
348
|
export function modifiersToString(modifiers: Es2pandaModifierFlags): string {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
349
|
+
return Object.values(Es2pandaModifierFlags)
|
|
350
|
+
.filter(isNumber)
|
|
351
|
+
.map((it) => {
|
|
352
|
+
console.log(it.valueOf(), Es2pandaModifierFlags[it], modifiers.valueOf() & it);
|
|
353
|
+
return (modifiers.valueOf() & it) === it ? Es2pandaModifierFlags[it] : '';
|
|
354
|
+
})
|
|
355
|
+
.join(' ');
|
|
326
356
|
}
|
|
327
357
|
|
|
328
358
|
export function nameIfIdentifier(node: AstNode): string {
|
|
329
|
-
return isIdentifier(node) ? `'${node.name}'` :
|
|
359
|
+
return isIdentifier(node) ? `'${node.name}'` : '';
|
|
330
360
|
}
|
|
331
361
|
|
|
332
362
|
export function nameIfETSModule(node: AstNode): string {
|
|
333
|
-
return isETSModule(node) ? `'${node.ident?.name}'` :
|
|
363
|
+
return isETSModule(node) ? `'${node.ident?.name}'` : '';
|
|
334
364
|
}
|
|
335
365
|
|
|
336
|
-
export function asString(node: AstNode|undefined): string {
|
|
337
|
-
return `${node?.constructor.name} ${node ? nameIfIdentifier(node) : undefined}
|
|
366
|
+
export function asString(node: AstNode | undefined): string {
|
|
367
|
+
return `${node?.constructor.name} ${node ? nameIfIdentifier(node) : undefined}`;
|
|
338
368
|
}
|
|
339
369
|
|
|
340
|
-
const defaultPandaSdk =
|
|
341
|
-
|
|
370
|
+
const defaultPandaSdk = '../../../incremental/tools/panda/node_modules/@panda/sdk';
|
|
342
371
|
|
|
343
372
|
export function findStdlib(): string {
|
|
344
|
-
const sdk =
|
|
345
|
-
|
|
346
|
-
`PANDA_SDK_PATH not set, assuming ${defaultPandaSdk}`
|
|
347
|
-
|
|
348
|
-
return `${sdk}/ets/stdlib`
|
|
373
|
+
const sdk =
|
|
374
|
+
process.env.PANDA_SDK_PATH ??
|
|
375
|
+
withWarning(defaultPandaSdk, `PANDA_SDK_PATH not set, assuming ${defaultPandaSdk}`);
|
|
376
|
+
return `${sdk}/ets/stdlib`;
|
|
349
377
|
}
|
|
350
378
|
|
|
351
379
|
export function generateTsDeclarationsFromContext(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
380
|
+
outputDeclEts: string,
|
|
381
|
+
outputEts: string,
|
|
382
|
+
exportAll: boolean,
|
|
383
|
+
isolated: boolean,
|
|
384
|
+
recordFile: string,
|
|
385
|
+
genAnnotations: boolean
|
|
357
386
|
): KInt {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
387
|
+
return global.generatedEs2panda._GenerateTsDeclarationsFromContext(
|
|
388
|
+
global.context,
|
|
389
|
+
passString(outputDeclEts),
|
|
390
|
+
passString(outputEts),
|
|
391
|
+
exportAll,
|
|
392
|
+
isolated,
|
|
393
|
+
recordFile,
|
|
394
|
+
genAnnotations
|
|
395
|
+
);
|
|
366
396
|
}
|
|
367
397
|
|
|
368
398
|
export function setAllParents(ast: AstNode): void {
|
|
@@ -370,48 +400,45 @@ export function setAllParents(ast: AstNode): void {
|
|
|
370
400
|
}
|
|
371
401
|
|
|
372
402
|
export function getProgramFromAstNode(node: AstNode): Program {
|
|
373
|
-
return new Program(global.es2panda._AstNodeProgram(global.context, node.peer))
|
|
403
|
+
return new Program(global.es2panda._AstNodeProgram(global.context, node.peer));
|
|
374
404
|
}
|
|
375
405
|
|
|
376
406
|
export function importDeclarationInsert(node: ETSImportDeclaration, program: Program): void {
|
|
377
|
-
global.generatedEs2panda._InsertETSImportDeclarationAndParse(global.context, program.peer, node.peer)
|
|
407
|
+
global.generatedEs2panda._InsertETSImportDeclarationAndParse(global.context, program.peer, node.peer);
|
|
378
408
|
}
|
|
379
409
|
|
|
380
410
|
export function signatureReturnType(signature: KNativePointer): KNativePointer {
|
|
381
411
|
if (!signature) {
|
|
382
|
-
return nullptr
|
|
412
|
+
return nullptr;
|
|
383
413
|
}
|
|
384
|
-
return global.es2panda._Checker_SignatureReturnType(global.context, signature)
|
|
414
|
+
return global.es2panda._Checker_SignatureReturnType(global.context, signature);
|
|
385
415
|
}
|
|
386
416
|
|
|
387
417
|
export function convertCheckerTypeToTypeNode(typePeer: KNativePointer | undefined): TypeNode | undefined {
|
|
388
418
|
if (!typePeer) {
|
|
389
|
-
return undefined
|
|
419
|
+
return undefined;
|
|
390
420
|
}
|
|
391
|
-
return factory.createOpaqueTypeNode(
|
|
392
|
-
global.es2panda._Checker_TypeClone(global.context, typePeer)
|
|
393
|
-
)
|
|
421
|
+
return factory.createOpaqueTypeNode(global.es2panda._Checker_TypeClone(global.context, typePeer));
|
|
394
422
|
}
|
|
395
423
|
|
|
396
424
|
export function originalSourcePositionString(node: AstNode | undefined) {
|
|
397
425
|
if (!node) {
|
|
398
|
-
return `[undefined]
|
|
426
|
+
return `[undefined]`;
|
|
399
427
|
}
|
|
400
|
-
const originalPeer = node.originalPeer
|
|
401
|
-
const sourcePosition = new SourcePosition(
|
|
402
|
-
|
|
428
|
+
const originalPeer = node.originalPeer;
|
|
429
|
+
const sourcePosition = new SourcePosition(
|
|
430
|
+
global.generatedEs2panda._AstNodeStartConst(global.context, originalPeer)
|
|
431
|
+
);
|
|
432
|
+
const program = new Program(global.es2panda._AstNodeProgram(global.context, originalPeer));
|
|
403
433
|
if (!program.peer) {
|
|
404
434
|
// This can happen if we are calling this method on node that is in update now and parent chain does not lead to program
|
|
405
|
-
return `[${global.filePath}${sourcePosition.toString()}]
|
|
435
|
+
return `[${global.filePath}${sourcePosition.toString()}]`;
|
|
406
436
|
}
|
|
407
|
-
return `[${program.absoluteName}${sourcePosition.toString()}]
|
|
437
|
+
return `[${program.absoluteName}${sourcePosition.toString()}]`;
|
|
408
438
|
}
|
|
409
439
|
|
|
410
440
|
export function generateStaticDeclarationsFromContext(outputPath: string): KInt {
|
|
411
|
-
return global.generatedEs2panda._GenerateStaticDeclarationsFromContext(
|
|
412
|
-
global.context,
|
|
413
|
-
passString(outputPath)
|
|
414
|
-
);
|
|
441
|
+
return global.generatedEs2panda._GenerateStaticDeclarationsFromContext(global.context, passString(outputPath));
|
|
415
442
|
}
|
|
416
443
|
|
|
417
444
|
export function createTypeNodeFromTsType(node: AstNode): AstNode | undefined {
|
|
@@ -423,19 +450,47 @@ export function createTypeNodeFromTsType(node: AstNode): AstNode | undefined {
|
|
|
423
450
|
}
|
|
424
451
|
|
|
425
452
|
export function createSourcePosition(index: KUInt, line: KUInt): SourcePosition {
|
|
426
|
-
return new SourcePosition(global.generatedEs2panda._CreateSourcePosition(global.context, index, line))
|
|
453
|
+
return new SourcePosition(global.generatedEs2panda._CreateSourcePosition(global.context, index, line));
|
|
427
454
|
}
|
|
428
455
|
|
|
429
456
|
export function createSourceRange(start: SourcePosition, end: SourcePosition): SourceRange {
|
|
430
|
-
return new SourceRange(global.generatedEs2panda._CreateSourceRange(global.context, start.peer, end.peer))
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
export function createDiagnosticInfo(
|
|
434
|
-
|
|
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
|
+
);
|
|
435
474
|
}
|
|
436
475
|
|
|
437
|
-
export function createSuggestionInfo(
|
|
438
|
-
|
|
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
|
+
);
|
|
439
494
|
}
|
|
440
495
|
|
|
441
496
|
export function createDiagnosticKind(message: string, type: Es2pandaPluginDiagnosticType): DiagnosticKind {
|
|
@@ -449,3 +504,27 @@ export function logDiagnostic(kind: DiagnosticKind, pos: SourcePosition, ...args
|
|
|
449
504
|
export function logDiagnosticWithSuggestion(diagnosticInfo: DiagnosticInfo, suggestionInfo: SuggestionInfo): void {
|
|
450
505
|
global.generatedEs2panda._LogDiagnosticWithSuggestion(global.context, diagnosticInfo.peer, suggestionInfo.peer);
|
|
451
506
|
}
|
|
507
|
+
|
|
508
|
+
export function filterNodes(node: AstNode, filter: string, deeperAfterMatch: boolean): AstNode[] {
|
|
509
|
+
return unpackNodeArray(global.es2panda._FilterNodes(global.context, passNode(node), filter, deeperAfterMatch));
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export function filterNodesByType<T extends AstNode = AstNode>(node: AstNode, type: Es2pandaAstNodeType): T[] {
|
|
513
|
+
return unpackNodeArray(global.es2panda._FilterNodes2(global.context, passNode(node), type), type);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export function filterNodesByTypes(node: AstNode, types: Es2pandaAstNodeType[]): AstNode[] {
|
|
517
|
+
const typesArray = new Int32Array(types.length)
|
|
518
|
+
for (let i = 0; i < types.length; i++) {
|
|
519
|
+
typesArray[i] = types[i]
|
|
520
|
+
}
|
|
521
|
+
return unpackNodeArray(global.es2panda._FilterNodes3(global.context, passNode(node), typesArray, types.length));
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export function MemInitialize() {
|
|
525
|
+
global.es2panda._MemInitialize()
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export function MemFinalize() {
|
|
529
|
+
global.es2panda._MemFinalize()
|
|
530
|
+
}
|