From aa8c3aa5494010b940255ef97bf16166a691b4b2 Mon Sep 17 00:00:00 2001 From: Igor Loginov Date: Fri, 15 Aug 2025 13:40:46 +0300 Subject: [PATCH 1/3] Signature rewrite without transformer --- .../src/transform/FunctionTransformer.ts | 23 ++---- .../src/transform/MemoTransformer.ts | 3 - .../src/transform/SignatureTransformer.ts | 76 +++++++------------ .../memo-plugin/test/golden/HQ/abstract.ets | 4 +- .../test/golden/HQ/arrow-assignment.ets | 2 +- .../memo-plugin/test/golden/HQ/call-type.ets | 2 +- ui2abc/memo-plugin/test/golden/HQ/compute.ets | 4 +- .../test/golden/HQ/content-usage.ets | 2 +- .../test/golden/HQ/implicit-void-method.ets | 2 +- .../test/golden/HQ/instantiate.ets | 2 +- .../test/golden/HQ/internal-call.ets | 4 +- .../memo-plugin/test/golden/HQ/internals.ets | 2 +- .../test/golden/HQ/intrinsic-call.ets | 2 +- ui2abc/memo-plugin/test/golden/HQ/invoke.ets | 2 +- .../test/golden/HQ/memo-property-type.ets | 2 +- .../test/golden/HQ/memo-property.ets | 2 +- .../test/golden/HQ/non-memo-property.ets | 2 +- .../test/golden/HQ/object-param.ets | 4 +- .../test/golden/HQ/param-calls-optional.ets | 2 +- .../test/golden/HQ/param-calls.ets | 2 +- .../test/golden/HQ/property-constructor.ets | 2 +- .../test/golden/HQ/static-void-method.ets | 4 +- .../test/golden/HQ/string-compute.ets | 4 +- .../test/golden/HQ/string-method.ets | 4 +- .../test/golden/HQ/type-param-method.ets | 4 +- .../test/golden/HQ/void-compute.ets | 4 +- .../test/golden/HQ/void-method-with-param.ets | 4 +- .../golden/HQ/void-method-with-return.ets | 4 +- .../test/golden/HQ/void-method.ets | 4 +- .../test/golden/basic/function.ets | 2 +- .../memo-plugin/test/golden/basic/method.ets | 2 +- .../test/golden/implicit-type/main.ets | 2 +- ui2abc/memo-plugin/test/golden/other.ets | 54 ++++++------- .../memo-on-optional-param.ets | 2 +- ...o-on-optional-possibly-undefined-param.ets | 2 +- .../on-param-and-type/memo-on-param.ets | 2 +- .../memo-on-possibly-undefined-param.ets | 2 +- .../on-param/memo-on-optional-param.ets | 2 +- ...o-on-optional-possibly-undefined-param.ets | 2 +- .../param-usage/on-param/memo-on-param.ets | 2 +- .../memo-on-possibly-undefined-param.ets | 2 +- .../on-type/memo-on-optional-param.ets | 2 +- ...o-on-optional-possibly-undefined-param.ets | 2 +- .../param-usage/on-type/memo-on-param.ets | 2 +- .../memo-on-possibly-undefined-param.ets | 2 +- .../union-with-non-memo/primitive.ets | 4 +- 46 files changed, 116 insertions(+), 150 deletions(-) diff --git a/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts b/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts index 759fd8107..e5c0bbdd5 100644 --- a/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts @@ -23,7 +23,6 @@ import { import { ParameterTransformer, ParamInfo } from "./ParameterTransformer" import { ReturnTransformer } from "./ReturnTranformer" import { InternalsTransformer } from "./InternalsTransformer" -import { SignatureTransformer } from "./SignatureTransformer" import { castParameters, hasMemoStableAnnotation, @@ -41,6 +40,7 @@ import { MemoPluginContext, RuntimeNames } from "../common" +import { rewriteSignature } from "./SignatureTransformer" function needThisRewrite(hasReceiver: boolean, isStatic: boolean, stableThis: boolean) { return hasReceiver && !isStatic && !stableThis @@ -141,7 +141,6 @@ export class FunctionTransformer extends arkts.AbstractVisitor { constructor( private memoPluginContext: MemoPluginContext, private positionalIdTracker: PositionalIdTracker, - private signatureTransformer: SignatureTransformer, private internalsTransformer: InternalsTransformer, private parameterTransformer: ParameterTransformer, private returnTransformer: ReturnTransformer, @@ -171,9 +170,8 @@ export class FunctionTransformer extends arkts.AbstractVisitor { return this } - updateScriptFunction( + transformScriptFunction( scriptFunction: arkts.ScriptFunction, - name: string = "", ): arkts.ScriptFunction { if (!scriptFunction.body || !arkts.isBlockStatement(scriptFunction.body)) { return scriptFunction @@ -185,7 +183,7 @@ export class FunctionTransformer extends arkts.AbstractVisitor { const afterInternalsTransformer = this.internalsTransformer.visitor(scriptFunction.body) as arkts.BlockStatement if (!functionHasFullBodyTransformation(kind)) { scriptFunction.setBody(afterInternalsTransformer) - return scriptFunction + return rewriteSignature(scriptFunction, kind) } const hasReceiver = functionHasReceiver(kind) const isStatic = (scriptFunction.modifierFlags & arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC) != 0 @@ -197,7 +195,7 @@ export class FunctionTransformer extends arkts.AbstractVisitor { hasReceiver, isStatic, isStableThis, - this.positionalIdTracker.id(name), + this.positionalIdTracker.id(), this.addLogging, this.trackContentParam, ) @@ -210,16 +208,7 @@ export class FunctionTransformer extends arkts.AbstractVisitor { .skip(syntheticReturnStatement) .visitor(afterParameterTransformer) scriptFunction.setBody(afterReturnTransformer) - return scriptFunction - } - - transformScriptFunction(node: arkts.ScriptFunction): arkts.ScriptFunction { - return this.signatureTransformer.visitor( - this.updateScriptFunction( - node, - node.id?.name, - ) - ) + return rewriteSignature(scriptFunction, kind) } transformCallExpression(node: arkts.CallExpression): arkts.CallExpression { @@ -251,7 +240,7 @@ export class FunctionTransformer extends arkts.AbstractVisitor { } transformETSFunctionType(node: arkts.ETSFunctionType): arkts.ETSFunctionType { - return this.signatureTransformer.visitor(node) + return rewriteSignature(node, this.memoPluginContext.ETSFunctionTypeKinds.get(node.original)) } visitor(beforeChildren: arkts.ETSModule): arkts.ETSModule diff --git a/ui2abc/memo-plugin/src/transform/MemoTransformer.ts b/ui2abc/memo-plugin/src/transform/MemoTransformer.ts index 5884e0c46..d28f16fdb 100644 --- a/ui2abc/memo-plugin/src/transform/MemoTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/MemoTransformer.ts @@ -19,7 +19,6 @@ import { dumpAstToFile, PositionalIdTracker } from "./utils" import { InternalsTransformer } from "./InternalsTransformer" import { ParameterTransformer } from "./ParameterTransformer" import { ReturnTransformer } from "./ReturnTranformer" -import { SignatureTransformer } from "./SignatureTransformer" import { MEMO_PLUGIN_CONTEXT_PARAMETER_NAME, MemoPluginContext, TransformerOptions } from "../common" export function checkedRewriteTransformer( @@ -32,7 +31,6 @@ export function checkedRewriteTransformer( } const positionalIdTracker = new PositionalIdTracker(program.relativeFilePath, userPluginOptions?.stableForTests) - const signatureTransformer = new SignatureTransformer(memoPluginContext) const internalsTransformer = new InternalsTransformer(positionalIdTracker) const parameterTransformer = new ParameterTransformer(positionalIdTracker) const returnTransformer = new ReturnTransformer() @@ -42,7 +40,6 @@ export function checkedRewriteTransformer( const functionTransformer = new FunctionTransformer( memoPluginContext, positionalIdTracker, - signatureTransformer, internalsTransformer, parameterTransformer, returnTransformer, diff --git a/ui2abc/memo-plugin/src/transform/SignatureTransformer.ts b/ui2abc/memo-plugin/src/transform/SignatureTransformer.ts index 9ac921491..e1084e96f 100644 --- a/ui2abc/memo-plugin/src/transform/SignatureTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/SignatureTransformer.ts @@ -18,11 +18,11 @@ import { moveToFront, parametersBlockHasReceiver, } from "./utils" -import { MemoFunctionKind, MemoPluginContext } from "../common" -import { castParameters } from "../api-utils" +import { functionSupportsParametersRewrite, MemoFunctionKind } from "../common" +import { assertIsNever, castParameters } from "../api-utils" import { factory } from "../MemoFactory" -export function extendParameters(params: readonly arkts.ETSParameterExpression[], hasReceiverHint: boolean) { +function extendParameters(params: readonly arkts.ETSParameterExpression[], hasReceiverHint: boolean) { let newParams = [...factory.createHiddenParameters(), ...params] if (hasReceiverHint && parametersBlockHasReceiver(params)) { newParams = moveToFront(newParams, 2) @@ -30,52 +30,32 @@ export function extendParameters(params: readonly arkts.ETSParameterExpression[] return newParams } -export class SignatureTransformer extends arkts.AbstractVisitor { - constructor( - private memoPluginContext: MemoPluginContext, - ) { - super() +export function rewriteSignature(node: T, kind?: MemoFunctionKind): T { + if (!functionSupportsParametersRewrite(kind)) { + return node } - - visitor(node: arkts.ScriptFunction): arkts.ScriptFunction - visitor(node: arkts.ETSFunctionType): arkts.ETSFunctionType - visitor(node: arkts.AstNode): arkts.AstNode { - if (arkts.isScriptFunction(node)) { - const kind = this.memoPluginContext.ScriptFunctionKinds.get(node.original) - const shouldTransform = kind == MemoFunctionKind.MEMO || kind == MemoFunctionKind.INTRINSIC - || kind == MemoFunctionKind.MEMO_WITH_RECEIVER || kind == MemoFunctionKind.INTRINSIC_WITH_RECEIVER - if (!shouldTransform) { - return node - } - node.setParams( - extendParameters( - castParameters(node.params), - kind == MemoFunctionKind.MEMO_WITH_RECEIVER || kind == MemoFunctionKind.INTRINSIC_WITH_RECEIVER - ) - ) - return node - } - if (arkts.isETSFunctionType(node)) { - const kind = this.memoPluginContext.ETSFunctionTypeKinds.get(node.original) - const shouldTransform = kind == MemoFunctionKind.MEMO || kind == MemoFunctionKind.INTRINSIC - || kind == MemoFunctionKind.MEMO_WITH_RECEIVER || kind == MemoFunctionKind.INTRINSIC_WITH_RECEIVER - if (!shouldTransform) { - return node - } - return arkts.factory.updateETSFunctionType( - node, - node.typeParams, - extendParameters( - castParameters(node.params), - kind == MemoFunctionKind.MEMO_WITH_RECEIVER || kind == MemoFunctionKind.INTRINSIC_WITH_RECEIVER - ), - node.returnType, - node.isExtensionFunction, - node.flags, - node.annotations, + if (arkts.isScriptFunction(node)) { + node.setParams( + extendParameters( + castParameters(node.params), + kind == MemoFunctionKind.MEMO_WITH_RECEIVER || kind == MemoFunctionKind.INTRINSIC_WITH_RECEIVER ) - } - - return this.visitEachChild(node) + ) + return node + } + if (arkts.isETSFunctionType(node)) { + return arkts.factory.updateETSFunctionType( + node, + node.typeParams, + extendParameters( + castParameters(node.params), + kind == MemoFunctionKind.MEMO_WITH_RECEIVER || kind == MemoFunctionKind.INTRINSIC_WITH_RECEIVER + ), + node.returnType, + node.isExtensionFunction, + node.flags, + node.annotations, + ) as T } + assertIsNever(node) } diff --git a/ui2abc/memo-plugin/test/golden/HQ/abstract.ets b/ui2abc/memo-plugin/test/golden/HQ/abstract.ets index 022466b1a..1c62b2123 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/abstract.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/abstract.ets @@ -7,7 +7,7 @@ function main() {} declare abstract class A { - @memo() public x(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void + @memo() public x(): void public test_signature(@memo() arg1: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void), @memo() arg2: (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined), @memo() arg3: ((((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) | (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> int) | undefined)), @memo() x: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, y: ((z: @memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void))=> void))=> void)): @memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) @@ -17,7 +17,7 @@ declare abstract class A { class AA extends A { @memo() public x(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_x_abstract.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__abstract.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/arrow-assignment.ets b/ui2abc/memo-plugin/test/golden/HQ/arrow-assignment.ets index e280e6578..a214ea128 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/arrow-assignment.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/arrow-assignment.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public memo_variables(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_variables_arrow-assignment.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__arrow-assignment.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/call-type.ets b/ui2abc/memo-plugin/test/golden/HQ/call-type.ets index 8aae4c634..7973f387d 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/call-type.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/call-type.ets @@ -10,7 +10,7 @@ type MemoType = @memo() ((__memo_context: __memo_context_type, __memo_id: __memo class Test { @memo() public type_alias(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: MemoType) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_type_alias_call-type.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__call-type.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/compute.ets b/ui2abc/memo-plugin/test/golden/HQ/compute.ets index 73ca6ac48..cb2b203ab 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/compute.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/compute.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public compute_test(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() arg1: (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined), arg2: ((()=> void) | undefined), content: ((()=> void) | undefined)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_compute_test_compute.ets"))), 3); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__compute.ets"))), 3); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg1 = __memo_scope.param(1, arg1), __memo_parameter_arg2 = __memo_scope.param(2, arg2); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -26,7 +26,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_compute.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__compute.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/content-usage.ets b/ui2abc/memo-plugin/test/golden/HQ/content-usage.ets index dfa8d0a3a..79c39c88e 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/content-usage.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/content-usage.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public memo_content(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() content: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_content_content-usage.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__content-usage.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/implicit-void-method.ets b/ui2abc/memo-plugin/test/golden/HQ/implicit-void-method.ets index 29204a795..d277f1921 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/implicit-void-method.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/implicit-void-method.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public a_method_with_implicit_return_type(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_a_method_with_implicit_return_type_implicit-void-method.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__implicit-void-method.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/instantiate.ets b/ui2abc/memo-plugin/test/golden/HQ/instantiate.ets index c7118c42a..7bb26fb9a 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/instantiate.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/instantiate.ets @@ -8,7 +8,7 @@ function main() {} class C { @memo() public static $_instantiate(__memo_context: __memo_context_type, __memo_id: __memo_id_type, factory: (()=> C)): C { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_$_instantiate_instantiate.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__instantiate.ets"))), 1); const __memo_parameter_factory = __memo_scope.param(0, factory); if (__memo_scope.unchanged) { return __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/internal-call.ets b/ui2abc/memo-plugin/test/golden/HQ/internal-call.ets index a25c37051..c4130ca93 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/internal-call.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/internal-call.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public void_method(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_void_method_internal-call.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__internal-call.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -21,7 +21,7 @@ class Test { } @memo() public internal_call(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_internal_call_internal-call.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__internal-call.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/internals.ets b/ui2abc/memo-plugin/test/golden/HQ/internals.ets index 168406678..e1ffb33f2 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/internals.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/internals.ets @@ -10,7 +10,7 @@ function main() {} class Test { @memo() public method_with_internals(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_method_with_internals_internals.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__internals.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/intrinsic-call.ets b/ui2abc/memo-plugin/test/golden/HQ/intrinsic-call.ets index 0f96aa0cf..ed4527579 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/intrinsic-call.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/intrinsic-call.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public void_method(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_void_method_intrinsic-call.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__intrinsic-call.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/invoke.ets b/ui2abc/memo-plugin/test/golden/HQ/invoke.ets index b9d48d436..44a16e159 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/invoke.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/invoke.ets @@ -8,7 +8,7 @@ function main() {} class A { @memo() public static $_invoke(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_$_invoke_invoke.ets"))), 0); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__invoke.ets"))), 0); if (__memo_scope.unchanged) { __memo_scope.cached; return; diff --git a/ui2abc/memo-plugin/test/golden/HQ/memo-property-type.ets b/ui2abc/memo-plugin/test/golden/HQ/memo-property-type.ets index 3286e71de..3eded753c 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/memo-property-type.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/memo-property-type.ets @@ -14,7 +14,7 @@ class A { } @memo() public build(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_build_memo-property-type.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-property-type.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/memo-property.ets b/ui2abc/memo-plugin/test/golden/HQ/memo-property.ets index a455276f3..a99aa2f1e 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/memo-property.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/memo-property.ets @@ -14,7 +14,7 @@ class A { } @memo() public build(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_build_memo-property.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-property.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/non-memo-property.ets b/ui2abc/memo-plugin/test/golden/HQ/non-memo-property.ets index f6bab57e8..0c787dc57 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/non-memo-property.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/non-memo-property.ets @@ -14,7 +14,7 @@ class A { } @memo() public build(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_build_non-memo-property.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__non-memo-property.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/object-param.ets b/ui2abc/memo-plugin/test/golden/HQ/object-param.ets index c12f49812..c812063c4 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/object-param.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/object-param.ets @@ -17,7 +17,7 @@ class A { class Test { @memo() public obj_arg(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: A) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_obj_arg_object-param.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__object-param.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -35,7 +35,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_object-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__object-param.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/param-calls-optional.ets b/ui2abc/memo-plugin/test/golden/HQ/param-calls-optional.ets index e42370103..07bf22567 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/param-calls-optional.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/param-calls-optional.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public optional_args(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg1?: int, arg2?: (()=> int)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_optional_args_param-calls-optional.ets"))), 3); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__param-calls-optional.ets"))), 3); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg1 = __memo_scope.param(1, arg1), __memo_parameter_arg2 = __memo_scope.param(2, arg2); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/param-calls.ets b/ui2abc/memo-plugin/test/golden/HQ/param-calls.ets index 89c435a3b..d4ac74aaa 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/param-calls.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/param-calls.ets @@ -13,7 +13,7 @@ class Test { return 20; }) as (()=> int))); let arg3: int = (((gensym_XXX) !== (undefined)) ? gensym_XXX : (arg1 as int)); - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_args_with_default_values_param-calls.ets"))), 5); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__param-calls.ets"))), 5); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg1 = __memo_scope.param(1, arg1), __memo_parameter_arg2 = __memo_scope.param(2, arg2), __memo_parameter_arg3 = __memo_scope.param(3, arg3), __memo_parameter_arg4 = __memo_scope.param(4, arg4); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/property-constructor.ets b/ui2abc/memo-plugin/test/golden/HQ/property-constructor.ets index 7beed3b03..ccafcb7f7 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/property-constructor.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/property-constructor.ets @@ -26,7 +26,7 @@ class AA { } @memo() public build(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_build_property-constructor.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__property-constructor.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/static-void-method.ets b/ui2abc/memo-plugin/test/golden/HQ/static-void-method.ets index 9aa9b61ee..f0491601e 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/static-void-method.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/static-void-method.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public static static_method_with_type_parameter(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: T): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_static_method_with_type_parameter_static-void-method.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__static-void-method.ets"))), 1); const __memo_parameter_arg = __memo_scope.param(0, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -26,7 +26,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_static-void-method.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__static-void-method.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/string-compute.ets b/ui2abc/memo-plugin/test/golden/HQ/string-compute.ets index 812c5e8ba..6aa1d4c3f 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/string-compute.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/string-compute.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public lambda_arg_with_arg(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() arg: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, value: string)=> string)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_lambda_arg_with_arg_string-compute.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__string-compute.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -26,7 +26,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_string-compute.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__string-compute.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/string-method.ets b/ui2abc/memo-plugin/test/golden/HQ/string-method.ets index c6f7029c4..3778c88c2 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/string-method.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/string-method.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public string_method_with_return(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: string): string { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_string_method_with_return_string-method.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__string-method.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { return __memo_scope.cached; @@ -22,7 +22,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_string-method.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__string-method.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/type-param-method.ets b/ui2abc/memo-plugin/test/golden/HQ/type-param-method.ets index a6e013a5a..e53ad4042 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/type-param-method.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/type-param-method.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public method_with_type_parameter(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: T): T { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_method_with_type_parameter_type-param-method.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__type-param-method.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { return __memo_scope.cached; @@ -22,7 +22,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_type-param-method.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__type-param-method.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/void-compute.ets b/ui2abc/memo-plugin/test/golden/HQ/void-compute.ets index 1142e1ba8..e3b220873 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/void-compute.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/void-compute.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public lambda_arg(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() arg: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_lambda_arg_void-compute.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__void-compute.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -26,7 +26,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_void-compute.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__void-compute.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/void-method-with-param.ets b/ui2abc/memo-plugin/test/golden/HQ/void-method-with-param.ets index c70f00e82..ab433db4a 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/void-method-with-param.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/void-method-with-param.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public void_method_with_arg(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: string) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_void_method_with_arg_void-method-with-param.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__void-method-with-param.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -26,7 +26,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_void-method-with-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__void-method-with-param.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/void-method-with-return.ets b/ui2abc/memo-plugin/test/golden/HQ/void-method-with-return.ets index 6d8bece23..4faa378e5 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/void-method-with-return.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/void-method-with-return.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public void_method_with_return(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: string) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_void_method_with_return_void-method-with-return.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__void-method-with-return.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -26,7 +26,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_void-method-with-return.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__void-method-with-return.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/HQ/void-method.ets b/ui2abc/memo-plugin/test/golden/HQ/void-method.ets index ad93cc859..58095d6df 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/void-method.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/void-method.ets @@ -8,7 +8,7 @@ function main() {} class Test { @memo() public void_method(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_void_method_void-method.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__void-method.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -26,7 +26,7 @@ class Test { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_void-method.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__void-method.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/basic/function.ets b/ui2abc/memo-plugin/test/golden/basic/function.ets index 19d04bf26..5a8a327c8 100644 --- a/ui2abc/memo-plugin/test/golden/basic/function.ets +++ b/ui2abc/memo-plugin/test/golden/basic/function.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_function.ets"))), 0); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__function.ets"))), 0); if (__memo_scope.unchanged) { __memo_scope.cached; return; diff --git a/ui2abc/memo-plugin/test/golden/basic/method.ets b/ui2abc/memo-plugin/test/golden/basic/method.ets index d16166fc9..dc6973c39 100644 --- a/ui2abc/memo-plugin/test/golden/basic/method.ets +++ b/ui2abc/memo-plugin/test/golden/basic/method.ets @@ -8,7 +8,7 @@ function main() {} class C { @memo() public memo_method(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_method_method.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__method.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/implicit-type/main.ets b/ui2abc/memo-plugin/test/golden/implicit-type/main.ets index 55d5913cf..f3337885c 100644 --- a/ui2abc/memo-plugin/test/golden/implicit-type/main.ets +++ b/ui2abc/memo-plugin/test/golden/implicit-type/main.ets @@ -8,7 +8,7 @@ import { function_returning_local_type as function_returning_local_type } from " function main() {} @memo() function function_with_implicit_return_type(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_function_with_implicit_return_type_main.ets"))), 0); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__main.ets"))), 0); if (__memo_scope.unchanged) { return __memo_scope.cached; } diff --git a/ui2abc/memo-plugin/test/golden/other.ets b/ui2abc/memo-plugin/test/golden/other.ets index e7550f667..004b46aac 100644 --- a/ui2abc/memo-plugin/test/golden/other.ets +++ b/ui2abc/memo-plugin/test/golden/other.ets @@ -8,7 +8,7 @@ import { __context as __context, __id as __id, __key as __key } from "@koalaui/r function main() {} @memo() function param_capturing(__memo_context: __memo_context_type, __memo_id: __memo_id_type, s: string) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_param_capturing_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_s = __memo_scope.param(0, s); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -29,7 +29,7 @@ function main() {} } @memo() function memo_arg_call(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg1: number, arg2: ((x: number)=> number), @memo() arg3: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, x: number)=> number), arg4?: ((x: number)=> number), @memo() arg5?: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, x: number)=> number)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_arg_call_other.ets"))), 5); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 5); const __memo_parameter_arg1 = __memo_scope.param(0, arg1), __memo_parameter_arg2 = __memo_scope.param(1, arg2), __memo_parameter_arg3 = __memo_scope.param(2, arg3), __memo_parameter_arg4 = __memo_scope.param(3, arg4), __memo_parameter_arg5 = __memo_scope.param(4, arg5); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -48,7 +48,7 @@ function main() {} } @memo() function call_with_receiver(__memo_context: __memo_context_type, __memo_id: __memo_id_type, obj: A, @memo() v: ((this: A, __memo_context: __memo_context_type, __memo_id: __memo_id_type)=> int)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_call_with_receiver_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_obj = __memo_scope.param(0, obj), __memo_parameter_v = __memo_scope.param(1, v); if (__memo_scope.unchanged) { return __memo_scope.cached; @@ -59,7 +59,7 @@ function main() {} } @memo() function test_call_with_receiver(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_call_with_receiver_other.ets"))), 0); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 0); if (__memo_scope.unchanged) { __memo_scope.cached; return; @@ -98,7 +98,7 @@ class A { class Test { @memo() public void_method(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_void_method_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -111,7 +111,7 @@ class Test { } @memo() public a_method_with_implicit_return_type(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_a_method_with_implicit_return_type_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -124,7 +124,7 @@ class Test { } @memo() public void_method_with_arg(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: string) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_void_method_with_arg_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -137,7 +137,7 @@ class Test { } @memo() public void_method_with_return(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: string) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_void_method_with_return_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -150,7 +150,7 @@ class Test { } @memo() public string_method_with_return(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: string) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_string_method_with_return_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { return __memo_scope.cached; @@ -159,7 +159,7 @@ class Test { } @memo() public method_with_type_parameter(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: T): T { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_method_with_type_parameter_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { return __memo_scope.cached; @@ -168,7 +168,7 @@ class Test { } @memo() public static static_method_with_type_parameter(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: T) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_static_method_with_type_parameter_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_arg = __memo_scope.param(0, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -181,7 +181,7 @@ class Test { } @memo() public internal_call(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_internal_call_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -195,7 +195,7 @@ class Test { } @memo() public lambda_arg(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() arg: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_lambda_arg_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -208,7 +208,7 @@ class Test { } @memo() public lambda_arg_with_arg(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() arg: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, value: string)=> string)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_lambda_arg_with_arg_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -230,7 +230,7 @@ class Test { } @memo() public method_with_internals(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_method_with_internals_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -245,7 +245,7 @@ class Test { } @memo() public obj_arg(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: A) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_obj_arg_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -272,7 +272,7 @@ class Test { } @memo() public memo_content(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() content: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_content_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -300,7 +300,7 @@ class Test { } @memo() public memo_variables(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_variables_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -337,7 +337,7 @@ class Test { } @memo() public compute_test(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() arg1: (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined), arg2: ((()=> void) | undefined), content: ((()=> void) | undefined)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_compute_test_other.ets"))), 3); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 3); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg1 = __memo_scope.param(1, arg1), __memo_parameter_arg2 = __memo_scope.param(2, arg2); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -355,7 +355,7 @@ class Test { return 20; }) as (()=> int))); let arg3: int = (((gensym_XXX) !== (undefined)) ? gensym_XXX : (arg1 as int)); - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_args_with_default_values_other.ets"))), 5); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 5); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg1 = __memo_scope.param(1, arg1), __memo_parameter_arg2 = __memo_scope.param(2, arg2), __memo_parameter_arg3 = __memo_scope.param(3, arg3), __memo_parameter_arg4 = __memo_scope.param(4, arg4); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -370,7 +370,7 @@ class Test { } @memo() public optional_args(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg1?: int, arg2?: (()=> int)) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_optional_args_other.ets"))), 3); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 3); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg1 = __memo_scope.param(1, arg1), __memo_parameter_arg2 = __memo_scope.param(2, arg2); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -387,7 +387,7 @@ class Test { } @memo() public type_alias(__memo_context: __memo_context_type, __memo_id: __memo_id_type, arg: MemoType) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_type_alias_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_arg = __memo_scope.param(1, arg); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -405,7 +405,7 @@ class Test { } @memo() public wrap_param_test(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo_wrap() obj: A): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_wrap_param_test_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_obj = __memo_scope.param(1, obj); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -460,7 +460,7 @@ declare class AbstractTest { @memo_stable() class MemoStableClass { @memo() public test1(__memo_context: __memo_context_type, __memo_id: __memo_id_type, x: string): string { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test1_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_x = __memo_scope.param(0, x); if (__memo_scope.unchanged) { return __memo_scope.cached; @@ -469,7 +469,7 @@ declare class AbstractTest { } @memo() public test2(__memo_context: __memo_context_type, __memo_id: __memo_id_type, value: int): this { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test2_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_value = __memo_scope.param(0, value); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -488,7 +488,7 @@ declare class AbstractTest { class MemoUnstableClass { @memo() public test2(__memo_context: __memo_context_type, __memo_id: __memo_id_type, value: int): this { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test2_other.ets"))), 2); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 2); const __memo_parameter_this = __memo_scope.param(0, this), __memo_parameter_value = __memo_scope.param(1, value); if (__memo_scope.unchanged) { __memo_scope.cached; @@ -508,7 +508,7 @@ class MemoUnstableClass { class Use { @memo() public test(__memo_context: __memo_context_type, __memo_id: __memo_id_type) { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_test_other.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__other.ets"))), 1); const __memo_parameter_this = __memo_scope.param(0, this); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-optional-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-optional-param.ets index 2227dbcc6..e335124d9 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-optional-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-optional-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() param?: @memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-optional-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-optional-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-optional-possibly-undefined-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-optional-possibly-undefined-param.ets index 210be1989..d4dc4cc8d 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-optional-possibly-undefined-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-optional-possibly-undefined-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() param?: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-optional-possibly-undefined-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-optional-possibly-undefined-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-param.ets index 73844dc72..6595ac59e 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() param: @memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-possibly-undefined-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-possibly-undefined-param.ets index 0cf90b68a..999520905 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-possibly-undefined-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-param-and-type/memo-on-possibly-undefined-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() param: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-possibly-undefined-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-possibly-undefined-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-optional-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-optional-param.ets index 634cc65e1..4730b5dde 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-optional-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-optional-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() param?: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-optional-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-optional-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-optional-possibly-undefined-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-optional-possibly-undefined-param.ets index dcb1483ba..26ffedd6a 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-optional-possibly-undefined-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-optional-possibly-undefined-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() param?: (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-optional-possibly-undefined-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-optional-possibly-undefined-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-param.ets index 1452c0a86..39cef1ae3 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() param: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-possibly-undefined-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-possibly-undefined-param.ets index 1721cd41e..9e84dfdbb 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-possibly-undefined-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-param/memo-on-possibly-undefined-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() param: (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-possibly-undefined-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-possibly-undefined-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-optional-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-optional-param.ets index bcdfd337d..440b71e87 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-optional-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-optional-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, param?: @memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-optional-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-optional-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-optional-possibly-undefined-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-optional-possibly-undefined-param.ets index ae7185201..41ec8d5d2 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-optional-possibly-undefined-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-optional-possibly-undefined-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, param?: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-optional-possibly-undefined-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-optional-possibly-undefined-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-param.ets index 4751d1472..a28e2c092 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, param: @memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-possibly-undefined-param.ets b/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-possibly-undefined-param.ets index c169a0a4e..c8be5bc9b 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-possibly-undefined-param.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/on-type/memo-on-possibly-undefined-param.ets @@ -6,7 +6,7 @@ import { memo as memo } from "@koalaui/runtime/annotations"; function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, param: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_memo-on-possibly-undefined-param.ets"))), 1); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__memo-on-possibly-undefined-param.ets"))), 1); const __memo_parameter_param = __memo_scope.param(0, param); if (__memo_scope.unchanged) { __memo_scope.cached; diff --git a/ui2abc/memo-plugin/test/golden/param-usage/union-with-non-memo/primitive.ets b/ui2abc/memo-plugin/test/golden/param-usage/union-with-non-memo/primitive.ets index 40338ca91..41a72eb3b 100644 --- a/ui2abc/memo-plugin/test/golden/param-usage/union-with-non-memo/primitive.ets +++ b/ui2abc/memo-plugin/test/golden/param-usage/union-with-non-memo/primitive.ets @@ -6,7 +6,7 @@ import { memo as memo, memo_skip as memo_skip } from "@koalaui/runtime/annotatio function main() {} @memo() function memo_function(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo_skip() param: (Builder | string)): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_memo_function_primitive.ets"))), 0); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__primitive.ets"))), 0); if (__memo_scope.unchanged) { __memo_scope.cached; return; @@ -23,7 +23,7 @@ function main() {} } @memo() function callsite(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { - const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id_callsite_primitive.ets"))), 0); + const __memo_scope = __memo_context.scope(((__memo_id) + (__hash("id__primitive.ets"))), 0); if (__memo_scope.unchanged) { __memo_scope.cached; return; -- Gitee From 4cb7e73f37540e9a4b392f491768f6793ceb7ff4 Mon Sep 17 00:00:00 2001 From: Igor Loginov Date: Fri, 15 Aug 2025 14:30:29 +0300 Subject: [PATCH 2/3] Reorder visitors --- .../src/transform/FunctionTransformer.ts | 66 ++++++++----------- .../src/transform/InternalsTransformer.ts | 2 + .../src/transform/ParameterTransformer.ts | 7 +- .../src/transform/ReturnTranformer.ts | 15 +---- .../memo-plugin/test/golden/HQ/abstract.ets | 2 +- 5 files changed, 34 insertions(+), 58 deletions(-) diff --git a/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts b/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts index e5c0bbdd5..647a61c0f 100644 --- a/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts @@ -88,23 +88,14 @@ function fixGensymParams(params: ParamInfo[], body: arkts.BlockStatement) { function updateFunctionBody( node: arkts.BlockStatement, - parameters: readonly arkts.ETSParameterExpression[], + parameterIdentifiers: ParamInfo[], + gensymParamsCount: number, returnTypeAnnotation: arkts.TypeNode | undefined, - hasReceiver: boolean, - isStatic: boolean, + shouldCreateMemoThisParam: boolean, stableThis: boolean, hash: arkts.Expression, addLogging: boolean, - trackContentParam: boolean, -): [ - arkts.BlockStatement, - ParamInfo[], - arkts.VariableDeclaration | undefined, - arkts.ReturnStatement | arkts.BlockStatement | undefined, -] { - const shouldCreateMemoThisParam = needThisRewrite(hasReceiver, isStatic, stableThis) && !parametersBlockHasReceiver(parameters) - const parameterIdentifiers = getMemoParameterIdentifiers(parameters, trackContentParam) - const gensymParamsCount = fixGensymParams(parameterIdentifiers, node) +): arkts.BlockStatement { const parameterNames = [...(shouldCreateMemoThisParam ? [RuntimeNames.THIS.valueOf()] : []), ...parameterIdentifiers.map(it => it.ident.name)] const scopeDeclaration = factory.createScopeDeclaration( arkts.isTSThisType(returnTypeAnnotation) ? undefined : returnTypeAnnotation, @@ -126,15 +117,9 @@ function updateFunctionBody( ...unchangedCheck, ...thisParamSubscription, ...node.statements.slice(gensymParamsCount), - ...(mayAddLastReturn(node) ? [arkts.factory.createReturnStatement(undefined)] : []), ] ) - return [ - node, - parameterIdentifiers, - memoParametersDeclaration, - syntheticReturnStatement, - ] + return node } export class FunctionTransformer extends arkts.AbstractVisitor { @@ -173,14 +158,15 @@ export class FunctionTransformer extends arkts.AbstractVisitor { transformScriptFunction( scriptFunction: arkts.ScriptFunction, ): arkts.ScriptFunction { - if (!scriptFunction.body || !arkts.isBlockStatement(scriptFunction.body)) { - return scriptFunction - } const kind = this.memoPluginContext.ScriptFunctionKinds.get(scriptFunction.original) if (!kind) { return scriptFunction } - const afterInternalsTransformer = this.internalsTransformer.visitor(scriptFunction.body) as arkts.BlockStatement + const body = scriptFunction.body + if (!arkts.isBlockStatement(body)) { + return rewriteSignature(scriptFunction, kind) + } + const afterInternalsTransformer = this.internalsTransformer.visitor(body) as arkts.BlockStatement if (!functionHasFullBodyTransformation(kind)) { scriptFunction.setBody(afterInternalsTransformer) return rewriteSignature(scriptFunction, kind) @@ -188,26 +174,28 @@ export class FunctionTransformer extends arkts.AbstractVisitor { const hasReceiver = functionHasReceiver(kind) const isStatic = (scriptFunction.modifierFlags & arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC) != 0 const isStableThis = this.stable > 0 - const [body, parameterIdentifiers, memoParametersDeclaration, syntheticReturnStatement] = updateFunctionBody( - afterInternalsTransformer, - castParameters(scriptFunction.params), + if (mayAddLastReturn(body)) { + body.addStatement(arkts.factory.createReturnStatement(undefined)) + } + const parameters = castParameters(scriptFunction.params) + const parameterIdentifiers = getMemoParameterIdentifiers(parameters, this.trackContentParam) + const gensymParamsCount = fixGensymParams(parameterIdentifiers, body) + const afterReturnTransformer = this.returnTransformer + .visitor(afterInternalsTransformer) + const afterParameterTransformer = this.parameterTransformer + .withThis(needThisRewrite(hasReceiver, isStatic, isStableThis)) + .withParameters(parameterIdentifiers) + .visitor(afterReturnTransformer) + updateFunctionBody( + afterParameterTransformer, + parameterIdentifiers, + gensymParamsCount, getReturnTypeAnnotation(scriptFunction), - hasReceiver, - isStatic, + needThisRewrite(hasReceiver, isStatic, isStableThis) && !parametersBlockHasReceiver(parameters), isStableThis, this.positionalIdTracker.id(), this.addLogging, - this.trackContentParam, ) - const afterParameterTransformer = this.parameterTransformer - .withThis(needThisRewrite(hasReceiver, isStatic, isStableThis)) - .withParameters(parameterIdentifiers) - .skip(memoParametersDeclaration) - .visitor(body) - const afterReturnTransformer = this.returnTransformer - .skip(syntheticReturnStatement) - .visitor(afterParameterTransformer) - scriptFunction.setBody(afterReturnTransformer) return rewriteSignature(scriptFunction, kind) } diff --git a/ui2abc/memo-plugin/src/transform/InternalsTransformer.ts b/ui2abc/memo-plugin/src/transform/InternalsTransformer.ts index fa8a9d9d4..f274589ea 100644 --- a/ui2abc/memo-plugin/src/transform/InternalsTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/InternalsTransformer.ts @@ -22,6 +22,8 @@ export class InternalsTransformer extends arkts.AbstractVisitor { super() } + visitor(beforeChildren: arkts.BlockStatement): arkts.BlockStatement + visitor(beforeChildren: arkts.AstNode): arkts.AstNode visitor(beforeChildren: arkts.AstNode): arkts.AstNode { const node = this.visitEachChild(beforeChildren) if (arkts.isCallExpression(node)) { diff --git a/ui2abc/memo-plugin/src/transform/ParameterTransformer.ts b/ui2abc/memo-plugin/src/transform/ParameterTransformer.ts index 23efed450..eb77b891a 100644 --- a/ui2abc/memo-plugin/src/transform/ParameterTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/ParameterTransformer.ts @@ -56,11 +56,8 @@ export class ParameterTransformer extends arkts.AbstractVisitor { return this } - skip(memoParametersDeclaration?: arkts.VariableDeclaration): ParameterTransformer { - this.skipNode = memoParametersDeclaration - return this - } - + visitor(beforeChildren: arkts.BlockStatement): arkts.BlockStatement + visitor(beforeChildren: arkts.AstNode): arkts.AstNode visitor(beforeChildren: arkts.AstNode): arkts.AstNode { if (beforeChildren === this.skipNode) { return beforeChildren diff --git a/ui2abc/memo-plugin/src/transform/ReturnTranformer.ts b/ui2abc/memo-plugin/src/transform/ReturnTranformer.ts index 37e3e3694..1c2a76d47 100644 --- a/ui2abc/memo-plugin/src/transform/ReturnTranformer.ts +++ b/ui2abc/memo-plugin/src/transform/ReturnTranformer.ts @@ -16,21 +16,10 @@ import * as arkts from "@koalaui/libarkts" import { factory } from "../MemoFactory" -/** - * This transformer corrects function's body according to memo transformation - */ export class ReturnTransformer extends arkts.AbstractVisitor { - private skipNode?: arkts.ReturnStatement | arkts.BlockStatement - - skip(syntheticReturnStatement?: arkts.ReturnStatement | arkts.BlockStatement): ReturnTransformer { - this.skipNode = syntheticReturnStatement - return this - } - + visitor(beforeChildren: arkts.BlockStatement): arkts.BlockStatement + visitor(beforeChildren: arkts.AstNode): arkts.AstNode visitor(beforeChildren: arkts.AstNode): arkts.AstNode { - if (beforeChildren === this.skipNode) { - return beforeChildren - } if (arkts.isScriptFunction(beforeChildren)) { return beforeChildren } diff --git a/ui2abc/memo-plugin/test/golden/HQ/abstract.ets b/ui2abc/memo-plugin/test/golden/HQ/abstract.ets index 1c62b2123..934a62077 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/abstract.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/abstract.ets @@ -7,7 +7,7 @@ function main() {} declare abstract class A { - @memo() public x(): void + @memo() public x(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void public test_signature(@memo() arg1: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void), @memo() arg2: (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined), @memo() arg3: ((((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) | (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> int) | undefined)), @memo() x: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, y: ((z: @memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void))=> void))=> void)): @memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) -- Gitee From e9d2de28a34e5fd166e83874e607421950f93a0f Mon Sep 17 00:00:00 2001 From: Igor Loginov Date: Fri, 15 Aug 2025 21:54:02 +0300 Subject: [PATCH 3/3] Transform bodies --- ...terTransformer.ts => BodiesTransformer.ts} | 93 ++++++++++++++----- .../src/transform/FunctionTransformer.ts | 24 +++-- .../src/transform/InternalsTransformer.ts | 50 ---------- .../src/transform/MemoTransformer.ts | 12 +-- .../src/transform/ReturnTranformer.ts | 41 -------- ui2abc/memo-plugin/test/golden/HQ/entry.ets | 4 +- ui2abc/memo-plugin/test/golden/other.ets | 4 +- 7 files changed, 88 insertions(+), 140 deletions(-) rename ui2abc/memo-plugin/src/transform/{ParameterTransformer.ts => BodiesTransformer.ts} (42%) delete mode 100644 ui2abc/memo-plugin/src/transform/InternalsTransformer.ts delete mode 100644 ui2abc/memo-plugin/src/transform/ReturnTranformer.ts diff --git a/ui2abc/memo-plugin/src/transform/ParameterTransformer.ts b/ui2abc/memo-plugin/src/transform/BodiesTransformer.ts similarity index 42% rename from ui2abc/memo-plugin/src/transform/ParameterTransformer.ts rename to ui2abc/memo-plugin/src/transform/BodiesTransformer.ts index eb77b891a..ec8eaeb33 100644 --- a/ui2abc/memo-plugin/src/transform/ParameterTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/BodiesTransformer.ts @@ -24,22 +24,35 @@ export type ParamInfo = { param: arkts.ETSParameterExpression } -export class ParameterTransformer extends arkts.AbstractVisitor { - private rewriteIdentifiers?: Map arkts.MemberExpression | arkts.Identifier> +export interface BodiesTransformerOptions { + transformParameters: boolean, + transformInternals: boolean, + transformReturns: boolean, +} + +export const fullBodiesTransfomerOptions = { transformParameters: true, transformInternals: true, transformReturns: true } +export const partBodiesTransfomerOptions = { transformParameters: false, transformInternals: true, transformReturns: false } + +/** + * This complex transformation is a combination of parameters transformation, returns transformation and internals transformation + * + * It seems that in current reality, visiting AST is one of the most expensive things expect recheck + */ +export class BodiesTransformer extends arkts.AbstractVisitor { + private rewriteIdentifiers?: Map arkts.MemberExpression> private rewriteCalls?: Map arkts.CallExpression> private rewriteThis?: boolean - private skipNode?: arkts.VariableDeclaration constructor(private positionalIdTracker: PositionalIdTracker) { super() } - withThis(flag: boolean): ParameterTransformer { + withThis(flag: boolean): BodiesTransformer { this.rewriteThis = flag return this } - withParameters(parameters: ParamInfo[]): ParameterTransformer { + withParameters(parameters: ParamInfo[]): BodiesTransformer { this.rewriteCalls = new Map(parameters.filter(it => it.param.typeAnnotation && (arkts.isETSFunctionType(it.param.typeAnnotation) || arkts.isETSUnionType(it.param.typeAnnotation))).map(it => { return [it.param.ident!.name.startsWith(RuntimeNames.GENSYM) ? it.ident.originalPeer : it.param.originalPeer, (passArgs: arkts.Expression[]) => { @@ -56,37 +69,71 @@ export class ParameterTransformer extends arkts.AbstractVisitor { return this } - visitor(beforeChildren: arkts.BlockStatement): arkts.BlockStatement - visitor(beforeChildren: arkts.AstNode): arkts.AstNode - visitor(beforeChildren: arkts.AstNode): arkts.AstNode { - if (beforeChildren === this.skipNode) { - return beforeChildren - } + visitor(beforeChildren: arkts.BlockStatement, options: BodiesTransformerOptions): arkts.BlockStatement + visitor(beforeChildren: arkts.Expression, options: BodiesTransformerOptions): arkts.Expression + visitor(beforeChildren: arkts.ReturnStatement, options: BodiesTransformerOptions): arkts.ReturnStatement + visitor(beforeChildren: arkts.AstNode, options: BodiesTransformerOptions): arkts.AstNode { + // This is about default parameter assignments, they are generated by compiler, don't go into them at all if (arkts.isVariableDeclaration(beforeChildren) && this.rewriteIdentifiers?.has(beforeChildren.declarators[0].id!.originalPeer)) { return beforeChildren } - if (arkts.isCallExpression(beforeChildren)) { - if (arkts.isIdentifier(beforeChildren.callee)) { + + if (arkts.isCallExpression(beforeChildren) && arkts.isIdentifier(beforeChildren.callee)) { + if (options.transformInternals) { + if (beforeChildren.callee.name == RuntimeNames.__CONTEXT) { + return arkts.factory.createIdentifier(RuntimeNames.CONTEXT) + } + if (beforeChildren.callee.name == RuntimeNames.__ID) { + return arkts.factory.createIdentifier(RuntimeNames.ID) + } + if (beforeChildren.callee.name == RuntimeNames.__KEY) { + return this.positionalIdTracker.id(RuntimeNames.__KEY) + } + } + if (options.transformParameters) { const decl = arkts.getPeerDecl(beforeChildren.callee.originalPeer) // Improve: here should be getDeclResolveGensym, but it would result in code not passing filterSource if (decl && this.rewriteCalls?.has(decl.originalPeer)) { return this.rewriteCalls.get(decl.originalPeer)!( - beforeChildren.arguments.map((it) => this.visitor(it) as arkts.Expression) // Improve: remove as + beforeChildren.arguments.map((it) => this.visitor(it, options)) ) } } } - const node = this.visitEachChild(beforeChildren) - if (arkts.isIdentifier(node)) { - const decl = arkts.getPeerDecl(node.originalPeer) // Improve: here should be getDeclResolveGensym, but it would result in code not passing filterSource - if (decl && this.rewriteIdentifiers?.has(decl.originalPeer)) { - return this.rewriteIdentifiers.get(decl.originalPeer)!() + + const node = this.visitEachChild(beforeChildren, { + transformParameters: options.transformParameters, + transformReturns: options.transformReturns && !arkts.isScriptFunction(beforeChildren), + transformInternals: options.transformInternals && !arkts.isScriptFunction(beforeChildren), + }) + + if (options.transformParameters) { + if (arkts.isIdentifier(node)) { + const decl = arkts.getPeerDecl(node.originalPeer) // Improve: here should be getDeclResolveGensym, but it would result in code not passing filterSource + if (decl && this.rewriteIdentifiers?.has(decl.originalPeer)) { + return this.rewriteIdentifiers.get(decl.originalPeer)!() + } + } + if (arkts.isThisExpression(node) && this.rewriteThis) { + if (!arkts.isReturnStatement(node.parent)) { + return factory.createMemoParameterAccess(RuntimeNames.THIS) + } } } - if (arkts.isThisExpression(node) && this.rewriteThis) { - if (arkts.isReturnStatement(node.parent)) { - return node + if (options.transformReturns && arkts.isReturnStatement(node)) { + if (node.argument == undefined || arkts.isThisExpression(node.argument)) { + return arkts.factory.createBlockStatement([ + arkts.factory.createExpressionStatement( + factory.createRecacheCall() + ), + node, + ]) } - return factory.createMemoParameterAccess(RuntimeNames.THIS) + node.setArgument(factory.createRecacheCall(this.visitor(node.argument, { + transformParameters: options.transformParameters, + transformReturns: options.transformReturns, + transformInternals: options.transformInternals, + }))) + return node } return node } diff --git a/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts b/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts index 647a61c0f..3bdf69178 100644 --- a/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts @@ -20,9 +20,6 @@ import { moveToFront, parametersBlockHasReceiver, } from "./utils" -import { ParameterTransformer, ParamInfo } from "./ParameterTransformer" -import { ReturnTransformer } from "./ReturnTranformer" -import { InternalsTransformer } from "./InternalsTransformer" import { castParameters, hasMemoStableAnnotation, @@ -41,6 +38,7 @@ import { RuntimeNames } from "../common" import { rewriteSignature } from "./SignatureTransformer" +import { BodiesTransformer, fullBodiesTransfomerOptions, ParamInfo, partBodiesTransfomerOptions } from "./BodiesTransformer" function needThisRewrite(hasReceiver: boolean, isStatic: boolean, stableThis: boolean) { return hasReceiver && !isStatic && !stableThis @@ -126,9 +124,7 @@ export class FunctionTransformer extends arkts.AbstractVisitor { constructor( private memoPluginContext: MemoPluginContext, private positionalIdTracker: PositionalIdTracker, - private internalsTransformer: InternalsTransformer, - private parameterTransformer: ParameterTransformer, - private returnTransformer: ReturnTransformer, + private bodiesTransformer: BodiesTransformer, private addLogging: boolean, private trackContentParam: boolean, ) { @@ -166,9 +162,13 @@ export class FunctionTransformer extends arkts.AbstractVisitor { if (!arkts.isBlockStatement(body)) { return rewriteSignature(scriptFunction, kind) } - const afterInternalsTransformer = this.internalsTransformer.visitor(body) as arkts.BlockStatement if (!functionHasFullBodyTransformation(kind)) { - scriptFunction.setBody(afterInternalsTransformer) + scriptFunction.setBody( + this.bodiesTransformer + .withParameters([]) + .withThis(false) + .visitor(body, partBodiesTransfomerOptions) + ) return rewriteSignature(scriptFunction, kind) } const hasReceiver = functionHasReceiver(kind) @@ -180,14 +180,12 @@ export class FunctionTransformer extends arkts.AbstractVisitor { const parameters = castParameters(scriptFunction.params) const parameterIdentifiers = getMemoParameterIdentifiers(parameters, this.trackContentParam) const gensymParamsCount = fixGensymParams(parameterIdentifiers, body) - const afterReturnTransformer = this.returnTransformer - .visitor(afterInternalsTransformer) - const afterParameterTransformer = this.parameterTransformer + const afterBodiesTransformer = this.bodiesTransformer .withThis(needThisRewrite(hasReceiver, isStatic, isStableThis)) .withParameters(parameterIdentifiers) - .visitor(afterReturnTransformer) + .visitor(body, fullBodiesTransfomerOptions) updateFunctionBody( - afterParameterTransformer, + afterBodiesTransformer, parameterIdentifiers, gensymParamsCount, getReturnTypeAnnotation(scriptFunction), diff --git a/ui2abc/memo-plugin/src/transform/InternalsTransformer.ts b/ui2abc/memo-plugin/src/transform/InternalsTransformer.ts deleted file mode 100644 index f274589ea..000000000 --- a/ui2abc/memo-plugin/src/transform/InternalsTransformer.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as arkts from "@koalaui/libarkts" -import { RuntimeNames } from "../common" -import { PositionalIdTracker } from "./utils" - -export class InternalsTransformer extends arkts.AbstractVisitor { - constructor(private positionalIdTracker: PositionalIdTracker) { - super() - } - - visitor(beforeChildren: arkts.BlockStatement): arkts.BlockStatement - visitor(beforeChildren: arkts.AstNode): arkts.AstNode - visitor(beforeChildren: arkts.AstNode): arkts.AstNode { - const node = this.visitEachChild(beforeChildren) - if (arkts.isCallExpression(node)) { - if (arkts.isIdentifier(node.callee)) { - if (node.callee.name == RuntimeNames.__CONTEXT) { - return arkts.factory.createIdentifier( - RuntimeNames.CONTEXT, - undefined - ) - } - if (node.callee.name == RuntimeNames.__ID) { - return arkts.factory.createIdentifier( - RuntimeNames.ID, - undefined - ) - } - if (node.callee.name == RuntimeNames.__KEY) { - return this.positionalIdTracker.id(RuntimeNames.__KEY) - } - } - } - return node - } -} diff --git a/ui2abc/memo-plugin/src/transform/MemoTransformer.ts b/ui2abc/memo-plugin/src/transform/MemoTransformer.ts index d28f16fdb..0a0700184 100644 --- a/ui2abc/memo-plugin/src/transform/MemoTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/MemoTransformer.ts @@ -16,9 +16,7 @@ import * as arkts from "@koalaui/libarkts" import { FunctionTransformer } from "./FunctionTransformer" import { dumpAstToFile, PositionalIdTracker } from "./utils" -import { InternalsTransformer } from "./InternalsTransformer" -import { ParameterTransformer } from "./ParameterTransformer" -import { ReturnTransformer } from "./ReturnTranformer" +import { BodiesTransformer } from "./BodiesTransformer" import { MEMO_PLUGIN_CONTEXT_PARAMETER_NAME, MemoPluginContext, TransformerOptions } from "../common" export function checkedRewriteTransformer( @@ -31,18 +29,14 @@ export function checkedRewriteTransformer( } const positionalIdTracker = new PositionalIdTracker(program.relativeFilePath, userPluginOptions?.stableForTests) - const internalsTransformer = new InternalsTransformer(positionalIdTracker) - const parameterTransformer = new ParameterTransformer(positionalIdTracker) - const returnTransformer = new ReturnTransformer() + const bodiesTransformer = new BodiesTransformer(positionalIdTracker) const node = program.ast as arkts.ETSModule const functionTransformer = new FunctionTransformer( memoPluginContext, positionalIdTracker, - internalsTransformer, - parameterTransformer, - returnTransformer, + bodiesTransformer, userPluginOptions?.addLogging ?? false, userPluginOptions?.trackContentParam ?? false, ) diff --git a/ui2abc/memo-plugin/src/transform/ReturnTranformer.ts b/ui2abc/memo-plugin/src/transform/ReturnTranformer.ts deleted file mode 100644 index 1c2a76d47..000000000 --- a/ui2abc/memo-plugin/src/transform/ReturnTranformer.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as arkts from "@koalaui/libarkts" -import { factory } from "../MemoFactory" - -export class ReturnTransformer extends arkts.AbstractVisitor { - visitor(beforeChildren: arkts.BlockStatement): arkts.BlockStatement - visitor(beforeChildren: arkts.AstNode): arkts.AstNode - visitor(beforeChildren: arkts.AstNode): arkts.AstNode { - if (arkts.isScriptFunction(beforeChildren)) { - return beforeChildren - } - const node = this.visitEachChild(beforeChildren) - if (arkts.isReturnStatement(node)) { - if (node.argument == undefined || arkts.isThisExpression(node.argument)) { - return arkts.factory.createBlockStatement([ - arkts.factory.createExpressionStatement( - factory.createRecacheCall() - ), - node - ]) - } - node.setArgument(factory.createRecacheCall(node.argument)) - return node - } - return node - } -} diff --git a/ui2abc/memo-plugin/test/golden/HQ/entry.ets b/ui2abc/memo-plugin/test/golden/HQ/entry.ets index 0d663d707..bbfe5c3aa 100644 --- a/ui2abc/memo-plugin/test/golden/HQ/entry.ets +++ b/ui2abc/memo-plugin/test/golden/HQ/entry.ets @@ -11,10 +11,10 @@ function main() {} class Test { @memo_entry() public memoEntry(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() entry: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> R)): R { const getContext = (() => { - return __memo_context; + return __context(); }); const getId = (() => { - return __memo_id; + return __id(); }); { const __memo_context = getContext(); diff --git a/ui2abc/memo-plugin/test/golden/other.ets b/ui2abc/memo-plugin/test/golden/other.ets index 004b46aac..6b934b526 100644 --- a/ui2abc/memo-plugin/test/golden/other.ets +++ b/ui2abc/memo-plugin/test/golden/other.ets @@ -259,10 +259,10 @@ class Test { @memo_entry() public memoEntry(__memo_context: __memo_context_type, __memo_id: __memo_id_type, @memo() entry: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> R)): R { const getContext = (() => { - return __memo_context; + return __context(); }); const getId = (() => { - return __memo_id; + return __id(); }); { const __memo_context = getContext(); -- Gitee