@idlizer/arktscgen 2.1.7 → 2.1.9-arktscgen-5
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 +34 -0
- package/build/libarkts-copy/native/meson.build +128 -75
- package/build/libarkts-copy/native/meson_options.txt +6 -0
- package/build/libarkts-copy/native/src/bridges.cc +271 -8
- package/build/libarkts-copy/native/src/common.cc +168 -47
- package/build/libarkts-copy/native/src/common.h +53 -8
- package/build/libarkts-copy/native/src/generated/bridges.cc +2625 -319
- package/build/libarkts-copy/package.json +31 -17
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +98 -4
- package/build/libarkts-copy/src/arkts-api/AbstractVisitor.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/ChainExpressionFilter.ts +78 -0
- package/build/libarkts-copy/src/arkts-api/CheckedBackFilter.ts +86 -8
- package/build/libarkts-copy/src/arkts-api/CompileWithCache.ts +193 -0
- package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +78 -0
- package/build/libarkts-copy/src/arkts-api/InferVoidReturnType.ts +89 -0
- package/build/libarkts-copy/src/arkts-api/ProgramProvider.ts +50 -0
- package/build/libarkts-copy/src/arkts-api/SetBaseOverloads.ts +10 -17
- package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +2 -3
- package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +18 -6
- package/build/libarkts-copy/src/arkts-api/index.ts +10 -1
- package/build/libarkts-copy/src/arkts-api/node-cache.ts +8 -4
- package/build/libarkts-copy/src/arkts-api/node-utilities/AnnotationUsage.ts +29 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/ArkTsConfig.ts +25 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/ArrayExpression.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/BlockStatement.ts +29 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/CallExpression.ts +2 -2
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDeclaration.ts +54 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDefinition.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassProperty.ts +3 -3
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSFunctionType.ts +2 -2
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSImportDeclaration.ts +3 -33
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSParameterExpression.ts +3 -9
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSStructDeclaration.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSTuple.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/MemberExpression.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/MethodDefinition.ts +2 -2
- package/build/libarkts-copy/src/arkts-api/node-utilities/NumberLiteral.ts +2 -2
- package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +40 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +2 -2
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeParameter.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeReferencePart.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclaration.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclarator.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/peers/ArktsObject.ts +3 -1
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +80 -15
- package/build/libarkts-copy/src/arkts-api/peers/Config.ts +8 -1
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +71 -4
- package/build/libarkts-copy/src/arkts-api/peers/{Program.ts → ExternalSource.ts} +2 -22
- package/build/libarkts-copy/src/arkts-api/peers/Options.ts +34 -0
- package/build/libarkts-copy/src/arkts-api/plugins.ts +26 -12
- package/build/libarkts-copy/src/arkts-api/static/global.ts +10 -4
- package/build/libarkts-copy/src/arkts-api/static/profiler.ts +180 -23
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +22 -24
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +54 -12
- package/build/libarkts-copy/src/arkts-api/visitor.ts +32 -37
- package/build/libarkts-copy/src/arkts-api/wrapper-compat.ts +32 -0
- package/build/libarkts-copy/src/checkSdk.ts +25 -0
- package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +450 -442
- package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +769 -63
- package/build/libarkts-copy/src/generated/factory.ts +12 -15
- package/build/libarkts-copy/src/generated/index.ts +10 -3
- package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +64 -6
- package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +16 -4
- package/build/libarkts-copy/src/generated/peers/ArkTsConfig.ts +67 -0
- package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +46 -6
- package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/AstDumper.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/AstVerifier.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/AstVisitor.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/BindingProps.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +30 -7
- package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +16 -4
- package/build/libarkts-copy/src/generated/peers/CallExpression.ts +24 -3
- package/build/libarkts-copy/src/generated/peers/CatchClause.ts +16 -4
- package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +37 -4
- package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +136 -42
- package/build/libarkts-copy/src/generated/peers/ClassElement.ts +28 -4
- package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +43 -5
- package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/CodeGen.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +16 -4
- package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/Declaration.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/Decorator.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/{OverloadInfo.ts → DiagnosticInfo.ts} +8 -2
- package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/DynamicImportData.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +20 -5
- package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSModule.ts +63 -4
- package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +54 -12
- package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +26 -8
- package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +19 -4
- package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +22 -4
- package/build/libarkts-copy/src/generated/peers/ErrorLogger.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +30 -7
- package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +30 -3
- package/build/libarkts-copy/src/generated/peers/Expression.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +10 -2
- package/build/libarkts-copy/src/generated/peers/FunctionDecl.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +50 -6
- package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +16 -4
- package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/IRNode.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/Identifier.ts +24 -5
- package/build/libarkts-copy/src/generated/peers/IfStatement.ts +18 -3
- package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +32 -4
- package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ImportSource.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/IndexInfo.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/InterfaceDecl.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/LabelPair.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/Literal.ts +15 -1
- package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +30 -10
- package/build/libarkts-copy/src/generated/peers/NamedType.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/NewExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +25 -9
- package/build/libarkts-copy/src/generated/peers/ObjectDescriptor.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/Program.ts +189 -0
- package/build/libarkts-copy/src/generated/peers/Property.ts +16 -4
- package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +16 -4
- package/build/libarkts-copy/src/generated/peers/ScopeFindResult.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +81 -10
- package/build/libarkts-copy/src/generated/peers/ScriptFunctionData.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/SignatureInfo.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/SourceRange.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +46 -9
- package/build/libarkts-copy/src/generated/peers/Statement.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +16 -4
- package/build/libarkts-copy/src/generated/peers/{ETSDynamicFunctionType.ts → SuggestionInfo.ts} +7 -5
- package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +52 -6
- package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSImportType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSInferType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +82 -8
- package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSThisType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +59 -6
- package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +47 -7
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +19 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/TryStatement.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/TypeNode.ts +37 -3
- package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +19 -4
- package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +13 -3
- package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +14 -4
- package/build/libarkts-copy/src/generated/peers/VReg.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +52 -8
- package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +17 -5
- package/build/libarkts-copy/src/generated/peers/VerificationContext.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/VerifierMessage.ts +7 -1
- package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +19 -4
- package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +14 -4
- package/build/libarkts-copy/src/index.ts +13 -1
- package/build/libarkts-copy/src/plugin-utils.ts +117 -0
- package/build/libarkts-copy/src/utils.ts +17 -28
- package/build/libarkts-copy/src/wrapper-compat/README.md +16 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/class-by-peer.ts +46 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/factory/nodeFactory.ts +454 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/factory/nodeTests.ts +99 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/index.ts +88 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrayExpression.ts +38 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrowFunctionExpression.ts +35 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/AssignmentExpression.ts +38 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/BlockStatement.ts +27 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/CallExpression.ts +45 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDeclaration.ts +27 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDefinition.ts +73 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassProperty.ts +51 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSFunctionType.ts +42 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSImportDeclaration.ts +39 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSParameterExpression.ts +43 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ExpressionStatement.ts +28 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionDeclaration.ts +37 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionExpression.ts +28 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/IfStatement.ts +37 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MemberExpression.ts +42 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MethodDefinition.ts +46 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/NumberLiteral.ts +30 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ObjectExpression.ts +37 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/Property.ts +27 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ScriptFunction.ts +46 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/StructDeclaration.ts +28 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSInterfaceDeclaration.ts +47 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +40 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeParameter.ts +36 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TryStatement.ts +41 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclaration.ts +42 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclarator.ts +39 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/ArktsObject.ts +45 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/AstNode.ts +26 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Config.ts +53 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Context.ts +60 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Diagnostic.ts +39 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +33 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticKind.ts +33 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/ImportPathManager.ts +34 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Program.ts +105 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourcePosition.ts +38 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourceRange.ts +38 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SuggestionInfo.ts +33 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/static/global.ts +16 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/static/globalUtils.ts +27 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/to-be-generated/MemberExpression.ts +108 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/types.ts +907 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/nativePtrDecoder.ts +69 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/performance.ts +190 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/private.ts +198 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/public.ts +325 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/visitor.ts +421 -0
- package/build/libarkts-copy/src/wrapper-compat/index.ts +20 -0
- package/lib/index.js +330 -149
- package/package.json +2 -2
- package/templates/Es2pandaEnums.ts +4 -0
- package/templates/Es2pandaNativeModule.ts +5 -1
- package/templates/factory.ts +5 -1
- package/templates/index.ts +5 -1
- package/templates/node-map.ts +5 -1
- package/templates/peer.ts +5 -1
- package/build/libarkts-copy/README.md +0 -36
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaui/libarkts",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5+devel",
|
|
4
4
|
"bin": "./lib/es2panda",
|
|
5
|
-
"
|
|
5
|
+
"typesVersions": {
|
|
6
|
+
"*": {
|
|
7
|
+
"./compat/*": [
|
|
8
|
+
"./build/wrapper-compat/index.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"*": [
|
|
11
|
+
"./build/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
6
15
|
"exports": {
|
|
7
16
|
".": "./lib/libarkts.js",
|
|
17
|
+
"./compat": "./lib/libarkts-compat.js",
|
|
8
18
|
"./plugins/*": "./lib/plugins/*.js"
|
|
9
19
|
},
|
|
10
20
|
"files": [
|
|
@@ -13,17 +23,17 @@
|
|
|
13
23
|
"./plugins/build/src/**/*"
|
|
14
24
|
],
|
|
15
25
|
"config": {
|
|
16
|
-
"gen_version": "2.1.
|
|
26
|
+
"gen_version": "2.1.9-arktscgen-5",
|
|
17
27
|
"panda_sdk_path": "../../incremental/tools/panda/node_modules/@panda/sdk",
|
|
18
28
|
"ohos_panda_sdk_path": "../build/sdk",
|
|
19
|
-
"panda_sdk_version": "
|
|
29
|
+
"panda_sdk_version": "next"
|
|
20
30
|
},
|
|
21
31
|
"dependencies": {
|
|
22
32
|
"@koalaui/ets-tsc": "4.9.5-r5",
|
|
23
|
-
"@koalaui/build-common": "1.7.
|
|
24
|
-
"@koalaui/compat": "1.7.
|
|
25
|
-
"@koalaui/common": "1.7.
|
|
26
|
-
"@koalaui/interop": "1.7.
|
|
33
|
+
"@koalaui/build-common": "1.7.5+devel",
|
|
34
|
+
"@koalaui/compat": "1.7.5+devel",
|
|
35
|
+
"@koalaui/common": "1.7.5+devel",
|
|
36
|
+
"@koalaui/interop": "1.7.5+devel",
|
|
27
37
|
"node-addon-api": "8.0.0",
|
|
28
38
|
"node-api-headers": "0.0.5",
|
|
29
39
|
"commander": "10.0.1"
|
|
@@ -40,10 +50,13 @@
|
|
|
40
50
|
"clean:plugins": "rimraf plugins/build",
|
|
41
51
|
"compile:koala:interop": "npm run --prefix ../../interop compile",
|
|
42
52
|
"compile:meson": "cd native && meson setup build && meson compile -C build",
|
|
43
|
-
"
|
|
53
|
+
"crosscompile:meson": "cd native && CXX=clang++ meson setup -D cross_compile=true build && CXX=clang++ meson compile -C build",
|
|
54
|
+
"copy:.node": "mkdir -p ./build/native/build && cp ./native/build/es2panda_*.node ./build/native/build",
|
|
44
55
|
"compile:native": "npm run compile:koala:interop && npm run compile:meson && npm run copy:.node",
|
|
56
|
+
"crosscompile:native": "npm run compile:koala:interop && npm run crosscompile:meson && npm run copy:.node",
|
|
45
57
|
"compile:src": "npx ets-tsc -p ./tsconfig.json",
|
|
46
58
|
"compile": "npm run compile:native && npm run compile:js",
|
|
59
|
+
"compile:release": "npm run crosscompile:native && npm run compile:js",
|
|
47
60
|
"compile:js": "npm run compile:src && rollup -c rollup.lib.mjs && rollup -c rollup.es2panda.mjs",
|
|
48
61
|
"compile:gn": "npm run compile:koala:interop && npm run compile:js",
|
|
49
62
|
"compile:plugins": "npx rollup -c ./rollup.printer-plugin.mjs && npx rollup -c ./rollup.no-visitor-plugin.mjs ",
|
|
@@ -51,19 +64,20 @@
|
|
|
51
64
|
"direct": "node ../fast-arktsc --config arktsconfig.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/abc/main.abc && ninja -f build/abc/build.ninja",
|
|
52
65
|
"run": "npm run compile && npm run compile:plugins && npm run direct",
|
|
53
66
|
"run:memo": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run memo",
|
|
54
|
-
"run:abc": "
|
|
55
|
-
"mocha": "PANDA_SDK_PATH
|
|
56
|
-
"mocha:ohos": "PANDA_SDK_PATH
|
|
57
|
-
"test": "npm run
|
|
58
|
-
"test
|
|
67
|
+
"run:abc": "$npm_package_config_panda_sdk_path/linux_host_tools/bin/ark --load-runtimes=ets --boot-panda-files=$npm_package_config_panda_sdk_path/ets/etsstdlib.abc ./main.abc main.ETSGLOBAL::main",
|
|
68
|
+
"mocha": "PANDA_SDK_PATH=${PANDA_SDK_PATH:=$npm_package_config_panda_sdk_path} TS_NODE_PROJECT=./test/tsconfig.json mocha -r tsconfig-paths/register --reporter-option maxDiffSize=0",
|
|
69
|
+
"mocha:ohos": "PANDA_SDK_PATH=${PANDA_SDK_PATH:=$npm_package_config_ohos_panda_sdk_path} TS_NODE_PROJECT=./test/tsconfig.json mocha -r tsconfig-paths/register --reporter-option maxDiffSize=0",
|
|
70
|
+
"test:light": "npm run mocha",
|
|
71
|
+
"test": "npm run compile:native && npm run test:light",
|
|
72
|
+
"test:golden": "npm run compile:native && TEST_GOLDEN=1 npm run test:light",
|
|
59
73
|
"compile:playground": "cd playground && meson setup build && meson compile -C build",
|
|
60
74
|
"run:playground": "npm run compile:playground && ./playground/build/playground.out",
|
|
61
75
|
"panda:sdk:clean": "cd ../../incremental/tools/panda && rimraf node_modules",
|
|
62
|
-
"panda:sdk:install": "cd ../../incremental/tools/panda && PANDA_SDK_VERSION=$npm_package_config_panda_sdk_version npm run panda:sdk:install
|
|
76
|
+
"panda:sdk:install": "cd ../../incremental/tools/panda && echo \"Installing panda sdk $npm_package_config_panda_sdk_version\" && PANDA_SDK_VERSION=$npm_package_config_panda_sdk_version npm run panda:sdk:install",
|
|
63
77
|
"panda:sdk:reinstall": "npm run panda:sdk:clean && npm run panda:sdk:install",
|
|
64
78
|
"regenerate:current": "npm run compile -C ../../../arktscgen && node ../../../arktscgen --panda-sdk-path $npm_package_config_panda_sdk_path --output-dir ../ --options-file ./generator/options.json5 --no-initialize --debug",
|
|
65
79
|
"regenerate": "npx --yes @idlizer/arktscgen@$npm_package_config_gen_version --panda-sdk-path $npm_package_config_panda_sdk_path --output-dir ../ --options-file ./generator/options.json5 --no-initialize",
|
|
66
|
-
"regenerate:ohos": "npx --yes @idlizer/arktscgen@$npm_package_config_gen_version --panda-sdk-path $npm_package_config_ohos_panda_sdk_path --output-dir ../ --options-file ./generator/options.json5 --no-initialize",
|
|
80
|
+
"regenerate:ohos": "npx --yes @idlizer/arktscgen@$npm_package_config_gen_version --panda-sdk-path ${PANDA_SDK_PATH:=$npm_package_config_ohos_panda_sdk_path} --output-dir ../ --options-file ./generator/options.json5 --no-initialize",
|
|
67
81
|
"reinstall:regenerate": "npm run panda:sdk:reinstall && npm run regenerate"
|
|
68
82
|
}
|
|
69
|
-
}
|
|
83
|
+
}
|
|
@@ -22,10 +22,12 @@ import {
|
|
|
22
22
|
loadNativeModuleLibrary,
|
|
23
23
|
KDouble,
|
|
24
24
|
KUInt,
|
|
25
|
+
KStringArrayPtr,
|
|
25
26
|
} from "@koalaui/interop"
|
|
26
27
|
import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule, KNativePointerArray } from "./generated/Es2pandaNativeModule"
|
|
27
28
|
import * as path from "path"
|
|
28
29
|
import * as fs from "fs"
|
|
30
|
+
import { Es2pandaPluginDiagnosticType } from "./generated/Es2pandaEnums"
|
|
29
31
|
|
|
30
32
|
// TODO: this type should be in interop
|
|
31
33
|
export type KPtrArray = BigUint64Array
|
|
@@ -61,6 +63,24 @@ export class Es2pandaNativeModule {
|
|
|
61
63
|
_CreateContextFromString(config: KPtr, source: String, filename: String): KPtr {
|
|
62
64
|
throw new Error("Not implemented")
|
|
63
65
|
}
|
|
66
|
+
_CreateContextFromFile(config: KPtr, filename: String): KPtr {
|
|
67
|
+
throw new Error("Not implemented")
|
|
68
|
+
}
|
|
69
|
+
_CreateCacheContextFromFile(config: KNativePointer, sourceFileName: String, globalContext: KNativePointer, isExternal: KBoolean): KNativePointer {
|
|
70
|
+
throw new Error("Not implemented");
|
|
71
|
+
}
|
|
72
|
+
_InsertGlobalStructInfo(context: KNativePointer, str: String): void {
|
|
73
|
+
throw new Error("Not implemented");
|
|
74
|
+
}
|
|
75
|
+
_HasGlobalStructInfo(context: KNativePointer, str: String): KBoolean {
|
|
76
|
+
throw new Error("Not implemented");
|
|
77
|
+
}
|
|
78
|
+
_CreateGlobalContext(config: KNativePointer, externalFileList: KStringArrayPtr, fileNum: KUInt, lspUsage: KBoolean): KNativePointer {
|
|
79
|
+
throw new Error("Not implemented");
|
|
80
|
+
}
|
|
81
|
+
_DestroyGlobalContext(context: KNativePointer): void {
|
|
82
|
+
throw new Error("Not implemented");
|
|
83
|
+
}
|
|
64
84
|
_DestroyContext(context: KPtr): void {
|
|
65
85
|
throw new Error("Not implemented")
|
|
66
86
|
}
|
|
@@ -82,7 +102,7 @@ export class Es2pandaNativeModule {
|
|
|
82
102
|
_CreateNumberLiteral(context: KPtr, value: KDouble): KPtr {
|
|
83
103
|
throw new Error("Not implemented")
|
|
84
104
|
}
|
|
85
|
-
|
|
105
|
+
_AstNodeSetChildrenParentPtr(context: KPtr, node: KPtr): void {
|
|
86
106
|
throw new Error("Not implemented")
|
|
87
107
|
}
|
|
88
108
|
_AstNodeUpdateAll(context: KPtr, node: KPtr): void {
|
|
@@ -97,9 +117,15 @@ export class Es2pandaNativeModule {
|
|
|
97
117
|
_DeclarationFromIdentifier(context: KPtr, identifier: KPtr): KPtr {
|
|
98
118
|
throw new Error("Not implemented")
|
|
99
119
|
}
|
|
120
|
+
_ProgramSourceFilePath(context: KNativePointer, instance: KNativePointer): KNativePointer {
|
|
121
|
+
throw new Error("Not implemented");
|
|
122
|
+
}
|
|
100
123
|
_ProgramExternalSources(context: KNativePointer, instance: KNativePointer): KNativePointer {
|
|
101
124
|
throw new Error("Not implemented");
|
|
102
125
|
}
|
|
126
|
+
_ProgramDirectExternalSources(context: KNativePointer, instance: KNativePointer): KNativePointer {
|
|
127
|
+
throw new Error("Not implemented")
|
|
128
|
+
}
|
|
103
129
|
_ExternalSourceName(instance: KNativePointer): KNativePointer {
|
|
104
130
|
throw new Error("Not implemented");
|
|
105
131
|
}
|
|
@@ -127,12 +153,79 @@ export class Es2pandaNativeModule {
|
|
|
127
153
|
_SourcePositionLine(context: KNativePointer, instance: KNativePointer): KInt {
|
|
128
154
|
throw new Error("Not implemented");
|
|
129
155
|
}
|
|
156
|
+
_ConfigGetOptions(config: KNativePointer): KNativePointer {
|
|
157
|
+
throw new Error("Not implemented");
|
|
158
|
+
}
|
|
159
|
+
_OptionsArkTsConfig(context: KNativePointer, options: KNativePointer): KNativePointer {
|
|
160
|
+
throw new Error("Not implemented");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// From koala-wrapper
|
|
164
|
+
_ClassVariableDeclaration(context: KNativePointer, classInstance: KNativePointer): KNativePointer {
|
|
165
|
+
throw new Error("Not implemented")
|
|
166
|
+
}
|
|
167
|
+
_IsMethodDefinition(node: KPtr): KBoolean {
|
|
168
|
+
throw new Error("Not implemented")
|
|
169
|
+
}
|
|
170
|
+
_SourceRangeStart(context: KNativePointer, range: KNativePointer): KNativePointer {
|
|
171
|
+
throw new Error("Not implemented")
|
|
172
|
+
}
|
|
173
|
+
_SourceRangeEnd(context: KNativePointer, range: KNativePointer): KNativePointer {
|
|
174
|
+
throw new Error("Not implemented")
|
|
175
|
+
}
|
|
176
|
+
_CreateSourceRange(context: KNativePointer, start: KNativePointer, end: KNativePointer): KNativePointer {
|
|
177
|
+
throw new Error("Not implemented")
|
|
178
|
+
}
|
|
179
|
+
_IsArrayExpression(node: KPtr): KBoolean {
|
|
180
|
+
throw new Error("Not implemented")
|
|
181
|
+
}
|
|
182
|
+
_ETSParserGetGlobalProgramAbsName(context: KNativePointer): KNativePointer {
|
|
183
|
+
throw new Error("Not implemented")
|
|
184
|
+
}
|
|
185
|
+
_CreateDiagnosticKind(context: KNativePointer, message: string, type: Es2pandaPluginDiagnosticType): KNativePointer {
|
|
186
|
+
throw new Error("Not implemented")
|
|
187
|
+
}
|
|
188
|
+
_CreateDiagnosticInfo(context: KNativePointer, kind: KNativePointer, args: string[], argc: number): KNativePointer {
|
|
189
|
+
throw new Error("Not implemented")
|
|
190
|
+
}
|
|
191
|
+
_CreateSuggestionInfo(context: KNativePointer, kind: KNativePointer, args: string[],
|
|
192
|
+
argc: number, substitutionCode: string): KNativePointer {
|
|
193
|
+
throw new Error("Not implemented")
|
|
194
|
+
}
|
|
195
|
+
_LogDiagnostic(context: KNativePointer, kind: KNativePointer, argv: string[], argc: number, pos: KNativePointer): void {
|
|
196
|
+
throw new Error("Not implemented")
|
|
197
|
+
}
|
|
198
|
+
_LogDiagnosticWithSuggestion(context: KNativePointer, diagnosticInfo: KNativePointer,
|
|
199
|
+
suggestionInfo?: KNativePointer, range?: KNativePointer): void {
|
|
200
|
+
throw new Error("Not implemented")
|
|
201
|
+
}
|
|
202
|
+
_SetUpSoPath(soPath: string): void {
|
|
203
|
+
throw new Error("Not implemented")
|
|
204
|
+
}
|
|
205
|
+
_MemInitialize(): void {
|
|
206
|
+
throw new Error("Not implemented")
|
|
207
|
+
}
|
|
208
|
+
_MemFinalize(): void {
|
|
209
|
+
throw new Error("Not implemented")
|
|
210
|
+
}
|
|
211
|
+
_ProgramCanSkipPhases(context: KNativePointer, program: KNativePointer): boolean {
|
|
212
|
+
throw new Error("Not implemented")
|
|
213
|
+
}
|
|
214
|
+
_GenerateTsDeclarationsFromContext(config: KPtr, outputDeclEts: String, outputEts: String, exportAll: KBoolean, isolated: KBoolean): KPtr {
|
|
215
|
+
throw new Error("Not implemented")
|
|
216
|
+
}
|
|
217
|
+
_GenerateStaticDeclarationsFromContext(config: KPtr, outputPath: String): KPtr {
|
|
218
|
+
throw new Error("Not implemented")
|
|
219
|
+
}
|
|
220
|
+
_AstNodeProgram(context: KNativePointer, instance: KNativePointer): KNativePointer {
|
|
221
|
+
throw new Error("Not implemented")
|
|
222
|
+
}
|
|
130
223
|
}
|
|
131
224
|
|
|
132
225
|
export function findNativeModule(): string {
|
|
133
226
|
const candidates = [
|
|
134
|
-
path.resolve(__dirname, "../native/build
|
|
135
|
-
path.resolve(__dirname, "../build/native/build
|
|
227
|
+
path.resolve(__dirname, "../native/build"),
|
|
228
|
+
path.resolve(__dirname, "../build/native/build"),
|
|
136
229
|
]
|
|
137
230
|
let result = undefined
|
|
138
231
|
candidates.forEach(path => {
|
|
@@ -141,7 +234,8 @@ export function findNativeModule(): string {
|
|
|
141
234
|
return
|
|
142
235
|
}
|
|
143
236
|
})
|
|
144
|
-
if (result)
|
|
237
|
+
if (result)
|
|
238
|
+
return path.join(result, "es2panda")
|
|
145
239
|
throw new Error("Cannot find native module")
|
|
146
240
|
}
|
|
147
241
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2025 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { ChainExpression, Expression, isChainExpression, isMemberExpression, MemberExpression } from "src/generated";
|
|
17
|
+
import { AbstractVisitor } from "./AbstractVisitor";
|
|
18
|
+
import { AstNode } from "./peers/AstNode"
|
|
19
|
+
import { factory } from "./factory/nodeFactory";
|
|
20
|
+
import { Es2pandaTokenType, Es2pandaVariableDeclarationKind, Es2pandaVariableDeclaratorFlag } from "src/generated/Es2pandaEnums";
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export class ChainExpressionFilter extends AbstractVisitor {
|
|
24
|
+
static counter = 0
|
|
25
|
+
transformChainExpression(node: ChainExpression): Expression {
|
|
26
|
+
const expression = node.expression
|
|
27
|
+
if (expression == undefined) return node
|
|
28
|
+
if (!isMemberExpression(expression)) return node
|
|
29
|
+
return this.transformMemberExpression(expression)
|
|
30
|
+
}
|
|
31
|
+
transformMemberExpression(expression: MemberExpression): Expression {
|
|
32
|
+
const temporaryVarName = `chaintmp%%_${ChainExpressionFilter.counter++}`
|
|
33
|
+
return factory.createBlockExpression(
|
|
34
|
+
[
|
|
35
|
+
factory.createVariableDeclaration(
|
|
36
|
+
Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_LET,
|
|
37
|
+
[
|
|
38
|
+
factory.createVariableDeclarator(
|
|
39
|
+
Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_LET,
|
|
40
|
+
factory.createIdentifier(temporaryVarName),
|
|
41
|
+
expression.object
|
|
42
|
+
)
|
|
43
|
+
],
|
|
44
|
+
undefined
|
|
45
|
+
),
|
|
46
|
+
factory.createExpressionStatement(
|
|
47
|
+
factory.createConditionalExpression(
|
|
48
|
+
factory.createBinaryExpression(
|
|
49
|
+
factory.createIdentifier(temporaryVarName, undefined),
|
|
50
|
+
factory.createUndefinedLiteral(),
|
|
51
|
+
Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_STRICT_EQUAL
|
|
52
|
+
),
|
|
53
|
+
factory.createUndefinedLiteral(),
|
|
54
|
+
factory.createMemberExpression(
|
|
55
|
+
factory.createIdentifier(temporaryVarName, undefined),
|
|
56
|
+
expression.property,
|
|
57
|
+
expression.kind,
|
|
58
|
+
expression.isComputed,
|
|
59
|
+
false
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
]
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
visitor(beforeChildren: AstNode): AstNode {
|
|
69
|
+
const node = this.visitEachChild(beforeChildren)
|
|
70
|
+
if (isChainExpression(node)) {
|
|
71
|
+
return this.transformChainExpression(node)
|
|
72
|
+
}
|
|
73
|
+
if (isMemberExpression(node) && node.isOptional) {
|
|
74
|
+
return this.transformMemberExpression(node)
|
|
75
|
+
}
|
|
76
|
+
return node
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2025 Huawei Device Co., Ltd.
|
|
3
3
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License.
|
|
5
5
|
* You may obtain a copy of the License at
|
|
@@ -13,16 +13,47 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { ClassDefinition, ClassElement,
|
|
16
|
+
import { AnnotationUsage, ClassDefinition, ClassElement, Expression, isArrowFunctionExpression, isClassDefinition, isClassProperty, isETSFunctionType, isETSModule, isETSNewClassInstanceExpression, isScriptFunction, isTSEnumDeclaration, TSEnumDeclaration, TSEnumMember } from "src/generated";
|
|
17
17
|
import { AbstractVisitor } from "./AbstractVisitor";
|
|
18
18
|
import { AstNode } from "./peers/AstNode"
|
|
19
|
+
import { Es2pandaModifierFlags } from "src/generated/Es2pandaEnums";
|
|
20
|
+
import { factory } from "src/generated/factory";
|
|
21
|
+
import { arkts } from "src";
|
|
22
|
+
import { TypeAliasDeclaration } from "@koalaui/ets-tsc";
|
|
19
23
|
|
|
24
|
+
function filterAnnotations(annotations: AnnotationUsage[]): AnnotationUsage[] {
|
|
25
|
+
return annotations.filter(it => it.baseName?.name != "OptionalParametersAnnotation")
|
|
26
|
+
}
|
|
20
27
|
|
|
21
|
-
export class
|
|
28
|
+
export abstract class ContextAwareVisitor extends AbstractVisitor {
|
|
29
|
+
private contextStack: ('global' | 'namespace')[] = ['global']
|
|
30
|
+
protected get context() {
|
|
31
|
+
return this.contextStack.at(-1)!
|
|
32
|
+
}
|
|
33
|
+
private enter(node:AstNode): () => void {
|
|
34
|
+
if (isETSModule(node) && node.ident?.name !== 'ETSGLOBAL') {
|
|
35
|
+
this.contextStack.push('namespace')
|
|
36
|
+
return () => this.contextStack.pop()
|
|
37
|
+
}
|
|
38
|
+
if (isClassDefinition(node) && node.isNamespaceTransformed && node.ident?.name !== 'ETSGLOBAL') {
|
|
39
|
+
this.contextStack.push('namespace')
|
|
40
|
+
return () => this.contextStack.pop()
|
|
41
|
+
}
|
|
42
|
+
return () => {}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
visitEachChild(node: AstNode, options?: object): AstNode {
|
|
46
|
+
const leave = this.enter(node)
|
|
47
|
+
const r = super.visitEachChild(node, options)
|
|
48
|
+
leave()
|
|
49
|
+
return r
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class CheckedBackFilter extends ContextAwareVisitor {
|
|
22
54
|
transformInitializer(node: Expression|undefined): Expression|undefined {
|
|
23
55
|
if (node == undefined) return undefined
|
|
24
56
|
if (!isETSNewClassInstanceExpression(node)) return node
|
|
25
|
-
// new ZZZ(ordinal, value) !-> value
|
|
26
57
|
return node.arguments[1]
|
|
27
58
|
}
|
|
28
59
|
transformEnum(node: ClassDefinition): AstNode {
|
|
@@ -40,14 +71,61 @@ export class CheckedBackFilter extends AbstractVisitor {
|
|
|
40
71
|
}).filter(it => it != undefined) as TSEnumMember[],
|
|
41
72
|
false,
|
|
42
73
|
false,
|
|
43
|
-
!!(node.modifierFlags & Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE)
|
|
74
|
+
!!(node.modifierFlags & Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE) && this.context !== 'namespace'
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
transformScopedClass(node:ClassDefinition): ClassDefinition {
|
|
78
|
+
return ClassDefinition.createClassDefinition(
|
|
79
|
+
node.ident,
|
|
80
|
+
node.typeParams,
|
|
81
|
+
node.superTypeParams,
|
|
82
|
+
node.implements,
|
|
83
|
+
node.ctor,
|
|
84
|
+
node.super,
|
|
85
|
+
node.body,
|
|
86
|
+
node.modifiers,
|
|
87
|
+
this.context === 'namespace'
|
|
88
|
+
? node.modifierFlags & (~Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE)
|
|
89
|
+
: node.modifierFlags
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
transformScopedEnum(node:TSEnumDeclaration): TSEnumDeclaration {
|
|
93
|
+
return TSEnumDeclaration.createTSEnumDeclaration(
|
|
94
|
+
node.key,
|
|
95
|
+
node.members,
|
|
96
|
+
node.isConst,
|
|
97
|
+
false,
|
|
98
|
+
!!(node.modifierFlags & Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE) && this.context !== 'namespace'
|
|
44
99
|
)
|
|
45
100
|
}
|
|
46
101
|
visitor(beforeChildren: AstNode): AstNode {
|
|
47
102
|
const node = this.visitEachChild(beforeChildren)
|
|
48
|
-
if (
|
|
49
|
-
return this.
|
|
103
|
+
if (isTSEnumDeclaration(node)) {
|
|
104
|
+
return this.transformScopedEnum(node)
|
|
105
|
+
}
|
|
106
|
+
if (isClassDefinition(node)) {
|
|
107
|
+
if (node.isEnumTransformed) {
|
|
108
|
+
return this.transformEnum(node)
|
|
109
|
+
} else {
|
|
110
|
+
const transformed = this.context === 'namespace'
|
|
111
|
+
? this.transformScopedClass(node)
|
|
112
|
+
: node
|
|
113
|
+
return transformed.setAnnotations(filterAnnotations([...node.annotations]))
|
|
114
|
+
}
|
|
50
115
|
}
|
|
116
|
+
if (isClassProperty(node)) {
|
|
117
|
+
return node.setAnnotations(filterAnnotations([...node.annotations]))
|
|
118
|
+
}
|
|
119
|
+
if (isArrowFunctionExpression(node)) {
|
|
120
|
+
return node.setAnnotations(filterAnnotations([...node.annotations]))
|
|
121
|
+
}
|
|
122
|
+
if (isETSFunctionType(node)) {
|
|
123
|
+
return node.setAnnotations(filterAnnotations([...node.annotations]))
|
|
124
|
+
}
|
|
125
|
+
if (isScriptFunction(node)) {
|
|
126
|
+
return node.setAnnotations(filterAnnotations([...node.annotations]))
|
|
127
|
+
}
|
|
128
|
+
|
|
51
129
|
return node
|
|
52
130
|
}
|
|
53
|
-
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { Config } from "./peers/Config"
|
|
17
|
+
import { CompilationOptions, PluginContextImpl, ProgramTransformer } from "./plugins"
|
|
18
|
+
import { findStdlib, proceedToState, recheckContext } from "./utilities/public"
|
|
19
|
+
import { global } from "./static/global"
|
|
20
|
+
import { passString, passStringArray } from "./utilities/private"
|
|
21
|
+
import { Context } from "./peers/Context"
|
|
22
|
+
import { Es2pandaContextState } from "../generated/Es2pandaEnums"
|
|
23
|
+
import { Program } from "../generated"
|
|
24
|
+
import { runTransformerOnProgram } from "../plugin-utils"
|
|
25
|
+
import { ProgramProvider } from "./ProgramProvider"
|
|
26
|
+
import { Options } from "./peers/Options"
|
|
27
|
+
|
|
28
|
+
export interface ProgramInfo {
|
|
29
|
+
/**
|
|
30
|
+
* Input to compile (absolute file path)
|
|
31
|
+
*/
|
|
32
|
+
absoluteName: string
|
|
33
|
+
/**
|
|
34
|
+
* Location of output (undefined for external sources)
|
|
35
|
+
*/
|
|
36
|
+
output: string | undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getProgramsForPluginApplication(
|
|
40
|
+
programs: ProgramInfo[],
|
|
41
|
+
) {
|
|
42
|
+
const programsForCodeGeneration = programs
|
|
43
|
+
.filter(it => it.output != undefined)
|
|
44
|
+
.map(it => it.absoluteName)
|
|
45
|
+
// Generally, it would be ok to return just the list above,
|
|
46
|
+
// but for experimental purpose let's filter programs that
|
|
47
|
+
// are mentioned as both codegeneration and caching
|
|
48
|
+
const programsForCaching = new Set(
|
|
49
|
+
programs
|
|
50
|
+
.filter(it => it.output == undefined)
|
|
51
|
+
.map(it => it.absoluteName)
|
|
52
|
+
)
|
|
53
|
+
return programsForCodeGeneration.filter(it => !programsForCaching.has(it))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function compileWithCache(
|
|
57
|
+
configPath: string,
|
|
58
|
+
orderedPrograms: ProgramInfo[],
|
|
59
|
+
parsedPlugins: ProgramTransformer[] | undefined,
|
|
60
|
+
checkedPlugins: ProgramTransformer[] | undefined,
|
|
61
|
+
) {
|
|
62
|
+
if (orderedPrograms.length == 0) {
|
|
63
|
+
console.log("No files to compile")
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
const globalConfig = Config.create(
|
|
67
|
+
[
|
|
68
|
+
'_', '--arktsconfig', configPath, '--extension', 'ets', '--stdlib', findStdlib(),
|
|
69
|
+
orderedPrograms[0].absoluteName // Putting some file here to avoid "Fatal error: Unresolved module name"
|
|
70
|
+
]
|
|
71
|
+
)
|
|
72
|
+
console.log(orderedPrograms)
|
|
73
|
+
const globalContext = global.es2panda._CreateGlobalContext(
|
|
74
|
+
globalConfig.peer,
|
|
75
|
+
passStringArray(orderedPrograms.map(it => it.absoluteName)),
|
|
76
|
+
orderedPrograms.length,
|
|
77
|
+
false
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
const programsForPluginApplication = getProgramsForPluginApplication(
|
|
81
|
+
orderedPrograms
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
orderedPrograms.forEach((it) => {
|
|
85
|
+
console.log(">>>", "considering", it.absoluteName)
|
|
86
|
+
const args = ['_', '--arktsconfig', configPath, '--extension', 'ets', '--stdlib', findStdlib()]
|
|
87
|
+
if (it.output) {
|
|
88
|
+
args.push('--output', it.output, it.absoluteName)
|
|
89
|
+
}
|
|
90
|
+
const config = Config.create(
|
|
91
|
+
args
|
|
92
|
+
)
|
|
93
|
+
const isExternalProgram = (it.output == undefined)
|
|
94
|
+
const context = global.es2panda._CreateCacheContextFromFile(
|
|
95
|
+
config.peer,
|
|
96
|
+
passString(it.absoluteName),
|
|
97
|
+
globalContext,
|
|
98
|
+
isExternalProgram,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
global.config = config.peer
|
|
102
|
+
global.compilerContext = new Context(context)
|
|
103
|
+
const options = Options.createOptions(new Config(global.config))
|
|
104
|
+
global.arktsconfig = options.getArkTsConfig()
|
|
105
|
+
|
|
106
|
+
function applyPlugins(plugins: ProgramTransformer[] | undefined, state: Es2pandaContextState) {
|
|
107
|
+
plugins?.forEach(plugin => {
|
|
108
|
+
const program = new Program(global.es2panda._ContextProgram(context))
|
|
109
|
+
const provider = new ProgramProvider(program)
|
|
110
|
+
let currentProgram = provider.next()
|
|
111
|
+
let isFirstProgram = true
|
|
112
|
+
while (currentProgram) {
|
|
113
|
+
if (
|
|
114
|
+
(!isExternalProgram && programsForPluginApplication.includes(currentProgram.absoluteName)) ||
|
|
115
|
+
(isExternalProgram && currentProgram.absoluteName == it.absoluteName)
|
|
116
|
+
) {
|
|
117
|
+
const options: CompilationOptions = {
|
|
118
|
+
isMainProgram: isFirstProgram,
|
|
119
|
+
stage: state,
|
|
120
|
+
restart: false,
|
|
121
|
+
}
|
|
122
|
+
runTransformerOnProgram(
|
|
123
|
+
currentProgram,
|
|
124
|
+
options,
|
|
125
|
+
plugin,
|
|
126
|
+
new PluginContextImpl(),
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
currentProgram = provider.next()
|
|
130
|
+
isFirstProgram = false
|
|
131
|
+
}
|
|
132
|
+
if (state == Es2pandaContextState.ES2PANDA_STATE_CHECKED) {
|
|
133
|
+
recheckContext(context)
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function proceedToParsed() {
|
|
139
|
+
proceedToState(Es2pandaContextState.ES2PANDA_STATE_PARSED)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function applyParsedPlugins() {
|
|
143
|
+
applyPlugins(parsedPlugins, Es2pandaContextState.ES2PANDA_STATE_PARSED)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function proceedToChecked() {
|
|
147
|
+
proceedToState(Es2pandaContextState.ES2PANDA_STATE_CHECKED)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function applyCheckedPlugins() {
|
|
151
|
+
applyPlugins(checkedPlugins, Es2pandaContextState.ES2PANDA_STATE_CHECKED)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function proceedToFinalState() {
|
|
155
|
+
if (isExternalProgram) {
|
|
156
|
+
proceedToState(Es2pandaContextState.ES2PANDA_STATE_LOWERED)
|
|
157
|
+
} else {
|
|
158
|
+
proceedToState(Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function cleanup() {
|
|
163
|
+
global.es2panda._DestroyContext(
|
|
164
|
+
context
|
|
165
|
+
)
|
|
166
|
+
global.es2panda._DestroyConfig(
|
|
167
|
+
config.peer
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const operations = [
|
|
172
|
+
proceedToParsed,
|
|
173
|
+
applyParsedPlugins,
|
|
174
|
+
proceedToChecked,
|
|
175
|
+
applyCheckedPlugins,
|
|
176
|
+
proceedToFinalState,
|
|
177
|
+
cleanup,
|
|
178
|
+
]
|
|
179
|
+
|
|
180
|
+
operations.forEach(operation => {
|
|
181
|
+
console.log('>>>', operation.name)
|
|
182
|
+
operation()
|
|
183
|
+
console.log('>>>', operation.name, 'OK')
|
|
184
|
+
})
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
global.es2panda._DestroyGlobalContext(
|
|
188
|
+
globalContext
|
|
189
|
+
)
|
|
190
|
+
global.es2panda._DestroyConfig(
|
|
191
|
+
globalConfig.peer
|
|
192
|
+
)
|
|
193
|
+
}
|