diff --git a/es2panda/es2abc_config.gni b/es2panda/es2abc_config.gni index 6a14c16732c8afe92d798ac39123de08682029e9..5ef8a79ab50f9fe415c0d554aa1955e8b51cf5b7 100644 --- a/es2panda/es2abc_config.gni +++ b/es2panda/es2abc_config.gni @@ -71,6 +71,13 @@ template("es2abc_gen_abc") { rebase_path("${es2abc_build_path}"), ] + if (defined(invoker.extension)) { + args += [ + "--extension", + invoker.extension, + ] + } + if (defined(invoker.dump_symbol_table)) { args += [ "--dump-symbol-table", diff --git a/es2panda/scripts/generate_js_bytecode.py b/es2panda/scripts/generate_js_bytecode.py index 6b49bf2adf73284d8f83c0b4adb2da1f4f007584..e9a70fa69c2e298299ea541a34b1342ea7ccb3ea 100755 --- a/es2panda/scripts/generate_js_bytecode.py +++ b/es2panda/scripts/generate_js_bytecode.py @@ -32,6 +32,8 @@ def parse_args(): help='the converted target file') parser.add_argument('--frontend-tool-path', help='path of the frontend conversion tool') + parser.add_argument('--extension', + help='source file extension') parser.add_argument("--debug", action='store_true', help='whether add debuginfo') parser.add_argument("--module", action='store_true', @@ -46,6 +48,10 @@ def parse_args(): help='dump symbol table of base abc') parser.add_argument("--input-symbol-table", help='input symbol table for patch abc') + parser.add_argument("--type-extractor", action='store_true', + help='enable type extractor') + parser.add_argument("--type-dts-builtin", action='store_true', + help='enable builtin type extractor') arguments = parser.parse_args() return arguments @@ -64,6 +70,8 @@ def gen_abc_info(input_arguments): '--output', input_arguments.dst_file, input_arguments.src_js] + if input_arguments.extension: + cmd += ['--extension', input_arguments.extension] if input_arguments.dump_symbol_table: cmd += ['--dump-symbol-table', input_arguments.dump_symbol_table] if input_arguments.input_symbol_table: @@ -84,6 +92,12 @@ def gen_abc_info(input_arguments): src_index = cmd.index(input_arguments.src_js) cmd.insert(src_index, '--generate-patch') # insert d.ts option to cmd later + if input_arguments.type_extractor: + src_index = cmd.index(input_arguments.src_js) + cmd.insert(src_index, '--type-extractor') + if input_arguments.type_dts_builtin: + src_index = cmd.index(input_arguments.src_js) + cmd.insert(src_index, '--type-dts-builtin') run_command(cmd, path) diff --git a/es2panda/test/type_extractor/testcases/test-class-with-static-field-expected.txt b/es2panda/test/type_extractor/testcases/test-class-with-static-field-expected.txt index 324e1a3d9a0be8ab4fea142da4ecfad1bf9cf976..5cfe6a866e7c48fb720aa0ab543e17ed70661e14 100644 --- a/es2panda/test/type_extractor/testcases/test-class-with-static-field-expected.txt +++ b/es2panda/test/type_extractor/testcases/test-class-with-static-field-expected.txt @@ -6,6 +6,28 @@ slot _-1 tag: 0 val: 2 }, +{ + index: 1 + tag: 2 + val: -2 +}, +{ + index: 2 + tag: 0 + val: 24 +}, +{ + index: 3 + tag: 24 + val: _2 +}, +------------------------------------ +slot _-2 +{ + index: 0 + tag: 0 + val: 2 +}, { index: 1 tag: 2 @@ -31,7 +53,7 @@ slot _0 { index: 1 tag: 2 - val: 1 + val: 2 }, { index: 2 @@ -46,10 +68,20 @@ slot _0 { index: 4 tag: 0 - val: 2 + val: 24 }, { index: 5 + tag: 24 + val: _2 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 tag: 2 val: 0 }, @@ -217,6 +249,28 @@ slot _1 }, ------------------------------------ slot _2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 2 +}, +{ + index: 2 + tag: 0 + val: 24 +}, +{ + index: 3 + tag: 24 + val: _1 +}, +------------------------------------ +slot _3 { index: 0 tag: 2 @@ -248,7 +302,7 @@ slot _2 val: 0 }, ------------------------------------ -slot _3 +slot _4 { index: 0 tag: 0