From 94a7aadfee2cbd741742e2563fc7568242235f07 Mon Sep 17 00:00:00 2001 From: zmw Date: Tue, 26 Aug 2025 21:19:22 +0800 Subject: [PATCH] Fix annotation bcHar compile fail Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICUXKP Description: Fix annotation bcHar compile fail Signed-off-by: zmw Change-Id: I15362a1731ce5ffdbcf53a11c4e795792bd77efe --- es2panda/compiler/core/compileQueue.cpp | 4 + es2panda/parser/statementParser.cpp | 4 + .../abcinputs/bytecodehar.txt | 2 + .../abcinputs/bytecodehar.txt | 2 + .../exportAnno.ts | 25 + .../importAnno-exec-expected.pa.txt | 627 ++++++++++++++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../exportAnno.ts | 23 + .../importAnno-exec-expected.pa.txt | 254 +++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../abcinputs/bytecodehar.txt | 2 + .../exportAnno.ts | 28 + .../importAnno-exec-expected.pa.txt | 400 +++++++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../abcinputs/bytecodehar.txt | 2 + .../exportAnno.ts | 28 + .../importAnno-exec-expected.pa.txt | 356 ++++++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../abcinputs/bytecodehar.txt | 2 + .../exportAnno.ts | 24 + .../importAnno-exec-expected.pa.txt | 366 ++++++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../abcinputs/bytecodehar.txt | 2 + .../exportAnno.ts | 23 + .../importAnno-exec-expected.pa.txt | 370 +++++++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../abcinputs/bytecodehar.txt | 2 + .../exportAnno.ts | 23 + .../importAnno-exec-expected.pa.txt | 318 +++++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../hap-file-exec-expected.pa.txt | 480 ++++++++++++-- .../hap-file-exec.ts | 7 +- .../abcinputs/bytecodehar.txt | 2 + .../exportAnno.ts | 23 + .../importAnno-exec-expected.pa.txt | 254 +++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../abcinputs/bytecodehar.txt | 2 + .../exportAnno.ts | 23 + .../importAnno-exec-expected.pa.txt | 270 ++++++++ .../importAnno-exec.ts | 23 + .../recordnames.txt | 2 + .../bytecode_feature/export_annotations.ts | 20 + ...runtime_below_abc_api_version-expected.txt | 1 + ...supported_compile_asm_version-expected.txt | 24 + ...ons_supported_runtime_version-expected.txt | 0 ...supported_compile_asm_version-expected.txt | 3 + es2panda/util/helpers.cpp | 31 +- es2panda/util/helpers.h | 2 +- 56 files changed, 4205 insertions(+), 49 deletions(-) create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/recordnames.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/recordnames.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/recordnames.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/recordnames.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/recordnames.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/recordnames.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/recordnames.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/recordnames.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/abcinputs/bytecodehar.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/exportAnno.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/importAnno-exec-expected.pa.txt create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/importAnno-exec.ts create mode 100644 es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/recordnames.txt create mode 100644 es2panda/test/version_control/API20/bytecode_feature/export_annotations.ts create mode 100644 es2panda/test/version_control/API20/bytecode_feature/export_annotations_runtime_below_abc_api_version-expected.txt create mode 100644 es2panda/test/version_control/API20/bytecode_feature/export_annotations_supported_compile_asm_version-expected.txt create mode 100644 es2panda/test/version_control/API20/bytecode_feature/export_annotations_supported_runtime_version-expected.txt create mode 100644 es2panda/test/version_control/API20/bytecode_feature/export_annotations_unsupported_compile_asm_version-expected.txt diff --git a/es2panda/compiler/core/compileQueue.cpp b/es2panda/compiler/core/compileQueue.cpp index 46739bbe06..733b0cb166 100644 --- a/es2panda/compiler/core/compileQueue.cpp +++ b/es2panda/compiler/core/compileQueue.cpp @@ -232,6 +232,10 @@ void CompileAbcClassJob::Run() auto *program = new panda::pandasm::Program(); std::string record_name = ""; compiler_.CompileAbcClass(recordId, *program, record_name); + if (program->record_table.size() == 0) { + delete program; + return; + } program->isGeneratedFromMergedAbc = true; if (!options_.modifiedPkgName.empty()) { diff --git a/es2panda/parser/statementParser.cpp b/es2panda/parser/statementParser.cpp index e239a442f0..5442875a89 100644 --- a/es2panda/parser/statementParser.cpp +++ b/es2panda/parser/statementParser.cpp @@ -2734,6 +2734,10 @@ ir::ExportNamedDeclaration *ParserImpl::ParseNamedExportDeclaration(const lexer: ThrowSyntaxError("'interface' keyword expected."); } + if (!program_.IsEnableAnnotations()) { + ThrowAnnotationNotEnable(); + } + if (!decorators.empty()) { ThrowSyntaxError("Decorators are not valid here.", decorators.front()->Start()); } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/exportAnno.ts new file mode 100644 index 0000000000..256703545e --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/exportAnno.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + name: string = "" + a: number; + + } + +@__$$ETS_ANNOTATION$$__MyAnno +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..e26d1714fa --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/importAnno-exec-expected.pa.txt @@ -0,0 +1,627 @@ +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1437, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1369 +{ + index: 0 + tag: 0 + val: 1 +}, +{ + index: 1 + tag: 1 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 1 +}, +{ + index: 3 + tag: 1 + val: 0 +}, +{ + index: 4 + tag: 0 + val: 1 +}, +{ + index: 5 + tag: 1 + val: 1 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1379 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1369 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1388 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1379 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1397 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1401 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1437 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1538, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1446 +{ + index: 0 + tag: 0 + val: 1 +}, +{ + index: 1 + tag: 1 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 1 +}, +{ + index: 3 + tag: 1 + val: 0 +}, +{ + index: 4 + tag: 0 + val: 1 +}, +{ + index: 5 + tag: 1 + val: 1 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1456 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1446 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1465 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1456 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1474 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1478 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1538 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any bytecodehar-annotations-string/exportAnno.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any bytecodehar-annotations-string/exportAnno.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, bytecodehar-annotations-string/exportAnno.#~A=#A, bytecodehar-annotations-string/exportAnno_2, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bytecodehar-annotations-string/exportAnno_0 +------------------------------------ +slot bytecodehar-annotations-string/exportAnno_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot bytecodehar-annotations-string/exportAnno_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"bytecodehar-annotations-string/exportAnno.#~A=#A"; "prototype"; +slotNum = 0x0 +.language ECMAScript +.function any bytecodehar-annotations-string/importAnno-exec.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any bytecodehar-annotations-string/importAnno-exec.#~B>#fun(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any bytecodehar-annotations-string/importAnno-exec.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, bytecodehar-annotations-string/importAnno-exec.#~B=#B, bytecodehar-annotations-string/importAnno-exec_2, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bytecodehar-annotations-string/importAnno-exec.#~B>#fun_name_0 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: hello +}, +------------------------------------ +slot bytecodehar-annotations-string/importAnno-exec_0 +------------------------------------ +slot bytecodehar-annotations-string/importAnno-exec_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot bytecodehar-annotations-string/importAnno-exec_2 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: bytecodehar-annotations-string/importAnno-exec.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"B"; "bytecodehar-annotations-string/importAnno-exec.#~B=#B"; "print"; "prototype"; diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/importAnno-exec.ts new file mode 100644 index 0000000000..fee3523c0d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({name: ["hello"]}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/bytecodehar-annotations-string/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/exportAnno.ts new file mode 100644 index 0000000000..bfff3ae45d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/exportAnno.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + a: boolean[][][]; +} + +@__$$ETS_ANNOTATION$$__MyAnno({a: [[[true, false, true]]]}) +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..ec558e4ba0 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/importAnno-exec-expected.pa.txt @@ -0,0 +1,254 @@ +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1370, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1330 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1334 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1370 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1443, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1379 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1383 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1443 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/importAnno-exec.ts new file mode 100644 index 0000000000..8c977a5c83 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({a: [[[true, false, true]]]}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-boolean/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/exportAnno.ts new file mode 100644 index 0000000000..dfca2df7ec --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/exportAnno.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const enum E { + A = 1, + B = -2 +} + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + a: E[][][] = [[new Array(0)]]; +} + +@__$$ETS_ANNOTATION$$__MyAnno({a: [[[1, -2, 1]]]}) +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..f5267ecdfc --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/importAnno-exec-expected.pa.txt @@ -0,0 +1,400 @@ +slotNum = 0x9 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#%#E(any a0, any a1, any a2, any a3) { + lda.str A + sta v0 + ldai 0x1 + sta v1 + lda v1 + stobjbyvalue 0x0, a3, v0 + lda.str A + stobjbyvalue 0x2, a3, v1 + lda.str B + sta v0 + ldai 0x2 + neg 0x4 + sta v1 + stobjbyvalue 0x5, a3, v0 + lda.str B + stobjbyvalue 0x7, a3, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldundefined + sta v0 + definefunc 0x0, &importAnnoPgName/exportAnno&2.0.0.#%#E, 0x1 + sta v1 + lda v0 + callruntime.istrue 0x1 + jnez label@9 + createemptyobject + sta v0 +label@9: + lda v1 + callarg1 0x2, v0 + ldhole + sta v0 + defineclasswithbuffer 0x4, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1552, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1463 +{ + index: 0 + tag: 0 + val: 4 +}, +{ + index: 1 + tag: 4 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 4 +}, +{ + index: 3 + tag: 4 + val: -2 +}, +{ + index: 4 + tag: 0 + val: 4 +}, +{ + index: 5 + tag: 4 + val: 1 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1494 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1463 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1503 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1494 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1512 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1516 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1552 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#%#E"; "&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "A"; "B"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1674, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1561 +{ + index: 0 + tag: 0 + val: 4 +}, +{ + index: 1 + tag: 4 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 4 +}, +{ + index: 3 + tag: 4 + val: -2 +}, +{ + index: 4 + tag: 0 + val: 4 +}, +{ + index: 5 + tag: 4 + val: 1 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1592 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1561 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1601 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1592 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1610 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1614 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1674 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/importAnno-exec.ts new file mode 100644 index 0000000000..c3f4d33928 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({a: [[[1, -2, 1]]]}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-number/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/exportAnno.ts new file mode 100644 index 0000000000..e7e6ab12e1 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/exportAnno.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const enum E { + A = "Hello", + B = "world" +} + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + a: E[][][] = [[new Array(2)]]; +} + +@__$$ETS_ANNOTATION$$__MyAnno({a: [[new Array(3)]]}) +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..c7473aea5e --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/importAnno-exec-expected.pa.txt @@ -0,0 +1,356 @@ +slotNum = 0x4 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#%#E(any a0, any a1, any a2, any a3) { + lda.str A + sta v0 + lda.str Hello + stobjbyvalue 0x0, a3, v0 + lda.str B + sta v0 + lda.str world + stobjbyvalue 0x2, a3, v0 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldundefined + sta v0 + definefunc 0x0, &importAnnoPgName/exportAnno&2.0.0.#%#E, 0x1 + sta v1 + lda v0 + callruntime.istrue 0x1 + jnez label@9 + createemptyobject + sta v0 +label@9: + lda v1 + callarg1 0x2, v0 + ldhole + sta v0 + defineclasswithbuffer 0x4, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1582, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1518 +{ + index: 0 + tag: 0 + val: 25 +}, +{ + index: 1 + tag: 25 + val: 2 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1524 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1518 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1533 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1524 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1542 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1546 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1582 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#%#E"; "&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "A"; "B"; "Hello"; "prototype"; "world"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1679, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1591 +{ + index: 0 + tag: 0 + val: 25 +}, +{ + index: 1 + tag: 25 + val: 2 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1597 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1591 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1606 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1597 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1615 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1619 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1679 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/importAnno-exec.ts new file mode 100644 index 0000000000..4f906dcb75 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({a: [[new Array(3)]]}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-enum-string/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/exportAnno.ts new file mode 100644 index 0000000000..d597e6e934 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/exportAnno.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + a: number[][][]; + + } + +@__$$ETS_ANNOTATION$$__MyAnno({a: [[[1, -2, 3]]]}) +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..cfbaf41712 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/importAnno-exec-expected.pa.txt @@ -0,0 +1,366 @@ +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1456, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1367 +{ + index: 0 + tag: 0 + val: 4 +}, +{ + index: 1 + tag: 4 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 4 +}, +{ + index: 3 + tag: 4 + val: -2 +}, +{ + index: 4 + tag: 0 + val: 4 +}, +{ + index: 5 + tag: 4 + val: 3 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1398 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1367 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1407 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1398 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1416 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1420 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1456 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1578, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1465 +{ + index: 0 + tag: 0 + val: 4 +}, +{ + index: 1 + tag: 4 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 4 +}, +{ + index: 3 + tag: 4 + val: -2 +}, +{ + index: 4 + tag: 0 + val: 4 +}, +{ + index: 5 + tag: 4 + val: 3 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1496 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1465 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1505 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1496 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1514 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1518 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1578 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/importAnno-exec.ts new file mode 100644 index 0000000000..74c0072b45 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({a: [[[1, -2, 3]]]}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-number/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/exportAnno.ts new file mode 100644 index 0000000000..1d83d97e69 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/exportAnno.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + a: string[][][]; +} + +@__$$ETS_ANNOTATION$$__MyAnno({a: [[["Hello", "World", "!"]]]}) +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..6b0caddd39 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/importAnno-exec-expected.pa.txt @@ -0,0 +1,370 @@ +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1494, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1417 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: Hello +}, +{ + index: 2 + tag: 0 + val: 5 +}, +{ + index: 3 + tag: 5 + val: World +}, +{ + index: 4 + tag: 0 + val: 5 +}, +{ + index: 5 + tag: 5 + val: ! +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1436 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1417 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1445 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/exportAnno&2.0.0_1436 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1454 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1458 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1494 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1604, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1503 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: Hello +}, +{ + index: 2 + tag: 0 + val: 5 +}, +{ + index: 3 + tag: 5 + val: World +}, +{ + index: 4 + tag: 0 + val: 5 +}, +{ + index: 5 + tag: 5 + val: ! +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1522 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1503 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1531 +{ + index: 0 + tag: 0 + val: 24 +}, +{ + index: 1 + tag: 24 + val: &importAnnoPgName/importAnno-exec&2.0.0_1522 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1540 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1544 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1604 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/importAnno-exec.ts new file mode 100644 index 0000000000..71b5f08045 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({a: [[["Hello", "World", "!"]]]}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-3d-array-string/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/exportAnno.ts new file mode 100644 index 0000000000..f7af177a27 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/exportAnno.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + a: boolean[]; +} + +@__$$ETS_ANNOTATION$$__MyAnno({a: [true, false, true]}) +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..0ce7b4aedd --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/importAnno-exec-expected.pa.txt @@ -0,0 +1,318 @@ +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1411, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1361 +{ + index: 0 + tag: 0 + val: 1 +}, +{ + index: 1 + tag: 1 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 1 +}, +{ + index: 3 + tag: 1 + val: 0 +}, +{ + index: 4 + tag: 0 + val: 1 +}, +{ + index: 5 + tag: 1 + val: 1 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1371 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1375 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1411 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1494, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1420 +{ + index: 0 + tag: 0 + val: 1 +}, +{ + index: 1 + tag: 1 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 1 +}, +{ + index: 3 + tag: 1 + val: 0 +}, +{ + index: 4 + tag: 0 + val: 1 +}, +{ + index: 5 + tag: 1 + val: 1 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1430 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1434 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1494 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/importAnno-exec.ts new file mode 100644 index 0000000000..8bd94517cb --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({a: [true, false, true]}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-array-boolean/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt index d327a5a78a..4896af8ffa 100644 --- a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt @@ -1,8 +1,12 @@ All Dependency Files: program_file: bytecodehar1-abcinput.abc record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file2&2.0.0 program_file: bytecodehar2-abcinput.abc record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 program_file: hap-file-exec.ts record_name: &myapp/hap-file-exec& program_file: sourcehar-file1.ts @@ -498,7 +502,7 @@ slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712 ======> literal array buffer <====== ======> strings <====== -slotNum = 0x4 +slotNum = 0x8 .language ECMAScript .function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { label_1: @@ -513,6 +517,12 @@ label_0: throw.undefinedifholewithname A mov v1, v0 newobjrange 0x2, 0x1, v1 + ldlexvar 0x0, 0x0 + sta v0 + throw.undefinedifholewithname ns + lda v0 + ldobjbyname 0x4, test + callthis0 0x6, v0 returnundefined label_2: } @@ -527,18 +537,46 @@ label_0: label_2: } -slotNum = 0x4 +slotNum = 0x0 .language ECMAScript -.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +.function any &myapp/hap-file-exec&.#~C=#C(any a0, any a1, any a2) { label_1: label_0: + lda a2 + return +label_2: +} + +slotNum = 0x10 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_4: +label_0: + newlexenv 0x1 definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x0 ldhole sta v0 defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 ldobjbyname 0x2, prototype + ldhole + sta v0 + defineclasswithbuffer 0x4, &myapp/hap-file-exec&.#~C=#C, &myapp/hap-file-exec&_3, 0x0, v0 + sta v0 + ldobjbyname 0x5, prototype + tryldglobalbyname 0x7, __$$ETS_ANNOTATION$$__ns + sta v1 + ldobjbyname 0x8, Anno2 + sta v2 + createobjectwithbuffer 0xa, &myapp/hap-file-exec&_4 + sta v3 + lda v2 + callthis1 0xb, v1, v3 + callarg1 0xd, v0 + callruntime.istrue 0xf returnundefined -label_2: +label_5: } @@ -550,7 +588,7 @@ slot &myapp/hap-file-exec&_1 { index: 0 tag: 2 - val: 1 + val: 2 }, { index: 1 @@ -559,71 +597,86 @@ slot &myapp/hap-file-exec&_1 }, { index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0 +}, +{ + index: 3 tag: 2 val: 3 }, { - index: 3 + index: 4 tag: 5 val: A }, { - index: 4 + index: 5 tag: 5 val: A }, { - index: 5 + index: 6 tag: 9 val: 0 }, { - index: 6 + index: 7 tag: 5 val: Anno1 }, { - index: 7 + index: 8 tag: 5 val: Anno1 }, { - index: 8 + index: 9 tag: 9 val: 0 }, { - index: 9 + index: 10 tag: 5 val: test }, { - index: 10 + index: 11 tag: 5 val: test }, { - index: 11 + index: 12 tag: 9 val: 0 }, { - index: 12 + index: 13 tag: 2 - val: 0 + val: 1 }, { - index: 13 + index: 14 + tag: 5 + val: ns +}, +{ + index: 15 + tag: 9 + val: 1 +}, +{ + index: 16 tag: 2 val: 0 }, { - index: 14 + index: 17 tag: 2 val: 0 }, { - index: 15 + index: 18 tag: 2 val: 0 }, @@ -639,8 +692,42 @@ slot &myapp/hap-file-exec&_2 tag: 2 val: 0 }, +------------------------------------ +slot &myapp/hap-file-exec&_3 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_4 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: b +}, +{ + index: 2 + tag: 0 + val: 1 +}, +{ + index: 3 + tag: 1 + val: 1 +}, ======> strings <====== -"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "&myapp/hap-file-exec&.#~C=#C"; "A"; "Anno2"; "__$$ETS_ANNOTATION$$__ns"; "ns"; "prototype"; "test"; slotNum = 0x3 .language ECMAScript .function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { @@ -936,6 +1023,133 @@ slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 ======> literal array buffer <====== ======> strings <====== +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1915, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1853 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1857 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1915 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + slotNum = 0x3 .language ECMAScript .function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { @@ -1041,8 +1255,113 @@ slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 ======> literal array buffer <====== ======> strings <====== +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + slotNum = 0x4 .language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1664 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1668 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x8 +.language ECMAScript .function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { label_1: label_0: @@ -1056,6 +1375,12 @@ label_0: throw.undefinedifholewithname A mov v1, v0 newobjrange 0x2, 0x1, v1 + ldlexvar 0x0, 0x0 + sta v0 + throw.undefinedifholewithname ns + lda v0 + ldobjbyname 0x4, test + callthis0 0x6, v0 returnundefined label_2: } @@ -1070,18 +1395,46 @@ label_0: label_2: } -slotNum = 0x4 +slotNum = 0x0 .language ECMAScript -.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +.function any &myapp/hap-file-exec&.#~C=#C(any a0, any a1, any a2) { label_1: label_0: + lda a2 + return +label_2: +} + +slotNum = 0x10 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_4: +label_0: + newlexenv 0x1 definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x0 ldhole sta v0 defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 ldobjbyname 0x2, prototype + ldhole + sta v0 + defineclasswithbuffer 0x4, &myapp/hap-file-exec&.#~C=#C, &myapp/hap-file-exec&_3, 0x0, v0 + sta v0 + ldobjbyname 0x5, prototype + tryldglobalbyname 0x7, __$$ETS_ANNOTATION$$__ns + sta v1 + ldobjbyname 0x8, Anno2 + sta v2 + createobjectwithbuffer 0xa, &myapp/hap-file-exec&_4 + sta v3 + lda v2 + callthis1 0xb, v1, v3 + callarg1 0xd, v0 + callruntime.istrue 0xf returnundefined -label_2: +label_5: } @@ -1093,7 +1446,7 @@ slot &myapp/hap-file-exec&_1 { index: 0 tag: 2 - val: 1 + val: 2 }, { index: 1 @@ -1102,71 +1455,86 @@ slot &myapp/hap-file-exec&_1 }, { index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0 +}, +{ + index: 3 tag: 2 val: 3 }, { - index: 3 + index: 4 tag: 5 val: A }, { - index: 4 + index: 5 tag: 5 val: A }, { - index: 5 + index: 6 tag: 9 val: 0 }, { - index: 6 + index: 7 tag: 5 val: Anno1 }, { - index: 7 + index: 8 tag: 5 val: Anno1 }, { - index: 8 + index: 9 tag: 9 val: 0 }, { - index: 9 + index: 10 tag: 5 val: test }, { - index: 10 + index: 11 tag: 5 val: test }, { - index: 11 + index: 12 tag: 9 val: 0 }, { - index: 12 + index: 13 tag: 2 - val: 0 + val: 1 }, { - index: 13 + index: 14 + tag: 5 + val: ns +}, +{ + index: 15 + tag: 9 + val: 1 +}, +{ + index: 16 tag: 2 val: 0 }, { - index: 14 + index: 17 tag: 2 val: 0 }, { - index: 15 + index: 18 tag: 2 val: 0 }, @@ -1182,8 +1550,42 @@ slot &myapp/hap-file-exec&_2 tag: 2 val: 0 }, +------------------------------------ +slot &myapp/hap-file-exec&_3 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_4 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: b +}, +{ + index: 2 + tag: 0 + val: 1 +}, +{ + index: 3 + tag: 1 + val: 1 +}, ======> strings <====== -"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "&myapp/hap-file-exec&.#~C=#C"; "A"; "Anno2"; "__$$ETS_ANNOTATION$$__ns"; "ns"; "prototype"; "test"; slotNum = 0x3 .language ECMAScript .function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts index 8fe9e1625e..db3f49111f 100644 --- a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts @@ -14,11 +14,16 @@ */ import { test, __$$ETS_ANNOTATION$$__Anno1, A } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" +import * as ns from "@normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0" function main() { test(); let a = new A(); + ns.test(); } @__$$ETS_ANNOTATION$$__Anno1({ b: true }) -class B { } \ No newline at end of file +class B { } + +@__$$ETS_ANNOTATION$$__ns.Anno2({ b: true }) +class C { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/exportAnno.ts new file mode 100644 index 0000000000..cf26c61cef --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/exportAnno.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + a: number; +} + +@__$$ETS_ANNOTATION$$__MyAnno({a: 42}) +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..525a4c9c70 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/importAnno-exec-expected.pa.txt @@ -0,0 +1,254 @@ +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1379, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1339 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1343 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1379 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1452, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1388 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1392 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1452 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/importAnno-exec.ts new file mode 100644 index 0000000000..67050f4249 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({a: 42}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-number/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000..e08eaf2f74 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +importAnno-exec.ts +exportAnno.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/exportAnno.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/exportAnno.ts new file mode 100644 index 0000000000..ad0a134528 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/exportAnno.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export @interface __$$ETS_ANNOTATION$$__MyAnno { + name: string = "" +} + +@__$$ETS_ANNOTATION$$__MyAnno +class A { + +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/importAnno-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/importAnno-exec-expected.pa.txt new file mode 100644 index 0000000000..8b72bbfe7c --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/importAnno-exec-expected.pa.txt @@ -0,0 +1,270 @@ +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/exportAnno&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/exportAnno&2.0.0.#~A=#A, &importAnnoPgName/exportAnno&2.0.0_1416, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1376 +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1380 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 5 + val: MyAnno +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/exportAnno&2.0.0_1416 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&importAnnoPgName/exportAnno&2.0.0.#~A=#A"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str B + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &importAnnoPgName/importAnno-exec&2.0.0.func_main_0(any a0, any a1, any a2) { + ldhole + sta v0 + defineclasswithbuffer 0x0, &importAnnoPgName/importAnno-exec&2.0.0.#~B=#B, &importAnnoPgName/importAnno-exec&2.0.0_1498, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1425 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: hello +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1434 +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1438 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&importAnnoPgName/exportAnno& +}, +{ + index: 2 + tag: 2 + val: 2 +}, +{ + index: 3 + tag: 5 + val: MyAnno +}, +{ + index: 4 + tag: 5 + val: MyAnno +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: fun +}, +{ + index: 7 + tag: 5 + val: fun +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 1 +}, +{ + index: 11 + tag: 5 + val: B +}, +{ + index: 12 + tag: 5 + val: B +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +------------------------------------ +slot &importAnnoPgName/importAnno-exec&2.0.0_1498 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: fun +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &importAnnoPgName/importAnno-exec&2.0.0.#~B>#fun +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +======> strings <====== +"&importAnnoPgName/importAnno-exec&2.0.0.#~B=#B"; "B"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/importAnno-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/importAnno-exec.ts new file mode 100644 index 0000000000..fee3523c0d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/importAnno-exec.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __$$ETS_ANNOTATION$$__MyAnno, fun } from "@normalized:N&&&importAnnoPgName/exportAnno&" + +export class B { + @__$$ETS_ANNOTATION$$__MyAnno({name: ["hello"]}) + fun() { + print("B") + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/recordnames.txt new file mode 100644 index 0000000000..a85a0366c4 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-string/recordnames.txt @@ -0,0 +1,2 @@ +importAnno-exec:&importAnnoPgName/importAnno-exec&2.0.0 +exportAnno:&importAnnoPgName/exportAnno&2.0.0 diff --git a/es2panda/test/version_control/API20/bytecode_feature/export_annotations.ts b/es2panda/test/version_control/API20/bytecode_feature/export_annotations.ts new file mode 100644 index 0000000000..1d565c0e09 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/export_annotations.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export @interface __$$ETS_ANNOTATION$$__Anno { + b: boolean = true +} + +class A { } diff --git a/es2panda/test/version_control/API20/bytecode_feature/export_annotations_runtime_below_abc_api_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/export_annotations_runtime_below_abc_api_version-expected.txt new file mode 100644 index 0000000000..13510081b9 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/export_annotations_runtime_below_abc_api_version-expected.txt @@ -0,0 +1 @@ +pandafile \ No newline at end of file diff --git a/es2panda/test/version_control/API20/bytecode_feature/export_annotations_supported_compile_asm_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/export_annotations_supported_compile_asm_version-expected.txt new file mode 100644 index 0000000000..11dd37ab8b --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/export_annotations_supported_compile_asm_version-expected.txt @@ -0,0 +1,24 @@ +slotNum = 0x0 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~A=#A, _2, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API20/bytecode_feature/export_annotations_supported_runtime_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/export_annotations_supported_runtime_version-expected.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/es2panda/test/version_control/API20/bytecode_feature/export_annotations_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/export_annotations_unsupported_compile_asm_version-expected.txt new file mode 100644 index 0000000000..005d86db57 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/export_annotations_unsupported_compile_asm_version-expected.txt @@ -0,0 +1,3 @@ +SyntaxError: Current configuration does not support using annotations. Annotations can be used in the version of API 20 or higher versions. +Solutions: > Check the compatibleSdkVersion in build-profile.json5.> If compatibleSdkVersion is set to API 20 or higher version.> If you're running es2abc in commandline without IDE, please check whether target-api-version and enable-annotations options are correctly configured. [export_annotations.ts:16:9] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/util/helpers.cpp b/es2panda/util/helpers.cpp index 4ef312d76e..95ab7745b8 100644 --- a/es2panda/util/helpers.cpp +++ b/es2panda/util/helpers.cpp @@ -966,13 +966,13 @@ bool Helpers::IsInnerAnnotationRecordName(const std::string_view &name) name == panda::abc2program::EXPECTED_PROPERTY_COUNT_RECORD_NAME; } -std::string Helpers::RemoveRecordSuffixAnnotationName(const std::string &name) +size_t Helpers::RemoveRecordSuffixAnnotationName(std::string &name) { auto pos = name.rfind(abc2program::RECORD_ANNOTATION_SEPARATOR); - if (pos == std::string::npos) { - return name; + if (pos != std::string::npos) { + name = name.substr(0, pos); } - return name.substr(0, pos); + return pos; } void Helpers::RemoveProgramsRedundantData(std::map &progsInfo, @@ -980,18 +980,33 @@ void Helpers::RemoveProgramsRedundantData(std::mapfirst; + std::string name = progInfoIter->first; auto &program = progInfoIter->second->program; + auto &recordMetaData = program.record_table.begin()->second.metadata; /** * The record name of a user-defined annotation is the annotation name concatenated with the record name of the * file where it is declared. In order to preserve the annotated record, it is necessary to remove the * concatenated annotation name from the record name before perform dependency matching. */ - if (!util::RecordNotGeneratedFromBytecode(name) && - (program.record_table.begin()->second.metadata->GetAccessFlags() & ACC_ANNOTATION) != 0 && + if (!util::RecordNotGeneratedFromBytecode(name) && (recordMetaData->GetAccessFlags() & ACC_ANNOTATION) != 0 && !IsInnerAnnotationRecordName(program.record_table.begin()->first)) { - name = RemoveRecordSuffixAnnotationName(name); + RemoveRecordSuffixAnnotationName(name); } + + /** + * Imported user-defined annotations will generate external records in the abc files. Its naming convention is + * consistent with the definition of annotations. But importing annotations supports qualified names, + * such as 'ns.Anno'. so it may need to remove suffixes multiple times to ensure that record name is found. + */ + if (!util::RecordNotGeneratedFromBytecode(name) && recordMetaData->IsForeign()) { + auto versionStart = name.rfind(util::NORMALIZED_OHMURL_SEPARATOR); + size_t pos = name.length(); + while (pos != std::string::npos && pos > versionStart && + resolvedDepsRelation.find(name) == resolvedDepsRelation.end()) { + pos = RemoveRecordSuffixAnnotationName(name); + } + } + // remove redundant sourcefiles and bytecodefile data which are not dependant in compilation if (resolvedDepsRelation.find(name) == resolvedDepsRelation.end()) { progInfoIter = progsInfo.erase(progInfoIter); diff --git a/es2panda/util/helpers.h b/es2panda/util/helpers.h index 3be95c36dd..1a4cda0c3e 100644 --- a/es2panda/util/helpers.h +++ b/es2panda/util/helpers.h @@ -183,7 +183,7 @@ public: static bool BelongingToRecords(const std::string &name, const std::unordered_set &retainRecordSet, const std::string &delimiter = std::string(DOT)); static bool IsInnerAnnotationRecordName(const std::string_view &name); - static std::string RemoveRecordSuffixAnnotationName(const std::string &name); + static size_t RemoveRecordSuffixAnnotationName(std::string &name); static void RemoveProgramsRedundantData(std::map &progsInfo, const std::map> &resolveDepsRelation); static bool IsDefaultApiVersion(int apiVersion, std::string subApiVersion); -- Gitee