From fa3d2270ca754af6b2bc732807f1f3f7a6bd8bf9 Mon Sep 17 00:00:00 2001 From: Aleksandr Veselov Date: Fri, 15 Aug 2025 16:36:36 +0300 Subject: [PATCH] Setup memo-plugin from another version of libarkts --- ui2abc/memo-plugin/src/entry.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ui2abc/memo-plugin/src/entry.ts b/ui2abc/memo-plugin/src/entry.ts index e696d71ac6..989d25d00c 100644 --- a/ui2abc/memo-plugin/src/entry.ts +++ b/ui2abc/memo-plugin/src/entry.ts @@ -24,11 +24,15 @@ export function init(parsedJson?: Object, checkedJson?: Object) { const checkedHooks = new arkts.DumpingHooks(arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, "memo") return { name: "memo", - parsed(hooks: arkts.RunTransformerHooks = parsedHooks) { + parsed(this: any, hooks: arkts.RunTransformerHooks = parsedHooks) { + if (this.projectConfig?.pandaSdkPath) { + arkts.arktsGlobal.es2panda._SetUpSoPath(this.projectConfig.pandaSdkPath) + arkts.arktsGlobal.compilerContext = new arkts.Context(this.projectConfig.arktsGlobal.compilerContext!.peer) + } arkts.Tracer.pushContext('memo-plugin') arkts.traceGlobal(() => "Run parsed state plugin", true) const transform = memo.parsedTransformer(parsedJson) - const prog = arkts.arktsGlobal.compilerContext!.program + const prog = new arkts.Program(arkts.arktsGlobal.compilerContext!.program.peer) const state = arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED try { arkts.runTransformer(prog, state, transform, pluginContext, hooks) @@ -38,10 +42,14 @@ export function init(parsedJson?: Object, checkedJson?: Object) { throw e } }, - checked(hooks: arkts.RunTransformerHooks = checkedHooks) { + checked(this: any, hooks: arkts.RunTransformerHooks = checkedHooks) { + if (this.projectConfig?.pandaSdkPath) { + arkts.arktsGlobal.es2panda._SetUpSoPath(this.projectConfig.pandaSdkPath) + arkts.arktsGlobal.compilerContext = new arkts.Context(this.projectConfig.arktsGlobal.compilerContext!.peer) + } arkts.Tracer.pushContext('memo-plugin') arkts.traceGlobal(() => "Run checked state plugin", true) - const prog = arkts.arktsGlobal.compilerContext!.program + const prog = new arkts.Program(arkts.arktsGlobal.compilerContext!.program.peer) const state = arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED const memoPluginContextImpl = new MemoPluginContextImpl() pluginContext.setParameter(MEMO_PLUGIN_CONTEXT_PARAMETER_NAME, memoPluginContextImpl) -- Gitee