From 1818726f4ead4c483e5047a10b3ffa223508504c Mon Sep 17 00:00:00 2001 From: hufeng Date: Tue, 31 May 2022 15:01:46 +0800 Subject: [PATCH 1/2] fixed d9aa9bc from https://gitee.com/hufeng20/ark_ts2abc/pulls/282 Fix add globalVariable with moduleScope Signed-off-by: hufeng Change-Id: I03b4aab8c709ef85055592082aba0f986f30bebc --- ts2panda/src/scope.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/ts2panda/src/scope.ts b/ts2panda/src/scope.ts index 62874900fb..24e7ebb468 100644 --- a/ts2panda/src/scope.ts +++ b/ts2panda/src/scope.ts @@ -491,13 +491,8 @@ export class FunctionScope extends VariableScope { if (declKind == VarDeclarationKind.NONE) { // the variable declared without anything should be global // See EcmaStandard: 13.3.2 Variable Statement - let globalScope = this.getRootScope(); - if (globalScope instanceof GlobalScope) { - v = globalScope.add(name, declKind); - } else { - v = undefined; - throw new Error("Error: global variable must be defined in global scope"); - } + let topLevelScope = this.getRootScope(); + v = topLevelScope.add(name, declKind); } else if (declKind == VarDeclarationKind.VAR || declKind == VarDeclarationKind.FUNCTION) { v = new LocalVariable(declKind, name); this.name2variable.set(name, v); @@ -527,14 +522,8 @@ export class LocalScope extends Scope { LOGD(this.debugTag, "localscope.add (" + name + "), kind:" + declKind); if (declKind == VarDeclarationKind.NONE) { - let root = this.getRootScope(); - - if (root instanceof GlobalScope) { - return root.add(name, declKind, status); - } else { - LOGE(undefined, "Error: the root of this scope is not global scope, it is wrong"); - return undefined; - } + let topLevelScope = this.getRootScope(); + v = topLevelScope.add(name, declKind); } else if (declKind == VarDeclarationKind.VAR) { /** * the variable declared without anything should be accessible -- Gitee From 362b8ef20d046d8f7c1afa9ae6bde8af88b36a1e Mon Sep 17 00:00:00 2001 From: hufeng Date: Tue, 31 May 2022 14:51:03 +0800 Subject: [PATCH 2/2] fixed 718ee89 from https://gitee.com/hufeng20/ark_ts2abc/pulls/282 Revise readme & config Signed-off-by: hufeng Change-Id: I4094e5b2cd00d0139a57ba00cab27666fe8f55d2 --- README.md | 4 ++-- README_zh.md | 4 ++-- test262/README.md | 2 +- test262/config.py | 6 +++--- testTs/README.md | 4 ++-- testTs/README_zh.md | 4 ++-- testTs/config.py | 2 +- ts2panda/scripts/run_tests.py | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4571032896..49c418f4a5 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ For more information, see: [ARK Runtime Subsystem](https://gitee.com/openharmony ts2abc uses the command line interaction mode and converts JS code into ARK bytecode files that can be run on an ARK runtime system. ts2abc supports Windows, Linux, and macOS. Front-end tools, converting JS source code into ARK bytecode, can be built by specifying the `--build-target` with `ark_ts2abc` on Linux. ``` -$ ./build.sh --product-name Hi3516DV300 --build-target ark_ts2abc_build +$ ./build.sh --product-name hispark_taurus_standard --build-target ark_ts2abc_build ``` ### Usage Guidelines @@ -44,7 +44,7 @@ Install `node` and `npm` convert JS to ARK bytecode ``` -$ cd out//hi3516dv300/clang_x64/ark/ark/build +$ cd out/hispark_taurus/clang_x64/ark/ark/build $ npm install $ node --expose-gc src/index.js [options] file.js ``` diff --git a/README_zh.md b/README_zh.md index b1cc5b1be2..159c76a436 100644 --- a/README_zh.md +++ b/README_zh.md @@ -34,7 +34,7 @@ ts2abc组件是方舟运行时子系统的前端工具,支持将JavaScript文 ts2abc组件采用命令行交互方式,支持将JavaScript代码转换为方舟字节码文件,使其能够在方舟运行时上运行。支持Windows/Linux/MacOS平台。方舟前端工具在linux平台上可通过全量编译或指定编译前端工具链获取。 ``` -$ ./build.sh --product-name Hi3516DV300 --build-target ark_ts2abc_build +$ ./build.sh --product-name hispark_taurus_standard --build-target ark_ts2abc_build ``` ### 使用说明 @@ -44,7 +44,7 @@ $ ./build.sh --product-name Hi3516DV300 --build-target ark_ts2abc_build 使用ts2abc组件将JavaScript文件转换为方舟字节码文件 ``` -$ cd out/hi3516dv300/clang_x64/ark/ark/build +$ cd out/hispark_taurus/clang_x64/ark/ark/build $ npm install $ node --expose-gc src/index.js [options] file.js ``` diff --git a/test262/README.md b/test262/README.md index d52468b8ba..c513b1a965 100644 --- a/test262/README.md +++ b/test262/README.md @@ -7,7 +7,7 @@ skip_tests.json: This file contains a list of use cases that do not meet the req ## 1. Compile ts2abc and ark_js_vm project ``` -./build.sh --product-name Hi3516DV300 --build-target ark_js_vm --build-target ark_ts2abc_build +./build.sh --product-name hispark_taurus_standard --build-target ark_js_vm --build-target ark_ts2abc_build ``` ## 2 Run test cases diff --git a/test262/config.py b/test262/config.py index 7b0022cc47..2e707f4da0 100755 --- a/test262/config.py +++ b/test262/config.py @@ -30,10 +30,10 @@ BASE_OUT_DIR = os.path.join("out", "test262") CUR_FILE_DIR = os.path.dirname(__file__) CODE_ROOT = os.path.abspath(os.path.join(CUR_FILE_DIR, "../../..")) -ARK_DIR = f"{CODE_ROOT}/out/hi3516dv300/clang_x64/ark/ark" -ICUI_DIR = f"{CODE_ROOT}/out/hi3516dv300/clang_x64/global/i18n_standard" +ARK_DIR = f"{CODE_ROOT}/out/hispark_taurus/clang_x64/ark/ark" +ICUI_DIR = f"{CODE_ROOT}/out/hispark_taurus/clang_x64/thirdparty/icu" LLVM_DIR = f"{CODE_ROOT}/prebuilts/clang/ohos/linux-x86_64/llvm/lib/" -ARK_JS_RUNTIME_DIR = f"{CODE_ROOT}/out/hi3516dv300/clang_x64/ark/ark_js_runtime" +ARK_JS_RUNTIME_DIR = f"{CODE_ROOT}/out/hispark_taurus/clang_x64/ark/ark_js_runtime" DEFAULT_MODE = 2 diff --git a/testTs/README.md b/testTs/README.md index 5a6262ab07..06a754567d 100644 --- a/testTs/README.md +++ b/testTs/README.md @@ -5,8 +5,8 @@ 2. import_tests.json:Is the path to the TS code file where import files are stored to add import files. ### Environment to prepare -1. Compile TS2ABC warehouse in hongmeng system code root directory. Delete the out directory and run the './build.sh --product-name Hi3516DV300 --build-target ark_ts2abc' command. -2. Go to the tool build directory 'cd out/hi3516DV300/clang_x64/ark/ark/build' in the out file and run the 'npm install' command to set up the environment +1. Compile TS2ABC warehouse in hongmeng system code root directory. Delete the out directory and run the './build.sh --product-name hispark_taurus_standard --build-target ark_ts2abc' command. +2. Go to the tool build directory 'cd out/hispark_taurus/clang_x64/ark/ark/build' in the out file and run the 'npm install' command to set up the environment 3. After setting up the environment, enter the ark/ts2abc directory of Hongmeng system ### Execute test framework diff --git a/testTs/README_zh.md b/testTs/README_zh.md index 7c8eadc4fb..3ffcf7c96f 100644 --- a/testTs/README_zh.md +++ b/testTs/README_zh.md @@ -5,8 +5,8 @@ 2.import_tests.json:存放import的ts代码文件路径,对import类型文件进行添加。
### 环境准备 -1.在鸿蒙系统代码根目录下编译ts2abc仓。先删除out目录,然后执行./build.sh --product-name Hi3516DV300 --build-target ark_ts2abc命令进行编译。
-2.进入out文件中的工具build目录 cd out/hi3516dv300/clang_x64/ark/ark/build,使用npm install命令进行环境搭建
+1.在鸿蒙系统代码根目录下编译ts2abc仓。先删除out目录,然后执行./build.sh --product-name hispark_taurus_standard --build-target ark_ts2abc命令进行编译。
+2.进入out文件中的工具build目录 cd out/hispark_taurus/clang_x64/ark/ark/build,使用npm install命令进行环境搭建
3.搭建完环境,进入到鸿蒙系统ark/ts2abc目录下
diff --git a/testTs/config.py b/testTs/config.py index 6957bb25ad..3412291c9d 100644 --- a/testTs/config.py +++ b/testTs/config.py @@ -33,7 +33,7 @@ SKIP_FILE_PATH = os.path.join("testTs", "skip_tests.json") IMPORT_FILE_PATH = os.path.join("testTs", "import_tests.json") CUR_FILE_DIR = os.path.dirname(__file__) CODE_ROOT = os.path.abspath(os.path.join(CUR_FILE_DIR, "../../..")) -ARK_DIR = f"{CODE_ROOT}/out/hi3516dv300/clang_x64/ark/ark" +ARK_DIR = f"{CODE_ROOT}/out/hispark_taurus/clang_x64/ark/ark" WORK_PATH = f'{CODE_ROOT}/ark/ts2abc' DEFAULT_ARK_FRONTEND_TOOL = os.path.join(ARK_DIR, "build", "src", "index.js") diff --git a/ts2panda/scripts/run_tests.py b/ts2panda/scripts/run_tests.py index 78ba52777b..ed38d57f99 100755 --- a/ts2panda/scripts/run_tests.py +++ b/ts2panda/scripts/run_tests.py @@ -27,7 +27,7 @@ CUR_FILE_DIR = os.path.dirname(__file__) TS2PANDA_DIR = os.path.abspath(os.path.join(CUR_FILE_DIR, "..")) CODE_ROOT = os.path.abspath(os.path.join(TS2PANDA_DIR, "../../..")) DEFAULT_TARGET_DIR = os.path.join( - CODE_ROOT, "out/hi3516dv300/clang_x64/obj/ark/ts2abc/ts2panda") + CODE_ROOT, "out/hispark_taurus/clang_x64/obj/ark/ts2abc/ts2panda") DEFAULT_NODE_MODULE = os.path.join( CODE_ROOT, "prebuilts/build-tools/common/ts2abc/node_modules") -- Gitee