From bbc8808256a7df35b1009ff388fa81c318aa81d0 Mon Sep 17 00:00:00 2001 From: shawn_hu_ls Date: Mon, 3 Apr 2023 22:59:31 +0800 Subject: [PATCH] Add type extractor parameters for typeinfer test suite Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I6SNJU?from=project-issue Signed-off-by: shawn_hu_ls --- es2panda/es2abc_config.gni | 7 +++ es2panda/scripts/generate_js_bytecode.py | 14 +++++ .../test-class-with-static-field-expected.txt | 60 ++++++++++++++++++- 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/es2panda/es2abc_config.gni b/es2panda/es2abc_config.gni index 6a14c16732..5ef8a79ab5 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 6b49bf2adf..e9a70fa69c 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 324e1a3d9a..5cfe6a866e 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 -- Gitee