diff --git a/incremental/common/src/Matrix33.ts b/incremental/common/src/Matrix33.ts index 9ff2feb33895acfd48b904e54e2d98c708139a89..c7087e64598d5d043e57abfeb0eb269c641996e3 100644 --- a/incremental/common/src/Matrix33.ts +++ b/incremental/common/src/Matrix33.ts @@ -13,13 +13,13 @@ * limitations under the License. */ -import { Array_from_number, float32, float64 } from "@koalaui/compat" +import { Array_from_number, float32, float64, float64To32 } from "@koalaui/compat" export function mat33(array?: Float32Array): Matrix33 { return (array == undefined) ? new Matrix33 () : new Matrix33(array) } -const tolerance: float32 = (1.0 / (1 << 12)) +const tolerance: float32 = float64To32(1.0 / (1 << 12)) export class Matrix33 { public readonly array: Float32Array diff --git a/incremental/compat/src/arkts/double.ts b/incremental/compat/src/arkts/double.ts index ed3fb70a5e246c47827b5744cab19d74d3464eb5..fc82195178ddc74ef6faf8c06d9286fa74915066 100644 --- a/incremental/compat/src/arkts/double.ts +++ b/incremental/compat/src/arkts/double.ts @@ -15,6 +15,14 @@ */ import { float64, int32, float32 } from "./types" +export function float32To64(value: float32): float64 { + return Float.toDouble(value) +} + +export function float64To32(value: float64): float32 { + return Double.toFloat(value) +} + export function asFloat64(value: string): float64 { return (new Number(value)).valueOf() } diff --git a/incremental/compat/src/index.ts b/incremental/compat/src/index.ts index 96204982b6360efc125e1b2eaeeea60d13b40c11..c9df2fc7433fafdd2693229b832cc5147b3b8fd3 100644 --- a/incremental/compat/src/index.ts +++ b/incremental/compat/src/index.ts @@ -23,6 +23,8 @@ export { asString, float32FromBits, int32BitsFromFloat, + float32To64, + float64To32, Thunk, finalizerRegister, finalizerUnregister, diff --git a/incremental/compat/src/typescript/double.ts b/incremental/compat/src/typescript/double.ts index 64ed41d2ac6b73aef4178b9339b99b7b6b1d8110..bd00e7a70312d68da1337ddc0aad3fbde065c577 100644 --- a/incremental/compat/src/typescript/double.ts +++ b/incremental/compat/src/typescript/double.ts @@ -19,6 +19,14 @@ export function asFloat64(value: string): float64 { return Number(value) } +export function float32To64(value: float32): float64 { + return value +} + +export function float64To32(value: float64): float32 { + return value +} + export function asString(value: float64 | undefined): string | undefined { return value?.toString() } diff --git a/incremental/runtime/package.json b/incremental/runtime/package.json index 1a3f83f180e1bf45a15726256901e2ae11aeb98e..937b774762af58011e34920ad9ff5973de1d68a8 100644 --- a/incremental/runtime/package.json +++ b/incremental/runtime/package.json @@ -38,7 +38,7 @@ "annotate": "npm run compile --prefix ../../ui2abc/annotate && node ../../ui2abc/annotate", "fast-arktsc": "npm run compile --prefix ../../ui2abc/fast-arktsc", "build:runtime:inc:ui2abc": "npm run annotate && npm run fast-arktsc && node ../../ui2abc/fast-arktsc --config ./ui2abcconfig.json --compiler ../tools/panda/arkts/ui2abc --link-name ./build/runtime.abc --restart-stages --group-by 5 && PANDA_SDK_PATH=${PANDA_SDK_PATH:=../tools/panda/node_modules/@panda/sdk} ninja ${NINJA_OPTIONS} -f build/build.ninja", - "build:runtime:inc:ui2abc:recheck": "npm run annotate && npm run fast-arktsc && node ../../ui2abc/fast-arktsc --config ./ui2abcconfig-recheck.json --compiler ../tools/panda/arkts/ui2abc --link-name ./build/runtime.abc --group-by 5 && PANDA_SDK_PATH=${PANDA_SDK_PATH:=../tools/panda/node_modules/@panda/sdk} ninja ${NINJA_OPTIONS} -f build/recheck/build.ninja", + "build:runtime:inc:ui2abc:recheck": "npm run annotate && npm run fast-arktsc && node ../../ui2abc/fast-arktsc --config ./ui2abcconfig-recheck.json --compiler ../tools/panda/arkts/ui2abc --link-name ./build/runtime.abc --group-by 2 && PANDA_SDK_PATH=${PANDA_SDK_PATH:=../tools/panda/node_modules/@panda/sdk} ninja ${NINJA_OPTIONS} -f build/recheck/build.ninja", "build:runtime:with:tests": "npm run unmemoize:with:tests && fast-arktsc --config ./arktsconfig-test-unmemoized.json --compiler ../tools/panda/arkts/arktsc --link-name ./build/runtime-tests.abc && ninja ${NINJA_OPTIONS} -f build/unmemoized/abc/build.ninja", "build:incremental:components": "npm run build:compat && npm run build:common && npm run build:runtime", "build:incremental:components:inc": "npm run build:compat:inc && npm run build:common:inc && npm run build:runtime:inc", @@ -65,4 +65,4 @@ "mocha": "^9.2.2", "source-map-support": "^0.5.21" } -} \ No newline at end of file +} diff --git a/ui2abc/libarkts/arktsconfig.json b/ui2abc/libarkts/arktsconfig.json index 3a00d970d1b980b5692b65ae72adfcd15d198ae1..bf0d40aafec6bda95393d7bc0551275aa793a50d 100644 --- a/ui2abc/libarkts/arktsconfig.json +++ b/ui2abc/libarkts/arktsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "package0": "@koalaui/example", "outDir": "./build/abc", + "package": "test", "baseUrl": ".", "plugins": [ { diff --git a/ui2abc/libarkts/native/src/generated/bridges.cc b/ui2abc/libarkts/native/src/generated/bridges.cc index b91259ba4ab2f3f20d8b3e672779956246b6e7c2..d8d866576f0aab32c1d2e68332a43f90d3753534 100644 --- a/ui2abc/libarkts/native/src/generated/bridges.cc +++ b/ui2abc/libarkts/native/src/generated/bridges.cc @@ -625,6 +625,16 @@ KNativePointer impl_IfStatementTest(KNativePointer context, KNativePointer recei } KOALA_INTEROP_2(IfStatementTest, KNativePointer, KNativePointer, KNativePointer); +void impl_IfStatementSetTest(KNativePointer context, KNativePointer receiver, KNativePointer test) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _test = reinterpret_cast(test); + GetImpl()->IfStatementSetTest(_context, _receiver, _test); + return ; +} +KOALA_INTEROP_V3(IfStatementSetTest, KNativePointer, KNativePointer, KNativePointer); + KNativePointer impl_IfStatementConsequentConst(KNativePointer context, KNativePointer receiver) { const auto _context = reinterpret_cast(context); @@ -4867,19 +4877,19 @@ KNativePointer impl_ClassDefinitionFunctionalReferenceReferencedMethodConst(KNat const auto _context = reinterpret_cast(context); const auto _receiver = reinterpret_cast(receiver); auto result = GetImpl()->ClassDefinitionFunctionalReferenceReferencedMethodConst(_context, _receiver); - return StageArena::strdup(result); + return (void*)result; } KOALA_INTEROP_2(ClassDefinitionFunctionalReferenceReferencedMethodConst, KNativePointer, KNativePointer, KNativePointer); -void impl_ClassDefinitionSetFunctionalReferenceReferencedMethod(KNativePointer context, KNativePointer receiver, KStringPtr& functionalReferenceReferencedMethod) +void impl_ClassDefinitionSetFunctionalReferenceReferencedMethod(KNativePointer context, KNativePointer receiver, KNativePointer functionalReferenceReferencedMethod) { const auto _context = reinterpret_cast(context); const auto _receiver = reinterpret_cast(receiver); - const auto _functionalReferenceReferencedMethod = getStringCopy(functionalReferenceReferencedMethod); + const auto _functionalReferenceReferencedMethod = reinterpret_cast(functionalReferenceReferencedMethod); GetImpl()->ClassDefinitionSetFunctionalReferenceReferencedMethod(_context, _receiver, _functionalReferenceReferencedMethod); return ; } -KOALA_INTEROP_V3(ClassDefinitionSetFunctionalReferenceReferencedMethod, KNativePointer, KNativePointer, KStringPtr); +KOALA_INTEROP_V3(ClassDefinitionSetFunctionalReferenceReferencedMethod, KNativePointer, KNativePointer, KNativePointer); KNativePointer impl_ClassDefinitionLocalPrefixConst(KNativePointer context, KNativePointer receiver) { @@ -6890,6 +6900,16 @@ KNativePointer impl_UnaryExpressionArgumentConst(KNativePointer context, KNative } KOALA_INTEROP_2(UnaryExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); +void impl_UnaryExpressionSetArgument(KNativePointer context, KNativePointer receiver, KNativePointer arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _arg = reinterpret_cast(arg); + GetImpl()->UnaryExpressionSetArgument(_context, _receiver, _arg); + return ; +} +KOALA_INTEROP_V3(UnaryExpressionSetArgument, KNativePointer, KNativePointer, KNativePointer); + KNativePointer impl_CreateForInStatement(KNativePointer context, KNativePointer left, KNativePointer right, KNativePointer body) { const auto _context = reinterpret_cast(context); @@ -8433,6 +8453,25 @@ KNativePointer impl_TSParenthesizedTypeTypeConst(KNativePointer context, KNative } KOALA_INTEROP_2(TSParenthesizedTypeTypeConst, KNativePointer, KNativePointer, KNativePointer); +KBoolean impl_LiteralIsFoldedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LiteralIsFoldedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(LiteralIsFoldedConst, KBoolean, KNativePointer, KNativePointer); + +void impl_LiteralSetFolded(KNativePointer context, KNativePointer receiver, KBoolean folded) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _folded = static_cast(folded); + GetImpl()->LiteralSetFolded(_context, _receiver, _folded); + return ; +} +KOALA_INTEROP_V3(LiteralSetFolded, KNativePointer, KNativePointer, KBoolean); + KNativePointer impl_CreateCharLiteral(KNativePointer context) { const auto _context = reinterpret_cast(context); @@ -9188,6 +9227,16 @@ KNativePointer impl_WhileStatementTest(KNativePointer context, KNativePointer re } KOALA_INTEROP_2(WhileStatementTest, KNativePointer, KNativePointer, KNativePointer); +void impl_WhileStatementSetTest(KNativePointer context, KNativePointer receiver, KNativePointer test) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _test = reinterpret_cast(test); + GetImpl()->WhileStatementSetTest(_context, _receiver, _test); + return ; +} +KOALA_INTEROP_V3(WhileStatementSetTest, KNativePointer, KNativePointer, KNativePointer); + KNativePointer impl_WhileStatementBodyConst(KNativePointer context, KNativePointer receiver) { const auto _context = reinterpret_cast(context); @@ -12030,45 +12079,65 @@ void impl_SrcDumperAdd(KNativePointer context, KNativePointer receiver, KStringP } KOALA_INTEROP_V3(SrcDumperAdd, KNativePointer, KNativePointer, KStringPtr); -void impl_SrcDumperAdd1(KNativePointer context, KNativePointer receiver, KInt i) +void impl_SrcDumperAdd1(KNativePointer context, KNativePointer receiver, KBoolean i) { const auto _context = reinterpret_cast(context); const auto _receiver = reinterpret_cast(receiver); - const auto _i = static_cast(i); + const auto _i = static_cast(i); GetImpl()->SrcDumperAdd1(_context, _receiver, _i); return ; } -KOALA_INTEROP_V3(SrcDumperAdd1, KNativePointer, KNativePointer, KInt); +KOALA_INTEROP_V3(SrcDumperAdd1, KNativePointer, KNativePointer, KBoolean); + +void impl_SrcDumperAdd2(KNativePointer context, KNativePointer receiver, KInt i) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _i = static_cast(i); + GetImpl()->SrcDumperAdd2(_context, _receiver, _i); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd2, KNativePointer, KNativePointer, KInt); + +void impl_SrcDumperAdd3(KNativePointer context, KNativePointer receiver, KInt i) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _i = static_cast(i); + GetImpl()->SrcDumperAdd3(_context, _receiver, _i); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd3, KNativePointer, KNativePointer, KInt); -void impl_SrcDumperAdd2(KNativePointer context, KNativePointer receiver, KLong l) +void impl_SrcDumperAdd4(KNativePointer context, KNativePointer receiver, KLong l) { const auto _context = reinterpret_cast(context); const auto _receiver = reinterpret_cast(receiver); const auto _l = static_cast(l); - GetImpl()->SrcDumperAdd2(_context, _receiver, _l); + GetImpl()->SrcDumperAdd4(_context, _receiver, _l); return ; } -KOALA_INTEROP_V3(SrcDumperAdd2, KNativePointer, KNativePointer, KLong); +KOALA_INTEROP_V3(SrcDumperAdd4, KNativePointer, KNativePointer, KLong); -void impl_SrcDumperAdd3(KNativePointer context, KNativePointer receiver, KFloat f) +void impl_SrcDumperAdd5(KNativePointer context, KNativePointer receiver, KFloat f) { const auto _context = reinterpret_cast(context); const auto _receiver = reinterpret_cast(receiver); const auto _f = static_cast(f); - GetImpl()->SrcDumperAdd3(_context, _receiver, _f); + GetImpl()->SrcDumperAdd5(_context, _receiver, _f); return ; } -KOALA_INTEROP_V3(SrcDumperAdd3, KNativePointer, KNativePointer, KFloat); +KOALA_INTEROP_V3(SrcDumperAdd5, KNativePointer, KNativePointer, KFloat); -void impl_SrcDumperAdd4(KNativePointer context, KNativePointer receiver, KDouble d) +void impl_SrcDumperAdd6(KNativePointer context, KNativePointer receiver, KDouble d) { const auto _context = reinterpret_cast(context); const auto _receiver = reinterpret_cast(receiver); const auto _d = static_cast(d); - GetImpl()->SrcDumperAdd4(_context, _receiver, _d); + GetImpl()->SrcDumperAdd6(_context, _receiver, _d); return ; } -KOALA_INTEROP_V3(SrcDumperAdd4, KNativePointer, KNativePointer, KDouble); +KOALA_INTEROP_V3(SrcDumperAdd6, KNativePointer, KNativePointer, KDouble); KNativePointer impl_SrcDumperStrConst(KNativePointer context, KNativePointer receiver) { diff --git a/ui2abc/libarkts/package.json b/ui2abc/libarkts/package.json index d5127b0d61bdfa06159dcd8f7807604d3d1ab0ae..edc94f9bfc772f5f5cdab6f2b7c88e2b066730e4 100644 --- a/ui2abc/libarkts/package.json +++ b/ui2abc/libarkts/package.json @@ -50,8 +50,8 @@ "compile:js": "npm run compile:src && rollup -c rollup.lib.mjs && rollup -c rollup.es2panda.mjs", "compile:gn": "npm run compile:koala:interop && npm run compile:js", "compile:plugins": "npx rollup -c ./rollup.printer-plugin.mjs && npx rollup -c ./rollup.no-visitor-plugin.mjs ", - "restart": "node ../fast-arktsc --config arktsconfig.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/abc/main.abc --restart-stages && ninja -f build/abc/build.ninja", - "direct": "node ../fast-arktsc --config arktsconfig.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/abc/main.abc && ninja -f build/abc/build.ninja", + "restart": "node ../fast-arktsc --config arktsconfig.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/abc/out.abc --restart-stages && ninja -f build/abc/build.ninja", + "direct": "node ../fast-arktsc --group-by 2 --config arktsconfig.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/abc/out.abc && ninja -v -f build/abc/build.ninja", "run": "npm run compile && npm run compile:plugins && npm run direct", "run:memo": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run memo", "run:abc": "$npm_package_config_panda_sdk_path/linux_host_tools/bin/ark --load-runtimes=ets --boot-panda-files=$npm_package_config_panda_sdk_path/ets/etsstdlib.abc ./main.abc main.ETSGLOBAL::main", @@ -70,4 +70,4 @@ "regenerate:ohos": "npx --yes @idlizer/arktscgen@$npm_package_config_gen_version --panda-sdk-path ${PANDA_SDK_PATH:=$npm_package_config_ohos_panda_sdk_path} --output-dir ../ --options-file ./generator/options.json5 --no-initialize", "reinstall:regenerate": "npm run panda:sdk:reinstall && npm run regenerate" } -} \ No newline at end of file +} diff --git a/ui2abc/libarkts/plugins/input/library.ets b/ui2abc/libarkts/plugins/input/library.ets index 6a90478cce3064de4ad1521dde0bedfeb7da1083..da40709d503f63ced11471c11d9001c12717a39f 100644 --- a/ui2abc/libarkts/plugins/input/library.ets +++ b/ui2abc/libarkts/plugins/input/library.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +import { Third } from "./third" + export function testFunction(): string { return "yes" } diff --git a/ui2abc/libarkts/plugins/input/main.ets b/ui2abc/libarkts/plugins/input/main.ets index 4846a65a957ef52a657ca7c743d4b86341481788..3396ced678fa0e7eba06b8abe01d5f153bb7f502 100644 --- a/ui2abc/libarkts/plugins/input/main.ets +++ b/ui2abc/libarkts/plugins/input/main.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +import { Third } from "./third" + enum X { A = 17 } diff --git a/ui2abc/libarkts/plugins/input/third.ets b/ui2abc/libarkts/plugins/input/third.ets new file mode 100644 index 0000000000000000000000000000000000000000..49cb0f708b9e12a91a446cb502068c5964c13fab --- /dev/null +++ b/ui2abc/libarkts/plugins/input/third.ets @@ -0,0 +1,3 @@ + +export class Third {} + diff --git a/ui2abc/libarkts/src-host/es2panda.ts b/ui2abc/libarkts/src-host/es2panda.ts index 8f314a43e0a6b05dbb738ab9737a201ecfdb90a7..bf3e720596f6359c668032118f0e801863a9da5c 100644 --- a/ui2abc/libarkts/src-host/es2panda.ts +++ b/ui2abc/libarkts/src-host/es2panda.ts @@ -15,12 +15,12 @@ import * as fs from "node:fs" import * as path from "node:path" -import { checkSDK, arktsGlobal as global, metaDatabase, runTransformer, CompilationOptions, findStdlib } from "@koalaui/libarkts" +import { checkSDK, arktsGlobal as global, metaDatabase, runTransformer, CompilationOptions, findStdlib, collectDependencies } from "@koalaui/libarkts" import { CheckedBackFilter, PluginContextImpl } from "@koalaui/libarkts" import { Command } from "commander" import { filterSource, isNumber, throwError } from "@koalaui/libarkts" import { Es2pandaContextState } from "@koalaui/libarkts" -import { Options, AstNode, Config, Context, createETSModuleFromContext, proceedToState, ProgramTransformer, rebindSubtree, recheckSubtree, dumpProgramInfo, dumpArkTsConfigInfo } from "@koalaui/libarkts" +import { Options, AstNode, Config, Context, GlobalContext, createETSModuleFromContext, proceedToState, ProgramTransformer, rebindSubtree, recheckSubtree, dumpProgramInfo, dumpArkTsConfigInfo } from "@koalaui/libarkts" function parseCommandLineArgs() { const commander = new Command() @@ -141,6 +141,7 @@ function restartCompiler(source: string, configPath: string, filePath: string, s } function invokeWithPlugins( + globalContext: GlobalContext, configPath: string, filePath: string, outputPath: string, @@ -171,7 +172,8 @@ function invokeWithPlugins( if (!global.configIsInitialized()) throw new Error(`Wrong config: path=${configPath} file=${filePath} stdlib=${stdlib} output=${outputPath}`) fs.mkdirSync(path.dirname(outputPath), {recursive: true}) - const compilerContext = Context.createFromFile(filePath, configPath, stdlib, outputPath)! + console.log(`will create ${globalContext.peer.toString(16)} ${filePath}`) + const compilerContext = Context.createCacheFromFile(filePath, compilerConfig, globalContext, false) global.compilerContext = compilerContext pluginNames.push(`_proceed_to_binary`) @@ -316,6 +318,37 @@ function readAndSortPlugins(configDir: string, plugins: any[]) { return pluginsByState } +function findDependencies(files: string[]): string[] { + // TODO: need dependencies + return files +} + +function findOutputDependencies(files: string[]): string[] { + // TODO: need dependencies + return files +} + +function createConfig(configPath: string, filePath?: string, outPath?: string): Config { + const values = [ + '_', + '--arktsconfig', + configPath, + '--extension', + 'ets', + '--stdlib', + findStdlib() + ] + if (outPath) { + values.push('--output') + values.push(outPath) + } + if (filePath) { + values.push(filePath) + } + console.log(values) + return Config.create(values) +} + export function main() { checkSDK() const { files, configPath, outputs, dumpAst, restartStages, stage } = parseCommandLineArgs() @@ -329,10 +362,16 @@ export function main() { const pluginNames = plugins.map((it: any) => `${it.name}-${it.stage}`) const pluginContext = new PluginContextImpl() const pluginsByState = readAndSortPlugins(configDir, plugins) + const filesWithDependencies = collectDependencies(files, configPath) + + const globalConfig = createConfig(configPath, files[0], outputs[0]) + const globalContext = GlobalContext.create(globalConfig, filesWithDependencies) for (var i = 0; i < files.length; i++) { - invokeWithPlugins(configPath, files[i], outputs[i], pluginsByState, dumpAst, restartStages, stage, pluginNames, pluginContext) + invokeWithPlugins(globalContext, configPath, files[i], outputs[i], pluginsByState, dumpAst, restartStages, stage, pluginNames, pluginContext) } + globalContext.destroy() + globalConfig.destroy() } function reportErrorAndExit(message: string): never { diff --git a/ui2abc/libarkts/src/arkts-api/peers/Config.ts b/ui2abc/libarkts/src/arkts-api/peers/Config.ts index 894fcbb75ee75119fa1a5106b3f5af042f095661..20a671fa256dd5480695d21da4c0a8ce90f04355 100644 --- a/ui2abc/libarkts/src/arkts-api/peers/Config.ts +++ b/ui2abc/libarkts/src/arkts-api/peers/Config.ts @@ -28,6 +28,7 @@ export class Config extends ArktsObject { static create( input: readonly string[] ): Config { + console.log(input) return new Config( global.es2panda._CreateConfig(input.length, passStringArray(input)) ) diff --git a/ui2abc/libarkts/src/arkts-api/peers/Context.ts b/ui2abc/libarkts/src/arkts-api/peers/Context.ts index 83f5fd45b13b7e47d2e55f9b15b309dae9efec34..d598bc939ac34115f1808d194cdd3d40e328cbd8 100644 --- a/ui2abc/libarkts/src/arkts-api/peers/Context.ts +++ b/ui2abc/libarkts/src/arkts-api/peers/Context.ts @@ -62,7 +62,18 @@ export class Context extends ArktsObject { ) } - static createCacheFromFile(filePath: string, configPath: string, stdlibPath: string, globalContext: GlobalContext, isExternal: boolean) { + static createCacheFromFile(filePath: string, config: Config, globalContext: GlobalContext, isExternal: boolean) { + return new Context( + global.es2panda._CreateCacheContextFromFile( + config.peer, + passString(filePath), + globalContext.peer, + isExternal + ) + ) + } +/* + static createCacheFromFile(filePath: string, outputPath: string, configPath: string, stdlibPath: string, globalContext: GlobalContext, isExternal: boolean) { const config = Config.create([ "", "--arktsconfig", @@ -71,6 +82,8 @@ export class Context extends ArktsObject { 'ets', '--stdlib', stdlibPath, + '--output', + outputPath, filePath ]) return new Context( @@ -82,7 +95,7 @@ export class Context extends ArktsObject { ) ) } - +*/ destroy() { if (this.peer != nullptr) { global.es2panda._DestroyContext(this.peer) diff --git a/ui2abc/libarkts/src/arkts-api/utilities/public.ts b/ui2abc/libarkts/src/arkts-api/utilities/public.ts index d9668af9c74d8a35f7da61fc5d3fec2a776256e4..b51e70200275aba5bb1c92a25c34eb074ac27a83 100644 --- a/ui2abc/libarkts/src/arkts-api/utilities/public.ts +++ b/ui2abc/libarkts/src/arkts-api/utilities/public.ts @@ -19,11 +19,11 @@ import { KNativePointer, nullptr } from "@koalaui/interop" import { passNode, passNodeArray, unpackNodeArray, unpackNonNullableNode } from "./private" import { Es2pandaContextState, Es2pandaModifierFlags } from "../../generated/Es2pandaEnums" import type { AstNode } from "../peers/AstNode" +import * as path from "path" import { type AnnotationUsage, ClassDefinition, ClassProperty, - ETSImportDeclaration, ETSModule, isClassDefinition, isFunctionDeclaration, @@ -36,6 +36,7 @@ import { Config } from "../peers/Config" import { Context } from "../peers/Context" import { NodeCache } from "../node-cache" import { programGetExternalSources } from "../node-utilities/Program" +import { defaultFilter, listPrograms } from "../plugins" export function createETSModuleFromContext(): ETSModule { let program = global.es2panda._ContextProgram(global.context) @@ -94,7 +95,7 @@ export function proceedToState(state: Es2pandaContextState): void { const before = Date.now() global.es2panda._ProceedToState(global.context, state) const after = Date.now() - global.profiler.proceededToState(after-before) + global.profiler.proceededToState(after - before) NodeCache.clear() checkErrors() } @@ -181,12 +182,12 @@ export function hasModifierFlag(node: AstNode, flag: Es2pandaModifierFlags): boo } export function modifiersToString(modifiers: Es2pandaModifierFlags): string { - return Object.values(Es2pandaModifierFlags) - .filter(isNumber) - .map(it => { - console.log(it.valueOf(), Es2pandaModifierFlags[it], modifiers.valueOf() & it) - return ((modifiers.valueOf() & it) === it) ? Es2pandaModifierFlags[it] : "" - }).join(" ") + return Object.values(Es2pandaModifierFlags) + .filter(isNumber) + .map(it => { + console.log(it.valueOf(), Es2pandaModifierFlags[it], modifiers.valueOf() & it) + return ((modifiers.valueOf() & it) === it) ? Es2pandaModifierFlags[it] : "" + }).join(" ") } export function nameIfIdentifier(node: AstNode): string { @@ -197,7 +198,7 @@ export function nameIfETSModule(node: AstNode): string { return isETSModule(node) ? `'${node.ident?.name}'` : "" } -export function asString(node: AstNode|undefined): string { +export function asString(node: AstNode | undefined): string { return `${node?.constructor.name} ${node ? nameIfIdentifier(node) : undefined}` } @@ -209,21 +210,31 @@ export function findStdlib(): string { defaultPandaSdk, `PANDA_SDK_PATH not set, assuming ${defaultPandaSdk}` ) - return `${sdk}/ets/stdlib` + return path.resolve(`${sdk}/ets/stdlib`) } export function collectDependencies(files: string[], configPath: string): string[] { const result = new Set() for (let file of files) { + console.log("collectDeps", file) const context = Context.createFromFile(file, configPath, findStdlib(), "/tmp/foo.abc")! global.compilerContext = context + proceedToState(Es2pandaContextState.ES2PANDA_STATE_PARSED) + /* let sources = programGetExternalSources(context.program, context.peer) sources.forEach(source => { - source.programs.forEach(program => { - result.add(program.absoluteName) - }) + if (defaultFilter(source.getName())) + source.programs.forEach(program => { + if (defaultFilter(program.moduleName)) + result.add(program.absoluteName) + }) }) + */ + listPrograms(context.program).forEach( + it => result.add(it.absoluteName) + ) context.destroy() } + console.log(result) return Array.from(result) } diff --git a/ui2abc/libarkts/src/generated/Es2pandaEnums.ts b/ui2abc/libarkts/src/generated/Es2pandaEnums.ts index 07b1308ffb94a21bf89fce9630b86eb7993e1897..446f0536a55e70836226bc3d2e9dbf41bded5a94 100644 --- a/ui2abc/libarkts/src/generated/Es2pandaEnums.ts +++ b/ui2abc/libarkts/src/generated/Es2pandaEnums.ts @@ -626,28 +626,6 @@ export enum Es2pandaMappedOption { MAPPED_OPTION_PLUS = 1, MAPPED_OPTION_MINUS = 2 } -export enum Es2pandaBoxingUnboxingFlags { - BOXING_UNBOXING_FLAGS_NONE = 0, - BOXING_UNBOXING_FLAGS_BOX_TO_BOOLEAN = 1, - BOXING_UNBOXING_FLAGS_BOX_TO_BYTE = 2, - BOXING_UNBOXING_FLAGS_BOX_TO_SHORT = 4, - BOXING_UNBOXING_FLAGS_BOX_TO_CHAR = 8, - BOXING_UNBOXING_FLAGS_BOX_TO_INT = 16, - BOXING_UNBOXING_FLAGS_BOX_TO_LONG = 32, - BOXING_UNBOXING_FLAGS_BOX_TO_FLOAT = 64, - BOXING_UNBOXING_FLAGS_BOX_TO_DOUBLE = 128, - BOXING_UNBOXING_FLAGS_BOX_TO_ENUM = 256, - BOXING_UNBOXING_FLAGS_UNBOX_TO_BOOLEAN = 512, - BOXING_UNBOXING_FLAGS_UNBOX_TO_BYTE = 1024, - BOXING_UNBOXING_FLAGS_UNBOX_TO_SHORT = 2048, - BOXING_UNBOXING_FLAGS_UNBOX_TO_CHAR = 4096, - BOXING_UNBOXING_FLAGS_UNBOX_TO_INT = 8192, - BOXING_UNBOXING_FLAGS_UNBOX_TO_LONG = 16384, - BOXING_UNBOXING_FLAGS_UNBOX_TO_FLOAT = 32768, - BOXING_UNBOXING_FLAGS_UNBOX_TO_DOUBLE = 65536, - BOXING_UNBOXING_FLAGS_BOXING_FLAG = 511, - BOXING_UNBOXING_FLAGS_UNBOXING_FLAG = 130560 -} export enum Es2pandaClassDefinitionModifiers { CLASS_DEFINITION_MODIFIERS_NONE = 0, CLASS_DEFINITION_MODIFIERS_DECLARATION = 1, @@ -689,35 +667,37 @@ export enum Es2pandaOperandType { } export enum Es2pandaTypeRelationFlag { TYPE_RELATION_FLAG_NONE = 0, - TYPE_RELATION_FLAG_NARROWING = 1, - TYPE_RELATION_FLAG_WIDENING = 2, - TYPE_RELATION_FLAG_BOXING = 4, - TYPE_RELATION_FLAG_UNBOXING = 8, - TYPE_RELATION_FLAG_CAPTURE = 16, - TYPE_RELATION_FLAG_STRING = 32, - TYPE_RELATION_FLAG_VALUE_SET = 64, - TYPE_RELATION_FLAG_UNCHECKED = 128, - TYPE_RELATION_FLAG_NO_THROW = 256, - TYPE_RELATION_FLAG_SELF_REFERENCE = 512, - TYPE_RELATION_FLAG_NO_RETURN_TYPE_CHECK = 1024, - TYPE_RELATION_FLAG_DIRECT_RETURN = 2048, - TYPE_RELATION_FLAG_NO_WIDENING = 4096, - TYPE_RELATION_FLAG_NO_BOXING = 8192, - TYPE_RELATION_FLAG_NO_UNBOXING = 16384, - TYPE_RELATION_FLAG_ONLY_CHECK_WIDENING = 32768, - TYPE_RELATION_FLAG_ONLY_CHECK_BOXING_UNBOXING = 65536, - TYPE_RELATION_FLAG_IN_ASSIGNMENT_CONTEXT = 131072, - TYPE_RELATION_FLAG_IN_CASTING_CONTEXT = 262144, - TYPE_RELATION_FLAG_UNCHECKED_CAST = 524288, - TYPE_RELATION_FLAG_IGNORE_TYPE_PARAMETERS = 1048576, - TYPE_RELATION_FLAG_CHECK_PROXY = 2097152, - TYPE_RELATION_FLAG_NO_CHECK_TRAILING_LAMBDA = 4194304, - TYPE_RELATION_FLAG_NO_THROW_GENERIC_TYPEALIAS = 8388608, - TYPE_RELATION_FLAG_OVERRIDING_CONTEXT = 16777216, - TYPE_RELATION_FLAG_IGNORE_REST_PARAM = 33554432, - TYPE_RELATION_FLAG_ASSIGNMENT_CONTEXT = 14, - TYPE_RELATION_FLAG_BRIDGE_CHECK = 17826816, - TYPE_RELATION_FLAG_CASTING_CONTEXT = 524303 + TYPE_RELATION_FLAG_WIDENING = 1, + TYPE_RELATION_FLAG_BOXING = 2, + TYPE_RELATION_FLAG_UNBOXING = 4, + TYPE_RELATION_FLAG_CAPTURE = 8, + TYPE_RELATION_FLAG_STRING = 16, + TYPE_RELATION_FLAG_VALUE_SET = 32, + TYPE_RELATION_FLAG_UNCHECKED = 64, + TYPE_RELATION_FLAG_NO_THROW = 128, + TYPE_RELATION_FLAG_SELF_REFERENCE = 256, + TYPE_RELATION_FLAG_NO_RETURN_TYPE_CHECK = 512, + TYPE_RELATION_FLAG_DIRECT_RETURN = 1024, + TYPE_RELATION_FLAG_NO_WIDENING = 2048, + TYPE_RELATION_FLAG_NO_BOXING = 4096, + TYPE_RELATION_FLAG_NO_UNBOXING = 8192, + TYPE_RELATION_FLAG_ONLY_CHECK_WIDENING = 16384, + TYPE_RELATION_FLAG_ONLY_CHECK_BOXING_UNBOXING = 32768, + TYPE_RELATION_FLAG_IN_ASSIGNMENT_CONTEXT = 65536, + TYPE_RELATION_FLAG_IN_CASTING_CONTEXT = 131072, + TYPE_RELATION_FLAG_UNCHECKED_CAST = 262144, + TYPE_RELATION_FLAG_IGNORE_TYPE_PARAMETERS = 524288, + TYPE_RELATION_FLAG_CHECK_PROXY = 1048576, + TYPE_RELATION_FLAG_NO_CHECK_TRAILING_LAMBDA = 2097152, + TYPE_RELATION_FLAG_NO_THROW_GENERIC_TYPEALIAS = 4194304, + TYPE_RELATION_FLAG_OVERRIDING_CONTEXT = 8388608, + TYPE_RELATION_FLAG_IGNORE_REST_PARAM = 16777216, + TYPE_RELATION_FLAG_STRING_TO_CHAR = 33554432, + TYPE_RELATION_FLAG_OVERLOADING_CONTEXT = 67108864, + TYPE_RELATION_FLAG_NO_SUBSTITUTION_NEEDED = 134217728, + TYPE_RELATION_FLAG_ASSIGNMENT_CONTEXT = 7, + TYPE_RELATION_FLAG_BRIDGE_CHECK = 8912896, + TYPE_RELATION_FLAG_CASTING_CONTEXT = 262151 } export enum Es2pandaRelationResult { RELATION_RESULT_TRUE = 0, @@ -834,6 +814,7 @@ export enum Es2pandaSignatureFlags { SIGNATURE_FLAGS_RETHROWS = 131072, SIGNATURE_FLAGS_EXTENSION_FUNCTION = 262144, SIGNATURE_FLAGS_DUPLICATE_ASM = 524288, + SIGNATURE_FLAGS_BRIDGE = 1048576, SIGNATURE_FLAGS_INTERNAL_PROTECTED = 1040, SIGNATURE_FLAGS_GETTER_OR_SETTER = 49152, SIGNATURE_FLAGS_THROWING = 196608 @@ -985,31 +966,31 @@ export enum Es2pandaGlobalTypeId { GLOBAL_TYPE_ID_ETS_INT_BUILTIN = 51, GLOBAL_TYPE_ID_ETS_INTEGRAL_BUILTIN = 52, GLOBAL_TYPE_ID_ETS_LONG_BUILTIN = 53, - GLOBAL_TYPE_ID_ETS_MAP_BUILTIN = 54, - GLOBAL_TYPE_ID_ETS_RECORD_BUILTIN = 55, - GLOBAL_TYPE_ID_ETS_ERROR_BUILTIN = 56, - GLOBAL_TYPE_ID_ETS_RUNTIME_BUILTIN = 57, - GLOBAL_TYPE_ID_ETS_RUNTIME_LINKER_BUILTIN = 58, - GLOBAL_TYPE_ID_ETS_SET_BUILTIN = 59, - GLOBAL_TYPE_ID_ETS_SHORT_BUILTIN = 60, - GLOBAL_TYPE_ID_ETS_STACK_TRACE_ELEMENT_BUILTIN = 61, - GLOBAL_TYPE_ID_ETS_STACK_TRACE_BUILTIN = 62, - GLOBAL_TYPE_ID_ETS_ARRAY_INDEX_OUT_OF_BOUNDS_ERROR_BUILTIN = 63, - GLOBAL_TYPE_ID_ETS_ARITHMETIC_ERROR_BUILTIN = 64, - GLOBAL_TYPE_ID_ETS_CLASS_CAST_ERROR_BUILTIN = 65, - GLOBAL_TYPE_ID_ETS_ASSERTION_ERROR_BUILTIN = 66, - GLOBAL_TYPE_ID_ETS_DIVIDE_BY_ZERO_ERROR_BUILTIN = 67, - GLOBAL_TYPE_ID_ETS_NULL_POINTER_ERROR_BUILTIN = 68, - GLOBAL_TYPE_ID_ETS_UNCAUGHT_EXCEPTION_ERROR_BUILTIN = 69, - GLOBAL_TYPE_ID_ETS_STRING_BUILTIN = 70, - GLOBAL_TYPE_ID_ETS_STRING_BUILDER_BUILTIN = 71, - GLOBAL_TYPE_ID_ETS_TYPE_BUILTIN = 72, - GLOBAL_TYPE_ID_ETS_TYPES_BUILTIN = 73, - GLOBAL_TYPE_ID_ETS_PROMISE_BUILTIN = 74, - GLOBAL_TYPE_ID_ETS_FUNCTION_BUILTIN = 75, - GLOBAL_TYPE_ID_ETS_REGEXP_BUILTIN = 76, - GLOBAL_TYPE_ID_ETS_ARRAY_BUILTIN = 77, - GLOBAL_TYPE_ID_ETS_ARRAY = 78, + GLOBAL_TYPE_ID_ETS_NUMERIC_BUILTIN = 54, + GLOBAL_TYPE_ID_ETS_MAP_BUILTIN = 55, + GLOBAL_TYPE_ID_ETS_RECORD_BUILTIN = 56, + GLOBAL_TYPE_ID_ETS_ERROR_BUILTIN = 57, + GLOBAL_TYPE_ID_ETS_RUNTIME_BUILTIN = 58, + GLOBAL_TYPE_ID_ETS_RUNTIME_LINKER_BUILTIN = 59, + GLOBAL_TYPE_ID_ETS_SET_BUILTIN = 60, + GLOBAL_TYPE_ID_ETS_SHORT_BUILTIN = 61, + GLOBAL_TYPE_ID_ETS_STACK_TRACE_ELEMENT_BUILTIN = 62, + GLOBAL_TYPE_ID_ETS_STACK_TRACE_BUILTIN = 63, + GLOBAL_TYPE_ID_ETS_ARRAY_INDEX_OUT_OF_BOUNDS_ERROR_BUILTIN = 64, + GLOBAL_TYPE_ID_ETS_ARITHMETIC_ERROR_BUILTIN = 65, + GLOBAL_TYPE_ID_ETS_CLASS_CAST_ERROR_BUILTIN = 66, + GLOBAL_TYPE_ID_ETS_ASSERTION_ERROR_BUILTIN = 67, + GLOBAL_TYPE_ID_ETS_DIVIDE_BY_ZERO_ERROR_BUILTIN = 68, + GLOBAL_TYPE_ID_ETS_NULL_POINTER_ERROR_BUILTIN = 69, + GLOBAL_TYPE_ID_ETS_UNCAUGHT_EXCEPTION_ERROR_BUILTIN = 70, + GLOBAL_TYPE_ID_ETS_STRING_BUILTIN = 71, + GLOBAL_TYPE_ID_ETS_STRING_BUILDER_BUILTIN = 72, + GLOBAL_TYPE_ID_ETS_TYPE_BUILTIN = 73, + GLOBAL_TYPE_ID_ETS_TYPES_BUILTIN = 74, + GLOBAL_TYPE_ID_ETS_PROMISE_BUILTIN = 75, + GLOBAL_TYPE_ID_ETS_FUNCTION_BUILTIN = 76, + GLOBAL_TYPE_ID_ETS_REGEXP_BUILTIN = 77, + GLOBAL_TYPE_ID_ETS_ARRAY_BUILTIN = 78, GLOBAL_TYPE_ID_ETS_INTEROP_JSRUNTIME_BUILTIN = 79, GLOBAL_TYPE_ID_ETS_INTEROP_JSVALUE_BUILTIN = 80, GLOBAL_TYPE_ID_ETS_BOX_BUILTIN = 81, @@ -1023,96 +1004,97 @@ export enum Es2pandaGlobalTypeId { GLOBAL_TYPE_ID_ETS_DOUBLE_BOX_BUILTIN = 89, GLOBAL_TYPE_ID_ETS_BIG_INT_BUILTIN = 90, GLOBAL_TYPE_ID_ETS_BIG_INT = 91, - GLOBAL_TYPE_ID_ETS_FUNCTION0_CLASS = 92, - GLOBAL_TYPE_ID_ETS_FUNCTION1_CLASS = 93, - GLOBAL_TYPE_ID_ETS_FUNCTION2_CLASS = 94, - GLOBAL_TYPE_ID_ETS_FUNCTION3_CLASS = 95, - GLOBAL_TYPE_ID_ETS_FUNCTION4_CLASS = 96, - GLOBAL_TYPE_ID_ETS_FUNCTION5_CLASS = 97, - GLOBAL_TYPE_ID_ETS_FUNCTION6_CLASS = 98, - GLOBAL_TYPE_ID_ETS_FUNCTION7_CLASS = 99, - GLOBAL_TYPE_ID_ETS_FUNCTION8_CLASS = 100, - GLOBAL_TYPE_ID_ETS_FUNCTION9_CLASS = 101, - GLOBAL_TYPE_ID_ETS_FUNCTION10_CLASS = 102, - GLOBAL_TYPE_ID_ETS_FUNCTION11_CLASS = 103, - GLOBAL_TYPE_ID_ETS_FUNCTION12_CLASS = 104, - GLOBAL_TYPE_ID_ETS_FUNCTION13_CLASS = 105, - GLOBAL_TYPE_ID_ETS_FUNCTION14_CLASS = 106, - GLOBAL_TYPE_ID_ETS_FUNCTION15_CLASS = 107, - GLOBAL_TYPE_ID_ETS_FUNCTION16_CLASS = 108, - GLOBAL_TYPE_ID_ETS_FUNCTIONN_CLASS = 109, - GLOBAL_TYPE_ID_ETS_LAMBDA0_CLASS = 110, - GLOBAL_TYPE_ID_ETS_LAMBDA1_CLASS = 111, - GLOBAL_TYPE_ID_ETS_LAMBDA2_CLASS = 112, - GLOBAL_TYPE_ID_ETS_LAMBDA3_CLASS = 113, - GLOBAL_TYPE_ID_ETS_LAMBDA4_CLASS = 114, - GLOBAL_TYPE_ID_ETS_LAMBDA5_CLASS = 115, - GLOBAL_TYPE_ID_ETS_LAMBDA6_CLASS = 116, - GLOBAL_TYPE_ID_ETS_LAMBDA7_CLASS = 117, - GLOBAL_TYPE_ID_ETS_LAMBDA8_CLASS = 118, - GLOBAL_TYPE_ID_ETS_LAMBDA9_CLASS = 119, - GLOBAL_TYPE_ID_ETS_LAMBDA10_CLASS = 120, - GLOBAL_TYPE_ID_ETS_LAMBDA11_CLASS = 121, - GLOBAL_TYPE_ID_ETS_LAMBDA12_CLASS = 122, - GLOBAL_TYPE_ID_ETS_LAMBDA13_CLASS = 123, - GLOBAL_TYPE_ID_ETS_LAMBDA14_CLASS = 124, - GLOBAL_TYPE_ID_ETS_LAMBDA15_CLASS = 125, - GLOBAL_TYPE_ID_ETS_LAMBDA16_CLASS = 126, - GLOBAL_TYPE_ID_ETS_LAMBDAN_CLASS = 127, - GLOBAL_TYPE_ID_ETS_FUNCTIONR0_CLASS = 128, - GLOBAL_TYPE_ID_ETS_FUNCTIONR1_CLASS = 129, - GLOBAL_TYPE_ID_ETS_FUNCTIONR2_CLASS = 130, - GLOBAL_TYPE_ID_ETS_FUNCTIONR3_CLASS = 131, - GLOBAL_TYPE_ID_ETS_FUNCTIONR4_CLASS = 132, - GLOBAL_TYPE_ID_ETS_FUNCTIONR5_CLASS = 133, - GLOBAL_TYPE_ID_ETS_FUNCTIONR6_CLASS = 134, - GLOBAL_TYPE_ID_ETS_FUNCTIONR7_CLASS = 135, - GLOBAL_TYPE_ID_ETS_FUNCTIONR8_CLASS = 136, - GLOBAL_TYPE_ID_ETS_FUNCTIONR9_CLASS = 137, - GLOBAL_TYPE_ID_ETS_FUNCTIONR10_CLASS = 138, - GLOBAL_TYPE_ID_ETS_FUNCTIONR11_CLASS = 139, - GLOBAL_TYPE_ID_ETS_FUNCTIONR12_CLASS = 140, - GLOBAL_TYPE_ID_ETS_FUNCTIONR13_CLASS = 141, - GLOBAL_TYPE_ID_ETS_FUNCTIONR14_CLASS = 142, - GLOBAL_TYPE_ID_ETS_FUNCTIONR15_CLASS = 143, - GLOBAL_TYPE_ID_ETS_FUNCTIONR16_CLASS = 144, - GLOBAL_TYPE_ID_ETS_LAMBDAR0_CLASS = 145, - GLOBAL_TYPE_ID_ETS_LAMBDAR1_CLASS = 146, - GLOBAL_TYPE_ID_ETS_LAMBDAR2_CLASS = 147, - GLOBAL_TYPE_ID_ETS_LAMBDAR3_CLASS = 148, - GLOBAL_TYPE_ID_ETS_LAMBDAR4_CLASS = 149, - GLOBAL_TYPE_ID_ETS_LAMBDAR5_CLASS = 150, - GLOBAL_TYPE_ID_ETS_LAMBDAR6_CLASS = 151, - GLOBAL_TYPE_ID_ETS_LAMBDAR7_CLASS = 152, - GLOBAL_TYPE_ID_ETS_LAMBDAR8_CLASS = 153, - GLOBAL_TYPE_ID_ETS_LAMBDAR9_CLASS = 154, - GLOBAL_TYPE_ID_ETS_LAMBDAR10_CLASS = 155, - GLOBAL_TYPE_ID_ETS_LAMBDAR11_CLASS = 156, - GLOBAL_TYPE_ID_ETS_LAMBDAR12_CLASS = 157, - GLOBAL_TYPE_ID_ETS_LAMBDAR13_CLASS = 158, - GLOBAL_TYPE_ID_ETS_LAMBDAR14_CLASS = 159, - GLOBAL_TYPE_ID_ETS_LAMBDAR15_CLASS = 160, - GLOBAL_TYPE_ID_ETS_LAMBDAR16_CLASS = 161, - GLOBAL_TYPE_ID_ETS_TUPLE0_CLASS = 162, - GLOBAL_TYPE_ID_ETS_TUPLE1_CLASS = 163, - GLOBAL_TYPE_ID_ETS_TUPLE2_CLASS = 164, - GLOBAL_TYPE_ID_ETS_TUPLE3_CLASS = 165, - GLOBAL_TYPE_ID_ETS_TUPLE4_CLASS = 166, - GLOBAL_TYPE_ID_ETS_TUPLE5_CLASS = 167, - GLOBAL_TYPE_ID_ETS_TUPLE6_CLASS = 168, - GLOBAL_TYPE_ID_ETS_TUPLE7_CLASS = 169, - GLOBAL_TYPE_ID_ETS_TUPLE8_CLASS = 170, - GLOBAL_TYPE_ID_ETS_TUPLE9_CLASS = 171, - GLOBAL_TYPE_ID_ETS_TUPLE10_CLASS = 172, - GLOBAL_TYPE_ID_ETS_TUPLE11_CLASS = 173, - GLOBAL_TYPE_ID_ETS_TUPLE12_CLASS = 174, - GLOBAL_TYPE_ID_ETS_TUPLE13_CLASS = 175, - GLOBAL_TYPE_ID_ETS_TUPLE14_CLASS = 176, - GLOBAL_TYPE_ID_ETS_TUPLE15_CLASS = 177, - GLOBAL_TYPE_ID_ETS_TUPLE16_CLASS = 178, - GLOBAL_TYPE_ID_ETS_TUPLEN_CLASS = 179, - GLOBAL_TYPE_ID_TYPE_ERROR = 180, - GLOBAL_TYPE_ID_COUNT = 181 + GLOBAL_TYPE_ID_ETS_ARRAY = 92, + GLOBAL_TYPE_ID_ETS_FUNCTION0_CLASS = 93, + GLOBAL_TYPE_ID_ETS_FUNCTION1_CLASS = 94, + GLOBAL_TYPE_ID_ETS_FUNCTION2_CLASS = 95, + GLOBAL_TYPE_ID_ETS_FUNCTION3_CLASS = 96, + GLOBAL_TYPE_ID_ETS_FUNCTION4_CLASS = 97, + GLOBAL_TYPE_ID_ETS_FUNCTION5_CLASS = 98, + GLOBAL_TYPE_ID_ETS_FUNCTION6_CLASS = 99, + GLOBAL_TYPE_ID_ETS_FUNCTION7_CLASS = 100, + GLOBAL_TYPE_ID_ETS_FUNCTION8_CLASS = 101, + GLOBAL_TYPE_ID_ETS_FUNCTION9_CLASS = 102, + GLOBAL_TYPE_ID_ETS_FUNCTION10_CLASS = 103, + GLOBAL_TYPE_ID_ETS_FUNCTION11_CLASS = 104, + GLOBAL_TYPE_ID_ETS_FUNCTION12_CLASS = 105, + GLOBAL_TYPE_ID_ETS_FUNCTION13_CLASS = 106, + GLOBAL_TYPE_ID_ETS_FUNCTION14_CLASS = 107, + GLOBAL_TYPE_ID_ETS_FUNCTION15_CLASS = 108, + GLOBAL_TYPE_ID_ETS_FUNCTION16_CLASS = 109, + GLOBAL_TYPE_ID_ETS_FUNCTIONN_CLASS = 110, + GLOBAL_TYPE_ID_ETS_LAMBDA0_CLASS = 111, + GLOBAL_TYPE_ID_ETS_LAMBDA1_CLASS = 112, + GLOBAL_TYPE_ID_ETS_LAMBDA2_CLASS = 113, + GLOBAL_TYPE_ID_ETS_LAMBDA3_CLASS = 114, + GLOBAL_TYPE_ID_ETS_LAMBDA4_CLASS = 115, + GLOBAL_TYPE_ID_ETS_LAMBDA5_CLASS = 116, + GLOBAL_TYPE_ID_ETS_LAMBDA6_CLASS = 117, + GLOBAL_TYPE_ID_ETS_LAMBDA7_CLASS = 118, + GLOBAL_TYPE_ID_ETS_LAMBDA8_CLASS = 119, + GLOBAL_TYPE_ID_ETS_LAMBDA9_CLASS = 120, + GLOBAL_TYPE_ID_ETS_LAMBDA10_CLASS = 121, + GLOBAL_TYPE_ID_ETS_LAMBDA11_CLASS = 122, + GLOBAL_TYPE_ID_ETS_LAMBDA12_CLASS = 123, + GLOBAL_TYPE_ID_ETS_LAMBDA13_CLASS = 124, + GLOBAL_TYPE_ID_ETS_LAMBDA14_CLASS = 125, + GLOBAL_TYPE_ID_ETS_LAMBDA15_CLASS = 126, + GLOBAL_TYPE_ID_ETS_LAMBDA16_CLASS = 127, + GLOBAL_TYPE_ID_ETS_LAMBDAN_CLASS = 128, + GLOBAL_TYPE_ID_ETS_FUNCTIONR0_CLASS = 129, + GLOBAL_TYPE_ID_ETS_FUNCTIONR1_CLASS = 130, + GLOBAL_TYPE_ID_ETS_FUNCTIONR2_CLASS = 131, + GLOBAL_TYPE_ID_ETS_FUNCTIONR3_CLASS = 132, + GLOBAL_TYPE_ID_ETS_FUNCTIONR4_CLASS = 133, + GLOBAL_TYPE_ID_ETS_FUNCTIONR5_CLASS = 134, + GLOBAL_TYPE_ID_ETS_FUNCTIONR6_CLASS = 135, + GLOBAL_TYPE_ID_ETS_FUNCTIONR7_CLASS = 136, + GLOBAL_TYPE_ID_ETS_FUNCTIONR8_CLASS = 137, + GLOBAL_TYPE_ID_ETS_FUNCTIONR9_CLASS = 138, + GLOBAL_TYPE_ID_ETS_FUNCTIONR10_CLASS = 139, + GLOBAL_TYPE_ID_ETS_FUNCTIONR11_CLASS = 140, + GLOBAL_TYPE_ID_ETS_FUNCTIONR12_CLASS = 141, + GLOBAL_TYPE_ID_ETS_FUNCTIONR13_CLASS = 142, + GLOBAL_TYPE_ID_ETS_FUNCTIONR14_CLASS = 143, + GLOBAL_TYPE_ID_ETS_FUNCTIONR15_CLASS = 144, + GLOBAL_TYPE_ID_ETS_FUNCTIONR16_CLASS = 145, + GLOBAL_TYPE_ID_ETS_LAMBDAR0_CLASS = 146, + GLOBAL_TYPE_ID_ETS_LAMBDAR1_CLASS = 147, + GLOBAL_TYPE_ID_ETS_LAMBDAR2_CLASS = 148, + GLOBAL_TYPE_ID_ETS_LAMBDAR3_CLASS = 149, + GLOBAL_TYPE_ID_ETS_LAMBDAR4_CLASS = 150, + GLOBAL_TYPE_ID_ETS_LAMBDAR5_CLASS = 151, + GLOBAL_TYPE_ID_ETS_LAMBDAR6_CLASS = 152, + GLOBAL_TYPE_ID_ETS_LAMBDAR7_CLASS = 153, + GLOBAL_TYPE_ID_ETS_LAMBDAR8_CLASS = 154, + GLOBAL_TYPE_ID_ETS_LAMBDAR9_CLASS = 155, + GLOBAL_TYPE_ID_ETS_LAMBDAR10_CLASS = 156, + GLOBAL_TYPE_ID_ETS_LAMBDAR11_CLASS = 157, + GLOBAL_TYPE_ID_ETS_LAMBDAR12_CLASS = 158, + GLOBAL_TYPE_ID_ETS_LAMBDAR13_CLASS = 159, + GLOBAL_TYPE_ID_ETS_LAMBDAR14_CLASS = 160, + GLOBAL_TYPE_ID_ETS_LAMBDAR15_CLASS = 161, + GLOBAL_TYPE_ID_ETS_LAMBDAR16_CLASS = 162, + GLOBAL_TYPE_ID_ETS_TUPLE0_CLASS = 163, + GLOBAL_TYPE_ID_ETS_TUPLE1_CLASS = 164, + GLOBAL_TYPE_ID_ETS_TUPLE2_CLASS = 165, + GLOBAL_TYPE_ID_ETS_TUPLE3_CLASS = 166, + GLOBAL_TYPE_ID_ETS_TUPLE4_CLASS = 167, + GLOBAL_TYPE_ID_ETS_TUPLE5_CLASS = 168, + GLOBAL_TYPE_ID_ETS_TUPLE6_CLASS = 169, + GLOBAL_TYPE_ID_ETS_TUPLE7_CLASS = 170, + GLOBAL_TYPE_ID_ETS_TUPLE8_CLASS = 171, + GLOBAL_TYPE_ID_ETS_TUPLE9_CLASS = 172, + GLOBAL_TYPE_ID_ETS_TUPLE10_CLASS = 173, + GLOBAL_TYPE_ID_ETS_TUPLE11_CLASS = 174, + GLOBAL_TYPE_ID_ETS_TUPLE12_CLASS = 175, + GLOBAL_TYPE_ID_ETS_TUPLE13_CLASS = 176, + GLOBAL_TYPE_ID_ETS_TUPLE14_CLASS = 177, + GLOBAL_TYPE_ID_ETS_TUPLE15_CLASS = 178, + GLOBAL_TYPE_ID_ETS_TUPLE16_CLASS = 179, + GLOBAL_TYPE_ID_ETS_TUPLEN_CLASS = 180, + GLOBAL_TYPE_ID_TYPE_ERROR = 181, + GLOBAL_TYPE_ID_COUNT = 182 } export enum Es2pandaMethodDefinitionKind { METHOD_DEFINITION_KIND_NONE = 0, diff --git a/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts b/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts index 8cad16f693c9061bc88ea7dad4adb81785add693..833446f05e46d1dc7c205f365dc93b2d1116070f 100644 --- a/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts +++ b/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts @@ -217,6 +217,9 @@ export class Es2pandaNativeModule { _IfStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } + _IfStatementSetTest(context: KNativePointer, receiver: KNativePointer, test: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } _IfStatementConsequentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } @@ -1519,10 +1522,10 @@ export class Es2pandaNativeModule { _ClassDefinitionLocalIndexConst(context: KNativePointer, receiver: KNativePointer): KInt { throw new Error("This methods was not overloaded by native module initialization") } - _ClassDefinitionFunctionalReferenceReferencedMethodConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + _ClassDefinitionFunctionalReferenceReferencedMethodConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } - _ClassDefinitionSetFunctionalReferenceReferencedMethod(context: KNativePointer, receiver: KNativePointer, functionalReferenceReferencedMethod: KStringPtr): void { + _ClassDefinitionSetFunctionalReferenceReferencedMethod(context: KNativePointer, receiver: KNativePointer, functionalReferenceReferencedMethod: KNativePointer): void { throw new Error("This methods was not overloaded by native module initialization") } _ClassDefinitionLocalPrefixConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { @@ -2152,6 +2155,9 @@ export class Es2pandaNativeModule { _UnaryExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } + _UnaryExpressionSetArgument(context: KNativePointer, receiver: KNativePointer, arg: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } _CreateForInStatement(context: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } @@ -2629,6 +2635,12 @@ export class Es2pandaNativeModule { _TSParenthesizedTypeTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } + _LiteralIsFoldedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _LiteralSetFolded(context: KNativePointer, receiver: KNativePointer, folded: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } _CreateCharLiteral(context: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } @@ -2860,6 +2872,9 @@ export class Es2pandaNativeModule { _WhileStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } + _WhileStatementSetTest(context: KNativePointer, receiver: KNativePointer, test: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } _WhileStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } @@ -3733,16 +3748,22 @@ export class Es2pandaNativeModule { _SrcDumperAdd(context: KNativePointer, receiver: KNativePointer, str: KStringPtr): void { throw new Error("This methods was not overloaded by native module initialization") } - _SrcDumperAdd1(context: KNativePointer, receiver: KNativePointer, i: KInt): void { + _SrcDumperAdd1(context: KNativePointer, receiver: KNativePointer, i: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperAdd2(context: KNativePointer, receiver: KNativePointer, i: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperAdd3(context: KNativePointer, receiver: KNativePointer, i: KInt): void { throw new Error("This methods was not overloaded by native module initialization") } - _SrcDumperAdd2(context: KNativePointer, receiver: KNativePointer, l: KLong): void { + _SrcDumperAdd4(context: KNativePointer, receiver: KNativePointer, l: KLong): void { throw new Error("This methods was not overloaded by native module initialization") } - _SrcDumperAdd3(context: KNativePointer, receiver: KNativePointer, f: KFloat): void { + _SrcDumperAdd5(context: KNativePointer, receiver: KNativePointer, f: KFloat): void { throw new Error("This methods was not overloaded by native module initialization") } - _SrcDumperAdd4(context: KNativePointer, receiver: KNativePointer, d: KDouble): void { + _SrcDumperAdd6(context: KNativePointer, receiver: KNativePointer, d: KDouble): void { throw new Error("This methods was not overloaded by native module initialization") } _SrcDumperStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { diff --git a/ui2abc/libarkts/src/generated/peers/ClassDefinition.ts b/ui2abc/libarkts/src/generated/peers/ClassDefinition.ts index 05a2d97885eb621f853eb6cd0abed1e6df305209..92df6f1205126ead1934e38bb24b01e260b5dc07 100644 --- a/ui2abc/libarkts/src/generated/peers/ClassDefinition.ts +++ b/ui2abc/libarkts/src/generated/peers/ClassDefinition.ts @@ -172,12 +172,12 @@ export class ClassDefinition extends TypedAstNode { get localIndex(): number { return global.generatedEs2panda._ClassDefinitionLocalIndexConst(global.context, this.peer) } - get functionalReferenceReferencedMethod(): string { - return unpackString(global.generatedEs2panda._ClassDefinitionFunctionalReferenceReferencedMethodConst(global.context, this.peer)) + get functionalReferenceReferencedMethod(): MethodDefinition | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionFunctionalReferenceReferencedMethodConst(global.context, this.peer)) } /** @deprecated */ - setFunctionalReferenceReferencedMethod(functionalReferenceReferencedMethod: string): this { - global.generatedEs2panda._ClassDefinitionSetFunctionalReferenceReferencedMethod(global.context, this.peer, functionalReferenceReferencedMethod) + setFunctionalReferenceReferencedMethod(functionalReferenceReferencedMethod?: MethodDefinition): this { + global.generatedEs2panda._ClassDefinitionSetFunctionalReferenceReferencedMethod(global.context, this.peer, passNode(functionalReferenceReferencedMethod)) return this } get localPrefix(): string { diff --git a/ui2abc/libarkts/src/generated/peers/IfStatement.ts b/ui2abc/libarkts/src/generated/peers/IfStatement.ts index a5f0e8960c0c3879012cbaeb21aa68630d67fe6a..d5c6b1dd50f4d06374524073fc11292b416df2ec 100644 --- a/ui2abc/libarkts/src/generated/peers/IfStatement.ts +++ b/ui2abc/libarkts/src/generated/peers/IfStatement.ts @@ -45,6 +45,11 @@ export class IfStatement extends Statement { get test(): Expression | undefined { return unpackNode(global.generatedEs2panda._IfStatementTest(global.context, this.peer)) } + /** @deprecated */ + setTest(test?: Expression): this { + global.generatedEs2panda._IfStatementSetTest(global.context, this.peer, passNode(test)) + return this + } get consequent(): Statement | undefined { return unpackNode(global.generatedEs2panda._IfStatementConsequent(global.context, this.peer)) } diff --git a/ui2abc/libarkts/src/generated/peers/Literal.ts b/ui2abc/libarkts/src/generated/peers/Literal.ts index 9bd3d2c11e59ad54482c3f3d305da190667f3924..fc110007e67f8f97eb86804367019de93503767a 100644 --- a/ui2abc/libarkts/src/generated/peers/Literal.ts +++ b/ui2abc/libarkts/src/generated/peers/Literal.ts @@ -33,6 +33,14 @@ export class Literal extends Expression { constructor(pointer: KNativePointer) { super(pointer) } + get isFolded(): boolean { + return global.generatedEs2panda._LiteralIsFoldedConst(global.context, this.peer) + } + /** @deprecated */ + setFolded(folded: boolean): this { + global.generatedEs2panda._LiteralSetFolded(global.context, this.peer, folded) + return this + } protected readonly brandLiteral: undefined } export function isLiteral(node: object | undefined): node is Literal { diff --git a/ui2abc/libarkts/src/generated/peers/SrcDumper.ts b/ui2abc/libarkts/src/generated/peers/SrcDumper.ts index 35021bb83f79f6f9d1afd5cbae1e12971860c4de..8ec090e54218eb167355b717a2e242c210cd8f69 100644 --- a/ui2abc/libarkts/src/generated/peers/SrcDumper.ts +++ b/ui2abc/libarkts/src/generated/peers/SrcDumper.ts @@ -46,18 +46,28 @@ export class SrcDumper extends ArktsObject { return this } /** @deprecated */ - add2(l: number): this { - global.generatedEs2panda._SrcDumperAdd2(global.context, this.peer, l) + add2(i: number): this { + global.generatedEs2panda._SrcDumperAdd2(global.context, this.peer, i) return this } /** @deprecated */ - add3(f: number): this { - global.generatedEs2panda._SrcDumperAdd3(global.context, this.peer, f) + add3(i: number): this { + global.generatedEs2panda._SrcDumperAdd3(global.context, this.peer, i) return this } /** @deprecated */ - add4(d: number): this { - global.generatedEs2panda._SrcDumperAdd4(global.context, this.peer, d) + add4(l: number): this { + global.generatedEs2panda._SrcDumperAdd4(global.context, this.peer, l) + return this + } + /** @deprecated */ + add5(f: number): this { + global.generatedEs2panda._SrcDumperAdd5(global.context, this.peer, f) + return this + } + /** @deprecated */ + add6(d: number): this { + global.generatedEs2panda._SrcDumperAdd6(global.context, this.peer, d) return this } get str(): string { diff --git a/ui2abc/libarkts/src/generated/peers/UnaryExpression.ts b/ui2abc/libarkts/src/generated/peers/UnaryExpression.ts index ea848cb11a55fc1b5683829865d932957363c05c..71e0c9b9a84f0fa43a6025403f08f2a9b9c809ac 100644 --- a/ui2abc/libarkts/src/generated/peers/UnaryExpression.ts +++ b/ui2abc/libarkts/src/generated/peers/UnaryExpression.ts @@ -48,6 +48,11 @@ export class UnaryExpression extends Expression { get argument(): Expression | undefined { return unpackNode(global.generatedEs2panda._UnaryExpressionArgument(global.context, this.peer)) } + /** @deprecated */ + setArgument(arg?: Expression): this { + global.generatedEs2panda._UnaryExpressionSetArgument(global.context, this.peer, passNode(arg)) + return this + } protected readonly brandUnaryExpression: undefined } export function isUnaryExpression(node: object | undefined): node is UnaryExpression { diff --git a/ui2abc/libarkts/src/generated/peers/WhileStatement.ts b/ui2abc/libarkts/src/generated/peers/WhileStatement.ts index 0f487a883a4e2b058bf4cfc309c7ac32bf9c913e..d0e3dc3e0f2620398f43da7b620c6084273c4582 100644 --- a/ui2abc/libarkts/src/generated/peers/WhileStatement.ts +++ b/ui2abc/libarkts/src/generated/peers/WhileStatement.ts @@ -46,6 +46,11 @@ export class WhileStatement extends LoopStatement { get test(): Expression | undefined { return unpackNode(global.generatedEs2panda._WhileStatementTest(global.context, this.peer)) } + /** @deprecated */ + setTest(test?: Expression): this { + global.generatedEs2panda._WhileStatementSetTest(global.context, this.peer, passNode(test)) + return this + } get body(): Statement | undefined { return unpackNode(global.generatedEs2panda._WhileStatementBody(global.context, this.peer)) } diff --git a/ui2abc/libarkts/src/plugin-utils.ts b/ui2abc/libarkts/src/plugin-utils.ts index f491f8969715108b3bc2affca9a04dcfa9a3e9c9..c5b1e3479ecf251a0a0f75312787903435934d25 100644 --- a/ui2abc/libarkts/src/plugin-utils.ts +++ b/ui2abc/libarkts/src/plugin-utils.ts @@ -33,9 +33,8 @@ export interface RunTransformerHooks { onProgramTransformEnd?(options: CompilationOptions): void } -class ASTCache { +class ProcessedPrograms { processedPrograms = new Set() - constructor() { } find(program: Program): boolean { return this.processedPrograms.has(program.absoluteName) } @@ -51,6 +50,11 @@ export function runTransformer(prog: Program, state: Es2pandaContextState, resta // The first program provided by program provider is the main program let currentProgram = provider.next() let isMainProgram = true + let processed = pluginContext.parameter("ProcessedPrograms") + if (!processed) { + processed = new ProcessedPrograms() + pluginContext.setParameter("ProcessedPrograms", processed) + } while (currentProgram) { // Options passed to plugin and hooks @@ -74,7 +78,13 @@ export function runTransformer(prog: Program, state: Es2pandaContextState, resta // Run the plugin itself if (options.isMainProgram || !onlyModifyMain) { - transform?.(currentProgram, options, pluginContext) + if (!processed.find(currentProgram)) { + transform?.(currentProgram, options, pluginContext) + if (state == Es2pandaContextState.ES2PANDA_STATE_CHECKED) + processed.update(currentProgram) + } else { + console.log(`${currentProgram.absoluteName} already processed`) + } } // Run some common plugins that should be run after plugin usage and depends on the current stage