From e8873124c141dbdbb4cf1ef1c02ba8fc5ababb88 Mon Sep 17 00:00:00 2001 From: yuanbo Date: Wed, 2 Jun 2021 14:39:47 +0800 Subject: [PATCH 1/3] add new hc-gen implement Signed-off-by: yuanbo --- tools/hc-gen/CMakeLists.txt | 24 + tools/hc-gen/Makefile | 86 +- tools/hc-gen/bin/hc-gen | Bin 80360 -> 0 bytes tools/hc-gen/build_hcs.py | 72 ++ tools/hc-gen/src/ast.cpp | 1029 +++++++++++++++++ tools/hc-gen/src/ast.h | 440 +++++++ tools/hc-gen/src/bytecode_gen.cpp | 324 ++++++ tools/hc-gen/src/bytecode_gen.h | 83 ++ tools/hc-gen/src/decompile.cpp | 333 ++++++ tools/hc-gen/src/decompile.h | 79 ++ tools/hc-gen/src/decompile_gen.cpp | 187 +++ tools/hc-gen/src/decompile_gen.h | 50 + tools/hc-gen/src/file.cpp | 71 ++ tools/hc-gen/src/file.h | 27 + tools/hc-gen/src/generator.h | 32 + tools/hc-gen/src/lexer.cpp | 381 ++++++ tools/hc-gen/src/lexer.h | 82 ++ tools/hc-gen/src/logger.h | 120 ++ tools/hc-gen/src/main.cpp | 58 + tools/hc-gen/src/opcode.h | 43 + tools/hc-gen/src/option.cpp | 228 ++++ tools/hc-gen/src/option.h | 87 ++ tools/hc-gen/src/parser.cpp | 409 +++++++ tools/hc-gen/src/parser.h | 63 + tools/hc-gen/src/text_gen.cpp | 735 ++++++++++++ tools/hc-gen/src/text_gen.h | 122 ++ tools/hc-gen/src/token.cpp | 69 ++ tools/hc-gen/src/token.h | 52 + tools/hc-gen/src/types.h | 44 + tools/hc-gen/test/01_empty_file_ei/case.hcs | 0 .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + tools/hc-gen/test/02_empty_root_ei/case.hcs | 3 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + tools/hc-gen/test/03_empty_node/case.hcs | 6 + tools/hc-gen/test/03_empty_node/golden.c.gen | 16 + tools/hc-gen/test/03_empty_node/golden.d.hcs | 9 + tools/hc-gen/test/03_empty_node/golden.h.gen | 20 + tools/hc-gen/test/03_empty_node/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/04_number_term/case.hcs | 9 + tools/hc-gen/test/04_number_term/golden.c.gen | 20 + tools/hc-gen/test/04_number_term/golden.d.hcs | 13 + tools/hc-gen/test/04_number_term/golden.h.gen | 22 + tools/hc-gen/test/04_number_term/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/05_string_term/case.hcs | 4 + tools/hc-gen/test/05_string_term/golden.c.gen | 15 + tools/hc-gen/test/05_string_term/golden.d.hcs | 8 + tools/hc-gen/test/05_string_term/golden.h.gen | 17 + tools/hc-gen/test/05_string_term/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/06_number_array/case.hcs | 4 + .../hc-gen/test/06_number_array/golden.c.gen | 15 + .../hc-gen/test/06_number_array/golden.d.hcs | 8 + .../hc-gen/test/06_number_array/golden.h.gen | 17 + tools/hc-gen/test/06_number_array/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/07_string_array/case.hcs | 4 + .../hc-gen/test/07_string_array/golden.c.gen | 15 + .../hc-gen/test/07_string_array/golden.d.hcs | 8 + .../hc-gen/test/07_string_array/golden.h.gen | 17 + tools/hc-gen/test/07_string_array/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/08_term_ref/case.hcs | 12 + tools/hc-gen/test/08_term_ref/golden.c.gen | 22 + tools/hc-gen/test/08_term_ref/golden.d.hcs | 15 + tools/hc-gen/test/08_term_ref/golden.h.gen | 28 + tools/hc-gen/test/08_term_ref/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/09_node_nested/case.hcs | 11 + tools/hc-gen/test/09_node_nested/golden.c.gen | 22 + tools/hc-gen/test/09_node_nested/golden.d.hcs | 15 + tools/hc-gen/test/09_node_nested/golden.h.gen | 30 + tools/hc-gen/test/09_node_nested/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/10_node_copy/case.hcs | 13 + tools/hc-gen/test/10_node_copy/golden.c.gen | 25 + tools/hc-gen/test/10_node_copy/golden.d.hcs | 18 + tools/hc-gen/test/10_node_copy/golden.h.gen | 31 + tools/hc-gen/test/10_node_copy/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/11_case_node_ref/case.hcs | 13 + .../hc-gen/test/11_case_node_ref/golden.c.gen | 20 + .../hc-gen/test/11_case_node_ref/golden.d.hcs | 13 + .../hc-gen/test/11_case_node_ref/golden.h.gen | 24 + tools/hc-gen/test/11_case_node_ref/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/12_include_insert/base.hcs | 8 + tools/hc-gen/test/12_include_insert/case.hcs | 11 + .../test/12_include_insert/golden.c.gen | 23 + .../test/12_include_insert/golden.d.hcs | 16 + .../test/12_include_insert/golden.h.gen | 29 + .../hc-gen/test/12_include_insert/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/13_include_modify/base.hcs | 10 + tools/hc-gen/test/13_include_modify/case.hcs | 11 + .../test/13_include_modify/golden.c.gen | 22 + .../test/13_include_modify/golden.d.hcs | 15 + .../test/13_include_modify/golden.h.gen | 28 + .../hc-gen/test/13_include_modify/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/14_include_delete/base.hcs | 11 + tools/hc-gen/test/14_include_delete/case.hcs | 11 + .../test/14_include_delete/golden.c.gen | 17 + .../test/14_include_delete/golden.d.hcs | 10 + .../test/14_include_delete/golden.h.gen | 21 + .../hc-gen/test/14_include_delete/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/15_line_comment/case.hcs | 10 + .../hc-gen/test/15_line_comment/golden.c.gen | 19 + .../hc-gen/test/15_line_comment/golden.d.hcs | 12 + .../hc-gen/test/15_line_comment/golden.h.gen | 25 + tools/hc-gen/test/15_line_comment/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/16_block_comment/case.hcs | 17 + .../hc-gen/test/16_block_comment/golden.c.gen | 19 + .../hc-gen/test/16_block_comment/golden.d.hcs | 12 + .../hc-gen/test/16_block_comment/golden.h.gen | 25 + tools/hc-gen/test/16_block_comment/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/17_broken_node_ei/case.hcs | 7 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../hc-gen/test/18_broken_string_ei/case.hcs | 6 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../hc-gen/test/19_broken_number_ei/case.hcs | 6 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + tools/hc-gen/test/20_broken_array_ei/case.hcs | 5 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../hc-gen/test/21_mix_type_array_ei/case.hcs | 4 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../hc-gen/test/22_redefine_error_ei/case.hcs | 5 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../test/23_node_ref_invalid_node_ei/case.hcs | 6 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../test/24_node_copy_invlid_node_ei/case.hcs | 6 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../test/25_term_ref_invlid_node_ei/case.hcs | 6 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../hc-gen/test/26_miss_semicolon_ei/case.hcs | 4 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../test/27_include_invalid_file_ei/case.hcs | 6 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../28_overwrite_with_diff_type_ei/case.hcs | 9 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + .../test/29_node_copy_nested_ei/case.hcs | 9 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + tools/hc-gen/test/30_include_order/base1.hcs | 7 + tools/hc-gen/test/30_include_order/base2.hcs | 6 + tools/hc-gen/test/30_include_order/case.hcs | 8 + .../hc-gen/test/30_include_order/golden.c.gen | 18 + .../hc-gen/test/30_include_order/golden.d.hcs | 11 + .../hc-gen/test/30_include_order/golden.h.gen | 22 + tools/hc-gen/test/30_include_order/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + .../test/31_node_duplicate_name/case.hcs | 12 + .../test/31_node_duplicate_name/golden.d.hcs | 15 + .../test/31_node_duplicate_name/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 4 + tools/hc-gen/test/32_large_hsl/case.hcs | 1008 ++++++++++++++++ tools/hc-gen/test/32_large_hsl/golden.c.gen | 1018 ++++++++++++++++ tools/hc-gen/test/32_large_hsl/golden.d.hcs | 1011 ++++++++++++++++ tools/hc-gen/test/32_large_hsl/golden.h.gen | 1024 ++++++++++++++++ tools/hc-gen/test/32_large_hsl/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + .../test/33_miss_module_name_ei/case.hcs | 4 + .../golden_binary_compile_result.txt | 3 + .../golden_text_compile_result.txt | 3 + tools/hc-gen/test/34_template/case.hcs | 37 + tools/hc-gen/test/34_template/golden.c.gen | 59 + tools/hc-gen/test/34_template/golden.d.hcs | 35 + tools/hc-gen/test/34_template/golden.h.gen | 48 + tools/hc-gen/test/34_template/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/35_nested_template/case.hcs | 22 + .../test/35_nested_template/golden.c.gen | 52 + .../test/35_nested_template/golden.d.hcs | 19 + .../test/35_nested_template/golden.h.gen | 29 + .../hc-gen/test/35_nested_template/golden.hcb | 1 + .../golden_binary_compile_result.txt | 2 + .../golden_text_compile_result.txt | 2 + tools/hc-gen/test/hcgen_test.py | 314 +++++ tools/hc-gen/test/update_case.py | 219 ++++ tools/leagecy/hc-gen/Makefile | 84 ++ tools/{ => leagecy}/hc-gen/README.md | 0 tools/{ => leagecy}/hc-gen/include/hcs_ast.h | 0 .../hc-gen/include/hcs_compiler.h | 0 .../hc-gen/include/hcs_decompiler.h | 0 tools/{ => leagecy}/hc-gen/include/hcs_file.h | 0 .../{ => leagecy}/hc-gen/include/hcs_gener.h | 0 tools/{ => leagecy}/hc-gen/include/hcs_log.h | 0 tools/{ => leagecy}/hc-gen/include/hcs_mem.h | 0 .../{ => leagecy}/hc-gen/include/hcs_opcode.h | 0 .../{ => leagecy}/hc-gen/include/hcs_option.h | 0 .../{ => leagecy}/hc-gen/include/hcs_parser.h | 0 .../{ => leagecy}/hc-gen/include/hcs_types.h | 0 tools/{ => leagecy}/hc-gen/src/hcs_ast.c | 0 .../hc-gen/src/hcs_bytecode_gen.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_compiler.l | 0 tools/{ => leagecy}/hc-gen/src/hcs_compiler.y | 0 .../hc-gen/src/hcs_decompile_gen.c | 0 .../{ => leagecy}/hc-gen/src/hcs_decompiler.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_file.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_hexdump.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_main.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_mem.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_middle.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_opcode.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_option.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_parser.c | 0 tools/{ => leagecy}/hc-gen/src/hcs_text_gen.c | 0 243 files changed, 11554 insertions(+), 74 deletions(-) create mode 100644 tools/hc-gen/CMakeLists.txt delete mode 100755 tools/hc-gen/bin/hc-gen create mode 100755 tools/hc-gen/build_hcs.py create mode 100644 tools/hc-gen/src/ast.cpp create mode 100644 tools/hc-gen/src/ast.h create mode 100644 tools/hc-gen/src/bytecode_gen.cpp create mode 100644 tools/hc-gen/src/bytecode_gen.h create mode 100644 tools/hc-gen/src/decompile.cpp create mode 100644 tools/hc-gen/src/decompile.h create mode 100644 tools/hc-gen/src/decompile_gen.cpp create mode 100644 tools/hc-gen/src/decompile_gen.h create mode 100644 tools/hc-gen/src/file.cpp create mode 100644 tools/hc-gen/src/file.h create mode 100644 tools/hc-gen/src/generator.h create mode 100644 tools/hc-gen/src/lexer.cpp create mode 100644 tools/hc-gen/src/lexer.h create mode 100644 tools/hc-gen/src/logger.h create mode 100644 tools/hc-gen/src/main.cpp create mode 100644 tools/hc-gen/src/opcode.h create mode 100644 tools/hc-gen/src/option.cpp create mode 100644 tools/hc-gen/src/option.h create mode 100644 tools/hc-gen/src/parser.cpp create mode 100644 tools/hc-gen/src/parser.h create mode 100644 tools/hc-gen/src/text_gen.cpp create mode 100644 tools/hc-gen/src/text_gen.h create mode 100644 tools/hc-gen/src/token.cpp create mode 100644 tools/hc-gen/src/token.h create mode 100644 tools/hc-gen/src/types.h create mode 100755 tools/hc-gen/test/01_empty_file_ei/case.hcs create mode 100644 tools/hc-gen/test/01_empty_file_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/01_empty_file_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/02_empty_root_ei/case.hcs create mode 100644 tools/hc-gen/test/02_empty_root_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/02_empty_root_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/03_empty_node/case.hcs create mode 100644 tools/hc-gen/test/03_empty_node/golden.c.gen create mode 100644 tools/hc-gen/test/03_empty_node/golden.d.hcs create mode 100644 tools/hc-gen/test/03_empty_node/golden.h.gen create mode 100644 tools/hc-gen/test/03_empty_node/golden.hcb create mode 100644 tools/hc-gen/test/03_empty_node/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/03_empty_node/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/04_number_term/case.hcs create mode 100644 tools/hc-gen/test/04_number_term/golden.c.gen create mode 100644 tools/hc-gen/test/04_number_term/golden.d.hcs create mode 100644 tools/hc-gen/test/04_number_term/golden.h.gen create mode 100644 tools/hc-gen/test/04_number_term/golden.hcb create mode 100644 tools/hc-gen/test/04_number_term/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/04_number_term/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/05_string_term/case.hcs create mode 100644 tools/hc-gen/test/05_string_term/golden.c.gen create mode 100644 tools/hc-gen/test/05_string_term/golden.d.hcs create mode 100644 tools/hc-gen/test/05_string_term/golden.h.gen create mode 100644 tools/hc-gen/test/05_string_term/golden.hcb create mode 100644 tools/hc-gen/test/05_string_term/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/05_string_term/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/06_number_array/case.hcs create mode 100644 tools/hc-gen/test/06_number_array/golden.c.gen create mode 100644 tools/hc-gen/test/06_number_array/golden.d.hcs create mode 100644 tools/hc-gen/test/06_number_array/golden.h.gen create mode 100644 tools/hc-gen/test/06_number_array/golden.hcb create mode 100644 tools/hc-gen/test/06_number_array/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/06_number_array/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/07_string_array/case.hcs create mode 100644 tools/hc-gen/test/07_string_array/golden.c.gen create mode 100644 tools/hc-gen/test/07_string_array/golden.d.hcs create mode 100644 tools/hc-gen/test/07_string_array/golden.h.gen create mode 100644 tools/hc-gen/test/07_string_array/golden.hcb create mode 100644 tools/hc-gen/test/07_string_array/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/07_string_array/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/08_term_ref/case.hcs create mode 100644 tools/hc-gen/test/08_term_ref/golden.c.gen create mode 100644 tools/hc-gen/test/08_term_ref/golden.d.hcs create mode 100644 tools/hc-gen/test/08_term_ref/golden.h.gen create mode 100644 tools/hc-gen/test/08_term_ref/golden.hcb create mode 100644 tools/hc-gen/test/08_term_ref/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/08_term_ref/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/09_node_nested/case.hcs create mode 100644 tools/hc-gen/test/09_node_nested/golden.c.gen create mode 100644 tools/hc-gen/test/09_node_nested/golden.d.hcs create mode 100644 tools/hc-gen/test/09_node_nested/golden.h.gen create mode 100644 tools/hc-gen/test/09_node_nested/golden.hcb create mode 100644 tools/hc-gen/test/09_node_nested/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/09_node_nested/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/10_node_copy/case.hcs create mode 100644 tools/hc-gen/test/10_node_copy/golden.c.gen create mode 100644 tools/hc-gen/test/10_node_copy/golden.d.hcs create mode 100644 tools/hc-gen/test/10_node_copy/golden.h.gen create mode 100644 tools/hc-gen/test/10_node_copy/golden.hcb create mode 100644 tools/hc-gen/test/10_node_copy/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/10_node_copy/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/11_case_node_ref/case.hcs create mode 100644 tools/hc-gen/test/11_case_node_ref/golden.c.gen create mode 100644 tools/hc-gen/test/11_case_node_ref/golden.d.hcs create mode 100644 tools/hc-gen/test/11_case_node_ref/golden.h.gen create mode 100644 tools/hc-gen/test/11_case_node_ref/golden.hcb create mode 100644 tools/hc-gen/test/11_case_node_ref/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/11_case_node_ref/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/12_include_insert/base.hcs create mode 100755 tools/hc-gen/test/12_include_insert/case.hcs create mode 100644 tools/hc-gen/test/12_include_insert/golden.c.gen create mode 100644 tools/hc-gen/test/12_include_insert/golden.d.hcs create mode 100644 tools/hc-gen/test/12_include_insert/golden.h.gen create mode 100644 tools/hc-gen/test/12_include_insert/golden.hcb create mode 100644 tools/hc-gen/test/12_include_insert/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/12_include_insert/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/13_include_modify/base.hcs create mode 100755 tools/hc-gen/test/13_include_modify/case.hcs create mode 100644 tools/hc-gen/test/13_include_modify/golden.c.gen create mode 100644 tools/hc-gen/test/13_include_modify/golden.d.hcs create mode 100644 tools/hc-gen/test/13_include_modify/golden.h.gen create mode 100644 tools/hc-gen/test/13_include_modify/golden.hcb create mode 100644 tools/hc-gen/test/13_include_modify/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/13_include_modify/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/14_include_delete/base.hcs create mode 100755 tools/hc-gen/test/14_include_delete/case.hcs create mode 100644 tools/hc-gen/test/14_include_delete/golden.c.gen create mode 100644 tools/hc-gen/test/14_include_delete/golden.d.hcs create mode 100644 tools/hc-gen/test/14_include_delete/golden.h.gen create mode 100644 tools/hc-gen/test/14_include_delete/golden.hcb create mode 100644 tools/hc-gen/test/14_include_delete/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/14_include_delete/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/15_line_comment/case.hcs create mode 100644 tools/hc-gen/test/15_line_comment/golden.c.gen create mode 100644 tools/hc-gen/test/15_line_comment/golden.d.hcs create mode 100644 tools/hc-gen/test/15_line_comment/golden.h.gen create mode 100644 tools/hc-gen/test/15_line_comment/golden.hcb create mode 100644 tools/hc-gen/test/15_line_comment/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/15_line_comment/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/16_block_comment/case.hcs create mode 100644 tools/hc-gen/test/16_block_comment/golden.c.gen create mode 100644 tools/hc-gen/test/16_block_comment/golden.d.hcs create mode 100644 tools/hc-gen/test/16_block_comment/golden.h.gen create mode 100644 tools/hc-gen/test/16_block_comment/golden.hcb create mode 100644 tools/hc-gen/test/16_block_comment/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/16_block_comment/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/17_broken_node_ei/case.hcs create mode 100644 tools/hc-gen/test/17_broken_node_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/17_broken_node_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/18_broken_string_ei/case.hcs create mode 100644 tools/hc-gen/test/18_broken_string_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/18_broken_string_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/19_broken_number_ei/case.hcs create mode 100644 tools/hc-gen/test/19_broken_number_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/19_broken_number_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/20_broken_array_ei/case.hcs create mode 100644 tools/hc-gen/test/20_broken_array_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/20_broken_array_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/21_mix_type_array_ei/case.hcs create mode 100644 tools/hc-gen/test/21_mix_type_array_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/21_mix_type_array_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/22_redefine_error_ei/case.hcs create mode 100644 tools/hc-gen/test/22_redefine_error_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/22_redefine_error_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/23_node_ref_invalid_node_ei/case.hcs create mode 100644 tools/hc-gen/test/23_node_ref_invalid_node_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/23_node_ref_invalid_node_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/24_node_copy_invlid_node_ei/case.hcs create mode 100644 tools/hc-gen/test/24_node_copy_invlid_node_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/24_node_copy_invlid_node_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/25_term_ref_invlid_node_ei/case.hcs create mode 100644 tools/hc-gen/test/25_term_ref_invlid_node_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/25_term_ref_invlid_node_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/26_miss_semicolon_ei/case.hcs create mode 100644 tools/hc-gen/test/26_miss_semicolon_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/26_miss_semicolon_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/27_include_invalid_file_ei/case.hcs create mode 100644 tools/hc-gen/test/27_include_invalid_file_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/27_include_invalid_file_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/28_overwrite_with_diff_type_ei/case.hcs create mode 100644 tools/hc-gen/test/28_overwrite_with_diff_type_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/28_overwrite_with_diff_type_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/29_node_copy_nested_ei/case.hcs create mode 100644 tools/hc-gen/test/29_node_copy_nested_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/29_node_copy_nested_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/30_include_order/base1.hcs create mode 100755 tools/hc-gen/test/30_include_order/base2.hcs create mode 100755 tools/hc-gen/test/30_include_order/case.hcs create mode 100644 tools/hc-gen/test/30_include_order/golden.c.gen create mode 100644 tools/hc-gen/test/30_include_order/golden.d.hcs create mode 100644 tools/hc-gen/test/30_include_order/golden.h.gen create mode 100644 tools/hc-gen/test/30_include_order/golden.hcb create mode 100644 tools/hc-gen/test/30_include_order/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/30_include_order/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/31_node_duplicate_name/case.hcs create mode 100644 tools/hc-gen/test/31_node_duplicate_name/golden.d.hcs create mode 100644 tools/hc-gen/test/31_node_duplicate_name/golden.hcb create mode 100644 tools/hc-gen/test/31_node_duplicate_name/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/31_node_duplicate_name/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/32_large_hsl/case.hcs create mode 100644 tools/hc-gen/test/32_large_hsl/golden.c.gen create mode 100644 tools/hc-gen/test/32_large_hsl/golden.d.hcs create mode 100644 tools/hc-gen/test/32_large_hsl/golden.h.gen create mode 100644 tools/hc-gen/test/32_large_hsl/golden.hcb create mode 100644 tools/hc-gen/test/32_large_hsl/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/32_large_hsl/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/33_miss_module_name_ei/case.hcs create mode 100644 tools/hc-gen/test/33_miss_module_name_ei/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/33_miss_module_name_ei/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/34_template/case.hcs create mode 100644 tools/hc-gen/test/34_template/golden.c.gen create mode 100644 tools/hc-gen/test/34_template/golden.d.hcs create mode 100644 tools/hc-gen/test/34_template/golden.h.gen create mode 100644 tools/hc-gen/test/34_template/golden.hcb create mode 100644 tools/hc-gen/test/34_template/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/34_template/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/35_nested_template/case.hcs create mode 100644 tools/hc-gen/test/35_nested_template/golden.c.gen create mode 100644 tools/hc-gen/test/35_nested_template/golden.d.hcs create mode 100644 tools/hc-gen/test/35_nested_template/golden.h.gen create mode 100644 tools/hc-gen/test/35_nested_template/golden.hcb create mode 100644 tools/hc-gen/test/35_nested_template/golden_binary_compile_result.txt create mode 100644 tools/hc-gen/test/35_nested_template/golden_text_compile_result.txt create mode 100755 tools/hc-gen/test/hcgen_test.py create mode 100755 tools/hc-gen/test/update_case.py create mode 100644 tools/leagecy/hc-gen/Makefile rename tools/{ => leagecy}/hc-gen/README.md (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_ast.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_compiler.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_decompiler.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_file.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_gener.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_log.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_mem.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_opcode.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_option.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_parser.h (100%) rename tools/{ => leagecy}/hc-gen/include/hcs_types.h (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_ast.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_bytecode_gen.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_compiler.l (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_compiler.y (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_decompile_gen.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_decompiler.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_file.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_hexdump.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_main.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_mem.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_middle.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_opcode.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_option.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_parser.c (100%) rename tools/{ => leagecy}/hc-gen/src/hcs_text_gen.c (100%) diff --git a/tools/hc-gen/CMakeLists.txt b/tools/hc-gen/CMakeLists.txt new file mode 100644 index 000000000..1075c8cfe --- /dev/null +++ b/tools/hc-gen/CMakeLists.txt @@ -0,0 +1,24 @@ +project(hc-gen) +cmake_minimum_required(VERSION 3.10) + +set(CMAKE_CXX_STANDARD 14) + +set(CMAKE_CXX_FLAGS "-Wall") + +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + add_definitions(-D OS_LINUX) +elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") + add_definitions(-D OS_WIN) + add_definitions(-D MINGW32) +endif (CMAKE_SYSTEM_NAME MATCHES "Linux") + +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") + +if(CMAKE_BUILD_TYPE MATCHES Asan) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address") +endif() + +aux_source_directory(src SOURCES) + +add_executable(hc-gen ${SOURCES}) \ No newline at end of file diff --git a/tools/hc-gen/Makefile b/tools/hc-gen/Makefile index 9dcdfae00..dbfb95d53 100644 --- a/tools/hc-gen/Makefile +++ b/tools/hc-gen/Makefile @@ -1,84 +1,22 @@ -# Copyright (c) 2020-2021 Huawei Device Co., Ltd. -# -# HDF is dual licensed: you can use it either under the terms of -# the GPL, or the BSD license, at your option. -# See the LICENSE file in the root of this repository for complete details. - -TARGET := hc-gen -YACC_LEX_PREFIX :=HcsCompiler -C_FLAGS := -std=gnu99 -Wall -Werror -Wno-attributes -Wall -CC := gcc -YACC := bison -LEX := flex Q = @ +BUILD_DIR := build +TARGET := hc-gen -BOUNDS_CHECK_LIB := $(abspath ../../../../third_party/bounds_checking_function/) -INCLUDE_DIR := ./include $(BOUNDS_CHECK_LIB)/include -OUT_DIR := build - -TEST_CASE := $(abspath ../../../adapter/lite/khdf/test/tools/hc-gen/test/unittest) - -ORIGIN_SOURCES := $(wildcard src/*) -ORIGIN_SOURCES += $(wildcard $(BOUNDS_CHECK_LIB)/src/*) - -C_SOURCES := $(filter %.c,$(ORIGIN_SOURCES)) -YACC_SOURCES := $(filter %.y,$(ORIGIN_SOURCES)) -LEX_SOURCES := $(filter %.l,$(ORIGIN_SOURCES)) -YACC_GEN_SOURCES := $(patsubst %.y,$(OUT_DIR)/%_tab.c,$(YACC_SOURCES)) -LEX_GEN_SOURCES := $(patsubst %.l,$(OUT_DIR)/%_lex.c,$(LEX_SOURCES)) - -C_OBJECTS := $(patsubst %.c,$(OUT_DIR)/%.o,$(C_SOURCES)) -GEN_OBJECTS += $(patsubst %.c,%.o,$(YACC_GEN_SOURCES) $(LEX_GEN_SOURCES)) -OBJECTS := $(GEN_OBJECTS) $(C_OBJECTS) - -C_FLAGS += $(addprefix -I,$(INCLUDE_DIR)) -INCLUDE_DIR += $(OUT_DIR) - -UNAME := $(shell uname -a) -ifneq ($(findstring Linux,$(UNAME)),) - C_FLAGS += -D OS_LINUX -else - C_FLAGS += -D OS_WIN - C_FLAGS += -D MINGW32 -endif - -ifeq ($(BUILD_TYPE),debug) - C_FLAGS += -g -else ifeq ($(BUILD_TYPE),asan) - C_FLAGS += -g -fsanitize=address -else - # release - C_FLAGS += -O2 -s -ffunction-sections -fdata-sections -Wl,--gc-sections -endif all: $(TARGET) -$(YACC_GEN_SOURCES) : $(OUT_DIR)/%_tab.c : %.y - $(Q)mkdir -p $(dir $(@)) - $(Q)$(YACC) -o $@ -v -d -pHcsCompiler $< - -$(LEX_GEN_SOURCES) : $(OUT_DIR)/%_lex.c : %.l | $(YACC_GEN_SOURCES) - $(Q)mkdir -p $(dir $(@)) - $(Q)$(LEX) -o $@ -PHcsCompiler $< - -$(C_OBJECTS) : $(OUT_DIR)/%.o : %.c - $(Q)mkdir -p $(dir $(@)) - $(Q)$(CC) -c -o $@ $(C_FLAGS) $^ - -$(GEN_OBJECTS) : %.o : %.c - $(Q)$(CC) -c -o $@ $(C_FLAGS) $^ - -$(TARGET) : $(OBJECTS) | $(GEN_OBJECTS) - $(Q)$(CC) -o $@ $(C_FLAGS) $^ +$(TARGET): + $(Q)mkdir -p $(BUILD_DIR) + $(Q)pushd $(BUILD_DIR); cmake ../; popd + $(Q)make -C $(BUILD_DIR) -test: all - python3 $(TEST_CASE)/hcgen_test.py $(TARGET) +test: $(TARGET) + $(Q) python test/hcgen_test.py $(BUILD_DIR)/$(TARGET) -test_update: all - python3 $(TEST_CASE)/update_case.py $(TARGET) +update_testcase: $(TARGET) + $(Q) python test/update_case.py $(BUILD_DIR)/$(TARGET) clean: - $(Q)rm -rf $(OUT_DIR) - $(Q)rm -f $(TARGET) + $(Q) rm -rf $(BUILD_DIR) -.PHONY: clean all test test_update +.PHONY: all clean test $(TARGET) \ No newline at end of file diff --git a/tools/hc-gen/bin/hc-gen b/tools/hc-gen/bin/hc-gen deleted file mode 100755 index a759c47705c7acf92e7cc4111cd42104253c7546..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 80360 zcmbrn4SWdljd9ZiYIm38&oG$Jg3d?(6J3!Pk=fJpS|W zvY!oZG4GiVuKZf?pOov9E2;l}c6Pwj;rzVX<>_}}zxAjob}+rC&lk{W0u^4LJJrd5 z?$mA??mY`z>7;LTq4V_0342m*?&(gsxu-kjyyy20*ylaH_DS31zmabHvY!>?$ZgYKSPMdn=Ila!D zHnGRFsn~9bFH-9FCek=3YBft+s<+t!3JOVrgoxpF@y!Z(8XCHx1-y`6Ee+2y6BfvvP zf**l?@e%O1906`00siF?;608|@3BXKe|Q8scOL=&<|E+GKLY;vBjBHY1b8cyH$YzY z?_~hLr6%@C{k; zLg)y-@2uwdU0nRlF23i_T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YLv6;`?|!>h>nvBTT&=Yzr<+U_xOtboS{ zg*WYpH2g21#AWCI`0SgM&+*w-K>r{CG?j1c=N+6vnG-`PmmS{Or;CT39VfKYc197_ N>Hp4&bcDCj{~vd%TnzvK diff --git a/tools/hc-gen/build_hcs.py b/tools/hc-gen/build_hcs.py new file mode 100755 index 000000000..721a96c9c --- /dev/null +++ b/tools/hc-gen/build_hcs.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# +# Copyright (c) 2021, Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Willow Garage, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import os +import sys +import argparse +import platform +import subprocess +import time + + +def exec_command(cmd): + process = subprocess.Popen(cmd) + process.wait() + ret_code = process.returncode + + if ret_code != 0: + raise Exception("{} failed, return code is {}".format(cmd, ret_code)) + + +def make_hc_gen(current_dir): + exec_command(['make', '-C', current_dir]) + + +def prepare(hc_gen, current_dir): + if not os.path.exists(hc_gen): + make_hc_gen(current_dir) + + +def main(argv): + current_dir = os.path.split(os.path.realpath(__file__))[0] + hc_gen = os.path.join(current_dir, 'build', 'hc-gen') + + build_hcs_cmd = [hc_gen] + argv[1:] + + prepare(hc_gen, current_dir) + exec_command(build_hcs_cmd) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) + diff --git a/tools/hc-gen/src/ast.cpp b/tools/hc-gen/src/ast.cpp new file mode 100644 index 000000000..d9f6b8b56 --- /dev/null +++ b/tools/hc-gen/src/ast.cpp @@ -0,0 +1,1029 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include +#include +#include +#include "ast.h" +#include "logger.h" + +using namespace OHOS::Hardware; + +AstObject::AstObject(AstObject &obj) : + AstObject(obj.name_, obj.type_, obj.stringValue_) +{ + integerValue_ = obj.integerValue_; +} + +AstObject::AstObject(std::string name, uint32_t type, uint64_t value) : + type_(type), + name_(std::move(name)), + parent_(nullptr), + lineno_(0), + opCode_(0), + size_(0), + subSize_(0), + hash_(0), + integerValue_(value) +{ +} + +AstObject::AstObject(std::string name, uint32_t type, std::string value) : AstObject(std::move(name), type, 0) +{ + stringValue_ = std::move(value); +} + +AstObject::AstObject(std::string name, uint32_t type, uint64_t value, const Token &bindToken) : + AstObject(std::move(name), type, value) +{ + lineno_ = bindToken.lineNo; + src_ = bindToken.src; + + switch (type) { + case PARSEROP_UINT8: /* fall-through */ + case PARSEROP_UINT16: /* fall-through */ + case PARSEROP_UINT32: /* fall-through */ + case PARSEROP_UINT64: + this->type_ = FitIntegerValueType(value); + break; + default: + break; + } +} + +AstObject::AstObject(std::string name, uint32_t type, std::string value, const Token &bindToken) : + AstObject(std::move(name), type, 0, bindToken) +{ + stringValue_ = std::move(value); +} + +AstObject::~AstObject() +{ + parent_ = nullptr; + next_ = nullptr; + child_ = nullptr; +} + +uint32_t AstObject::FitIntegerValueType(uint64_t value) +{ + if (value <= UINT8_MAX) { + return PARSEROP_UINT8; + } else if (value <= UINT16_MAX) { + return PARSEROP_UINT16; + } else if (value <= UINT32_MAX) { + return PARSEROP_UINT32; + } else { + return PARSEROP_UINT64; + } +} + +bool AstObject::AddChild(const std::shared_ptr &childObj) +{ + if (childObj == nullptr) { + return false; + } + if (child_ == nullptr) { + child_ = childObj; + std::shared_ptr childNext = childObj; + while (childNext != nullptr) { + childNext->parent_ = this; + childNext = childNext->next_; + } + } else { + return child_->AddPeer(childObj); + } + + return true; +} + +bool AstObject::AddPeer(std::shared_ptr peerObject) +{ + if (peerObject == nullptr) { + return false; + } + + if (this == peerObject.get()) { + Logger().Error() << "add self as peer"; + return false; + } + + if (next_ == nullptr) { + next_ = peerObject; + } else { + std::shared_ptr lastNode = next_; + while (lastNode->next_ != nullptr) { + lastNode = lastNode->next_; + } + lastNode->next_ = peerObject; + } + + std::shared_ptr peer = peerObject; + while (peer) { + peer->parent_ = parent_; + peer = peer->next_; + } + + return true; +} + +std::ostream &OHOS::Hardware::operator<<(std::ostream &stream, const AstObject &t) +{ + if (t.type_ == PARSEROP_CONFNODE) { + auto node = static_cast(&t); + stream << *node; + return stream; + } else if (t.type_ == PARSEROP_CONFTERM) { + auto term = static_cast(&t); + stream << *term; + return stream; + } + + if (t.name_.empty()) { + stream << "|_"; + } else { + stream << t.name_; + } + switch (t.type_) { + case PARSEROP_UINT8: + stream << "uint8 " << "0x" << std::hex << t.integerValue_; + break; + case PARSEROP_UINT16: + stream << "uint16 " << "0x" << std::hex << t.integerValue_; + break; + case PARSEROP_UINT32: + stream << "uint32 " << "0x" << std::hex << t.integerValue_; + break; + case PARSEROP_UINT64: + stream << "uint64 " << "0x" << std::hex << t.integerValue_; + break; + case PARSEROP_STRING: + stream << "string " << "\"" << t.stringValue_ << "\""; + break; + case PARSEROP_ARRAY: + stream << "array"; + break; + case PARSEROP_NODEREF: + stream << "noderef " << t.stringValue_; + break; + case PARSEROP_DELETE: + stream << "delete"; + break; + default: + break; + } + return stream; +} + +bool AstObject::Merge(std::shared_ptr &srcObj) +{ + if (srcObj->name_ != name_) { + Logger().Error() << this->SourceInfo() << "merge different node to" << srcObj->SourceInfo(); + return false; + } + + if (srcObj->type_ != type_) { + Logger().Error() << this->SourceInfo() << "conflict type with " << srcObj->SourceInfo(); + return false; + } + + src_ = srcObj->src_; + lineno_ = srcObj->lineno_; + stringValue_ = srcObj->stringValue_; + integerValue_ = srcObj->integerValue_; + + return true; +} + +bool AstObject::Copy(std::shared_ptr src, bool overwrite) +{ + if (src == nullptr) { + return false; + } + + if (overwrite) { + src_ = src->src_; + lineno_ = src->lineno_; + integerValue_ = src->integerValue_; + stringValue_ = src->stringValue_; + } + + return true; +} + +bool AstObject::Move(std::shared_ptr src) +{ + if (!Copy(src, true)) { + return false; + } + src->Separate(); + return true; +} + +std::string AstObject::SourceInfo() +{ + std::stringstream o; + o << src_->c_str() << ":" << lineno_ << " "; + return o.str(); +} + +void AstObject::Remove() +{ + Separate(); + child_ = nullptr; + next_ = nullptr; +} + +std::shared_ptr AstObject::Lookup(const std::string &name, uint32_t type) const +{ + auto peer = child_; + while (peer != nullptr) { + if (peer->name_ == name && (type == 0 || peer->type_ == type)) { + return peer; + } + + peer = peer->next_; + } + + return nullptr; +} + +bool AstObject::IsNumber() const +{ + return type_ >= PARSEROP_UINT8 && type_ <= PARSEROP_UINT64;; +} + +bool AstObject::IsNode() const +{ + return type_ == PARSEROP_CONFNODE; +} + +bool AstObject::IsTerm() const +{ + return type_ == PARSEROP_CONFTERM; +} + +bool AstObject::IsArray() const +{ + return type_ == PARSEROP_ARRAY; +} + +void AstObject::Separate() +{ + if (parent_ == nullptr) { + return; + } + if (parent_->child_.get() == this) { + parent_->child_ = next_; // decref this + next_ = nullptr; + return; + } + + auto pre = parent_->child_; + while (pre != nullptr) { + if (pre->next_.get() == this) { + pre->next_ = pre->next_->next_; // decref this + break; + } + + pre = pre->next_; + } + next_ = nullptr; +} + +void AstObject::SetParent(AstObject *parent) +{ + parent_ = parent; +} + +void AstObject::SetSize(uint32_t size) +{ + size_ = size; +} + +void AstObject::SetSubSize(uint32_t size) +{ + subSize_ = size; +} + +uint32_t AstObject::GetSubSize() +{ + return subSize_; +} + +void AstObject::SetHash(uint32_t hash) +{ + hash_ = hash; +} + +uint32_t AstObject::GetSize() +{ + return size_; +} + +uint32_t AstObject::GetHash() +{ + return hash_; +} + +std::shared_ptr AstObject::Next() +{ + return next_; +} + +std::shared_ptr AstObject::Child() +{ + return child_; +} + +const std::string &AstObject::Name() +{ + return name_; +} + +const std::string &AstObject::StringValue() +{ + return stringValue_; +} + +uint64_t AstObject::IntegerValue() +{ + return integerValue_; +} + +uint32_t AstObject::Type() +{ + return type_; +} + +uint8_t AstObject::OpCode() +{ + return opCode_; +} + +void AstObject::SetOpCode(uint8_t opcode) +{ + opCode_ = opcode; +} + +bool AstObject::HasDuplicateChild() +{ + return false; +} + +bool AstObject::IsElders(const std::shared_ptr &child) +{ + auto p = child.get(); + while (p != nullptr) { + if (p == this) { + return true; + } + p = p->parent_; + } + return false; +} + +std::shared_ptr AstObject::Parent() +{ + return std::shared_ptr(parent_, [](auto p) {}); +} + +ConfigNode::ConfigNode(ConfigNode &node) : ConfigNode(node.name_, node.nodeType_, node.refNodePath_) +{ + auto child = node.child_; + while (child != nullptr) { + AstObject::AddChild(AstObjectFactory::Build(child)); + child = child->Next(); + } +} + +ConfigNode::ConfigNode(std::string name, uint32_t nodeType, std::string refName) : + AstObject(std::move(name), PARSEROP_CONFNODE, ""), + refNodePath_(std::move(refName)), + nodeType_(nodeType), + inheritIndex_(0), + inheritCount_(0), + templateSignNum_(0) +{ + +} + +ConfigNode::ConfigNode(Token &name, uint32_t nodeType, std::string refName) : + AstObject(name.strval, PARSEROP_CONFNODE, 0, name), + refNodePath_(std::move(refName)), + nodeType_(nodeType), + inheritIndex_(0), + inheritCount_(0), + templateSignNum_(0) +{ +} + +const std::string &ConfigNode::NodeTypeToStr(uint32_t type) +{ + static std::map type2StringMap = { + {NODE_NOREF, ""}, + {NODE_COPY, "NodeCopy"}, + {NODE_REF, "NodeReference"}, + {NODE_DELETE, "NodeDelete"}, + {NODE_INHERIT, "NodeInherit"}, + {NODE_TEMPLATE, "NodeTemplate"}, + }; + return type2StringMap[type]; +} + +std::ostream &OHOS::Hardware::operator<<(std::ostream &stream, const ConfigNode &t) +{ + stream << "[node] " << t.name_.data() << " " << ConfigNode::NodeTypeToStr(t.nodeType_).data() << " " + << t.refNodePath_.data(); + return stream; +} + +ConfigNode *ConfigNode::CastFrom(const std::shared_ptr &astObject) +{ + return dynamic_cast(astObject.get()); +} + +uint32_t ConfigNode::GetNodeType() const +{ + return nodeType_; +} + +const std::string &ConfigNode::GetRefPath() +{ + return refNodePath_; +} + +bool ConfigNode::Merge(std::shared_ptr &srcObj) +{ + if (srcObj == nullptr) { + return true; + } + if (!srcObj->IsNode() || srcObj->Name() != name_) { + Logger().Error() << SourceInfo() << "merge conflict type with " << srcObj->SourceInfo(); + return false; + } + + auto srcNode = ConfigNode::CastFrom(srcObj); + if (srcNode->GetNodeType() == DELETE) { + srcObj->Separate(); + this->Separate(); + return true; + } + + nodeType_ = srcNode->nodeType_; + refNodePath_ = srcNode->refNodePath_; + + auto childSrc = srcObj->Child(); + while (childSrc != nullptr) { + auto childSrcNext = childSrc->Next(); + auto childDst = Lookup(childSrc->Name(), childSrc->Type()); + if (childDst == nullptr) { + childSrc->Separate(); + AddChild(childSrc); + } else { + if (!childDst->Merge(childSrc)) { + return false; + } + } + childSrc = childSrcNext; + } + return true; +} + +void ConfigNode::SetNodeType(uint32_t nodeType) +{ + nodeType_ = nodeType; +} + +void ConfigNode::SetRefPath(std::string ref) +{ + refNodePath_ = std::move(ref); +} + +bool ConfigNode::HasDuplicateChild() +{ + std::map> symMap; + auto child = child_; + while (child != nullptr) { + auto sym = symMap.find(child->Name()); + if (sym != symMap.end()) { + Logger().Error() << child->SourceInfo() << "redefined, first definition at " << sym->second->SourceInfo(); + return true; + } + symMap[child->Name()] = child; + child = child->Next(); + } + + return false; +} + +bool ConfigNode::InheritExpand(const std::shared_ptr &refObj) +{ + if (refObj == nullptr) { + Logger().Error() << SourceInfo() << "inherit invalid node: " << refNodePath_; + return false; + } + + if (!Copy(refObj, false)) { + return false; + } + + auto templateNode = ConfigNode::CastFrom(refObj); + if (!Compare(*templateNode)) { + return false; + } + inheritIndex_ = templateNode->inheritCount_++; + templateNode->subClasses_.push_back(this); + return true; +} + +bool ConfigNode::RefExpand(const std::shared_ptr &refObj) +{ + if (nodeType_ == NODE_DELETE) { + this->Separate(); + return true; + } + + if (refObj->IsElders(std::shared_ptr(this, [](auto p) {}))) { + Logger().Error() << SourceInfo() << "circular reference " << refObj->SourceInfo(); + return false; + } + + bool ret = true; + if (nodeType_ == NODE_REF) { + ret = NodeRefExpand(refObj); + } else if (nodeType_ == NODE_COPY) { + ret = NodeCopyExpand(refObj); + } + + return ret; +} + +bool ConfigNode::Copy(std::shared_ptr src, bool overwrite) +{ + auto child = src->Child(); + while (child != nullptr) { + auto dst = Lookup(child->Name(), child->Type()); + if (dst == nullptr) { + AddChild(AstObjectFactory::Build(child)); + } else { + if (!dst->Copy(child, overwrite)) { + return false; + } + } + child = child->Next(); + } + + return true; +} + +bool ConfigNode::Move(std::shared_ptr src) +{ + return AstObject::Move(src); +} + +bool ConfigNode::NodeRefExpand(const std::shared_ptr &ref) +{ + if (ref == nullptr) { + Logger().Error() << SourceInfo() << "reference node '" << refNodePath_ << "' not exist"; + return false; + } + return ref->Move(std::shared_ptr(this, [](AstObject *p) { (void) p; })); +} + +bool ConfigNode::NodeCopyExpand(const std::shared_ptr &ref) +{ + if (ref == nullptr) { + Logger().Error() << SourceInfo() << "copy node '" << refNodePath_ << "' not exist"; + return false; + } + this->nodeType_ = NODE_NOREF; + return Copy(ref, false); +} + +bool ConfigNode::Compare(ConfigNode &other) +{ + auto objChild = child_; + while (objChild != nullptr) { + auto baseObj = Lookup(objChild->Name(), objChild->Type()); + if (baseObj == nullptr) { + Logger().Error() << objChild->SourceInfo() << "not in template node: " << other.SourceInfo(); + return false; + } + if (objChild->IsNode()) { + return ConfigNode::CastFrom(objChild)->Compare(*ConfigNode::CastFrom(baseObj)); + } + + objChild = objChild->Next(); + } + return true; +} + +uint32_t ConfigNode::InheritIndex() +{ + return inheritIndex_; +} + +uint32_t ConfigNode::InheritCount() +{ + return inheritCount_; +} + +uint32_t ConfigNode::TemplateSignNum() +{ + return templateSignNum_; +} + +void ConfigNode::SetTemplateSignNum(uint32_t sigNum) +{ + templateSignNum_ = sigNum; +} + +const std::list &ConfigNode::SubClasses() +{ + return subClasses_; +} + +ConfigTerm::ConfigTerm(ConfigTerm &term) : ConfigTerm(term.name_, nullptr) +{ + AstObject::AddChild(AstObjectFactory::Build(term.child_)); +} + +ConfigTerm::ConfigTerm(std::string name, const std::shared_ptr &value) : + AstObject(std::move(name), PARSEROP_CONFTERM, 0), + signNum_(0) +{ + if (value != nullptr) { + child_ = value; + value->SetParent(this); + } +} + +ConfigTerm::ConfigTerm(Token &name, const std::shared_ptr &value) : + AstObject(name.strval, PARSEROP_CONFTERM, 0, name), + signNum_(0) +{ + if (value != nullptr) { + child_ = value; + value->SetParent(this); + } +} + +std::ostream &OHOS::Hardware::operator<<(std::ostream &stream, const ConfigTerm &t) +{ + stream << "[term] " << t.name_.data(); + return stream; +} + +ConfigTerm *ConfigTerm::CastFrom(const std::shared_ptr &astObject) +{ + return dynamic_cast(astObject.get()); +} + +bool ConfigTerm::Merge(std::shared_ptr &srcObj) +{ + if (!srcObj->IsTerm()) { + Logger().Error() << SourceInfo() << "merge conflict type with " << srcObj->SourceInfo(); + return false; + } + + auto value = srcObj->Child(); + srcObj->Child()->Separate(); + child_ = nullptr; + AddChild(value); + return true; +} + +bool ConfigTerm::RefExpand(std::shared_ptr refObj) +{ + if (child_->Type() == PARSEROP_DELETE) { + this->Separate(); + return true; + } + + if (child_->Type() != PARSEROP_NODEREF) { + return true; + } + + if (refObj == nullptr || !refObj->IsNode() || + ConfigNode::CastFrom(refObj)->GetNodeType() == NODE_REF || + ConfigNode::CastFrom(refObj)->GetNodeType() == NODE_TEMPLATE || + ConfigNode::CastFrom(refObj)->GetNodeType() == NODE_DELETE) { + Logger().Error() << SourceInfo() << "reference invalid node '" << child_->StringValue() << '\''; + return false; + } + + refNode_ = refObj; + return true; +} + +bool ConfigTerm::Copy(std::shared_ptr src, bool overwrite) +{ + if (!overwrite) { + return true; + } + if (child_->Type() != src->Child()->Type() && (!child_->IsNumber() || !src->Child()->IsNumber())) { + Logger().Error() << src->SourceInfo() << "overwrite different type with:" << child_->SourceInfo(); + return false; + } + return child_->Copy(src->Child(), overwrite); +} + +bool ConfigTerm::Move(std::shared_ptr src) +{ + return child_->Move(src->Child()); +} + +std::weak_ptr ConfigTerm::RefNode() +{ + return refNode_; +} + +void ConfigTerm::SetSigNum(uint32_t sigNum) +{ + signNum_ = sigNum; +} + +uint32_t ConfigTerm::SigNum() +{ + return signNum_; +} + +ConfigArray::ConfigArray() : + AstObject("", PARSEROP_ARRAY, 0), + arrayType_(0), + arraySize_(0) +{ +} + +ConfigArray::ConfigArray(ConfigArray &array) : ConfigArray() +{ + auto child = array.child_; + while (child != nullptr) { + AstObject::AddChild(AstObjectFactory::Build(child)); + child = child->Next(); + } + arraySize_ = array.arraySize_; + arrayType_ = array.arrayType_; +} + +ConfigArray::ConfigArray(const Token &bindToken) : + AstObject("", PARSEROP_ARRAY, 0, bindToken), + arrayType_(0), + arraySize_(0) +{ +}; + +bool ConfigArray::AddChild(const std::shared_ptr &childObj) +{ + if (AstObject::AddChild(childObj)) { + arraySize_++; + arrayType_ = std::max(arrayType_, childObj->Type()); + return true; + } else { + return false; + } +} + +bool ConfigArray::Merge(std::shared_ptr &srcObj) +{ + if (!srcObj->IsArray()) { + Logger().Error() << SourceInfo() << "merge conflict type with " << srcObj->SourceInfo(); + return false; + } + + auto value = srcObj->Child(); + value->Separate(); + child_ = value; + return true; +} + +bool ConfigArray::Copy(std::shared_ptr src, bool overwrite) +{ + if (!overwrite) { + return true; + } + auto array = ConfigArray::CastFrom(src); + child_ = nullptr; + auto t = array->child_; + while (t != nullptr) { + AddChild(AstObjectFactory::Build(t)); + } + return true; +} + +ConfigArray *ConfigArray::CastFrom(const std::shared_ptr &astObject) +{ + return static_cast(astObject.get()); +} + +uint16_t ConfigArray::ArraySize() +{ + return arraySize_; +} + +uint16_t ConfigArray::ArrayType() +{ + return arrayType_; +} + +std::shared_ptr AstObjectFactory::Build(std::shared_ptr object) +{ + switch (object->Type()) { + case PARSEROP_CONFNODE: + return std::shared_ptr(new ConfigNode(*ConfigNode::CastFrom(object))); + case PARSEROP_CONFTERM: + return std::shared_ptr(new ConfigTerm(*ConfigTerm::CastFrom(object))); + case PARSEROP_ARRAY: + return std::shared_ptr(new ConfigArray(*static_cast(object.get()))); + default: + return std::make_shared(*object); + } +} + +void Ast::Dump(const std::string &prefix) +{ + Logger().Debug() << "Dump " << prefix << " AST:"; + WalkForward([](const std::shared_ptr ¤t, int32_t walkDepth) -> int32_t { + Logger().Debug() << ::std::setw(walkDepth * 4) << " " << *current; + return NOERR; + }); +} + +std::shared_ptr Ast::GetAstRoot() +{ + return astRoot_; +} + +bool Ast::Merge(const std::list> &astList) +{ + if (!RedefineCheck()) { + return false; + } + for (auto &astIt : astList) { + if (!astIt->RedefineCheck()) { + return false; + } + if (astRoot_ == nullptr) { + astRoot_ = astIt->GetAstRoot(); + continue; + } + Dump("merge this"); + astIt->Dump("tobe merge"); + if (!astRoot_->Merge(astIt->astRoot_)) { + return false; + } + astIt->Dump("merged"); + } + return true; +} + +bool Ast::Expand() +{ + if (!RedefineCheck()) { + return false; + } + + if (astRoot_->Lookup("module", PARSEROP_CONFTERM) == nullptr) { + Logger().Error() << astRoot_->SourceInfo() << "miss 'module' attribute under root node"; + return false; + } + + if (!NodeExpand()) { + return false; + } + + if (!InheritExpand()) { + return false; + }; + + Dump("expanded"); + return true; +} + +bool Ast::NodeExpand() +{ + return WalkBackward([this](const std::shared_ptr ¤t, int32_t walkDepth) -> int32_t { + (void) walkDepth; + if (current->IsNode()) { + auto node = ConfigNode::CastFrom(current); + if (node->GetNodeType() == NODE_DELETE) { + current->Remove(); + return NOERR; + } + if (node->GetNodeType() != NODE_REF && node->GetNodeType() != NODE_COPY) { + return NOERR; + } + // current node maybe deleted after reference expand, never use it after this + auto ret = node->RefExpand(Lookup(current, node->GetRefPath())); + if (!ret) { + return EFAIL; + } + } else if (current->IsTerm()) { + std::shared_ptr ref; + if (current->child_->Type() == PARSEROP_DELETE) { + current->Remove(); + return NOERR; + } + if (current->child_->Type() == PARSEROP_NODEREF) { + ref = Lookup(current, current->child_->StringValue()); + if (!ConfigTerm::CastFrom(current)->RefExpand(ref)) { + return EFAIL; + } + } + } + return NOERR; + }); +} + +bool Ast::InheritExpand() +{ + return WalkForward([this](const std::shared_ptr ¤t, int32_t) -> int32_t { + if (current->IsNode()) { + auto node = ConfigNode::CastFrom(current); + if (node->GetNodeType() != NODE_INHERIT) { + return NOERR; + } + auto inherit = Lookup(current, node->GetRefPath()); + if (!node->InheritExpand(inherit)) { + return EFAIL; + } + } + + return NOERR; + }); +} + + +bool Ast::RedefineCheck() +{ + if (redefineChecked_) { + return true; + } + + bool ret = WalkForward([](const std::shared_ptr ¤t, int32_t) -> int32_t { + if (current->IsNode() && current->HasDuplicateChild()) { + return EFAIL; + } + + return NOERR; + }); + + redefineChecked_ = true; + return ret; +} + +std::shared_ptr Ast::Lookup(const std::shared_ptr &startObj, const std::string &path) +{ + if (path.find('.') == std::string::npos) { + return startObj->parent_->Lookup(path); + } + + auto splitPath = SplitNodePath(path, '.'); + if (splitPath.front() != astRoot_->name_) { + Logger().Error() << "lookup ast with invalid path, which not begin with 'root': " << path; + return nullptr; + } + splitPath.erase(splitPath.begin()); + + std::shared_ptr target = astRoot_; + std::shared_ptr child = astRoot_->Child(); + for (auto &it : splitPath) { + // look up children + target = target->Lookup(it); + if (target == nullptr) { + break; + } + } + + return target; +} + +std::list Ast::SplitNodePath(const std::string &path, char separator) +{ + std::list splitList; + std::string temp; + for (auto c : path) { + if (c != separator) { + temp.push_back(c); + } else { + if (temp.empty()) { + splitList.clear(); + break; + } + splitList.push_back(temp); + temp.clear(); + } + } + + if (temp.empty()) { + splitList.push_back(path); + } else { + splitList.push_back(temp); + } + return splitList; +} diff --git a/tools/hc-gen/src/ast.h b/tools/hc-gen/src/ast.h new file mode 100644 index 000000000..fb37bbfe1 --- /dev/null +++ b/tools/hc-gen/src/ast.h @@ -0,0 +1,440 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_AST_H +#define HC_GEN_AST_H + +#include +#include +#include +#include +#include +#include +#include "token.h" +#include "types.h" + +namespace OHOS { +namespace Hardware { +enum ObjectType { + PARSEROP_UINT8 = 0x01, + PARSEROP_UINT16, + PARSEROP_UINT32, + PARSEROP_UINT64, + PARSEROP_STRING, + PARSEROP_CONFNODE, + PARSEROP_CONFTERM, + PARSEROP_ARRAY, + PARSEROP_NODEREF, + PARSEROP_DELETE, +}; + +enum NodeRefType { + NODE_NOREF = 0, + NODE_COPY, + NODE_REF, + NODE_DELETE, + NODE_TEMPLATE, + NODE_INHERIT, +}; + +class AstObject { +public: + friend class Ast; + + AstObject(AstObject &obj); + + AstObject(std::string name, uint32_t type, uint64_t value); + + AstObject(std::string name, uint32_t type, std::string value); + + AstObject(std::string name, uint32_t type, uint64_t value, const Token &bindToken); + + AstObject(std::string name, uint32_t type, std::string value, const Token &bindToken); + + virtual ~AstObject(); + + virtual bool AddChild(const std::shared_ptr &childObj); + + virtual bool AddPeer(std::shared_ptr peerObject); + + friend std::ostream &operator<<(std::ostream &stream, const AstObject &t); + + virtual bool Merge(std::shared_ptr &srcObj); + + virtual bool Copy(std::shared_ptr src, bool overwrite); + + virtual bool Move(std::shared_ptr src); + + void Remove(); + + void Separate(); + + std::shared_ptr Lookup(const std::string &name, uint32_t type = 0) const; + + bool IsElders(const std::shared_ptr &child); + + bool IsNumber() const; + + bool IsNode() const; + + bool IsTerm() const; + + bool IsArray() const; + + virtual std::string SourceInfo(); + + void SetParent(AstObject *parent); + + void SetSize(uint32_t size); + + void SetSubSize(uint32_t size); + + void SetHash(uint32_t hash); + + uint32_t GetSize(); + + uint32_t GetSubSize(); + + uint32_t GetHash(); + + std::shared_ptr Child(); + + std::shared_ptr Next(); + + virtual const std::string &Name(); + + const std::string &StringValue(); + + uint64_t IntegerValue(); + + virtual uint32_t Type(); + + uint8_t OpCode(); + + void SetOpCode(uint8_t opcode); + + virtual bool HasDuplicateChild(); + + std::shared_ptr Parent(); + +protected: + uint32_t type_; + std::string name_; + AstObject *parent_; + std::shared_ptr next_; + std::shared_ptr child_; + uint32_t lineno_; + std::shared_ptr src_; + uint8_t opCode_; + uint32_t size_; + uint32_t subSize_; + uint32_t hash_; + uint64_t integerValue_; + std::string stringValue_; + +private: + static uint32_t FitIntegerValueType(uint64_t value); +}; + +class ConfigNode : public AstObject { +public: + ConfigNode(ConfigNode &node); + + ConfigNode(std::string name, uint32_t nodeType, std::string refName); + + ConfigNode(Token &name, uint32_t nodeType, std::string refName); + + ~ConfigNode() override = default; + + friend std::ostream &operator<<(std::ostream &stream, const ConfigNode &t); + + bool Merge(std::shared_ptr &srcObj) override; + + static ConfigNode *CastFrom(const std::shared_ptr &astObject); + + uint32_t GetNodeType() const; + + const std::string &GetRefPath(); + + void SetNodeType(uint32_t type); + + void SetRefPath(std::string ref); + + static const std::string &NodeTypeToStr(uint32_t type); + + bool HasDuplicateChild() override; + + bool InheritExpand(const std::shared_ptr &refObj); + + bool RefExpand(const std::shared_ptr &refObj); + + bool Copy(std::shared_ptr src, bool overwrite) override; + + bool Move(std::shared_ptr src) override; + + bool Compare(ConfigNode &other); + + uint32_t InheritIndex(); + + uint32_t InheritCount(); + + uint32_t TemplateSignNum(); + + void SetTemplateSignNum(uint32_t sigNum); + + const std::list &SubClasses(); + +private: + bool NodeRefExpand(const std::shared_ptr &ref); + + bool NodeCopyExpand(const std::shared_ptr &ref); + + std::string refNodePath_; + uint32_t nodeType_; + uint32_t inheritIndex_; + uint32_t inheritCount_; + uint32_t templateSignNum_; + std::list subClasses_; +}; + +class ConfigTerm : public AstObject { +public: + ConfigTerm(ConfigTerm &term); + + ConfigTerm(std::string name, const std::shared_ptr &value); + + ConfigTerm(Token &name, const std::shared_ptr &value); + + ~ConfigTerm() override = default; + + static ConfigTerm *CastFrom(const std::shared_ptr &astObject); + + bool Merge(std::shared_ptr &srcObj) override; + + friend std::ostream &operator<<(std::ostream &stream, const ConfigTerm &t); + + bool RefExpand(std::shared_ptr refObject); + + bool Copy(std::shared_ptr src, bool overwrite) override; + + bool Move(std::shared_ptr src) override; + + std::weak_ptr RefNode(); + + uint32_t SigNum(); + + void SetSigNum(uint32_t sigNum); + +private: + std::weak_ptr refNode_; + uint32_t signNum_; +}; + +class ConfigArray : public AstObject { +public: + ConfigArray(); + + ConfigArray(ConfigArray &array); + + explicit ConfigArray(const Token &bindToken); + + ~ConfigArray() override = default; + + static ConfigArray *CastFrom(const std::shared_ptr &astObject); + + bool AddChild(const std::shared_ptr &childObj) override; + + bool Merge(std::shared_ptr &srcObj) override; + + bool Copy(std::shared_ptr src, bool overwrite) override; + + uint16_t ArraySize(); + + uint16_t ArrayType(); + +private: + uint32_t arrayType_; + uint32_t arraySize_; +}; + +class AstObjectFactory { +public: + static std::shared_ptr Build(std::shared_ptr object); +}; + +class Ast { +public: + Ast() = default; + + explicit Ast(std::shared_ptr astRoot) : astRoot_(std::move(astRoot)), redefineChecked_(false) {} + + ~Ast() = default; + + std::shared_ptr GetAstRoot(); + + bool Merge(const std::list> &astList); + + bool Expand(); + + std::shared_ptr Lookup(const std::shared_ptr &startObj, const std::string &path); + + template + static bool WalkForward(const std::shared_ptr &startObject, T callback) + { + std::shared_ptr forwardWalkObj = startObject; + int32_t walkDepth = 0; + bool preVisited = false; + + while (forwardWalkObj != nullptr) { + if (!preVisited) { + int32_t ret = callback(forwardWalkObj, walkDepth); + if (ret && ret != EASTWALKBREAK) { + return false; + } else if (ret != EASTWALKBREAK && forwardWalkObj->child_ != nullptr) { + /* when callback return EASTWALKBREAK, not walk current's child */ + walkDepth++; + forwardWalkObj = forwardWalkObj->child_; + continue; + } + } + if (forwardWalkObj == startObject) { + break; + } + + if (forwardWalkObj->next_ != nullptr) { + forwardWalkObj = forwardWalkObj->next_; + preVisited = false; + } else { + forwardWalkObj = forwardWalkObj->Parent(); + preVisited = true; + walkDepth--; + } + } + + return true; + } + + template + static bool WalkBackward(const std::shared_ptr &startObject, T callback) + { + std::shared_ptr backWalkObj = startObject; + std::shared_ptr next = nullptr; + std::shared_ptr parent = nullptr; + int32_t walkDepth = 0; + bool preVisited = false; + + while (backWalkObj != nullptr) { + if (backWalkObj->child_ == nullptr || preVisited) { + next = backWalkObj->next_; + parent = backWalkObj->Parent(); + /* can safe delete current in callback */ + if (callback(backWalkObj, walkDepth) != NOERR) { + return false; + } + } else { + if (backWalkObj->child_) { + walkDepth++; + backWalkObj = backWalkObj->child_; + continue; + } + } + if (backWalkObj == startObject) { + break; + } + + if (next != nullptr) { + backWalkObj = next; + preVisited = false; + } else { + backWalkObj = parent; + preVisited = true; + walkDepth--; + } + } + + return true; + } + + template + static bool WalkRound(const std::shared_ptr &startObject, T1 forwardCallback, T2 backwardCallback) + { + std::shared_ptr roundWalkObj = startObject; + int32_t walkDepth = 0; + bool preVisited = false; + + while (roundWalkObj != nullptr) { + if (preVisited) { + if (backwardCallback(roundWalkObj, walkDepth) != NOERR) { + return false; + } + } else { + int32_t ret = forwardCallback(roundWalkObj, walkDepth); + /* when callback return EASTWALKBREAK, not walk current's child */ + if (ret && ret != EASTWALKBREAK) { + return false; + } else if (!ret && roundWalkObj->child_ != nullptr) { + walkDepth++; + roundWalkObj = roundWalkObj->child_; + continue; + } + } + if (roundWalkObj == startObject) { + break; + } + + if (roundWalkObj->next_) { + roundWalkObj = roundWalkObj->next_; + preVisited = false; + } else { + roundWalkObj = roundWalkObj->Parent(); + preVisited = true; + walkDepth--; + } + } + + return true; + } + + + template + bool WalkForward(T callback) + { + return WalkForward(astRoot_, callback); + } + + template + bool WalkBackward(T callback) + { + return WalkBackward(astRoot_, callback); + } + + template + bool WalkRound(T1 forwardCallback, T2 backwardCallback) + { + return WalkRound(astRoot_, forwardCallback, backwardCallback); + } + + void Dump(const std::string &prefix = std::string()); + +private: + bool RedefineCheck(); + + bool NodeExpand(); + + bool InheritExpand(); + + std::list SplitNodePath(const std::string &path, char separator); + + std::shared_ptr astRoot_; + bool redefineChecked_; +}; + +} // Hardware +} // OHOS + +#endif // HC_GEN_AST_H diff --git a/tools/hc-gen/src/bytecode_gen.cpp b/tools/hc-gen/src/bytecode_gen.cpp new file mode 100644 index 000000000..88e3bc2d4 --- /dev/null +++ b/tools/hc-gen/src/bytecode_gen.cpp @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "bytecode_gen.h" +#include +#include "file.h" +#include "logger.h" +#include "opcode.h" + +using namespace OHOS::Hardware; + +ByteCodeGen::ByteCodeGen(std::shared_ptr ast) : Generator(ast), + needAlign_(false) +{ +} + +bool ByteCodeGen::Output() +{ + if (!Initialize()) { + return false; + } + + if (!ByteCodeConvert()) { + return false; + } + + if (!ByteCodeWrite(true)) { + return false; + } + + if (!ByteCodeWrite(false)) { + return false; + } + + if (Option::Instance().ShouldGenHexDump()) { + return Hexdump(); + } + + return true; +} + +bool ByteCodeGen::Initialize() +{ + auto opt = Option::Instance(); + std::string outFileName = Util::File::StripSuffix(opt.GetOutputName()); + if (outFileName.empty()) { + outFileName = opt.GetSourceNameBase() + ".hcb"; + } + + if (outFileName.find(".hcb") == std::string::npos) { + outFileName.append(".hcb"); + } + + ofs_.open(outFileName, std::ofstream::out | std::ofstream::binary); + if (!ofs_.is_open()) { + Logger().Error() << "failed to open output file: " << outFileName; + return false; + } + Logger().Debug() << "output: " << outFileName; + + needAlign_ = opt.ShouldAlign(); + outFileName_ = std::move(outFileName); + return true; +} + +bool ByteCodeGen::ByteCodeConvert() +{ + return ast_->WalkBackward([this](std::shared_ptr &object, uint32_t depth) { + if (object->IsNode() && ConfigNode::CastFrom(object)->GetNodeType() == NODE_TEMPLATE) { + object->Separate(); + return NOERR; + } + auto opcode = ToOpCode(object->Type()); + if (opcode.opCode == 0) { + Logger().Error() << object->SourceInfo() << "cannot covert type " << object->Type() << " to opcode"; + return EINVALF; + } + object->SetOpCode(opcode.opCode); + CalculateSize(object); + return NOERR; + }); +} + +uint32_t ByteCodeGen::Align(uint32_t size) const +{ + return needAlign_ ? ((size + ALIGN_SIZE - 1) & (~(ALIGN_SIZE - 1))) : size; +} + +const OpCode &ByteCodeGen::ToOpCode(uint32_t objectType) +{ + static std::map byteCodeMap = { + {PARSEROP_UINT8, {HCS_BYTE_OP, BYTE_SIZE, "Uint8"}}, + {PARSEROP_UINT16, {HCS_WORD_OP, WORD_SIZE, "Uint16"}}, + {PARSEROP_UINT32, {HCS_DWORD_OP, DWORD_SIZE, "Uint32"}}, + {PARSEROP_UINT64, {HCS_QWORD_OP, QWORD_SIZE, "Uint64"}}, + {PARSEROP_STRING, {HCS_STRING_OP, 0, "String"}}, + {PARSEROP_ARRAY, {HCS_ARRAY_OP, WORD_SIZE, "Array"}}, /* ElementCount - WORD */ + {PARSEROP_CONFNODE, {HCS_NODE_OP, DWORD_SIZE, "ConfigNode"}}, /* SubSize - DWORD */ + {PARSEROP_CONFTERM, {HCS_TERM_OP, 0, "ConfigTerm"}}, + {PARSEROP_NODEREF, {HCS_NODEREF_OP, DWORD_SIZE, "NodeRef"}}, /* RefHashCode - DWORD */ + }; + return byteCodeMap[objectType]; +} + +void ByteCodeGen::Write(const std::string &data) +{ + Write(data.c_str(), static_cast(data.size() + 1)); +} + +template +void ByteCodeGen::Write(T &data) +{ + auto p = &data; + uint32_t size = sizeof(data); + auto d = reinterpret_cast(p); + Write(d, size); +} + +void ByteCodeGen::Write(const char *data, uint32_t size) +{ + FsWrite(data, size); + static char stubData[ALIGN_SIZE] = {0}; + auto alignSize = Align(size); + auto stubSize = alignSize - size; + + if (stubSize != 0) { + FsWrite(stubData, stubSize); + } + + writeSize_ += alignSize; +} + +void ByteCodeGen::CalculateSize(const std::shared_ptr &object) +{ + uint32_t size = Align(OPCODE_BYTE_WIDTH) + Align(ToOpCode(object->Type()).size); + switch (object->OpCode()) { + case HCS_NODE_OP: /* fall-through */ + case HCS_TERM_OP: + /* name string */ + size += Align(object->Name().size() + 1); // add 1 for '\0' + break; + case HCS_STRING_OP: + size += Align(object->StringValue().size() + 1); + break; + default: + break; + } + + auto child = object->Child(); + uint32_t subSize = 0; + while (child != nullptr) { + subSize += child->GetSize(); + child = child->Next(); + } + + object->SetSize(subSize + size); + object->SetSubSize(subSize); +} + +bool ByteCodeGen::ByteCodeWrite(bool dummy) +{ + dummyOutput_ = dummy; + writeSize_ = 0; + + HcbHeader header = { + .magicNumber = HCB_MAGIC_NUM, + .versionMajor = 0, + .versionMinor = 0, + .checkSum = 0, + .totalSize = static_cast(Option::Instance().ShouldAlign() ? -ast_->GetAstRoot()->GetSize() + : ast_->GetAstRoot()->GetSize()), + }; + Option::Instance().GetVersion(header.versionMinor, header.versionMajor); + Write(header); + if (WriteBad()) { + return false; + } + + return ByteCodeWriteWalk(); +} + +bool ByteCodeGen::ByteCodeWriteWalk() +{ + return ast_->WalkForward([this](std::shared_ptr ¤t, uint32_t depth) { + current->SetHash(writeSize_); + auto opcode = current->OpCode(); + Write(opcode); + switch (current->OpCode()) { + case HCS_BYTE_OP: + case HCS_WORD_OP: + case HCS_DWORD_OP: + case HCS_QWORD_OP: { + auto value = current->IntegerValue(); + Write(reinterpret_cast(&value), ToOpCode(current->Type()).size); + break; + } + case HCS_STRING_OP: + Write(current->StringValue()); + break; + case HCS_TERM_OP: + Write(current->Name()); + + break; + case HCS_NODE_OP: { + Write(current->Name()); + auto subSize = current->GetSubSize(); + Write(subSize); + break; + } + case HCS_ARRAY_OP: { + uint16_t arraySize = ConfigArray::CastFrom(current)->ArraySize(); + Write(arraySize); + break; + } + case HCS_NODEREF_OP: { + auto term = ConfigTerm::CastFrom(current->Parent()); + uint32_t hashCode = term->RefNode().lock()->GetHash(); + Write(hashCode); + break; + } + default: + break; + } + if (WriteBad()) { + return EOUTPUT; + } + return NOERR; + }); +} + +void ByteCodeGen::FsWrite(const char *data, uint32_t size) +{ + if (dummyOutput_) + return; + + ofs_.write(data, size); +} + +bool ByteCodeGen::WriteBad() +{ + if (ofs_.bad()) { + Logger().Error() << "failed to write file " << outFileName_; + return true; + } + return false; +} + +bool ByteCodeGen::HexdumpInitialize(FILE *&in, FILE *&out) +{ + ofs_.close(); + std::string hexdumpOutName = Util::File::StripSuffix(outFileName_).append("_hex.c"); + + in = fopen(outFileName_.data(), "rb"); + if (in == nullptr) { + Logger().Error() << "failed to open " << outFileName_; + return false; + } + + out = fopen(hexdumpOutName.data(), "wb"); + if (out == nullptr) { + fclose(in); + in = nullptr; + Logger().Error() << "failed to open " << hexdumpOutName; + return false; + } + return true; +} + +bool ByteCodeGen::Hexdump() +{ + FILE *in = nullptr; + FILE *out = nullptr; + if (!HexdumpInitialize(in, out)) { + return false; + } + + auto ret = HexdumpOutput(in, out); + fclose(in); + fclose(out); + + return ret; +} + +bool ByteCodeGen::HexdumpOutput(FILE *in, FILE *out) +{ + constexpr const char *HCS_HEXDUMP_ENTRY_SYMBOL = "hdfConfigEntrySymbol"; + constexpr const int PRINT_SKIP_STEP = 2; + constexpr const int NUMS_PER_LINE = 16; + std::string prefix = Option::Instance().GetSymbolPrefix(); + if (fprintf(out, "static const unsigned char g_%s%s[] = {\n", prefix.data(), HCS_HEXDUMP_ENTRY_SYMBOL) < 0) { + return false; + } + uint32_t writeCount = 0; + int32_t byte; + while ((byte = getc(in)) != EOF) { + if (fprintf(out, "%s0x%02x", (writeCount % NUMS_PER_LINE) ? ", " : &",\n "[PRINT_SKIP_STEP * !writeCount], + byte) < 0) { + return false; + } + writeCount++; + } + if (fprintf(out, "\n};\n") < 0) { + return false; + } + + if (fprintf(out, "static const unsigned int g_%sLen = %u;\n", HCS_HEXDUMP_ENTRY_SYMBOL, writeCount) < 0) { + return false; + } + if (fprintf(out, + "void HdfGetBuildInConfigData(const unsigned char** data, unsigned int* size)\n" + "{\n" + " *data = g_%s%s;\n" + " *size = g_%s%sLen;\n" + "}", + prefix.data(), HCS_HEXDUMP_ENTRY_SYMBOL, prefix.data(), HCS_HEXDUMP_ENTRY_SYMBOL) < 0) { + return false; + } + return true; +} diff --git a/tools/hc-gen/src/bytecode_gen.h b/tools/hc-gen/src/bytecode_gen.h new file mode 100644 index 000000000..638f503e1 --- /dev/null +++ b/tools/hc-gen/src/bytecode_gen.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + + +#ifndef HC_GEN_BYTECODE_GEN_H +#define HC_GEN_BYTECODE_GEN_H + +#include +#include +#include "generator.h" + +namespace OHOS { +namespace Hardware { + +struct OpCode { + OpCode() : opCode(0), + size(0) {} + + OpCode(uint8_t code, uint32_t s, std::string str) : opCode(code), + size(s), + opStr(std::move(str)) {} + + ~OpCode() = default; + + uint8_t opCode; + uint32_t size; + const std::string opStr; +}; + +class ByteCodeGen : public Generator { +public: + explicit ByteCodeGen(std::shared_ptr ast); + + ~ByteCodeGen() override = default; + + bool Output() override; + +private: + bool Initialize(); + + bool ByteCodeConvert(); + + uint32_t Align(uint32_t size) const; + + void CalculateSize(const std::shared_ptr &object); + + bool ByteCodeWrite(bool dummy); + + bool ByteCodeWriteWalk(); + + template + void Write(T &data); + + void Write(const char *data, uint32_t size); + + void Write(const std::string &data); + + void FsWrite(const char *data, uint32_t size); + + static const OpCode &ToOpCode(uint32_t objectType); + + bool WriteBad(); + + bool HexdumpInitialize(FILE *&in, FILE *&out); + + static bool HexdumpOutput(FILE *in, FILE *out); + + bool Hexdump(); + + bool needAlign_; + std::ofstream ofs_; + std::string outFileName_; + bool dummyOutput_; + uint32_t writeSize_; +}; +} // Hardware +} // OHOS +#endif // HC_GEN_BYTECODE_GEN_H diff --git a/tools/hc-gen/src/decompile.cpp b/tools/hc-gen/src/decompile.cpp new file mode 100644 index 000000000..e31089ec2 --- /dev/null +++ b/tools/hc-gen/src/decompile.cpp @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "decompile.h" +#include +#include "decompile_gen.h" +#include "logger.h" +#include "opcode.h" + +using namespace OHOS::Hardware; + +Decompile::Decompile(std::string fileName) : isAlign_(false), fileName_(std::move(fileName)) +{ +} + +bool Decompile::InitDecompileFile() +{ + file_.open(fileName_.data(), std::ios::binary); + if(!file_.is_open()) { + Logger().Error() << "Failed to open decompile file: " << fileName_; + return false; + } + return true; +} + +bool Decompile::ReadFile(char *buffer, size_t readSize) +{ + if(!file_.read(buffer, static_cast(readSize))) { + Logger().Error() << "read file failed, read size is: " << readSize; + return false; + } + return true; +} + +void Decompile::SetAlign(bool isAlign) +{ + isAlign_ = isAlign; +} + +bool Decompile::VerifyDecompileFile() +{ + HcbHeader header{0}; + if (!ReadFile(reinterpret_cast(&header), sizeof(header))) { + Logger().Error() << "read header failed"; + return false; + } + Logger().Debug() << "read Header: magic is: " << header.magicNumber << " version major: " << header.versionMajor << + " version minor: " << header.versionMinor << " checksum: " << header.checkSum << " totalSize: " << header.totalSize; + if (header.magicNumber != HCB_MAGIC_NUM) { + Logger().Error() << "magic number is: " << header.magicNumber << ", check failed!"; + return false; + } + if (header.totalSize < 0) { + SetAlign(true); + header.totalSize = -header.totalSize; + } + return true; +} + +bool Decompile::ReadUint32(uint32_t &value) +{ + return ReadFile(reinterpret_cast(&value), sizeof(uint32_t)); +} + +bool Decompile::ReadUint8(uint8_t &value) +{ + if (GetAlignSize(sizeof(uint8_t)) != sizeof(uint8_t)) { + uint32_t readValue = 0; + if (!ReadUint32(readValue)) { + return false; + } + value = static_cast(readValue); + return true; + } + return ReadFile(reinterpret_cast(&value), sizeof(uint8_t)); +} + +bool Decompile::ReadUint16(uint16_t &value) +{ + if (GetAlignSize(sizeof(uint16_t)) != sizeof(uint16_t)) { + uint32_t readValue = 0; + if (!ReadUint32(readValue)) { + return false; + } + value = static_cast(readValue); + return true; + } + return ReadFile(reinterpret_cast(&value), sizeof(uint16_t)); +} + +bool Decompile::ReadUint64(uint64_t &value) +{ + return ReadFile(reinterpret_cast(&value), sizeof(uint64_t)); +} + +bool Decompile::ReadString(std::string &value) +{ + value.clear(); + char c; + while(ReadFile(&c, sizeof(c))) { + if (c == '\0') { + break; + } + if (value.length() > NUMBER) { + return false; + } + value += c; + } + uint32_t alignSize = GetAlignSize(value.length() + 1) - (value.length() + 1); + if (alignSize > 0) { + char alignReadBuff[4]; + if (!ReadFile(alignReadBuff, alignSize)) { + return false; + } + } + return true; +} + +bool Decompile::GetNextByteCode(uint32_t &byteCode) +{ + if (GetAlignSize(OPCODE_BYTE_WIDTH) == OPCODE_BYTE_WIDTH) { + uint8_t value = 0; + bool ret = ReadUint8(value); + byteCode = value; + return ret; + } else { + return ReadUint32(byteCode); + } +} + +std::shared_ptr Decompile::RebuildNode() +{ + uint32_t nodeHash = static_cast(file_.tellg()) - GetAlignSize(OPCODE_BYTE_WIDTH); + std::string nodeName; + if (!ReadString(nodeName)) { + return nullptr; + } + + auto node = std::make_shared(nodeName, NODE_NOREF, ""); + uint32_t nodeSize = 0; + if(!ReadUint32(nodeSize)) { + return nullptr; + } + node->SetSize(nodeSize); + node->SetHash(nodeHash); + Logger().Debug() << "node name is: " << node->Name() << ", size is: " << nodeSize << ", hash is: " << nodeHash; + uint32_t pos = file_.tellg(); + uint32_t nodeEnd = pos + nodeSize; + while (pos < nodeEnd) { + uint32_t childOpCode; + if (!GetNextByteCode(childOpCode)) { + Logger().Error() << "Rebuild node failed, get next byte code failed"; + return nullptr; + } + auto child = RebuildObject(childOpCode); + if (child == nullptr) { + Logger().Error() << "Rebuild node failed, get child failed"; + return nullptr; + } + if (!node->AddChild(child)) { + Logger().Error() << "Rebuild node failed, add child failed"; + return nullptr; + } + pos = file_.tellg(); + } + return node; +} + +std::shared_ptr Decompile::RebuildTerm() +{ + std::string termName; + if (!ReadString(termName)) { + return nullptr; + } + uint32_t childOpCode; + if (!GetNextByteCode(childOpCode)) { + return nullptr; + } + auto value = RebuildObject(childOpCode); + if (value == nullptr) { + return nullptr; + } + return std::make_shared(termName, value); +} + +std::shared_ptr Decompile::RebuildNodeRefObject() +{ + uint32_t refNodeHash = 0; + if (!ReadUint32(refNodeHash)) { + return nullptr; + } + Logger().Debug() << "Ref object value is: " << refNodeHash; + return std::make_shared(std::string(), PARSEROP_NODEREF, refNodeHash); +} + +std::shared_ptr Decompile::RebuildNumberObject(uint8_t opCode) +{ + uint8_t u8Value = 0; + uint16_t u16Value = 0; + uint32_t u32Value = 0; + uint64_t u64Value = 0; + switch (opCode) { + case HCS_BYTE_OP: + if (!ReadUint8(u8Value)) { + return nullptr; + } + return std::make_shared(std::string(), PARSEROP_UINT8, u8Value); + case HCS_WORD_OP: + if (!ReadUint16(u16Value)) { + return nullptr; + } + return std::make_shared(std::string(), PARSEROP_UINT16, u16Value); + case HCS_DWORD_OP: + if (!ReadUint32(u32Value)) { + return nullptr; + } + return std::make_shared(std::string(), PARSEROP_UINT32, u32Value); + case HCS_QWORD_OP: + if (!ReadUint64(u64Value)) { + return nullptr; + } + return std::make_shared(std::string(), PARSEROP_UINT64, u64Value); + default: + return nullptr; + } +} + +std::shared_ptr Decompile::RebuildArray() +{ + uint16_t arraySize = 0; + if (!ReadUint16(arraySize)) { + return nullptr; + } + auto array = std::make_shared(std::string(), PARSEROP_ARRAY, 0); + if (array == nullptr) { + return nullptr; + } + for (uint16_t i = 0; i < arraySize; i++) { + uint32_t opCode = 0; + if (!GetNextByteCode(opCode)) { + return nullptr; + } + auto element = RebuildObject(opCode); + if (element == nullptr) { + return nullptr; + } + if (!array->AddChild(element)) { + return nullptr; + } + } + return array; +} + +std::shared_ptr Decompile::RebuildStringObject() +{ + std::string strValue; + if (!ReadString(strValue)) { + return nullptr; + } + return std::make_shared(std::string(), PARSEROP_STRING, strValue); +} + +std::shared_ptr Decompile::RebuildObject(uint8_t opCode) +{ + switch (opCode) { + case HCS_NODE_OP: + return RebuildNode(); + case HCS_TERM_OP: + return RebuildTerm(); + case HCS_NODEREF_OP: + return RebuildNodeRefObject(); + case HCS_BYTE_OP: + case HCS_WORD_OP: + case HCS_DWORD_OP: + case HCS_QWORD_OP: + return RebuildNumberObject(opCode); + case HCS_ARRAY_OP: + return RebuildArray(); + case HCS_STRING_OP: + return RebuildStringObject(); + default: + Logger().Error() << "Rebuild object failed, unknown OpCode is: " << opCode; + break; + } + return nullptr; +} + +std::shared_ptr Decompile::RebuildAst() +{ + uint32_t currByteCode = 0; + if (!GetNextByteCode(currByteCode) || currByteCode != HCS_NODE_OP) { + Logger().Error() << "Rebuild Ast failed, miss root node!"; + return nullptr; + } + auto rootObject = RebuildObject(currByteCode); + if (rootObject == nullptr) { + Logger().Error() << "Rebuild Ast failed, rebuild object failed!"; + return nullptr; + } + auto ast = std::make_shared(rootObject); + ast->Dump(); + return ast; +} + +bool Decompile::DoDecompile() +{ + if(!InitDecompileFile()) { + return false; + } + + if (!VerifyDecompileFile()) { + Logger().Error() << "Verify decompile file failed!"; + return false; + } + auto ast = RebuildAst(); + if (ast == nullptr) { + Logger().Error() << "Rebuild ast failed!"; + return false; + } + std::string outPutFileName = Option::Instance().GetOutputName(); + if (outPutFileName.empty()) { + outPutFileName = Option::Instance().GetSourceName(); + } else if (!isalpha(outPutFileName[outPutFileName.length() - 1])) { + outPutFileName.append(Option::Instance().GetSourceNameBase()); + } + DecompileGen decompileGen(ast, outPutFileName); + return decompileGen.OutPut(); +} diff --git a/tools/hc-gen/src/decompile.h b/tools/hc-gen/src/decompile.h new file mode 100644 index 000000000..cec3fe063 --- /dev/null +++ b/tools/hc-gen/src/decompile.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_DECOMPILE_H +#define HC_GEN_DECOMPILE_H + +#include +#include +#include "ast.h" + +namespace OHOS { +namespace Hardware { +class Decompile { +public: + explicit Decompile(std::string fileName); + + ~Decompile() = default; + + bool DoDecompile(); + +private: + bool InitDecompileFile(); + + bool ReadFile(char *buffer, size_t readSize); + + uint32_t GetAlignSize(uint32_t size) + { + if (isAlign_) { + return (size + ALIGN_SIZE - 1) & (~(ALIGN_SIZE - 1)); + } else { + return size; + } + } + + bool ReadUint8(uint8_t &value); + + bool ReadUint16(uint16_t &value); + + bool ReadUint32(uint32_t &value); + + bool ReadUint64(uint64_t &value); + + bool ReadString(std::string &value); + + void SetAlign(bool isAlign); + + bool VerifyDecompileFile(); + + bool GetNextByteCode(uint32_t &byteCode); + + std::shared_ptr RebuildObject(uint8_t opCode); + + std::shared_ptr RebuildNode(); + + std::shared_ptr RebuildTerm(); + + std::shared_ptr RebuildNodeRefObject(); + + std::shared_ptr RebuildNumberObject(uint8_t opCode); + + std::shared_ptr RebuildArray(); + + std::shared_ptr RebuildStringObject(); + + std::shared_ptr RebuildAst(); + + bool isAlign_; + std::string fileName_; + std::ifstream file_; +}; + +} // OHOS +} // Hardware +#endif // HC_GEN_DECOMPILE_H diff --git a/tools/hc-gen/src/decompile_gen.cpp b/tools/hc-gen/src/decompile_gen.cpp new file mode 100644 index 000000000..ba9360076 --- /dev/null +++ b/tools/hc-gen/src/decompile_gen.cpp @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "decompile_gen.h" +#include +#include "file.h" +#include "logger.h" + +using namespace OHOS::Hardware; + +DecompileGen::DecompileGen(std::shared_ptr ast, std::string outPutFileName) : ast_(ast) +{ + outPutFileName_ = Util::File::StripSuffix(std::move(outPutFileName)).append(".d.hcs"); + Logger().Debug() << "Decompile gen file: " << outPutFileName_; +} + +bool DecompileGen::Init() +{ + file_.open(outPutFileName_, std::ostream::out | std::ostream::binary); + if (!file_.is_open()) { + Logger().Error() << "Failed to open decompile output file: " << outPutFileName_; + return false; + } + return true; +} + +void DecompileGen::WriteFile(const std::string &str) +{ + file_ << str; +} + +std::string DecompileGen::GetNodeRefPath(uint32_t value) +{ + std::string refPath; + std::shared_ptr astObject = ast_->GetAstRoot(); + if (astObject == nullptr) { + return refPath; + } + while (astObject->Child() != nullptr) { + refPath = astObject->Name() + "."; + auto child = astObject->Child(); + bool deepIn = false; + while (child != nullptr) { + if (child->Type() != PARSEROP_CONFNODE) { + child = child->Next(); + continue; + } + if (child->GetHash() == value) { + return (refPath + child->Name()); + } + if (value > child->GetHash() && value < (child->GetHash() + child->GetSize())) { + astObject = child; + deepIn = true; + break; + } + child = child->Next(); + } + if (!deepIn) { + Logger().Error() << "ref unknown node, hash = " << value; + break; + } + } + return std::string(); +} + +int32_t DecompileGen::PrintArrayType(const std::shared_ptr& astObj) +{ + WriteFile("["); + auto arrayElement = astObj->Child(); + while (arrayElement->Next()) { + if (PrintBaseType(arrayElement) != NOERR) { + return EOUTPUT; + } + WriteFile(", "); + arrayElement = arrayElement->Next(); + } + if (PrintBaseType(arrayElement) != NOERR) { + return EOUTPUT; + } + WriteFile("]"); + return NOERR; +} + +int32_t DecompileGen::PrintBaseType(const std::shared_ptr& astObj) +{ + std::stringstream outStr; + std::string refPath; + switch (astObj->Type()) { + case PARSEROP_UINT8: + case PARSEROP_UINT16: + case PARSEROP_UINT32: + case PARSEROP_UINT64: + outStr << "0x" << std::uppercase << std::hex << astObj->IntegerValue(); + WriteFile(outStr.str()); + break; + case PARSEROP_STRING: + outStr << "\"" << astObj->StringValue() << "\""; + WriteFile(outStr.str()); + break; + case PARSEROP_NODEREF: + refPath = GetNodeRefPath(astObj->IntegerValue()); + if (refPath.empty()) { + return EOUTPUT; + } + WriteFile("&" + refPath); + break; + case PARSEROP_ARRAY: + return PrintArrayType(astObj); + default: + Logger().Error() << "unknown opcode = " << astObj->Type(); + return EFAIL; + } + return NOERR; +} + +int32_t DecompileGen::OutPutWalk(const std::shared_ptr& astObj, int32_t walkDepth) +{ + if (astObj->Type() != PARSEROP_CONFNODE && astObj->Type() != PARSEROP_CONFTERM) { + return NOERR; + } + int ret; + std::string tabStr = std::string(TAB_SIZE * walkDepth, ' '); + if (walkDepth != 0) { + WriteFile(tabStr); + } + std::string str; + switch (astObj->Type()) { + case PARSEROP_CONFNODE: + str = astObj->Name() + " {\n"; + WriteFile(str); + if (astObj->Child() == nullptr) { + tabStr += "}\n"; + WriteFile(tabStr); + } + break; + case PARSEROP_CONFTERM: + str = astObj->Name() + " = "; + WriteFile(str); + ret = PrintBaseType(astObj->Child()); + if (ret != NOERR) { + return ret; + } + WriteFile(";\n"); + break; + default: + return EOUTPUT; + } + return 0; +} + +int32_t DecompileGen::CloseBrace(const std::shared_ptr& astObj, int32_t walkDepth) +{ + if (astObj->Type() != PARSEROP_CONFNODE) { + return NOERR; + } + std::string tabStr = std::string(TAB_SIZE * walkDepth, ' '); + if (astObj != ast_->GetAstRoot()) { + WriteFile(tabStr + "}\n"); + } else { + WriteFile("}\n"); + } + return file_.good() ? NOERR : EOUTPUT; +} + +bool DecompileGen::OutPut() +{ + if (!Init()) { + return false; + } + WriteFile(fileHeader_); + if (!ast_->WalkRound( + [this](std::shared_ptr ¤t, int32_t walkDepth) -> int32_t { + return OutPutWalk(current, walkDepth); + }, + [this](std::shared_ptr ¤t, int32_t walkDepth) -> int32_t { + return CloseBrace(current, walkDepth); + })) { + return false; + } + + return file_.good(); +} diff --git a/tools/hc-gen/src/decompile_gen.h b/tools/hc-gen/src/decompile_gen.h new file mode 100644 index 000000000..3f3ae0af6 --- /dev/null +++ b/tools/hc-gen/src/decompile_gen.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_DECOMPILE_GEN_H +#define HC_GEN_DECOMPILE_GEN_H + +#include +#include +#include "ast.h" + +namespace OHOS { +namespace Hardware { + +class DecompileGen { +public: + DecompileGen(std::shared_ptr ast, std::string outPutFileName); + + ~DecompileGen() = default; + + bool OutPut(); + +private: + bool Init(); + + void WriteFile(const std::string &str); + + int32_t PrintBaseType(const std::shared_ptr& astObj); + + std::string GetNodeRefPath(uint32_t hash); + + int32_t PrintArrayType(const std::shared_ptr& astObj); + + int32_t OutPutWalk(const std::shared_ptr& astObj, int32_t walkDepth); + + int32_t CloseBrace(const std::shared_ptr& astObj, int32_t walkDepth); + + const std::string fileHeader_ = "/*\n * HDF decompile hcs file\n */\n\n"; + std::string outPutFileName_; + std::ofstream file_; + std::shared_ptr ast_; +}; + +} // OHOS +} // Hardware +#endif // HC_GEN_DECOMPILE_GEN_H diff --git a/tools/hc-gen/src/file.cpp b/tools/hc-gen/src/file.cpp new file mode 100644 index 000000000..79fe1a18f --- /dev/null +++ b/tools/hc-gen/src/file.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "file.h" +#include +#include +#include +#include "types.h" + +using namespace OHOS::Hardware::Util; + +std::string File::AbsPath(const std::string& path) +{ + char realPath[PATH_MAX]; +#ifdef MINGW32 + char *p = _fullpath(realPath, path.data(), PATH_MAX); + if (p != nullptr && access(p, F_OK) != 0) { + p = nullptr; + } +#else + char *p = realpath(path.data(), realPath); +#endif + return p == nullptr ? "" : p; +} + +std::string File::StripSuffix(std::string path) +{ + auto sepPos = path.rfind(OS_SEPARATOR); + auto dotPos = path.rfind('.'); + if (sepPos == std::string::npos || dotPos > sepPos) { + return path.substr(0, dotPos); + } else { + return path; + } +} + +std::string File::GetDir(std::string path) +{ + auto separatorPos = path.rfind(OS_SEPARATOR); + if (separatorPos == std::string::npos) { + return path; + } + return path.substr(0, separatorPos + 1); +} + +std::string File::FileNameBase(const std::string& path) +{ + auto sepPos = path.rfind(OS_SEPARATOR); + auto dotPos = path.rfind('.'); + + if (sepPos == std::string::npos) { + sepPos = 0; + } else { + sepPos++; + } + + if (dotPos == std::string::npos || dotPos < sepPos) { + dotPos = path.size(); + } + + auto len = path.size() - 1; + if (dotPos != std::string::npos && dotPos > sepPos) { + len = dotPos - sepPos; + } + return path.substr(sepPos, len); +} diff --git a/tools/hc-gen/src/file.h b/tools/hc-gen/src/file.h new file mode 100644 index 000000000..6bfca9060 --- /dev/null +++ b/tools/hc-gen/src/file.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_FILE_H +#define HC_GEN_FILE_H + +#include + +namespace OHOS { +namespace Hardware { +namespace Util { +class File { +public: + static std::string AbsPath(const std::string& path); + static std::string StripSuffix(std::string path); + static std::string GetDir(std::string path); + static std::string FileNameBase(const std::string& path); +}; +} // Util +} //Hardware +} //OHOS +#endif // HC_GEN_FILE_H diff --git a/tools/hc-gen/src/generator.h b/tools/hc-gen/src/generator.h new file mode 100644 index 000000000..60c6fb74f --- /dev/null +++ b/tools/hc-gen/src/generator.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_GENERATOR_H +#define HC_GEN_GENERATOR_H + +#include +#include +#include "ast.h" + +namespace OHOS { +namespace Hardware { +class Generator { +public: + Generator(std::shared_ptr ast) : ast_(ast) {}; + + virtual ~Generator() = default; + + virtual bool Output() = 0; + +protected: + std::shared_ptr ast_; +}; +} // Hardware +} // OHOS + +#endif // HC_GEN_GENERATOR_H diff --git a/tools/hc-gen/src/lexer.cpp b/tools/hc-gen/src/lexer.cpp new file mode 100644 index 000000000..fd58550c7 --- /dev/null +++ b/tools/hc-gen/src/lexer.cpp @@ -0,0 +1,381 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "lexer.h" +#include +#include +#include "logger.h" + +using namespace OHOS::Hardware; + +Lexer::Lexer() : lineno_(0), lineLoc_(0) +{ +} + +std::map Lexer::keyWords_ = { + {"#include", INCLUDE}, + {"root", ROOT}, + {"delete", DELETE}, + {"template", TEMPLATE}, +}; + +bool Lexer::Initialize(const std::string &sourceName) +{ + srcName_ = std::make_shared(sourceName); + + if (src_.is_open()) { + src_.close(); + } + bufferStart_ = nullptr; + bufferEnd_ = nullptr; + lineno_ = 1; + lineLoc_ = 1; + src_.open(srcName_->c_str(), std::ifstream::binary); + if (!src_.is_open()) { + Logger().Error() << "Failed to open source file: " << srcName_->data(); + return false; + } + return true; +} + +bool Lexer::Lex(Token &token) +{ + char c; + InitToken(token); + do { + if (!PeekChar(c, true)) { + token.type = EOF; + return true; + } + if (c == '#') { + return LexInclude(token); + } + if (isalpha(c)) { + LexFromLiteral(token); + return true; + } + + if (IsNum(c)) { + return LexFromNumber(token); + } + switch (c) { + case '/': + if (!ProcessComment()) { + return false; + } + continue; + case ';': /* fall-through */ + case ',': /* fall-through */ + case '[': /* fall-through */ + case ']': /* fall-through */ + case '{': /* fall-through */ + case '}': /* fall-through */ + case '=': /* fall-through */ + case '&': /* fall-through */ + case ':': + ConsumeChar(); + token.type = c; + token.lineNo = lineno_; + break; + case '"': + return LexFromString(token); + case '+': /* fall-through */ + case '-': + return LexFromNumber(token); + case EOF: + token.type = EOF; + break; + default: + Logger().Error() << *this << "can not recognized character '" << c << "'"; + return false; + } + break; + } while (true); + + return true; +} + +char Lexer::GetRawChar() +{ + if (!FillBuffer()) { + return EOF; + } + lineLoc_++; + return *bufferStart_++; +} + +bool Lexer::GetChar(char &c, bool skipSpace) +{ + char chr = GetRawChar(); + if (skipSpace) { + while (IsSpace(chr)) { + chr = GetRawChar(); + } + } + + if (chr == '\n') { + lineno_++; + lineLoc_ = 0; + } + c = chr; + return chr != EOF; +} + +bool Lexer::PeekChar(char &c, bool skipSpace) +{ + if (!FillBuffer()) { + return false; + } + + if (skipSpace) { + while (bufferStart_ <= bufferEnd_ && (IsSpace(*bufferStart_) || *bufferStart_ == '\n')) { + lineLoc_++; + if (*bufferStart_ == '\n') { + lineLoc_ = 0; + lineno_++; + } + bufferStart_++; + } + } + + if (bufferStart_ > bufferEnd_) { + return false; + } + c = *bufferStart_; + return true; +} + +bool Lexer::IsSpace(char c) +{ + return c == ' ' || c == '\t' || c == '\r'; +} + +bool Lexer::FillBuffer() +{ + if (bufferStart_ != nullptr && bufferStart_ <= bufferEnd_) { + return true; + } + auto size = src_.readsome(buffer_, BUFFER_SIZE); + if (size == 0) { + return false; + } + bufferStart_ = buffer_; + bufferEnd_ = bufferStart_ + size - 1; + return true; +} + +bool Lexer::ProcessComment() +{ + char c; + ConsumeChar();// skip first '/' + if (!GetChar(c)) { + Logger().Error() << *this << "unterminated comment"; + return false; + } + + if (c == '/') { + while (c != '\n' && GetChar(c)) { + } + if (c != '\n' && c != EOF) { + Logger().Error() << *this << "unterminated signal line comment"; + return false; + } + } else if (c == '*') { + while (GetChar(c)) { + if (c == '*' && GetChar(c) && c == '/') { + return true; + } + } + if (c != '/') { + Logger().Error() << *this << "unterminated multi-line comment"; + return false; + } + } else { + Logger().Error() << *this << "invalid character"; + return false; + } + + return true; +} + +std::shared_ptr Lexer::GetSourceName() const +{ + return srcName_; +} + +int32_t Lexer::GetLineno() const +{ + return lineno_; +} + +int32_t Lexer::GetLineLoc() const +{ + return lineLoc_; +} + +std::ostream &OHOS::Hardware::operator<<(std::ostream &stream, const Lexer &p) +{ + return stream << p.GetSourceName()->data() << ":" << p.GetLineno() << ":" << p.GetLineLoc() << ": "; +} + +void Lexer::InitToken(Token &token) +{ + token.type = 0; + token.numval = 0; + token.strval.clear(); + token.src = srcName_; + token.lineNo = lineno_; +} + +bool Lexer::LexFromString(Token &token) +{ + char c; + GetChar(c, false); // skip first '"' + std::string value; + while (GetChar(c, false) && c != '"') { + value.push_back(c); + } + + if (c != '"') { + Logger().Error() << *this << "unterminated string"; + return false; + } + token.type = STRING; + token.strval = std::move(value); + token.lineNo = lineno_; + return true; +} + +bool Lexer::LexFromNumber(Token &token) +{ + std::string value; + char c; + uint64_t v = 0; + GetChar(c, false); + switch (c) { + case '0': + if (!PeekChar(c, true)) { + break; + } + + if (IsNum(c)) { // Octal number + while (PeekChar(c) && IsNum(c)) { + ConsumeChar(); + value.push_back(c); + } + v = strtoll(value.data(), nullptr, 8); + break; + } + switch (c) { + case 'x': // fall-through + case 'X': // hex number + ConsumeChar(); + while (PeekChar(c, false) && (IsNum(c) || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F'))) { + value.push_back(c); + ConsumeChar(); + } + v = strtoll(value.data(), nullptr, 16); + break; + case 'b': // binary number + ConsumeChar(); + while (PeekChar(c, false) && (c == '0' || c == '1')) { + value.push_back(c); + ConsumeChar(); + } + v = strtoll(value.data(), nullptr, 2); + break; + default:; // fall-through + } + break; + case '+': // fall-through + case '-': // fall-through, signed decimal number + default: // unsigned decimal number + value.push_back(c); + while (PeekChar(c, true) && IsNum(c)) { + ConsumeChar(); + value.push_back(c); + } + v = strtoll(value.data(), nullptr, 10); + break; + } + + if (errno != 0) { + Logger().Error() << *this << "illegal number: " << value.data(); + return false; + } + token.type = NUMBER; + token.numval = v; + token.lineNo = lineno_; + return true; +} + +void Lexer::LexFromLiteral(Token &token) +{ + std::string value; + char c; + + while (PeekChar(c, false) && !IsSpace(c)) { + if (!isalnum(c) && c != '_' && c != '.' && c != '\\') { + break; + } + value.push_back(c); + ConsumeChar(); + } + + do { + if (value == "true") { + token.type = NUMBER; + token.numval = 1; + break; + } else if (value == "false") { + token.type = NUMBER; + token.numval = 0; + break; + } + auto keyword = keyWords_.find(value); + if (keyword != keyWords_.end()) { + token.type = keyword->second; + break; + } + + if (value.find('.') != std::string::npos) { + token.type = REF_PATH; + } else { + token.type = LITERAL; + } + } while (false); + + + token.strval = std::move(value); + token.lineNo = lineno_; +} + +void Lexer::ConsumeChar() +{ + char c; + (void) GetChar(c, false); +} + +bool Lexer::IsNum(char c) +{ + return c >= '0' && c <= '9'; +} + +bool Lexer::LexInclude(Token &token) +{ + ConsumeChar(); + LexFromLiteral(token); + if (token.strval != "include") { + return false; + } + + token.type = INCLUDE; + return true; +} + diff --git a/tools/hc-gen/src/lexer.h b/tools/hc-gen/src/lexer.h new file mode 100644 index 000000000..2fe699586 --- /dev/null +++ b/tools/hc-gen/src/lexer.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_LEXER_H +#define HC_GEN_LEXER_H + +#include +#include +#include +#include +#include "token.h" + +namespace OHOS { +namespace Hardware { + +class Lexer { +public: + Lexer(); + + ~Lexer() = default; + + bool Initialize(const std::string &sourceName); + + bool Lex(Token &token); + + friend std::ostream &operator<<(std::ostream &stream, const Lexer &p); + + std::shared_ptr GetSourceName() const; + + int32_t GetLineno() const; + + int32_t GetLineLoc() const; + +private: + static constexpr int BUFFER_SIZE = (1024 * 1024); + + void InitToken(Token &token); + + bool GetChar(char &c, bool skipSpace = true); + + void ConsumeChar(); + + char GetRawChar(); + + static bool IsSpace(char c); + + static bool IsNum(char c); + + bool FillBuffer(); + + bool ProcessComment(); + + bool LexInclude(Token &token); + + bool LexFromString(Token &token); + + bool LexFromNumber(Token &token); + + void LexFromLiteral(Token &token); + + bool PeekChar(char &c, bool skipSpace = true); + + static std::map keyWords_; + + std::ifstream src_; + std::shared_ptr srcName_; + char buffer_[BUFFER_SIZE]{0}; + const char *bufferStart_{nullptr}; + const char *bufferEnd_{nullptr}; + int32_t lineno_; + int32_t lineLoc_; +}; + +} // Hardware +} // OHOS + +#endif // HC_GEN_LEXER_H diff --git a/tools/hc-gen/src/logger.h b/tools/hc-gen/src/logger.h new file mode 100644 index 000000000..93678e5d4 --- /dev/null +++ b/tools/hc-gen/src/logger.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + + +#ifndef HC_GEN_LOG_H +#define HC_GEN_LOG_H + +#include +#include +#include +#include "option.h" + +namespace OHOS { +namespace Hardware { + +class Logger { +public: + Logger() : level_(INFO) {}; + + inline ~Logger() + { + if (level_ > INFO) { + ::std::cout << ERROR_COLOR_END; + } + if (level_ <= DEBUG && !Option::Instance().VerboseLog()) { + return; + } + ::std::cout << ::std::endl; + } + + template + inline Logger &operator<<(const T &v) + { + if (level_ <= DEBUG && !Option::Instance().VerboseLog()) { + return *this; + } + ::std::cout << v; + return *this; + } + + inline Logger &Debug() + { + level_ = DEBUG; + if (Option::Instance().VerboseLog()) { + ShowLevel(); + } + return *this; + } + + inline Logger &Info() + { + level_ = INFO; + ShowLevel(); + return *this; + } + + inline Logger &Warning() + { + level_ = WARNING; + ShowLevel(); + return *this; + } + + inline Logger &Error() + { + level_ = ERROR; + ShowLevel(); + return *this; + } + + inline Logger &Fatal() + { + level_ = FATAL; + ShowLevel(); + return *this; + } + +private: + enum LogLevel { + NONE, + DEBUG, + INFO, + WARNING, + ERROR, + FATAL, + } level_; + + void ShowLevel() + { + static ::std::map levelStrMap = { + {NONE, ""}, + {DEBUG, "Debug"}, + {INFO, "Info"}, + {WARNING, "Warning"}, + {ERROR, "Error"}, + {FATAL, "Fatal"} + }; + if (level_ > INFO) { + ::std::cout << ERROR_COLOR_PREFIX; + } + ::std::cout << "[" << levelStrMap[level_] << "] "; + } + +#ifdef OS_LINUX + static constexpr const char *ERROR_COLOR_PREFIX = "\033[31m"; + static constexpr const char *ERROR_COLOR_END = "\033[0m"; +#else + static constexpr const char *ERROR_COLOR_PREFIX = ""; + static constexpr const char *ERROR_COLOR_END = ""; +#endif +}; + +} // OHOS +} // Hardware +#endif // HC_GEN_LOG_H diff --git a/tools/hc-gen/src/main.cpp b/tools/hc-gen/src/main.cpp new file mode 100644 index 000000000..6e994a4ac --- /dev/null +++ b/tools/hc-gen/src/main.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "bytecode_gen.h" +#include "decompile.h" +#include "option.h" +#include "parser.h" +#include "text_gen.h" + +using namespace OHOS::Hardware; + +int main(int argc, char *argv[]) +{ + auto option = Option::Instance().Parse(argc, argv); + if (option.OptionError()) { + return EFAIL; + } + + if (option.ShouldShowUsage()) { + option.ShowUsage(); + return option.OptionError(); + } + + if (option.ShouldShowVersion()) { + option.ShowVersion(); + return 0; + } + + if (option.ShouldDecompile()) { + Decompile decompile(option.GetSourceName()); + return decompile.DoDecompile() ? 0 : EFAIL; + } + + Parser parser; + if (!parser.Parse()) { + return EFAIL; + } + + if (option.ShouldGenBinaryConfig()) { + if (!ByteCodeGen(parser.GetAst()).Output()) { + return EFAIL; + } + return 0; + } + + if (option.ShouldGenTextConfig()) { + if (!TextGen(parser.GetAst()).Output()) { + return EFAIL; + } + } + + return 0; +} diff --git a/tools/hc-gen/src/opcode.h b/tools/hc-gen/src/opcode.h new file mode 100644 index 000000000..d082d1908 --- /dev/null +++ b/tools/hc-gen/src/opcode.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_OPCODE_H +#define HC_GEN_OPCODE_H + +#include +#include +#include "ast.h" + +namespace OHOS { +namespace Hardware { +constexpr uint32_t HCB_MAGIC_NUM = 0xA00AA00A; + +enum OpCodeType { + HCS_NODE_OP = 0x01, + HCS_TERM_OP = 0x02, + HCS_NODEREF_OP = 0x03, + HCS_ARRAY_OP = 0x04, + HCS_BYTE_OP = 0x10, + HCS_WORD_OP = 0x11, + HCS_DWORD_OP = 0x12, + HCS_QWORD_OP = 0x13, + HCS_STRING_OP = 0x14, +}; + +struct HcbHeader { + uint32_t magicNumber; + uint32_t versionMajor; + uint32_t versionMinor; + uint32_t checkSum; + int32_t totalSize; +}; + +} // OHOS +} // Hardware + +#endif // HC_GEN_OPCODE_H diff --git a/tools/hc-gen/src/option.cpp b/tools/hc-gen/src/option.cpp new file mode 100644 index 000000000..148644ab3 --- /dev/null +++ b/tools/hc-gen/src/option.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "option.h" +#include +#include +#include +#include +#include "logger.h" +#include "file.h" + +using namespace OHOS::Hardware; +static constexpr int HCS_COMPILER_VERSION_MAJOR = 00; +static constexpr int HCS_COMPILER_VERSION_MINOR = 7; + +static constexpr int ARG_COUNT_MIN = 2; + +Option &Option::Instance() +{ + static Option option; + return option; +} + +static constexpr int OPTION_END = -1; +static constexpr const char *HCS_SUPPORT_ARGS = "o:ap:bditvVh"; + +Option &Option::Parse(int argc, char **argv) +{ + do { + if (argc < ARG_COUNT_MIN) { + showUsage_ = true; + break; + } + + if (!ParseOptions(argc, argv)) { + break; + } + + if (optind >= argc) { + Logger().Error() << "Miss input file name"; + SetOptionError(); + break; + } + SetSourceOption(argv[optind]); + return *this; + } while (false); + + return *this; +} + +bool Option::ParseOptions(int argc, char **argv) +{ + int32_t op = 0; + while (op != OPTION_END) { + op = getopt(argc, argv, HCS_SUPPORT_ARGS); + switch (op) { + case 'o': + outputName_ = optarg; + break; + case 'a': + shouldAlign_ = true; + break; + case 'b': + shouldGenByteCodeConfig_ = true; + break; + case 't': + shouldGenTextConfig_ = true; + shouldGenByteCodeConfig_ = false; + break; + case 'p': + symbolNamePrefix_ = optarg; + break; + case 'i': + showGenHexDump_ = true; + break; + case 'V': + verboseLog_ = true; + break; + case 'd': + shouldDecompile_ = true; + break; + case 'v': + showVersion_ = true; + return false; + case 'h': /* fall-through */ + showUsage_ = true; + return false; + case '?': + showUsage_ = true; + optionError_ = true; + SetOptionError(); + return false; + default: + break; + } + } + + return true; +} + +void Option::ShowUsage() +{ + Logger() << + "Usage: hc-gen [Options] [File]\n" << + "options:"; + ShowOption("-a", "hcb align with four bytes"); + ShowOption("-b", "output binary output, default enable"); + ShowOption("-t", "output config in C language source file style"); + ShowOption("-i", "output binary hex dump in C language source file style"); + ShowOption("-p ", "prefix of generated symbol name"); + ShowOption("-d", "decompile hcb to hcs"); + ShowOption("-V", "show verbose info"); + ShowOption("-v", "show version"); + ShowOption("-h", "show this help message"); +} + +void Option::ShowOption(const ::std::string &option, const ::std::string &helpInfo) +{ + Logger() << " " << ::std::setw(12) << ::std::left << option << " " << helpInfo; +} + +bool Option::ShouldShowUsage() const +{ + return showUsage_; +} + +void Option::ShowVersion() +{ + Logger() << "Hcs compiler " << HCS_COMPILER_VERSION_MAJOR << "." << HCS_COMPILER_VERSION_MINOR; + Logger() << "Copyright (c) 2020-2021 Huawei Device Co., Ltd."; +} + +bool Option::OptionError() const +{ + return optionError_; +} + +bool Option::ShouldShowVersion() const +{ + return showVersion_; +} + +bool Option::ShouldAlign() const +{ + return shouldAlign_; +} + +bool Option::ShouldGenTextConfig() const +{ + return shouldGenTextConfig_; +} + +bool Option::ShouldGenBinaryConfig() const +{ + return shouldGenByteCodeConfig_; +} + +bool Option::ShouldGenHexDump() const +{ + return showGenHexDump_; +} + +bool Option::ShouldDecompile() const +{ + return shouldDecompile_; +} + +std::string Option::GetSymbolPrefix() +{ + return symbolNamePrefix_; +} + +bool Option::VerboseLog() const +{ + return verboseLog_; +} + +void Option::SetOptionError(bool shouldShowUsage) +{ + showUsage_ = shouldShowUsage; + optionError_ = true; +} + +std::string Option::GetSourceName() +{ + return sourceName_; +} + +std::string Option::GetSourceNameBase() +{ + return sourceNameBase_; +} + +std::string Option::GetOutputName() +{ + return outputName_; +} + +std::string Option::GetSourceDir() +{ + return sourceDir_; +} + +bool Option::SetSourceOption(const char *srcName) +{ + std::string srcAbsPath; + srcAbsPath = Util::File::AbsPath(srcName); + if (srcAbsPath.empty()) { + Logger().Error() << "invalid source file: " << srcName << ", " << strerror(errno); + SetOptionError(false); + return false; + } + + sourceName_ = srcAbsPath; + sourceNameBase_ = Util::File::FileNameBase(srcAbsPath) ; + return true; +} + +void Option::GetVersion(uint32_t &minor, uint32_t &major) +{ + minor = HCS_COMPILER_VERSION_MINOR; + major = HCS_COMPILER_VERSION_MAJOR; +} diff --git a/tools/hc-gen/src/option.h b/tools/hc-gen/src/option.h new file mode 100644 index 000000000..de7389be1 --- /dev/null +++ b/tools/hc-gen/src/option.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_OPTION_H +#define HC_GEN_OPTION_H + +#include +#include + +namespace OHOS { +namespace Hardware { + +class Option { +public: + Option() = default; + + ~Option() = default; + + static Option &Instance(); + + Option &Parse(int argc, char *argv[]); + + void ShowUsage(); + + void ShowVersion(); + + bool ShouldShowUsage() const; + + bool OptionError() const; + + bool ShouldShowVersion() const; + + bool ShouldAlign() const; + + bool ShouldGenTextConfig() const; + + bool ShouldGenBinaryConfig() const; + + bool ShouldGenHexDump() const; + + bool ShouldDecompile() const; + + std::string GetSymbolPrefix(); + + std::string GetSourceName(); + + std::string GetSourceNameBase(); + + std::string GetOutputName(); + + void GetVersion(uint32_t &minor, uint32_t &major); + + bool VerboseLog() const; + + std::string GetSourceDir(); + + static std::string RealPathSourcePath(const char *path); +private: + static void ShowOption(const std::string &option, const std::string &helpInfo); + bool ParseOptions(int argc, char *argv[]); + void SetOptionError(bool shouldShowUsage = true); + bool SetSourceOption(const char* srcName); + + bool showUsage_ = false; + bool showVersion_ = false; + bool shouldAlign_ = false; + bool shouldGenTextConfig_ = false; + bool shouldGenByteCodeConfig_ = true; + bool showGenHexDump_ = false; + bool shouldDecompile_ = false; + bool verboseLog_ = false; + bool optionError_ = false; + std::string symbolNamePrefix_; + std::string sourceName_; + std::string sourceNameBase_; + std::string outputName_; + std::string sourceDir_; +}; + +} // Hardware +} // OHOS +#endif // HC_GEN_OPTION_H diff --git a/tools/hc-gen/src/parser.cpp b/tools/hc-gen/src/parser.cpp new file mode 100644 index 000000000..2679cd8c6 --- /dev/null +++ b/tools/hc-gen/src/parser.cpp @@ -0,0 +1,409 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "parser.h" +#include +#include "file.h" +#include "logger.h" + +using namespace OHOS::Hardware; + +bool Parser::Parse() +{ + srcQueue_.push_back(Option::Instance().GetSourceName()); + std::list> astList; + + while (!srcQueue_.empty()) { + std::list includeList; + auto oneAst = ParseOne(srcQueue_.front(), includeList); + if (oneAst == nullptr) { + return false; + } + + astList.push_back(oneAst); + srcQueue_.pop_front(); + srcQueue_.splice(srcQueue_.begin(), includeList); + } + + astList.push_back(astList.front()); + astList.pop_front(); + ast_ = astList.front(); + astList.pop_front(); + + if (!ast_->Merge(astList)) { + Logger().Debug() << "failed to merge ast"; + return false; + } + if (!astList.empty()) { + ast_->Dump("merged"); + } + + if (ast_->GetAstRoot() == nullptr) { + Logger().Error() << Option::Instance().GetSourceName() << ": Empty hcs file"; + return false; + } + + if (!ast_->Expand()) { + return false; + } + return true; +} + + +std::shared_ptr Parser::ParseOne(const std::string &src, std::list &includeList) +{ + if (!lexer_.Initialize(src)) { + return nullptr; + } + + if (!lexer_.Lex(current_)) { + return nullptr; + } + + if (current_ == INCLUDE && !ProcessInclude(includeList)) { + return nullptr; + } + + std::shared_ptr rootNode = nullptr; + if (current_ == ROOT) { + auto preToken = current_; + preToken.type = LITERAL; + preToken.strval = "root"; + rootNode = ParseNode(preToken); + if (rootNode == nullptr) { + return nullptr; + } + } else if (current_ != EOF) { + Logger().Error() << lexer_ << "syntax error, expect root node of end of file"; + return nullptr; + } + + if (!lexer_.Lex(current_) || current_ != EOF) { + Logger().Error() << lexer_ << "syntax error, expect EOF"; + return nullptr; + } + + std::shared_ptr oneAst = std::make_shared(rootNode); + oneAst->Dump(*lexer_.GetSourceName()); + + return oneAst; +} + +bool Parser::ProcessInclude(std::list &includeList) +{ + do { + if (!lexer_.Lex(current_) || current_ != STRING) { + Logger().Error() << lexer_ << "syntax error, expect include path after ’#include‘"; + return false; + } + + auto includePath = current_.strval; + if (includePath.empty()) { + Logger().Error() << lexer_ << "include invalid file: \'" << includePath << '\''; + return false; + } + if (includePath[0] != '/') { + auto currentSrc = srcQueue_.front(); + auto currentSrcDir = Util::File::GetDir(currentSrc); + includePath = currentSrcDir.append(includePath); + } + + auto includeAbsPath = Util::File::AbsPath(includePath); + if (includeAbsPath.empty()) { + Logger().Error() << lexer_ << "include invalid file: \'" << current_.strval << '\''; + return false; + } + + includeList.push_back(includeAbsPath); + + if (!lexer_.Lex(current_)) { + return false; + } + + if (current_ == INCLUDE) { + continue; + } + + break; + } while (true); + + return true; +} + +std::shared_ptr Parser::ParseNode(Token &name, bool bracesStart) +{ + /* bracesStart: if true, current is '{' , else need to read next token and check with '}' */ + if (!bracesStart) { + if (!lexer_.Lex(current_) || current_ != '{') { + Logger().Error() << lexer_ << "syntax error, node miss '{'"; + return nullptr; + } + } + + auto node = std::shared_ptr(new ConfigNode(name, NODE_NOREF, "")); + std::shared_ptr child; + while (lexer_.Lex(current_) && current_ != '}') { + switch (current_.type) { + case TEMPLATE: + child = ParseTemplate(); + break; + case LITERAL: + child = ParseNodeAndTerm(); + break; + default: + Logger().Error() << lexer_ + << "syntax error, except '}' or TEMPLATE or LITERAL for node '" << name.strval << '\''; + return nullptr; + } + if (child == nullptr) { + return nullptr; + } + + node->AddChild(child); + } + + if (current_ != '}') { + Logger().Error() << lexer_ << "syntax error, node miss '}'"; + return nullptr; + } + return std::shared_ptr(node); +} + +std::shared_ptr Parser::ParseTerm(Token &name) +{ + if (!lexer_.Lex(current_)) { + Logger().Error() << lexer_ << "syntax error, miss value of config term"; + return nullptr; + } + auto term = std::shared_ptr(new(std::nothrow) ConfigTerm(name, nullptr)); + if (term == nullptr) { + return nullptr; + } + switch (current_.type) { + case STRING: + term->AddChild(std::make_shared("", PARSEROP_STRING, current_.strval, current_)); + break; + case NUMBER: + term->AddChild(std::make_shared("", PARSEROP_UINT64, current_.numval, current_)); + break; + case '[': { + std::shared_ptr list = ParseArray(); + if (list == nullptr) { + return nullptr; + } else { + term->AddChild(list); + } + break; + } + case '&': + if (!lexer_.Lex(current_) || (current_ != LITERAL && current_ != REF_PATH)) { + Logger().Error() << lexer_ << "syntax error, invalid config term definition"; + return nullptr; + } + term->AddChild(std::make_shared("", PARSEROP_NODEREF, current_.strval, current_)); + break; + case DELETE: + term->AddChild(std::make_shared("", PARSEROP_DELETE, current_.strval, current_)); + break; + default: + Logger().Error() << lexer_ << "syntax error, invalid config term definition"; + return nullptr; + } + + if (!lexer_.Lex(current_) || current_ != ';') { + Logger().Error() << lexer_ << "syntax error, miss ';'"; + return nullptr; + } + + return std::shared_ptr(term); +} + +std::shared_ptr Parser::ParseTemplate() +{ + if (!lexer_.Lex(current_) || current_ != LITERAL) { + Logger().Error() << lexer_ << "syntax error, template miss name"; + return nullptr; + } + + auto name = current_; + auto node = ParseNode(name, false); + if (node == nullptr) { + return node; + } + + ConfigNode::CastFrom(node)->SetNodeType(NODE_TEMPLATE); + return node; +} + +std::shared_ptr Parser::ParseNodeAndTerm() +{ + auto name = current_; + if (!lexer_.Lex(current_)) { + Logger().Error() << lexer_ << "syntax error, broken term or node"; + return nullptr; + } + + switch (current_.type) { + case '=': + return ParseTerm(name); + case '{': + return ParseNode(name, true); + case ':': + if (lexer_.Lex(current_)) { + return ParseNodeWithRef(name); + } + Logger().Error() << lexer_ << "syntax error, unknown node reference type"; + break; + default: + Logger().Error() << lexer_ << "syntax error, except '=' or '{' or ':'"; + break; + } + + return nullptr; +} + +std::shared_ptr Parser::ParseNodeWithRef(Token name) +{ + std::shared_ptr node; + switch (current_.type) { + case REF_PATH: + case LITERAL: + return ParseNodeCopy(name); + case '&': + return ParseNodeRef(name); + case DELETE: + return ParseNodeDelete(name); + case ':': + return ParseNodeInherit(name); + default: + Logger().Error() << lexer_ << "syntax error, unknown node type"; + break; + } + + return node; +} + +/* started with NodePath on gramme : LITERAL ':' NodePath '{' ConfigTermList '}'*/ +std::shared_ptr Parser::ParseNodeCopy(Token &name) +{ + auto nodePath = current_.strval; + + auto node = ParseNode(name); + if (node == nullptr) { + return nullptr; + } + + auto nodeCopy = ConfigNode::CastFrom(node); + nodeCopy->SetNodeType(NODE_COPY); + nodeCopy->SetRefPath(nodePath); + + return node; +} + +/* started with & on gramme : LITERAL ':' '&' NodePath '{' ConfigTermList '}'*/ +std::shared_ptr Parser::ParseNodeRef(Token &name) +{ + if (!lexer_.Lex(current_) || (current_ != LITERAL && current_ != REF_PATH)) { + Logger().Error() << lexer_ << "syntax error, miss node reference path"; + return nullptr; + } + auto refPath = current_.strval; + auto node = ParseNode(name); + if (node == nullptr) { + return nullptr; + } + + auto configNode = ConfigNode::CastFrom(node); + configNode->SetNodeType(NODE_REF); + configNode->SetRefPath(refPath); + return node; +} + +/* started with DELETE on gramme : LITERAL ':' DELETE '{' ConfigTermList '}'*/ +std::shared_ptr Parser::ParseNodeDelete(Token &name) +{ + auto node = ParseNode(name); + if (node == nullptr) { + return nullptr; + } + + /* maybe drop node context is better */ + auto configNode = ConfigNode::CastFrom(node); + configNode->SetNodeType(NODE_DELETE); + return node; +} + +/* started with 2th ':' on gramme : LITERAL ':' ':' NodePath '{' ConfigTermList '}'*/ +std::shared_ptr Parser::ParseNodeInherit(Token &name) +{ + if (!lexer_.Lex(current_) || (current_ != LITERAL && current_ != REF_PATH)) { + Logger().Error() << lexer_ << "syntax error, miss node inherit path"; + return nullptr; + } + + auto inheritPath = current_.strval; + + auto node = ParseNode(name); + if (node == nullptr) { + return nullptr; + } + + auto configNode = ConfigNode::CastFrom(node); + configNode->SetNodeType(NODE_INHERIT); + configNode->SetRefPath(inheritPath); + + return node; +} + +std::shared_ptr Parser::ParseArray() +{ + auto array = std::shared_ptr(new ConfigArray(current_)); + int32_t arrayType = 0; + + while (lexer_.Lex(current_) && current_ != ']') { + if (current_.type == STRING) { + array->AddChild(std::make_shared("", PARSEROP_STRING, current_.strval, current_)); + } else if (current_.type == NUMBER) { + array->AddChild(std::make_shared("", PARSEROP_UINT64, current_.numval, current_)); + } else { + Logger().Error() << lexer_ << "syntax error, except STRING or NUMBER in array"; + return nullptr; + } + + if (arrayType == 0) { + arrayType = current_.type; + } else if (arrayType != current_.type) { + Logger().Error() << lexer_ << "syntax error, not allow mix type array"; + return nullptr; + } + + if (lexer_.Lex(current_)) { + if (current_ == ',') { + continue; + } else if (current_ == ']') { + break; + } else { + Logger().Error() << lexer_ << "syntax error, except ',' or ']'"; + return nullptr; + } + } + return std::shared_ptr(); + } + + if (current_ != ']') { + Logger().Error() << lexer_ << "syntax error, miss ']' at end of array"; + return nullptr; + } + + return std::shared_ptr(array); +} + +std::shared_ptr Parser::GetAst() +{ + return ast_; +} diff --git a/tools/hc-gen/src/parser.h b/tools/hc-gen/src/parser.h new file mode 100644 index 000000000..a3b055c87 --- /dev/null +++ b/tools/hc-gen/src/parser.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_PARSER_H +#define HC_GEN_PARSER_H + +#include +#include "ast.h" +#include "lexer.h" + +namespace OHOS { +namespace Hardware { + + +class Parser { +public: + Parser() = default; + + ~Parser() = default; + + bool Parse(); + + std::shared_ptr ParseOne(const std::string &src, std::list &includeList); + + std::shared_ptr GetAst(); + +private: + bool ProcessInclude(std::list &includeList); + + std::shared_ptr ParseTemplate(); + + std::shared_ptr ParseNodeAndTerm(); + + std::shared_ptr ParseNodeCopy(Token &name); + + std::shared_ptr ParseNodeRef(Token &name); + + std::shared_ptr ParseNodeDelete(Token &name); + + std::shared_ptr ParseNodeInherit(Token &name); + + std::shared_ptr ParseNode(Token &name, bool bracesStart = false); + + std::shared_ptr ParseTerm(Token &name); + + std::shared_ptr ParseNodeWithRef(Token name); + + std::shared_ptr ParseArray(); + + Lexer lexer_; + Token current_; + std::shared_ptr ast_; + std::list srcQueue_; +}; + +} // OHOS +} // Hardware +#endif // HC_GEN_PARSER_H diff --git a/tools/hc-gen/src/text_gen.cpp b/tools/hc-gen/src/text_gen.cpp new file mode 100644 index 000000000..0c7d72e6c --- /dev/null +++ b/tools/hc-gen/src/text_gen.cpp @@ -0,0 +1,735 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include +#include "file.h" +#include "logger.h" +#include "opcode.h" +#include "text_gen.h" + +using namespace OHOS::Hardware; + +constexpr static const char *FILE_HEAD_COMMENT = \ + "/*\n" \ + " * This is an automatically generated HDF config file. Do not modify it manually.\n" \ + " */\n\n"; + +TextGen::TextGen(std::shared_ptr ast) : Generator(ast) +{ +} + +bool TextGen::Output() +{ + if (!Initialize() || !DuplicateNodeNameCheck()) { + return false; + } + + auto ret = HeaderOutput(); + if (ret) { + ret = ImplOutput(); + } + + if (!ret && (ofs_.is_open() && !ofs_.good())) { + Logger().Error() << "failed to write file:" << outputFileName_; + } + + return ret; +} + +bool TextGen::Initialize() +{ + auto opt = Option::Instance(); + prefix_ = opt.GetSymbolPrefix(); + if (prefix_.empty()) { + prefix_ = "HdfConfig"; + } + + prefix_ = ToLowerCamelString(prefix_); + + auto moduleTerm = ast_->GetAstRoot()->Lookup("module", PARSEROP_CONFTERM); + if (moduleTerm == nullptr) { + return false; // never hit + } + + moduleName_ = ToUpperCamelString(moduleTerm->Child()->StringValue()); + rootVariableName_ = "g_" + prefix_ + moduleName_ + "ModuleRoot"; + return true; +} + +bool TextGen::HeaderOutput() +{ + if (!InitOutput(".h")) { + return false; + } + ofs_ << FILE_HEAD_COMMENT; + + std::string headerMacro = GetHeaderProtectMacro(outputFileName_); + ofs_ << "#ifndef " << headerMacro << "\n"; + ofs_ << "#define " << headerMacro << "\n\n"; + ofs_ << "#include \n\n"; + + if (!HeaderOutputTraversal()) { + return false; + } + + ofs_ << "\n#endif // " << headerMacro << '\n'; + return ofs_.good(); +} + +bool TextGen::HeaderOutputTraversal() +{ + auto ret = ast_->WalkBackward([this](const std::shared_ptr ¤t, uint32_t) -> uint32_t { + if (!current->IsNode()) { + return NOERR; + } + auto node = ConfigNode::CastFrom(current); + if (node->GetNodeType() == NODE_INHERIT) { + return NOERR; + } + + return GenNodeDefinition(current); + }); + + if (!ret) { + return false; + } + + ofs_ << "const struct " << ToUpperCamelString(prefix_) << moduleName_ << "Root* HdfGet" + << moduleName_ << "ModuleConfigRoot(void);\n"; + return ofs_.good(); +} + +bool TextGen::ImplOutput() +{ + if (!InitOutput(".c")) { + return false; + } + symMap.clear(); + ofs_ << FILE_HEAD_COMMENT; + ofs_ << "#include \"" << outputNameBase_ << ".h\"\n\n"; + + bool ret = OutputTemplateImpl(); + if (ret) { + ret = OutputImplGlobalVariables(); + } + + if (!ret) { + return ret; + } + + ofs_ << "\nconst struct " << ToUpperCamelString(prefix_) << moduleName_ << "Root* HdfGet" << moduleName_ << "ModuleConfigRoot(void)\n" + << "{\n" + << Indent() << "return &" << rootVariableName_ << ";\n" + << "}\n"; + + return ofs_.good(); +} + +std::string TextGen::ToUpperCamelString(const std::string &str) +{ + if (str.empty()) { + return str; + } + auto out = ToCamelString(str); + out[0] = static_cast(toupper(out[0])); + + return out; +} + +std::string TextGen::ToLowerCamelString(const std::string &str) +{ + if (str.empty()) { + return str; + } + auto out = ToCamelString(str); + out[0] = static_cast(tolower(out[0])); + + return out; +} + +std::string TextGen::ToCamelString(const std::string &str) +{ + if (str.empty()) { + return str; + } + + if (str.find('_') == std::string::npos) { + return str; + } + + std::string out; + char cb = '\0'; + constexpr char underLine = '_'; + for (auto c : str) { + if (c == '_') { + cb = c; + continue; + } + + if (cb == underLine) { + out.push_back(static_cast(toupper(c))); + } else { + out.push_back(c); + } + + cb = c; + } + + return out; +} + +bool TextGen::InitOutput(const std::string &fileSuffix) +{ + ofs_.close(); + outputFileName_ = Option::Instance().GetOutputName(); + if (outputFileName_.empty()) { + outputFileName_ = Option::Instance().GetSourceNameBase(); + } + outputFileName_ = Util::File::StripSuffix(outputFileName_).append(fileSuffix); + outputNameBase_ = Util::File::FileNameBase(outputFileName_); + + ofs_.open(outputFileName_, std::ostream::out | std::ostream::binary); + if (!ofs_.is_open()) { + Logger().Error() << "failed to open output file: " << outputFileName_; + return false; + } + + return true; +} + +const std::string &TextGen::ToUpperString(std::string &str) +{ + for (char &i : str) { + i = static_cast(toupper(i)); + } + + return str; +} + +std::string TextGen::GetHeaderProtectMacro(const std::string &headerFileName) +{ + return std::string().append("HCS_CONFIG_").append(ToUpperString(outputNameBase_)).append("_HEADER_H"); +} + +uint32_t TextGen::GenNodeDefinition(const std::shared_ptr &node) +{ + auto structName = GenConfigStructName(node); + static std::set symbolSet; + + if (symbolSet.find(structName) != symbolSet.end()) { + return NOERR; + } else { + symbolSet.insert(structName); + } + + ofs_ << "struct " << structName << " {\n"; + + auto termIt = node->Child(); + while (termIt != nullptr) { + bool res = GenObjectDefinitionGen(termIt); + if (!res) { + return res; + } + termIt = termIt->Next(); + } + + ofs_ << "};\n\n"; + + return ofs_.good() ? NOERR : EOUTPUT; +} + +std::string TextGen::GenConfigStructName(const std::shared_ptr &node) +{ + return ToUpperCamelString(prefix_).append(ToUpperCamelString(moduleName_)).append(ToUpperCamelString(node->Name())); +} + +bool TextGen::GenObjectDefinitionGen(const std::shared_ptr& object) +{ + if (!object->IsNode() && !object->IsTerm()) { + return true; + } + + switch (object->Type()) { + case PARSEROP_CONFNODE: { + auto structName = GenConfigStructName(object); + auto node = ConfigNode::CastFrom(object); + auto nodeName = ToLowerCamelString(node->Name()); + if (node->GetNodeType() == NODE_TEMPLATE) { + ofs_ << Indent() << "const struct " << structName << "* " << nodeName << ";\n"; + ofs_ << Indent() << "uint16_t " << nodeName << "Size;\n"; + + } else if (node->GetNodeType() == NODE_INHERIT) { + return true; + } else { + ofs_ << Indent() << "struct " << structName << " " << nodeName << ";\n"; + } + break; + } + case PARSEROP_CONFTERM: + return GenTermDefinition(object); + default: + break; + } + + return ofs_.good(); +} + +bool TextGen::GenTermDefinition(const std::shared_ptr &term) +{ + auto value = term->Child(); + switch (value->Type()) { + case PARSEROP_ARRAY: { + auto array = ConfigArray::CastFrom(value); + if (IsInTemplate(term)) { + ofs_ << TAB << "const " << TypeToStr(array->ArrayType()) << "* " << term->Name() << ";\n"; + ofs_ << TAB << "uint32_t " << term->Name() << "Size;\n"; + } else { + ofs_ << TAB << TypeToStr(array->ArrayType()) << " " << term->Name() << "[" + << array->ArraySize() << "];\n"; + } + break; + } + case PARSEROP_UINT8: + case PARSEROP_UINT16: + case PARSEROP_UINT32: + case PARSEROP_UINT64: + case PARSEROP_STRING: + ofs_ << TAB << TypeToStr(value->Type()) << " " << term->Name() << ";\n"; + break; + case PARSEROP_NODEREF: { + auto structName = GenConfigStructName(ConfigTerm::CastFrom(term)->RefNode().lock()); + ofs_ << TAB << "const struct " << structName << "* " << term->Name() << ";\n"; + } + break; + default: + break; + } + + return ofs_.good(); +} + +bool TextGen::IsInTemplate(const std::shared_ptr &object) +{ + auto p = object->Parent(); + while (p != nullptr) { + if (p->IsNode() && ConfigNode::CastFrom(p)->GetNodeType() == NODE_TEMPLATE) { + return true; + } + p = p->Parent(); + } + return false; +} + +const std::string &TextGen::TypeToStr(uint32_t type) +{ + static std::map typeMap = { + {PARSEROP_UINT8, "uint8_t"}, + {PARSEROP_UINT16, "uint16_t"}, + {PARSEROP_UINT32, "uint32_t"}, + {PARSEROP_UINT64, "uint64_t"}, + {PARSEROP_STRING, "const char*"}, + }; + return typeMap[type]; +} + +bool TextGen::OutputImplGlobalVariables() +{ + auto forwardWalkFunc = [this](const std::shared_ptr& current, uint32_t depth) -> uint32_t { + return ImplementGenTraversal(current, depth); + }; + + auto backwardWalkFunc = [this](const std::shared_ptr& current, uint32_t depth) -> uint32_t { + return ImplementCloseBraceGen(current, depth); + }; + + return ast_->WalkRound(forwardWalkFunc, backwardWalkFunc); +} + +const std::string &TextGen::Indent(uint32_t times) +{ + static std::map indentMap; + auto indent = indentMap.find(times); + if (indent == indentMap.end()) { + auto str = std::string(); + for (uint32_t i = 0; i < times; ++i) { + str.append(TAB); + } + indentMap.emplace(std::pair(times, std::move(str))); + } + + return indentMap.at(times); +} + +uint32_t TextGen::ImplementCloseBraceGen(const std::shared_ptr &object, uint32_t depth) +{ + if (!object->IsNode() || ConfigNode::CastFrom(object)->GetNodeType() == NODE_INHERIT) { + return NOERR; + } + if (object == ast_->GetAstRoot()) { + ofs_ << "};\n"; + } else { + ofs_ << Indent(depth) << "},\n"; + } + return ofs_.good() ? NOERR : EOUTPUT; +} + +uint32_t TextGen::ImplementGenTraversal(const std::shared_ptr &object, uint32_t depth) +{ + if (!object->IsNode() && !object->IsTerm()) { + return NOERR; + } + + if (object->IsTerm() && IsInSubClassNode(object)) { + return NOERR; + } + + if (object == ast_->GetAstRoot()) { + auto structName = GenConfigStructName(object); + ofs_ << "static const struct " << structName << " " << rootVariableName_ << " = {\n"; + if (object->Child() == nullptr) { + ofs_ << "};\n"; + } + return ofs_.good() ? NOERR : EOUTPUT; + } + return ObjectImplementGen(object, depth); +} + +bool TextGen::IsInSubClassNode(const std::shared_ptr &object) +{ + std::shared_ptr obj = object; + while (obj != nullptr) { + if (obj->IsNode() && ConfigNode::CastFrom(obj)->GetNodeType() == NODE_INHERIT) { + return true; + } + obj = obj->Parent(); + } + return false; +} + +uint32_t TextGen::ObjectImplementGen(const std::shared_ptr &object, uint32_t depth) +{ + switch (object->Type()) { + case PARSEROP_CONFNODE: { + auto node = ConfigNode::CastFrom(object); + if (node->GetNodeType() != NODE_NOREF) { + return TemplateObjectImplGen(object, depth) ? EASTWALKBREAK : EOUTPUT; + } + ofs_ << Indent(depth) << '.' << node->Name() << " = {\n"; + if (node->Child() == nullptr) { + ofs_ << Indent(depth) << "},\n"; + } + break; + } + case PARSEROP_CONFTERM: + return PrintTermImplement(object, depth); + default: + return NOERR; + } + + return ofs_.good() ? NOERR : EOUTPUT; +} + +bool TextGen::TemplateObjectImplGen(const std::shared_ptr &object, uint32_t depth) +{ + auto node = ConfigNode::CastFrom(object); + if (node->GetNodeType() != NODE_TEMPLATE) { + return true; + } + + std::string varName = GenTemplateVariableName(object); + auto nodeName = ToLowerCamelString(node->Name()); + + ofs_ << Indent(depth) << '.' << nodeName << " = "; + if (node->InheritCount() != 0) { + ofs_ << varName; + } else { + ofs_ << '0'; + } + ofs_ << ",\n"; + ofs_ << Indent(depth) << '.' << nodeName << "Size = " << node->InheritCount() << ",\n"; + return ofs_.good(); +} + +std::string TextGen::GenTemplateVariableName(const std::shared_ptr &object) +{ + auto name = ToUpperCamelString(object->Name()); + auto sym = SymbolFind(name); + auto node = ConfigNode::CastFrom(object); + if (sym == nullptr) { + SymbolAdd(name, object); + } else if (sym->object != object && node->TemplateSignNum() == 0) { + sym->duplicateCount++; + node->SetTemplateSignNum(sym->duplicateCount); + } + + return node->TemplateSignNum() != 0 ? + std::string("g_").append(prefix_).append(name).append(std::to_string(node->TemplateSignNum())) : + std::string("g_").append(prefix_).append(name); +} + +std::shared_ptr TextGen::SymbolFind(const std::string &name) +{ + auto sym = symMap.find(name); + return sym == symMap.end() ? nullptr : sym->second; +} + +void TextGen::SymbolAdd(const std::string &name, const std::shared_ptr &object) +{ + auto sym = symMap.find(name); + if (sym != symMap.end()) { + sym->second->duplicateCount++; + } + symMap.insert(std::make_pair(std::string(name), std::make_shared(object, 1))); +} + +uint32_t TextGen::PrintTermImplement(const std::shared_ptr &object, uint32_t depth) +{ + auto term = ConfigTerm::CastFrom(object); + auto value = object->Child(); + switch (value->Type()) { + case PARSEROP_UINT8: + case PARSEROP_UINT16: /* fall-through */ + case PARSEROP_UINT32: /* fall-through */ + case PARSEROP_UINT64: /* fall-through */ + case PARSEROP_STRING: + ofs_ << Indent(depth) << '.' << term->Name() << " = "; + if (!PrintBaseTypeValue(value)) { + return EOUTPUT; + } + ofs_ << ",\n"; + break; + case PARSEROP_ARRAY: + return PrintArrayImplement(object, depth); + case PARSEROP_NODEREF: { + std::string refPath = HcsBuildObjectPath(term->RefNode().lock()); + ofs_ << Indent(depth) << '.' << term->Name() << " = &" << refPath << ",\n"; + break; + } + default: + break; + } + + return ofs_.good() ? NOERR : EOUTPUT; +} + +bool TextGen::PrintBaseTypeValue(const std::shared_ptr &object) +{ + switch (object->Type()) { + case PARSEROP_UINT8: /* fallthrough */ + case PARSEROP_UINT16: /* fallthrough */ + case PARSEROP_UINT32: /* fallthrough */ + case PARSEROP_UINT64: + ofs_ << "0x" << std::hex << object->IntegerValue(); + break; + case PARSEROP_STRING: + ofs_ << '"' << object->StringValue() << '"'; + break; + default: + break; + } + + return ofs_.good(); +} + +uint32_t TextGen::PrintArrayImplement(const std::shared_ptr &object, uint32_t depth) +{ + if (IsInSubClassNode(object)) { + return PrintArrayImplInSubClass(object, depth) ? NOERR : EOUTPUT; + } + + auto termContext = object->Child(); + ofs_ << Indent(depth) << '.' << object->Name() << " = { "; + + if (!HcsPrintArrayContent(termContext, depth + 1)) { + return EOUTPUT; + } + + ofs_ << " },\n"; + + return ofs_.good() ? NOERR : EOUTPUT; +} + +bool TextGen::PrintArrayImplInSubClass(const std::shared_ptr &object, uint32_t depth) +{ + auto array = ConfigArray::CastFrom(object->Child()); + auto arrayName = GenArrayName(object); + + ofs_ << Indent(depth) << '.' << object->Name() << " = " << arrayName << ",\n"; + ofs_ << Indent(depth) << '.' << object->Name() << "Size = " << std::to_string(array->ArraySize()) << ",\n"; + + return ofs_.good(); +} + +bool TextGen::HcsPrintArrayContent(const std::shared_ptr &object, uint32_t indent) +{ + constexpr uint32_t ELEMENT_PER_LINE = 16; + auto element = object->Child(); + uint32_t elementCount = 0; + while (element != nullptr) { + if (!PrintBaseTypeValue(element)) { + return false; + } + if (elementCount++ >= ELEMENT_PER_LINE) { + ofs_ << "\n" << Indent(indent); + } + element = element->Next(); + if (element != nullptr) { + ofs_ << ", "; + } + } + + return ofs_.good(); +} + +std::string TextGen::HcsBuildObjectPath(std::shared_ptr object) +{ + std::list> pathList; + auto p = object; + while (p != ast_->GetAstRoot()) { + pathList.push_back(p); + p = p->Parent(); + } + + pathList.reverse(); + + std::string path = rootVariableName_; + for (auto &it : pathList) { + path.append(".").append(it->Name()); + } + + return path; +} + +bool TextGen::OutputTemplateImpl() +{ + if (!OutputTemplateVariablesDeclare()) { + return false; + } + + return ast_->WalkBackward([this](const std::shared_ptr &object, uint32_t) -> uint32_t { + if (!object->IsNode() || + (object->IsNode() && ConfigNode::CastFrom(object)->GetNodeType() != NODE_TEMPLATE)) { + return NOERR; + } + auto node = ConfigNode::CastFrom(object); + if (node->InheritCount() == 0) { + return NOERR; + } + + ofs_ << "static const struct " << GenConfigStructName(object) << ' ' + << GenTemplateVariableName(object) << "[] = {\n"; + auto subClass = node->SubClasses(); + for (auto nodeObj : subClass) { + std::shared_ptr obj = std::shared_ptr(nodeObj, [](auto p) {}); + ofs_ << Indent() << '[' << ConfigNode::CastFrom(obj)->InheritIndex() << "] = {\n"; + if (!TemplateVariableGen(obj)) { + return EOUTPUT; + } + ofs_ << Indent() << "},\n"; + } + + ofs_ << "};\n\n"; + return ofs_.good() ? NOERR : EOUTPUT; + }); +} + +bool TextGen::OutputTemplateVariablesDeclare() +{ + return ast_->WalkBackward([this](const std::shared_ptr &object, uint32_t) -> uint32_t { + if (object->IsTerm() && object->Child()->IsArray()) { + return ArrayVariablesDeclareGen(object); + } else if (!object->IsNode() || + (object->IsNode() && ConfigNode::CastFrom(object)->GetNodeType() != NODE_TEMPLATE)) { + return NOERR; + } + auto node = ConfigNode::CastFrom(object); + if (node->InheritCount() == 0) { + return NOERR; + } + + auto structName = GenConfigStructName(object); + ofs_ << "static const struct " << GenConfigStructName(object) << ' ' << GenTemplateVariableName(object) + << "[];\n\n"; + + return ofs_.good() ? NOERR : EOUTPUT; + }); +} + +uint32_t TextGen::ArrayVariablesDeclareGen(const std::shared_ptr &object) +{ + if (!IsInSubClassNode(object)) { + return NOERR; + } + + auto arrayName = GenArrayName(object); + auto array = ConfigArray::CastFrom(object->Child()); + ofs_ << "static const " << TypeToStr(array->ArrayType()) << ' ' << arrayName << '[' << array->ArraySize() + << "] = {\n" << Indent(); + HcsPrintArrayContent(object->Child(), 1); + ofs_ << "\n};\n\n"; + + return ofs_.good() ? NOERR : EOUTPUT; +} + +std::string TextGen::GenArrayName(const std::shared_ptr &term) +{ + auto arrayName = std::string("g_hcsConfigArray").append(ToUpperCamelString(term->Name())); + auto t = ConfigTerm::CastFrom(term); + auto sym = SymbolFind(arrayName); + + if (sym == nullptr) { + SymbolAdd(arrayName, term); + t->SetSigNum(1); + } else if (t->SigNum() == 0){ + t->SetSigNum(sym->duplicateCount + 1); + sym->duplicateCount++; + } + + arrayName.append(std::to_string(t->SigNum())); + return arrayName; +} + +uint32_t TextGen::TemplateVariableGen(const std::shared_ptr &nodeObject) +{ + auto child = nodeObject->Child(); + while (child != nullptr) { + auto res = Ast::WalkRound(child, + [this](const std::shared_ptr& object, uint32_t depth) -> uint32_t { + return ObjectImplementGen(object, depth + 2); + }, + [this](const std::shared_ptr& object, uint32_t depth) -> uint32_t { + return ImplementCloseBraceGen(object, depth + 2); + }); + if (!res) { + return false; + } + child = child->Next(); + } + return true; +} + +bool TextGen::DuplicateNodeNameCheck() +{ + std::map> nodeMap; + + return ast_->WalkForward([&](const std::shared_ptr& current, uint32_t) -> uint32_t { + if (!current->IsNode() || IsInSubClassNode(current)) { + return NOERR; + } + + auto node = nodeMap.find(current->Name()); + if (node == nodeMap.end()) { + nodeMap[current->Name()] = current; + return NOERR; + } + + Logger().Error() << current->SourceInfo() << "duplicate node name at " << node->second->SourceInfo() << "\n" + << "To avoid redefining structures, not allow duplicate node name at text config mode"; + return EFAIL; + }); +} diff --git a/tools/hc-gen/src/text_gen.h b/tools/hc-gen/src/text_gen.h new file mode 100644 index 000000000..e165c10a8 --- /dev/null +++ b/tools/hc-gen/src/text_gen.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_TEXT_GENERATOR_H +#define HC_GEN_TEXT_GENERATOR_H + +#include +#include +#include +#include "generator.h" + +namespace OHOS { +namespace Hardware { +class TextGen : public Generator { +public: + explicit TextGen(std::shared_ptr ast); + + ~TextGen() override = default; + + bool Output() override; + +private: + bool Initialize(); + + bool HeaderOutput(); + + bool HeaderOutputTraversal(); + + bool ImplOutput(); + + bool InitOutput(const std::string &fileSuffix); + + bool DuplicateNodeNameCheck(); + + static std::string ToUpperCamelString(const std::string &str); + + static std::string ToLowerCamelString(const std::string &str); + + static std::string ToCamelString(const std::string &str); + + static const std::string &ToUpperString(std::string &str); + + std::string GetHeaderProtectMacro(const std::string &headerFileName); + + uint32_t GenNodeDefinition(const std::shared_ptr &node); + + std::string GenConfigStructName(const std::shared_ptr &node); + + bool GenObjectDefinitionGen(const std::shared_ptr& object); + + bool GenTermDefinition(const std::shared_ptr &term); + + static const std::string &TypeToStr(uint32_t type); + + static bool IsInTemplate(const std::shared_ptr &object); + + bool OutputImplGlobalVariables(); + + uint32_t ImplementGenTraversal(const std::shared_ptr &object, uint32_t depth); + + uint32_t ImplementCloseBraceGen(const std::shared_ptr &object, uint32_t depth); + + static const std::string & Indent(uint32_t times = 1); + + static bool IsInSubClassNode(const std::shared_ptr &object); + + uint32_t ObjectImplementGen(const std::shared_ptr &object, uint32_t depth); + + bool TemplateObjectImplGen(const std::shared_ptr &object, uint32_t depth); + + std::string GenTemplateVariableName(const std::shared_ptr &object); + + struct Symbol { + Symbol(std::shared_ptr obj, uint32_t c) : object(std::move(obj)), duplicateCount(c) {}; + ~Symbol() = default; + std::shared_ptr object; + uint32_t duplicateCount; + }; + + std::shared_ptr SymbolFind(const std::string &name); + + void SymbolAdd(const std::string &name, const std::shared_ptr& object); + + std::ofstream ofs_; + std::string outputFileName_; + std::string outputNameBase_; + std::string prefix_; + std::string moduleName_; + std::string rootVariableName_; + std::map> symMap; + + uint32_t PrintTermImplement(const std::shared_ptr &object, uint32_t depth); + + bool PrintBaseTypeValue(const std::shared_ptr& object); + + uint32_t PrintArrayImplement(const std::shared_ptr &object, uint32_t depth); + + bool PrintArrayImplInSubClass(const std::shared_ptr &object, uint32_t depth); + + bool HcsPrintArrayContent(const std::shared_ptr& object, uint32_t indent); + + std::string HcsBuildObjectPath(std::shared_ptr object); + + bool OutputTemplateImpl(); + + bool OutputTemplateVariablesDeclare(); + + uint32_t ArrayVariablesDeclareGen(const std::shared_ptr& object); + + std::string GenArrayName(const std::shared_ptr& term); + + uint32_t TemplateVariableGen(const std::shared_ptr& nodeObject); +}; + +} // Hardware +} // OHOS +#endif // HC_GEN_TEXT_GENERATOR_H diff --git a/tools/hc-gen/src/token.cpp b/tools/hc-gen/src/token.cpp new file mode 100644 index 000000000..134444ff5 --- /dev/null +++ b/tools/hc-gen/src/token.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "token.h" +#include +#include + +using namespace OHOS::Hardware; + +std::string OHOS::Hardware::TokenType2String(int32_t type) +{ + static std::map tokenTypeMap = { + {NUMBER, "NUMBER"}, + {TEMPLATE, "TEMPLATE"}, + {LITERAL, "LITERAL"}, + {ROOT, "ROOT"}, + {INCLUDE, "INCLUDE"}, + {DELETE, "DELETE"}, + {STRING, "STRING"}, + {REF_PATH, "REF_PATH"}, + {FILE_PATH, "FILE_PATH"} + }; + + std::string str; + if (type < '~') { + str.push_back(static_cast(type)); + return str; + } else if (tokenTypeMap.find(type) != tokenTypeMap.end()) { + str = tokenTypeMap[type]; + } + + return str; +} + +std::ostream &OHOS::Hardware::operator<<(std::ostream &stream, const OHOS::Hardware::Token &t) +{ + stream << "Token: type: " << std::setw(8) << ::std::left << TokenType2String(t.type).data(); + stream << " value: " << std::setw(8) << ::std::left; + t.type != NUMBER ? stream << std::setw(20) << t.strval.data() + : stream << std::setw(0) << "0x" << std::setw(18) << std::hex << t.numval; + stream << " lineno:" << t.lineNo; + return stream; +} + +bool Token::operator==(int32_t t) const +{ + return t == type; +} + +bool Token::operator!=(int32_t t) const +{ + return t != type; +} +bool Token::operator==(Token &t) const +{ + return t.type == type && t.numval == numval && t.strval == strval; +} + +bool Token::operator!=(Token &t) const +{ + return t.type != type || t.numval != numval || t.strval != strval; +} + + diff --git a/tools/hc-gen/src/token.h b/tools/hc-gen/src/token.h new file mode 100644 index 000000000..80c16d255 --- /dev/null +++ b/tools/hc-gen/src/token.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_TOKEN_H +#define HC_GEN_TOKEN_H + +#include +#include +#include +#include + +namespace OHOS { +namespace Hardware { + +enum TokenType { + NUMBER = 256, + TEMPLATE, + LITERAL, + STRING, + REF_PATH, + FILE_PATH, + ROOT, + INCLUDE, + DELETE, +}; + +struct Token { + int32_t type; + std::string strval; + uint64_t numval; + std::shared_ptr src; + int32_t lineNo; + bool operator==(Token &t) const; + bool operator!=(Token &t) const; + bool operator==(int32_t type) const; + bool operator!=(int32_t type) const; + friend std::ostream &operator<<(std::ostream &stream, const Token &t); +}; + +std::string TokenType2String(int32_t type); + +} // Hardware +} // OHOS + + + +#endif // HC_GEN_TOKEN_H diff --git a/tools/hc-gen/src/types.h b/tools/hc-gen/src/types.h new file mode 100644 index 000000000..5cdfc79af --- /dev/null +++ b/tools/hc-gen/src/types.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HC_GEN_TYPES_H +#define HC_GEN_TYPES_H + +#define ALIGN_SIZE 4 +#define TAB " " +#define TAB_SIZE 4 +#define OPCODE_BYTE_WIDTH 1 + +#define BYTE_SIZE 1 +#define WORD_SIZE 2 +#define DWORD_SIZE 4 +#define QWORD_SIZE 8 + +#define UNIX_SEPARATOR '/' +#define WIN_SEPARATOR '\\' + +#ifdef OS_WIN +#define OS_SEPARATOR WIN_SEPARATOR +#else +#define OS_SEPARATOR UNIX_SEPARATOR +#endif + +enum HcsErrorNo { + NOERR = 0, /* No error */ + EFAIL, /* Process fail */ + EOOM, /* Out of memory */ + EOPTION, /* Option error */ + EREOPENF, /* Reopen argument */ + EINVALF, /* Invalid file */ + EINVALARG, /* Invalid argument */ + EDECOMP, /* Decompile error */ + EOUTPUT, /* Output error */ + EASTWALKBREAK, /* Break ast walk */ +}; + +#endif // HC_GEN_TYPES_H diff --git a/tools/hc-gen/test/01_empty_file_ei/case.hcs b/tools/hc-gen/test/01_empty_file_ei/case.hcs new file mode 100755 index 000000000..e69de29bb diff --git a/tools/hc-gen/test/01_empty_file_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/01_empty_file_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..cf9382bda --- /dev/null +++ b/tools/hc-gen/test/01_empty_file_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./01_empty_file_ei/case.hcs: Empty hcs file \ No newline at end of file diff --git a/tools/hc-gen/test/01_empty_file_ei/golden_text_compile_result.txt b/tools/hc-gen/test/01_empty_file_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..cf9382bda --- /dev/null +++ b/tools/hc-gen/test/01_empty_file_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./01_empty_file_ei/case.hcs: Empty hcs file \ No newline at end of file diff --git a/tools/hc-gen/test/02_empty_root_ei/case.hcs b/tools/hc-gen/test/02_empty_root_ei/case.hcs new file mode 100755 index 000000000..d5aedd2bf --- /dev/null +++ b/tools/hc-gen/test/02_empty_root_ei/case.hcs @@ -0,0 +1,3 @@ +root { + +} \ No newline at end of file diff --git a/tools/hc-gen/test/02_empty_root_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/02_empty_root_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..7355d5d1f --- /dev/null +++ b/tools/hc-gen/test/02_empty_root_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./02_empty_root_ei/case.hcs:1 miss 'module' attribute under root node \ No newline at end of file diff --git a/tools/hc-gen/test/02_empty_root_ei/golden_text_compile_result.txt b/tools/hc-gen/test/02_empty_root_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..7355d5d1f --- /dev/null +++ b/tools/hc-gen/test/02_empty_root_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./02_empty_root_ei/case.hcs:1 miss 'module' attribute under root node \ No newline at end of file diff --git a/tools/hc-gen/test/03_empty_node/case.hcs b/tools/hc-gen/test/03_empty_node/case.hcs new file mode 100755 index 000000000..29feadfd2 --- /dev/null +++ b/tools/hc-gen/test/03_empty_node/case.hcs @@ -0,0 +1,6 @@ +root { + module = "test"; + foo { + + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/03_empty_node/golden.c.gen b/tools/hc-gen/test/03_empty_node/golden.c.gen new file mode 100644 index 000000000..4f3e73b80 --- /dev/null +++ b/tools/hc-gen/test/03_empty_node/golden.c.gen @@ -0,0 +1,16 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/03_empty_node/golden.d.hcs b/tools/hc-gen/test/03_empty_node/golden.d.hcs new file mode 100644 index 000000000..93516fe78 --- /dev/null +++ b/tools/hc-gen/test/03_empty_node/golden.d.hcs @@ -0,0 +1,9 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + } +} diff --git a/tools/hc-gen/test/03_empty_node/golden.h.gen b/tools/hc-gen/test/03_empty_node/golden.h.gen new file mode 100644 index 000000000..a854dd94e --- /dev/null +++ b/tools/hc-gen/test/03_empty_node/golden.h.gen @@ -0,0 +1,20 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/03_empty_node/golden.hcb b/tools/hc-gen/test/03_empty_node/golden.hcb new file mode 100644 index 000000000..37f6c91ee --- /dev/null +++ b/tools/hc-gen/test/03_empty_node/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAACEAAAABcm9vdAAXAAAAAm1vZHVsZQAUdGVzdAABZm9vAAAAAAA= \ No newline at end of file diff --git a/tools/hc-gen/test/03_empty_node/golden_binary_compile_result.txt b/tools/hc-gen/test/03_empty_node/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/03_empty_node/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/03_empty_node/golden_text_compile_result.txt b/tools/hc-gen/test/03_empty_node/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/03_empty_node/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/04_number_term/case.hcs b/tools/hc-gen/test/04_number_term/case.hcs new file mode 100755 index 000000000..ea27b93e2 --- /dev/null +++ b/tools/hc-gen/test/04_number_term/case.hcs @@ -0,0 +1,9 @@ +root { + module = "test"; + term1 = 1; + term2 = 0x2; + term3 = 0b11; + term_uint16 = 0xffff; + term_uint32 = 0xffffffff; + term_uint64 = 0xffffffffff; +} \ No newline at end of file diff --git a/tools/hc-gen/test/04_number_term/golden.c.gen b/tools/hc-gen/test/04_number_term/golden.c.gen new file mode 100644 index 000000000..d5a05a678 --- /dev/null +++ b/tools/hc-gen/test/04_number_term/golden.c.gen @@ -0,0 +1,20 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .term1 = 0x1, + .term2 = 0x2, + .term3 = 0x3, + .term_uint16 = 0xffff, + .term_uint32 = 0xffffffff, + .term_uint64 = 0xffffffffff, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/04_number_term/golden.d.hcs b/tools/hc-gen/test/04_number_term/golden.d.hcs new file mode 100644 index 000000000..01f167cbd --- /dev/null +++ b/tools/hc-gen/test/04_number_term/golden.d.hcs @@ -0,0 +1,13 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + term1 = 0x1; + term2 = 0x2; + term3 = 0x3; + term_uint16 = 0xFFFF; + term_uint32 = 0xFFFFFFFF; + term_uint64 = 0xFFFFFFFFFF; +} diff --git a/tools/hc-gen/test/04_number_term/golden.h.gen b/tools/hc-gen/test/04_number_term/golden.h.gen new file mode 100644 index 000000000..68206b966 --- /dev/null +++ b/tools/hc-gen/test/04_number_term/golden.h.gen @@ -0,0 +1,22 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestRoot { + const char* module; + uint8_t term1; + uint8_t term2; + uint8_t term3; + uint16_t term_uint16; + uint32_t term_uint32; + uint64_t term_uint64; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/04_number_term/golden.hcb b/tools/hc-gen/test/04_number_term/golden.hcb new file mode 100644 index 000000000..f55d00ecd --- /dev/null +++ b/tools/hc-gen/test/04_number_term/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAGsAAAABcm9vdABhAAAAAm1vZHVsZQAUdGVzdAACdGVybTEAEAECdGVybTIAEAICdGVybTMAEAMCdGVybV91aW50MTYAEf//AnRlcm1fdWludDMyABL/////AnRlcm1fdWludDY0ABP//////wAAAA== \ No newline at end of file diff --git a/tools/hc-gen/test/04_number_term/golden_binary_compile_result.txt b/tools/hc-gen/test/04_number_term/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/04_number_term/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/04_number_term/golden_text_compile_result.txt b/tools/hc-gen/test/04_number_term/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/04_number_term/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/05_string_term/case.hcs b/tools/hc-gen/test/05_string_term/case.hcs new file mode 100755 index 000000000..bf7b87734 --- /dev/null +++ b/tools/hc-gen/test/05_string_term/case.hcs @@ -0,0 +1,4 @@ +root { + module = "test"; + term1 = "hello"; +} \ No newline at end of file diff --git a/tools/hc-gen/test/05_string_term/golden.c.gen b/tools/hc-gen/test/05_string_term/golden.c.gen new file mode 100644 index 000000000..5ef6af666 --- /dev/null +++ b/tools/hc-gen/test/05_string_term/golden.c.gen @@ -0,0 +1,15 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .term1 = "hello", +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/05_string_term/golden.d.hcs b/tools/hc-gen/test/05_string_term/golden.d.hcs new file mode 100644 index 000000000..6a7470d11 --- /dev/null +++ b/tools/hc-gen/test/05_string_term/golden.d.hcs @@ -0,0 +1,8 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + term1 = "hello"; +} diff --git a/tools/hc-gen/test/05_string_term/golden.h.gen b/tools/hc-gen/test/05_string_term/golden.h.gen new file mode 100644 index 000000000..9cca9358b --- /dev/null +++ b/tools/hc-gen/test/05_string_term/golden.h.gen @@ -0,0 +1,17 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestRoot { + const char* module; + const char* term1; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/05_string_term/golden.hcb b/tools/hc-gen/test/05_string_term/golden.hcb new file mode 100644 index 000000000..d07bf7bfb --- /dev/null +++ b/tools/hc-gen/test/05_string_term/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAACYAAAABcm9vdAAcAAAAAm1vZHVsZQAUdGVzdAACdGVybTEAFGhlbGxvAA== \ No newline at end of file diff --git a/tools/hc-gen/test/05_string_term/golden_binary_compile_result.txt b/tools/hc-gen/test/05_string_term/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/05_string_term/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/05_string_term/golden_text_compile_result.txt b/tools/hc-gen/test/05_string_term/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/05_string_term/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/06_number_array/case.hcs b/tools/hc-gen/test/06_number_array/case.hcs new file mode 100755 index 000000000..d6e99cd21 --- /dev/null +++ b/tools/hc-gen/test/06_number_array/case.hcs @@ -0,0 +1,4 @@ +root { + module = "test"; + term1 = [0x1,0x2,0xffffffffff]; +} \ No newline at end of file diff --git a/tools/hc-gen/test/06_number_array/golden.c.gen b/tools/hc-gen/test/06_number_array/golden.c.gen new file mode 100644 index 000000000..0f834dbf5 --- /dev/null +++ b/tools/hc-gen/test/06_number_array/golden.c.gen @@ -0,0 +1,15 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .term1 = { 0x1, 0x2, 0xffffffffff }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/06_number_array/golden.d.hcs b/tools/hc-gen/test/06_number_array/golden.d.hcs new file mode 100644 index 000000000..b441e385d --- /dev/null +++ b/tools/hc-gen/test/06_number_array/golden.d.hcs @@ -0,0 +1,8 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + term1 = [0x1, 0x2, 0xFFFFFFFFFF]; +} diff --git a/tools/hc-gen/test/06_number_array/golden.h.gen b/tools/hc-gen/test/06_number_array/golden.h.gen new file mode 100644 index 000000000..c38db1ad1 --- /dev/null +++ b/tools/hc-gen/test/06_number_array/golden.h.gen @@ -0,0 +1,17 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestRoot { + const char* module; + uint64_t term1[3]; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/06_number_array/golden.hcb b/tools/hc-gen/test/06_number_array/golden.hcb new file mode 100644 index 000000000..22273be10 --- /dev/null +++ b/tools/hc-gen/test/06_number_array/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAC8AAAABcm9vdAAlAAAAAm1vZHVsZQAUdGVzdAACdGVybTEABAMAEAEQAhP//////wAAAA== \ No newline at end of file diff --git a/tools/hc-gen/test/06_number_array/golden_binary_compile_result.txt b/tools/hc-gen/test/06_number_array/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/06_number_array/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/06_number_array/golden_text_compile_result.txt b/tools/hc-gen/test/06_number_array/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/06_number_array/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/07_string_array/case.hcs b/tools/hc-gen/test/07_string_array/case.hcs new file mode 100755 index 000000000..5eb7d7719 --- /dev/null +++ b/tools/hc-gen/test/07_string_array/case.hcs @@ -0,0 +1,4 @@ +root { + module = "test"; + term1 = ["hello", "world"]; +} \ No newline at end of file diff --git a/tools/hc-gen/test/07_string_array/golden.c.gen b/tools/hc-gen/test/07_string_array/golden.c.gen new file mode 100644 index 000000000..9addf5376 --- /dev/null +++ b/tools/hc-gen/test/07_string_array/golden.c.gen @@ -0,0 +1,15 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .term1 = { "hello", "world" }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/07_string_array/golden.d.hcs b/tools/hc-gen/test/07_string_array/golden.d.hcs new file mode 100644 index 000000000..a7c98954c --- /dev/null +++ b/tools/hc-gen/test/07_string_array/golden.d.hcs @@ -0,0 +1,8 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + term1 = ["hello", "world"]; +} diff --git a/tools/hc-gen/test/07_string_array/golden.h.gen b/tools/hc-gen/test/07_string_array/golden.h.gen new file mode 100644 index 000000000..249e501d6 --- /dev/null +++ b/tools/hc-gen/test/07_string_array/golden.h.gen @@ -0,0 +1,17 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestRoot { + const char* module; + const char* term1[2]; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/07_string_array/golden.hcb b/tools/hc-gen/test/07_string_array/golden.hcb new file mode 100644 index 000000000..4401f5929 --- /dev/null +++ b/tools/hc-gen/test/07_string_array/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAADAAAAABcm9vdAAmAAAAAm1vZHVsZQAUdGVzdAACdGVybTEABAIAFGhlbGxvABR3b3JsZAA= \ No newline at end of file diff --git a/tools/hc-gen/test/07_string_array/golden_binary_compile_result.txt b/tools/hc-gen/test/07_string_array/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/07_string_array/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/07_string_array/golden_text_compile_result.txt b/tools/hc-gen/test/07_string_array/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/07_string_array/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/08_term_ref/case.hcs b/tools/hc-gen/test/08_term_ref/case.hcs new file mode 100755 index 000000000..65a526044 --- /dev/null +++ b/tools/hc-gen/test/08_term_ref/case.hcs @@ -0,0 +1,12 @@ +root { + module = "test"; + foo { + term1 = 1; + term2 = 0x2; + term3 = 0b11; + } + + bar { + term1 = &root.bar; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/08_term_ref/golden.c.gen b/tools/hc-gen/test/08_term_ref/golden.c.gen new file mode 100644 index 000000000..d068d0264 --- /dev/null +++ b/tools/hc-gen/test/08_term_ref/golden.c.gen @@ -0,0 +1,22 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + .term1 = 0x1, + .term2 = 0x2, + .term3 = 0x3, + }, + .bar = { + .term1 = &g_hdfConfigTestModuleRoot.bar, + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/08_term_ref/golden.d.hcs b/tools/hc-gen/test/08_term_ref/golden.d.hcs new file mode 100644 index 000000000..c80e5ffc2 --- /dev/null +++ b/tools/hc-gen/test/08_term_ref/golden.d.hcs @@ -0,0 +1,15 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + term1 = 0x1; + term2 = 0x2; + term3 = 0x3; + } + bar { + term1 = &root.bar; + } +} diff --git a/tools/hc-gen/test/08_term_ref/golden.h.gen b/tools/hc-gen/test/08_term_ref/golden.h.gen new file mode 100644 index 000000000..43f67cc59 --- /dev/null +++ b/tools/hc-gen/test/08_term_ref/golden.h.gen @@ -0,0 +1,28 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { + uint8_t term1; + uint8_t term2; + uint8_t term3; +}; + +struct HdfConfigTestBar { + const struct HdfConfigTestBar* term1; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; + struct HdfConfigTestBar bar; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/08_term_ref/golden.hcb b/tools/hc-gen/test/08_term_ref/golden.hcb new file mode 100644 index 000000000..b8deb73b9 --- /dev/null +++ b/tools/hc-gen/test/08_term_ref/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAFEAAAABcm9vdABHAAAAAm1vZHVsZQAUdGVzdAABZm9vABsAAAACdGVybTEAEAECdGVybTIAEAICdGVybTMAEAMBYmFyAAwAAAACdGVybTEAA1AAAAA= \ No newline at end of file diff --git a/tools/hc-gen/test/08_term_ref/golden_binary_compile_result.txt b/tools/hc-gen/test/08_term_ref/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/08_term_ref/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/08_term_ref/golden_text_compile_result.txt b/tools/hc-gen/test/08_term_ref/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/08_term_ref/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/09_node_nested/case.hcs b/tools/hc-gen/test/09_node_nested/case.hcs new file mode 100755 index 000000000..bd8f7f02b --- /dev/null +++ b/tools/hc-gen/test/09_node_nested/case.hcs @@ -0,0 +1,11 @@ +root { + module = "test"; + foo { + foo1 { + term1 = "hello"; + bar { + term1 = "world"; + } + } + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/09_node_nested/golden.c.gen b/tools/hc-gen/test/09_node_nested/golden.c.gen new file mode 100644 index 000000000..383be063a --- /dev/null +++ b/tools/hc-gen/test/09_node_nested/golden.c.gen @@ -0,0 +1,22 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + .foo1 = { + .term1 = "hello", + .bar = { + .term1 = "world", + }, + }, + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/09_node_nested/golden.d.hcs b/tools/hc-gen/test/09_node_nested/golden.d.hcs new file mode 100644 index 000000000..18685506f --- /dev/null +++ b/tools/hc-gen/test/09_node_nested/golden.d.hcs @@ -0,0 +1,15 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + foo1 { + term1 = "hello"; + bar { + term1 = "world"; + } + } + } +} diff --git a/tools/hc-gen/test/09_node_nested/golden.h.gen b/tools/hc-gen/test/09_node_nested/golden.h.gen new file mode 100644 index 000000000..f387da949 --- /dev/null +++ b/tools/hc-gen/test/09_node_nested/golden.h.gen @@ -0,0 +1,30 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestBar { + const char* term1; +}; + +struct HdfConfigTestFoo1 { + const char* term1; + struct HdfConfigTestBar bar; +}; + +struct HdfConfigTestFoo { + struct HdfConfigTestFoo1 foo1; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/09_node_nested/golden.hcb b/tools/hc-gen/test/09_node_nested/golden.hcb new file mode 100644 index 000000000..8684ee8d3 --- /dev/null +++ b/tools/hc-gen/test/09_node_nested/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAFAAAAABcm9vdABGAAAAAm1vZHVsZQAUdGVzdAABZm9vAC8AAAABZm9vMQAlAAAAAnRlcm0xABRoZWxsbwABYmFyAA4AAAACdGVybTEAFHdvcmxkAA== \ No newline at end of file diff --git a/tools/hc-gen/test/09_node_nested/golden_binary_compile_result.txt b/tools/hc-gen/test/09_node_nested/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/09_node_nested/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/09_node_nested/golden_text_compile_result.txt b/tools/hc-gen/test/09_node_nested/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/09_node_nested/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/10_node_copy/case.hcs b/tools/hc-gen/test/10_node_copy/case.hcs new file mode 100755 index 000000000..94bf7e040 --- /dev/null +++ b/tools/hc-gen/test/10_node_copy/case.hcs @@ -0,0 +1,13 @@ +root { + module = "test"; + foo { + term1 = 1; + term2 = 0x2; + term3 = 0b11; + } + + bar : foo { + term1 = 2; + term4 = "hello"; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/10_node_copy/golden.c.gen b/tools/hc-gen/test/10_node_copy/golden.c.gen new file mode 100644 index 000000000..0a3867f6f --- /dev/null +++ b/tools/hc-gen/test/10_node_copy/golden.c.gen @@ -0,0 +1,25 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + .term1 = 0x1, + .term2 = 0x2, + .term3 = 0x3, + }, + .bar = { + .term1 = 0x2, + .term4 = "hello", + .term2 = 0x2, + .term3 = 0x3, + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/10_node_copy/golden.d.hcs b/tools/hc-gen/test/10_node_copy/golden.d.hcs new file mode 100644 index 000000000..4688e2ff6 --- /dev/null +++ b/tools/hc-gen/test/10_node_copy/golden.d.hcs @@ -0,0 +1,18 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + term1 = 0x1; + term2 = 0x2; + term3 = 0x3; + } + bar { + term1 = 0x2; + term4 = "hello"; + term2 = 0x2; + term3 = 0x3; + } +} diff --git a/tools/hc-gen/test/10_node_copy/golden.h.gen b/tools/hc-gen/test/10_node_copy/golden.h.gen new file mode 100644 index 000000000..29ee3835f --- /dev/null +++ b/tools/hc-gen/test/10_node_copy/golden.h.gen @@ -0,0 +1,31 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { + uint8_t term1; + uint8_t term2; + uint8_t term3; +}; + +struct HdfConfigTestBar { + uint8_t term1; + const char* term4; + uint8_t term2; + uint8_t term3; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; + struct HdfConfigTestBar bar; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/10_node_copy/golden.hcb b/tools/hc-gen/test/10_node_copy/golden.hcb new file mode 100644 index 000000000..018cf2893 --- /dev/null +++ b/tools/hc-gen/test/10_node_copy/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAG4AAAABcm9vdABkAAAAAm1vZHVsZQAUdGVzdAABZm9vABsAAAACdGVybTEAEAECdGVybTIAEAICdGVybTMAEAMBYmFyACkAAAACdGVybTEAEAICdGVybTQAFGhlbGxvAAJ0ZXJtMgAQAgJ0ZXJtMwAQAw== \ No newline at end of file diff --git a/tools/hc-gen/test/10_node_copy/golden_binary_compile_result.txt b/tools/hc-gen/test/10_node_copy/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/10_node_copy/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/10_node_copy/golden_text_compile_result.txt b/tools/hc-gen/test/10_node_copy/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/10_node_copy/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/11_case_node_ref/case.hcs b/tools/hc-gen/test/11_case_node_ref/case.hcs new file mode 100755 index 000000000..ecf452633 --- /dev/null +++ b/tools/hc-gen/test/11_case_node_ref/case.hcs @@ -0,0 +1,13 @@ +root { + module = "test"; + foo { + term1 = 1; + term2 = 0x2; + term3 = 0b11; + } + + bar : &foo { + term1 = 2; + term4 = "world"; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/11_case_node_ref/golden.c.gen b/tools/hc-gen/test/11_case_node_ref/golden.c.gen new file mode 100644 index 000000000..4b4615608 --- /dev/null +++ b/tools/hc-gen/test/11_case_node_ref/golden.c.gen @@ -0,0 +1,20 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + .term1 = 0x2, + .term2 = 0x2, + .term3 = 0x3, + .term4 = "world", + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/11_case_node_ref/golden.d.hcs b/tools/hc-gen/test/11_case_node_ref/golden.d.hcs new file mode 100644 index 000000000..a17721521 --- /dev/null +++ b/tools/hc-gen/test/11_case_node_ref/golden.d.hcs @@ -0,0 +1,13 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + term1 = 0x2; + term2 = 0x2; + term3 = 0x3; + term4 = "world"; + } +} diff --git a/tools/hc-gen/test/11_case_node_ref/golden.h.gen b/tools/hc-gen/test/11_case_node_ref/golden.h.gen new file mode 100644 index 000000000..6c6427ec3 --- /dev/null +++ b/tools/hc-gen/test/11_case_node_ref/golden.h.gen @@ -0,0 +1,24 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { + uint8_t term1; + uint8_t term2; + uint8_t term3; + const char* term4; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/11_case_node_ref/golden.hcb b/tools/hc-gen/test/11_case_node_ref/golden.hcb new file mode 100644 index 000000000..0d630d77c --- /dev/null +++ b/tools/hc-gen/test/11_case_node_ref/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAEoAAAABcm9vdABAAAAAAm1vZHVsZQAUdGVzdAABZm9vACkAAAACdGVybTEAEAICdGVybTIAEAICdGVybTMAEAMCdGVybTQAFHdvcmxkAA== \ No newline at end of file diff --git a/tools/hc-gen/test/11_case_node_ref/golden_binary_compile_result.txt b/tools/hc-gen/test/11_case_node_ref/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/11_case_node_ref/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/11_case_node_ref/golden_text_compile_result.txt b/tools/hc-gen/test/11_case_node_ref/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/11_case_node_ref/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/12_include_insert/base.hcs b/tools/hc-gen/test/12_include_insert/base.hcs new file mode 100755 index 000000000..2722fd67c --- /dev/null +++ b/tools/hc-gen/test/12_include_insert/base.hcs @@ -0,0 +1,8 @@ +root { + module = "test"; + foo { + term1 = 1; + term2 = 0x2; + term3 = 0b11; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/12_include_insert/case.hcs b/tools/hc-gen/test/12_include_insert/case.hcs new file mode 100755 index 000000000..569de95e4 --- /dev/null +++ b/tools/hc-gen/test/12_include_insert/case.hcs @@ -0,0 +1,11 @@ +#include "base.hcs" + +root { + bar { + term = [0,1]; + } + foo { + term1 = 2; + term4 = "world"; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/12_include_insert/golden.c.gen b/tools/hc-gen/test/12_include_insert/golden.c.gen new file mode 100644 index 000000000..70d0d1a5d --- /dev/null +++ b/tools/hc-gen/test/12_include_insert/golden.c.gen @@ -0,0 +1,23 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + .term1 = 0x2, + .term2 = 0x2, + .term3 = 0x3, + .term4 = "world", + }, + .bar = { + .term = { 0x0, 0x1 }, + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/12_include_insert/golden.d.hcs b/tools/hc-gen/test/12_include_insert/golden.d.hcs new file mode 100644 index 000000000..3b73d3485 --- /dev/null +++ b/tools/hc-gen/test/12_include_insert/golden.d.hcs @@ -0,0 +1,16 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + term1 = 0x2; + term2 = 0x2; + term3 = 0x3; + term4 = "world"; + } + bar { + term = [0x0, 0x1]; + } +} diff --git a/tools/hc-gen/test/12_include_insert/golden.h.gen b/tools/hc-gen/test/12_include_insert/golden.h.gen new file mode 100644 index 000000000..a21e5c27f --- /dev/null +++ b/tools/hc-gen/test/12_include_insert/golden.h.gen @@ -0,0 +1,29 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { + uint8_t term1; + uint8_t term2; + uint8_t term3; + const char* term4; +}; + +struct HdfConfigTestBar { + uint8_t term[2]; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; + struct HdfConfigTestBar bar; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/12_include_insert/golden.hcb b/tools/hc-gen/test/12_include_insert/golden.hcb new file mode 100644 index 000000000..4d2b7a61b --- /dev/null +++ b/tools/hc-gen/test/12_include_insert/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAGAAAAABcm9vdABWAAAAAm1vZHVsZQAUdGVzdAABZm9vACkAAAACdGVybTEAEAICdGVybTIAEAICdGVybTMAEAMCdGVybTQAFHdvcmxkAAFiYXIADQAAAAJ0ZXJtAAQCABAAEAE= \ No newline at end of file diff --git a/tools/hc-gen/test/12_include_insert/golden_binary_compile_result.txt b/tools/hc-gen/test/12_include_insert/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/12_include_insert/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/12_include_insert/golden_text_compile_result.txt b/tools/hc-gen/test/12_include_insert/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/12_include_insert/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/13_include_modify/base.hcs b/tools/hc-gen/test/13_include_modify/base.hcs new file mode 100755 index 000000000..dc6fe07c2 --- /dev/null +++ b/tools/hc-gen/test/13_include_modify/base.hcs @@ -0,0 +1,10 @@ +root { + module = "test"; + foo { + term1 = [2,3]; + } + bar { + term1 = 1; + term4 = "hello"; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/13_include_modify/case.hcs b/tools/hc-gen/test/13_include_modify/case.hcs new file mode 100755 index 000000000..f416849e6 --- /dev/null +++ b/tools/hc-gen/test/13_include_modify/case.hcs @@ -0,0 +1,11 @@ +#include "base.hcs" + +root { + foo { + term = [0,1]; + } + bar { + term1 = 2; + term4 = "world"; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/13_include_modify/golden.c.gen b/tools/hc-gen/test/13_include_modify/golden.c.gen new file mode 100644 index 000000000..806dadf79 --- /dev/null +++ b/tools/hc-gen/test/13_include_modify/golden.c.gen @@ -0,0 +1,22 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + .term1 = { 0x2, 0x3 }, + .term = { 0x0, 0x1 }, + }, + .bar = { + .term1 = 0x2, + .term4 = "world", + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/13_include_modify/golden.d.hcs b/tools/hc-gen/test/13_include_modify/golden.d.hcs new file mode 100644 index 000000000..8b8618f36 --- /dev/null +++ b/tools/hc-gen/test/13_include_modify/golden.d.hcs @@ -0,0 +1,15 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + term1 = [0x2, 0x3]; + term = [0x0, 0x1]; + } + bar { + term1 = 0x2; + term4 = "world"; + } +} diff --git a/tools/hc-gen/test/13_include_modify/golden.h.gen b/tools/hc-gen/test/13_include_modify/golden.h.gen new file mode 100644 index 000000000..ac1a9c576 --- /dev/null +++ b/tools/hc-gen/test/13_include_modify/golden.h.gen @@ -0,0 +1,28 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { + uint8_t term1[2]; + uint8_t term[2]; +}; + +struct HdfConfigTestBar { + uint8_t term1; + const char* term4; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; + struct HdfConfigTestBar bar; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/13_include_modify/golden.hcb b/tools/hc-gen/test/13_include_modify/golden.hcb new file mode 100644 index 000000000..7124f159c --- /dev/null +++ b/tools/hc-gen/test/13_include_modify/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAFwAAAABcm9vdABSAAAAAm1vZHVsZQAUdGVzdAABZm9vABsAAAACdGVybTEABAIAEAIQAwJ0ZXJtAAQCABAAEAEBYmFyABcAAAACdGVybTEAEAICdGVybTQAFHdvcmxkAA== \ No newline at end of file diff --git a/tools/hc-gen/test/13_include_modify/golden_binary_compile_result.txt b/tools/hc-gen/test/13_include_modify/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/13_include_modify/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/13_include_modify/golden_text_compile_result.txt b/tools/hc-gen/test/13_include_modify/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/13_include_modify/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/14_include_delete/base.hcs b/tools/hc-gen/test/14_include_delete/base.hcs new file mode 100755 index 000000000..0f605d517 --- /dev/null +++ b/tools/hc-gen/test/14_include_delete/base.hcs @@ -0,0 +1,11 @@ +root { + foo { + term1 = 1; + term2 = 0x2; + term3 = 0b11; + } + bar { + term1 = 2; + term2 = 3; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/14_include_delete/case.hcs b/tools/hc-gen/test/14_include_delete/case.hcs new file mode 100755 index 000000000..b77e6e036 --- /dev/null +++ b/tools/hc-gen/test/14_include_delete/case.hcs @@ -0,0 +1,11 @@ +#include "base.hcs" + +root { + module = "test"; + foo : delete{ + } + bar { + term1 = delete; + term2 = 1; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/14_include_delete/golden.c.gen b/tools/hc-gen/test/14_include_delete/golden.c.gen new file mode 100644 index 000000000..415650247 --- /dev/null +++ b/tools/hc-gen/test/14_include_delete/golden.c.gen @@ -0,0 +1,17 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .bar = { + .term2 = 0x1, + }, + .module = "test", +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/14_include_delete/golden.d.hcs b/tools/hc-gen/test/14_include_delete/golden.d.hcs new file mode 100644 index 000000000..57b63c1e8 --- /dev/null +++ b/tools/hc-gen/test/14_include_delete/golden.d.hcs @@ -0,0 +1,10 @@ +/* + * HDF decompile hcs file + */ + +root { + bar { + term2 = 0x1; + } + module = "test"; +} diff --git a/tools/hc-gen/test/14_include_delete/golden.h.gen b/tools/hc-gen/test/14_include_delete/golden.h.gen new file mode 100644 index 000000000..5224fc639 --- /dev/null +++ b/tools/hc-gen/test/14_include_delete/golden.h.gen @@ -0,0 +1,21 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestBar { + uint8_t term2; +}; + +struct HdfConfigTestRoot { + struct HdfConfigTestBar bar; + const char* module; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/14_include_delete/golden.hcb b/tools/hc-gen/test/14_include_delete/golden.hcb new file mode 100644 index 000000000..588e69da4 --- /dev/null +++ b/tools/hc-gen/test/14_include_delete/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAACoAAAABcm9vdAAgAAAAAWJhcgAJAAAAAnRlcm0yABABAm1vZHVsZQAUdGVzdAA= \ No newline at end of file diff --git a/tools/hc-gen/test/14_include_delete/golden_binary_compile_result.txt b/tools/hc-gen/test/14_include_delete/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/14_include_delete/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/14_include_delete/golden_text_compile_result.txt b/tools/hc-gen/test/14_include_delete/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/14_include_delete/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/15_line_comment/case.hcs b/tools/hc-gen/test/15_line_comment/case.hcs new file mode 100755 index 000000000..4b7bd07d1 --- /dev/null +++ b/tools/hc-gen/test/15_line_comment/case.hcs @@ -0,0 +1,10 @@ +root { + module = "test"; + bar{ + } + foo { + // it's comment + // term1 = 1; + term2 = 1; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/15_line_comment/golden.c.gen b/tools/hc-gen/test/15_line_comment/golden.c.gen new file mode 100644 index 000000000..7bc068c9a --- /dev/null +++ b/tools/hc-gen/test/15_line_comment/golden.c.gen @@ -0,0 +1,19 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .bar = { + }, + .foo = { + .term2 = 0x1, + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/15_line_comment/golden.d.hcs b/tools/hc-gen/test/15_line_comment/golden.d.hcs new file mode 100644 index 000000000..308235a6b --- /dev/null +++ b/tools/hc-gen/test/15_line_comment/golden.d.hcs @@ -0,0 +1,12 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + bar { + } + foo { + term2 = 0x1; + } +} diff --git a/tools/hc-gen/test/15_line_comment/golden.h.gen b/tools/hc-gen/test/15_line_comment/golden.h.gen new file mode 100644 index 000000000..7346ba3a3 --- /dev/null +++ b/tools/hc-gen/test/15_line_comment/golden.h.gen @@ -0,0 +1,25 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestBar { +}; + +struct HdfConfigTestFoo { + uint8_t term2; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestBar bar; + struct HdfConfigTestFoo foo; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/15_line_comment/golden.hcb b/tools/hc-gen/test/15_line_comment/golden.hcb new file mode 100644 index 000000000..2f0f2dc3b --- /dev/null +++ b/tools/hc-gen/test/15_line_comment/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAADMAAAABcm9vdAApAAAAAm1vZHVsZQAUdGVzdAABYmFyAAAAAAABZm9vAAkAAAACdGVybTIAEAE= \ No newline at end of file diff --git a/tools/hc-gen/test/15_line_comment/golden_binary_compile_result.txt b/tools/hc-gen/test/15_line_comment/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/15_line_comment/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/15_line_comment/golden_text_compile_result.txt b/tools/hc-gen/test/15_line_comment/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/15_line_comment/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/16_block_comment/case.hcs b/tools/hc-gen/test/16_block_comment/case.hcs new file mode 100755 index 000000000..5009a6199 --- /dev/null +++ b/tools/hc-gen/test/16_block_comment/case.hcs @@ -0,0 +1,17 @@ +root { + module = "test"; + foo { + } + bar { + /* + * it's comment + */ + + /* + term1 = 1; + term2 = 1; + */ + + term2 = 2; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/16_block_comment/golden.c.gen b/tools/hc-gen/test/16_block_comment/golden.c.gen new file mode 100644 index 000000000..d1ab8b3a7 --- /dev/null +++ b/tools/hc-gen/test/16_block_comment/golden.c.gen @@ -0,0 +1,19 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + }, + .bar = { + .term2 = 0x2, + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/16_block_comment/golden.d.hcs b/tools/hc-gen/test/16_block_comment/golden.d.hcs new file mode 100644 index 000000000..0b9254fdb --- /dev/null +++ b/tools/hc-gen/test/16_block_comment/golden.d.hcs @@ -0,0 +1,12 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + } + bar { + term2 = 0x2; + } +} diff --git a/tools/hc-gen/test/16_block_comment/golden.h.gen b/tools/hc-gen/test/16_block_comment/golden.h.gen new file mode 100644 index 000000000..4fe2cfb06 --- /dev/null +++ b/tools/hc-gen/test/16_block_comment/golden.h.gen @@ -0,0 +1,25 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { +}; + +struct HdfConfigTestBar { + uint8_t term2; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; + struct HdfConfigTestBar bar; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/16_block_comment/golden.hcb b/tools/hc-gen/test/16_block_comment/golden.hcb new file mode 100644 index 000000000..88029087a --- /dev/null +++ b/tools/hc-gen/test/16_block_comment/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAADMAAAABcm9vdAApAAAAAm1vZHVsZQAUdGVzdAABZm9vAAAAAAABYmFyAAkAAAACdGVybTIAEAI= \ No newline at end of file diff --git a/tools/hc-gen/test/16_block_comment/golden_binary_compile_result.txt b/tools/hc-gen/test/16_block_comment/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/16_block_comment/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/16_block_comment/golden_text_compile_result.txt b/tools/hc-gen/test/16_block_comment/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/16_block_comment/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/17_broken_node_ei/case.hcs b/tools/hc-gen/test/17_broken_node_ei/case.hcs new file mode 100755 index 000000000..640766da0 --- /dev/null +++ b/tools/hc-gen/test/17_broken_node_ei/case.hcs @@ -0,0 +1,7 @@ +root { + module = "test"; + bar { + term1 = delete; + term2 = 1; + // miss '}' here for test +} \ No newline at end of file diff --git a/tools/hc-gen/test/17_broken_node_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/17_broken_node_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..87c2e231d --- /dev/null +++ b/tools/hc-gen/test/17_broken_node_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./17_broken_node_ei/case.hcs:7:1: syntax error, except '}' or TEMPLATE or LITERAL for node 'root' \ No newline at end of file diff --git a/tools/hc-gen/test/17_broken_node_ei/golden_text_compile_result.txt b/tools/hc-gen/test/17_broken_node_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..87c2e231d --- /dev/null +++ b/tools/hc-gen/test/17_broken_node_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./17_broken_node_ei/case.hcs:7:1: syntax error, except '}' or TEMPLATE or LITERAL for node 'root' \ No newline at end of file diff --git a/tools/hc-gen/test/18_broken_string_ei/case.hcs b/tools/hc-gen/test/18_broken_string_ei/case.hcs new file mode 100755 index 000000000..bc8d820d0 --- /dev/null +++ b/tools/hc-gen/test/18_broken_string_ei/case.hcs @@ -0,0 +1,6 @@ +root { + module = "test"; + term1 = "hello", + // test string miss '"' + term2 = world" +} \ No newline at end of file diff --git a/tools/hc-gen/test/18_broken_string_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/18_broken_string_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..606693971 --- /dev/null +++ b/tools/hc-gen/test/18_broken_string_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./18_broken_string_ei/case.hcs:3:20: syntax error, miss ';' \ No newline at end of file diff --git a/tools/hc-gen/test/18_broken_string_ei/golden_text_compile_result.txt b/tools/hc-gen/test/18_broken_string_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..606693971 --- /dev/null +++ b/tools/hc-gen/test/18_broken_string_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./18_broken_string_ei/case.hcs:3:20: syntax error, miss ';' \ No newline at end of file diff --git a/tools/hc-gen/test/19_broken_number_ei/case.hcs b/tools/hc-gen/test/19_broken_number_ei/case.hcs new file mode 100755 index 000000000..dab9cc92b --- /dev/null +++ b/tools/hc-gen/test/19_broken_number_ei/case.hcs @@ -0,0 +1,6 @@ +root { + module = "test"; + term1 = "hello", + // test number miss prefix + term2 = 2f; +} \ No newline at end of file diff --git a/tools/hc-gen/test/19_broken_number_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/19_broken_number_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..67a465862 --- /dev/null +++ b/tools/hc-gen/test/19_broken_number_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./19_broken_number_ei/case.hcs:3:20: syntax error, miss ';' \ No newline at end of file diff --git a/tools/hc-gen/test/19_broken_number_ei/golden_text_compile_result.txt b/tools/hc-gen/test/19_broken_number_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..67a465862 --- /dev/null +++ b/tools/hc-gen/test/19_broken_number_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./19_broken_number_ei/case.hcs:3:20: syntax error, miss ';' \ No newline at end of file diff --git a/tools/hc-gen/test/20_broken_array_ei/case.hcs b/tools/hc-gen/test/20_broken_array_ei/case.hcs new file mode 100755 index 000000000..7ea51db2b --- /dev/null +++ b/tools/hc-gen/test/20_broken_array_ei/case.hcs @@ -0,0 +1,5 @@ +root { + module = "test"; + // test number miss ']' + term1 = [1, 2, +} \ No newline at end of file diff --git a/tools/hc-gen/test/20_broken_array_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/20_broken_array_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..a71a723e9 --- /dev/null +++ b/tools/hc-gen/test/20_broken_array_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./20_broken_array_ei/case.hcs:5:1: syntax error, except STRING or NUMBER in array \ No newline at end of file diff --git a/tools/hc-gen/test/20_broken_array_ei/golden_text_compile_result.txt b/tools/hc-gen/test/20_broken_array_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..a71a723e9 --- /dev/null +++ b/tools/hc-gen/test/20_broken_array_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./20_broken_array_ei/case.hcs:5:1: syntax error, except STRING or NUMBER in array \ No newline at end of file diff --git a/tools/hc-gen/test/21_mix_type_array_ei/case.hcs b/tools/hc-gen/test/21_mix_type_array_ei/case.hcs new file mode 100755 index 000000000..c7a46d9be --- /dev/null +++ b/tools/hc-gen/test/21_mix_type_array_ei/case.hcs @@ -0,0 +1,4 @@ +root { + module = "test"; + term1 = [1, 2, "3"]; +} \ No newline at end of file diff --git a/tools/hc-gen/test/21_mix_type_array_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/21_mix_type_array_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..771a39682 --- /dev/null +++ b/tools/hc-gen/test/21_mix_type_array_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./21_mix_type_array_ei/case.hcs:3:22: syntax error, not allow mix type array \ No newline at end of file diff --git a/tools/hc-gen/test/21_mix_type_array_ei/golden_text_compile_result.txt b/tools/hc-gen/test/21_mix_type_array_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..771a39682 --- /dev/null +++ b/tools/hc-gen/test/21_mix_type_array_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./21_mix_type_array_ei/case.hcs:3:22: syntax error, not allow mix type array \ No newline at end of file diff --git a/tools/hc-gen/test/22_redefine_error_ei/case.hcs b/tools/hc-gen/test/22_redefine_error_ei/case.hcs new file mode 100755 index 000000000..9aacaaaa2 --- /dev/null +++ b/tools/hc-gen/test/22_redefine_error_ei/case.hcs @@ -0,0 +1,5 @@ +root { + module = "test"; + term1 = 1; + term1 = 2; +} \ No newline at end of file diff --git a/tools/hc-gen/test/22_redefine_error_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/22_redefine_error_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..bbc40474b --- /dev/null +++ b/tools/hc-gen/test/22_redefine_error_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./22_redefine_error_ei/case.hcs:4 redefined, first definition at ./22_redefine_error_ei/case.hcs:3 \ No newline at end of file diff --git a/tools/hc-gen/test/22_redefine_error_ei/golden_text_compile_result.txt b/tools/hc-gen/test/22_redefine_error_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..bbc40474b --- /dev/null +++ b/tools/hc-gen/test/22_redefine_error_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./22_redefine_error_ei/case.hcs:4 redefined, first definition at ./22_redefine_error_ei/case.hcs:3 \ No newline at end of file diff --git a/tools/hc-gen/test/23_node_ref_invalid_node_ei/case.hcs b/tools/hc-gen/test/23_node_ref_invalid_node_ei/case.hcs new file mode 100755 index 000000000..0fa0b2a9c --- /dev/null +++ b/tools/hc-gen/test/23_node_ref_invalid_node_ei/case.hcs @@ -0,0 +1,6 @@ +root { + module = "test"; + foo : &root.bar{ + term1 = 1; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/23_node_ref_invalid_node_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/23_node_ref_invalid_node_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..2b161bf54 --- /dev/null +++ b/tools/hc-gen/test/23_node_ref_invalid_node_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./23_node_ref_invalid_node_ei/case.hcs:3 reference node 'root.bar' not exist \ No newline at end of file diff --git a/tools/hc-gen/test/23_node_ref_invalid_node_ei/golden_text_compile_result.txt b/tools/hc-gen/test/23_node_ref_invalid_node_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..2b161bf54 --- /dev/null +++ b/tools/hc-gen/test/23_node_ref_invalid_node_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./23_node_ref_invalid_node_ei/case.hcs:3 reference node 'root.bar' not exist \ No newline at end of file diff --git a/tools/hc-gen/test/24_node_copy_invlid_node_ei/case.hcs b/tools/hc-gen/test/24_node_copy_invlid_node_ei/case.hcs new file mode 100755 index 000000000..8cd3a5bd9 --- /dev/null +++ b/tools/hc-gen/test/24_node_copy_invlid_node_ei/case.hcs @@ -0,0 +1,6 @@ +root { + module = "test"; + foo : root.bar{ + term1 = 1; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/24_node_copy_invlid_node_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/24_node_copy_invlid_node_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..2cc27865a --- /dev/null +++ b/tools/hc-gen/test/24_node_copy_invlid_node_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./24_node_copy_invlid_node_ei/case.hcs:3 copy node 'root.bar' not exist \ No newline at end of file diff --git a/tools/hc-gen/test/24_node_copy_invlid_node_ei/golden_text_compile_result.txt b/tools/hc-gen/test/24_node_copy_invlid_node_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..2cc27865a --- /dev/null +++ b/tools/hc-gen/test/24_node_copy_invlid_node_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./24_node_copy_invlid_node_ei/case.hcs:3 copy node 'root.bar' not exist \ No newline at end of file diff --git a/tools/hc-gen/test/25_term_ref_invlid_node_ei/case.hcs b/tools/hc-gen/test/25_term_ref_invlid_node_ei/case.hcs new file mode 100755 index 000000000..da7cc78e6 --- /dev/null +++ b/tools/hc-gen/test/25_term_ref_invlid_node_ei/case.hcs @@ -0,0 +1,6 @@ +root { + module = "test"; + foo { + term1 = &root.bar; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/25_term_ref_invlid_node_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/25_term_ref_invlid_node_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..f0cc37154 --- /dev/null +++ b/tools/hc-gen/test/25_term_ref_invlid_node_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./25_term_ref_invlid_node_ei/case.hcs:4 reference invalid node 'root.bar' \ No newline at end of file diff --git a/tools/hc-gen/test/25_term_ref_invlid_node_ei/golden_text_compile_result.txt b/tools/hc-gen/test/25_term_ref_invlid_node_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..f0cc37154 --- /dev/null +++ b/tools/hc-gen/test/25_term_ref_invlid_node_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./25_term_ref_invlid_node_ei/case.hcs:4 reference invalid node 'root.bar' \ No newline at end of file diff --git a/tools/hc-gen/test/26_miss_semicolon_ei/case.hcs b/tools/hc-gen/test/26_miss_semicolon_ei/case.hcs new file mode 100755 index 000000000..476b0f21f --- /dev/null +++ b/tools/hc-gen/test/26_miss_semicolon_ei/case.hcs @@ -0,0 +1,4 @@ +root { + module = "test"; + term1 = 1 +} \ No newline at end of file diff --git a/tools/hc-gen/test/26_miss_semicolon_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/26_miss_semicolon_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..50b3cb0d6 --- /dev/null +++ b/tools/hc-gen/test/26_miss_semicolon_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./26_miss_semicolon_ei/case.hcs:4:1: syntax error, miss ';' \ No newline at end of file diff --git a/tools/hc-gen/test/26_miss_semicolon_ei/golden_text_compile_result.txt b/tools/hc-gen/test/26_miss_semicolon_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..50b3cb0d6 --- /dev/null +++ b/tools/hc-gen/test/26_miss_semicolon_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./26_miss_semicolon_ei/case.hcs:4:1: syntax error, miss ';' \ No newline at end of file diff --git a/tools/hc-gen/test/27_include_invalid_file_ei/case.hcs b/tools/hc-gen/test/27_include_invalid_file_ei/case.hcs new file mode 100755 index 000000000..8b549635b --- /dev/null +++ b/tools/hc-gen/test/27_include_invalid_file_ei/case.hcs @@ -0,0 +1,6 @@ +#include "bar.hcs" + +root { + module = "test"; + term1 = 1; +} \ No newline at end of file diff --git a/tools/hc-gen/test/27_include_invalid_file_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/27_include_invalid_file_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..32ec7703f --- /dev/null +++ b/tools/hc-gen/test/27_include_invalid_file_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./27_include_invalid_file_ei/case.hcs:1:19: include invalid file: 'bar.hcs' \ No newline at end of file diff --git a/tools/hc-gen/test/27_include_invalid_file_ei/golden_text_compile_result.txt b/tools/hc-gen/test/27_include_invalid_file_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..32ec7703f --- /dev/null +++ b/tools/hc-gen/test/27_include_invalid_file_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./27_include_invalid_file_ei/case.hcs:1:19: include invalid file: 'bar.hcs' \ No newline at end of file diff --git a/tools/hc-gen/test/28_overwrite_with_diff_type_ei/case.hcs b/tools/hc-gen/test/28_overwrite_with_diff_type_ei/case.hcs new file mode 100755 index 000000000..2048f8fd5 --- /dev/null +++ b/tools/hc-gen/test/28_overwrite_with_diff_type_ei/case.hcs @@ -0,0 +1,9 @@ +root { + module = "test"; + foo { + term = 1; + } + bar :& foo { + term = "hello"; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/28_overwrite_with_diff_type_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/28_overwrite_with_diff_type_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..e7313241a --- /dev/null +++ b/tools/hc-gen/test/28_overwrite_with_diff_type_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./28_overwrite_with_diff_type_ei/case.hcs:7 overwrite different type with:./28_overwrite_with_diff_type_ei/case.hcs:4 \ No newline at end of file diff --git a/tools/hc-gen/test/28_overwrite_with_diff_type_ei/golden_text_compile_result.txt b/tools/hc-gen/test/28_overwrite_with_diff_type_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..e7313241a --- /dev/null +++ b/tools/hc-gen/test/28_overwrite_with_diff_type_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./28_overwrite_with_diff_type_ei/case.hcs:7 overwrite different type with:./28_overwrite_with_diff_type_ei/case.hcs:4 \ No newline at end of file diff --git a/tools/hc-gen/test/29_node_copy_nested_ei/case.hcs b/tools/hc-gen/test/29_node_copy_nested_ei/case.hcs new file mode 100755 index 000000000..a8f3a7db4 --- /dev/null +++ b/tools/hc-gen/test/29_node_copy_nested_ei/case.hcs @@ -0,0 +1,9 @@ +root { + module = "test"; + foo { + term = 1; + bar : root.foo { + term = "hello"; + } + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/29_node_copy_nested_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/29_node_copy_nested_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..372d25e1d --- /dev/null +++ b/tools/hc-gen/test/29_node_copy_nested_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./29_node_copy_nested_ei/case.hcs:5 circular reference ./29_node_copy_nested_ei/case.hcs:3 \ No newline at end of file diff --git a/tools/hc-gen/test/29_node_copy_nested_ei/golden_text_compile_result.txt b/tools/hc-gen/test/29_node_copy_nested_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..372d25e1d --- /dev/null +++ b/tools/hc-gen/test/29_node_copy_nested_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./29_node_copy_nested_ei/case.hcs:5 circular reference ./29_node_copy_nested_ei/case.hcs:3 \ No newline at end of file diff --git a/tools/hc-gen/test/30_include_order/base1.hcs b/tools/hc-gen/test/30_include_order/base1.hcs new file mode 100755 index 000000000..7271064b5 --- /dev/null +++ b/tools/hc-gen/test/30_include_order/base1.hcs @@ -0,0 +1,7 @@ +root { + module = "test"; + foo { + term = 1; + term1 = 1; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/30_include_order/base2.hcs b/tools/hc-gen/test/30_include_order/base2.hcs new file mode 100755 index 000000000..f42a9bd6d --- /dev/null +++ b/tools/hc-gen/test/30_include_order/base2.hcs @@ -0,0 +1,6 @@ +root { + foo { + term = 2; + term1 = 2; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/30_include_order/case.hcs b/tools/hc-gen/test/30_include_order/case.hcs new file mode 100755 index 000000000..7f4065780 --- /dev/null +++ b/tools/hc-gen/test/30_include_order/case.hcs @@ -0,0 +1,8 @@ +#include "base1.hcs" +#include "base2.hcs" + +root { + foo { + term1 = 3; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/30_include_order/golden.c.gen b/tools/hc-gen/test/30_include_order/golden.c.gen new file mode 100644 index 000000000..2f36402af --- /dev/null +++ b/tools/hc-gen/test/30_include_order/golden.c.gen @@ -0,0 +1,18 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + .term = 0x2, + .term1 = 0x3, + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/30_include_order/golden.d.hcs b/tools/hc-gen/test/30_include_order/golden.d.hcs new file mode 100644 index 000000000..d9ac2a8bb --- /dev/null +++ b/tools/hc-gen/test/30_include_order/golden.d.hcs @@ -0,0 +1,11 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + term = 0x2; + term1 = 0x3; + } +} diff --git a/tools/hc-gen/test/30_include_order/golden.h.gen b/tools/hc-gen/test/30_include_order/golden.h.gen new file mode 100644 index 000000000..95293f600 --- /dev/null +++ b/tools/hc-gen/test/30_include_order/golden.h.gen @@ -0,0 +1,22 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { + uint8_t term; + uint8_t term1; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/30_include_order/golden.hcb b/tools/hc-gen/test/30_include_order/golden.hcb new file mode 100644 index 000000000..3503e9bc2 --- /dev/null +++ b/tools/hc-gen/test/30_include_order/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAADIAAAABcm9vdAAoAAAAAm1vZHVsZQAUdGVzdAABZm9vABEAAAACdGVybQAQAgJ0ZXJtMQAQAw== \ No newline at end of file diff --git a/tools/hc-gen/test/30_include_order/golden_binary_compile_result.txt b/tools/hc-gen/test/30_include_order/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/30_include_order/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/30_include_order/golden_text_compile_result.txt b/tools/hc-gen/test/30_include_order/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/30_include_order/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/31_node_duplicate_name/case.hcs b/tools/hc-gen/test/31_node_duplicate_name/case.hcs new file mode 100755 index 000000000..52bd6303f --- /dev/null +++ b/tools/hc-gen/test/31_node_duplicate_name/case.hcs @@ -0,0 +1,12 @@ +root { + module = "test"; + foo { + term1 = 3; + } + + bar { + foo { + term1 = 2; + } + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/31_node_duplicate_name/golden.d.hcs b/tools/hc-gen/test/31_node_duplicate_name/golden.d.hcs new file mode 100644 index 000000000..11f5c0531 --- /dev/null +++ b/tools/hc-gen/test/31_node_duplicate_name/golden.d.hcs @@ -0,0 +1,15 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + term1 = 0x3; + } + bar { + foo { + term1 = 0x2; + } + } +} diff --git a/tools/hc-gen/test/31_node_duplicate_name/golden.hcb b/tools/hc-gen/test/31_node_duplicate_name/golden.hcb new file mode 100644 index 000000000..d7718f6dc --- /dev/null +++ b/tools/hc-gen/test/31_node_duplicate_name/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAEUAAAABcm9vdAA7AAAAAm1vZHVsZQAUdGVzdAABZm9vAAkAAAACdGVybTEAEAMBYmFyABIAAAABZm9vAAkAAAACdGVybTEAEAI= \ No newline at end of file diff --git a/tools/hc-gen/test/31_node_duplicate_name/golden_binary_compile_result.txt b/tools/hc-gen/test/31_node_duplicate_name/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/31_node_duplicate_name/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/31_node_duplicate_name/golden_text_compile_result.txt b/tools/hc-gen/test/31_node_duplicate_name/golden_text_compile_result.txt new file mode 100644 index 000000000..995b42bc1 --- /dev/null +++ b/tools/hc-gen/test/31_node_duplicate_name/golden_text_compile_result.txt @@ -0,0 +1,4 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./31_node_duplicate_name/case.hcs:8 duplicate node name at ./31_node_duplicate_name/case.hcs:3 +To avoid redefining structures, not allow duplicate node name at text config mode \ No newline at end of file diff --git a/tools/hc-gen/test/32_large_hsl/case.hcs b/tools/hc-gen/test/32_large_hsl/case.hcs new file mode 100755 index 000000000..9cfb0344f --- /dev/null +++ b/tools/hc-gen/test/32_large_hsl/case.hcs @@ -0,0 +1,1008 @@ +root { + module = "test"; + foo { + term0 = 41; + term1 = 8467; + term2 = 6334; + term3 = 6500; + term4 = 9169; + term5 = 5724; + term6 = 1478; + term7 = 9358; + term8 = 6962; + term9 = 4464; + term10 = 5705; + term11 = 8145; + term12 = 3281; + term13 = 6827; + term14 = 9961; + term15 = 491; + term16 = 2995; + term17 = 1942; + term18 = 4827; + term19 = 5436; + term20 = 2391; + term21 = 4604; + term22 = 3902; + term23 = 153; + term24 = 292; + term25 = 2382; + term26 = 7421; + term27 = 8716; + term28 = 9718; + term29 = 9895; + term30 = 5447; + term31 = 1726; + term32 = 4771; + term33 = 1538; + term34 = 1869; + term35 = 9912; + term36 = 5667; + term37 = 6299; + term38 = 7035; + term39 = 9894; + term40 = 8703; + term41 = 3811; + term42 = 1322; + term43 = 333; + term44 = 7673; + term45 = 4664; + term46 = 5141; + term47 = 7711; + term48 = 8253; + term49 = 6868; + term50 = 5547; + term51 = 7644; + term52 = 2662; + term53 = 2757; + term54 = 37; + term55 = 2859; + term56 = 8723; + term57 = 9741; + term58 = 7529; + term59 = 778; + term60 = 2316; + term61 = 3035; + term62 = 2190; + term63 = 1842; + term64 = 288; + term65 = 106; + term66 = 9040; + term67 = 8942; + term68 = 9264; + term69 = 2648; + term70 = 7446; + term71 = 3805; + term72 = 5890; + term73 = 6729; + term74 = 4370; + term75 = 5350; + term76 = 5006; + term77 = 1101; + term78 = 4393; + term79 = 3548; + term80 = 9629; + term81 = 2623; + term82 = 4084; + term83 = 9954; + term84 = 8756; + term85 = 1840; + term86 = 4966; + term87 = 7376; + term88 = 3931; + term89 = 6308; + term90 = 6944; + term91 = 2439; + term92 = 4626; + term93 = 1323; + term94 = 5537; + term95 = 1538; + term96 = 6118; + term97 = 2082; + term98 = 2929; + term99 = 6541; + term100 = 4833; + term101 = 1115; + term102 = 4639; + term103 = 9658; + term104 = 2704; + term105 = 9930; + term106 = 3977; + term107 = 2306; + term108 = 1673; + term109 = 2386; + term110 = 5021; + term111 = 8745; + term112 = 6924; + term113 = 9072; + term114 = 6270; + term115 = 5829; + term116 = 6777; + term117 = 5573; + term118 = 5097; + term119 = 6512; + term120 = 3986; + term121 = 3290; + term122 = 9161; + term123 = 8636; + term124 = 2355; + term125 = 4767; + term126 = 3655; + term127 = 5574; + term128 = 4031; + term129 = 2052; + term130 = 7350; + term131 = 1150; + term132 = 6941; + term133 = 1724; + term134 = 3966; + term135 = 3430; + term136 = 1107; + term137 = 191; + term138 = 8007; + term139 = 1337; + term140 = 5457; + term141 = 2287; + term142 = 7753; + term143 = 383; + term144 = 4945; + term145 = 8909; + term146 = 2209; + term147 = 9758; + term148 = 4221; + term149 = 8588; + term150 = 6422; + term151 = 4946; + term152 = 7506; + term153 = 3030; + term154 = 6413; + term155 = 9168; + term156 = 900; + term157 = 2591; + term158 = 8762; + term159 = 1655; + term160 = 7410; + term161 = 6359; + term162 = 7624; + term163 = 537; + term164 = 1548; + term165 = 6483; + term166 = 7595; + term167 = 4041; + term168 = 3602; + term169 = 4350; + term170 = 291; + term171 = 836; + term172 = 9374; + term173 = 1020; + term174 = 4596; + term175 = 4021; + term176 = 7348; + term177 = 3199; + term178 = 9668; + term179 = 4484; + term180 = 8281; + term181 = 4734; + term182 = 53; + term183 = 1999; + term184 = 6418; + term185 = 7938; + term186 = 6900; + term187 = 3788; + term188 = 8127; + term189 = 467; + term190 = 3728; + term191 = 4893; + term192 = 4648; + term193 = 2483; + term194 = 7807; + term195 = 2421; + term196 = 4310; + term197 = 6617; + term198 = 2813; + term199 = 9514; + term200 = 4309; + term201 = 7616; + term202 = 8935; + term203 = 7451; + term204 = 600; + term205 = 5249; + term206 = 6519; + term207 = 1556; + term208 = 2798; + term209 = 303; + term210 = 6224; + term211 = 1008; + term212 = 5844; + term213 = 2609; + term214 = 4989; + term215 = 2702; + term216 = 3195; + term217 = 485; + term218 = 3093; + term219 = 4343; + term220 = 523; + term221 = 1587; + term222 = 9314; + term223 = 9503; + term224 = 7448; + term225 = 5200; + term226 = 3458; + term227 = 6618; + term228 = 580; + term229 = 9796; + term230 = 4798; + term231 = 5281; + term232 = 9589; + term233 = 798; + term234 = 8009; + term235 = 7157; + term236 = 472; + term237 = 3622; + term238 = 8538; + term239 = 2292; + term240 = 6038; + term241 = 4179; + term242 = 8190; + term243 = 9657; + term244 = 7958; + term245 = 6191; + term246 = 9815; + term247 = 2888; + term248 = 9156; + term249 = 1511; + term250 = 6202; + term251 = 2634; + term252 = 4272; + term253 = 55; + term254 = 328; + term255 = 2646; + term256 = 6362; + term257 = 4886; + term258 = 8875; + term259 = 8433; + term260 = 9869; + term261 = 142; + term262 = 3844; + term263 = 1416; + term264 = 1881; + term265 = 1998; + term266 = 322; + term267 = 8651; + term268 = 21; + term269 = 5699; + term270 = 3557; + term271 = 8476; + term272 = 7892; + term273 = 4389; + term274 = 5075; + term275 = 712; + term276 = 2600; + term277 = 2510; + term278 = 1003; + term279 = 6869; + term280 = 7861; + term281 = 4688; + term282 = 3401; + term283 = 9789; + term284 = 5255; + term285 = 6423; + term286 = 5002; + term287 = 585; + term288 = 4182; + term289 = 285; + term290 = 7088; + term291 = 1426; + term292 = 8617; + term293 = 3757; + term294 = 9832; + term295 = 932; + term296 = 4169; + term297 = 2154; + term298 = 5721; + term299 = 7189; + term300 = 9976; + term301 = 1329; + term302 = 2368; + term303 = 8692; + term304 = 1425; + term305 = 555; + term306 = 3434; + term307 = 6549; + term308 = 7441; + term309 = 9512; + term310 = 145; + term311 = 8060; + term312 = 1718; + term313 = 3753; + term314 = 6139; + term315 = 2423; + term316 = 6279; + term317 = 5996; + term318 = 6687; + term319 = 2529; + term320 = 2549; + term321 = 7437; + term322 = 9866; + term323 = 2949; + term324 = 193; + term325 = 3195; + term326 = 3297; + term327 = 416; + term328 = 8286; + term329 = 6105; + term330 = 4488; + term331 = 6282; + term332 = 2455; + term333 = 5734; + term334 = 8114; + term335 = 1701; + term336 = 1316; + term337 = 671; + term338 = 5786; + term339 = 2263; + term340 = 4313; + term341 = 4355; + term342 = 1185; + term343 = 53; + term344 = 912; + term345 = 808; + term346 = 1832; + term347 = 945; + term348 = 4313; + term349 = 7756; + term350 = 8321; + term351 = 9558; + term352 = 3646; + term353 = 7982; + term354 = 481; + term355 = 4144; + term356 = 3196; + term357 = 222; + term358 = 7129; + term359 = 2161; + term360 = 5535; + term361 = 450; + term362 = 1173; + term363 = 466; + term364 = 2044; + term365 = 1659; + term366 = 6292; + term367 = 6439; + term368 = 7253; + term369 = 24; + term370 = 6154; + term371 = 9510; + term372 = 4745; + term373 = 649; + term374 = 3186; + term375 = 8313; + term376 = 4474; + term377 = 8022; + term378 = 2168; + term379 = 4018; + term380 = 8787; + term381 = 9905; + term382 = 7958; + term383 = 7391; + term384 = 202; + term385 = 3625; + term386 = 6477; + term387 = 4414; + term388 = 9314; + term389 = 5824; + term390 = 9334; + term391 = 5874; + term392 = 4372; + term393 = 159; + term394 = 1833; + term395 = 8070; + term396 = 7487; + term397 = 8297; + term398 = 7518; + term399 = 8177; + term400 = 7773; + term401 = 2270; + term402 = 1763; + term403 = 2668; + term404 = 7192; + term405 = 3985; + term406 = 3102; + term407 = 8480; + term408 = 9213; + term409 = 7627; + term410 = 4802; + term411 = 4099; + term412 = 527; + term413 = 2625; + term414 = 1543; + term415 = 1924; + term416 = 1023; + term417 = 9972; + term418 = 3061; + term419 = 4181; + term420 = 1003; + term421 = 7432; + term422 = 7505; + term423 = 7593; + term424 = 2725; + term425 = 3031; + term426 = 8492; + term427 = 142; + term428 = 7222; + term429 = 1286; + term430 = 3064; + term431 = 7900; + term432 = 9187; + term433 = 8360; + term434 = 2413; + term435 = 974; + term436 = 4270; + term437 = 9170; + term438 = 235; + term439 = 833; + term440 = 9711; + term441 = 5760; + term442 = 8896; + term443 = 4667; + term444 = 7285; + term445 = 2550; + term446 = 140; + term447 = 3694; + term448 = 2695; + term449 = 1624; + term450 = 8019; + term451 = 2125; + term452 = 6576; + term453 = 1694; + term454 = 2658; + term455 = 6302; + term456 = 7371; + term457 = 2466; + term458 = 4678; + term459 = 2593; + term460 = 3851; + term461 = 5484; + term462 = 1018; + term463 = 8464; + term464 = 1119; + term465 = 3152; + term466 = 2800; + term467 = 8087; + term468 = 1060; + term469 = 1926; + term470 = 9010; + term471 = 4757; + term472 = 2170; + term473 = 315; + term474 = 9576; + term475 = 227; + term476 = 2043; + term477 = 2758; + term478 = 7164; + term479 = 5109; + term480 = 7882; + term481 = 7086; + term482 = 9565; + term483 = 3487; + term484 = 9577; + term485 = 4474; + term486 = 2625; + term487 = 5627; + term488 = 5629; + term489 = 1928; + term490 = 5423; + term491 = 8520; + term492 = 6902; + term493 = 4962; + term494 = 123; + term495 = 4596; + term496 = 3737; + term497 = 3261; + term498 = 195; + term499 = 2525; + term500 = 1264; + term501 = 8260; + term502 = 6202; + term503 = 8116; + term504 = 5030; + term505 = 326; + term506 = 9011; + term507 = 771; + term508 = 6411; + term509 = 5547; + term510 = 1153; + term511 = 1520; + term512 = 9790; + term513 = 4924; + term514 = 188; + term515 = 1763; + term516 = 4940; + term517 = 851; + term518 = 8662; + term519 = 3829; + term520 = 900; + term521 = 7713; + term522 = 8958; + term523 = 7578; + term524 = 8365; + term525 = 3007; + term526 = 1477; + term527 = 1200; + term528 = 6058; + term529 = 6439; + term530 = 2303; + term531 = 2760; + term532 = 9357; + term533 = 2324; + term534 = 6477; + term535 = 5108; + term536 = 1113; + term537 = 4887; + term538 = 9801; + term539 = 2850; + term540 = 4460; + term541 = 2428; + term542 = 2993; + term543 = 7384; + term544 = 9405; + term545 = 6540; + term546 = 1111; + term547 = 8704; + term548 = 2835; + term549 = 2356; + term550 = 6072; + term551 = 9350; + term552 = 8823; + term553 = 4485; + term554 = 556; + term555 = 3216; + term556 = 1626; + term557 = 9357; + term558 = 8526; + term559 = 3357; + term560 = 9337; + term561 = 3271; + term562 = 3869; + term563 = 9361; + term564 = 2896; + term565 = 3022; + term566 = 9617; + term567 = 112; + term568 = 2717; + term569 = 8696; + term570 = 1585; + term571 = 4041; + term572 = 4423; + term573 = 4129; + term574 = 4229; + term575 = 4565; + term576 = 6559; + term577 = 8932; + term578 = 2296; + term579 = 9855; + term580 = 2053; + term581 = 6962; + term582 = 3584; + term583 = 9734; + term584 = 6654; + term585 = 6972; + term586 = 1457; + term587 = 4369; + term588 = 2532; + term589 = 2963; + term590 = 2607; + term591 = 2483; + term592 = 911; + term593 = 1635; + term594 = 67; + term595 = 2848; + term596 = 4675; + term597 = 2938; + term598 = 2223; + term599 = 2142; + term600 = 3754; + term601 = 6511; + term602 = 2741; + term603 = 175; + term604 = 1459; + term605 = 7825; + term606 = 3221; + term607 = 7870; + term608 = 1626; + term609 = 1934; + term610 = 5205; + term611 = 1783; + term612 = 3850; + term613 = 7398; + term614 = 2279; + term615 = 2701; + term616 = 2193; + term617 = 2734; + term618 = 1637; + term619 = 6534; + term620 = 5556; + term621 = 1993; + term622 = 176; + term623 = 5705; + term624 = 6962; + term625 = 548; + term626 = 5881; + term627 = 300; + term628 = 4413; + term629 = 6641; + term630 = 9855; + term631 = 4855; + term632 = 3142; + term633 = 1462; + term634 = 7611; + term635 = 877; + term636 = 424; + term637 = 2678; + term638 = 1752; + term639 = 8443; + term640 = 8296; + term641 = 2673; + term642 = 40; + term643 = 9313; + term644 = 875; + term645 = 72; + term646 = 2818; + term647 = 610; + term648 = 1017; + term649 = 4932; + term650 = 8112; + term651 = 695; + term652 = 3169; + term653 = 3831; + term654 = 40; + term655 = 6488; + term656 = 8685; + term657 = 9090; + term658 = 9497; + term659 = 2589; + term660 = 5990; + term661 = 5145; + term662 = 9353; + term663 = 9314; + term664 = 8651; + term665 = 6740; + term666 = 2044; + term667 = 1258; + term668 = 335; + term669 = 8759; + term670 = 1192; + term671 = 7605; + term672 = 5264; + term673 = 2181; + term674 = 8503; + term675 = 3829; + term676 = 3775; + term677 = 608; + term678 = 9292; + term679 = 5997; + term680 = 7549; + term681 = 9556; + term682 = 5561; + term683 = 1627; + term684 = 6467; + term685 = 9541; + term686 = 6129; + term687 = 1240; + term688 = 7813; + term689 = 9174; + term690 = 601; + term691 = 6077; + term692 = 215; + term693 = 8683; + term694 = 8213; + term695 = 3992; + term696 = 5824; + term697 = 5601; + term698 = 3392; + term699 = 5759; + term700 = 2670; + term701 = 6428; + term702 = 8027; + term703 = 4084; + term704 = 75; + term705 = 8786; + term706 = 5498; + term707 = 4970; + term708 = 6287; + term709 = 3847; + term710 = 2604; + term711 = 503; + term712 = 1221; + term713 = 2663; + term714 = 5706; + term715 = 2363; + term716 = 9010; + term717 = 2171; + term718 = 7489; + term719 = 8240; + term720 = 2164; + term721 = 5542; + term722 = 7619; + term723 = 913; + term724 = 7591; + term725 = 6704; + term726 = 1818; + term727 = 9232; + term728 = 750; + term729 = 5205; + term730 = 4975; + term731 = 1539; + term732 = 303; + term733 = 1422; + term734 = 1098; + term735 = 1247; + term736 = 3584; + term737 = 3648; + term738 = 2971; + term739 = 7864; + term740 = 2913; + term741 = 1075; + term742 = 1545; + term743 = 8712; + term744 = 7546; + term745 = 8678; + term746 = 1769; + term747 = 5262; + term748 = 8519; + term749 = 3985; + term750 = 8289; + term751 = 5944; + term752 = 2865; + term753 = 8540; + term754 = 3245; + term755 = 5508; + term756 = 8318; + term757 = 7870; + term758 = 9601; + term759 = 8323; + term760 = 1132; + term761 = 4472; + term762 = 7152; + term763 = 5087; + term764 = 8570; + term765 = 9763; + term766 = 9901; + term767 = 7103; + term768 = 4423; + term769 = 3527; + term770 = 1600; + term771 = 6969; + term772 = 4015; + term773 = 5565; + term774 = 28; + term775 = 1543; + term776 = 5347; + term777 = 2088; + term778 = 2943; + term779 = 2637; + term780 = 2409; + term781 = 6463; + term782 = 5049; + term783 = 4681; + term784 = 1588; + term785 = 1342; + term786 = 608; + term787 = 2060; + term788 = 1221; + term789 = 1758; + term790 = 9954; + term791 = 888; + term792 = 4146; + term793 = 690; + term794 = 7949; + term795 = 2843; + term796 = 1430; + term797 = 5620; + term798 = 748; + term799 = 7067; + term800 = 4536; + term801 = 783; + term802 = 8035; + term803 = 2226; + term804 = 5185; + term805 = 7038; + term806 = 9853; + term807 = 5629; + term808 = 1224; + term809 = 5748; + term810 = 9923; + term811 = 3359; + term812 = 2257; + term813 = 4766; + term814 = 4944; + term815 = 4955; + term816 = 3318; + term817 = 2726; + term818 = 5411; + term819 = 1025; + term820 = 355; + term821 = 1001; + term822 = 2549; + term823 = 9496; + term824 = 8584; + term825 = 9515; + term826 = 7964; + term827 = 3342; + term828 = 8075; + term829 = 7913; + term830 = 6142; + term831 = 1196; + term832 = 1948; + term833 = 5072; + term834 = 426; + term835 = 4606; + term836 = 6173; + term837 = 4429; + term838 = 2404; + term839 = 6705; + term840 = 626; + term841 = 9812; + term842 = 9375; + term843 = 93; + term844 = 6565; + term845 = 6036; + term846 = 4736; + term847 = 9141; + term848 = 814; + term849 = 5994; + term850 = 8256; + term851 = 6652; + term852 = 3936; + term853 = 838; + term854 = 482; + term855 = 1355; + term856 = 1015; + term857 = 1131; + term858 = 8230; + term859 = 7841; + term860 = 4625; + term861 = 2011; + term862 = 2637; + term863 = 4186; + term864 = 9690; + term865 = 1650; + term866 = 5662; + term867 = 1634; + term868 = 893; + term869 = 353; + term870 = 1416; + term871 = 3452; + term872 = 4008; + term873 = 7262; + term874 = 2233; + term875 = 5454; + term876 = 6303; + term877 = 6634; + term878 = 6303; + term879 = 4256; + term880 = 148; + term881 = 1124; + term882 = 2317; + term883 = 4213; + term884 = 7109; + term885 = 4028; + term886 = 9200; + term887 = 1080; + term888 = 1318; + term889 = 6858; + term890 = 4050; + term891 = 4155; + term892 = 1361; + term893 = 5264; + term894 = 1903; + term895 = 3676; + term896 = 9643; + term897 = 6909; + term898 = 4902; + term899 = 3561; + term900 = 8489; + term901 = 4948; + term902 = 1282; + term903 = 3653; + term904 = 674; + term905 = 2220; + term906 = 5402; + term907 = 6923; + term908 = 3831; + term909 = 9369; + term910 = 3878; + term911 = 259; + term912 = 9008; + term913 = 2619; + term914 = 3971; + term915 = 3; + term916 = 1945; + term917 = 9781; + term918 = 6504; + term919 = 2392; + term920 = 2685; + term921 = 5313; + term922 = 6698; + term923 = 5589; + term924 = 2722; + term925 = 5938; + term926 = 9037; + term927 = 6410; + term928 = 1461; + term929 = 6234; + term930 = 2508; + term931 = 9961; + term932 = 3959; + term933 = 6493; + term934 = 1515; + term935 = 5269; + term936 = 4937; + term937 = 8869; + term938 = 58; + term939 = 4700; + term940 = 3971; + term941 = 6264; + term942 = 5117; + term943 = 6215; + term944 = 4555; + term945 = 7815; + term946 = 8330; + term947 = 3039; + term948 = 212; + term949 = 9288; + term950 = 8082; + term951 = 1954; + term952 = 6085; + term953 = 710; + term954 = 4484; + term955 = 4774; + term956 = 8380; + term957 = 9815; + term958 = 5951; + term959 = 6541; + term960 = 8115; + term961 = 1679; + term962 = 7110; + term963 = 5898; + term964 = 3073; + term965 = 788; + term966 = 3977; + term967 = 8132; + term968 = 9956; + term969 = 8689; + term970 = 6113; + term971 = 8; + term972 = 2941; + term973 = 5790; + term974 = 1723; + term975 = 1363; + term976 = 28; + term977 = 5184; + term978 = 4778; + term979 = 7200; + term980 = 5071; + term981 = 1885; + term982 = 1974; + term983 = 1071; + term984 = 1333; + term985 = 2867; + term986 = 6153; + term987 = 4295; + term988 = 2168; + term989 = 825; + term990 = 9676; + term991 = 5629; + term992 = 8650; + term993 = 2598; + term994 = 3309; + term995 = 4693; + term996 = 4686; + } + + bar { + term997 = 80; + term998 = 116; + term999 = 2249; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/32_large_hsl/golden.c.gen b/tools/hc-gen/test/32_large_hsl/golden.c.gen new file mode 100644 index 000000000..978596474 --- /dev/null +++ b/tools/hc-gen/test/32_large_hsl/golden.c.gen @@ -0,0 +1,1018 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .foo = { + .term0 = 0x29, + .term1 = 0x2113, + .term2 = 0x18be, + .term3 = 0x1964, + .term4 = 0x23d1, + .term5 = 0x165c, + .term6 = 0x5c6, + .term7 = 0x248e, + .term8 = 0x1b32, + .term9 = 0x1170, + .term10 = 0x1649, + .term11 = 0x1fd1, + .term12 = 0xcd1, + .term13 = 0x1aab, + .term14 = 0x26e9, + .term15 = 0x1eb, + .term16 = 0xbb3, + .term17 = 0x796, + .term18 = 0x12db, + .term19 = 0x153c, + .term20 = 0x957, + .term21 = 0x11fc, + .term22 = 0xf3e, + .term23 = 0x99, + .term24 = 0x124, + .term25 = 0x94e, + .term26 = 0x1cfd, + .term27 = 0x220c, + .term28 = 0x25f6, + .term29 = 0x26a7, + .term30 = 0x1547, + .term31 = 0x6be, + .term32 = 0x12a3, + .term33 = 0x602, + .term34 = 0x74d, + .term35 = 0x26b8, + .term36 = 0x1623, + .term37 = 0x189b, + .term38 = 0x1b7b, + .term39 = 0x26a6, + .term40 = 0x21ff, + .term41 = 0xee3, + .term42 = 0x52a, + .term43 = 0x14d, + .term44 = 0x1df9, + .term45 = 0x1238, + .term46 = 0x1415, + .term47 = 0x1e1f, + .term48 = 0x203d, + .term49 = 0x1ad4, + .term50 = 0x15ab, + .term51 = 0x1ddc, + .term52 = 0xa66, + .term53 = 0xac5, + .term54 = 0x25, + .term55 = 0xb2b, + .term56 = 0x2213, + .term57 = 0x260d, + .term58 = 0x1d69, + .term59 = 0x30a, + .term60 = 0x90c, + .term61 = 0xbdb, + .term62 = 0x88e, + .term63 = 0x732, + .term64 = 0x120, + .term65 = 0x6a, + .term66 = 0x2350, + .term67 = 0x22ee, + .term68 = 0x2430, + .term69 = 0xa58, + .term70 = 0x1d16, + .term71 = 0xedd, + .term72 = 0x1702, + .term73 = 0x1a49, + .term74 = 0x1112, + .term75 = 0x14e6, + .term76 = 0x138e, + .term77 = 0x44d, + .term78 = 0x1129, + .term79 = 0xddc, + .term80 = 0x259d, + .term81 = 0xa3f, + .term82 = 0xff4, + .term83 = 0x26e2, + .term84 = 0x2234, + .term85 = 0x730, + .term86 = 0x1366, + .term87 = 0x1cd0, + .term88 = 0xf5b, + .term89 = 0x18a4, + .term90 = 0x1b20, + .term91 = 0x987, + .term92 = 0x1212, + .term93 = 0x52b, + .term94 = 0x15a1, + .term95 = 0x602, + .term96 = 0x17e6, + .term97 = 0x822, + .term98 = 0xb71, + .term99 = 0x198d, + .term100 = 0x12e1, + .term101 = 0x45b, + .term102 = 0x121f, + .term103 = 0x25ba, + .term104 = 0xa90, + .term105 = 0x26ca, + .term106 = 0xf89, + .term107 = 0x902, + .term108 = 0x689, + .term109 = 0x952, + .term110 = 0x139d, + .term111 = 0x2229, + .term112 = 0x1b0c, + .term113 = 0x2370, + .term114 = 0x187e, + .term115 = 0x16c5, + .term116 = 0x1a79, + .term117 = 0x15c5, + .term118 = 0x13e9, + .term119 = 0x1970, + .term120 = 0xf92, + .term121 = 0xcda, + .term122 = 0x23c9, + .term123 = 0x21bc, + .term124 = 0x933, + .term125 = 0x129f, + .term126 = 0xe47, + .term127 = 0x15c6, + .term128 = 0xfbf, + .term129 = 0x804, + .term130 = 0x1cb6, + .term131 = 0x47e, + .term132 = 0x1b1d, + .term133 = 0x6bc, + .term134 = 0xf7e, + .term135 = 0xd66, + .term136 = 0x453, + .term137 = 0xbf, + .term138 = 0x1f47, + .term139 = 0x539, + .term140 = 0x1551, + .term141 = 0x8ef, + .term142 = 0x1e49, + .term143 = 0x17f, + .term144 = 0x1351, + .term145 = 0x22cd, + .term146 = 0x8a1, + .term147 = 0x261e, + .term148 = 0x107d, + .term149 = 0x218c, + .term150 = 0x1916, + .term151 = 0x1352, + .term152 = 0x1d52, + .term153 = 0xbd6, + .term154 = 0x190d, + .term155 = 0x23d0, + .term156 = 0x384, + .term157 = 0xa1f, + .term158 = 0x223a, + .term159 = 0x677, + .term160 = 0x1cf2, + .term161 = 0x18d7, + .term162 = 0x1dc8, + .term163 = 0x219, + .term164 = 0x60c, + .term165 = 0x1953, + .term166 = 0x1dab, + .term167 = 0xfc9, + .term168 = 0xe12, + .term169 = 0x10fe, + .term170 = 0x123, + .term171 = 0x344, + .term172 = 0x249e, + .term173 = 0x3fc, + .term174 = 0x11f4, + .term175 = 0xfb5, + .term176 = 0x1cb4, + .term177 = 0xc7f, + .term178 = 0x25c4, + .term179 = 0x1184, + .term180 = 0x2059, + .term181 = 0x127e, + .term182 = 0x35, + .term183 = 0x7cf, + .term184 = 0x1912, + .term185 = 0x1f02, + .term186 = 0x1af4, + .term187 = 0xecc, + .term188 = 0x1fbf, + .term189 = 0x1d3, + .term190 = 0xe90, + .term191 = 0x131d, + .term192 = 0x1228, + .term193 = 0x9b3, + .term194 = 0x1e7f, + .term195 = 0x975, + .term196 = 0x10d6, + .term197 = 0x19d9, + .term198 = 0xafd, + .term199 = 0x252a, + .term200 = 0x10d5, + .term201 = 0x1dc0, + .term202 = 0x22e7, + .term203 = 0x1d1b, + .term204 = 0x258, + .term205 = 0x1481, + .term206 = 0x1977, + .term207 = 0x614, + .term208 = 0xaee, + .term209 = 0x12f, + .term210 = 0x1850, + .term211 = 0x3f0, + .term212 = 0x16d4, + .term213 = 0xa31, + .term214 = 0x137d, + .term215 = 0xa8e, + .term216 = 0xc7b, + .term217 = 0x1e5, + .term218 = 0xc15, + .term219 = 0x10f7, + .term220 = 0x20b, + .term221 = 0x633, + .term222 = 0x2462, + .term223 = 0x251f, + .term224 = 0x1d18, + .term225 = 0x1450, + .term226 = 0xd82, + .term227 = 0x19da, + .term228 = 0x244, + .term229 = 0x2644, + .term230 = 0x12be, + .term231 = 0x14a1, + .term232 = 0x2575, + .term233 = 0x31e, + .term234 = 0x1f49, + .term235 = 0x1bf5, + .term236 = 0x1d8, + .term237 = 0xe26, + .term238 = 0x215a, + .term239 = 0x8f4, + .term240 = 0x1796, + .term241 = 0x1053, + .term242 = 0x1ffe, + .term243 = 0x25b9, + .term244 = 0x1f16, + .term245 = 0x182f, + .term246 = 0x2657, + .term247 = 0xb48, + .term248 = 0x23c4, + .term249 = 0x5e7, + .term250 = 0x183a, + .term251 = 0xa4a, + .term252 = 0x10b0, + .term253 = 0x37, + .term254 = 0x148, + .term255 = 0xa56, + .term256 = 0x18da, + .term257 = 0x1316, + .term258 = 0x22ab, + .term259 = 0x20f1, + .term260 = 0x268d, + .term261 = 0x8e, + .term262 = 0xf04, + .term263 = 0x588, + .term264 = 0x759, + .term265 = 0x7ce, + .term266 = 0x142, + .term267 = 0x21cb, + .term268 = 0x15, + .term269 = 0x1643, + .term270 = 0xde5, + .term271 = 0x211c, + .term272 = 0x1ed4, + .term273 = 0x1125, + .term274 = 0x13d3, + .term275 = 0x2c8, + .term276 = 0xa28, + .term277 = 0x9ce, + .term278 = 0x3eb, + .term279 = 0x1ad5, + .term280 = 0x1eb5, + .term281 = 0x1250, + .term282 = 0xd49, + .term283 = 0x263d, + .term284 = 0x1487, + .term285 = 0x1917, + .term286 = 0x138a, + .term287 = 0x249, + .term288 = 0x1056, + .term289 = 0x11d, + .term290 = 0x1bb0, + .term291 = 0x592, + .term292 = 0x21a9, + .term293 = 0xead, + .term294 = 0x2668, + .term295 = 0x3a4, + .term296 = 0x1049, + .term297 = 0x86a, + .term298 = 0x1659, + .term299 = 0x1c15, + .term300 = 0x26f8, + .term301 = 0x531, + .term302 = 0x940, + .term303 = 0x21f4, + .term304 = 0x591, + .term305 = 0x22b, + .term306 = 0xd6a, + .term307 = 0x1995, + .term308 = 0x1d11, + .term309 = 0x2528, + .term310 = 0x91, + .term311 = 0x1f7c, + .term312 = 0x6b6, + .term313 = 0xea9, + .term314 = 0x17fb, + .term315 = 0x977, + .term316 = 0x1887, + .term317 = 0x176c, + .term318 = 0x1a1f, + .term319 = 0x9e1, + .term320 = 0x9f5, + .term321 = 0x1d0d, + .term322 = 0x268a, + .term323 = 0xb85, + .term324 = 0xc1, + .term325 = 0xc7b, + .term326 = 0xce1, + .term327 = 0x1a0, + .term328 = 0x205e, + .term329 = 0x17d9, + .term330 = 0x1188, + .term331 = 0x188a, + .term332 = 0x997, + .term333 = 0x1666, + .term334 = 0x1fb2, + .term335 = 0x6a5, + .term336 = 0x524, + .term337 = 0x29f, + .term338 = 0x169a, + .term339 = 0x8d7, + .term340 = 0x10d9, + .term341 = 0x1103, + .term342 = 0x4a1, + .term343 = 0x35, + .term344 = 0x390, + .term345 = 0x328, + .term346 = 0x728, + .term347 = 0x3b1, + .term348 = 0x10d9, + .term349 = 0x1e4c, + .term350 = 0x2081, + .term351 = 0x2556, + .term352 = 0xe3e, + .term353 = 0x1f2e, + .term354 = 0x1e1, + .term355 = 0x1030, + .term356 = 0xc7c, + .term357 = 0xde, + .term358 = 0x1bd9, + .term359 = 0x871, + .term360 = 0x159f, + .term361 = 0x1c2, + .term362 = 0x495, + .term363 = 0x1d2, + .term364 = 0x7fc, + .term365 = 0x67b, + .term366 = 0x1894, + .term367 = 0x1927, + .term368 = 0x1c55, + .term369 = 0x18, + .term370 = 0x180a, + .term371 = 0x2526, + .term372 = 0x1289, + .term373 = 0x289, + .term374 = 0xc72, + .term375 = 0x2079, + .term376 = 0x117a, + .term377 = 0x1f56, + .term378 = 0x878, + .term379 = 0xfb2, + .term380 = 0x2253, + .term381 = 0x26b1, + .term382 = 0x1f16, + .term383 = 0x1cdf, + .term384 = 0xca, + .term385 = 0xe29, + .term386 = 0x194d, + .term387 = 0x113e, + .term388 = 0x2462, + .term389 = 0x16c0, + .term390 = 0x2476, + .term391 = 0x16f2, + .term392 = 0x1114, + .term393 = 0x9f, + .term394 = 0x729, + .term395 = 0x1f86, + .term396 = 0x1d3f, + .term397 = 0x2069, + .term398 = 0x1d5e, + .term399 = 0x1ff1, + .term400 = 0x1e5d, + .term401 = 0x8de, + .term402 = 0x6e3, + .term403 = 0xa6c, + .term404 = 0x1c18, + .term405 = 0xf91, + .term406 = 0xc1e, + .term407 = 0x2120, + .term408 = 0x23fd, + .term409 = 0x1dcb, + .term410 = 0x12c2, + .term411 = 0x1003, + .term412 = 0x20f, + .term413 = 0xa41, + .term414 = 0x607, + .term415 = 0x784, + .term416 = 0x3ff, + .term417 = 0x26f4, + .term418 = 0xbf5, + .term419 = 0x1055, + .term420 = 0x3eb, + .term421 = 0x1d08, + .term422 = 0x1d51, + .term423 = 0x1da9, + .term424 = 0xaa5, + .term425 = 0xbd7, + .term426 = 0x212c, + .term427 = 0x8e, + .term428 = 0x1c36, + .term429 = 0x506, + .term430 = 0xbf8, + .term431 = 0x1edc, + .term432 = 0x23e3, + .term433 = 0x20a8, + .term434 = 0x96d, + .term435 = 0x3ce, + .term436 = 0x10ae, + .term437 = 0x23d2, + .term438 = 0xeb, + .term439 = 0x341, + .term440 = 0x25ef, + .term441 = 0x1680, + .term442 = 0x22c0, + .term443 = 0x123b, + .term444 = 0x1c75, + .term445 = 0x9f6, + .term446 = 0x8c, + .term447 = 0xe6e, + .term448 = 0xa87, + .term449 = 0x658, + .term450 = 0x1f53, + .term451 = 0x84d, + .term452 = 0x19b0, + .term453 = 0x69e, + .term454 = 0xa62, + .term455 = 0x189e, + .term456 = 0x1ccb, + .term457 = 0x9a2, + .term458 = 0x1246, + .term459 = 0xa21, + .term460 = 0xf0b, + .term461 = 0x156c, + .term462 = 0x3fa, + .term463 = 0x2110, + .term464 = 0x45f, + .term465 = 0xc50, + .term466 = 0xaf0, + .term467 = 0x1f97, + .term468 = 0x424, + .term469 = 0x786, + .term470 = 0x2332, + .term471 = 0x1295, + .term472 = 0x87a, + .term473 = 0x13b, + .term474 = 0x2568, + .term475 = 0xe3, + .term476 = 0x7fb, + .term477 = 0xac6, + .term478 = 0x1bfc, + .term479 = 0x13f5, + .term480 = 0x1eca, + .term481 = 0x1bae, + .term482 = 0x255d, + .term483 = 0xd9f, + .term484 = 0x2569, + .term485 = 0x117a, + .term486 = 0xa41, + .term487 = 0x15fb, + .term488 = 0x15fd, + .term489 = 0x788, + .term490 = 0x152f, + .term491 = 0x2148, + .term492 = 0x1af6, + .term493 = 0x1362, + .term494 = 0x7b, + .term495 = 0x11f4, + .term496 = 0xe99, + .term497 = 0xcbd, + .term498 = 0xc3, + .term499 = 0x9dd, + .term500 = 0x4f0, + .term501 = 0x2044, + .term502 = 0x183a, + .term503 = 0x1fb4, + .term504 = 0x13a6, + .term505 = 0x146, + .term506 = 0x2333, + .term507 = 0x303, + .term508 = 0x190b, + .term509 = 0x15ab, + .term510 = 0x481, + .term511 = 0x5f0, + .term512 = 0x263e, + .term513 = 0x133c, + .term514 = 0xbc, + .term515 = 0x6e3, + .term516 = 0x134c, + .term517 = 0x353, + .term518 = 0x21d6, + .term519 = 0xef5, + .term520 = 0x384, + .term521 = 0x1e21, + .term522 = 0x22fe, + .term523 = 0x1d9a, + .term524 = 0x20ad, + .term525 = 0xbbf, + .term526 = 0x5c5, + .term527 = 0x4b0, + .term528 = 0x17aa, + .term529 = 0x1927, + .term530 = 0x8ff, + .term531 = 0xac8, + .term532 = 0x248d, + .term533 = 0x914, + .term534 = 0x194d, + .term535 = 0x13f4, + .term536 = 0x459, + .term537 = 0x1317, + .term538 = 0x2649, + .term539 = 0xb22, + .term540 = 0x116c, + .term541 = 0x97c, + .term542 = 0xbb1, + .term543 = 0x1cd8, + .term544 = 0x24bd, + .term545 = 0x198c, + .term546 = 0x457, + .term547 = 0x2200, + .term548 = 0xb13, + .term549 = 0x934, + .term550 = 0x17b8, + .term551 = 0x2486, + .term552 = 0x2277, + .term553 = 0x1185, + .term554 = 0x22c, + .term555 = 0xc90, + .term556 = 0x65a, + .term557 = 0x248d, + .term558 = 0x214e, + .term559 = 0xd1d, + .term560 = 0x2479, + .term561 = 0xcc7, + .term562 = 0xf1d, + .term563 = 0x2491, + .term564 = 0xb50, + .term565 = 0xbce, + .term566 = 0x2591, + .term567 = 0x70, + .term568 = 0xa9d, + .term569 = 0x21f8, + .term570 = 0x631, + .term571 = 0xfc9, + .term572 = 0x1147, + .term573 = 0x1021, + .term574 = 0x1085, + .term575 = 0x11d5, + .term576 = 0x199f, + .term577 = 0x22e4, + .term578 = 0x8f8, + .term579 = 0x267f, + .term580 = 0x805, + .term581 = 0x1b32, + .term582 = 0xe00, + .term583 = 0x2606, + .term584 = 0x19fe, + .term585 = 0x1b3c, + .term586 = 0x5b1, + .term587 = 0x1111, + .term588 = 0x9e4, + .term589 = 0xb93, + .term590 = 0xa2f, + .term591 = 0x9b3, + .term592 = 0x38f, + .term593 = 0x663, + .term594 = 0x43, + .term595 = 0xb20, + .term596 = 0x1243, + .term597 = 0xb7a, + .term598 = 0x8af, + .term599 = 0x85e, + .term600 = 0xeaa, + .term601 = 0x196f, + .term602 = 0xab5, + .term603 = 0xaf, + .term604 = 0x5b3, + .term605 = 0x1e91, + .term606 = 0xc95, + .term607 = 0x1ebe, + .term608 = 0x65a, + .term609 = 0x78e, + .term610 = 0x1455, + .term611 = 0x6f7, + .term612 = 0xf0a, + .term613 = 0x1ce6, + .term614 = 0x8e7, + .term615 = 0xa8d, + .term616 = 0x891, + .term617 = 0xaae, + .term618 = 0x665, + .term619 = 0x1986, + .term620 = 0x15b4, + .term621 = 0x7c9, + .term622 = 0xb0, + .term623 = 0x1649, + .term624 = 0x1b32, + .term625 = 0x224, + .term626 = 0x16f9, + .term627 = 0x12c, + .term628 = 0x113d, + .term629 = 0x19f1, + .term630 = 0x267f, + .term631 = 0x12f7, + .term632 = 0xc46, + .term633 = 0x5b6, + .term634 = 0x1dbb, + .term635 = 0x36d, + .term636 = 0x1a8, + .term637 = 0xa76, + .term638 = 0x6d8, + .term639 = 0x20fb, + .term640 = 0x2068, + .term641 = 0xa71, + .term642 = 0x28, + .term643 = 0x2461, + .term644 = 0x36b, + .term645 = 0x48, + .term646 = 0xb02, + .term647 = 0x262, + .term648 = 0x3f9, + .term649 = 0x1344, + .term650 = 0x1fb0, + .term651 = 0x2b7, + .term652 = 0xc61, + .term653 = 0xef7, + .term654 = 0x28, + .term655 = 0x1958, + .term656 = 0x21ed, + .term657 = 0x2382, + .term658 = 0x2519, + .term659 = 0xa1d, + .term660 = 0x1766, + .term661 = 0x1419, + .term662 = 0x2489, + .term663 = 0x2462, + .term664 = 0x21cb, + .term665 = 0x1a54, + .term666 = 0x7fc, + .term667 = 0x4ea, + .term668 = 0x14f, + .term669 = 0x2237, + .term670 = 0x4a8, + .term671 = 0x1db5, + .term672 = 0x1490, + .term673 = 0x885, + .term674 = 0x2137, + .term675 = 0xef5, + .term676 = 0xebf, + .term677 = 0x260, + .term678 = 0x244c, + .term679 = 0x176d, + .term680 = 0x1d7d, + .term681 = 0x2554, + .term682 = 0x15b9, + .term683 = 0x65b, + .term684 = 0x1943, + .term685 = 0x2545, + .term686 = 0x17f1, + .term687 = 0x4d8, + .term688 = 0x1e85, + .term689 = 0x23d6, + .term690 = 0x259, + .term691 = 0x17bd, + .term692 = 0xd7, + .term693 = 0x21eb, + .term694 = 0x2015, + .term695 = 0xf98, + .term696 = 0x16c0, + .term697 = 0x15e1, + .term698 = 0xd40, + .term699 = 0x167f, + .term700 = 0xa6e, + .term701 = 0x191c, + .term702 = 0x1f5b, + .term703 = 0xff4, + .term704 = 0x4b, + .term705 = 0x2252, + .term706 = 0x157a, + .term707 = 0x136a, + .term708 = 0x188f, + .term709 = 0xf07, + .term710 = 0xa2c, + .term711 = 0x1f7, + .term712 = 0x4c5, + .term713 = 0xa67, + .term714 = 0x164a, + .term715 = 0x93b, + .term716 = 0x2332, + .term717 = 0x87b, + .term718 = 0x1d41, + .term719 = 0x2030, + .term720 = 0x874, + .term721 = 0x15a6, + .term722 = 0x1dc3, + .term723 = 0x391, + .term724 = 0x1da7, + .term725 = 0x1a30, + .term726 = 0x71a, + .term727 = 0x2410, + .term728 = 0x2ee, + .term729 = 0x1455, + .term730 = 0x136f, + .term731 = 0x603, + .term732 = 0x12f, + .term733 = 0x58e, + .term734 = 0x44a, + .term735 = 0x4df, + .term736 = 0xe00, + .term737 = 0xe40, + .term738 = 0xb9b, + .term739 = 0x1eb8, + .term740 = 0xb61, + .term741 = 0x433, + .term742 = 0x609, + .term743 = 0x2208, + .term744 = 0x1d7a, + .term745 = 0x21e6, + .term746 = 0x6e9, + .term747 = 0x148e, + .term748 = 0x2147, + .term749 = 0xf91, + .term750 = 0x2061, + .term751 = 0x1738, + .term752 = 0xb31, + .term753 = 0x215c, + .term754 = 0xcad, + .term755 = 0x1584, + .term756 = 0x207e, + .term757 = 0x1ebe, + .term758 = 0x2581, + .term759 = 0x2083, + .term760 = 0x46c, + .term761 = 0x1178, + .term762 = 0x1bf0, + .term763 = 0x13df, + .term764 = 0x217a, + .term765 = 0x2623, + .term766 = 0x26ad, + .term767 = 0x1bbf, + .term768 = 0x1147, + .term769 = 0xdc7, + .term770 = 0x640, + .term771 = 0x1b39, + .term772 = 0xfaf, + .term773 = 0x15bd, + .term774 = 0x1c, + .term775 = 0x607, + .term776 = 0x14e3, + .term777 = 0x828, + .term778 = 0xb7f, + .term779 = 0xa4d, + .term780 = 0x969, + .term781 = 0x193f, + .term782 = 0x13b9, + .term783 = 0x1249, + .term784 = 0x634, + .term785 = 0x53e, + .term786 = 0x260, + .term787 = 0x80c, + .term788 = 0x4c5, + .term789 = 0x6de, + .term790 = 0x26e2, + .term791 = 0x378, + .term792 = 0x1032, + .term793 = 0x2b2, + .term794 = 0x1f0d, + .term795 = 0xb1b, + .term796 = 0x596, + .term797 = 0x15f4, + .term798 = 0x2ec, + .term799 = 0x1b9b, + .term800 = 0x11b8, + .term801 = 0x30f, + .term802 = 0x1f63, + .term803 = 0x8b2, + .term804 = 0x1441, + .term805 = 0x1b7e, + .term806 = 0x267d, + .term807 = 0x15fd, + .term808 = 0x4c8, + .term809 = 0x1674, + .term810 = 0x26c3, + .term811 = 0xd1f, + .term812 = 0x8d1, + .term813 = 0x129e, + .term814 = 0x1350, + .term815 = 0x135b, + .term816 = 0xcf6, + .term817 = 0xaa6, + .term818 = 0x1523, + .term819 = 0x401, + .term820 = 0x163, + .term821 = 0x3e9, + .term822 = 0x9f5, + .term823 = 0x2518, + .term824 = 0x2188, + .term825 = 0x252b, + .term826 = 0x1f1c, + .term827 = 0xd0e, + .term828 = 0x1f8b, + .term829 = 0x1ee9, + .term830 = 0x17fe, + .term831 = 0x4ac, + .term832 = 0x79c, + .term833 = 0x13d0, + .term834 = 0x1aa, + .term835 = 0x11fe, + .term836 = 0x181d, + .term837 = 0x114d, + .term838 = 0x964, + .term839 = 0x1a31, + .term840 = 0x272, + .term841 = 0x2654, + .term842 = 0x249f, + .term843 = 0x5d, + .term844 = 0x19a5, + .term845 = 0x1794, + .term846 = 0x1280, + .term847 = 0x23b5, + .term848 = 0x32e, + .term849 = 0x176a, + .term850 = 0x2040, + .term851 = 0x19fc, + .term852 = 0xf60, + .term853 = 0x346, + .term854 = 0x1e2, + .term855 = 0x54b, + .term856 = 0x3f7, + .term857 = 0x46b, + .term858 = 0x2026, + .term859 = 0x1ea1, + .term860 = 0x1211, + .term861 = 0x7db, + .term862 = 0xa4d, + .term863 = 0x105a, + .term864 = 0x25da, + .term865 = 0x672, + .term866 = 0x161e, + .term867 = 0x662, + .term868 = 0x37d, + .term869 = 0x161, + .term870 = 0x588, + .term871 = 0xd7c, + .term872 = 0xfa8, + .term873 = 0x1c5e, + .term874 = 0x8b9, + .term875 = 0x154e, + .term876 = 0x189f, + .term877 = 0x19ea, + .term878 = 0x189f, + .term879 = 0x10a0, + .term880 = 0x94, + .term881 = 0x464, + .term882 = 0x90d, + .term883 = 0x1075, + .term884 = 0x1bc5, + .term885 = 0xfbc, + .term886 = 0x23f0, + .term887 = 0x438, + .term888 = 0x526, + .term889 = 0x1aca, + .term890 = 0xfd2, + .term891 = 0x103b, + .term892 = 0x551, + .term893 = 0x1490, + .term894 = 0x76f, + .term895 = 0xe5c, + .term896 = 0x25ab, + .term897 = 0x1afd, + .term898 = 0x1326, + .term899 = 0xde9, + .term900 = 0x2129, + .term901 = 0x1354, + .term902 = 0x502, + .term903 = 0xe45, + .term904 = 0x2a2, + .term905 = 0x8ac, + .term906 = 0x151a, + .term907 = 0x1b0b, + .term908 = 0xef7, + .term909 = 0x2499, + .term910 = 0xf26, + .term911 = 0x103, + .term912 = 0x2330, + .term913 = 0xa3b, + .term914 = 0xf83, + .term915 = 0x3, + .term916 = 0x799, + .term917 = 0x2635, + .term918 = 0x1968, + .term919 = 0x958, + .term920 = 0xa7d, + .term921 = 0x14c1, + .term922 = 0x1a2a, + .term923 = 0x15d5, + .term924 = 0xaa2, + .term925 = 0x1732, + .term926 = 0x234d, + .term927 = 0x190a, + .term928 = 0x5b5, + .term929 = 0x185a, + .term930 = 0x9cc, + .term931 = 0x26e9, + .term932 = 0xf77, + .term933 = 0x195d, + .term934 = 0x5eb, + .term935 = 0x1495, + .term936 = 0x1349, + .term937 = 0x22a5, + .term938 = 0x3a, + .term939 = 0x125c, + .term940 = 0xf83, + .term941 = 0x1878, + .term942 = 0x13fd, + .term943 = 0x1847, + .term944 = 0x11cb, + .term945 = 0x1e87, + .term946 = 0x208a, + .term947 = 0xbdf, + .term948 = 0xd4, + .term949 = 0x2448, + .term950 = 0x1f92, + .term951 = 0x7a2, + .term952 = 0x17c5, + .term953 = 0x2c6, + .term954 = 0x1184, + .term955 = 0x12a6, + .term956 = 0x20bc, + .term957 = 0x2657, + .term958 = 0x173f, + .term959 = 0x198d, + .term960 = 0x1fb3, + .term961 = 0x68f, + .term962 = 0x1bc6, + .term963 = 0x170a, + .term964 = 0xc01, + .term965 = 0x314, + .term966 = 0xf89, + .term967 = 0x1fc4, + .term968 = 0x26e4, + .term969 = 0x21f1, + .term970 = 0x17e1, + .term971 = 0x8, + .term972 = 0xb7d, + .term973 = 0x169e, + .term974 = 0x6bb, + .term975 = 0x553, + .term976 = 0x1c, + .term977 = 0x1440, + .term978 = 0x12aa, + .term979 = 0x1c20, + .term980 = 0x13cf, + .term981 = 0x75d, + .term982 = 0x7b6, + .term983 = 0x42f, + .term984 = 0x535, + .term985 = 0xb33, + .term986 = 0x1809, + .term987 = 0x10c7, + .term988 = 0x878, + .term989 = 0x339, + .term990 = 0x25cc, + .term991 = 0x15fd, + .term992 = 0x21ca, + .term993 = 0xa26, + .term994 = 0xced, + .term995 = 0x1255, + .term996 = 0x124e, + }, + .bar = { + .term997 = 0x50, + .term998 = 0x74, + .term999 = 0x8c9, + }, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/32_large_hsl/golden.d.hcs b/tools/hc-gen/test/32_large_hsl/golden.d.hcs new file mode 100644 index 000000000..6a6f8d049 --- /dev/null +++ b/tools/hc-gen/test/32_large_hsl/golden.d.hcs @@ -0,0 +1,1011 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo { + term0 = 0x29; + term1 = 0x2113; + term2 = 0x18BE; + term3 = 0x1964; + term4 = 0x23D1; + term5 = 0x165C; + term6 = 0x5C6; + term7 = 0x248E; + term8 = 0x1B32; + term9 = 0x1170; + term10 = 0x1649; + term11 = 0x1FD1; + term12 = 0xCD1; + term13 = 0x1AAB; + term14 = 0x26E9; + term15 = 0x1EB; + term16 = 0xBB3; + term17 = 0x796; + term18 = 0x12DB; + term19 = 0x153C; + term20 = 0x957; + term21 = 0x11FC; + term22 = 0xF3E; + term23 = 0x99; + term24 = 0x124; + term25 = 0x94E; + term26 = 0x1CFD; + term27 = 0x220C; + term28 = 0x25F6; + term29 = 0x26A7; + term30 = 0x1547; + term31 = 0x6BE; + term32 = 0x12A3; + term33 = 0x602; + term34 = 0x74D; + term35 = 0x26B8; + term36 = 0x1623; + term37 = 0x189B; + term38 = 0x1B7B; + term39 = 0x26A6; + term40 = 0x21FF; + term41 = 0xEE3; + term42 = 0x52A; + term43 = 0x14D; + term44 = 0x1DF9; + term45 = 0x1238; + term46 = 0x1415; + term47 = 0x1E1F; + term48 = 0x203D; + term49 = 0x1AD4; + term50 = 0x15AB; + term51 = 0x1DDC; + term52 = 0xA66; + term53 = 0xAC5; + term54 = 0x25; + term55 = 0xB2B; + term56 = 0x2213; + term57 = 0x260D; + term58 = 0x1D69; + term59 = 0x30A; + term60 = 0x90C; + term61 = 0xBDB; + term62 = 0x88E; + term63 = 0x732; + term64 = 0x120; + term65 = 0x6A; + term66 = 0x2350; + term67 = 0x22EE; + term68 = 0x2430; + term69 = 0xA58; + term70 = 0x1D16; + term71 = 0xEDD; + term72 = 0x1702; + term73 = 0x1A49; + term74 = 0x1112; + term75 = 0x14E6; + term76 = 0x138E; + term77 = 0x44D; + term78 = 0x1129; + term79 = 0xDDC; + term80 = 0x259D; + term81 = 0xA3F; + term82 = 0xFF4; + term83 = 0x26E2; + term84 = 0x2234; + term85 = 0x730; + term86 = 0x1366; + term87 = 0x1CD0; + term88 = 0xF5B; + term89 = 0x18A4; + term90 = 0x1B20; + term91 = 0x987; + term92 = 0x1212; + term93 = 0x52B; + term94 = 0x15A1; + term95 = 0x602; + term96 = 0x17E6; + term97 = 0x822; + term98 = 0xB71; + term99 = 0x198D; + term100 = 0x12E1; + term101 = 0x45B; + term102 = 0x121F; + term103 = 0x25BA; + term104 = 0xA90; + term105 = 0x26CA; + term106 = 0xF89; + term107 = 0x902; + term108 = 0x689; + term109 = 0x952; + term110 = 0x139D; + term111 = 0x2229; + term112 = 0x1B0C; + term113 = 0x2370; + term114 = 0x187E; + term115 = 0x16C5; + term116 = 0x1A79; + term117 = 0x15C5; + term118 = 0x13E9; + term119 = 0x1970; + term120 = 0xF92; + term121 = 0xCDA; + term122 = 0x23C9; + term123 = 0x21BC; + term124 = 0x933; + term125 = 0x129F; + term126 = 0xE47; + term127 = 0x15C6; + term128 = 0xFBF; + term129 = 0x804; + term130 = 0x1CB6; + term131 = 0x47E; + term132 = 0x1B1D; + term133 = 0x6BC; + term134 = 0xF7E; + term135 = 0xD66; + term136 = 0x453; + term137 = 0xBF; + term138 = 0x1F47; + term139 = 0x539; + term140 = 0x1551; + term141 = 0x8EF; + term142 = 0x1E49; + term143 = 0x17F; + term144 = 0x1351; + term145 = 0x22CD; + term146 = 0x8A1; + term147 = 0x261E; + term148 = 0x107D; + term149 = 0x218C; + term150 = 0x1916; + term151 = 0x1352; + term152 = 0x1D52; + term153 = 0xBD6; + term154 = 0x190D; + term155 = 0x23D0; + term156 = 0x384; + term157 = 0xA1F; + term158 = 0x223A; + term159 = 0x677; + term160 = 0x1CF2; + term161 = 0x18D7; + term162 = 0x1DC8; + term163 = 0x219; + term164 = 0x60C; + term165 = 0x1953; + term166 = 0x1DAB; + term167 = 0xFC9; + term168 = 0xE12; + term169 = 0x10FE; + term170 = 0x123; + term171 = 0x344; + term172 = 0x249E; + term173 = 0x3FC; + term174 = 0x11F4; + term175 = 0xFB5; + term176 = 0x1CB4; + term177 = 0xC7F; + term178 = 0x25C4; + term179 = 0x1184; + term180 = 0x2059; + term181 = 0x127E; + term182 = 0x35; + term183 = 0x7CF; + term184 = 0x1912; + term185 = 0x1F02; + term186 = 0x1AF4; + term187 = 0xECC; + term188 = 0x1FBF; + term189 = 0x1D3; + term190 = 0xE90; + term191 = 0x131D; + term192 = 0x1228; + term193 = 0x9B3; + term194 = 0x1E7F; + term195 = 0x975; + term196 = 0x10D6; + term197 = 0x19D9; + term198 = 0xAFD; + term199 = 0x252A; + term200 = 0x10D5; + term201 = 0x1DC0; + term202 = 0x22E7; + term203 = 0x1D1B; + term204 = 0x258; + term205 = 0x1481; + term206 = 0x1977; + term207 = 0x614; + term208 = 0xAEE; + term209 = 0x12F; + term210 = 0x1850; + term211 = 0x3F0; + term212 = 0x16D4; + term213 = 0xA31; + term214 = 0x137D; + term215 = 0xA8E; + term216 = 0xC7B; + term217 = 0x1E5; + term218 = 0xC15; + term219 = 0x10F7; + term220 = 0x20B; + term221 = 0x633; + term222 = 0x2462; + term223 = 0x251F; + term224 = 0x1D18; + term225 = 0x1450; + term226 = 0xD82; + term227 = 0x19DA; + term228 = 0x244; + term229 = 0x2644; + term230 = 0x12BE; + term231 = 0x14A1; + term232 = 0x2575; + term233 = 0x31E; + term234 = 0x1F49; + term235 = 0x1BF5; + term236 = 0x1D8; + term237 = 0xE26; + term238 = 0x215A; + term239 = 0x8F4; + term240 = 0x1796; + term241 = 0x1053; + term242 = 0x1FFE; + term243 = 0x25B9; + term244 = 0x1F16; + term245 = 0x182F; + term246 = 0x2657; + term247 = 0xB48; + term248 = 0x23C4; + term249 = 0x5E7; + term250 = 0x183A; + term251 = 0xA4A; + term252 = 0x10B0; + term253 = 0x37; + term254 = 0x148; + term255 = 0xA56; + term256 = 0x18DA; + term257 = 0x1316; + term258 = 0x22AB; + term259 = 0x20F1; + term260 = 0x268D; + term261 = 0x8E; + term262 = 0xF04; + term263 = 0x588; + term264 = 0x759; + term265 = 0x7CE; + term266 = 0x142; + term267 = 0x21CB; + term268 = 0x15; + term269 = 0x1643; + term270 = 0xDE5; + term271 = 0x211C; + term272 = 0x1ED4; + term273 = 0x1125; + term274 = 0x13D3; + term275 = 0x2C8; + term276 = 0xA28; + term277 = 0x9CE; + term278 = 0x3EB; + term279 = 0x1AD5; + term280 = 0x1EB5; + term281 = 0x1250; + term282 = 0xD49; + term283 = 0x263D; + term284 = 0x1487; + term285 = 0x1917; + term286 = 0x138A; + term287 = 0x249; + term288 = 0x1056; + term289 = 0x11D; + term290 = 0x1BB0; + term291 = 0x592; + term292 = 0x21A9; + term293 = 0xEAD; + term294 = 0x2668; + term295 = 0x3A4; + term296 = 0x1049; + term297 = 0x86A; + term298 = 0x1659; + term299 = 0x1C15; + term300 = 0x26F8; + term301 = 0x531; + term302 = 0x940; + term303 = 0x21F4; + term304 = 0x591; + term305 = 0x22B; + term306 = 0xD6A; + term307 = 0x1995; + term308 = 0x1D11; + term309 = 0x2528; + term310 = 0x91; + term311 = 0x1F7C; + term312 = 0x6B6; + term313 = 0xEA9; + term314 = 0x17FB; + term315 = 0x977; + term316 = 0x1887; + term317 = 0x176C; + term318 = 0x1A1F; + term319 = 0x9E1; + term320 = 0x9F5; + term321 = 0x1D0D; + term322 = 0x268A; + term323 = 0xB85; + term324 = 0xC1; + term325 = 0xC7B; + term326 = 0xCE1; + term327 = 0x1A0; + term328 = 0x205E; + term329 = 0x17D9; + term330 = 0x1188; + term331 = 0x188A; + term332 = 0x997; + term333 = 0x1666; + term334 = 0x1FB2; + term335 = 0x6A5; + term336 = 0x524; + term337 = 0x29F; + term338 = 0x169A; + term339 = 0x8D7; + term340 = 0x10D9; + term341 = 0x1103; + term342 = 0x4A1; + term343 = 0x35; + term344 = 0x390; + term345 = 0x328; + term346 = 0x728; + term347 = 0x3B1; + term348 = 0x10D9; + term349 = 0x1E4C; + term350 = 0x2081; + term351 = 0x2556; + term352 = 0xE3E; + term353 = 0x1F2E; + term354 = 0x1E1; + term355 = 0x1030; + term356 = 0xC7C; + term357 = 0xDE; + term358 = 0x1BD9; + term359 = 0x871; + term360 = 0x159F; + term361 = 0x1C2; + term362 = 0x495; + term363 = 0x1D2; + term364 = 0x7FC; + term365 = 0x67B; + term366 = 0x1894; + term367 = 0x1927; + term368 = 0x1C55; + term369 = 0x18; + term370 = 0x180A; + term371 = 0x2526; + term372 = 0x1289; + term373 = 0x289; + term374 = 0xC72; + term375 = 0x2079; + term376 = 0x117A; + term377 = 0x1F56; + term378 = 0x878; + term379 = 0xFB2; + term380 = 0x2253; + term381 = 0x26B1; + term382 = 0x1F16; + term383 = 0x1CDF; + term384 = 0xCA; + term385 = 0xE29; + term386 = 0x194D; + term387 = 0x113E; + term388 = 0x2462; + term389 = 0x16C0; + term390 = 0x2476; + term391 = 0x16F2; + term392 = 0x1114; + term393 = 0x9F; + term394 = 0x729; + term395 = 0x1F86; + term396 = 0x1D3F; + term397 = 0x2069; + term398 = 0x1D5E; + term399 = 0x1FF1; + term400 = 0x1E5D; + term401 = 0x8DE; + term402 = 0x6E3; + term403 = 0xA6C; + term404 = 0x1C18; + term405 = 0xF91; + term406 = 0xC1E; + term407 = 0x2120; + term408 = 0x23FD; + term409 = 0x1DCB; + term410 = 0x12C2; + term411 = 0x1003; + term412 = 0x20F; + term413 = 0xA41; + term414 = 0x607; + term415 = 0x784; + term416 = 0x3FF; + term417 = 0x26F4; + term418 = 0xBF5; + term419 = 0x1055; + term420 = 0x3EB; + term421 = 0x1D08; + term422 = 0x1D51; + term423 = 0x1DA9; + term424 = 0xAA5; + term425 = 0xBD7; + term426 = 0x212C; + term427 = 0x8E; + term428 = 0x1C36; + term429 = 0x506; + term430 = 0xBF8; + term431 = 0x1EDC; + term432 = 0x23E3; + term433 = 0x20A8; + term434 = 0x96D; + term435 = 0x3CE; + term436 = 0x10AE; + term437 = 0x23D2; + term438 = 0xEB; + term439 = 0x341; + term440 = 0x25EF; + term441 = 0x1680; + term442 = 0x22C0; + term443 = 0x123B; + term444 = 0x1C75; + term445 = 0x9F6; + term446 = 0x8C; + term447 = 0xE6E; + term448 = 0xA87; + term449 = 0x658; + term450 = 0x1F53; + term451 = 0x84D; + term452 = 0x19B0; + term453 = 0x69E; + term454 = 0xA62; + term455 = 0x189E; + term456 = 0x1CCB; + term457 = 0x9A2; + term458 = 0x1246; + term459 = 0xA21; + term460 = 0xF0B; + term461 = 0x156C; + term462 = 0x3FA; + term463 = 0x2110; + term464 = 0x45F; + term465 = 0xC50; + term466 = 0xAF0; + term467 = 0x1F97; + term468 = 0x424; + term469 = 0x786; + term470 = 0x2332; + term471 = 0x1295; + term472 = 0x87A; + term473 = 0x13B; + term474 = 0x2568; + term475 = 0xE3; + term476 = 0x7FB; + term477 = 0xAC6; + term478 = 0x1BFC; + term479 = 0x13F5; + term480 = 0x1ECA; + term481 = 0x1BAE; + term482 = 0x255D; + term483 = 0xD9F; + term484 = 0x2569; + term485 = 0x117A; + term486 = 0xA41; + term487 = 0x15FB; + term488 = 0x15FD; + term489 = 0x788; + term490 = 0x152F; + term491 = 0x2148; + term492 = 0x1AF6; + term493 = 0x1362; + term494 = 0x7B; + term495 = 0x11F4; + term496 = 0xE99; + term497 = 0xCBD; + term498 = 0xC3; + term499 = 0x9DD; + term500 = 0x4F0; + term501 = 0x2044; + term502 = 0x183A; + term503 = 0x1FB4; + term504 = 0x13A6; + term505 = 0x146; + term506 = 0x2333; + term507 = 0x303; + term508 = 0x190B; + term509 = 0x15AB; + term510 = 0x481; + term511 = 0x5F0; + term512 = 0x263E; + term513 = 0x133C; + term514 = 0xBC; + term515 = 0x6E3; + term516 = 0x134C; + term517 = 0x353; + term518 = 0x21D6; + term519 = 0xEF5; + term520 = 0x384; + term521 = 0x1E21; + term522 = 0x22FE; + term523 = 0x1D9A; + term524 = 0x20AD; + term525 = 0xBBF; + term526 = 0x5C5; + term527 = 0x4B0; + term528 = 0x17AA; + term529 = 0x1927; + term530 = 0x8FF; + term531 = 0xAC8; + term532 = 0x248D; + term533 = 0x914; + term534 = 0x194D; + term535 = 0x13F4; + term536 = 0x459; + term537 = 0x1317; + term538 = 0x2649; + term539 = 0xB22; + term540 = 0x116C; + term541 = 0x97C; + term542 = 0xBB1; + term543 = 0x1CD8; + term544 = 0x24BD; + term545 = 0x198C; + term546 = 0x457; + term547 = 0x2200; + term548 = 0xB13; + term549 = 0x934; + term550 = 0x17B8; + term551 = 0x2486; + term552 = 0x2277; + term553 = 0x1185; + term554 = 0x22C; + term555 = 0xC90; + term556 = 0x65A; + term557 = 0x248D; + term558 = 0x214E; + term559 = 0xD1D; + term560 = 0x2479; + term561 = 0xCC7; + term562 = 0xF1D; + term563 = 0x2491; + term564 = 0xB50; + term565 = 0xBCE; + term566 = 0x2591; + term567 = 0x70; + term568 = 0xA9D; + term569 = 0x21F8; + term570 = 0x631; + term571 = 0xFC9; + term572 = 0x1147; + term573 = 0x1021; + term574 = 0x1085; + term575 = 0x11D5; + term576 = 0x199F; + term577 = 0x22E4; + term578 = 0x8F8; + term579 = 0x267F; + term580 = 0x805; + term581 = 0x1B32; + term582 = 0xE00; + term583 = 0x2606; + term584 = 0x19FE; + term585 = 0x1B3C; + term586 = 0x5B1; + term587 = 0x1111; + term588 = 0x9E4; + term589 = 0xB93; + term590 = 0xA2F; + term591 = 0x9B3; + term592 = 0x38F; + term593 = 0x663; + term594 = 0x43; + term595 = 0xB20; + term596 = 0x1243; + term597 = 0xB7A; + term598 = 0x8AF; + term599 = 0x85E; + term600 = 0xEAA; + term601 = 0x196F; + term602 = 0xAB5; + term603 = 0xAF; + term604 = 0x5B3; + term605 = 0x1E91; + term606 = 0xC95; + term607 = 0x1EBE; + term608 = 0x65A; + term609 = 0x78E; + term610 = 0x1455; + term611 = 0x6F7; + term612 = 0xF0A; + term613 = 0x1CE6; + term614 = 0x8E7; + term615 = 0xA8D; + term616 = 0x891; + term617 = 0xAAE; + term618 = 0x665; + term619 = 0x1986; + term620 = 0x15B4; + term621 = 0x7C9; + term622 = 0xB0; + term623 = 0x1649; + term624 = 0x1B32; + term625 = 0x224; + term626 = 0x16F9; + term627 = 0x12C; + term628 = 0x113D; + term629 = 0x19F1; + term630 = 0x267F; + term631 = 0x12F7; + term632 = 0xC46; + term633 = 0x5B6; + term634 = 0x1DBB; + term635 = 0x36D; + term636 = 0x1A8; + term637 = 0xA76; + term638 = 0x6D8; + term639 = 0x20FB; + term640 = 0x2068; + term641 = 0xA71; + term642 = 0x28; + term643 = 0x2461; + term644 = 0x36B; + term645 = 0x48; + term646 = 0xB02; + term647 = 0x262; + term648 = 0x3F9; + term649 = 0x1344; + term650 = 0x1FB0; + term651 = 0x2B7; + term652 = 0xC61; + term653 = 0xEF7; + term654 = 0x28; + term655 = 0x1958; + term656 = 0x21ED; + term657 = 0x2382; + term658 = 0x2519; + term659 = 0xA1D; + term660 = 0x1766; + term661 = 0x1419; + term662 = 0x2489; + term663 = 0x2462; + term664 = 0x21CB; + term665 = 0x1A54; + term666 = 0x7FC; + term667 = 0x4EA; + term668 = 0x14F; + term669 = 0x2237; + term670 = 0x4A8; + term671 = 0x1DB5; + term672 = 0x1490; + term673 = 0x885; + term674 = 0x2137; + term675 = 0xEF5; + term676 = 0xEBF; + term677 = 0x260; + term678 = 0x244C; + term679 = 0x176D; + term680 = 0x1D7D; + term681 = 0x2554; + term682 = 0x15B9; + term683 = 0x65B; + term684 = 0x1943; + term685 = 0x2545; + term686 = 0x17F1; + term687 = 0x4D8; + term688 = 0x1E85; + term689 = 0x23D6; + term690 = 0x259; + term691 = 0x17BD; + term692 = 0xD7; + term693 = 0x21EB; + term694 = 0x2015; + term695 = 0xF98; + term696 = 0x16C0; + term697 = 0x15E1; + term698 = 0xD40; + term699 = 0x167F; + term700 = 0xA6E; + term701 = 0x191C; + term702 = 0x1F5B; + term703 = 0xFF4; + term704 = 0x4B; + term705 = 0x2252; + term706 = 0x157A; + term707 = 0x136A; + term708 = 0x188F; + term709 = 0xF07; + term710 = 0xA2C; + term711 = 0x1F7; + term712 = 0x4C5; + term713 = 0xA67; + term714 = 0x164A; + term715 = 0x93B; + term716 = 0x2332; + term717 = 0x87B; + term718 = 0x1D41; + term719 = 0x2030; + term720 = 0x874; + term721 = 0x15A6; + term722 = 0x1DC3; + term723 = 0x391; + term724 = 0x1DA7; + term725 = 0x1A30; + term726 = 0x71A; + term727 = 0x2410; + term728 = 0x2EE; + term729 = 0x1455; + term730 = 0x136F; + term731 = 0x603; + term732 = 0x12F; + term733 = 0x58E; + term734 = 0x44A; + term735 = 0x4DF; + term736 = 0xE00; + term737 = 0xE40; + term738 = 0xB9B; + term739 = 0x1EB8; + term740 = 0xB61; + term741 = 0x433; + term742 = 0x609; + term743 = 0x2208; + term744 = 0x1D7A; + term745 = 0x21E6; + term746 = 0x6E9; + term747 = 0x148E; + term748 = 0x2147; + term749 = 0xF91; + term750 = 0x2061; + term751 = 0x1738; + term752 = 0xB31; + term753 = 0x215C; + term754 = 0xCAD; + term755 = 0x1584; + term756 = 0x207E; + term757 = 0x1EBE; + term758 = 0x2581; + term759 = 0x2083; + term760 = 0x46C; + term761 = 0x1178; + term762 = 0x1BF0; + term763 = 0x13DF; + term764 = 0x217A; + term765 = 0x2623; + term766 = 0x26AD; + term767 = 0x1BBF; + term768 = 0x1147; + term769 = 0xDC7; + term770 = 0x640; + term771 = 0x1B39; + term772 = 0xFAF; + term773 = 0x15BD; + term774 = 0x1C; + term775 = 0x607; + term776 = 0x14E3; + term777 = 0x828; + term778 = 0xB7F; + term779 = 0xA4D; + term780 = 0x969; + term781 = 0x193F; + term782 = 0x13B9; + term783 = 0x1249; + term784 = 0x634; + term785 = 0x53E; + term786 = 0x260; + term787 = 0x80C; + term788 = 0x4C5; + term789 = 0x6DE; + term790 = 0x26E2; + term791 = 0x378; + term792 = 0x1032; + term793 = 0x2B2; + term794 = 0x1F0D; + term795 = 0xB1B; + term796 = 0x596; + term797 = 0x15F4; + term798 = 0x2EC; + term799 = 0x1B9B; + term800 = 0x11B8; + term801 = 0x30F; + term802 = 0x1F63; + term803 = 0x8B2; + term804 = 0x1441; + term805 = 0x1B7E; + term806 = 0x267D; + term807 = 0x15FD; + term808 = 0x4C8; + term809 = 0x1674; + term810 = 0x26C3; + term811 = 0xD1F; + term812 = 0x8D1; + term813 = 0x129E; + term814 = 0x1350; + term815 = 0x135B; + term816 = 0xCF6; + term817 = 0xAA6; + term818 = 0x1523; + term819 = 0x401; + term820 = 0x163; + term821 = 0x3E9; + term822 = 0x9F5; + term823 = 0x2518; + term824 = 0x2188; + term825 = 0x252B; + term826 = 0x1F1C; + term827 = 0xD0E; + term828 = 0x1F8B; + term829 = 0x1EE9; + term830 = 0x17FE; + term831 = 0x4AC; + term832 = 0x79C; + term833 = 0x13D0; + term834 = 0x1AA; + term835 = 0x11FE; + term836 = 0x181D; + term837 = 0x114D; + term838 = 0x964; + term839 = 0x1A31; + term840 = 0x272; + term841 = 0x2654; + term842 = 0x249F; + term843 = 0x5D; + term844 = 0x19A5; + term845 = 0x1794; + term846 = 0x1280; + term847 = 0x23B5; + term848 = 0x32E; + term849 = 0x176A; + term850 = 0x2040; + term851 = 0x19FC; + term852 = 0xF60; + term853 = 0x346; + term854 = 0x1E2; + term855 = 0x54B; + term856 = 0x3F7; + term857 = 0x46B; + term858 = 0x2026; + term859 = 0x1EA1; + term860 = 0x1211; + term861 = 0x7DB; + term862 = 0xA4D; + term863 = 0x105A; + term864 = 0x25DA; + term865 = 0x672; + term866 = 0x161E; + term867 = 0x662; + term868 = 0x37D; + term869 = 0x161; + term870 = 0x588; + term871 = 0xD7C; + term872 = 0xFA8; + term873 = 0x1C5E; + term874 = 0x8B9; + term875 = 0x154E; + term876 = 0x189F; + term877 = 0x19EA; + term878 = 0x189F; + term879 = 0x10A0; + term880 = 0x94; + term881 = 0x464; + term882 = 0x90D; + term883 = 0x1075; + term884 = 0x1BC5; + term885 = 0xFBC; + term886 = 0x23F0; + term887 = 0x438; + term888 = 0x526; + term889 = 0x1ACA; + term890 = 0xFD2; + term891 = 0x103B; + term892 = 0x551; + term893 = 0x1490; + term894 = 0x76F; + term895 = 0xE5C; + term896 = 0x25AB; + term897 = 0x1AFD; + term898 = 0x1326; + term899 = 0xDE9; + term900 = 0x2129; + term901 = 0x1354; + term902 = 0x502; + term903 = 0xE45; + term904 = 0x2A2; + term905 = 0x8AC; + term906 = 0x151A; + term907 = 0x1B0B; + term908 = 0xEF7; + term909 = 0x2499; + term910 = 0xF26; + term911 = 0x103; + term912 = 0x2330; + term913 = 0xA3B; + term914 = 0xF83; + term915 = 0x3; + term916 = 0x799; + term917 = 0x2635; + term918 = 0x1968; + term919 = 0x958; + term920 = 0xA7D; + term921 = 0x14C1; + term922 = 0x1A2A; + term923 = 0x15D5; + term924 = 0xAA2; + term925 = 0x1732; + term926 = 0x234D; + term927 = 0x190A; + term928 = 0x5B5; + term929 = 0x185A; + term930 = 0x9CC; + term931 = 0x26E9; + term932 = 0xF77; + term933 = 0x195D; + term934 = 0x5EB; + term935 = 0x1495; + term936 = 0x1349; + term937 = 0x22A5; + term938 = 0x3A; + term939 = 0x125C; + term940 = 0xF83; + term941 = 0x1878; + term942 = 0x13FD; + term943 = 0x1847; + term944 = 0x11CB; + term945 = 0x1E87; + term946 = 0x208A; + term947 = 0xBDF; + term948 = 0xD4; + term949 = 0x2448; + term950 = 0x1F92; + term951 = 0x7A2; + term952 = 0x17C5; + term953 = 0x2C6; + term954 = 0x1184; + term955 = 0x12A6; + term956 = 0x20BC; + term957 = 0x2657; + term958 = 0x173F; + term959 = 0x198D; + term960 = 0x1FB3; + term961 = 0x68F; + term962 = 0x1BC6; + term963 = 0x170A; + term964 = 0xC01; + term965 = 0x314; + term966 = 0xF89; + term967 = 0x1FC4; + term968 = 0x26E4; + term969 = 0x21F1; + term970 = 0x17E1; + term971 = 0x8; + term972 = 0xB7D; + term973 = 0x169E; + term974 = 0x6BB; + term975 = 0x553; + term976 = 0x1C; + term977 = 0x1440; + term978 = 0x12AA; + term979 = 0x1C20; + term980 = 0x13CF; + term981 = 0x75D; + term982 = 0x7B6; + term983 = 0x42F; + term984 = 0x535; + term985 = 0xB33; + term986 = 0x1809; + term987 = 0x10C7; + term988 = 0x878; + term989 = 0x339; + term990 = 0x25CC; + term991 = 0x15FD; + term992 = 0x21CA; + term993 = 0xA26; + term994 = 0xCED; + term995 = 0x1255; + term996 = 0x124E; + } + bar { + term997 = 0x50; + term998 = 0x74; + term999 = 0x8C9; + } +} diff --git a/tools/hc-gen/test/32_large_hsl/golden.h.gen b/tools/hc-gen/test/32_large_hsl/golden.h.gen new file mode 100644 index 000000000..9224c2089 --- /dev/null +++ b/tools/hc-gen/test/32_large_hsl/golden.h.gen @@ -0,0 +1,1024 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestFoo { + uint8_t term0; + uint16_t term1; + uint16_t term2; + uint16_t term3; + uint16_t term4; + uint16_t term5; + uint16_t term6; + uint16_t term7; + uint16_t term8; + uint16_t term9; + uint16_t term10; + uint16_t term11; + uint16_t term12; + uint16_t term13; + uint16_t term14; + uint16_t term15; + uint16_t term16; + uint16_t term17; + uint16_t term18; + uint16_t term19; + uint16_t term20; + uint16_t term21; + uint16_t term22; + uint8_t term23; + uint16_t term24; + uint16_t term25; + uint16_t term26; + uint16_t term27; + uint16_t term28; + uint16_t term29; + uint16_t term30; + uint16_t term31; + uint16_t term32; + uint16_t term33; + uint16_t term34; + uint16_t term35; + uint16_t term36; + uint16_t term37; + uint16_t term38; + uint16_t term39; + uint16_t term40; + uint16_t term41; + uint16_t term42; + uint16_t term43; + uint16_t term44; + uint16_t term45; + uint16_t term46; + uint16_t term47; + uint16_t term48; + uint16_t term49; + uint16_t term50; + uint16_t term51; + uint16_t term52; + uint16_t term53; + uint8_t term54; + uint16_t term55; + uint16_t term56; + uint16_t term57; + uint16_t term58; + uint16_t term59; + uint16_t term60; + uint16_t term61; + uint16_t term62; + uint16_t term63; + uint16_t term64; + uint8_t term65; + uint16_t term66; + uint16_t term67; + uint16_t term68; + uint16_t term69; + uint16_t term70; + uint16_t term71; + uint16_t term72; + uint16_t term73; + uint16_t term74; + uint16_t term75; + uint16_t term76; + uint16_t term77; + uint16_t term78; + uint16_t term79; + uint16_t term80; + uint16_t term81; + uint16_t term82; + uint16_t term83; + uint16_t term84; + uint16_t term85; + uint16_t term86; + uint16_t term87; + uint16_t term88; + uint16_t term89; + uint16_t term90; + uint16_t term91; + uint16_t term92; + uint16_t term93; + uint16_t term94; + uint16_t term95; + uint16_t term96; + uint16_t term97; + uint16_t term98; + uint16_t term99; + uint16_t term100; + uint16_t term101; + uint16_t term102; + uint16_t term103; + uint16_t term104; + uint16_t term105; + uint16_t term106; + uint16_t term107; + uint16_t term108; + uint16_t term109; + uint16_t term110; + uint16_t term111; + uint16_t term112; + uint16_t term113; + uint16_t term114; + uint16_t term115; + uint16_t term116; + uint16_t term117; + uint16_t term118; + uint16_t term119; + uint16_t term120; + uint16_t term121; + uint16_t term122; + uint16_t term123; + uint16_t term124; + uint16_t term125; + uint16_t term126; + uint16_t term127; + uint16_t term128; + uint16_t term129; + uint16_t term130; + uint16_t term131; + uint16_t term132; + uint16_t term133; + uint16_t term134; + uint16_t term135; + uint16_t term136; + uint8_t term137; + uint16_t term138; + uint16_t term139; + uint16_t term140; + uint16_t term141; + uint16_t term142; + uint16_t term143; + uint16_t term144; + uint16_t term145; + uint16_t term146; + uint16_t term147; + uint16_t term148; + uint16_t term149; + uint16_t term150; + uint16_t term151; + uint16_t term152; + uint16_t term153; + uint16_t term154; + uint16_t term155; + uint16_t term156; + uint16_t term157; + uint16_t term158; + uint16_t term159; + uint16_t term160; + uint16_t term161; + uint16_t term162; + uint16_t term163; + uint16_t term164; + uint16_t term165; + uint16_t term166; + uint16_t term167; + uint16_t term168; + uint16_t term169; + uint16_t term170; + uint16_t term171; + uint16_t term172; + uint16_t term173; + uint16_t term174; + uint16_t term175; + uint16_t term176; + uint16_t term177; + uint16_t term178; + uint16_t term179; + uint16_t term180; + uint16_t term181; + uint8_t term182; + uint16_t term183; + uint16_t term184; + uint16_t term185; + uint16_t term186; + uint16_t term187; + uint16_t term188; + uint16_t term189; + uint16_t term190; + uint16_t term191; + uint16_t term192; + uint16_t term193; + uint16_t term194; + uint16_t term195; + uint16_t term196; + uint16_t term197; + uint16_t term198; + uint16_t term199; + uint16_t term200; + uint16_t term201; + uint16_t term202; + uint16_t term203; + uint16_t term204; + uint16_t term205; + uint16_t term206; + uint16_t term207; + uint16_t term208; + uint16_t term209; + uint16_t term210; + uint16_t term211; + uint16_t term212; + uint16_t term213; + uint16_t term214; + uint16_t term215; + uint16_t term216; + uint16_t term217; + uint16_t term218; + uint16_t term219; + uint16_t term220; + uint16_t term221; + uint16_t term222; + uint16_t term223; + uint16_t term224; + uint16_t term225; + uint16_t term226; + uint16_t term227; + uint16_t term228; + uint16_t term229; + uint16_t term230; + uint16_t term231; + uint16_t term232; + uint16_t term233; + uint16_t term234; + uint16_t term235; + uint16_t term236; + uint16_t term237; + uint16_t term238; + uint16_t term239; + uint16_t term240; + uint16_t term241; + uint16_t term242; + uint16_t term243; + uint16_t term244; + uint16_t term245; + uint16_t term246; + uint16_t term247; + uint16_t term248; + uint16_t term249; + uint16_t term250; + uint16_t term251; + uint16_t term252; + uint8_t term253; + uint16_t term254; + uint16_t term255; + uint16_t term256; + uint16_t term257; + uint16_t term258; + uint16_t term259; + uint16_t term260; + uint8_t term261; + uint16_t term262; + uint16_t term263; + uint16_t term264; + uint16_t term265; + uint16_t term266; + uint16_t term267; + uint8_t term268; + uint16_t term269; + uint16_t term270; + uint16_t term271; + uint16_t term272; + uint16_t term273; + uint16_t term274; + uint16_t term275; + uint16_t term276; + uint16_t term277; + uint16_t term278; + uint16_t term279; + uint16_t term280; + uint16_t term281; + uint16_t term282; + uint16_t term283; + uint16_t term284; + uint16_t term285; + uint16_t term286; + uint16_t term287; + uint16_t term288; + uint16_t term289; + uint16_t term290; + uint16_t term291; + uint16_t term292; + uint16_t term293; + uint16_t term294; + uint16_t term295; + uint16_t term296; + uint16_t term297; + uint16_t term298; + uint16_t term299; + uint16_t term300; + uint16_t term301; + uint16_t term302; + uint16_t term303; + uint16_t term304; + uint16_t term305; + uint16_t term306; + uint16_t term307; + uint16_t term308; + uint16_t term309; + uint8_t term310; + uint16_t term311; + uint16_t term312; + uint16_t term313; + uint16_t term314; + uint16_t term315; + uint16_t term316; + uint16_t term317; + uint16_t term318; + uint16_t term319; + uint16_t term320; + uint16_t term321; + uint16_t term322; + uint16_t term323; + uint8_t term324; + uint16_t term325; + uint16_t term326; + uint16_t term327; + uint16_t term328; + uint16_t term329; + uint16_t term330; + uint16_t term331; + uint16_t term332; + uint16_t term333; + uint16_t term334; + uint16_t term335; + uint16_t term336; + uint16_t term337; + uint16_t term338; + uint16_t term339; + uint16_t term340; + uint16_t term341; + uint16_t term342; + uint8_t term343; + uint16_t term344; + uint16_t term345; + uint16_t term346; + uint16_t term347; + uint16_t term348; + uint16_t term349; + uint16_t term350; + uint16_t term351; + uint16_t term352; + uint16_t term353; + uint16_t term354; + uint16_t term355; + uint16_t term356; + uint8_t term357; + uint16_t term358; + uint16_t term359; + uint16_t term360; + uint16_t term361; + uint16_t term362; + uint16_t term363; + uint16_t term364; + uint16_t term365; + uint16_t term366; + uint16_t term367; + uint16_t term368; + uint8_t term369; + uint16_t term370; + uint16_t term371; + uint16_t term372; + uint16_t term373; + uint16_t term374; + uint16_t term375; + uint16_t term376; + uint16_t term377; + uint16_t term378; + uint16_t term379; + uint16_t term380; + uint16_t term381; + uint16_t term382; + uint16_t term383; + uint8_t term384; + uint16_t term385; + uint16_t term386; + uint16_t term387; + uint16_t term388; + uint16_t term389; + uint16_t term390; + uint16_t term391; + uint16_t term392; + uint8_t term393; + uint16_t term394; + uint16_t term395; + uint16_t term396; + uint16_t term397; + uint16_t term398; + uint16_t term399; + uint16_t term400; + uint16_t term401; + uint16_t term402; + uint16_t term403; + uint16_t term404; + uint16_t term405; + uint16_t term406; + uint16_t term407; + uint16_t term408; + uint16_t term409; + uint16_t term410; + uint16_t term411; + uint16_t term412; + uint16_t term413; + uint16_t term414; + uint16_t term415; + uint16_t term416; + uint16_t term417; + uint16_t term418; + uint16_t term419; + uint16_t term420; + uint16_t term421; + uint16_t term422; + uint16_t term423; + uint16_t term424; + uint16_t term425; + uint16_t term426; + uint8_t term427; + uint16_t term428; + uint16_t term429; + uint16_t term430; + uint16_t term431; + uint16_t term432; + uint16_t term433; + uint16_t term434; + uint16_t term435; + uint16_t term436; + uint16_t term437; + uint8_t term438; + uint16_t term439; + uint16_t term440; + uint16_t term441; + uint16_t term442; + uint16_t term443; + uint16_t term444; + uint16_t term445; + uint8_t term446; + uint16_t term447; + uint16_t term448; + uint16_t term449; + uint16_t term450; + uint16_t term451; + uint16_t term452; + uint16_t term453; + uint16_t term454; + uint16_t term455; + uint16_t term456; + uint16_t term457; + uint16_t term458; + uint16_t term459; + uint16_t term460; + uint16_t term461; + uint16_t term462; + uint16_t term463; + uint16_t term464; + uint16_t term465; + uint16_t term466; + uint16_t term467; + uint16_t term468; + uint16_t term469; + uint16_t term470; + uint16_t term471; + uint16_t term472; + uint16_t term473; + uint16_t term474; + uint8_t term475; + uint16_t term476; + uint16_t term477; + uint16_t term478; + uint16_t term479; + uint16_t term480; + uint16_t term481; + uint16_t term482; + uint16_t term483; + uint16_t term484; + uint16_t term485; + uint16_t term486; + uint16_t term487; + uint16_t term488; + uint16_t term489; + uint16_t term490; + uint16_t term491; + uint16_t term492; + uint16_t term493; + uint8_t term494; + uint16_t term495; + uint16_t term496; + uint16_t term497; + uint8_t term498; + uint16_t term499; + uint16_t term500; + uint16_t term501; + uint16_t term502; + uint16_t term503; + uint16_t term504; + uint16_t term505; + uint16_t term506; + uint16_t term507; + uint16_t term508; + uint16_t term509; + uint16_t term510; + uint16_t term511; + uint16_t term512; + uint16_t term513; + uint8_t term514; + uint16_t term515; + uint16_t term516; + uint16_t term517; + uint16_t term518; + uint16_t term519; + uint16_t term520; + uint16_t term521; + uint16_t term522; + uint16_t term523; + uint16_t term524; + uint16_t term525; + uint16_t term526; + uint16_t term527; + uint16_t term528; + uint16_t term529; + uint16_t term530; + uint16_t term531; + uint16_t term532; + uint16_t term533; + uint16_t term534; + uint16_t term535; + uint16_t term536; + uint16_t term537; + uint16_t term538; + uint16_t term539; + uint16_t term540; + uint16_t term541; + uint16_t term542; + uint16_t term543; + uint16_t term544; + uint16_t term545; + uint16_t term546; + uint16_t term547; + uint16_t term548; + uint16_t term549; + uint16_t term550; + uint16_t term551; + uint16_t term552; + uint16_t term553; + uint16_t term554; + uint16_t term555; + uint16_t term556; + uint16_t term557; + uint16_t term558; + uint16_t term559; + uint16_t term560; + uint16_t term561; + uint16_t term562; + uint16_t term563; + uint16_t term564; + uint16_t term565; + uint16_t term566; + uint8_t term567; + uint16_t term568; + uint16_t term569; + uint16_t term570; + uint16_t term571; + uint16_t term572; + uint16_t term573; + uint16_t term574; + uint16_t term575; + uint16_t term576; + uint16_t term577; + uint16_t term578; + uint16_t term579; + uint16_t term580; + uint16_t term581; + uint16_t term582; + uint16_t term583; + uint16_t term584; + uint16_t term585; + uint16_t term586; + uint16_t term587; + uint16_t term588; + uint16_t term589; + uint16_t term590; + uint16_t term591; + uint16_t term592; + uint16_t term593; + uint8_t term594; + uint16_t term595; + uint16_t term596; + uint16_t term597; + uint16_t term598; + uint16_t term599; + uint16_t term600; + uint16_t term601; + uint16_t term602; + uint8_t term603; + uint16_t term604; + uint16_t term605; + uint16_t term606; + uint16_t term607; + uint16_t term608; + uint16_t term609; + uint16_t term610; + uint16_t term611; + uint16_t term612; + uint16_t term613; + uint16_t term614; + uint16_t term615; + uint16_t term616; + uint16_t term617; + uint16_t term618; + uint16_t term619; + uint16_t term620; + uint16_t term621; + uint8_t term622; + uint16_t term623; + uint16_t term624; + uint16_t term625; + uint16_t term626; + uint16_t term627; + uint16_t term628; + uint16_t term629; + uint16_t term630; + uint16_t term631; + uint16_t term632; + uint16_t term633; + uint16_t term634; + uint16_t term635; + uint16_t term636; + uint16_t term637; + uint16_t term638; + uint16_t term639; + uint16_t term640; + uint16_t term641; + uint8_t term642; + uint16_t term643; + uint16_t term644; + uint8_t term645; + uint16_t term646; + uint16_t term647; + uint16_t term648; + uint16_t term649; + uint16_t term650; + uint16_t term651; + uint16_t term652; + uint16_t term653; + uint8_t term654; + uint16_t term655; + uint16_t term656; + uint16_t term657; + uint16_t term658; + uint16_t term659; + uint16_t term660; + uint16_t term661; + uint16_t term662; + uint16_t term663; + uint16_t term664; + uint16_t term665; + uint16_t term666; + uint16_t term667; + uint16_t term668; + uint16_t term669; + uint16_t term670; + uint16_t term671; + uint16_t term672; + uint16_t term673; + uint16_t term674; + uint16_t term675; + uint16_t term676; + uint16_t term677; + uint16_t term678; + uint16_t term679; + uint16_t term680; + uint16_t term681; + uint16_t term682; + uint16_t term683; + uint16_t term684; + uint16_t term685; + uint16_t term686; + uint16_t term687; + uint16_t term688; + uint16_t term689; + uint16_t term690; + uint16_t term691; + uint8_t term692; + uint16_t term693; + uint16_t term694; + uint16_t term695; + uint16_t term696; + uint16_t term697; + uint16_t term698; + uint16_t term699; + uint16_t term700; + uint16_t term701; + uint16_t term702; + uint16_t term703; + uint8_t term704; + uint16_t term705; + uint16_t term706; + uint16_t term707; + uint16_t term708; + uint16_t term709; + uint16_t term710; + uint16_t term711; + uint16_t term712; + uint16_t term713; + uint16_t term714; + uint16_t term715; + uint16_t term716; + uint16_t term717; + uint16_t term718; + uint16_t term719; + uint16_t term720; + uint16_t term721; + uint16_t term722; + uint16_t term723; + uint16_t term724; + uint16_t term725; + uint16_t term726; + uint16_t term727; + uint16_t term728; + uint16_t term729; + uint16_t term730; + uint16_t term731; + uint16_t term732; + uint16_t term733; + uint16_t term734; + uint16_t term735; + uint16_t term736; + uint16_t term737; + uint16_t term738; + uint16_t term739; + uint16_t term740; + uint16_t term741; + uint16_t term742; + uint16_t term743; + uint16_t term744; + uint16_t term745; + uint16_t term746; + uint16_t term747; + uint16_t term748; + uint16_t term749; + uint16_t term750; + uint16_t term751; + uint16_t term752; + uint16_t term753; + uint16_t term754; + uint16_t term755; + uint16_t term756; + uint16_t term757; + uint16_t term758; + uint16_t term759; + uint16_t term760; + uint16_t term761; + uint16_t term762; + uint16_t term763; + uint16_t term764; + uint16_t term765; + uint16_t term766; + uint16_t term767; + uint16_t term768; + uint16_t term769; + uint16_t term770; + uint16_t term771; + uint16_t term772; + uint16_t term773; + uint8_t term774; + uint16_t term775; + uint16_t term776; + uint16_t term777; + uint16_t term778; + uint16_t term779; + uint16_t term780; + uint16_t term781; + uint16_t term782; + uint16_t term783; + uint16_t term784; + uint16_t term785; + uint16_t term786; + uint16_t term787; + uint16_t term788; + uint16_t term789; + uint16_t term790; + uint16_t term791; + uint16_t term792; + uint16_t term793; + uint16_t term794; + uint16_t term795; + uint16_t term796; + uint16_t term797; + uint16_t term798; + uint16_t term799; + uint16_t term800; + uint16_t term801; + uint16_t term802; + uint16_t term803; + uint16_t term804; + uint16_t term805; + uint16_t term806; + uint16_t term807; + uint16_t term808; + uint16_t term809; + uint16_t term810; + uint16_t term811; + uint16_t term812; + uint16_t term813; + uint16_t term814; + uint16_t term815; + uint16_t term816; + uint16_t term817; + uint16_t term818; + uint16_t term819; + uint16_t term820; + uint16_t term821; + uint16_t term822; + uint16_t term823; + uint16_t term824; + uint16_t term825; + uint16_t term826; + uint16_t term827; + uint16_t term828; + uint16_t term829; + uint16_t term830; + uint16_t term831; + uint16_t term832; + uint16_t term833; + uint16_t term834; + uint16_t term835; + uint16_t term836; + uint16_t term837; + uint16_t term838; + uint16_t term839; + uint16_t term840; + uint16_t term841; + uint16_t term842; + uint8_t term843; + uint16_t term844; + uint16_t term845; + uint16_t term846; + uint16_t term847; + uint16_t term848; + uint16_t term849; + uint16_t term850; + uint16_t term851; + uint16_t term852; + uint16_t term853; + uint16_t term854; + uint16_t term855; + uint16_t term856; + uint16_t term857; + uint16_t term858; + uint16_t term859; + uint16_t term860; + uint16_t term861; + uint16_t term862; + uint16_t term863; + uint16_t term864; + uint16_t term865; + uint16_t term866; + uint16_t term867; + uint16_t term868; + uint16_t term869; + uint16_t term870; + uint16_t term871; + uint16_t term872; + uint16_t term873; + uint16_t term874; + uint16_t term875; + uint16_t term876; + uint16_t term877; + uint16_t term878; + uint16_t term879; + uint8_t term880; + uint16_t term881; + uint16_t term882; + uint16_t term883; + uint16_t term884; + uint16_t term885; + uint16_t term886; + uint16_t term887; + uint16_t term888; + uint16_t term889; + uint16_t term890; + uint16_t term891; + uint16_t term892; + uint16_t term893; + uint16_t term894; + uint16_t term895; + uint16_t term896; + uint16_t term897; + uint16_t term898; + uint16_t term899; + uint16_t term900; + uint16_t term901; + uint16_t term902; + uint16_t term903; + uint16_t term904; + uint16_t term905; + uint16_t term906; + uint16_t term907; + uint16_t term908; + uint16_t term909; + uint16_t term910; + uint16_t term911; + uint16_t term912; + uint16_t term913; + uint16_t term914; + uint8_t term915; + uint16_t term916; + uint16_t term917; + uint16_t term918; + uint16_t term919; + uint16_t term920; + uint16_t term921; + uint16_t term922; + uint16_t term923; + uint16_t term924; + uint16_t term925; + uint16_t term926; + uint16_t term927; + uint16_t term928; + uint16_t term929; + uint16_t term930; + uint16_t term931; + uint16_t term932; + uint16_t term933; + uint16_t term934; + uint16_t term935; + uint16_t term936; + uint16_t term937; + uint8_t term938; + uint16_t term939; + uint16_t term940; + uint16_t term941; + uint16_t term942; + uint16_t term943; + uint16_t term944; + uint16_t term945; + uint16_t term946; + uint16_t term947; + uint8_t term948; + uint16_t term949; + uint16_t term950; + uint16_t term951; + uint16_t term952; + uint16_t term953; + uint16_t term954; + uint16_t term955; + uint16_t term956; + uint16_t term957; + uint16_t term958; + uint16_t term959; + uint16_t term960; + uint16_t term961; + uint16_t term962; + uint16_t term963; + uint16_t term964; + uint16_t term965; + uint16_t term966; + uint16_t term967; + uint16_t term968; + uint16_t term969; + uint16_t term970; + uint8_t term971; + uint16_t term972; + uint16_t term973; + uint16_t term974; + uint16_t term975; + uint8_t term976; + uint16_t term977; + uint16_t term978; + uint16_t term979; + uint16_t term980; + uint16_t term981; + uint16_t term982; + uint16_t term983; + uint16_t term984; + uint16_t term985; + uint16_t term986; + uint16_t term987; + uint16_t term988; + uint16_t term989; + uint16_t term990; + uint16_t term991; + uint16_t term992; + uint16_t term993; + uint16_t term994; + uint16_t term995; + uint16_t term996; +}; + +struct HdfConfigTestBar { + uint8_t term997; + uint8_t term998; + uint16_t term999; +}; + +struct HdfConfigTestRoot { + const char* module; + struct HdfConfigTestFoo foo; + struct HdfConfigTestBar bar; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/32_large_hsl/golden.hcb b/tools/hc-gen/test/32_large_hsl/golden.hcb new file mode 100644 index 000000000..12a240fef --- /dev/null +++ b/tools/hc-gen/test/32_large_hsl/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAHIuAAABcm9vdABoLgAAAm1vZHVsZQAUdGVzdAABZm9vACYuAAACdGVybTAAECkCdGVybTEAERMhAnRlcm0yABG+GAJ0ZXJtMwARZBkCdGVybTQAEdEjAnRlcm01ABFcFgJ0ZXJtNgARxgUCdGVybTcAEY4kAnRlcm04ABEyGwJ0ZXJtOQARcBECdGVybTEwABFJFgJ0ZXJtMTEAEdEfAnRlcm0xMgAR0QwCdGVybTEzABGrGgJ0ZXJtMTQAEekmAnRlcm0xNQAR6wECdGVybTE2ABGzCwJ0ZXJtMTcAEZYHAnRlcm0xOAAR2xICdGVybTE5ABE8FQJ0ZXJtMjAAEVcJAnRlcm0yMQAR/BECdGVybTIyABE+DwJ0ZXJtMjMAEJkCdGVybTI0ABEkAQJ0ZXJtMjUAEU4JAnRlcm0yNgAR/RwCdGVybTI3ABEMIgJ0ZXJtMjgAEfYlAnRlcm0yOQARpyYCdGVybTMwABFHFQJ0ZXJtMzEAEb4GAnRlcm0zMgARoxICdGVybTMzABECBgJ0ZXJtMzQAEU0HAnRlcm0zNQARuCYCdGVybTM2ABEjFgJ0ZXJtMzcAEZsYAnRlcm0zOAARexsCdGVybTM5ABGmJgJ0ZXJtNDAAEf8hAnRlcm00MQAR4w4CdGVybTQyABEqBQJ0ZXJtNDMAEU0BAnRlcm00NAAR+R0CdGVybTQ1ABE4EgJ0ZXJtNDYAERUUAnRlcm00NwARHx4CdGVybTQ4ABE9IAJ0ZXJtNDkAEdQaAnRlcm01MAARqxUCdGVybT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JtOTcxABAIAnRlcm05NzIAEX0LAnRlcm05NzMAEZ4WAnRlcm05NzQAEbsGAnRlcm05NzUAEVMFAnRlcm05NzYAEBwCdGVybTk3NwARQBQCdGVybTk3OAARqhICdGVybTk3OQARIBwCdGVybTk4MAARzxMCdGVybTk4MQARXQcCdGVybTk4MgARtgcCdGVybTk4MwARLwQCdGVybTk4NAARNQUCdGVybTk4NQARMwsCdGVybTk4NgARCRgCdGVybTk4NwARxxACdGVybTk4OAAReAgCdGVybTk4OQAROQMCdGVybTk5MAARzCUCdGVybTk5MQAR/RUCdGVybTk5MgARyiECdGVybTk5MwARJgoCdGVybTk5NAAR7QwCdGVybTk5NQARVRICdGVybTk5NgARThIBYmFyACIAAAACdGVybTk5NwAQUAJ0ZXJtOTk4ABB0AnRlcm05OTkAEckI \ No newline at end of file diff --git a/tools/hc-gen/test/32_large_hsl/golden_binary_compile_result.txt b/tools/hc-gen/test/32_large_hsl/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/32_large_hsl/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/32_large_hsl/golden_text_compile_result.txt b/tools/hc-gen/test/32_large_hsl/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/32_large_hsl/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/33_miss_module_name_ei/case.hcs b/tools/hc-gen/test/33_miss_module_name_ei/case.hcs new file mode 100755 index 000000000..b4fcc8bd0 --- /dev/null +++ b/tools/hc-gen/test/33_miss_module_name_ei/case.hcs @@ -0,0 +1,4 @@ +root { + foo { + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/33_miss_module_name_ei/golden_binary_compile_result.txt b/tools/hc-gen/test/33_miss_module_name_ei/golden_binary_compile_result.txt new file mode 100644 index 000000000..c8bbf0469 --- /dev/null +++ b/tools/hc-gen/test/33_miss_module_name_ei/golden_binary_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./33_miss_module_name_ei/case.hcs:1 miss 'module' attribute under root node \ No newline at end of file diff --git a/tools/hc-gen/test/33_miss_module_name_ei/golden_text_compile_result.txt b/tools/hc-gen/test/33_miss_module_name_ei/golden_text_compile_result.txt new file mode 100644 index 000000000..c8bbf0469 --- /dev/null +++ b/tools/hc-gen/test/33_miss_module_name_ei/golden_text_compile_result.txt @@ -0,0 +1,3 @@ +[compile exit status]:1 +[compile console output]: +[Error] ./33_miss_module_name_ei/case.hcs:1 miss 'module' attribute under root node \ No newline at end of file diff --git a/tools/hc-gen/test/34_template/case.hcs b/tools/hc-gen/test/34_template/case.hcs new file mode 100755 index 000000000..fd65ded6b --- /dev/null +++ b/tools/hc-gen/test/34_template/case.hcs @@ -0,0 +1,37 @@ + +root { + module = "test"; + template FooBase { + term1 = 1; + term2 = 2; + term3 = [2,2]; + attr { + term4 = 4; + } + } + fooSub :: FooBase { + term1 = 2; + } + fooSub1 :: FooBase { + term1 = 2; + term3 = [1]; + attr { + term4 = 1; + } + } + foo { + foo1 { + term1 = "world"; + bar2_2 = ["test3"]; + foo = &root.foo; + bar = &root.bar; + + } + + array_oct = [1, 2, 3, 4]; + } + bar { + //foo {} + } + t = 1; +} diff --git a/tools/hc-gen/test/34_template/golden.c.gen b/tools/hc-gen/test/34_template/golden.c.gen new file mode 100644 index 000000000..2fcd6f13c --- /dev/null +++ b/tools/hc-gen/test/34_template/golden.c.gen @@ -0,0 +1,59 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestFooBase g_hdfConfigFooBase[]; + +static const uint8_t g_hcsConfigArrayTerm31[2] = { + 0x2, 0x2 +}; + +static const uint8_t g_hcsConfigArrayTerm32[1] = { + 0x1 +}; + +static const struct HdfConfigTestFooBase g_hdfConfigFooBase[] = { + [0] = { + .term1 = 0x2, + .term2 = 0x2, + .term3 = g_hcsConfigArrayTerm31, + .term3Size = 2, + .attr = { + .term4 = 0x4, + }, + }, + [1] = { + .term1 = 0x2, + .term3 = g_hcsConfigArrayTerm32, + .term3Size = 1, + .attr = { + .term4 = 0x1, + }, + .term2 = 0x2, + }, +}; + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .fooBase = g_hdfConfigFooBase, + .fooBaseSize = 2, + .foo = { + .foo1 = { + .term1 = "world", + .bar2_2 = { "test3" }, + .foo = &g_hdfConfigTestModuleRoot.foo, + .bar = &g_hdfConfigTestModuleRoot.bar, + }, + .array_oct = { 0x1, 0x2, 0x3, 0x4 }, + }, + .bar = { + }, + .t = 0x1, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/34_template/golden.d.hcs b/tools/hc-gen/test/34_template/golden.d.hcs new file mode 100644 index 000000000..07487793a --- /dev/null +++ b/tools/hc-gen/test/34_template/golden.d.hcs @@ -0,0 +1,35 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + fooSub { + term1 = 0x2; + term2 = 0x2; + term3 = [0x2, 0x2]; + attr { + term4 = 0x4; + } + } + fooSub1 { + term1 = 0x2; + term3 = [0x1]; + attr { + term4 = 0x1; + } + term2 = 0x2; + } + foo { + foo1 { + term1 = "world"; + bar2_2 = ["test3"]; + foo = &root.foo; + bar = &root.bar; + } + array_oct = [0x1, 0x2, 0x3, 0x4]; + } + bar { + } + t = 0x1; +} diff --git a/tools/hc-gen/test/34_template/golden.h.gen b/tools/hc-gen/test/34_template/golden.h.gen new file mode 100644 index 000000000..5a5f1ef8b --- /dev/null +++ b/tools/hc-gen/test/34_template/golden.h.gen @@ -0,0 +1,48 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestAttr { + uint8_t term4; +}; + +struct HdfConfigTestFooBase { + uint8_t term1; + uint8_t term2; + const uint8_t* term3; + uint32_t term3Size; + struct HdfConfigTestAttr attr; +}; + +struct HdfConfigTestFoo1 { + const char* term1; + const char* bar2_2[1]; + const struct HdfConfigTestFoo* foo; + const struct HdfConfigTestBar* bar; +}; + +struct HdfConfigTestFoo { + struct HdfConfigTestFoo1 foo1; + uint8_t array_oct[4]; +}; + +struct HdfConfigTestBar { +}; + +struct HdfConfigTestRoot { + const char* module; + const struct HdfConfigTestFooBase* fooBase; + uint16_t fooBaseSize; + struct HdfConfigTestFoo foo; + struct HdfConfigTestBar bar; + uint8_t t; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/34_template/golden.hcb b/tools/hc-gen/test/34_template/golden.hcb new file mode 100644 index 000000000..6edf96322 --- /dev/null +++ b/tools/hc-gen/test/34_template/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAAABAAABcm9vdAD2AAAAAm1vZHVsZQAUdGVzdAABZm9vU3ViADMAAAACdGVybTEAEAICdGVybTIAEAICdGVybTMABAIAEAIQAgFhdHRyAAkAAAACdGVybTQAEAQBZm9vU3ViMQAxAAAAAnRlcm0xABACAnRlcm0zAAQBABABAWF0dHIACQAAAAJ0ZXJtNAAQAQJ0ZXJtMgAQAgFmb28AVAAAAAFmb28xADQAAAACdGVybTEAFHdvcmxkAAJiYXIyXzIABAEAFHRlc3QzAAJmb28AA6kAAAACYmFyAAMGAQAAAmFycmF5X29jdAAEBAAQARACEAMQBAFiYXIAAAAAAAJ0ABAB \ No newline at end of file diff --git a/tools/hc-gen/test/34_template/golden_binary_compile_result.txt b/tools/hc-gen/test/34_template/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/34_template/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/34_template/golden_text_compile_result.txt b/tools/hc-gen/test/34_template/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/34_template/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/35_nested_template/case.hcs b/tools/hc-gen/test/35_nested_template/case.hcs new file mode 100755 index 000000000..f71b8206e --- /dev/null +++ b/tools/hc-gen/test/35_nested_template/case.hcs @@ -0,0 +1,22 @@ +root { + module = "test"; + template foo_base { + term3 = [2,2]; + template attr { + term4 = 4; + } + } + + foo_1 :: foo_base { + attr1 :: attr { + term4 = 1; + } + attr2 :: attr { + term4 = 2; + } + } + + foo_2 :: foo_base { + term3 = [1, 2, 3, 4]; + } +} \ No newline at end of file diff --git a/tools/hc-gen/test/35_nested_template/golden.c.gen b/tools/hc-gen/test/35_nested_template/golden.c.gen new file mode 100644 index 000000000..5bfb55a76 --- /dev/null +++ b/tools/hc-gen/test/35_nested_template/golden.c.gen @@ -0,0 +1,52 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#include "golden.h" + +static const struct HdfConfigTestFooBase g_hdfConfigFooBase[]; + +static const uint8_t g_hcsConfigArrayTerm31[2] = { + 0x2, 0x2 +}; + +static const struct HdfConfigTestAttr g_hdfConfigAttr[]; + +static const uint8_t g_hcsConfigArrayTerm32[4] = { + 0x1, 0x2, 0x3, 0x4 +}; + +static const struct HdfConfigTestFooBase g_hdfConfigFooBase[] = { + [0] = { + .term3 = g_hcsConfigArrayTerm31, + .term3Size = 2, + .attr = g_hdfConfigAttr, + .attrSize = 2, + }, + [1] = { + .term3 = g_hcsConfigArrayTerm32, + .term3Size = 4, + .attr = 0, + .attrSize = 0, + }, +}; + +static const struct HdfConfigTestAttr g_hdfConfigAttr[] = { + [0] = { + .term4 = 0x1, + }, + [1] = { + .term4 = 0x2, + }, +}; + +static const struct HdfConfigTestRoot g_hdfConfigTestModuleRoot = { + .module = "test", + .fooBase = g_hdfConfigFooBase, + .fooBaseSize = 2, +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void) +{ + return &g_hdfConfigTestModuleRoot; +} diff --git a/tools/hc-gen/test/35_nested_template/golden.d.hcs b/tools/hc-gen/test/35_nested_template/golden.d.hcs new file mode 100644 index 000000000..8875bbf8a --- /dev/null +++ b/tools/hc-gen/test/35_nested_template/golden.d.hcs @@ -0,0 +1,19 @@ +/* + * HDF decompile hcs file + */ + +root { + module = "test"; + foo_1 { + attr1 { + term4 = 0x1; + } + attr2 { + term4 = 0x2; + } + term3 = [0x2, 0x2]; + } + foo_2 { + term3 = [0x1, 0x2, 0x3, 0x4]; + } +} diff --git a/tools/hc-gen/test/35_nested_template/golden.h.gen b/tools/hc-gen/test/35_nested_template/golden.h.gen new file mode 100644 index 000000000..7ec6029dd --- /dev/null +++ b/tools/hc-gen/test/35_nested_template/golden.h.gen @@ -0,0 +1,29 @@ +/* + * This is an automatically generated HDF config file. Do not modify it manually. + */ + +#ifndef HCS_CONFIG_GOLDEN_HEADER_H +#define HCS_CONFIG_GOLDEN_HEADER_H + +#include + +struct HdfConfigTestAttr { + uint8_t term4; +}; + +struct HdfConfigTestFooBase { + const uint8_t* term3; + uint32_t term3Size; + const struct HdfConfigTestAttr* attr; + uint16_t attrSize; +}; + +struct HdfConfigTestRoot { + const char* module; + const struct HdfConfigTestFooBase* fooBase; + uint16_t fooBaseSize; +}; + +const struct HdfConfigTestRoot* HdfGetTestModuleConfigRoot(void); + +#endif // HCS_CONFIG_GOLDEN_HEADER_H diff --git a/tools/hc-gen/test/35_nested_template/golden.hcb b/tools/hc-gen/test/35_nested_template/golden.hcb new file mode 100644 index 000000000..95b7df16f --- /dev/null +++ b/tools/hc-gen/test/35_nested_template/golden.hcb @@ -0,0 +1 @@ +CqAKoAAAAAAHAAAAAAAAAHYAAAABcm9vdABsAAAAAm1vZHVsZQAUdGVzdAABZm9vXzEANgAAAAFhdHRyMQAJAAAAAnRlcm00ABABAWF0dHIyAAkAAAACdGVybTQAEAICdGVybTMABAIAEAIQAgFmb29fMgASAAAAAnRlcm0zAAQEABABEAIQAxAE \ No newline at end of file diff --git a/tools/hc-gen/test/35_nested_template/golden_binary_compile_result.txt b/tools/hc-gen/test/35_nested_template/golden_binary_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/35_nested_template/golden_binary_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/35_nested_template/golden_text_compile_result.txt b/tools/hc-gen/test/35_nested_template/golden_text_compile_result.txt new file mode 100644 index 000000000..3e0feb33c --- /dev/null +++ b/tools/hc-gen/test/35_nested_template/golden_text_compile_result.txt @@ -0,0 +1,2 @@ +[compile exit status]:0 +[compile console output]: diff --git a/tools/hc-gen/test/hcgen_test.py b/tools/hc-gen/test/hcgen_test.py new file mode 100755 index 000000000..097543d99 --- /dev/null +++ b/tools/hc-gen/test/hcgen_test.py @@ -0,0 +1,314 @@ +#!/usr/bin/env python +# coding: utf-8 +# +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import os +import platform +import shutil +import subprocess +import sys +import time +import base64 + +SOURCE_ROOT = "../../" +CMAKE_GEN_PATH = "cmake-build-debug" +WORK_DIR = "" +HCGEN = "" +TEMP_DIR = 'temp' +ERROR_COLOR_PREFIX = "\033[31m" +ERROR_COLOR_END = "\033[0m" +SHOULD_CLEAN_TEMP = True +PERFORMANCE_MAX_COMPILE_TIME_MS = 1000 + + +def text_file_compare(file_a, file_target): + if not os.path.exists(file_target): + return True + + with open(file_a, 'r') as f_a: + with open(file_target, 'r') as f_b: + a_content = f_a.read().replace(r'\r\n', r'\n') + b_content = f_b.read().replace(r'\r\n', r'\n') + return a_content == b_content + + +def binary_file_compare(file_a, file_target, skip_size=0, + target_base64_encode=False): + if not os.path.exists(file_target): + return True + + with open(file_a, 'rb') as f_a: + with open(file_target, 'rb') as f_b: + a_content = f_a.read() + b_content = f_b.read() + if target_base64_encode: + b_content = base64.b64decode(b_content) + return a_content[skip_size:] == b_content[skip_size:] + + +def exec_command(command): + return subprocess.getstatusoutput(command) + + +def setup_hcgen_compiler(): + global SOURCE_ROOT + global CMAKE_GEN_PATH + global HCGEN + + if len(sys.argv) > 1: + hcgen_path = os.path.abspath(sys.argv[1]) + if hcgen_path.find('hc-gen') >= 0 and os.access(hcgen_path, os.X_OK): + HCGEN = hcgen_path + print('use specified hsc:' + hcgen_path) + return + + source_root = '../../' + compiler_name = "hc-gen" + if platform.system() == "Windows": + source_root = source_root.replace("/", "\\") + compiler_name += ".exe" + + source_root = os.path.abspath(os.path.join(WORK_DIR, source_root)) + hcgen = os.path.join(source_root, compiler_name) + if not os.access(hcgen, os.X_OK): + hcgen = os.path.join(source_root, CMAKE_GEN_PATH, compiler_name) + if not os.access(hcgen, os.X_OK): + print("Error: hcgen not found, please make first") + exit(1) + HCGEN = hcgen + + +def index_case(case_path): + cases = [] + for dir_name in os.listdir(case_path): + if os.path.isdir(os.path.join(case_path, dir_name)): + cases.append(dir_name) + cases.sort() + return cases + + +def get_golden_compile_result(mode, case_name): + result_file_name = os.path.join(WORK_DIR, case_name, + 'golden_%s_compile_result.txt' % mode) + status_prefix = '[compile exit status]:' + output_prefix = '[compile console output]:\n' + with open(result_file_name, 'r') as result_file: + status = result_file.readline() + status = status[len(status_prefix):] + console_output = result_file.read() + console_output = console_output[len(output_prefix):] + + return int(status), console_output.strip() + + +def compile_status_to_str(status): + if status: + return 'success' + else: + return 'failed' + + +def test_compile(case_name, mode): + output_dir = os.path.join(WORK_DIR, TEMP_DIR, case_name) + if not os.path.exists(output_dir): + os.makedirs(output_dir) + output_file = os.path.join(output_dir, 'golden') + source_file = os.path.join(WORK_DIR, case_name, 'case.hcs') + temp_dir = os.path.join(WORK_DIR, TEMP_DIR) + + if mode == 'text': + command = "%s -o %s -t %s" % (HCGEN, output_file, source_file) + else: + command = "%s -o %s %s" % (HCGEN, output_file, source_file) + + status, output = exec_command(command) + golden_status, golden_output = get_golden_compile_result(mode, case_name) + if bool(status) != bool(golden_status): + print("%s mode: case %s expect compile %s but %s" % + (mode, case_name, compile_status_to_str(status), + compile_status_to_str(golden_status))) + print("Console output :\n" + output) + return False + + output = output.replace(temp_dir, ".").replace(WORK_DIR, "."). \ + replace('\\', '/').replace(ERROR_COLOR_PREFIX, ""). \ + replace(ERROR_COLOR_END, "") + if output.strip() != golden_output: + print("output is different with golden for %s compile:" % mode) + print("EXPECT:\n" + golden_output) + print("ACTUAL:\n" + output.strip()) + return False + + return True + + +def binary_code_compile(case_name): + compile_result = test_compile(case_name, 'binary') + if not compile_result: + return False + + compile_start_time = get_current_time_ms() + + case_hcb = os.path.join(WORK_DIR, TEMP_DIR, case_name, 'golden.hcb') + golden_hcb = os.path.join(WORK_DIR, case_name, 'golden.hcb') + hcb_header_size = 20 # hcb compare skip hcb header + output_compare = \ + binary_file_compare(case_hcb, golden_hcb, hcb_header_size, True) + if not output_compare: + print('Error: hcb output mismatch with golden') + return False + + compile_finish_time = get_current_time_ms() + compile_used_time = compile_finish_time - compile_start_time + if compile_used_time > PERFORMANCE_MAX_COMPILE_TIME_MS: + print('Error: compile time %d, out of threshold %d ms' + % (compile_used_time, PERFORMANCE_MAX_COMPILE_TIME_MS)) + return False + + decompile_result = test_decompile(case_name) + + return decompile_result + + +def test_text_code_compile(case_name): + compile_result = test_compile(case_name, 'text') + if not compile_result: + return False + + case_c_file = os.path.join(WORK_DIR, TEMP_DIR, case_name, 'golden.c') + golden_c_file = os.path.join(WORK_DIR, case_name, 'golden.c.gen') + c_file_compare = text_file_compare(case_c_file, golden_c_file) + if not c_file_compare: + print("Error: The generated C file mismatch with golden") + + case_header_file = os.path.join(WORK_DIR, TEMP_DIR, case_name, 'golden.h') + golden_header_file = os.path.join(WORK_DIR, case_name, 'golden.h.gen') + header_file_compare = \ + text_file_compare(case_header_file, golden_header_file) + if not header_file_compare: + print("Error: The generated header file mismatch with golden") + return c_file_compare and header_file_compare + + +def test_decompile(case_name): + golden_decompile_file_name = \ + os.path.join(WORK_DIR, case_name, 'golden.d.hcs') + if not os.path.exists(golden_decompile_file_name): + return True + + output_dir = os.path.join(WORK_DIR, TEMP_DIR, case_name) + output_file = os.path.join(output_dir, 'case.hcs') + source_file = os.path.join(output_dir, 'golden.hcb') + command = "%s -o %s -d %s" % (HCGEN, output_file, source_file) + + status, output = exec_command(command) + if status != 0: + print('decompile fail') + print(output) + return False + + decompile_golden_result = text_file_compare( + os.path.join(output_dir, 'case.d.hcs'), golden_decompile_file_name) + if not decompile_golden_result: + print('Error: case %s decompile hcs mismatch with golden' % case_name) + return False + + return True + + +def get_current_time_ms(): + return int(round(time.time() * 1000)) + + +def test_cases(cases): + global SHOULD_CLEAN_TEMP + print('[==========] running %d cases form hcgen test' % len(cases)) + failed_cases = [] + test_start_time = get_current_time_ms() + for case in cases: + case_start_time = get_current_time_ms() + print('[ RUN ] %s' % case) + binary_compile_result = binary_code_compile(case) + text_compile_result = test_text_code_compile(case) + case_finish_time = get_current_time_ms() + used_time_str = ' (%d ms)' % (case_finish_time - case_start_time) + if (not binary_compile_result) or (not text_compile_result): + print('[ ERROR ] %s%s' % (case, used_time_str)) + failed_cases.append(case) + else: + print('[ OK ] %s%s' % (case, used_time_str)) + test_finish_time = get_current_time_ms() + print('\n[==========] running %d case (%d ms)' + % (len(cases), test_finish_time - test_start_time)) + print('[ PASSED ] %d cases' % (len(cases) - len(failed_cases))) + if len(failed_cases) > 0: + SHOULD_CLEAN_TEMP = False + print('[ FAILED ] %d cases, list below:' % len(failed_cases)) + for case in failed_cases: + print('[ FAILED ] %s' % case) + + +def setup_work_dir(): + global WORK_DIR + pwd = os.path.abspath(sys.argv[0]) + pwd = pwd[:pwd.rfind(os.sep)] + WORK_DIR = pwd + + +def test_setup(): + temp_dir = os.path.join(WORK_DIR, TEMP_DIR) + if not os.path.exists(temp_dir): + os.mkdir(temp_dir) + + +def test_teardown(): + global SHOULD_CLEAN_TEMP + if not SHOULD_CLEAN_TEMP: + return + temp_dir = os.path.join(WORK_DIR, TEMP_DIR) + if os.path.exists(temp_dir): + shutil.rmtree(temp_dir) + + +def clean_up(): + temp_dir = os.path.join(WORK_DIR, TEMP_DIR) + if os.path.exists(temp_dir): + shutil.rmtree(temp_dir) + + +if __name__ == "__main__": + setup_work_dir() + clean_up() + setup_hcgen_compiler() + print("hcgen path : " + HCGEN) + cases_list = index_case(WORK_DIR) + test_setup() + test_cases(cases_list) + test_teardown() diff --git a/tools/hc-gen/test/update_case.py b/tools/hc-gen/test/update_case.py new file mode 100755 index 000000000..292ee0ab8 --- /dev/null +++ b/tools/hc-gen/test/update_case.py @@ -0,0 +1,219 @@ +#!/usr/bin/env python +# coding: utf-8 +# +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import os +import platform +import shutil +import subprocess +import sys +import base64 + +SOURCE_ROOT = "../../" +CMAKE_GEN_PATH = "cmake-build-debug/" +WORK_DIR = "" +ERROR_COLOR_PREFIX = "\033[31m" +ERROR_COLOR_END = "\033[0m" +aligned_parm = '' + + +def setup_hcgen_compiler(): + global SOURCE_ROOT + global CMAKE_GEN_PATH + + if len(sys.argv) > 1: + hcgen_path = os.path.abspath(sys.argv[1]) + if hcgen_path.find('hc-gen') >= 0 and os.access(hcgen_path, os.X_OK): + print('use specified hsc:' + hcgen_path) + return hcgen_path + + source_root = '../../' + compiler_name = "hc-gen" + if platform.system() == "Windows": + source_root = source_root.replace("/", "\\") + compiler_name += ".exe" + + source_root = os.path.abspath(os.path.join(WORK_DIR, source_root)) + hcgen_path = os.path.join(source_root, compiler_name) + if not os.access(hcgen_path, os.X_OK): + hcgen_path = os.path.join(source_root, CMAKE_GEN_PATH, compiler_name) + if not os.access(hcgen_path, os.X_OK): + print("Error: hcgen not found, please make first") + exit(1) + + return hcgen_path + + +def index_case(case_path): + cases = [] + for directory in os.listdir(case_path): + if os.path.isdir(os.path.join(case_path, directory)): + cases.append(directory) + cases.sort() + return cases + + +def save_compile_result(mode, case_name, status, output): + result_file_name = os.path.join(WORK_DIR, case_name, + 'golden_%s_compile_result.txt' % mode) + with open(result_file_name, 'w') as result_output: + status_str = "[compile exit status]:" + str(status) + output_str = "\n[compile console output]:\n" + output + result_output.write(status_str) + result_output.write(output_str) + + +def gen_decompile_golden(hcgen_path, case_name): + source_file = os.path.join(WORK_DIR, case_name, 'golden.hcb') + target_file = os.path.join(WORK_DIR, case_name, 'golden') + command = "%s -o %s -d %s" % (hcgen_path, target_file, source_file) + status, output = subprocess.getstatusoutput(command) + if status: + print('case %s decompile fail:\n %s, status=%d' % + (case_name, output, status)) + + return status == 0 + + +def recode_hcb_file(file_path): + with open(file_path, 'rb') as hcb_file: + content = hcb_file.read() + hcb_file.close() + + with open(file_path, 'wb') as hcb_file: + base64_content = base64.b64encode(content) + hcb_file.write(base64_content) + hcb_file.close() + + +def build_binary(hcgen_path, case_name): + source_file = os.path.join(WORK_DIR, case_name, 'case.hcs') + target_file = os.path.join(WORK_DIR, case_name, 'golden') + command = "%s %s -o %s %s" % \ + (hcgen_path, aligned_parm, target_file, source_file) + status, output = subprocess.getstatusoutput(command) + if case_name.endswith('_ei'): + if status == 0: + print("CASE_ERROR:error identify case " + case_name + + "expect build fail but success at binary mode") + return False + elif status != 0: + print("CASE_ERROR:case " + case_name + + " expect build success but failed at binary mode") + return False + output = output.replace(WORK_DIR, ".").replace('\\', '/') \ + .replace(ERROR_COLOR_PREFIX, "") \ + .replace(ERROR_COLOR_END, "").strip() + + save_compile_result('binary', case_name, status, output) + + result = True + if status == 0: + result = gen_decompile_golden(hcgen_path, case_name) + if result: + recode_hcb_file(target_file + '.hcb') + return result + + +def build_text(hcgen_path, case_name): + source_file = os.path.join(WORK_DIR, case_name, 'case.hcs') + target_file = os.path.join(WORK_DIR, case_name, 'golden') + command = "%s -t -o %s %s" % (hcgen_path, target_file, source_file) + status, output = subprocess.getstatusoutput(command) + if case_name.endswith('_ei') or case_name.find('node_duplicate_name') >= 0: + if status == 0: + print("CASE_ERROR:error identify case " + + case_name + " expect build fail but success at text mode") + print(output) + return False + elif status != 0: + print("CASE_ERROR:case " + case_name + + " expect build success but failed at text mode") + print(output) + return False + output = output.replace(WORK_DIR, ".").replace('\\', '/') \ + .replace(ERROR_COLOR_PREFIX, "") \ + .replace(ERROR_COLOR_END, "").strip() + + save_compile_result('text', case_name, status, output) + + if status == 0: + os.rename(target_file + '.c', target_file + '.c.gen') + os.rename(target_file + '.h', target_file + '.h.gen') + return True + + +def build_cases(hcgen_path, cases): + index = 1 + failed_cases = [] + for case in cases: + print('[%02d/%d] build %s' % (index, len(cases), case)) + text_compile = build_text(hcgen_path, case) + binary_compile = build_binary(hcgen_path, case) + if not text_compile or not binary_compile: + failed_cases.append(case) + index += 1 + + print("\nUpdate cases result :\ntotal case: %d, failed: %d, success: %d" % + (len(cases), len(failed_cases), len(cases) - len(failed_cases))) + if len(failed_cases) > 0: + print("Failed case as below:") + for case in failed_cases: + print(case) + + +def setup_work_dir(): + global WORK_DIR + pwd = os.path.abspath(sys.argv[0]) + pwd = pwd[:pwd.rfind(os.sep)] + WORK_DIR = pwd + + +def clean_up(): + list_dirs = os.walk(WORK_DIR) + for root, dirs, files in list_dirs: + for file in files: + if file.startswith('golden'): + os.remove(os.path.join(root, file)) + + temp_dir = os.path.join(WORK_DIR, 'temp') + if os.path.exists(temp_dir): + shutil.rmtree(temp_dir) + + +if __name__ == "__main__": + if len(sys.argv) > 1 and sys.argv[-1] == '--align': + aligned_parm = ' -a ' + setup_work_dir() + hc_gen = setup_hcgen_compiler() + clean_up() + print("hc-gen path : " + hc_gen) + test_case_list = index_case(WORK_DIR) + build_cases(hc_gen, test_case_list) diff --git a/tools/leagecy/hc-gen/Makefile b/tools/leagecy/hc-gen/Makefile new file mode 100644 index 000000000..9dcdfae00 --- /dev/null +++ b/tools/leagecy/hc-gen/Makefile @@ -0,0 +1,84 @@ +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. +# +# HDF is dual licensed: you can use it either under the terms of +# the GPL, or the BSD license, at your option. +# See the LICENSE file in the root of this repository for complete details. + +TARGET := hc-gen +YACC_LEX_PREFIX :=HcsCompiler +C_FLAGS := -std=gnu99 -Wall -Werror -Wno-attributes -Wall +CC := gcc +YACC := bison +LEX := flex +Q = @ + +BOUNDS_CHECK_LIB := $(abspath ../../../../third_party/bounds_checking_function/) +INCLUDE_DIR := ./include $(BOUNDS_CHECK_LIB)/include +OUT_DIR := build + +TEST_CASE := $(abspath ../../../adapter/lite/khdf/test/tools/hc-gen/test/unittest) + +ORIGIN_SOURCES := $(wildcard src/*) +ORIGIN_SOURCES += $(wildcard $(BOUNDS_CHECK_LIB)/src/*) + +C_SOURCES := $(filter %.c,$(ORIGIN_SOURCES)) +YACC_SOURCES := $(filter %.y,$(ORIGIN_SOURCES)) +LEX_SOURCES := $(filter %.l,$(ORIGIN_SOURCES)) +YACC_GEN_SOURCES := $(patsubst %.y,$(OUT_DIR)/%_tab.c,$(YACC_SOURCES)) +LEX_GEN_SOURCES := $(patsubst %.l,$(OUT_DIR)/%_lex.c,$(LEX_SOURCES)) + +C_OBJECTS := $(patsubst %.c,$(OUT_DIR)/%.o,$(C_SOURCES)) +GEN_OBJECTS += $(patsubst %.c,%.o,$(YACC_GEN_SOURCES) $(LEX_GEN_SOURCES)) +OBJECTS := $(GEN_OBJECTS) $(C_OBJECTS) + +C_FLAGS += $(addprefix -I,$(INCLUDE_DIR)) +INCLUDE_DIR += $(OUT_DIR) + +UNAME := $(shell uname -a) +ifneq ($(findstring Linux,$(UNAME)),) + C_FLAGS += -D OS_LINUX +else + C_FLAGS += -D OS_WIN + C_FLAGS += -D MINGW32 +endif + +ifeq ($(BUILD_TYPE),debug) + C_FLAGS += -g +else ifeq ($(BUILD_TYPE),asan) + C_FLAGS += -g -fsanitize=address +else + # release + C_FLAGS += -O2 -s -ffunction-sections -fdata-sections -Wl,--gc-sections +endif + +all: $(TARGET) + +$(YACC_GEN_SOURCES) : $(OUT_DIR)/%_tab.c : %.y + $(Q)mkdir -p $(dir $(@)) + $(Q)$(YACC) -o $@ -v -d -pHcsCompiler $< + +$(LEX_GEN_SOURCES) : $(OUT_DIR)/%_lex.c : %.l | $(YACC_GEN_SOURCES) + $(Q)mkdir -p $(dir $(@)) + $(Q)$(LEX) -o $@ -PHcsCompiler $< + +$(C_OBJECTS) : $(OUT_DIR)/%.o : %.c + $(Q)mkdir -p $(dir $(@)) + $(Q)$(CC) -c -o $@ $(C_FLAGS) $^ + +$(GEN_OBJECTS) : %.o : %.c + $(Q)$(CC) -c -o $@ $(C_FLAGS) $^ + +$(TARGET) : $(OBJECTS) | $(GEN_OBJECTS) + $(Q)$(CC) -o $@ $(C_FLAGS) $^ + +test: all + python3 $(TEST_CASE)/hcgen_test.py $(TARGET) + +test_update: all + python3 $(TEST_CASE)/update_case.py $(TARGET) + +clean: + $(Q)rm -rf $(OUT_DIR) + $(Q)rm -f $(TARGET) + +.PHONY: clean all test test_update diff --git a/tools/hc-gen/README.md b/tools/leagecy/hc-gen/README.md similarity index 100% rename from tools/hc-gen/README.md rename to tools/leagecy/hc-gen/README.md diff --git a/tools/hc-gen/include/hcs_ast.h b/tools/leagecy/hc-gen/include/hcs_ast.h similarity index 100% rename from tools/hc-gen/include/hcs_ast.h rename to tools/leagecy/hc-gen/include/hcs_ast.h diff --git a/tools/hc-gen/include/hcs_compiler.h b/tools/leagecy/hc-gen/include/hcs_compiler.h similarity index 100% rename from tools/hc-gen/include/hcs_compiler.h rename to tools/leagecy/hc-gen/include/hcs_compiler.h diff --git a/tools/hc-gen/include/hcs_decompiler.h b/tools/leagecy/hc-gen/include/hcs_decompiler.h similarity index 100% rename from tools/hc-gen/include/hcs_decompiler.h rename to tools/leagecy/hc-gen/include/hcs_decompiler.h diff --git a/tools/hc-gen/include/hcs_file.h b/tools/leagecy/hc-gen/include/hcs_file.h similarity index 100% rename from tools/hc-gen/include/hcs_file.h rename to tools/leagecy/hc-gen/include/hcs_file.h diff --git a/tools/hc-gen/include/hcs_gener.h b/tools/leagecy/hc-gen/include/hcs_gener.h similarity index 100% rename from tools/hc-gen/include/hcs_gener.h rename to tools/leagecy/hc-gen/include/hcs_gener.h diff --git a/tools/hc-gen/include/hcs_log.h b/tools/leagecy/hc-gen/include/hcs_log.h similarity index 100% rename from tools/hc-gen/include/hcs_log.h rename to tools/leagecy/hc-gen/include/hcs_log.h diff --git a/tools/hc-gen/include/hcs_mem.h b/tools/leagecy/hc-gen/include/hcs_mem.h similarity index 100% rename from tools/hc-gen/include/hcs_mem.h rename to tools/leagecy/hc-gen/include/hcs_mem.h diff --git a/tools/hc-gen/include/hcs_opcode.h b/tools/leagecy/hc-gen/include/hcs_opcode.h similarity index 100% rename from tools/hc-gen/include/hcs_opcode.h rename to tools/leagecy/hc-gen/include/hcs_opcode.h diff --git a/tools/hc-gen/include/hcs_option.h b/tools/leagecy/hc-gen/include/hcs_option.h similarity index 100% rename from tools/hc-gen/include/hcs_option.h rename to tools/leagecy/hc-gen/include/hcs_option.h diff --git a/tools/hc-gen/include/hcs_parser.h b/tools/leagecy/hc-gen/include/hcs_parser.h similarity index 100% rename from tools/hc-gen/include/hcs_parser.h rename to tools/leagecy/hc-gen/include/hcs_parser.h diff --git a/tools/hc-gen/include/hcs_types.h b/tools/leagecy/hc-gen/include/hcs_types.h similarity index 100% rename from tools/hc-gen/include/hcs_types.h rename to tools/leagecy/hc-gen/include/hcs_types.h diff --git a/tools/hc-gen/src/hcs_ast.c b/tools/leagecy/hc-gen/src/hcs_ast.c similarity index 100% rename from tools/hc-gen/src/hcs_ast.c rename to tools/leagecy/hc-gen/src/hcs_ast.c diff --git a/tools/hc-gen/src/hcs_bytecode_gen.c b/tools/leagecy/hc-gen/src/hcs_bytecode_gen.c similarity index 100% rename from tools/hc-gen/src/hcs_bytecode_gen.c rename to tools/leagecy/hc-gen/src/hcs_bytecode_gen.c diff --git a/tools/hc-gen/src/hcs_compiler.l b/tools/leagecy/hc-gen/src/hcs_compiler.l similarity index 100% rename from tools/hc-gen/src/hcs_compiler.l rename to tools/leagecy/hc-gen/src/hcs_compiler.l diff --git a/tools/hc-gen/src/hcs_compiler.y b/tools/leagecy/hc-gen/src/hcs_compiler.y similarity index 100% rename from tools/hc-gen/src/hcs_compiler.y rename to tools/leagecy/hc-gen/src/hcs_compiler.y diff --git a/tools/hc-gen/src/hcs_decompile_gen.c b/tools/leagecy/hc-gen/src/hcs_decompile_gen.c similarity index 100% rename from tools/hc-gen/src/hcs_decompile_gen.c rename to tools/leagecy/hc-gen/src/hcs_decompile_gen.c diff --git a/tools/hc-gen/src/hcs_decompiler.c b/tools/leagecy/hc-gen/src/hcs_decompiler.c similarity index 100% rename from tools/hc-gen/src/hcs_decompiler.c rename to tools/leagecy/hc-gen/src/hcs_decompiler.c diff --git a/tools/hc-gen/src/hcs_file.c b/tools/leagecy/hc-gen/src/hcs_file.c similarity index 100% rename from tools/hc-gen/src/hcs_file.c rename to tools/leagecy/hc-gen/src/hcs_file.c diff --git a/tools/hc-gen/src/hcs_hexdump.c b/tools/leagecy/hc-gen/src/hcs_hexdump.c similarity index 100% rename from tools/hc-gen/src/hcs_hexdump.c rename to tools/leagecy/hc-gen/src/hcs_hexdump.c diff --git a/tools/hc-gen/src/hcs_main.c b/tools/leagecy/hc-gen/src/hcs_main.c similarity index 100% rename from tools/hc-gen/src/hcs_main.c rename to tools/leagecy/hc-gen/src/hcs_main.c diff --git a/tools/hc-gen/src/hcs_mem.c b/tools/leagecy/hc-gen/src/hcs_mem.c similarity index 100% rename from tools/hc-gen/src/hcs_mem.c rename to tools/leagecy/hc-gen/src/hcs_mem.c diff --git a/tools/hc-gen/src/hcs_middle.c b/tools/leagecy/hc-gen/src/hcs_middle.c similarity index 100% rename from tools/hc-gen/src/hcs_middle.c rename to tools/leagecy/hc-gen/src/hcs_middle.c diff --git a/tools/hc-gen/src/hcs_opcode.c b/tools/leagecy/hc-gen/src/hcs_opcode.c similarity index 100% rename from tools/hc-gen/src/hcs_opcode.c rename to tools/leagecy/hc-gen/src/hcs_opcode.c diff --git a/tools/hc-gen/src/hcs_option.c b/tools/leagecy/hc-gen/src/hcs_option.c similarity index 100% rename from tools/hc-gen/src/hcs_option.c rename to tools/leagecy/hc-gen/src/hcs_option.c diff --git a/tools/hc-gen/src/hcs_parser.c b/tools/leagecy/hc-gen/src/hcs_parser.c similarity index 100% rename from tools/hc-gen/src/hcs_parser.c rename to tools/leagecy/hc-gen/src/hcs_parser.c diff --git a/tools/hc-gen/src/hcs_text_gen.c b/tools/leagecy/hc-gen/src/hcs_text_gen.c similarity index 100% rename from tools/hc-gen/src/hcs_text_gen.c rename to tools/leagecy/hc-gen/src/hcs_text_gen.c -- Gitee From 7da55a78e84e57f56d40739502b11170158d74ab Mon Sep 17 00:00:00 2001 From: yuanbo Date: Wed, 2 Jun 2021 14:42:12 +0800 Subject: [PATCH 2/3] fit file mode Signed-off-by: yuanbo --- tools/hc-gen/test/01_empty_file_ei/case.hcs | 0 tools/hc-gen/test/02_empty_root_ei/case.hcs | 0 tools/hc-gen/test/03_empty_node/case.hcs | 0 tools/hc-gen/test/04_number_term/case.hcs | 0 tools/hc-gen/test/05_string_term/case.hcs | 0 tools/hc-gen/test/06_number_array/case.hcs | 0 tools/hc-gen/test/07_string_array/case.hcs | 0 tools/hc-gen/test/08_term_ref/case.hcs | 0 tools/hc-gen/test/09_node_nested/case.hcs | 0 tools/hc-gen/test/10_node_copy/case.hcs | 0 tools/hc-gen/test/11_case_node_ref/case.hcs | 0 tools/hc-gen/test/12_include_insert/case.hcs | 0 tools/hc-gen/test/13_include_modify/case.hcs | 0 tools/hc-gen/test/14_include_delete/case.hcs | 0 tools/hc-gen/test/15_line_comment/case.hcs | 0 tools/hc-gen/test/16_block_comment/case.hcs | 0 tools/hc-gen/test/17_broken_node_ei/case.hcs | 0 tools/hc-gen/test/18_broken_string_ei/case.hcs | 0 tools/hc-gen/test/19_broken_number_ei/case.hcs | 0 tools/hc-gen/test/20_broken_array_ei/case.hcs | 0 tools/hc-gen/test/21_mix_type_array_ei/case.hcs | 0 tools/hc-gen/test/22_redefine_error_ei/case.hcs | 0 tools/hc-gen/test/23_node_ref_invalid_node_ei/case.hcs | 0 tools/hc-gen/test/24_node_copy_invlid_node_ei/case.hcs | 0 tools/hc-gen/test/25_term_ref_invlid_node_ei/case.hcs | 0 tools/hc-gen/test/26_miss_semicolon_ei/case.hcs | 0 tools/hc-gen/test/27_include_invalid_file_ei/case.hcs | 0 tools/hc-gen/test/28_overwrite_with_diff_type_ei/case.hcs | 0 tools/hc-gen/test/29_node_copy_nested_ei/case.hcs | 0 tools/hc-gen/test/30_include_order/case.hcs | 0 tools/hc-gen/test/31_node_duplicate_name/case.hcs | 0 tools/hc-gen/test/32_large_hsl/case.hcs | 0 tools/hc-gen/test/33_miss_module_name_ei/case.hcs | 0 tools/hc-gen/test/34_template/case.hcs | 0 tools/hc-gen/test/35_nested_template/case.hcs | 0 35 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tools/hc-gen/test/01_empty_file_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/02_empty_root_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/03_empty_node/case.hcs mode change 100755 => 100644 tools/hc-gen/test/04_number_term/case.hcs mode change 100755 => 100644 tools/hc-gen/test/05_string_term/case.hcs mode change 100755 => 100644 tools/hc-gen/test/06_number_array/case.hcs mode change 100755 => 100644 tools/hc-gen/test/07_string_array/case.hcs mode change 100755 => 100644 tools/hc-gen/test/08_term_ref/case.hcs mode change 100755 => 100644 tools/hc-gen/test/09_node_nested/case.hcs mode change 100755 => 100644 tools/hc-gen/test/10_node_copy/case.hcs mode change 100755 => 100644 tools/hc-gen/test/11_case_node_ref/case.hcs mode change 100755 => 100644 tools/hc-gen/test/12_include_insert/case.hcs mode change 100755 => 100644 tools/hc-gen/test/13_include_modify/case.hcs mode change 100755 => 100644 tools/hc-gen/test/14_include_delete/case.hcs mode change 100755 => 100644 tools/hc-gen/test/15_line_comment/case.hcs mode change 100755 => 100644 tools/hc-gen/test/16_block_comment/case.hcs mode change 100755 => 100644 tools/hc-gen/test/17_broken_node_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/18_broken_string_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/19_broken_number_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/20_broken_array_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/21_mix_type_array_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/22_redefine_error_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/23_node_ref_invalid_node_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/24_node_copy_invlid_node_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/25_term_ref_invlid_node_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/26_miss_semicolon_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/27_include_invalid_file_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/28_overwrite_with_diff_type_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/29_node_copy_nested_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/30_include_order/case.hcs mode change 100755 => 100644 tools/hc-gen/test/31_node_duplicate_name/case.hcs mode change 100755 => 100644 tools/hc-gen/test/32_large_hsl/case.hcs mode change 100755 => 100644 tools/hc-gen/test/33_miss_module_name_ei/case.hcs mode change 100755 => 100644 tools/hc-gen/test/34_template/case.hcs mode change 100755 => 100644 tools/hc-gen/test/35_nested_template/case.hcs diff --git a/tools/hc-gen/test/01_empty_file_ei/case.hcs b/tools/hc-gen/test/01_empty_file_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/02_empty_root_ei/case.hcs b/tools/hc-gen/test/02_empty_root_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/03_empty_node/case.hcs b/tools/hc-gen/test/03_empty_node/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/04_number_term/case.hcs b/tools/hc-gen/test/04_number_term/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/05_string_term/case.hcs b/tools/hc-gen/test/05_string_term/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/06_number_array/case.hcs b/tools/hc-gen/test/06_number_array/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/07_string_array/case.hcs b/tools/hc-gen/test/07_string_array/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/08_term_ref/case.hcs b/tools/hc-gen/test/08_term_ref/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/09_node_nested/case.hcs b/tools/hc-gen/test/09_node_nested/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/10_node_copy/case.hcs b/tools/hc-gen/test/10_node_copy/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/11_case_node_ref/case.hcs b/tools/hc-gen/test/11_case_node_ref/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/12_include_insert/case.hcs b/tools/hc-gen/test/12_include_insert/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/13_include_modify/case.hcs b/tools/hc-gen/test/13_include_modify/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/14_include_delete/case.hcs b/tools/hc-gen/test/14_include_delete/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/15_line_comment/case.hcs b/tools/hc-gen/test/15_line_comment/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/16_block_comment/case.hcs b/tools/hc-gen/test/16_block_comment/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/17_broken_node_ei/case.hcs b/tools/hc-gen/test/17_broken_node_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/18_broken_string_ei/case.hcs b/tools/hc-gen/test/18_broken_string_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/19_broken_number_ei/case.hcs b/tools/hc-gen/test/19_broken_number_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/20_broken_array_ei/case.hcs b/tools/hc-gen/test/20_broken_array_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/21_mix_type_array_ei/case.hcs b/tools/hc-gen/test/21_mix_type_array_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/22_redefine_error_ei/case.hcs b/tools/hc-gen/test/22_redefine_error_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/23_node_ref_invalid_node_ei/case.hcs b/tools/hc-gen/test/23_node_ref_invalid_node_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/24_node_copy_invlid_node_ei/case.hcs b/tools/hc-gen/test/24_node_copy_invlid_node_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/25_term_ref_invlid_node_ei/case.hcs b/tools/hc-gen/test/25_term_ref_invlid_node_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/26_miss_semicolon_ei/case.hcs b/tools/hc-gen/test/26_miss_semicolon_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/27_include_invalid_file_ei/case.hcs b/tools/hc-gen/test/27_include_invalid_file_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/28_overwrite_with_diff_type_ei/case.hcs b/tools/hc-gen/test/28_overwrite_with_diff_type_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/29_node_copy_nested_ei/case.hcs b/tools/hc-gen/test/29_node_copy_nested_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/30_include_order/case.hcs b/tools/hc-gen/test/30_include_order/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/31_node_duplicate_name/case.hcs b/tools/hc-gen/test/31_node_duplicate_name/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/32_large_hsl/case.hcs b/tools/hc-gen/test/32_large_hsl/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/33_miss_module_name_ei/case.hcs b/tools/hc-gen/test/33_miss_module_name_ei/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/34_template/case.hcs b/tools/hc-gen/test/34_template/case.hcs old mode 100755 new mode 100644 diff --git a/tools/hc-gen/test/35_nested_template/case.hcs b/tools/hc-gen/test/35_nested_template/case.hcs old mode 100755 new mode 100644 -- Gitee From 13e1d64c92cb1abcd361bce6c34e24788c39675e Mon Sep 17 00:00:00 2001 From: yuanbo Date: Thu, 3 Jun 2021 20:26:10 +0800 Subject: [PATCH 3/3] update makefile to remove cmake dependency Signed-off-by: yuanbo --- tools/hc-gen/Makefile | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tools/hc-gen/Makefile b/tools/hc-gen/Makefile index dbfb95d53..9ee07ed59 100644 --- a/tools/hc-gen/Makefile +++ b/tools/hc-gen/Makefile @@ -1,20 +1,34 @@ Q = @ BUILD_DIR := build -TARGET := hc-gen +TARGET := $(BUILD_DIR)/hc-gen +CXX := c++ +CXX_FLAGS := -std=gnu++14 + +SRCS := $(wildcard src/*.cpp) +OBJECTS := $(patsubst %.cpp,$(BUILD_DIR)/%.o,$(SRCS)) + +ifeq ($(LANG),) + CXX_FLAGS += -DOS_MINGW +else + CXX_FLAGS += -DOS_UNIX +endif all: $(TARGET) -$(TARGET): - $(Q)mkdir -p $(BUILD_DIR) - $(Q)pushd $(BUILD_DIR); cmake ../; popd - $(Q)make -C $(BUILD_DIR) +$(OBJECTS): $(BUILD_DIR)/%.o : %.cpp + $(Q) echo CC $< + $(Q) mkdir -p $(dir $@) + $(Q) $(CXX) $(CXX_FLAGS) $(CXX_LD_FLAGS) -c $< -o $@ + +$(TARGET): $(OBJECTS) + $(Q) $(CXX) $(CXX_FLAGS) $(CXX_LD_FLAGS) $^ -o $@ test: $(TARGET) - $(Q) python test/hcgen_test.py $(BUILD_DIR)/$(TARGET) + $(Q) python test/hcgen_test.py $(TARGET) update_testcase: $(TARGET) - $(Q) python test/update_case.py $(BUILD_DIR)/$(TARGET) + $(Q) python test/update_case.py $(TARGET) clean: $(Q) rm -rf $(BUILD_DIR) -- Gitee