diff --git a/README.md b/README.md index 4571032896fb92dc1bbd7944c7838f594243e06e..49c418f4a55670e6ae41add3406aa33f15690640 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 b1cc5b1be2e0765130c128fe14197280446f13d5..159c76a436e13b259c98bc896cf2cdfbcd3cb385 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 d52468b8ba7cd7079206fc79c9a9d522945e9b50..c513b1a965b4fce0883458916b35b442158f53bd 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 7b0022cc470a6447e45857f9b7488959a4bbe983..2e707f4da08360709e3ab9fdeabef1a0b8cf02c1 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 5a6262ab074d98b5537c35bb88a6ef8a284a21b4..06a754567d7dd3416306d6c9703f956e17ad38a3 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 7c8eadc4fb71d4e2a6daf837c3a54fcaef76c200..3ffcf7c96f369abc2145d457a4063b8899a51622 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 6957bb25ad05947e43d4503c80a7686b21cb95a6..3412291c9dfae66f603737a3f758348a72823b06 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 78ba52777b699b893141768cfdd42aa7d2f4ba58..ed38d57f9980f592e7387d8c8f3a85dfe60ee60a 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") diff --git a/ts2panda/src/scope.ts b/ts2panda/src/scope.ts index 62874900fb82b1c64c9b531dcca212830f8de46f..24e7ebb4689801e9859e3e29c7567321025b4613 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