diff --git a/es2panda/test/type_extractor/dts-testcases/test-type-summary-order-1-expected.txt b/es2panda/test/type_extractor/dts-testcases/test-type-summary-order-1-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..23a004528850382ebc11d145d1e958e778a7db26 --- /dev/null +++ b/es2panda/test/type_extractor/dts-testcases/test-type-summary-order-1-expected.txt @@ -0,0 +1,1381 @@ +======> literal array buffer <====== +------------------------------------ +slot _0 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 83 +}, +{ + index: 2 + tag: 0 + val: 24 +}, +{ + index: 3 + tag: 24 + val: _1 +}, +{ + index: 4 + tag: 0 + val: 24 +}, +{ + index: 5 + tag: 24 + val: _2 +}, +{ + index: 6 + tag: 0 + val: 24 +}, +{ + index: 7 + tag: 24 + val: _3 +}, +{ + index: 8 + tag: 0 + val: 24 +}, +{ + index: 9 + tag: 24 + val: _4 +}, +{ + index: 10 + tag: 0 + val: 24 +}, +{ + index: 11 + tag: 24 + val: _5 +}, +{ + index: 12 + tag: 0 + val: 24 +}, +{ + index: 13 + tag: 24 + val: _6 +}, +{ + index: 14 + tag: 0 + val: 24 +}, +{ + index: 15 + tag: 24 + val: _7 +}, +{ + index: 16 + tag: 0 + val: 24 +}, +{ + index: 17 + tag: 24 + val: _8 +}, +{ + index: 18 + tag: 0 + val: 24 +}, +{ + index: 19 + tag: 24 + val: _9 +}, +{ + index: 20 + tag: 0 + val: 24 +}, +{ + index: 21 + tag: 24 + val: _10 +}, +{ + index: 22 + tag: 0 + val: 24 +}, +{ + index: 23 + tag: 24 + val: _11 +}, +{ + index: 24 + tag: 0 + val: 24 +}, +{ + index: 25 + tag: 24 + val: _12 +}, +{ + index: 26 + tag: 0 + val: 24 +}, +{ + index: 27 + tag: 24 + val: _13 +}, +{ + index: 28 + tag: 0 + val: 24 +}, +{ + index: 29 + tag: 24 + val: _14 +}, +{ + index: 30 + tag: 0 + val: 24 +}, +{ + index: 31 + tag: 24 + val: _15 +}, +{ + index: 32 + tag: 0 + val: 24 +}, +{ + index: 33 + tag: 24 + val: _16 +}, +{ + index: 34 + tag: 0 + val: 24 +}, +{ + index: 35 + tag: 24 + val: _17 +}, +{ + index: 36 + tag: 0 + val: 24 +}, +{ + index: 37 + tag: 24 + val: _18 +}, +{ + index: 38 + tag: 0 + val: 24 +}, +{ + index: 39 + tag: 24 + val: _19 +}, +{ + index: 40 + tag: 0 + val: 24 +}, +{ + index: 41 + tag: 24 + val: _20 +}, +{ + index: 42 + tag: 0 + val: 24 +}, +{ + index: 43 + tag: 24 + val: _21 +}, +{ + index: 44 + tag: 0 + val: 24 +}, +{ + index: 45 + tag: 24 + val: _22 +}, +{ + index: 46 + tag: 0 + val: 24 +}, +{ + index: 47 + tag: 24 + val: _23 +}, +{ + index: 48 + tag: 0 + val: 24 +}, +{ + index: 49 + tag: 24 + val: _24 +}, +{ + index: 50 + tag: 0 + val: 24 +}, +{ + index: 51 + tag: 24 + val: _25 +}, +{ + index: 52 + tag: 0 + val: 24 +}, +{ + index: 53 + tag: 24 + val: _26 +}, +{ + index: 54 + tag: 0 + val: 24 +}, +{ + index: 55 + tag: 24 + val: _27 +}, +{ + index: 56 + tag: 0 + val: 24 +}, +{ + index: 57 + tag: 24 + val: _28 +}, +{ + index: 58 + tag: 0 + val: 24 +}, +{ + index: 59 + tag: 24 + val: _29 +}, +{ + index: 60 + tag: 0 + val: 24 +}, +{ + index: 61 + tag: 24 + val: _30 +}, +{ + index: 62 + tag: 0 + val: 24 +}, +{ + index: 63 + tag: 24 + val: _31 +}, +{ + index: 64 + tag: 0 + val: 24 +}, +{ + index: 65 + tag: 24 + val: _32 +}, +{ + index: 66 + tag: 0 + val: 24 +}, +{ + index: 67 + tag: 24 + val: _33 +}, +{ + index: 68 + tag: 0 + val: 24 +}, +{ + index: 69 + tag: 24 + val: _34 +}, +{ + index: 70 + tag: 0 + val: 24 +}, +{ + index: 71 + tag: 24 + val: _35 +}, +{ + index: 72 + tag: 0 + val: 24 +}, +{ + index: 73 + tag: 24 + val: _36 +}, +{ + index: 74 + tag: 0 + val: 24 +}, +{ + index: 75 + tag: 24 + val: _37 +}, +{ + index: 76 + tag: 0 + val: 24 +}, +{ + index: 77 + tag: 24 + val: _38 +}, +{ + index: 78 + tag: 0 + val: 24 +}, +{ + index: 79 + tag: 24 + val: _39 +}, +{ + index: 80 + tag: 0 + val: 24 +}, +{ + index: 81 + tag: 24 + val: _40 +}, +{ + index: 82 + tag: 0 + val: 24 +}, +{ + index: 83 + tag: 24 + val: _41 +}, +{ + index: 84 + tag: 0 + val: 24 +}, +{ + index: 85 + tag: 24 + val: _42 +}, +{ + index: 86 + tag: 0 + val: 24 +}, +{ + index: 87 + tag: 24 + val: _43 +}, +{ + index: 88 + tag: 0 + val: 24 +}, +{ + index: 89 + tag: 24 + val: _44 +}, +{ + index: 90 + tag: 0 + val: 24 +}, +{ + index: 91 + tag: 24 + val: _45 +}, +{ + index: 92 + tag: 0 + val: 24 +}, +{ + index: 93 + tag: 24 + val: _46 +}, +{ + index: 94 + tag: 0 + val: 24 +}, +{ + index: 95 + tag: 24 + val: _47 +}, +{ + index: 96 + tag: 0 + val: 24 +}, +{ + index: 97 + tag: 24 + val: _48 +}, +{ + index: 98 + tag: 0 + val: 24 +}, +{ + index: 99 + tag: 24 + val: _49 +}, +{ + index: 100 + tag: 0 + val: 24 +}, +{ + index: 101 + tag: 24 + val: _50 +}, +{ + index: 102 + tag: 0 + val: 24 +}, +{ + index: 103 + tag: 24 + val: _51 +}, +{ + index: 104 + tag: 0 + val: 24 +}, +{ + index: 105 + tag: 24 + val: _52 +}, +{ + index: 106 + tag: 0 + val: 24 +}, +{ + index: 107 + tag: 24 + val: _53 +}, +{ + index: 108 + tag: 0 + val: 24 +}, +{ + index: 109 + tag: 24 + val: _54 +}, +{ + index: 110 + tag: 0 + val: 24 +}, +{ + index: 111 + tag: 24 + val: _55 +}, +{ + index: 112 + tag: 0 + val: 24 +}, +{ + index: 113 + tag: 24 + val: _56 +}, +{ + index: 114 + tag: 0 + val: 24 +}, +{ + index: 115 + tag: 24 + val: _57 +}, +{ + index: 116 + tag: 0 + val: 24 +}, +{ + index: 117 + tag: 24 + val: _58 +}, +{ + index: 118 + tag: 0 + val: 24 +}, +{ + index: 119 + tag: 24 + val: _59 +}, +{ + index: 120 + tag: 0 + val: 24 +}, +{ + index: 121 + tag: 24 + val: _60 +}, +{ + index: 122 + tag: 0 + val: 24 +}, +{ + index: 123 + tag: 24 + val: _61 +}, +{ + index: 124 + tag: 0 + val: 24 +}, +{ + index: 125 + tag: 24 + val: _62 +}, +{ + index: 126 + tag: 0 + val: 24 +}, +{ + index: 127 + tag: 24 + val: _63 +}, +{ + index: 128 + tag: 0 + val: 24 +}, +{ + index: 129 + tag: 24 + val: _64 +}, +{ + index: 130 + tag: 0 + val: 24 +}, +{ + index: 131 + tag: 24 + val: _65 +}, +{ + index: 132 + tag: 0 + val: 24 +}, +{ + index: 133 + tag: 24 + val: _66 +}, +{ + index: 134 + tag: 0 + val: 24 +}, +{ + index: 135 + tag: 24 + val: _67 +}, +{ + index: 136 + tag: 0 + val: 24 +}, +{ + index: 137 + tag: 24 + val: _68 +}, +{ + index: 138 + tag: 0 + val: 24 +}, +{ + index: 139 + tag: 24 + val: _69 +}, +{ + index: 140 + tag: 0 + val: 24 +}, +{ + index: 141 + tag: 24 + val: _70 +}, +{ + index: 142 + tag: 0 + val: 24 +}, +{ + index: 143 + tag: 24 + val: _71 +}, +{ + index: 144 + tag: 0 + val: 24 +}, +{ + index: 145 + tag: 24 + val: _72 +}, +{ + index: 146 + tag: 0 + val: 24 +}, +{ + index: 147 + tag: 24 + val: _73 +}, +{ + index: 148 + tag: 0 + val: 24 +}, +{ + index: 149 + tag: 24 + val: _74 +}, +{ + index: 150 + tag: 0 + val: 24 +}, +{ + index: 151 + tag: 24 + val: _75 +}, +{ + index: 152 + tag: 0 + val: 24 +}, +{ + index: 153 + tag: 24 + val: _76 +}, +{ + index: 154 + tag: 0 + val: 24 +}, +{ + index: 155 + tag: 24 + val: _77 +}, +{ + index: 156 + tag: 0 + val: 24 +}, +{ + index: 157 + tag: 24 + val: _78 +}, +{ + index: 158 + tag: 0 + val: 24 +}, +{ + index: 159 + tag: 24 + val: _79 +}, +{ + index: 160 + tag: 0 + val: 24 +}, +{ + index: 161 + tag: 24 + val: _80 +}, +{ + index: 162 + tag: 0 + val: 24 +}, +{ + index: 163 + tag: 24 + val: _81 +}, +{ + index: 164 + tag: 0 + val: 24 +}, +{ + index: 165 + tag: 24 + val: _82 +}, +{ + index: 166 + tag: 0 + val: 24 +}, +{ + index: 167 + tag: 24 + val: _83 +}, +{ + index: 168 + tag: 0 + val: 2 +}, +{ + index: 169 + tag: 2 + val: 0 +}, +------------------------------------ +slot _1 +------------------------------------ +slot _10 +------------------------------------ +slot _11 +------------------------------------ +slot _12 +------------------------------------ +slot _13 +------------------------------------ +slot _14 +------------------------------------ +slot _15 +------------------------------------ +slot _16 +------------------------------------ +slot _17 +------------------------------------ +slot _18 +------------------------------------ +slot _19 +------------------------------------ +slot _2 +------------------------------------ +slot _20 +------------------------------------ +slot _21 +------------------------------------ +slot _22 +------------------------------------ +slot _23 +------------------------------------ +slot _24 +------------------------------------ +slot _25 +------------------------------------ +slot _26 +------------------------------------ +slot _27 +------------------------------------ +slot _28 +------------------------------------ +slot _29 +------------------------------------ +slot _3 +------------------------------------ +slot _30 +------------------------------------ +slot _31 +------------------------------------ +slot _32 +------------------------------------ +slot _33 +------------------------------------ +slot _34 +------------------------------------ +slot _35 +------------------------------------ +slot _36 +------------------------------------ +slot _37 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 1 +}, +{ + index: 2 + tag: 0 + val: 2 +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 0 + val: 25 +}, +{ + index: 5 + tag: 25 + val: 0 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +{ + index: 8 + tag: 0 + val: 2 +}, +{ + index: 9 + tag: 2 + val: 1 +}, +{ + index: 10 + tag: 0 + val: 5 +}, +{ + index: 11 + tag: 5 + val: byteLength +}, +{ + index: 12 + tag: 0 + val: 25 +}, +{ + index: 13 + tag: 25 + val: 1 +}, +{ + index: 14 + tag: 0 + val: 2 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +{ + index: 16 + tag: 0 + val: 2 +}, +{ + index: 17 + tag: 2 + val: 0 +}, +{ + index: 18 + tag: 0 + val: 2 +}, +{ + index: 19 + tag: 2 + val: 2 +}, +{ + index: 20 + tag: 0 + val: 5 +}, +{ + index: 21 + tag: 5 + val: constructor +}, +{ + index: 22 + tag: 0 + val: 24 +}, +{ + index: 23 + tag: 24 + val: _81 +}, +{ + index: 24 + tag: 0 + val: 5 +}, +{ + index: 25 + tag: 5 + val: slice +}, +{ + index: 26 + tag: 0 + val: 24 +}, +{ + index: 27 + tag: 24 + val: _83 +}, +{ + index: 28 + tag: 0 + val: 2 +}, +{ + index: 29 + tag: 2 + val: 0 +}, +{ + index: 30 + tag: 0 + val: 2 +}, +{ + index: 31 + tag: 2 + val: 0 +}, +------------------------------------ +slot _38 +------------------------------------ +slot _39 +------------------------------------ +slot _4 +------------------------------------ +slot _40 +------------------------------------ +slot _41 +------------------------------------ +slot _42 +------------------------------------ +slot _43 +------------------------------------ +slot _44 +------------------------------------ +slot _45 +------------------------------------ +slot _46 +------------------------------------ +slot _47 +------------------------------------ +slot _48 +------------------------------------ +slot _49 +------------------------------------ +slot _5 +------------------------------------ +slot _50 +------------------------------------ +slot _51 +------------------------------------ +slot _52 +------------------------------------ +slot _53 +------------------------------------ +slot _54 +------------------------------------ +slot _55 +------------------------------------ +slot _56 +------------------------------------ +slot _57 +------------------------------------ +slot _58 +------------------------------------ +slot _59 +------------------------------------ +slot _6 +------------------------------------ +slot _60 +------------------------------------ +slot _61 +------------------------------------ +slot _62 +------------------------------------ +slot _63 +------------------------------------ +slot _64 +------------------------------------ +slot _65 +------------------------------------ +slot _66 +------------------------------------ +slot _67 +------------------------------------ +slot _68 +------------------------------------ +slot _69 +------------------------------------ +slot _7 +------------------------------------ +slot _70 +------------------------------------ +slot _71 +------------------------------------ +slot _72 +------------------------------------ +slot _73 +------------------------------------ +slot _74 +------------------------------------ +slot _75 +------------------------------------ +slot _76 +------------------------------------ +slot _77 +------------------------------------ +slot _78 +------------------------------------ +slot _79 +------------------------------------ +slot _8 +------------------------------------ +slot _80 +------------------------------------ +slot _81 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 3 +}, +{ + index: 2 + tag: 0 + val: 2 +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 0 + val: 5 +}, +{ + index: 5 + tag: 5 + val: constructor +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +{ + index: 8 + tag: 0 + val: 2 +}, +{ + index: 9 + tag: 2 + val: 1 +}, +{ + index: 10 + tag: 0 + val: 25 +}, +{ + index: 11 + tag: 25 + val: 1 +}, +{ + index: 12 + tag: 0 + val: 24 +}, +{ + index: 13 + tag: 24 + val: _82 +}, +------------------------------------ +slot _82 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 2 +}, +{ + index: 2 + tag: 0 + val: 24 +}, +{ + index: 3 + tag: 24 + val: _37 +}, +------------------------------------ +slot _83 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 3 +}, +{ + index: 2 + tag: 0 + val: 2 +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 0 + val: 5 +}, +{ + index: 5 + tag: 5 + val: slice +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +{ + index: 8 + tag: 0 + val: 2 +}, +{ + index: 9 + tag: 2 + val: 2 +}, +{ + index: 10 + tag: 0 + val: 25 +}, +{ + index: 11 + tag: 25 + val: 1 +}, +{ + index: 12 + tag: 0 + val: 25 +}, +{ + index: 13 + tag: 25 + val: 1 +}, +{ + index: 14 + tag: 0 + val: 24 +}, +{ + index: 15 + tag: 24 + val: _82 +}, +------------------------------------ +slot _84 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 0 +}, +{ + index: 5 + tag: 2 + val: 0 +}, +------------------------------------ +slot _9 diff --git a/es2panda/test/type_extractor/dts-testcases/test-type-summary-order-1.d.ts b/es2panda/test/type_extractor/dts-testcases/test-type-summary-order-1.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..696952097dfd13eaaa6dc936d5a7184f6ca76e09 --- /dev/null +++ b/es2panda/test/type_extractor/dts-testcases/test-type-summary-order-1.d.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 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. + */ + + +declare class SharedArrayBuffer extends Object { + constructor(byteLength: number): SharedArrayBuffer; + byteLength: number; + slice(begin: number, end?: number): SharedArrayBuffer; +} diff --git a/es2panda/typescript/extractor/typeRecorder.cpp b/es2panda/typescript/extractor/typeRecorder.cpp index 4b071d3fa8c6a83078e3af327a3877fc09b1dc1d..a801323fe72bc96e814ff6c378363dc7d220168f 100644 --- a/es2panda/typescript/extractor/typeRecorder.cpp +++ b/es2panda/typescript/extractor/typeRecorder.cpp @@ -109,7 +109,9 @@ const std::set &TypeRecorder::GetUserType() const void TypeRecorder::AddUserType(int64_t index) { - userType_.insert(index); + if (index > TypeRecorder::USERTYPEINDEXHEAD) { + userType_.insert(index); + } } int64_t TypeRecorder::GetTypeSummaryIndex() const diff --git a/es2panda/typescript/extractor/typeSystem.h b/es2panda/typescript/extractor/typeSystem.h index d3c1dfda5372e36f95c6b4edd62a0e52bfb0838c..0aff14ee20300be5f798821d9ca5d962b0b77e18 100644 --- a/es2panda/typescript/extractor/typeSystem.h +++ b/es2panda/typescript/extractor/typeSystem.h @@ -361,6 +361,10 @@ public: if (extractor_->GetTypeDtsExtractor()) { buffer_->Add(recorder_->Allocator()->New(userType.size() + TypeRecorder::USERTYPEINDEXHEAD - BuiltinType::BT_HEAD)); + for (int builtinTypeOrder = BuiltinType::BT_HEAD; builtinTypeOrder < TypeRecorder::USERTYPEINDEXHEAD; + builtinTypeOrder++) { + FillTypeIndexLiteralBuffer(builtinTypeOrder + 1); + } } else { buffer_->Add(recorder_->Allocator()->New(userType.size())); }