@idlizer/arktscgen 2.1.2
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 +155 -0
- package/build/libarkts-copy/native/meson.build +62 -0
- package/build/libarkts-copy/native/meson_options.txt +24 -0
- package/build/libarkts-copy/native/src/bridges.cc +265 -0
- package/build/libarkts-copy/native/src/common.cc +231 -0
- package/build/libarkts-copy/native/src/common.h +39 -0
- package/build/libarkts-copy/native/src/generated/bridges.cc +11979 -0
- package/build/libarkts-copy/package.json +51 -0
- package/build/libarkts-copy/src/Es2pandaEnums.ts +183 -0
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +123 -0
- package/build/libarkts-copy/src/InteropNativeModule.ts +50 -0
- package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +31 -0
- package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +147 -0
- package/build/libarkts-copy/src/arkts-api/index.ts +28 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/createCallExpression.ts +40 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/createNumberLiteral.ts +28 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/createScriptFunction.ts +55 -0
- package/build/libarkts-copy/src/arkts-api/peers/ArktsObject.ts +45 -0
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +121 -0
- package/build/libarkts-copy/src/arkts-api/peers/Config.ts +52 -0
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +46 -0
- package/build/libarkts-copy/src/arkts-api/peers/Program.ts +55 -0
- package/build/libarkts-copy/src/arkts-api/static/global.ts +67 -0
- package/build/libarkts-copy/src/arkts-api/utilities/nativePtrDecoder.ts +69 -0
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +156 -0
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +135 -0
- package/build/libarkts-copy/src/arkts-api/visitor.ts +297 -0
- package/build/libarkts-copy/src/es2panda.ts +277 -0
- package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +1266 -0
- package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +3745 -0
- package/build/libarkts-copy/src/generated/factory.ts +1299 -0
- package/build/libarkts-copy/src/generated/index.ts +191 -0
- package/build/libarkts-copy/src/generated/node-map.ts +182 -0
- package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +39 -0
- package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +49 -0
- package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +40 -0
- package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +110 -0
- package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +74 -0
- package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +98 -0
- package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +70 -0
- package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +57 -0
- package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +95 -0
- package/build/libarkts-copy/src/generated/peers/AstDumper.ts +42 -0
- package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +95 -0
- package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +64 -0
- package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +63 -0
- package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +65 -0
- package/build/libarkts-copy/src/generated/peers/CallExpression.ts +97 -0
- package/build/libarkts-copy/src/generated/peers/CatchClause.ts +64 -0
- package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +58 -0
- package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +233 -0
- package/build/libarkts-copy/src/generated/peers/ClassElement.ts +80 -0
- package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +70 -0
- package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +58 -0
- package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +74 -0
- package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +65 -0
- package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/Decorator.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +52 -0
- package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +58 -0
- package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/ETSDynamicFunctionType.ts +40 -0
- package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +84 -0
- package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +68 -0
- package/build/libarkts-copy/src/generated/peers/ETSLaunchExpression.ts +57 -0
- package/build/libarkts-copy/src/generated/peers/ETSModule.ts +71 -0
- package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +62 -0
- package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +69 -0
- package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +60 -0
- package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +51 -0
- package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +126 -0
- package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +51 -0
- package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +51 -0
- package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +73 -0
- package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +58 -0
- package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +68 -0
- package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +55 -0
- package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +58 -0
- package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +56 -0
- package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +73 -0
- package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +57 -0
- package/build/libarkts-copy/src/generated/peers/Expression.ts +75 -0
- package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +59 -0
- package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +61 -0
- package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +64 -0
- package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +61 -0
- package/build/libarkts-copy/src/generated/peers/FunctionDecl.ts +40 -0
- package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +69 -0
- package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +64 -0
- package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +62 -0
- package/build/libarkts-copy/src/generated/peers/Identifier.ts +154 -0
- package/build/libarkts-copy/src/generated/peers/IfStatement.ts +65 -0
- package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +61 -0
- package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/ImportSource.ts +49 -0
- package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +57 -0
- package/build/libarkts-copy/src/generated/peers/InterfaceDecl.ts +40 -0
- package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +60 -0
- package/build/libarkts-copy/src/generated/peers/Literal.ts +40 -0
- package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +40 -0
- package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +48 -0
- package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +95 -0
- package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +105 -0
- package/build/libarkts-copy/src/generated/peers/NamedType.ts +76 -0
- package/build/libarkts-copy/src/generated/peers/NewExpression.ts +56 -0
- package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +47 -0
- package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +90 -0
- package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +57 -0
- package/build/libarkts-copy/src/generated/peers/Property.ts +82 -0
- package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +57 -0
- package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +62 -0
- package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +201 -0
- package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +79 -0
- package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +82 -0
- package/build/libarkts-copy/src/generated/peers/Statement.ts +39 -0
- package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +56 -0
- package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +62 -0
- package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +63 -0
- package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +76 -0
- package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +60 -0
- package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +63 -0
- package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +65 -0
- package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +81 -0
- package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +66 -0
- package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +67 -0
- package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +61 -0
- package/build/libarkts-copy/src/generated/peers/TSImportType.ts +64 -0
- package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +65 -0
- package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +56 -0
- package/build/libarkts-copy/src/generated/peers/TSInferType.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +102 -0
- package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +64 -0
- package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +71 -0
- package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +63 -0
- package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +60 -0
- package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +58 -0
- package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +66 -0
- package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +72 -0
- package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +63 -0
- package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +67 -0
- package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSThisType.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +88 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +63 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +63 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +84 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +62 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +60 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +62 -0
- package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +61 -0
- package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +59 -0
- package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +60 -0
- package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +54 -0
- package/build/libarkts-copy/src/generated/peers/TryStatement.ts +75 -0
- package/build/libarkts-copy/src/generated/peers/TypeNode.ts +49 -0
- package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +39 -0
- package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +40 -0
- package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +53 -0
- package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +57 -0
- package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +50 -0
- package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +60 -0
- package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +42 -0
- package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +71 -0
- package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +69 -0
- package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +58 -0
- package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +56 -0
- package/build/libarkts-copy/src/reexport-for-generated.ts +33 -0
- package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +1375 -0
- package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +110 -0
- package/build/libarkts-copy/src/ts-api/index.ts +35 -0
- package/build/libarkts-copy/src/ts-api/static/enums.ts +18 -0
- package/build/libarkts-copy/src/ts-api/types.ts +920 -0
- package/build/libarkts-copy/src/ts-api/utilities/private.ts +289 -0
- package/build/libarkts-copy/src/ts-api/utilities/public.ts +55 -0
- package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +155 -0
- package/build/libarkts-copy/src/utils.ts +89 -0
- package/build/libarkts-copy/tsconfig.json +15 -0
- package/lib/index.js +11858 -0
- package/package.json +54 -0
- package/templates/Es2pandaEnums.ts +16 -0
- package/templates/Es2pandaNativeModule.ts +32 -0
- package/templates/bridges.cc +18 -0
- package/templates/factory.ts +34 -0
- package/templates/index.ts +16 -0
- package/templates/node-map.ts +31 -0
- package/templates/peer.ts +32 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@koalaui/libarkts",
|
|
3
|
+
"private": true,
|
|
4
|
+
"main": "./build/src/es2panda.js",
|
|
5
|
+
"types": "./build/src/arkts-api/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./build/src/arkts-api/index.js",
|
|
8
|
+
"./plugins/*": "./plugins/build/src/*.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"./build/*"
|
|
12
|
+
],
|
|
13
|
+
"config": {
|
|
14
|
+
"gen_version": "3.6.0",
|
|
15
|
+
"panda_sdk_path": "../../incremental/tools/panda/node_modules/@panda/sdk"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@koalaui/ets-tsc": "4.9.5-r4",
|
|
19
|
+
"@koalaui/build-common": "1.5.5+devel",
|
|
20
|
+
"@koalaui/interop": "1.5.5+devel",
|
|
21
|
+
"node-addon-api": "8.0.0",
|
|
22
|
+
"node-api-headers": "0.0.5",
|
|
23
|
+
"commander": "10.0.1"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"clean": "rimraf build native/build*",
|
|
27
|
+
"clean:plugins": "rimraf plugins/build",
|
|
28
|
+
"compile:koala:interop": "npm run --prefix ../../interop compile",
|
|
29
|
+
"compile:meson": "cd native && meson setup build && meson compile -C build",
|
|
30
|
+
"copy:.node": "mkdir -p ./build/native/build && cp ./native/build/es2panda.node ./build/native/build",
|
|
31
|
+
"compile:native": "npm run compile:koala:interop && npm run compile:meson && npm run copy:.node",
|
|
32
|
+
"compile:src": "npx ets-tsc -p ./tsconfig.json",
|
|
33
|
+
"compile": "npm run compile:native && npm run compile:src",
|
|
34
|
+
"compile:plugins": "npx ets-tsc -p plugins/tsconfig.json",
|
|
35
|
+
"restart": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/main.ets --output ./build/abc/main.abc --dump-plugin-ast --arktsconfig ./arktsconfig.json --restart-stages",
|
|
36
|
+
"direct": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/no-import-no-struct.ets --output ./build/abc/no-import-no-struct.abc --dump-plugin-ast --arktsconfig ./arktsconfig-print-only.json",
|
|
37
|
+
"memo": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/memo.ets --output ./build/abc/memo.abc --dump-plugin-ast --arktsconfig ./arktsconfig-memo.json --restart-stages",
|
|
38
|
+
"run": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run restart",
|
|
39
|
+
"run:memo": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run memo",
|
|
40
|
+
"run:abc": "../../incremental/tools/panda/node_modules/@panda/sdk/linux_host_tools/bin/ark --load-runtimes=ets --boot-panda-files=../../incremental/tools/panda/node_modules/@panda/sdk/ets/etsstdlib.abc ./main.abc main.ETSGLOBAL::main",
|
|
41
|
+
"mocha": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk TS_NODE_PROJECT=./test/tsconfig.json mocha -r tsconfig-paths/register --reporter-option maxDiffSize=0",
|
|
42
|
+
"test": "npm run compile:native && npm run mocha",
|
|
43
|
+
"compile:playground": "cd playground && meson setup build && meson compile -C build",
|
|
44
|
+
"run:playground": "npm run compile:playground && ./playground/build/playground.out",
|
|
45
|
+
"panda:sdk:clean": "cd ../../incremental/tools/panda && rimraf node_modules",
|
|
46
|
+
"panda:sdk:install": "cd ../../incremental/tools/panda && npm run panda:sdk:install",
|
|
47
|
+
"panda:sdk:reinstall": "npm run panda:sdk:clean && npm run panda:sdk:install",
|
|
48
|
+
"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",
|
|
49
|
+
"reinstall:regenerate": "npm run panda:sdk:reinstall && npm run regenerate"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
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
|
+
// HANDWRITTEN (for now)
|
|
17
|
+
|
|
18
|
+
export enum Es2pandaAstNodeType {
|
|
19
|
+
AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION,
|
|
20
|
+
AST_NODE_TYPE_ANNOTATION_DECLARATION,
|
|
21
|
+
AST_NODE_TYPE_ANNOTATION_USAGE,
|
|
22
|
+
AST_NODE_TYPE_ASSERT_STATEMENT,
|
|
23
|
+
AST_NODE_TYPE_AWAIT_EXPRESSION,
|
|
24
|
+
AST_NODE_TYPE_BIGINT_LITERAL,
|
|
25
|
+
AST_NODE_TYPE_BINARY_EXPRESSION,
|
|
26
|
+
AST_NODE_TYPE_BLOCK_STATEMENT,
|
|
27
|
+
AST_NODE_TYPE_BOOLEAN_LITERAL,
|
|
28
|
+
AST_NODE_TYPE_BREAK_STATEMENT,
|
|
29
|
+
AST_NODE_TYPE_CALL_EXPRESSION,
|
|
30
|
+
AST_NODE_TYPE_CATCH_CLAUSE,
|
|
31
|
+
AST_NODE_TYPE_CHAIN_EXPRESSION,
|
|
32
|
+
AST_NODE_TYPE_CHAR_LITERAL,
|
|
33
|
+
AST_NODE_TYPE_CLASS_DEFINITION,
|
|
34
|
+
AST_NODE_TYPE_CLASS_DECLARATION,
|
|
35
|
+
AST_NODE_TYPE_CLASS_EXPRESSION,
|
|
36
|
+
AST_NODE_TYPE_CLASS_PROPERTY,
|
|
37
|
+
AST_NODE_TYPE_CLASS_STATIC_BLOCK,
|
|
38
|
+
AST_NODE_TYPE_CONDITIONAL_EXPRESSION,
|
|
39
|
+
AST_NODE_TYPE_CONTINUE_STATEMENT,
|
|
40
|
+
AST_NODE_TYPE_DEBUGGER_STATEMENT,
|
|
41
|
+
AST_NODE_TYPE_DECORATOR,
|
|
42
|
+
AST_NODE_TYPE_DIRECT_EVAL,
|
|
43
|
+
AST_NODE_TYPE_DO_WHILE_STATEMENT,
|
|
44
|
+
AST_NODE_TYPE_EMPTY_STATEMENT,
|
|
45
|
+
AST_NODE_TYPE_EXPORT_ALL_DECLARATION,
|
|
46
|
+
AST_NODE_TYPE_EXPORT_DEFAULT_DECLARATION,
|
|
47
|
+
AST_NODE_TYPE_EXPORT_NAMED_DECLARATION,
|
|
48
|
+
AST_NODE_TYPE_EXPORT_SPECIFIER,
|
|
49
|
+
AST_NODE_TYPE_EXPRESSION_STATEMENT,
|
|
50
|
+
AST_NODE_TYPE_FOR_IN_STATEMENT,
|
|
51
|
+
AST_NODE_TYPE_FOR_OF_STATEMENT,
|
|
52
|
+
AST_NODE_TYPE_FOR_UPDATE_STATEMENT,
|
|
53
|
+
AST_NODE_TYPE_FUNCTION_DECLARATION,
|
|
54
|
+
AST_NODE_TYPE_FUNCTION_EXPRESSION,
|
|
55
|
+
AST_NODE_TYPE_IDENTIFIER,
|
|
56
|
+
AST_NODE_TYPE_DUMMYNODE,
|
|
57
|
+
AST_NODE_TYPE_IF_STATEMENT,
|
|
58
|
+
AST_NODE_TYPE_IMPORT_DECLARATION,
|
|
59
|
+
AST_NODE_TYPE_IMPORT_EXPRESSION,
|
|
60
|
+
AST_NODE_TYPE_IMPORT_DEFAULT_SPECIFIER,
|
|
61
|
+
AST_NODE_TYPE_IMPORT_NAMESPACE_SPECIFIER,
|
|
62
|
+
AST_NODE_TYPE_IMPORT_SPECIFIER,
|
|
63
|
+
AST_NODE_TYPE_LABELLED_STATEMENT,
|
|
64
|
+
AST_NODE_TYPE_MEMBER_EXPRESSION,
|
|
65
|
+
AST_NODE_TYPE_META_PROPERTY_EXPRESSION,
|
|
66
|
+
AST_NODE_TYPE_METHOD_DEFINITION,
|
|
67
|
+
AST_NODE_TYPE_NAMED_TYPE,
|
|
68
|
+
AST_NODE_TYPE_NEW_EXPRESSION,
|
|
69
|
+
AST_NODE_TYPE_NULL_LITERAL,
|
|
70
|
+
AST_NODE_TYPE_UNDEFINED_LITERAL,
|
|
71
|
+
AST_NODE_TYPE_NUMBER_LITERAL,
|
|
72
|
+
AST_NODE_TYPE_OMITTED_EXPRESSION,
|
|
73
|
+
AST_NODE_TYPE_PREFIX_ASSERTION_EXPRESSION,
|
|
74
|
+
AST_NODE_TYPE_PROPERTY,
|
|
75
|
+
AST_NODE_TYPE_REGEXP_LITERAL,
|
|
76
|
+
AST_NODE_TYPE_REEXPORT_STATEMENT,
|
|
77
|
+
AST_NODE_TYPE_RETURN_STATEMENT,
|
|
78
|
+
AST_NODE_TYPE_SCRIPT_FUNCTION,
|
|
79
|
+
AST_NODE_TYPE_SEQUENCE_EXPRESSION,
|
|
80
|
+
AST_NODE_TYPE_STRING_LITERAL,
|
|
81
|
+
AST_NODE_TYPE_ETS_NULL_TYPE,
|
|
82
|
+
AST_NODE_TYPE_ETS_UNDEFINED_TYPE,
|
|
83
|
+
AST_NODE_TYPE_ETS_NEVER_TYPE,
|
|
84
|
+
AST_NODE_TYPE_ETS_STRING_LITERAL_TYPE,
|
|
85
|
+
AST_NODE_TYPE_ETS_FUNCTION_TYPE,
|
|
86
|
+
AST_NODE_TYPE_ETS_WILDCARD_TYPE,
|
|
87
|
+
AST_NODE_TYPE_ETS_PRIMITIVE_TYPE,
|
|
88
|
+
AST_NODE_TYPE_ETS_PACKAGE_DECLARATION,
|
|
89
|
+
AST_NODE_TYPE_ETS_CLASS_LITERAL,
|
|
90
|
+
AST_NODE_TYPE_ETS_TYPE_REFERENCE,
|
|
91
|
+
AST_NODE_TYPE_ETS_TYPE_REFERENCE_PART,
|
|
92
|
+
AST_NODE_TYPE_ETS_UNION_TYPE,
|
|
93
|
+
AST_NODE_TYPE_ETS_LAUNCH_EXPRESSION,
|
|
94
|
+
AST_NODE_TYPE_ETS_NEW_ARRAY_INSTANCE_EXPRESSION,
|
|
95
|
+
AST_NODE_TYPE_ETS_NEW_MULTI_DIM_ARRAY_INSTANCE_EXPRESSION,
|
|
96
|
+
AST_NODE_TYPE_ETS_NEW_CLASS_INSTANCE_EXPRESSION,
|
|
97
|
+
AST_NODE_TYPE_ETS_IMPORT_DECLARATION,
|
|
98
|
+
AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION,
|
|
99
|
+
AST_NODE_TYPE_ETS_TUPLE,
|
|
100
|
+
AST_NODE_TYPE_ETS_MODULE,
|
|
101
|
+
AST_NODE_TYPE_SUPER_EXPRESSION,
|
|
102
|
+
AST_NODE_TYPE_STRUCT_DECLARATION,
|
|
103
|
+
AST_NODE_TYPE_SWITCH_CASE_STATEMENT,
|
|
104
|
+
AST_NODE_TYPE_SWITCH_STATEMENT,
|
|
105
|
+
AST_NODE_TYPE_TS_ENUM_DECLARATION,
|
|
106
|
+
AST_NODE_TYPE_TS_ENUM_MEMBER,
|
|
107
|
+
AST_NODE_TYPE_TS_EXTERNAL_MODULE_REFERENCE,
|
|
108
|
+
AST_NODE_TYPE_TS_NUMBER_KEYWORD,
|
|
109
|
+
AST_NODE_TYPE_TS_ANY_KEYWORD,
|
|
110
|
+
AST_NODE_TYPE_TS_STRING_KEYWORD,
|
|
111
|
+
AST_NODE_TYPE_TS_BOOLEAN_KEYWORD,
|
|
112
|
+
AST_NODE_TYPE_TS_VOID_KEYWORD,
|
|
113
|
+
AST_NODE_TYPE_TS_UNDEFINED_KEYWORD,
|
|
114
|
+
AST_NODE_TYPE_TS_UNKNOWN_KEYWORD,
|
|
115
|
+
AST_NODE_TYPE_TS_OBJECT_KEYWORD,
|
|
116
|
+
AST_NODE_TYPE_TS_BIGINT_KEYWORD,
|
|
117
|
+
AST_NODE_TYPE_TS_NEVER_KEYWORD,
|
|
118
|
+
AST_NODE_TYPE_TS_NON_NULL_EXPRESSION,
|
|
119
|
+
AST_NODE_TYPE_TS_NULL_KEYWORD,
|
|
120
|
+
AST_NODE_TYPE_TS_ARRAY_TYPE,
|
|
121
|
+
AST_NODE_TYPE_TS_UNION_TYPE,
|
|
122
|
+
AST_NODE_TYPE_TS_TYPE_LITERAL,
|
|
123
|
+
AST_NODE_TYPE_TS_PROPERTY_SIGNATURE,
|
|
124
|
+
AST_NODE_TYPE_TS_METHOD_SIGNATURE,
|
|
125
|
+
AST_NODE_TYPE_TS_SIGNATURE_DECLARATION,
|
|
126
|
+
AST_NODE_TYPE_TS_PARENT_TYPE,
|
|
127
|
+
AST_NODE_TYPE_TS_LITERAL_TYPE,
|
|
128
|
+
AST_NODE_TYPE_TS_INFER_TYPE,
|
|
129
|
+
AST_NODE_TYPE_TS_CONDITIONAL_TYPE,
|
|
130
|
+
AST_NODE_TYPE_TS_IMPORT_TYPE,
|
|
131
|
+
AST_NODE_TYPE_TS_INTERSECTION_TYPE,
|
|
132
|
+
AST_NODE_TYPE_TS_MAPPED_TYPE,
|
|
133
|
+
AST_NODE_TYPE_TS_MODULE_BLOCK,
|
|
134
|
+
AST_NODE_TYPE_TS_THIS_TYPE,
|
|
135
|
+
AST_NODE_TYPE_TS_TYPE_OPERATOR,
|
|
136
|
+
AST_NODE_TYPE_TS_TYPE_PARAMETER,
|
|
137
|
+
AST_NODE_TYPE_TS_TYPE_PARAMETER_DECLARATION,
|
|
138
|
+
AST_NODE_TYPE_TS_TYPE_PARAMETER_INSTANTIATION,
|
|
139
|
+
AST_NODE_TYPE_TS_TYPE_PREDICATE,
|
|
140
|
+
AST_NODE_TYPE_TS_PARAMETER_PROPERTY,
|
|
141
|
+
AST_NODE_TYPE_TS_MODULE_DECLARATION,
|
|
142
|
+
AST_NODE_TYPE_TS_IMPORT_EQUALS_DECLARATION,
|
|
143
|
+
AST_NODE_TYPE_TS_FUNCTION_TYPE,
|
|
144
|
+
AST_NODE_TYPE_TS_CONSTRUCTOR_TYPE,
|
|
145
|
+
AST_NODE_TYPE_TS_TYPE_ALIAS_DECLARATION,
|
|
146
|
+
AST_NODE_TYPE_TS_TYPE_REFERENCE,
|
|
147
|
+
AST_NODE_TYPE_TS_QUALIFIED_NAME,
|
|
148
|
+
AST_NODE_TYPE_TS_INDEXED_ACCESS_TYPE,
|
|
149
|
+
AST_NODE_TYPE_TS_INTERFACE_DECLARATION,
|
|
150
|
+
AST_NODE_TYPE_TS_INTERFACE_BODY,
|
|
151
|
+
AST_NODE_TYPE_TS_INTERFACE_HERITAGE,
|
|
152
|
+
AST_NODE_TYPE_TS_TUPLE_TYPE,
|
|
153
|
+
AST_NODE_TYPE_TS_NAMED_TUPLE_MEMBER,
|
|
154
|
+
AST_NODE_TYPE_TS_INDEX_SIGNATURE,
|
|
155
|
+
AST_NODE_TYPE_TS_TYPE_QUERY,
|
|
156
|
+
AST_NODE_TYPE_TS_AS_EXPRESSION,
|
|
157
|
+
AST_NODE_TYPE_TS_CLASS_IMPLEMENTS,
|
|
158
|
+
AST_NODE_TYPE_TS_TYPE_ASSERTION,
|
|
159
|
+
AST_NODE_TYPE_TAGGED_TEMPLATE_EXPRESSION,
|
|
160
|
+
AST_NODE_TYPE_TEMPLATE_ELEMENT,
|
|
161
|
+
AST_NODE_TYPE_TEMPLATE_LITERAL,
|
|
162
|
+
AST_NODE_TYPE_THIS_EXPRESSION,
|
|
163
|
+
AST_NODE_TYPE_TYPEOF_EXPRESSION,
|
|
164
|
+
AST_NODE_TYPE_THROW_STATEMENT,
|
|
165
|
+
AST_NODE_TYPE_TRY_STATEMENT,
|
|
166
|
+
AST_NODE_TYPE_UNARY_EXPRESSION,
|
|
167
|
+
AST_NODE_TYPE_UPDATE_EXPRESSION,
|
|
168
|
+
AST_NODE_TYPE_VARIABLE_DECLARATION,
|
|
169
|
+
AST_NODE_TYPE_VARIABLE_DECLARATOR,
|
|
170
|
+
AST_NODE_TYPE_WHILE_STATEMENT,
|
|
171
|
+
AST_NODE_TYPE_YIELD_EXPRESSION,
|
|
172
|
+
AST_NODE_TYPE_OPAQUE_TYPE_NODE,
|
|
173
|
+
AST_NODE_TYPE_BLOCK_EXPRESSION,
|
|
174
|
+
AST_NODE_TYPE_ERROR_TYPE_NODE,
|
|
175
|
+
AST_NODE_TYPE_ARRAY_EXPRESSION,
|
|
176
|
+
AST_NODE_TYPE_ARRAY_PATTERN,
|
|
177
|
+
AST_NODE_TYPE_ASSIGNMENT_EXPRESSION,
|
|
178
|
+
AST_NODE_TYPE_ASSIGNMENT_PATTERN,
|
|
179
|
+
AST_NODE_TYPE_OBJECT_EXPRESSION,
|
|
180
|
+
AST_NODE_TYPE_OBJECT_PATTERN,
|
|
181
|
+
AST_NODE_TYPE_SPREAD_ELEMENT,
|
|
182
|
+
AST_NODE_TYPE_REST_ELEMENT,
|
|
183
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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 {
|
|
17
|
+
KNativePointer as KPtr,
|
|
18
|
+
KInt,
|
|
19
|
+
KBoolean,
|
|
20
|
+
KNativePointer,
|
|
21
|
+
registerNativeModuleLibraryName,
|
|
22
|
+
loadNativeModuleLibrary,
|
|
23
|
+
KDouble,
|
|
24
|
+
KStringPtr
|
|
25
|
+
} from "@koalaui/interop"
|
|
26
|
+
import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from "./generated/Es2pandaNativeModule"
|
|
27
|
+
import * as path from "path"
|
|
28
|
+
|
|
29
|
+
// TODO: this type should be in interop
|
|
30
|
+
export type KPtrArray = BigUint64Array
|
|
31
|
+
|
|
32
|
+
export class Es2pandaNativeModule {
|
|
33
|
+
_AnnotationAllowedAnnotations(context: KPtr, node: KPtr, returnLen: KPtr): KPtr {
|
|
34
|
+
throw new Error("Not implemented")
|
|
35
|
+
}
|
|
36
|
+
_AstNodeRebind(context: KPtr, node: KPtr): void {
|
|
37
|
+
throw new Error("Not implemented")
|
|
38
|
+
}
|
|
39
|
+
_AstNodeRecheck(context: KPtr, node: KPtr): void {
|
|
40
|
+
throw new Error("Not implemented")
|
|
41
|
+
}
|
|
42
|
+
_ContextState(context: KPtr): KInt {
|
|
43
|
+
throw new Error("Not implemented")
|
|
44
|
+
}
|
|
45
|
+
_ContextErrorMessage(context: KPtr): KPtr {
|
|
46
|
+
throw new Error("Not implemented")
|
|
47
|
+
}
|
|
48
|
+
_AstNodeChildren(context: KPtr, node: KPtr): KPtr {
|
|
49
|
+
throw new Error("Not implemented")
|
|
50
|
+
}
|
|
51
|
+
_AstNodeDumpModifiers(context: KPtr, node: KPtr): KPtr {
|
|
52
|
+
throw new Error("Not implemented")
|
|
53
|
+
}
|
|
54
|
+
_CreateConfig(argc: number, argv: string[]): KPtr {
|
|
55
|
+
throw new Error("Not implemented")
|
|
56
|
+
}
|
|
57
|
+
_DestroyConfig(peer: KNativePointer): void {
|
|
58
|
+
throw new Error("Not implemented")
|
|
59
|
+
}
|
|
60
|
+
_CreateContextFromString(config: KPtr, source: String, filename: String): KPtr {
|
|
61
|
+
throw new Error("Not implemented")
|
|
62
|
+
}
|
|
63
|
+
_DestroyContext(context: KPtr): void {
|
|
64
|
+
throw new Error("Not implemented")
|
|
65
|
+
}
|
|
66
|
+
_ProceedToState(context: KPtr, state: number): void {
|
|
67
|
+
throw new Error("Not implemented")
|
|
68
|
+
}
|
|
69
|
+
_ContextProgram(context: KPtr): KPtr {
|
|
70
|
+
throw new Error("Not implemented")
|
|
71
|
+
}
|
|
72
|
+
_ProgramAst(context: KPtr, program: KPtr): KPtr {
|
|
73
|
+
throw new Error("Not implemented")
|
|
74
|
+
}
|
|
75
|
+
_CheckerStartChecker(context: KPtr): KBoolean {
|
|
76
|
+
throw new Error("Not implemented")
|
|
77
|
+
}
|
|
78
|
+
_AstNodeVariableConst(context: KPtr, ast: KPtr): KPtr {
|
|
79
|
+
throw new Error("Not implemented")
|
|
80
|
+
}
|
|
81
|
+
_CreateNumberLiteral(context: KPtr, value: KDouble): KPtr {
|
|
82
|
+
throw new Error("Not implemented")
|
|
83
|
+
}
|
|
84
|
+
_AstNodeUpdateChildren(context: KPtr, node: KPtr): void {
|
|
85
|
+
throw new Error("Not implemented")
|
|
86
|
+
}
|
|
87
|
+
_AstNodeUpdateAll(context: KPtr, node: KPtr): void {
|
|
88
|
+
throw new Error("Not implemented")
|
|
89
|
+
}
|
|
90
|
+
_VariableDeclaration(context: KPtr, variable: KPtr): KPtr {
|
|
91
|
+
throw new Error("Not implemented")
|
|
92
|
+
}
|
|
93
|
+
_DeclNode(context: KPtr, decl: KPtr): KPtr {
|
|
94
|
+
throw new Error("Not implemented")
|
|
95
|
+
}
|
|
96
|
+
_DeclarationFromIdentifier(context: KPtr, identifier: KPtr): KPtr {
|
|
97
|
+
throw new Error("Not implemented")
|
|
98
|
+
}
|
|
99
|
+
_ProgramExternalSources(context: KNativePointer, instance: KNativePointer): KNativePointer {
|
|
100
|
+
throw new Error("Not implemented");
|
|
101
|
+
}
|
|
102
|
+
_ExternalSourceName(instance: KNativePointer): KNativePointer {
|
|
103
|
+
throw new Error("Not implemented");
|
|
104
|
+
}
|
|
105
|
+
_ExternalSourcePrograms(instance: KNativePointer): KNativePointer {
|
|
106
|
+
throw new Error("Not implemented");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function initEs2panda(): Es2pandaNativeModule {
|
|
111
|
+
registerNativeModuleLibraryName("NativeModule", path.resolve(__dirname, "../native/build/es2panda.node"))
|
|
112
|
+
const instance = new Es2pandaNativeModule()
|
|
113
|
+
loadNativeModuleLibrary("NativeModule", instance)
|
|
114
|
+
return instance
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function initGeneratedEs2panda(): GeneratedEs2pandaNativeModule {
|
|
118
|
+
registerNativeModuleLibraryName("NativeModule", path.resolve(__dirname, "../native/build/es2panda.node"))
|
|
119
|
+
const instance = new GeneratedEs2pandaNativeModule()
|
|
120
|
+
// registerNativeModule("InteropNativeModule", NativeModule)
|
|
121
|
+
loadNativeModuleLibrary("NativeModule", instance)
|
|
122
|
+
return instance
|
|
123
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 {
|
|
17
|
+
KNativePointer as KPtr,
|
|
18
|
+
KInt,
|
|
19
|
+
registerNativeModuleLibraryName,
|
|
20
|
+
loadNativeModuleLibrary
|
|
21
|
+
} from "@koalaui/interop"
|
|
22
|
+
import * as path from "path"
|
|
23
|
+
|
|
24
|
+
export class InteropNativeModule {
|
|
25
|
+
_StringLength(ptr: KPtr): KInt {
|
|
26
|
+
throw new Error("Not implemented")
|
|
27
|
+
}
|
|
28
|
+
_StringData(ptr: KPtr, buffer: KPtr, length: KInt): void {
|
|
29
|
+
throw new Error("Not implemented")
|
|
30
|
+
}
|
|
31
|
+
_GetStringFinalizer(): KPtr {
|
|
32
|
+
throw new Error("Not implemented")
|
|
33
|
+
}
|
|
34
|
+
_InvokeFinalizer(ptr: KPtr, finalizer: KPtr): void {
|
|
35
|
+
throw new Error("Not implemented")
|
|
36
|
+
}
|
|
37
|
+
_GetPtrVectorSize(ptr: KPtr): KInt {
|
|
38
|
+
throw new Error("Not implemented")
|
|
39
|
+
}
|
|
40
|
+
_GetPtrVectorElement(ptr: KPtr, index: KInt): KPtr {
|
|
41
|
+
throw new Error("Not implemented")
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function initInterop(): InteropNativeModule {
|
|
46
|
+
registerNativeModuleLibraryName("InteropNativeModule", path.join(__dirname, "../native/build/es2panda"))
|
|
47
|
+
const instance = new InteropNativeModule()
|
|
48
|
+
loadNativeModuleLibrary("InteropNativeModule", instance)
|
|
49
|
+
return instance
|
|
50
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 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 { Es2pandaAstNodeType } from "../Es2pandaEnums"
|
|
17
|
+
import { throwError } from "../utils"
|
|
18
|
+
import { global } from "./static/global"
|
|
19
|
+
import { KNativePointer, nullptr } from "@koalaui/interop"
|
|
20
|
+
import { AstNode, UnsupportedNode } from "./peers/AstNode"
|
|
21
|
+
|
|
22
|
+
export const nodeByType = new Map<Es2pandaAstNodeType, { new(peer: KNativePointer): AstNode }>([])
|
|
23
|
+
|
|
24
|
+
export function classByPeer<T extends AstNode>(peer: KNativePointer): T {
|
|
25
|
+
if (peer === nullptr) {
|
|
26
|
+
throwError('classByPeer: peer is NULLPTR')
|
|
27
|
+
}
|
|
28
|
+
const type = global.generatedEs2panda._AstNodeTypeConst(global.context, peer)
|
|
29
|
+
const node = nodeByType.get(type) ?? UnsupportedNode
|
|
30
|
+
return new node(peer) as T
|
|
31
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
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 { updateNodeByNode } from "../utilities/private"
|
|
17
|
+
import { AstNode } from "../peers/AstNode"
|
|
18
|
+
import {
|
|
19
|
+
ClassDefinition,
|
|
20
|
+
ClassProperty,
|
|
21
|
+
ETSFunctionType,
|
|
22
|
+
ETSImportDeclaration,
|
|
23
|
+
ETSParameterExpression,
|
|
24
|
+
ETSStructDeclaration,
|
|
25
|
+
ETSTypeReferencePart,
|
|
26
|
+
MemberExpression,
|
|
27
|
+
MethodDefinition,
|
|
28
|
+
TSInterfaceDeclaration,
|
|
29
|
+
TSTypeParameter,
|
|
30
|
+
VariableDeclarator,
|
|
31
|
+
} from "../../generated"
|
|
32
|
+
import { factory as generatedFactory } from "../../generated/factory"
|
|
33
|
+
import { createScriptFunction } from "../node-utilities/createScriptFunction"
|
|
34
|
+
import { createCallExpression } from "../node-utilities/createCallExpression"
|
|
35
|
+
import { createNumberLiteral } from "../node-utilities/createNumberLiteral"
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated
|
|
39
|
+
* expect no new handwritten nodes to appear in the future
|
|
40
|
+
* however, if they do appear, they should have proper update
|
|
41
|
+
*/
|
|
42
|
+
function compose<T extends AstNode, ARGS extends any[]>(
|
|
43
|
+
create: (...args: ARGS) => T,
|
|
44
|
+
update: (node: T, original: T) => T = updateNodeByNode
|
|
45
|
+
): (node: T, ...args: ARGS) => T {
|
|
46
|
+
return (node: T, ...args: ARGS) => update(create(...args), node);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const factory = {
|
|
50
|
+
...generatedFactory,
|
|
51
|
+
get createCallExpression() {
|
|
52
|
+
return createCallExpression
|
|
53
|
+
},
|
|
54
|
+
get updateCallExpression() {
|
|
55
|
+
return compose(createCallExpression)
|
|
56
|
+
},
|
|
57
|
+
get createMemberExpression() {
|
|
58
|
+
return MemberExpression.createMemberExpression
|
|
59
|
+
},
|
|
60
|
+
get updateMemberExpression() {
|
|
61
|
+
return compose(MemberExpression.createMemberExpression)
|
|
62
|
+
},
|
|
63
|
+
get createScriptFunction() {
|
|
64
|
+
return createScriptFunction
|
|
65
|
+
},
|
|
66
|
+
get updateScriptFunction() {
|
|
67
|
+
return compose(createScriptFunction)
|
|
68
|
+
},
|
|
69
|
+
get createNumberLiteral() {
|
|
70
|
+
return createNumberLiteral
|
|
71
|
+
},
|
|
72
|
+
get updateNumberLiteral() {
|
|
73
|
+
return compose(createNumberLiteral)
|
|
74
|
+
},
|
|
75
|
+
get createETSParameterExpression() {
|
|
76
|
+
return ETSParameterExpression.createETSParameterExpression
|
|
77
|
+
},
|
|
78
|
+
get updateETSParameterExpression() {
|
|
79
|
+
return compose(ETSParameterExpression.createETSParameterExpression)
|
|
80
|
+
},
|
|
81
|
+
get create1ETSParameterExpression() {
|
|
82
|
+
return ETSParameterExpression.create1ETSParameterExpression
|
|
83
|
+
},
|
|
84
|
+
get update1ETSParameterExpression() {
|
|
85
|
+
return compose(ETSParameterExpression.create1ETSParameterExpression)
|
|
86
|
+
},
|
|
87
|
+
get createTypeParameter() {
|
|
88
|
+
return TSTypeParameter.create1TSTypeParameter
|
|
89
|
+
},
|
|
90
|
+
get updateTypeParameter() {
|
|
91
|
+
return compose(TSTypeParameter.create1TSTypeParameter)
|
|
92
|
+
},
|
|
93
|
+
get createETSTypeReferencePart() {
|
|
94
|
+
return ETSTypeReferencePart.createETSTypeReferencePart
|
|
95
|
+
},
|
|
96
|
+
get updateTypeReferencePart() {
|
|
97
|
+
return compose(ETSTypeReferencePart.createETSTypeReferencePart)
|
|
98
|
+
},
|
|
99
|
+
get createETSImportDeclaration() {
|
|
100
|
+
return ETSImportDeclaration.createETSImportDeclaration
|
|
101
|
+
},
|
|
102
|
+
get updateETSImportDeclaration() {
|
|
103
|
+
return compose(ETSImportDeclaration.createETSImportDeclaration)
|
|
104
|
+
},
|
|
105
|
+
get createVariableDeclarator() {
|
|
106
|
+
return VariableDeclarator.create1VariableDeclarator
|
|
107
|
+
},
|
|
108
|
+
get updateVariableDeclarator() {
|
|
109
|
+
return compose(VariableDeclarator.create1VariableDeclarator)
|
|
110
|
+
},
|
|
111
|
+
get createETSStructDeclaration() {
|
|
112
|
+
return ETSStructDeclaration.createETSStructDeclaration
|
|
113
|
+
},
|
|
114
|
+
get updateETSStructDeclaration() {
|
|
115
|
+
return compose(ETSStructDeclaration.createETSStructDeclaration)
|
|
116
|
+
},
|
|
117
|
+
get createClassDefinition() {
|
|
118
|
+
return ClassDefinition.createClassDefinition
|
|
119
|
+
},
|
|
120
|
+
get updateClassDefinition() {
|
|
121
|
+
return compose(ClassDefinition.createClassDefinition)
|
|
122
|
+
},
|
|
123
|
+
get createClassProperty() {
|
|
124
|
+
return ClassProperty.createClassProperty
|
|
125
|
+
},
|
|
126
|
+
get updateClassProperty() {
|
|
127
|
+
return compose(ClassProperty.createClassProperty)
|
|
128
|
+
},
|
|
129
|
+
get createFunctionType() {
|
|
130
|
+
return ETSFunctionType.createETSFunctionType
|
|
131
|
+
},
|
|
132
|
+
get updateFunctionType() {
|
|
133
|
+
return compose(ETSFunctionType.createETSFunctionType)
|
|
134
|
+
},
|
|
135
|
+
get createMethodDefinition() {
|
|
136
|
+
return MethodDefinition.createMethodDefinition
|
|
137
|
+
},
|
|
138
|
+
get updateMethodDefinition() {
|
|
139
|
+
return compose(MethodDefinition.createMethodDefinition)
|
|
140
|
+
},
|
|
141
|
+
get createInterfaceDeclaration() {
|
|
142
|
+
return TSInterfaceDeclaration.createTSInterfaceDeclaration
|
|
143
|
+
},
|
|
144
|
+
get updateInterfaceDeclaration() {
|
|
145
|
+
return compose(TSInterfaceDeclaration.createTSInterfaceDeclaration)
|
|
146
|
+
},
|
|
147
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
export * from "../Es2pandaEnums"
|
|
17
|
+
export * from "../generated/Es2pandaEnums"
|
|
18
|
+
export * from "../generated"
|
|
19
|
+
|
|
20
|
+
export * from "./utilities/private"
|
|
21
|
+
export * from "./utilities/public"
|
|
22
|
+
export * from "./factory/nodeFactory"
|
|
23
|
+
export * from "./visitor"
|
|
24
|
+
|
|
25
|
+
export * from "./peers/AstNode"
|
|
26
|
+
export * from "./peers/Config"
|
|
27
|
+
export * from "./peers/Context"
|
|
28
|
+
export * from "./peers/Program"
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { BlockStatement } from "../../generated/peers/BlockStatement"
|
|
17
|
+
import { CallExpression } from "../../generated/peers/CallExpression"
|
|
18
|
+
import { Expression } from "../../generated/peers/Expression"
|
|
19
|
+
import { TSTypeParameterInstantiation } from "../../generated/peers/TSTypeParameterInstantiation"
|
|
20
|
+
|
|
21
|
+
export function createCallExpression(
|
|
22
|
+
callee: Expression | undefined,
|
|
23
|
+
_arguments: readonly Expression[],
|
|
24
|
+
typeParams: TSTypeParameterInstantiation | undefined,
|
|
25
|
+
optional_arg: boolean = false,
|
|
26
|
+
trailingComma: boolean = false,
|
|
27
|
+
trailingBlock: BlockStatement | undefined = undefined,
|
|
28
|
+
) {
|
|
29
|
+
const res = CallExpression.createCallExpression(
|
|
30
|
+
callee,
|
|
31
|
+
_arguments,
|
|
32
|
+
typeParams,
|
|
33
|
+
optional_arg,
|
|
34
|
+
trailingComma,
|
|
35
|
+
)
|
|
36
|
+
if (trailingBlock) {
|
|
37
|
+
res.setTrailingBlock(trailingBlock)
|
|
38
|
+
}
|
|
39
|
+
return res
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { global } from "../static/global"
|
|
17
|
+
import { NumberLiteral } from "../../generated"
|
|
18
|
+
|
|
19
|
+
export function createNumberLiteral(
|
|
20
|
+
value: number
|
|
21
|
+
) {
|
|
22
|
+
return new NumberLiteral(
|
|
23
|
+
global.es2panda._CreateNumberLiteral(
|
|
24
|
+
global.context,
|
|
25
|
+
value
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
}
|