diff --git a/arkoala-arkts/libarkts/arktsconfig-memo.json b/arkoala-arkts/libarkts/arktsconfig-memo.json new file mode 100644 index 0000000000000000000000000000000000000000..d3645627b77af1855fca56a3005269538041dce0 --- /dev/null +++ b/arkoala-arkts/libarkts/arktsconfig-memo.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "package0": "@koalaui/example", + "outDir": "./abc", + "baseUrl": ".", + "paths": { + "@koalaui/runtime": [ + "../memo-plugin/runtime-api" + ] + }, + "plugins": [ + { + "transform": "@koalaui/memo-plugin", + "stage": "checked" + } + ] + } +} diff --git a/arkoala-arkts/libarkts/package.json b/arkoala-arkts/libarkts/package.json index fd2fb932606fbbed41389e5d346eeb1ba2e5e5cd..77397bf7d48d460c95cfc95e3491b0244f24adb6 100644 --- a/arkoala-arkts/libarkts/package.json +++ b/arkoala-arkts/libarkts/package.json @@ -27,7 +27,9 @@ "compile:plugins": "npx ets-tsc -p plugins/tsconfig.json", "restart": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/main.sts --output ./build/abc/main.abc --dump-plugin-ast --arktsconfig ./arktsconfig.json --restart-stages", "direct": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/no-import-no-struct.sts --output ./build/abc/no-import-no-struct.abc --dump-plugin-ast --arktsconfig ./arktsconfig-print-only.json", + "memo": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/memo.sts --output ./build/abc/memo.abc --dump-plugin-ast --arktsconfig ./arktsconfig-memo.json --restart-stages", "run": "npm run compile && npm run compile:plugins && npm run restart", + "run:memo": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run memo", "run:abc": "../../incremental/tools/panda/node_modules/@panda/sdk/linux_host_tools/bin/ark --load-runtimes=ets --boot-panda-files=../../incremental/tools/panda/node_modules/@panda/sdk/ets/etsstdlib.abc ./main.abc main.ETSGLOBAL::main", "mocha": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk TS_NODE_PROJECT=./test/tsconfig.json mocha -r tsconfig-paths/register --reporter-option maxDiffSize=0", "test": "npm run compile:native && npm run mocha", diff --git a/arkoala-arkts/libarkts/plugins/input/memo.sts b/arkoala-arkts/libarkts/plugins/input/memo.sts new file mode 100644 index 0000000000000000000000000000000000000000..1ac3b80a0424a322a2d5f2a3f5ba2dff48c3495f --- /dev/null +++ b/arkoala-arkts/libarkts/plugins/input/memo.sts @@ -0,0 +1,70 @@ + +@interface memo{} + +class Test { + + @memo void_method(): void { + } + + @memo a_method_with_implicit_return_type() { + } + + @memo void_method_with_arg(arg: string) { + } + + // TODO: return statement duplicates + // @memo void_method_with_return(arg: string) { + // return + // } + + // TODO: context.compute + // @memo string_method_with_return(arg: string): string { + // return arg + // } + + // TODO: context.compute + // @memo method_with_type_parameter(arg: T): T { + // return arg + // } + + // TODO: return statement duplicates + // @memo static static_method_with_type_parameter(arg: T): void { + // return + // } + + @memo internal_call() { + // TODO: the call doesn't rewrite + // this.void_method() + } + + //@memo lambda_arg(@memo arg: () => void) { + + //} + + //@memo lambda_arg_with_arg(@memo arg: (value: string) => string) { + + //} +} + +class Use { + test() { + const test = new Test() + + // TODO: the calls don't rewrite + // test.void_method() + // test.void_method_with_arg("an arg") + // test.void_method_with_return("a value") + // Test.static_method_with_type_parameter("I'm static") + + // TODO: the function don't rewrite + // test.string_method_with_return("a string") + // test.method_with_type_parameter("I'm string") + + // TODO: lamda calls + // test.lambda_arg(() => {}) + // test.lambda_arg((value: string) => value) + } +} + + +