From f6a194dba7f35391b70aa7d54cb57e8d9fd99dec Mon Sep 17 00:00:00 2001 From: wangjunlin Date: Thu, 24 Mar 2022 12:00:43 +0800 Subject: [PATCH 1/9] String concatenation Signed-off-by: wangjunlin Change-Id: Ibdd3912f5da8a7bcebd74d7fb57eec84e3b67a1c --- ts2panda/scripts/generate_plugin.py | 2 +- ts2panda/scripts/run_tests.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ts2panda/scripts/generate_plugin.py b/ts2panda/scripts/generate_plugin.py index 61a7c365a4..e9e44432f1 100755 --- a/ts2panda/scripts/generate_plugin.py +++ b/ts2panda/scripts/generate_plugin.py @@ -144,7 +144,7 @@ def gen_java_method(input_arguments): buf = bytearray(os.path.getsize(js_bin_file)) input_bin.readinto(buf) hex_str = [hex(i) for i in buf] - byte_str = ["(byte)" + i for i in hex_str] + byte_str = ["(byte){}".format(i) for i in hex_str] seperate_array = split_array_by_n(byte_str, ARRAY_MAX) # generate separate methods for js bytecode with ARRAY_MAX diff --git a/ts2panda/scripts/run_tests.py b/ts2panda/scripts/run_tests.py index 8e25749fad..78ba52777b 100755 --- a/ts2panda/scripts/run_tests.py +++ b/ts2panda/scripts/run_tests.py @@ -115,7 +115,7 @@ class Ts2abcTests(): 'tests/tsconfig.mac.json'] ret = run_command(cmd, self.dist_dir) if ret: - raise RuntimeError("Run [" + " ".join(cmd) + "] failed !") + raise RuntimeError("Run [{}] failed !".format(" ".join(cmd))) def run_tests(self): os.chdir(self.dist_dir) @@ -144,9 +144,9 @@ class Ts2abcTests(): cmd = [mocha, f'build-mac/{tests_args}'] ret = run_command(cmd, self.dist_dir) if ret: - raise RuntimeError("Run [" + " ".join(cmd) + "] failed !") + raise RuntimeError("Run [{}] failed !".format(" ".join(cmd))) else: - print("Run [" + " ".join(cmd) + "] success!") + print("Run [{}] success!".format(" ".join(cmd))) print("used: %.5f seconds" % (time.time() - start_time)) -- Gitee From 2e5f67e0494e3847e04e3663ee90cb3a4754c32f Mon Sep 17 00:00:00 2001 From: wangjunlin Date: Thu, 24 Mar 2022 12:16:54 +0800 Subject: [PATCH 2/9] Misspelled words Signed-off-by: wangjunlin Change-Id: I3901788a27e80538a3f03dae70f9c2528c4eaff5 --- ts2panda/scripts/generate_plugin.py | 4 ++-- ts2panda/src/compiler.ts | 12 ++++++------ ts2panda/ts2abc_config.gni | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ts2panda/scripts/generate_plugin.py b/ts2panda/scripts/generate_plugin.py index e9e44432f1..9f2f3a1c6f 100755 --- a/ts2panda/scripts/generate_plugin.py +++ b/ts2panda/scripts/generate_plugin.py @@ -145,12 +145,12 @@ def gen_java_method(input_arguments): input_bin.readinto(buf) hex_str = [hex(i) for i in buf] byte_str = ["(byte){}".format(i) for i in hex_str] - seperate_array = split_array_by_n(byte_str, ARRAY_MAX) + separate_array = split_array_by_n(byte_str, ARRAY_MAX) # generate separate methods for js bytecode with ARRAY_MAX method_idx = 0 method_len_list = [] - for array in seperate_array: + for array in separate_array: output.write(" private static byte[] getJsByteCode_%s() {%s" % (method_idx, os.linesep)) output.write(" return new byte[] {") diff --git a/ts2panda/src/compiler.ts b/ts2panda/src/compiler.ts index 98225b6250..7d64549e99 100644 --- a/ts2panda/src/compiler.ts +++ b/ts2panda/src/compiler.ts @@ -18,8 +18,8 @@ * The compiler traverses TypeScript's AST, splits operations into sinmple ones * and asks Pandagen to generate bytecode. * - * This file shold not contain import from irnodes.ts. - * The interface of PandaGen shold be enough. + * This file should not contain import from irnodes.ts. + * The interface of PandaGen should be enough. */ import * as ts from "typescript"; @@ -203,7 +203,7 @@ export class Compiler { count++; } } - // acutal parameters + // actual parameters for (let i = 3; i < this.pandaGen.getLocals().length; i++) { tempLocals.push(this.pandaGen.getLocals()[i]); } @@ -610,7 +610,7 @@ export class Compiler { this.pandaGen.label(stmt, blockEndLabel); } - // because the scope of the label is just in labeled statment, we need to delete it. + // because the scope of the label is just in labeled statement, we need to delete it. LabelTarget.deleteName2LabelTarget(labelName); this.popScope(); } @@ -1192,9 +1192,9 @@ export class Compiler { // left -> acc -> lhs this.compileExpression(expr.left); pandaGen.storeAccumulator(expr, lhs); - // eqaulity comparasion between lhs and null, if true, load right + // equality comparasion between lhs and null, if true, load right pandaGen.condition(expr, ts.SyntaxKind.ExclamationEqualsEqualsToken, getVregisterCache(pandaGen, CacheList.Null), leftNullishLabel); - // eqaulity comparasion between lhs and undefined, if true, load right + // equality comparasion between lhs and undefined, if true, load right pandaGen.loadAccumulator(expr.left, lhs); pandaGen.condition(expr, ts.SyntaxKind.ExclamationEqualsEqualsToken, getVregisterCache(pandaGen, CacheList.undefined), leftNullishLabel); // lhs is either null or undefined, load left diff --git a/ts2panda/ts2abc_config.gni b/ts2panda/ts2abc_config.gni index 9a1db65616..9cd6af7ce3 100755 --- a/ts2panda/ts2abc_config.gni +++ b/ts2panda/ts2abc_config.gni @@ -62,7 +62,7 @@ if (host_toolchain == buildtool_mac) { # plugin_name -- name of js file, ex: BatteryPlugin.js # generat_file -- name of generated file # package_name -- name of generated file's package -# extra_dependencies -- a list of files that should be considered as dependencies, must be lable +# extra_dependencies -- a list of files that should be considered as dependencies, must be label # out_puts template("ts2abc_gen_file") { assert(defined(invoker.plugin_path), "plugin_path is required!") -- Gitee From 3718d0f255effb5b9c733eab357cefc6cffce3dd Mon Sep 17 00:00:00 2001 From: wangjunlin Date: Thu, 24 Mar 2022 12:20:29 +0800 Subject: [PATCH 3/9] Modifying file Permissions Signed-off-by: wangjunlin Change-Id: I0ec5ee912c7b4335013d406ecac2dcd07d795a22 --- test262/es2015_tests.txt | 0 test262/es5_tests.txt | 0 test262/skip_tests.json | 0 ts2panda/README.md | 0 ts2panda/scripts/diagnosticMessages.json | 0 ts2panda/src/tsconfig.json | 0 ts2panda/src/tsconfig.mac.json | 0 ts2panda/src/tsconfig.win.json | 0 ts2panda/tests/tsconfig.json | 0 ts2panda/tools/tsconfig.json | 0 ts2panda/ts2abc/CMakeLists.txt | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 test262/es2015_tests.txt mode change 100755 => 100644 test262/es5_tests.txt mode change 100755 => 100644 test262/skip_tests.json mode change 100755 => 100644 ts2panda/README.md mode change 100755 => 100644 ts2panda/scripts/diagnosticMessages.json mode change 100755 => 100644 ts2panda/src/tsconfig.json mode change 100755 => 100644 ts2panda/src/tsconfig.mac.json mode change 100755 => 100644 ts2panda/src/tsconfig.win.json mode change 100755 => 100644 ts2panda/tests/tsconfig.json mode change 100755 => 100644 ts2panda/tools/tsconfig.json mode change 100755 => 100644 ts2panda/ts2abc/CMakeLists.txt diff --git a/test262/es2015_tests.txt b/test262/es2015_tests.txt old mode 100755 new mode 100644 diff --git a/test262/es5_tests.txt b/test262/es5_tests.txt old mode 100755 new mode 100644 diff --git a/test262/skip_tests.json b/test262/skip_tests.json old mode 100755 new mode 100644 diff --git a/ts2panda/README.md b/ts2panda/README.md old mode 100755 new mode 100644 diff --git a/ts2panda/scripts/diagnosticMessages.json b/ts2panda/scripts/diagnosticMessages.json old mode 100755 new mode 100644 diff --git a/ts2panda/src/tsconfig.json b/ts2panda/src/tsconfig.json old mode 100755 new mode 100644 diff --git a/ts2panda/src/tsconfig.mac.json b/ts2panda/src/tsconfig.mac.json old mode 100755 new mode 100644 diff --git a/ts2panda/src/tsconfig.win.json b/ts2panda/src/tsconfig.win.json old mode 100755 new mode 100644 diff --git a/ts2panda/tests/tsconfig.json b/ts2panda/tests/tsconfig.json old mode 100755 new mode 100644 diff --git a/ts2panda/tools/tsconfig.json b/ts2panda/tools/tsconfig.json old mode 100755 new mode 100644 diff --git a/ts2panda/ts2abc/CMakeLists.txt b/ts2panda/ts2abc/CMakeLists.txt old mode 100755 new mode 100644 -- Gitee From d2d937f50a90373c947fa6da63037246332a7b39 Mon Sep 17 00:00:00 2001 From: wangjunlin Date: Thu, 24 Mar 2022 16:05:35 +0800 Subject: [PATCH 4/9] Code specification modification Signed-off-by: wangjunlin Change-Id: I8315ad664613ffb4924f3c16b61b6d128a841e86 --- testTs/run_testTs.py | 6 ++---- ts2panda/scripts/generate_plugin.py | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/testTs/run_testTs.py b/testTs/run_testTs.py index 921e9824df..8980e37d20 100644 --- a/testTs/run_testTs.py +++ b/testTs/run_testTs.py @@ -48,14 +48,12 @@ def parse_args(): def skip(filepath, flag=False): with open(SKIP_FILE_PATH, 'r') as f: content = f.read() - test_list = [] - import_list = [] skip_test = json.loads(content) skip_test_list = skip_test['error.txt'] + skip_test['no2015'] + skip_test['tsc_error'] + \ skip_test['import_skip'] + \ skip_test['code_rule'] + skip_test['no_case'] if os.path.isfile(filepath): - if '.ts' in filepath: + if filepath.endswith('.ts'): if filepath not in skip_test_list: return True else: @@ -67,7 +65,7 @@ def skip(filepath, flag=False): def abc_judge(filepath): if not os.path.getsize(filepath): - print(f'Error : {filepath} 文件为空') + print(f'Error : {filepath}.The file is empty') def run_test(file, tool, flag=False): diff --git a/ts2panda/scripts/generate_plugin.py b/ts2panda/scripts/generate_plugin.py index 9f2f3a1c6f..7b3e660db2 100755 --- a/ts2panda/scripts/generate_plugin.py +++ b/ts2panda/scripts/generate_plugin.py @@ -20,6 +20,7 @@ Description: Generate interface to get java plugin's js code and binary import os import subprocess import argparse +import stat JAVA_FILE_SUFFIX = "JsCode" JS_BIN_EXT = ".abc" @@ -92,7 +93,10 @@ def gen_java_method(input_arguments): (out_dir, _) = os.path.split(input_arguments.generated_file) js_bin_file = os.path.join(out_dir, file_name_pre + JS_BIN_EXT) - with open(out_file, "w") as output: + flags = os.O_WRONLY | os.O_CREAT | os.EXCL + modes = stat.S_IWUSR | stat.S_IRUSR + + with (os.fdopen(out_file, flags, modes), "w") as output: output.write("/*%s * Generated from Java and JavaScript plugins by ts2abc.%s */%s%s" % (os.linesep, os.linesep, os.linesep, os.linesep)) -- Gitee From d0a6d764d2c56c66f9589b22bc1e5dc75a14fbea Mon Sep 17 00:00:00 2001 From: wangjunlin Date: Thu, 24 Mar 2022 16:17:01 +0800 Subject: [PATCH 5/9] Version statement changes Signed-off-by: wangjunlin Change-Id: If20e50e04c3d51fc99807d63bd7accd731eea352 --- OAT.xml | 1 - ts2panda/src/assemblyDumper.ts | 2 +- ts2panda/src/cmdOptions.ts | 2 +- ts2panda/tests/hoist.test.ts | 2 +- ts2panda/tests/regAllocator.test.ts | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/OAT.xml b/OAT.xml index 9a4623d36b..1578ebfe3e 100644 --- a/OAT.xml +++ b/OAT.xml @@ -1,6 +1,5 @@