@idlizer/arktscgen 2.1.9-arktscgen-5 → 2.1.9-arktscgen-8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/libarkts-copy/generator/options.json5 +151 -0
- package/build/libarkts-copy/native/meson.build +11 -12
- package/build/libarkts-copy/native/meson_options.txt +1 -1
- package/build/libarkts-copy/native/mingw.cross +14 -0
- package/build/libarkts-copy/native/src/bridges.cc +77 -1
- package/build/libarkts-copy/native/src/common.cc +5 -5
- package/build/libarkts-copy/native/src/generated/bridges.cc +312 -33
- package/build/libarkts-copy/package.json +24 -20
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +19 -1
- package/build/libarkts-copy/src/arkts-api/ChainExpressionFilter.ts +2 -1
- package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +18 -12
- package/build/libarkts-copy/src/arkts-api/ProgramProvider.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +15 -26
- package/build/libarkts-copy/src/arkts-api/index.ts +2 -4
- package/build/libarkts-copy/src/arkts-api/node-utilities/BlockStatement.ts +0 -4
- package/build/libarkts-copy/src/arkts-api/node-utilities/CallExpression.ts +1 -22
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDefinition.ts +7 -8
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassProperty.ts +1 -22
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSFunctionType.ts +2 -5
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSImportDeclaration.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSModule.ts +44 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/ETSParameterExpression.ts +1 -4
- package/build/libarkts-copy/src/arkts-api/node-utilities/MethodDefinition.ts +3 -7
- package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +10 -0
- package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +11 -7
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +3 -6
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +13 -12
- package/build/libarkts-copy/src/arkts-api/peers/Config.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +35 -4
- package/build/libarkts-copy/src/arkts-api/plugins.ts +12 -3
- package/build/libarkts-copy/src/arkts-api/static/global.ts +2 -2
- package/build/libarkts-copy/src/{wrapper-compat/arkts-api → arkts-api}/static/globalUtils.ts +4 -4
- package/build/libarkts-copy/src/arkts-api/static/profiler.ts +0 -8
- package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +57 -0
- package/build/libarkts-copy/src/arkts-api/utilities/nativePtrDecoder.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +6 -8
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +153 -29
- package/build/libarkts-copy/src/arkts-api/visitor.ts +16 -10
- package/build/libarkts-copy/src/checkSdk.ts +15 -0
- package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +343 -321
- package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +93 -12
- package/build/libarkts-copy/src/generated/factory.ts +38 -25
- package/build/libarkts-copy/src/generated/index.ts +2 -0
- package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +15 -3
- package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/CallExpression.ts +10 -2
- package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +11 -2
- package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +20 -4
- package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +10 -2
- package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +12 -9
- package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSIntrinsicNode.ts +77 -0
- package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSModule.ts +3 -1
- package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +29 -5
- package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +12 -3
- package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +14 -2
- package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/OverloadDeclaration.ts +103 -0
- package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/Program.ts +8 -0
- package/build/libarkts-copy/src/generated/peers/Property.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +26 -9
- package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +12 -3
- package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSImportType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSInferType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +12 -3
- package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSThisType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +29 -4
- package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TryStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +11 -3
- package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +1 -1
- package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +1 -1
- package/build/libarkts-copy/src/index.ts +1 -4
- package/build/libarkts-copy/src/plugin-utils.ts +37 -37
- package/build/libarkts-copy/src/reexport-for-generated.ts +7 -0
- package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +14 -14
- package/build/libarkts-copy/src/ts-api/index.ts +1 -1
- package/build/libarkts-copy/src/ts-api/types.ts +56 -56
- package/build/libarkts-copy/src/ts-api/utilities/private.ts +6 -6
- package/build/libarkts-copy/src/ts-api/utilities/public.ts +3 -3
- package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +4 -4
- package/build/libarkts-copy/src/utils.ts +13 -159
- package/build/libarkts-copy/src/wrapper-compat/README.md +4 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/index.ts +3 -4
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrayExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrowFunctionExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/AssignmentExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/BlockStatement.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/CallExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDefinition.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassProperty.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSFunctionType.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSImportDeclaration.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSParameterExpression.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ExpressionStatement.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/IfStatement.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MemberExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MethodDefinition.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/NumberLiteral.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ObjectExpression.ts +3 -3
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/Property.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ScriptFunction.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/StructDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSInterfaceDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeParameter.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TryStatement.ts +3 -3
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclaration.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclarator.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Diagnostic.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticKind.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/ImportPathManager.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Program.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourceRange.ts +2 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SuggestionInfo.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/to-be-generated/MemberExpression.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/types.ts +10 -11
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/nativePtrDecoder.ts +1 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/private.ts +4 -4
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/public.ts +6 -6
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/visitor.ts +10 -10
- package/lib/index.js +7194 -7097
- package/package.json +2 -2
- package/templates/Es2pandaNativeModule.ts +1 -1
- package/templates/bridges.cc +5 -0
- package/build/libarkts-copy/src/arkts-api/CheckedBackFilter.ts +0 -131
- package/build/libarkts-copy/src/arkts-api/CompileWithCache.ts +0 -193
- package/build/libarkts-copy/src/arkts-api/InferVoidReturnType.ts +0 -89
- package/build/libarkts-copy/src/arkts-api/SetBaseOverloads.ts +0 -44
- package/build/libarkts-copy/src/arkts-api/node-utilities/AnnotationUsage.ts +0 -29
- package/build/libarkts-copy/src/arkts-api/node-utilities/ArrowFunctionExpression.ts +0 -49
- package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDeclaration.ts +0 -54
- package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +0 -68
- package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclaration.ts +0 -54
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/ArktsObject.ts +0 -45
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Config.ts +0 -53
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Context.ts +0 -60
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourcePosition.ts +0 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlizer/arktscgen",
|
|
3
|
-
"version": "2.1.9-arktscgen-
|
|
3
|
+
"version": "2.1.9-arktscgen-8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": "lib/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"keywords": [],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@idlizer/core": "2.1.9-arktscgen-
|
|
22
|
+
"@idlizer/core": "2.1.9-arktscgen-8",
|
|
23
23
|
"@types/node": "^18.0.0",
|
|
24
24
|
"commander": "^10.0.0",
|
|
25
25
|
"typescript": "^4.9.5"
|
package/templates/bridges.cc
CHANGED
|
@@ -1,131 +0,0 @@
|
|
|
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 { AnnotationUsage, ClassDefinition, ClassElement, Expression, isArrowFunctionExpression, isClassDefinition, isClassProperty, isETSFunctionType, isETSModule, isETSNewClassInstanceExpression, isScriptFunction, isTSEnumDeclaration, TSEnumDeclaration, TSEnumMember } from "src/generated";
|
|
17
|
-
import { AbstractVisitor } from "./AbstractVisitor";
|
|
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";
|
|
23
|
-
|
|
24
|
-
function filterAnnotations(annotations: AnnotationUsage[]): AnnotationUsage[] {
|
|
25
|
-
return annotations.filter(it => it.baseName?.name != "OptionalParametersAnnotation")
|
|
26
|
-
}
|
|
27
|
-
|
|
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 {
|
|
54
|
-
transformInitializer(node: Expression|undefined): Expression|undefined {
|
|
55
|
-
if (node == undefined) return undefined
|
|
56
|
-
if (!isETSNewClassInstanceExpression(node)) return node
|
|
57
|
-
return node.arguments[1]
|
|
58
|
-
}
|
|
59
|
-
transformEnum(node: ClassDefinition): AstNode {
|
|
60
|
-
return TSEnumDeclaration.createTSEnumDeclaration(
|
|
61
|
-
node.ident,
|
|
62
|
-
node.body.map(it => {
|
|
63
|
-
const member: ClassElement = it as ClassElement
|
|
64
|
-
if (!isClassProperty(member)) return undefined
|
|
65
|
-
if (isClassProperty(member) && member.id?.name.startsWith("#")) return undefined
|
|
66
|
-
return factory.createTSEnumMember(
|
|
67
|
-
member.key,
|
|
68
|
-
this.transformInitializer(member.value),
|
|
69
|
-
false
|
|
70
|
-
)
|
|
71
|
-
}).filter(it => it != undefined) as TSEnumMember[],
|
|
72
|
-
false,
|
|
73
|
-
false,
|
|
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'
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
visitor(beforeChildren: AstNode): AstNode {
|
|
102
|
-
const node = this.visitEachChild(beforeChildren)
|
|
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
|
-
}
|
|
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
|
-
|
|
129
|
-
return node
|
|
130
|
-
}
|
|
131
|
-
}
|
|
@@ -1,193 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
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 { factory } from "./factory/nodeFactory"
|
|
17
|
-
import { isReturnStatement, isScriptFunction, ScriptFunction } from "../generated"
|
|
18
|
-
import { AbstractVisitor } from "./AbstractVisitor"
|
|
19
|
-
import { AstNode } from "./peers/AstNode"
|
|
20
|
-
import { Es2pandaPrimitiveType, Es2pandaScriptFunctionFlags } from "src/generated/Es2pandaEnums"
|
|
21
|
-
|
|
22
|
-
interface IsScriptFunctionRoot {
|
|
23
|
-
isScriptFunctionRoot: boolean
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// TODO: this is to workaround compiler not beeing able to infer return type on recheck
|
|
27
|
-
class CheckReturns extends AbstractVisitor {
|
|
28
|
-
visitor(node: AstNode, options?: IsScriptFunctionRoot): AstNode {
|
|
29
|
-
if (isReturnStatement(node) && node.argument !== undefined) {
|
|
30
|
-
this.seenNonVoidReturn = true
|
|
31
|
-
}
|
|
32
|
-
if (isScriptFunction(node) && !options?.isScriptFunctionRoot) {
|
|
33
|
-
return node
|
|
34
|
-
}
|
|
35
|
-
return this.visitEachChild(node)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
seenNonVoidReturn: boolean = false
|
|
39
|
-
static instance?: CheckReturns
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// This function checks that it is possible to infer return type of script function as void
|
|
43
|
-
function checkReturns(node: AstNode): boolean {
|
|
44
|
-
if (!CheckReturns.instance) {
|
|
45
|
-
CheckReturns.instance = new CheckReturns()
|
|
46
|
-
}
|
|
47
|
-
CheckReturns.instance.seenNonVoidReturn = false
|
|
48
|
-
CheckReturns.instance.visitor(node, { isScriptFunctionRoot: true })
|
|
49
|
-
return CheckReturns.instance.seenNonVoidReturn == false
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
class InferVoidReturnType extends AbstractVisitor {
|
|
53
|
-
visitor(node: AstNode): AstNode {
|
|
54
|
-
const result = this.visitEachChild(node)
|
|
55
|
-
if (isScriptFunction(result) &&
|
|
56
|
-
result.returnTypeAnnotation === undefined &&
|
|
57
|
-
!result.isConstructor && // constructors should not have return type
|
|
58
|
-
(result.flags & Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_SETTER) == 0 // setters should not return void
|
|
59
|
-
) {
|
|
60
|
-
const isVoid = checkReturns(result)
|
|
61
|
-
if (isVoid) {
|
|
62
|
-
return factory.updateScriptFunction(
|
|
63
|
-
result,
|
|
64
|
-
result.body,
|
|
65
|
-
result.typeParams,
|
|
66
|
-
result.params,
|
|
67
|
-
factory.createETSPrimitiveType(
|
|
68
|
-
Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID,
|
|
69
|
-
),
|
|
70
|
-
result.hasReceiver,
|
|
71
|
-
result.flags,
|
|
72
|
-
result.modifierFlags,
|
|
73
|
-
result.id,
|
|
74
|
-
result.annotations,
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return result
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
static instance?: InferVoidReturnType
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function inferVoidReturnType(node: AstNode) {
|
|
85
|
-
if (!InferVoidReturnType.instance) {
|
|
86
|
-
InferVoidReturnType.instance = new InferVoidReturnType()
|
|
87
|
-
}
|
|
88
|
-
InferVoidReturnType.instance.visitor(node)
|
|
89
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
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 { factory } from "./factory/nodeFactory"
|
|
17
|
-
import { isMethodDefinition } from "../generated"
|
|
18
|
-
import { AbstractVisitor } from "./AbstractVisitor"
|
|
19
|
-
import { AstNode } from "./peers/AstNode"
|
|
20
|
-
|
|
21
|
-
export class SetBaseOverloads extends AbstractVisitor {
|
|
22
|
-
visitor(node: AstNode): AstNode {
|
|
23
|
-
if (isMethodDefinition(node)) {
|
|
24
|
-
const baseOverloadMethod = node
|
|
25
|
-
return factory.updateMethodDefinition(
|
|
26
|
-
node,
|
|
27
|
-
node.kind,
|
|
28
|
-
node.key,
|
|
29
|
-
node.value,
|
|
30
|
-
node.modifierFlags,
|
|
31
|
-
node.isComputed,
|
|
32
|
-
node.overloads.map((it) => {
|
|
33
|
-
it.setBaseOverloadMethod(baseOverloadMethod)
|
|
34
|
-
return it
|
|
35
|
-
})
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
return this.visitEachChild(node)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function setBaseOverloads(node: AstNode) {
|
|
43
|
-
new SetBaseOverloads().visitor(node)
|
|
44
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
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 { AnnotationUsage, Expression } from '../../generated';
|
|
17
|
-
import { isSameNativeObject } from '../peers/ArktsObject';
|
|
18
|
-
|
|
19
|
-
// TODO generate this function
|
|
20
|
-
export function updateAnnotationUsage(original: AnnotationUsage, expr?: Expression): AnnotationUsage {
|
|
21
|
-
if (isSameNativeObject(expr, original.expr)) {
|
|
22
|
-
return original;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const newNode = AnnotationUsage.updateAnnotationUsage(original, expr);
|
|
26
|
-
original.onUpdate(newNode)
|
|
27
|
-
return newNode
|
|
28
|
-
}
|
|
29
|
-
|
|
@@ -1,49 +0,0 @@
|
|
|
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 { ArrowFunctionExpression, AnnotationUsage, ScriptFunction } from "../../generated"
|
|
17
|
-
import { isSameNativeObject } from "../peers/ArktsObject"
|
|
18
|
-
import { updateNodeByNode } from "../utilities/private"
|
|
19
|
-
|
|
20
|
-
export function createArrowFunctionExpression(
|
|
21
|
-
func?: ScriptFunction,
|
|
22
|
-
annotations?: readonly AnnotationUsage[],
|
|
23
|
-
): ArrowFunctionExpression {
|
|
24
|
-
const res = ArrowFunctionExpression.createArrowFunctionExpression(
|
|
25
|
-
func
|
|
26
|
-
)
|
|
27
|
-
if (annotations) {
|
|
28
|
-
res.setAnnotations(annotations)
|
|
29
|
-
}
|
|
30
|
-
return res
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function updateArrowFunctionExpression(
|
|
34
|
-
original: ArrowFunctionExpression,
|
|
35
|
-
func?: ScriptFunction,
|
|
36
|
-
annotations?: readonly AnnotationUsage[],
|
|
37
|
-
): ArrowFunctionExpression {
|
|
38
|
-
if (isSameNativeObject(original.function, func)
|
|
39
|
-
&& isSameNativeObject(original.annotations, annotations)) {
|
|
40
|
-
return original
|
|
41
|
-
}
|
|
42
|
-
return updateNodeByNode(
|
|
43
|
-
createArrowFunctionExpression(
|
|
44
|
-
func,
|
|
45
|
-
annotations,
|
|
46
|
-
),
|
|
47
|
-
original
|
|
48
|
-
)
|
|
49
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
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 {
|
|
17
|
-
ClassDeclaration,
|
|
18
|
-
ClassDefinition,
|
|
19
|
-
} from "../../generated"
|
|
20
|
-
import { isSameNativeObject } from "../peers/ArktsObject"
|
|
21
|
-
import { updateNodeByNode } from "../utilities/private"
|
|
22
|
-
import { Es2pandaModifierFlags } from "../../generated/Es2pandaEnums"
|
|
23
|
-
|
|
24
|
-
export function createClassDeclaration(
|
|
25
|
-
def?: ClassDefinition,
|
|
26
|
-
modifierFlags?: Es2pandaModifierFlags,
|
|
27
|
-
): ClassDeclaration {
|
|
28
|
-
const res = ClassDeclaration.createClassDeclaration(
|
|
29
|
-
def,
|
|
30
|
-
)
|
|
31
|
-
if (modifierFlags) {
|
|
32
|
-
res.modifierFlags = modifierFlags
|
|
33
|
-
}
|
|
34
|
-
return res
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function updateClassDeclaration(
|
|
38
|
-
original: ClassDeclaration,
|
|
39
|
-
def?: ClassDefinition,
|
|
40
|
-
modifierFlags?: Es2pandaModifierFlags,
|
|
41
|
-
): ClassDeclaration {
|
|
42
|
-
if (isSameNativeObject(def, original.definition)
|
|
43
|
-
&& isSameNativeObject(modifierFlags, original.modifierFlags)
|
|
44
|
-
) {
|
|
45
|
-
return original
|
|
46
|
-
}
|
|
47
|
-
return updateNodeByNode(
|
|
48
|
-
createClassDeclaration(
|
|
49
|
-
def,
|
|
50
|
-
modifierFlags,
|
|
51
|
-
),
|
|
52
|
-
original
|
|
53
|
-
)
|
|
54
|
-
}
|