@idlizer/arktscgen 2.1.9-arktscgen-6 → 2.1.9-arktscgen-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/libarkts-copy/generator/options.json5 +165 -3
- 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 +105 -15
- package/build/libarkts-copy/native/src/common.cc +11 -7
- package/build/libarkts-copy/native/src/common.h +1 -0
- package/build/libarkts-copy/native/src/generated/bridges.cc +318 -35
- package/build/libarkts-copy/package.json +24 -21
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +33 -6
- 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 -12
- 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 -11
- package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +17 -6
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +3 -6
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +3 -3
- package/build/libarkts-copy/src/arkts-api/peers/Config.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +26 -5
- package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +4 -0
- package/build/libarkts-copy/src/arkts-api/plugins.ts +15 -7
- package/build/libarkts-copy/src/arkts-api/static/global.ts +3 -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 +80 -0
- package/build/libarkts-copy/src/arkts-api/utilities/nativePtrDecoder.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +5 -5
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +217 -29
- package/build/libarkts-copy/src/arkts-api/visitor.ts +17 -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 +97 -14
- package/build/libarkts-copy/src/generated/factory.ts +40 -27
- package/build/libarkts-copy/src/generated/index.ts +4 -2
- package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/ArkTsConfig.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +26 -8
- package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/AstDumper.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/AstVerifier.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/AstVisitor.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/BindingProps.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/CallExpression.ts +19 -7
- package/build/libarkts-copy/src/generated/peers/CatchClause.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +21 -8
- package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +37 -13
- package/build/libarkts-copy/src/generated/peers/ClassElement.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +19 -7
- package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/CodeGen.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/Declaration.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/Decorator.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/DiagnosticInfo.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/DynamicImportData.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +20 -13
- package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSIntrinsicNode.ts +77 -0
- package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSModule.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +46 -14
- package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +3 -3
- package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +21 -9
- package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +20 -7
- package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/ErrorLogger.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +20 -8
- package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/Expression.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +5 -3
- package/build/libarkts-copy/src/generated/peers/FunctionDecl.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +11 -5
- package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/IRNode.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/Identifier.ts +14 -6
- package/build/libarkts-copy/src/generated/peers/IfStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/ImportSource.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/IndexInfo.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/InterfaceDecl.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/LabelPair.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/Literal.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +23 -7
- package/build/libarkts-copy/src/generated/peers/NamedType.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/NewExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +17 -7
- package/build/libarkts-copy/src/generated/peers/ObjectDescriptor.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/OverloadDeclaration.ts +103 -0
- package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/Program.ts +4 -2
- package/build/libarkts-copy/src/generated/peers/Property.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/ScopeFindResult.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +47 -14
- package/build/libarkts-copy/src/generated/peers/ScriptFunctionData.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/SignatureInfo.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/SourceRange.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/Statement.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/SuggestionInfo.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +19 -6
- package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSImportType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSInferType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +21 -8
- package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSThisType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +42 -11
- package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/TryStatement.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/TypeNode.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +8 -4
- package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/VReg.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +20 -8
- package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +12 -6
- package/build/libarkts-copy/src/generated/peers/VerificationContext.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/VerifierMessage.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +9 -5
- package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +9 -5
- package/build/libarkts-copy/src/index.ts +1 -4
- package/build/libarkts-copy/src/plugin-utils.ts +45 -32
- package/build/libarkts-copy/src/reexport-for-generated.ts +10 -1
- 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 +5 -5
- 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 +4 -5
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +4 -3
- 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/SourcePosition.ts +2 -2
- 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 +4 -3
- 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 +12 -30
- 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 +10 -8
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/visitor.ts +10 -10
- package/lib/index.js +2799 -2665
- package/package.json +2 -2
- package/templates/Es2pandaEnums.ts +1 -2
- package/templates/Es2pandaNativeModule.ts +2 -3
- package/templates/factory.ts +1 -2
- package/templates/index.ts +1 -2
- package/templates/node-map.ts +1 -2
- package/templates/peer.ts +1 -2
- 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/arkts-api/utilities/method-definition.ts +0 -38
- 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
|
@@ -17,18 +17,17 @@ import { ArktsObject } from "./ArktsObject"
|
|
|
17
17
|
import { Program } from "../../generated"
|
|
18
18
|
import { global } from "../static/global"
|
|
19
19
|
import { passString, passStringArray } from "../utilities/private"
|
|
20
|
-
import { KNativePointer,
|
|
20
|
+
import { KNativePointer, nullptr, KBoolean } from "@koalaui/interop"
|
|
21
21
|
import { Config } from "./Config"
|
|
22
|
-
import { throwError } from "../../utils"
|
|
22
|
+
import { filterSource, throwError } from "../../utils"
|
|
23
|
+
import { AstNode } from "./AstNode"
|
|
23
24
|
|
|
24
25
|
export class Context extends ArktsObject {
|
|
25
26
|
constructor(peer: KNativePointer) {
|
|
26
27
|
super(peer)
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
static createFromString(
|
|
30
|
-
source: string
|
|
31
|
-
): Context {
|
|
30
|
+
static createFromString(source: string): Context {
|
|
32
31
|
if (!global.configIsInitialized()) {
|
|
33
32
|
throw new Error(`Config not initialized`)
|
|
34
33
|
}
|
|
@@ -40,6 +39,18 @@ export class Context extends ArktsObject {
|
|
|
40
39
|
)
|
|
41
40
|
)
|
|
42
41
|
}
|
|
42
|
+
|
|
43
|
+
/** @deprecated Use {@link createCacheFromFile} instead */
|
|
44
|
+
static createCacheContextFromFile(
|
|
45
|
+
configPtr: KNativePointer,
|
|
46
|
+
fileName: string,
|
|
47
|
+
globalContextPtr: KNativePointer,
|
|
48
|
+
isExternal: KBoolean
|
|
49
|
+
): Context {
|
|
50
|
+
return new Context(
|
|
51
|
+
global.es2panda._CreateCacheContextFromFile(configPtr, passString(fileName), globalContextPtr, isExternal)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
43
54
|
|
|
44
55
|
static createFromFile(filePath: string, configPath: string, stdlibPath: string, outputPath: string): Context | undefined {
|
|
45
56
|
const config = Config.create([
|
|
@@ -89,6 +100,16 @@ export class Context extends ArktsObject {
|
|
|
89
100
|
this.peer = nullptr
|
|
90
101
|
}
|
|
91
102
|
}
|
|
103
|
+
|
|
104
|
+
/** @deprecated */
|
|
105
|
+
static destroyAndRecreate(ast: AstNode): Context {
|
|
106
|
+
console.log('[TS WRAPPER] DESTROY AND RECREATE');
|
|
107
|
+
const source = filterSource(ast.dumpSrc());
|
|
108
|
+
global.es2panda._DestroyContext(global.context);
|
|
109
|
+
global.compilerContext = Context.createFromString(source) as any; // Improve: commonize Context
|
|
110
|
+
|
|
111
|
+
return new Context(global.context);
|
|
112
|
+
}
|
|
92
113
|
|
|
93
114
|
get program(): Program {
|
|
94
115
|
return new Program(global.es2panda._ContextProgram(this.peer));
|
|
@@ -16,21 +16,20 @@
|
|
|
16
16
|
import { Es2pandaContextState } from "../generated/Es2pandaEnums"
|
|
17
17
|
import { Program } from "../generated"
|
|
18
18
|
import { ExternalSource } from "./peers/ExternalSource"
|
|
19
|
-
import { programGetExternalSources } from "./node-utilities/Program"
|
|
20
19
|
import { KNativePointer } from "@koalaui/interop"
|
|
21
20
|
import { global } from "./static/global"
|
|
21
|
+
import { RunTransformerHooks } from "../plugin-utils"
|
|
22
22
|
|
|
23
23
|
export interface CompilationOptions {
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
readonly restart: boolean,
|
|
24
|
+
readonly isProgramForCodegeneration: boolean,
|
|
25
|
+
readonly state: Es2pandaContextState,
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
export interface PluginContext {
|
|
30
29
|
setParameter<V>(name: string, value: V): void
|
|
31
30
|
parameter<V>(name: string) : V | undefined
|
|
32
|
-
|
|
33
31
|
}
|
|
32
|
+
|
|
34
33
|
export class PluginContextImpl implements PluginContext {
|
|
35
34
|
map = new Map<String, Object|undefined>()
|
|
36
35
|
parameter<V>(name: string): V|undefined {
|
|
@@ -49,10 +48,10 @@ export function defaultFilter(name: string) {
|
|
|
49
48
|
return true
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
export function listPrograms(program: Program, filter: (name: string) => boolean = defaultFilter
|
|
51
|
+
export function listPrograms(program: Program, filter: (name: string) => boolean = defaultFilter): Program[] {
|
|
53
52
|
return [
|
|
54
53
|
program,
|
|
55
|
-
...
|
|
54
|
+
...program.getExternalSources().flatMap((it: ExternalSource) => {
|
|
56
55
|
if (filter(it.getName())) {
|
|
57
56
|
return it.programs
|
|
58
57
|
}
|
|
@@ -60,3 +59,12 @@ export function listPrograms(program: Program, filter: (name: string) => boolean
|
|
|
60
59
|
})
|
|
61
60
|
]
|
|
62
61
|
}
|
|
62
|
+
|
|
63
|
+
export interface PluginEntry {
|
|
64
|
+
name?: string
|
|
65
|
+
parsed?: (hooks?: RunTransformerHooks) => void
|
|
66
|
+
checked?: (hooks?: RunTransformerHooks) => void
|
|
67
|
+
clean?: (hooks?: RunTransformerHooks) => void
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type PluginInitializer = (parsedJson?: Object, checkedJson?: Object) => PluginEntry
|
|
@@ -41,13 +41,14 @@ 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
|
+
public static isContextGenerateAbcForExternalSourceFiles: boolean = false
|
|
51
52
|
|
|
52
53
|
private static _es2panda: Es2pandaNativeModule | undefined = undefined
|
|
53
54
|
public static get es2panda(): Es2pandaNativeModule {
|
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,80 @@
|
|
|
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 { KNativePointer } from "@koalaui/interop"
|
|
17
|
+
import type {
|
|
18
|
+
ETSModule,
|
|
19
|
+
MethodDefinition,
|
|
20
|
+
Program,
|
|
21
|
+
ScriptFunction,
|
|
22
|
+
} from "../../generated"
|
|
23
|
+
import { ExternalSource } from "../peers/ExternalSource"
|
|
24
|
+
import { Es2pandaModuleFlag } from "../../generated/Es2pandaEnums"
|
|
25
|
+
import { global } from "../static/global"
|
|
26
|
+
import { acceptNativeObjectArrayResult } from "./private"
|
|
27
|
+
|
|
28
|
+
export function extension_ETSModuleGetNamespaceFlag(this: ETSModule): Es2pandaModuleFlag {
|
|
29
|
+
return (this.isETSScript ? Es2pandaModuleFlag.MODULE_FLAG_ETSSCRIPT : 0)
|
|
30
|
+
+ (this.isNamespace ? Es2pandaModuleFlag.MODULE_FLAG_NAMESPACE : 0)
|
|
31
|
+
+ (this.isNamespaceChainLastNode ? Es2pandaModuleFlag.MODULE_FLAG_NAMESPACE_CHAIN_LAST_NODE : 0)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// this is a workaround for overloads not included in children list
|
|
35
|
+
export function extension_MethodDefinitionSetChildrenParentPtr(this: MethodDefinition) {
|
|
36
|
+
global.es2panda._AstNodeSetChildrenParentPtr(global.context, this.peer)
|
|
37
|
+
const overloads = this.overloads
|
|
38
|
+
for (const overload of overloads) {
|
|
39
|
+
overload.setBaseOverloadMethod(this)
|
|
40
|
+
overload.parent = this // overloads are not listed as children in native
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function extension_MethodDefinitionOnUpdate(this: MethodDefinition, original: MethodDefinition): void {
|
|
45
|
+
this.setChildrenParentPtr()
|
|
46
|
+
// Improve: Update modifiers only for specific AST nodes in the generated factory code
|
|
47
|
+
this.modifierFlags = original.modifierFlags
|
|
48
|
+
global.generatedEs2panda._AstNodeSetOriginalNode(global.context, this.peer, original.originalPeer)
|
|
49
|
+
global.generatedEs2panda._AstNodeSetParent(global.context, this.peer, global.generatedEs2panda._AstNodeParent(global.context, original.peer))
|
|
50
|
+
const originalBase = original.baseOverloadMethod
|
|
51
|
+
if (originalBase) {
|
|
52
|
+
this.setBaseOverloadMethod(originalBase)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Improve: generate checker related stuff
|
|
57
|
+
export function extension_ScriptFunctionGetSignaturePointer(this: ScriptFunction): KNativePointer {
|
|
58
|
+
return global.es2panda._Checker_ScriptFunctionSignature(global.context, this.peer)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function extension_ScriptFunctionSetSignaturePointer(this: ScriptFunction, signaturePointer: KNativePointer): void {
|
|
62
|
+
global.es2panda._Checker_ScriptFunctionSetSignature(global.context, this.peer, signaturePointer)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Improve: perhaps "preferredReturnType" stuff can be removed later if "signature" is always enough
|
|
66
|
+
export function extension_ScriptFunctionGetPreferredReturnTypePointer(this: ScriptFunction): KNativePointer {
|
|
67
|
+
return global.es2panda._Checker_ScriptFunctionGetPreferredReturnType(global.context, this.peer)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function extension_ScriptFunctionSetPreferredReturnTypePointer(this: ScriptFunction, typePointer: KNativePointer): void {
|
|
71
|
+
global.es2panda._Checker_ScriptFunctionSetPreferredReturnType(global.context, this.peer, typePointer)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Improve: generate methods with string[] args or return type
|
|
75
|
+
export function extension_ProgramGetExternalSources(this: Program): ExternalSource[] {
|
|
76
|
+
return acceptNativeObjectArrayResult<ExternalSource>(
|
|
77
|
+
global.es2panda._ProgramExternalSources(global.context, this.peer),
|
|
78
|
+
ExternalSource.instantiate,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
@@ -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
|
}
|
|
@@ -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, Es2pandaScriptFunctionFlags } 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
|
|
164
|
+
}
|
|
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
|
|
135
206
|
}
|
|
136
|
-
return
|
|
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,13 @@ export function getFileName(): string {
|
|
|
166
245
|
return global.filePath
|
|
167
246
|
}
|
|
168
247
|
|
|
169
|
-
|
|
248
|
+
export function getJsDoc(node: AstNode): string | undefined {
|
|
249
|
+
const result = unpackString(global.es2panda._JsdocStringFromDeclaration(global.context, node.peer))
|
|
250
|
+
return result === 'Empty Jsdoc' ? undefined : result
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
// Improve: It seems like Definition overrides AstNode modifiers
|
|
170
255
|
// with it's own modifiers which is completely unrelated set of flags.
|
|
171
256
|
// Use this function if you need
|
|
172
257
|
// the language level modifiers: public, declare, export, etc.
|
|
@@ -174,7 +259,7 @@ export function classDefinitionFlags(node: ClassDefinition): Es2pandaModifierFla
|
|
|
174
259
|
return global.generatedEs2panda._AstNodeModifiers(global.context, node.peer)
|
|
175
260
|
}
|
|
176
261
|
|
|
177
|
-
//
|
|
262
|
+
// Improve: ClassProperty's optional flag is set by AstNode's modifiers flags.
|
|
178
263
|
export function classPropertySetOptional(node: ClassProperty, value: boolean): ClassProperty {
|
|
179
264
|
if (value) {
|
|
180
265
|
node.modifierFlags |= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL;
|
|
@@ -239,3 +324,106 @@ export function collectDependencies(files: string[], configPath: string): string
|
|
|
239
324
|
}
|
|
240
325
|
return Array.from(result)
|
|
241
326
|
}
|
|
327
|
+
|
|
328
|
+
export function generateTsDeclarationsFromContext(
|
|
329
|
+
outputDeclEts: string,
|
|
330
|
+
outputEts: string,
|
|
331
|
+
exportAll: boolean,
|
|
332
|
+
isolated: boolean,
|
|
333
|
+
recordFile: string
|
|
334
|
+
): KInt {
|
|
335
|
+
return global.es2panda._GenerateTsDeclarationsFromContext(
|
|
336
|
+
global.context,
|
|
337
|
+
passString(outputDeclEts),
|
|
338
|
+
passString(outputEts),
|
|
339
|
+
exportAll,
|
|
340
|
+
isolated,
|
|
341
|
+
recordFile
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function setAllParents(ast: AstNode): void {
|
|
346
|
+
global.es2panda._AstNodeUpdateAll(global.context, ast.peer);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function getProgramFromAstNode(node: AstNode): Program {
|
|
350
|
+
return new Program(global.es2panda._AstNodeProgram(global.context, node.peer))
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export function importDeclarationInsert(node: ETSImportDeclaration, program: Program): void {
|
|
354
|
+
global.es2panda._InsertETSImportDeclarationAndParse(global.context, program.peer, node.peer)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export function signatureReturnType(signature: KNativePointer): KNativePointer {
|
|
358
|
+
if (!signature) {
|
|
359
|
+
return nullptr
|
|
360
|
+
}
|
|
361
|
+
return global.es2panda._Checker_SignatureReturnType(global.context, signature)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export function tryConvertCheckerTypeToTypeNode(typePeer: KNativePointer | undefined): TypeNode | undefined {
|
|
365
|
+
if (!typePeer) {
|
|
366
|
+
return undefined
|
|
367
|
+
}
|
|
368
|
+
const str = unpackString(global.es2panda._Checker_TypeToString(global.context, typePeer))
|
|
369
|
+
// Primitive types
|
|
370
|
+
if (str == "void") {
|
|
371
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID)
|
|
372
|
+
}
|
|
373
|
+
if (str == "Byte") {
|
|
374
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_BYTE)
|
|
375
|
+
}
|
|
376
|
+
if (str == "Int") {
|
|
377
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_INT)
|
|
378
|
+
}
|
|
379
|
+
if (str == "Long") {
|
|
380
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_LONG)
|
|
381
|
+
}
|
|
382
|
+
if (str == "Short") {
|
|
383
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_SHORT)
|
|
384
|
+
}
|
|
385
|
+
if (str == "Float") {
|
|
386
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_FLOAT)
|
|
387
|
+
}
|
|
388
|
+
if (str == "Double") {
|
|
389
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_DOUBLE)
|
|
390
|
+
}
|
|
391
|
+
if (str == "Boolean") {
|
|
392
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_BOOLEAN)
|
|
393
|
+
}
|
|
394
|
+
if (str == "Char") {
|
|
395
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_CHAR)
|
|
396
|
+
}
|
|
397
|
+
// Special types
|
|
398
|
+
if (str == "undefined") {
|
|
399
|
+
return factory.createETSUndefinedType()
|
|
400
|
+
}
|
|
401
|
+
// Stdlib types
|
|
402
|
+
if (str == "String" || str == "Object" || str == "Any") {
|
|
403
|
+
return factory.createETSTypeReference(
|
|
404
|
+
factory.createETSTypeReferencePart(
|
|
405
|
+
factory.createIdentifier(str)
|
|
406
|
+
)
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
// Basic arrow type
|
|
410
|
+
if (str == "() => void") {
|
|
411
|
+
return factory.createETSFunctionType(
|
|
412
|
+
undefined,
|
|
413
|
+
[],
|
|
414
|
+
factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID),
|
|
415
|
+
false,
|
|
416
|
+
Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE,
|
|
417
|
+
undefined,
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
// Only used in samples code
|
|
421
|
+
if (str == "StringerNode") {
|
|
422
|
+
return factory.createETSTypeReference(
|
|
423
|
+
factory.createETSTypeReferencePart(
|
|
424
|
+
factory.createIdentifier(str)
|
|
425
|
+
)
|
|
426
|
+
)
|
|
427
|
+
}
|
|
428
|
+
return undefined
|
|
429
|
+
}
|