From 6c1da0da4675f51374f012b498202d4094b47f9d Mon Sep 17 00:00:00 2001 From: gavin1012_hw Date: Tue, 9 Aug 2022 11:06:27 +0800 Subject: [PATCH] Update the Information description for ets_frontend Issue: I5LDNO Signed-off-by: gavin1012_hw Change-Id: I60ea1a396afc2cc9d37b3d42843f2b5c637c145c --- README.md | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++- README_zh.md | 168 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 335 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 20dd9bce71..0c894ee386 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,17 @@ For more information, see: [ARK Runtime Subsystem](https://gitee.com/openharmony /arkcompiler/ets_frontend/ ├── test262 # scripts for configuration and running Test262 ├── testTs # system test cases +├── es2panda + ├── aot # logical entry + ├── binder # info binding + ├── compiler # compiling logic + ├── ir # Bytecode generation + ├── lexer # lexical analysis + ├── parser # syntax parsing, AST generation + ├── scripts # script directory + ├── test # test directory + ├── typescript # typescript support + └── util # tool directory ├── ts2panda ├── scripts # dependency scripts ├── src # source code directory @@ -31,14 +42,169 @@ For more information, see: [ARK Runtime Subsystem](https://gitee.com/openharmony ## Build -ets_frontend uses the command line interaction mode and converts JS code into ARK bytecode files that can be run on an ARK runtime system. ets_frontend 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. +ets_frontend uses the command line interaction mode and converts JS code into ARK bytecode files that can be run on an ARK runtime system. ets_frontend supports Windows, Linux, and macOS. Front-end tools, converting JS source code into ARK bytecode, can be built by specifying the `--build-target` with `ets_frontend_build` on Linux. ``` -$ ./build.sh --product-name hispark_taurus_standard --build-target ark_ts2abc_build +$ ./build.sh --product-name hispark_taurus_standard --build-target ets_frontend_build ``` ### Usage Guidelines +#### Usage For Es2panda #### + +convert JS to ARK bytecode via es2abc + +``` +$ cd out/hispark_taurus/clang_x64/ark/ark/ +$ ./es2abc [options] file.js +``` + +If no parameter is specified for **\[options\]**, an ARK binary file is generated by default. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Option

+

Description

+

Value Range

+

Default Value

+

--debug-info

+

Provides debug information.

+

-

+

-

+

--debugger-evaluate-expression

+

Evaluates base64 style expression in debugger

+

-

+

-

+

--dump-assembly

+

Outputs an assembly file.

+

-

+

-

+

--dump-ast

+

Prints the parsed AST(Abstract Syntax Tree)

+

-

+

-

+

--dump-debug-info

+

Prints debug Info

+

-

+

-

+

--dump-literal-buffer

+

Prints the content of literal buffer

+

-

+

-

+

--dump-size-stat

+

Displays statistics about bytecodes.

+

-

+

-

+

--extension

+

Specifies input file type

+

['js', 'ts', 'as']

+

-

+

--help

+

Displays help information.

+

-

+

-

+

--module

+

Compiles the code based on the ecmascript standard module.

+

-

+

-

+

--opt-level

+

Specifies the level for compilation optimization.

+

['0', '1', '2']

+

0

+

--output

+

+Specifies the path of the output file.

+

-

+

-

+

--parse-only

+

Parse the input file only

+

-

+

-

+

--thread

+

Specifies the number of threads used to generate bytecode

+

0-Number of threads supported by your machine

+

0

+
+ +#### Usage For Ts2panda #### + Install `node` and `npm` convert JS to ARK bytecode diff --git a/README_zh.md b/README_zh.md index 37d31bd7e5..5966da7972 100644 --- a/README_zh.md +++ b/README_zh.md @@ -19,6 +19,17 @@ ets_frontend组件是方舟运行时子系统的前端工具,支持将JavaScri /arkcompiler/ets_frontend/ ├── test262 # test262测试配置和运行脚本 ├── testTs # 系统测试目录 +├── es2panda + ├── aot # 逻辑入口 + ├── binder # 信息绑定 + ├── compiler # 编译逻辑 + ├── ir # 字节码生成 + ├── lexer # 词法分析 + ├── parser # 语法解析,ast生成 + ├── scripts # 脚本目录 + ├── test # 测试目录 + ├── typescript # typescript支持 + └── util # 工具目录 ├── ts2panda ├── doc # 文档 ├── scripts # 依赖的脚本 @@ -34,11 +45,166 @@ ets_frontend组件是方舟运行时子系统的前端工具,支持将JavaScri ets_frontend组件采用命令行交互方式,支持将JavaScript代码转换为方舟字节码文件,使其能够在方舟运行时上运行。支持Windows/Linux/MacOS平台。方舟前端工具在linux平台上可通过全量编译或指定编译前端工具链获取。 ``` -$ ./build.sh --product-name hispark_taurus_standard --build-target ark_ts2abc_build +$ ./build.sh --product-name hispark_taurus_standard --build-target ets_frontend_build ``` ### 使用说明 +#### es2panda使用方式 #### + +使用ets_frontend组件下的es2abc可执行文件将JavaScript文件转换为方舟字节码文件 + +``` +$ cd out/hispark_taurus/clang_x64/ark/ark/ +$ ./es2abc [options] file.js +``` + +当不输入任何option参数时,默认生成方舟二进制文件。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

选项

+

描述

+

取值范围

+

默认值

+

--debug-info

+

携带debug信息

+

-

+

-

+

--debugger-evaluate-expression

+

debugger下对输入的base64形式的表达式求值

+

-

+

-

+

--dump-assembly

+

输出为汇编文件

+

-

+

-

+

--dump-ast

+

打印解析得到的ast(抽象语法树)

+

-

+

-

+

--dump-debug-info

+

打印debug信息

+

-

+

-

+

--dump-literal-buffer

+

打印literal buffer内容

+

-

+

-

+

--dump-size-stat

+

显示字节码相关的统计信息

+

-

+

-

+

--extension

+

指定输入类型

+

['js', 'ts', 'as']

+

-

+

--help

+

帮助提示

+

-

+

-

+

--module

+

按照ESM模式编译

+

-

+

-

+

--opt-level

+

指定编译优化等级

+

['0', '1', '2']

+

0

+

--output

+

+输出文件路径

+

-

+

-

+

--parse-only

+

只对输入文件做解析动作

+

-

+

-

+

--thread

+

指定生成字节码时所用的线程数目

+

0-机器支持的线程数目

+

0

+
+ +#### ts2panda使用方式 #### + 安装`node`和`npm` 使用ets_frontend组件将JavaScript文件转换为方舟字节码文件 -- Gitee