diff --git a/ui2abc/memo-plugin/src/MemoFactory.ts b/ui2abc/memo-plugin/src/MemoFactory.ts index 762f95366b2b7da9a78b6c6db8d89b60fe2f5c41..7910d694584740ca80f944f2d45404f9c3726a00 100644 --- a/ui2abc/memo-plugin/src/MemoFactory.ts +++ b/ui2abc/memo-plugin/src/MemoFactory.ts @@ -175,23 +175,6 @@ export class factory { false, ) } - static createMemoParameterAccessCall(name: string, passArgs?: arkts.Expression[]): arkts.CallExpression { - const updatedArgs = passArgs ? passArgs : [] - return arkts.factory.createCallExpression( - arkts.factory.createMemberExpression( - factory.createMemoParameterIdentifier(name), - arkts.factory.createIdentifier(RuntimeNames.VALUE, undefined), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, - false, - false, - ), - [...updatedArgs], - undefined, - false, - false, - undefined, - ) - } // Recache static createScopeDeclaration(returnTypeAnnotation: arkts.TypeNode | undefined, hash: arkts.Expression, cnt: number): arkts.VariableDeclaration { diff --git a/ui2abc/memo-plugin/src/transform/BodiesTransformer.ts b/ui2abc/memo-plugin/src/transform/BodiesTransformer.ts index ec8eaeb33bc1ded676da8de0de454f1a72b5fed5..16e7378d5efa95a51e50ace1a3e3c5bf4f28d79e 100644 --- a/ui2abc/memo-plugin/src/transform/BodiesTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/BodiesTransformer.ts @@ -40,7 +40,6 @@ export const partBodiesTransfomerOptions = { transformParameters: false, transfo */ export class BodiesTransformer extends arkts.AbstractVisitor { private rewriteIdentifiers?: Map arkts.MemberExpression> - private rewriteCalls?: Map arkts.CallExpression> private rewriteThis?: boolean constructor(private positionalIdTracker: PositionalIdTracker) { @@ -53,13 +52,6 @@ export class BodiesTransformer extends arkts.AbstractVisitor { } 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[]) => { - return factory.createMemoParameterAccessCall(it.ident.name, passArgs) - }] - }) - ) this.rewriteIdentifiers = new Map(parameters.map(it => { return [it.param.ident!.name.startsWith(RuntimeNames.GENSYM) ? it.ident.originalPeer : it.param.originalPeer, () => { return factory.createMemoParameterAccess(it.ident.name) @@ -78,25 +70,15 @@ export class BodiesTransformer extends arkts.AbstractVisitor { return beforeChildren } - 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.transformInternals && arkts.isCallExpression(beforeChildren) && arkts.isIdentifier(beforeChildren.callee)) { + if (beforeChildren.callee.name == RuntimeNames.__CONTEXT) { + return arkts.factory.createIdentifier(RuntimeNames.CONTEXT) } - 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, options)) - ) - } + if (beforeChildren.callee.name == RuntimeNames.__ID) { + return arkts.factory.createIdentifier(RuntimeNames.ID) + } + if (beforeChildren.callee.name == RuntimeNames.__KEY) { + return this.positionalIdTracker.id(RuntimeNames.__KEY) } }