WasmParser.js (176639B)
1 "use strict"; 2 /* Copyright 2016 Mozilla Foundation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 var __extends = (this && this.__extends) || (function () { 17 var extendStatics = function (d, b) { 18 extendStatics = Object.setPrototypeOf || 19 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 20 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 21 return extendStatics(d, b); 22 }; 23 return function (d, b) { 24 if (typeof b !== "function" && b !== null) 25 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 26 extendStatics(d, b); 27 function __() { this.constructor = d; } 28 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 29 }; 30 })(); 31 Object.defineProperty(exports, "__esModule", { value: true }); 32 exports.bytesToString = exports.BinaryReader = exports.Int64 = exports.TagAttribute = exports.ElementMode = exports.DataMode = exports.BinaryReaderState = exports.NameType = exports.LinkingType = exports.RelocType = exports.CatchHandler = exports.CatchHandlerKind = exports.RefType = exports.Type = exports.FuncDef = exports.FieldDef = exports.TypeKind = exports.ExternalKind = exports.OperatorCodeNames = exports.OperatorCode = exports.SectionCode = void 0; 33 // See https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md 34 var WASM_MAGIC_NUMBER = 0x6d736100; 35 var WASM_SUPPORTED_EXPERIMENTAL_VERSION = 0xd; 36 var WASM_SUPPORTED_VERSION = 0x1; 37 var SectionCode; 38 (function (SectionCode) { 39 SectionCode[SectionCode["Unknown"] = -1] = "Unknown"; 40 SectionCode[SectionCode["Custom"] = 0] = "Custom"; 41 SectionCode[SectionCode["Type"] = 1] = "Type"; 42 SectionCode[SectionCode["Import"] = 2] = "Import"; 43 SectionCode[SectionCode["Function"] = 3] = "Function"; 44 SectionCode[SectionCode["Table"] = 4] = "Table"; 45 SectionCode[SectionCode["Memory"] = 5] = "Memory"; 46 SectionCode[SectionCode["Global"] = 6] = "Global"; 47 SectionCode[SectionCode["Export"] = 7] = "Export"; 48 SectionCode[SectionCode["Start"] = 8] = "Start"; 49 SectionCode[SectionCode["Element"] = 9] = "Element"; 50 SectionCode[SectionCode["Code"] = 10] = "Code"; 51 SectionCode[SectionCode["Data"] = 11] = "Data"; 52 SectionCode[SectionCode["DataCount"] = 12] = "DataCount"; 53 SectionCode[SectionCode["Tag"] = 13] = "Tag"; 54 })(SectionCode = exports.SectionCode || (exports.SectionCode = {})); 55 var OperatorCode; 56 (function (OperatorCode) { 57 OperatorCode[OperatorCode["unreachable"] = 0] = "unreachable"; 58 OperatorCode[OperatorCode["nop"] = 1] = "nop"; 59 OperatorCode[OperatorCode["block"] = 2] = "block"; 60 OperatorCode[OperatorCode["loop"] = 3] = "loop"; 61 OperatorCode[OperatorCode["if"] = 4] = "if"; 62 OperatorCode[OperatorCode["else"] = 5] = "else"; 63 OperatorCode[OperatorCode["try"] = 6] = "try"; 64 OperatorCode[OperatorCode["catch"] = 7] = "catch"; 65 OperatorCode[OperatorCode["throw"] = 8] = "throw"; 66 OperatorCode[OperatorCode["rethrow"] = 9] = "rethrow"; 67 OperatorCode[OperatorCode["throw_ref"] = 10] = "throw_ref"; 68 OperatorCode[OperatorCode["end"] = 11] = "end"; 69 OperatorCode[OperatorCode["br"] = 12] = "br"; 70 OperatorCode[OperatorCode["br_if"] = 13] = "br_if"; 71 OperatorCode[OperatorCode["br_table"] = 14] = "br_table"; 72 OperatorCode[OperatorCode["return"] = 15] = "return"; 73 OperatorCode[OperatorCode["call"] = 16] = "call"; 74 OperatorCode[OperatorCode["call_indirect"] = 17] = "call_indirect"; 75 OperatorCode[OperatorCode["return_call"] = 18] = "return_call"; 76 OperatorCode[OperatorCode["return_call_indirect"] = 19] = "return_call_indirect"; 77 OperatorCode[OperatorCode["call_ref"] = 20] = "call_ref"; 78 OperatorCode[OperatorCode["return_call_ref"] = 21] = "return_call_ref"; 79 OperatorCode[OperatorCode["let"] = 23] = "let"; 80 OperatorCode[OperatorCode["delegate"] = 24] = "delegate"; 81 OperatorCode[OperatorCode["catch_all"] = 25] = "catch_all"; 82 OperatorCode[OperatorCode["drop"] = 26] = "drop"; 83 OperatorCode[OperatorCode["select"] = 27] = "select"; 84 OperatorCode[OperatorCode["select_with_type"] = 28] = "select_with_type"; 85 OperatorCode[OperatorCode["try_table"] = 31] = "try_table"; 86 OperatorCode[OperatorCode["local_get"] = 32] = "local_get"; 87 OperatorCode[OperatorCode["local_set"] = 33] = "local_set"; 88 OperatorCode[OperatorCode["local_tee"] = 34] = "local_tee"; 89 OperatorCode[OperatorCode["global_get"] = 35] = "global_get"; 90 OperatorCode[OperatorCode["global_set"] = 36] = "global_set"; 91 OperatorCode[OperatorCode["i32_load"] = 40] = "i32_load"; 92 OperatorCode[OperatorCode["i64_load"] = 41] = "i64_load"; 93 OperatorCode[OperatorCode["f32_load"] = 42] = "f32_load"; 94 OperatorCode[OperatorCode["f64_load"] = 43] = "f64_load"; 95 OperatorCode[OperatorCode["i32_load8_s"] = 44] = "i32_load8_s"; 96 OperatorCode[OperatorCode["i32_load8_u"] = 45] = "i32_load8_u"; 97 OperatorCode[OperatorCode["i32_load16_s"] = 46] = "i32_load16_s"; 98 OperatorCode[OperatorCode["i32_load16_u"] = 47] = "i32_load16_u"; 99 OperatorCode[OperatorCode["i64_load8_s"] = 48] = "i64_load8_s"; 100 OperatorCode[OperatorCode["i64_load8_u"] = 49] = "i64_load8_u"; 101 OperatorCode[OperatorCode["i64_load16_s"] = 50] = "i64_load16_s"; 102 OperatorCode[OperatorCode["i64_load16_u"] = 51] = "i64_load16_u"; 103 OperatorCode[OperatorCode["i64_load32_s"] = 52] = "i64_load32_s"; 104 OperatorCode[OperatorCode["i64_load32_u"] = 53] = "i64_load32_u"; 105 OperatorCode[OperatorCode["i32_store"] = 54] = "i32_store"; 106 OperatorCode[OperatorCode["i64_store"] = 55] = "i64_store"; 107 OperatorCode[OperatorCode["f32_store"] = 56] = "f32_store"; 108 OperatorCode[OperatorCode["f64_store"] = 57] = "f64_store"; 109 OperatorCode[OperatorCode["i32_store8"] = 58] = "i32_store8"; 110 OperatorCode[OperatorCode["i32_store16"] = 59] = "i32_store16"; 111 OperatorCode[OperatorCode["i64_store8"] = 60] = "i64_store8"; 112 OperatorCode[OperatorCode["i64_store16"] = 61] = "i64_store16"; 113 OperatorCode[OperatorCode["i64_store32"] = 62] = "i64_store32"; 114 OperatorCode[OperatorCode["memory_size"] = 63] = "memory_size"; 115 OperatorCode[OperatorCode["memory_grow"] = 64] = "memory_grow"; 116 OperatorCode[OperatorCode["i32_const"] = 65] = "i32_const"; 117 OperatorCode[OperatorCode["i64_const"] = 66] = "i64_const"; 118 OperatorCode[OperatorCode["f32_const"] = 67] = "f32_const"; 119 OperatorCode[OperatorCode["f64_const"] = 68] = "f64_const"; 120 OperatorCode[OperatorCode["i32_eqz"] = 69] = "i32_eqz"; 121 OperatorCode[OperatorCode["i32_eq"] = 70] = "i32_eq"; 122 OperatorCode[OperatorCode["i32_ne"] = 71] = "i32_ne"; 123 OperatorCode[OperatorCode["i32_lt_s"] = 72] = "i32_lt_s"; 124 OperatorCode[OperatorCode["i32_lt_u"] = 73] = "i32_lt_u"; 125 OperatorCode[OperatorCode["i32_gt_s"] = 74] = "i32_gt_s"; 126 OperatorCode[OperatorCode["i32_gt_u"] = 75] = "i32_gt_u"; 127 OperatorCode[OperatorCode["i32_le_s"] = 76] = "i32_le_s"; 128 OperatorCode[OperatorCode["i32_le_u"] = 77] = "i32_le_u"; 129 OperatorCode[OperatorCode["i32_ge_s"] = 78] = "i32_ge_s"; 130 OperatorCode[OperatorCode["i32_ge_u"] = 79] = "i32_ge_u"; 131 OperatorCode[OperatorCode["i64_eqz"] = 80] = "i64_eqz"; 132 OperatorCode[OperatorCode["i64_eq"] = 81] = "i64_eq"; 133 OperatorCode[OperatorCode["i64_ne"] = 82] = "i64_ne"; 134 OperatorCode[OperatorCode["i64_lt_s"] = 83] = "i64_lt_s"; 135 OperatorCode[OperatorCode["i64_lt_u"] = 84] = "i64_lt_u"; 136 OperatorCode[OperatorCode["i64_gt_s"] = 85] = "i64_gt_s"; 137 OperatorCode[OperatorCode["i64_gt_u"] = 86] = "i64_gt_u"; 138 OperatorCode[OperatorCode["i64_le_s"] = 87] = "i64_le_s"; 139 OperatorCode[OperatorCode["i64_le_u"] = 88] = "i64_le_u"; 140 OperatorCode[OperatorCode["i64_ge_s"] = 89] = "i64_ge_s"; 141 OperatorCode[OperatorCode["i64_ge_u"] = 90] = "i64_ge_u"; 142 OperatorCode[OperatorCode["f32_eq"] = 91] = "f32_eq"; 143 OperatorCode[OperatorCode["f32_ne"] = 92] = "f32_ne"; 144 OperatorCode[OperatorCode["f32_lt"] = 93] = "f32_lt"; 145 OperatorCode[OperatorCode["f32_gt"] = 94] = "f32_gt"; 146 OperatorCode[OperatorCode["f32_le"] = 95] = "f32_le"; 147 OperatorCode[OperatorCode["f32_ge"] = 96] = "f32_ge"; 148 OperatorCode[OperatorCode["f64_eq"] = 97] = "f64_eq"; 149 OperatorCode[OperatorCode["f64_ne"] = 98] = "f64_ne"; 150 OperatorCode[OperatorCode["f64_lt"] = 99] = "f64_lt"; 151 OperatorCode[OperatorCode["f64_gt"] = 100] = "f64_gt"; 152 OperatorCode[OperatorCode["f64_le"] = 101] = "f64_le"; 153 OperatorCode[OperatorCode["f64_ge"] = 102] = "f64_ge"; 154 OperatorCode[OperatorCode["i32_clz"] = 103] = "i32_clz"; 155 OperatorCode[OperatorCode["i32_ctz"] = 104] = "i32_ctz"; 156 OperatorCode[OperatorCode["i32_popcnt"] = 105] = "i32_popcnt"; 157 OperatorCode[OperatorCode["i32_add"] = 106] = "i32_add"; 158 OperatorCode[OperatorCode["i32_sub"] = 107] = "i32_sub"; 159 OperatorCode[OperatorCode["i32_mul"] = 108] = "i32_mul"; 160 OperatorCode[OperatorCode["i32_div_s"] = 109] = "i32_div_s"; 161 OperatorCode[OperatorCode["i32_div_u"] = 110] = "i32_div_u"; 162 OperatorCode[OperatorCode["i32_rem_s"] = 111] = "i32_rem_s"; 163 OperatorCode[OperatorCode["i32_rem_u"] = 112] = "i32_rem_u"; 164 OperatorCode[OperatorCode["i32_and"] = 113] = "i32_and"; 165 OperatorCode[OperatorCode["i32_or"] = 114] = "i32_or"; 166 OperatorCode[OperatorCode["i32_xor"] = 115] = "i32_xor"; 167 OperatorCode[OperatorCode["i32_shl"] = 116] = "i32_shl"; 168 OperatorCode[OperatorCode["i32_shr_s"] = 117] = "i32_shr_s"; 169 OperatorCode[OperatorCode["i32_shr_u"] = 118] = "i32_shr_u"; 170 OperatorCode[OperatorCode["i32_rotl"] = 119] = "i32_rotl"; 171 OperatorCode[OperatorCode["i32_rotr"] = 120] = "i32_rotr"; 172 OperatorCode[OperatorCode["i64_clz"] = 121] = "i64_clz"; 173 OperatorCode[OperatorCode["i64_ctz"] = 122] = "i64_ctz"; 174 OperatorCode[OperatorCode["i64_popcnt"] = 123] = "i64_popcnt"; 175 OperatorCode[OperatorCode["i64_add"] = 124] = "i64_add"; 176 OperatorCode[OperatorCode["i64_sub"] = 125] = "i64_sub"; 177 OperatorCode[OperatorCode["i64_mul"] = 126] = "i64_mul"; 178 OperatorCode[OperatorCode["i64_div_s"] = 127] = "i64_div_s"; 179 OperatorCode[OperatorCode["i64_div_u"] = 128] = "i64_div_u"; 180 OperatorCode[OperatorCode["i64_rem_s"] = 129] = "i64_rem_s"; 181 OperatorCode[OperatorCode["i64_rem_u"] = 130] = "i64_rem_u"; 182 OperatorCode[OperatorCode["i64_and"] = 131] = "i64_and"; 183 OperatorCode[OperatorCode["i64_or"] = 132] = "i64_or"; 184 OperatorCode[OperatorCode["i64_xor"] = 133] = "i64_xor"; 185 OperatorCode[OperatorCode["i64_shl"] = 134] = "i64_shl"; 186 OperatorCode[OperatorCode["i64_shr_s"] = 135] = "i64_shr_s"; 187 OperatorCode[OperatorCode["i64_shr_u"] = 136] = "i64_shr_u"; 188 OperatorCode[OperatorCode["i64_rotl"] = 137] = "i64_rotl"; 189 OperatorCode[OperatorCode["i64_rotr"] = 138] = "i64_rotr"; 190 OperatorCode[OperatorCode["f32_abs"] = 139] = "f32_abs"; 191 OperatorCode[OperatorCode["f32_neg"] = 140] = "f32_neg"; 192 OperatorCode[OperatorCode["f32_ceil"] = 141] = "f32_ceil"; 193 OperatorCode[OperatorCode["f32_floor"] = 142] = "f32_floor"; 194 OperatorCode[OperatorCode["f32_trunc"] = 143] = "f32_trunc"; 195 OperatorCode[OperatorCode["f32_nearest"] = 144] = "f32_nearest"; 196 OperatorCode[OperatorCode["f32_sqrt"] = 145] = "f32_sqrt"; 197 OperatorCode[OperatorCode["f32_add"] = 146] = "f32_add"; 198 OperatorCode[OperatorCode["f32_sub"] = 147] = "f32_sub"; 199 OperatorCode[OperatorCode["f32_mul"] = 148] = "f32_mul"; 200 OperatorCode[OperatorCode["f32_div"] = 149] = "f32_div"; 201 OperatorCode[OperatorCode["f32_min"] = 150] = "f32_min"; 202 OperatorCode[OperatorCode["f32_max"] = 151] = "f32_max"; 203 OperatorCode[OperatorCode["f32_copysign"] = 152] = "f32_copysign"; 204 OperatorCode[OperatorCode["f64_abs"] = 153] = "f64_abs"; 205 OperatorCode[OperatorCode["f64_neg"] = 154] = "f64_neg"; 206 OperatorCode[OperatorCode["f64_ceil"] = 155] = "f64_ceil"; 207 OperatorCode[OperatorCode["f64_floor"] = 156] = "f64_floor"; 208 OperatorCode[OperatorCode["f64_trunc"] = 157] = "f64_trunc"; 209 OperatorCode[OperatorCode["f64_nearest"] = 158] = "f64_nearest"; 210 OperatorCode[OperatorCode["f64_sqrt"] = 159] = "f64_sqrt"; 211 OperatorCode[OperatorCode["f64_add"] = 160] = "f64_add"; 212 OperatorCode[OperatorCode["f64_sub"] = 161] = "f64_sub"; 213 OperatorCode[OperatorCode["f64_mul"] = 162] = "f64_mul"; 214 OperatorCode[OperatorCode["f64_div"] = 163] = "f64_div"; 215 OperatorCode[OperatorCode["f64_min"] = 164] = "f64_min"; 216 OperatorCode[OperatorCode["f64_max"] = 165] = "f64_max"; 217 OperatorCode[OperatorCode["f64_copysign"] = 166] = "f64_copysign"; 218 OperatorCode[OperatorCode["i32_wrap_i64"] = 167] = "i32_wrap_i64"; 219 OperatorCode[OperatorCode["i32_trunc_f32_s"] = 168] = "i32_trunc_f32_s"; 220 OperatorCode[OperatorCode["i32_trunc_f32_u"] = 169] = "i32_trunc_f32_u"; 221 OperatorCode[OperatorCode["i32_trunc_f64_s"] = 170] = "i32_trunc_f64_s"; 222 OperatorCode[OperatorCode["i32_trunc_f64_u"] = 171] = "i32_trunc_f64_u"; 223 OperatorCode[OperatorCode["i64_extend_i32_s"] = 172] = "i64_extend_i32_s"; 224 OperatorCode[OperatorCode["i64_extend_i32_u"] = 173] = "i64_extend_i32_u"; 225 OperatorCode[OperatorCode["i64_trunc_f32_s"] = 174] = "i64_trunc_f32_s"; 226 OperatorCode[OperatorCode["i64_trunc_f32_u"] = 175] = "i64_trunc_f32_u"; 227 OperatorCode[OperatorCode["i64_trunc_f64_s"] = 176] = "i64_trunc_f64_s"; 228 OperatorCode[OperatorCode["i64_trunc_f64_u"] = 177] = "i64_trunc_f64_u"; 229 OperatorCode[OperatorCode["f32_convert_i32_s"] = 178] = "f32_convert_i32_s"; 230 OperatorCode[OperatorCode["f32_convert_i32_u"] = 179] = "f32_convert_i32_u"; 231 OperatorCode[OperatorCode["f32_convert_i64_s"] = 180] = "f32_convert_i64_s"; 232 OperatorCode[OperatorCode["f32_convert_i64_u"] = 181] = "f32_convert_i64_u"; 233 OperatorCode[OperatorCode["f32_demote_f64"] = 182] = "f32_demote_f64"; 234 OperatorCode[OperatorCode["f64_convert_i32_s"] = 183] = "f64_convert_i32_s"; 235 OperatorCode[OperatorCode["f64_convert_i32_u"] = 184] = "f64_convert_i32_u"; 236 OperatorCode[OperatorCode["f64_convert_i64_s"] = 185] = "f64_convert_i64_s"; 237 OperatorCode[OperatorCode["f64_convert_i64_u"] = 186] = "f64_convert_i64_u"; 238 OperatorCode[OperatorCode["f64_promote_f32"] = 187] = "f64_promote_f32"; 239 OperatorCode[OperatorCode["i32_reinterpret_f32"] = 188] = "i32_reinterpret_f32"; 240 OperatorCode[OperatorCode["i64_reinterpret_f64"] = 189] = "i64_reinterpret_f64"; 241 OperatorCode[OperatorCode["f32_reinterpret_i32"] = 190] = "f32_reinterpret_i32"; 242 OperatorCode[OperatorCode["f64_reinterpret_i64"] = 191] = "f64_reinterpret_i64"; 243 OperatorCode[OperatorCode["i32_extend8_s"] = 192] = "i32_extend8_s"; 244 OperatorCode[OperatorCode["i32_extend16_s"] = 193] = "i32_extend16_s"; 245 OperatorCode[OperatorCode["i64_extend8_s"] = 194] = "i64_extend8_s"; 246 OperatorCode[OperatorCode["i64_extend16_s"] = 195] = "i64_extend16_s"; 247 OperatorCode[OperatorCode["i64_extend32_s"] = 196] = "i64_extend32_s"; 248 OperatorCode[OperatorCode["prefix_0xfb"] = 251] = "prefix_0xfb"; 249 OperatorCode[OperatorCode["prefix_0xfc"] = 252] = "prefix_0xfc"; 250 OperatorCode[OperatorCode["prefix_0xfd"] = 253] = "prefix_0xfd"; 251 OperatorCode[OperatorCode["prefix_0xfe"] = 254] = "prefix_0xfe"; 252 OperatorCode[OperatorCode["i32_trunc_sat_f32_s"] = 64512] = "i32_trunc_sat_f32_s"; 253 OperatorCode[OperatorCode["i32_trunc_sat_f32_u"] = 64513] = "i32_trunc_sat_f32_u"; 254 OperatorCode[OperatorCode["i32_trunc_sat_f64_s"] = 64514] = "i32_trunc_sat_f64_s"; 255 OperatorCode[OperatorCode["i32_trunc_sat_f64_u"] = 64515] = "i32_trunc_sat_f64_u"; 256 OperatorCode[OperatorCode["i64_trunc_sat_f32_s"] = 64516] = "i64_trunc_sat_f32_s"; 257 OperatorCode[OperatorCode["i64_trunc_sat_f32_u"] = 64517] = "i64_trunc_sat_f32_u"; 258 OperatorCode[OperatorCode["i64_trunc_sat_f64_s"] = 64518] = "i64_trunc_sat_f64_s"; 259 OperatorCode[OperatorCode["i64_trunc_sat_f64_u"] = 64519] = "i64_trunc_sat_f64_u"; 260 OperatorCode[OperatorCode["memory_init"] = 64520] = "memory_init"; 261 OperatorCode[OperatorCode["data_drop"] = 64521] = "data_drop"; 262 OperatorCode[OperatorCode["memory_copy"] = 64522] = "memory_copy"; 263 OperatorCode[OperatorCode["memory_fill"] = 64523] = "memory_fill"; 264 OperatorCode[OperatorCode["table_init"] = 64524] = "table_init"; 265 OperatorCode[OperatorCode["elem_drop"] = 64525] = "elem_drop"; 266 OperatorCode[OperatorCode["table_copy"] = 64526] = "table_copy"; 267 OperatorCode[OperatorCode["table_grow"] = 64527] = "table_grow"; 268 OperatorCode[OperatorCode["table_size"] = 64528] = "table_size"; 269 OperatorCode[OperatorCode["table_fill"] = 64529] = "table_fill"; 270 OperatorCode[OperatorCode["table_get"] = 37] = "table_get"; 271 OperatorCode[OperatorCode["table_set"] = 38] = "table_set"; 272 OperatorCode[OperatorCode["ref_null"] = 208] = "ref_null"; 273 OperatorCode[OperatorCode["ref_is_null"] = 209] = "ref_is_null"; 274 OperatorCode[OperatorCode["ref_func"] = 210] = "ref_func"; 275 OperatorCode[OperatorCode["ref_eq"] = 211] = "ref_eq"; 276 OperatorCode[OperatorCode["ref_as_non_null"] = 212] = "ref_as_non_null"; 277 OperatorCode[OperatorCode["br_on_null"] = 213] = "br_on_null"; 278 OperatorCode[OperatorCode["br_on_non_null"] = 214] = "br_on_non_null"; 279 OperatorCode[OperatorCode["memory_atomic_notify"] = 65024] = "memory_atomic_notify"; 280 OperatorCode[OperatorCode["memory_atomic_wait32"] = 65025] = "memory_atomic_wait32"; 281 OperatorCode[OperatorCode["memory_atomic_wait64"] = 65026] = "memory_atomic_wait64"; 282 OperatorCode[OperatorCode["atomic_fence"] = 65027] = "atomic_fence"; 283 OperatorCode[OperatorCode["i32_atomic_load"] = 65040] = "i32_atomic_load"; 284 OperatorCode[OperatorCode["i64_atomic_load"] = 65041] = "i64_atomic_load"; 285 OperatorCode[OperatorCode["i32_atomic_load8_u"] = 65042] = "i32_atomic_load8_u"; 286 OperatorCode[OperatorCode["i32_atomic_load16_u"] = 65043] = "i32_atomic_load16_u"; 287 OperatorCode[OperatorCode["i64_atomic_load8_u"] = 65044] = "i64_atomic_load8_u"; 288 OperatorCode[OperatorCode["i64_atomic_load16_u"] = 65045] = "i64_atomic_load16_u"; 289 OperatorCode[OperatorCode["i64_atomic_load32_u"] = 65046] = "i64_atomic_load32_u"; 290 OperatorCode[OperatorCode["i32_atomic_store"] = 65047] = "i32_atomic_store"; 291 OperatorCode[OperatorCode["i64_atomic_store"] = 65048] = "i64_atomic_store"; 292 OperatorCode[OperatorCode["i32_atomic_store8"] = 65049] = "i32_atomic_store8"; 293 OperatorCode[OperatorCode["i32_atomic_store16"] = 65050] = "i32_atomic_store16"; 294 OperatorCode[OperatorCode["i64_atomic_store8"] = 65051] = "i64_atomic_store8"; 295 OperatorCode[OperatorCode["i64_atomic_store16"] = 65052] = "i64_atomic_store16"; 296 OperatorCode[OperatorCode["i64_atomic_store32"] = 65053] = "i64_atomic_store32"; 297 OperatorCode[OperatorCode["i32_atomic_rmw_add"] = 65054] = "i32_atomic_rmw_add"; 298 OperatorCode[OperatorCode["i64_atomic_rmw_add"] = 65055] = "i64_atomic_rmw_add"; 299 OperatorCode[OperatorCode["i32_atomic_rmw8_add_u"] = 65056] = "i32_atomic_rmw8_add_u"; 300 OperatorCode[OperatorCode["i32_atomic_rmw16_add_u"] = 65057] = "i32_atomic_rmw16_add_u"; 301 OperatorCode[OperatorCode["i64_atomic_rmw8_add_u"] = 65058] = "i64_atomic_rmw8_add_u"; 302 OperatorCode[OperatorCode["i64_atomic_rmw16_add_u"] = 65059] = "i64_atomic_rmw16_add_u"; 303 OperatorCode[OperatorCode["i64_atomic_rmw32_add_u"] = 65060] = "i64_atomic_rmw32_add_u"; 304 OperatorCode[OperatorCode["i32_atomic_rmw_sub"] = 65061] = "i32_atomic_rmw_sub"; 305 OperatorCode[OperatorCode["i64_atomic_rmw_sub"] = 65062] = "i64_atomic_rmw_sub"; 306 OperatorCode[OperatorCode["i32_atomic_rmw8_sub_u"] = 65063] = "i32_atomic_rmw8_sub_u"; 307 OperatorCode[OperatorCode["i32_atomic_rmw16_sub_u"] = 65064] = "i32_atomic_rmw16_sub_u"; 308 OperatorCode[OperatorCode["i64_atomic_rmw8_sub_u"] = 65065] = "i64_atomic_rmw8_sub_u"; 309 OperatorCode[OperatorCode["i64_atomic_rmw16_sub_u"] = 65066] = "i64_atomic_rmw16_sub_u"; 310 OperatorCode[OperatorCode["i64_atomic_rmw32_sub_u"] = 65067] = "i64_atomic_rmw32_sub_u"; 311 OperatorCode[OperatorCode["i32_atomic_rmw_and"] = 65068] = "i32_atomic_rmw_and"; 312 OperatorCode[OperatorCode["i64_atomic_rmw_and"] = 65069] = "i64_atomic_rmw_and"; 313 OperatorCode[OperatorCode["i32_atomic_rmw8_and_u"] = 65070] = "i32_atomic_rmw8_and_u"; 314 OperatorCode[OperatorCode["i32_atomic_rmw16_and_u"] = 65071] = "i32_atomic_rmw16_and_u"; 315 OperatorCode[OperatorCode["i64_atomic_rmw8_and_u"] = 65072] = "i64_atomic_rmw8_and_u"; 316 OperatorCode[OperatorCode["i64_atomic_rmw16_and_u"] = 65073] = "i64_atomic_rmw16_and_u"; 317 OperatorCode[OperatorCode["i64_atomic_rmw32_and_u"] = 65074] = "i64_atomic_rmw32_and_u"; 318 OperatorCode[OperatorCode["i32_atomic_rmw_or"] = 65075] = "i32_atomic_rmw_or"; 319 OperatorCode[OperatorCode["i64_atomic_rmw_or"] = 65076] = "i64_atomic_rmw_or"; 320 OperatorCode[OperatorCode["i32_atomic_rmw8_or_u"] = 65077] = "i32_atomic_rmw8_or_u"; 321 OperatorCode[OperatorCode["i32_atomic_rmw16_or_u"] = 65078] = "i32_atomic_rmw16_or_u"; 322 OperatorCode[OperatorCode["i64_atomic_rmw8_or_u"] = 65079] = "i64_atomic_rmw8_or_u"; 323 OperatorCode[OperatorCode["i64_atomic_rmw16_or_u"] = 65080] = "i64_atomic_rmw16_or_u"; 324 OperatorCode[OperatorCode["i64_atomic_rmw32_or_u"] = 65081] = "i64_atomic_rmw32_or_u"; 325 OperatorCode[OperatorCode["i32_atomic_rmw_xor"] = 65082] = "i32_atomic_rmw_xor"; 326 OperatorCode[OperatorCode["i64_atomic_rmw_xor"] = 65083] = "i64_atomic_rmw_xor"; 327 OperatorCode[OperatorCode["i32_atomic_rmw8_xor_u"] = 65084] = "i32_atomic_rmw8_xor_u"; 328 OperatorCode[OperatorCode["i32_atomic_rmw16_xor_u"] = 65085] = "i32_atomic_rmw16_xor_u"; 329 OperatorCode[OperatorCode["i64_atomic_rmw8_xor_u"] = 65086] = "i64_atomic_rmw8_xor_u"; 330 OperatorCode[OperatorCode["i64_atomic_rmw16_xor_u"] = 65087] = "i64_atomic_rmw16_xor_u"; 331 OperatorCode[OperatorCode["i64_atomic_rmw32_xor_u"] = 65088] = "i64_atomic_rmw32_xor_u"; 332 OperatorCode[OperatorCode["i32_atomic_rmw_xchg"] = 65089] = "i32_atomic_rmw_xchg"; 333 OperatorCode[OperatorCode["i64_atomic_rmw_xchg"] = 65090] = "i64_atomic_rmw_xchg"; 334 OperatorCode[OperatorCode["i32_atomic_rmw8_xchg_u"] = 65091] = "i32_atomic_rmw8_xchg_u"; 335 OperatorCode[OperatorCode["i32_atomic_rmw16_xchg_u"] = 65092] = "i32_atomic_rmw16_xchg_u"; 336 OperatorCode[OperatorCode["i64_atomic_rmw8_xchg_u"] = 65093] = "i64_atomic_rmw8_xchg_u"; 337 OperatorCode[OperatorCode["i64_atomic_rmw16_xchg_u"] = 65094] = "i64_atomic_rmw16_xchg_u"; 338 OperatorCode[OperatorCode["i64_atomic_rmw32_xchg_u"] = 65095] = "i64_atomic_rmw32_xchg_u"; 339 OperatorCode[OperatorCode["i32_atomic_rmw_cmpxchg"] = 65096] = "i32_atomic_rmw_cmpxchg"; 340 OperatorCode[OperatorCode["i64_atomic_rmw_cmpxchg"] = 65097] = "i64_atomic_rmw_cmpxchg"; 341 OperatorCode[OperatorCode["i32_atomic_rmw8_cmpxchg_u"] = 65098] = "i32_atomic_rmw8_cmpxchg_u"; 342 OperatorCode[OperatorCode["i32_atomic_rmw16_cmpxchg_u"] = 65099] = "i32_atomic_rmw16_cmpxchg_u"; 343 OperatorCode[OperatorCode["i64_atomic_rmw8_cmpxchg_u"] = 65100] = "i64_atomic_rmw8_cmpxchg_u"; 344 OperatorCode[OperatorCode["i64_atomic_rmw16_cmpxchg_u"] = 65101] = "i64_atomic_rmw16_cmpxchg_u"; 345 OperatorCode[OperatorCode["i64_atomic_rmw32_cmpxchg_u"] = 65102] = "i64_atomic_rmw32_cmpxchg_u"; 346 OperatorCode[OperatorCode["v128_load"] = 1036288] = "v128_load"; 347 OperatorCode[OperatorCode["i16x8_load8x8_s"] = 1036289] = "i16x8_load8x8_s"; 348 OperatorCode[OperatorCode["i16x8_load8x8_u"] = 1036290] = "i16x8_load8x8_u"; 349 OperatorCode[OperatorCode["i32x4_load16x4_s"] = 1036291] = "i32x4_load16x4_s"; 350 OperatorCode[OperatorCode["i32x4_load16x4_u"] = 1036292] = "i32x4_load16x4_u"; 351 OperatorCode[OperatorCode["i64x2_load32x2_s"] = 1036293] = "i64x2_load32x2_s"; 352 OperatorCode[OperatorCode["i64x2_load32x2_u"] = 1036294] = "i64x2_load32x2_u"; 353 OperatorCode[OperatorCode["v8x16_load_splat"] = 1036295] = "v8x16_load_splat"; 354 OperatorCode[OperatorCode["v16x8_load_splat"] = 1036296] = "v16x8_load_splat"; 355 OperatorCode[OperatorCode["v32x4_load_splat"] = 1036297] = "v32x4_load_splat"; 356 OperatorCode[OperatorCode["v64x2_load_splat"] = 1036298] = "v64x2_load_splat"; 357 OperatorCode[OperatorCode["v128_store"] = 1036299] = "v128_store"; 358 OperatorCode[OperatorCode["v128_const"] = 1036300] = "v128_const"; 359 OperatorCode[OperatorCode["i8x16_shuffle"] = 1036301] = "i8x16_shuffle"; 360 OperatorCode[OperatorCode["i8x16_swizzle"] = 1036302] = "i8x16_swizzle"; 361 OperatorCode[OperatorCode["i8x16_splat"] = 1036303] = "i8x16_splat"; 362 OperatorCode[OperatorCode["i16x8_splat"] = 1036304] = "i16x8_splat"; 363 OperatorCode[OperatorCode["i32x4_splat"] = 1036305] = "i32x4_splat"; 364 OperatorCode[OperatorCode["i64x2_splat"] = 1036306] = "i64x2_splat"; 365 OperatorCode[OperatorCode["f32x4_splat"] = 1036307] = "f32x4_splat"; 366 OperatorCode[OperatorCode["f64x2_splat"] = 1036308] = "f64x2_splat"; 367 OperatorCode[OperatorCode["i8x16_extract_lane_s"] = 1036309] = "i8x16_extract_lane_s"; 368 OperatorCode[OperatorCode["i8x16_extract_lane_u"] = 1036310] = "i8x16_extract_lane_u"; 369 OperatorCode[OperatorCode["i8x16_replace_lane"] = 1036311] = "i8x16_replace_lane"; 370 OperatorCode[OperatorCode["i16x8_extract_lane_s"] = 1036312] = "i16x8_extract_lane_s"; 371 OperatorCode[OperatorCode["i16x8_extract_lane_u"] = 1036313] = "i16x8_extract_lane_u"; 372 OperatorCode[OperatorCode["i16x8_replace_lane"] = 1036314] = "i16x8_replace_lane"; 373 OperatorCode[OperatorCode["i32x4_extract_lane"] = 1036315] = "i32x4_extract_lane"; 374 OperatorCode[OperatorCode["i32x4_replace_lane"] = 1036316] = "i32x4_replace_lane"; 375 OperatorCode[OperatorCode["i64x2_extract_lane"] = 1036317] = "i64x2_extract_lane"; 376 OperatorCode[OperatorCode["i64x2_replace_lane"] = 1036318] = "i64x2_replace_lane"; 377 OperatorCode[OperatorCode["f32x4_extract_lane"] = 1036319] = "f32x4_extract_lane"; 378 OperatorCode[OperatorCode["f32x4_replace_lane"] = 1036320] = "f32x4_replace_lane"; 379 OperatorCode[OperatorCode["f64x2_extract_lane"] = 1036321] = "f64x2_extract_lane"; 380 OperatorCode[OperatorCode["f64x2_replace_lane"] = 1036322] = "f64x2_replace_lane"; 381 OperatorCode[OperatorCode["i8x16_eq"] = 1036323] = "i8x16_eq"; 382 OperatorCode[OperatorCode["i8x16_ne"] = 1036324] = "i8x16_ne"; 383 OperatorCode[OperatorCode["i8x16_lt_s"] = 1036325] = "i8x16_lt_s"; 384 OperatorCode[OperatorCode["i8x16_lt_u"] = 1036326] = "i8x16_lt_u"; 385 OperatorCode[OperatorCode["i8x16_gt_s"] = 1036327] = "i8x16_gt_s"; 386 OperatorCode[OperatorCode["i8x16_gt_u"] = 1036328] = "i8x16_gt_u"; 387 OperatorCode[OperatorCode["i8x16_le_s"] = 1036329] = "i8x16_le_s"; 388 OperatorCode[OperatorCode["i8x16_le_u"] = 1036330] = "i8x16_le_u"; 389 OperatorCode[OperatorCode["i8x16_ge_s"] = 1036331] = "i8x16_ge_s"; 390 OperatorCode[OperatorCode["i8x16_ge_u"] = 1036332] = "i8x16_ge_u"; 391 OperatorCode[OperatorCode["i16x8_eq"] = 1036333] = "i16x8_eq"; 392 OperatorCode[OperatorCode["i16x8_ne"] = 1036334] = "i16x8_ne"; 393 OperatorCode[OperatorCode["i16x8_lt_s"] = 1036335] = "i16x8_lt_s"; 394 OperatorCode[OperatorCode["i16x8_lt_u"] = 1036336] = "i16x8_lt_u"; 395 OperatorCode[OperatorCode["i16x8_gt_s"] = 1036337] = "i16x8_gt_s"; 396 OperatorCode[OperatorCode["i16x8_gt_u"] = 1036338] = "i16x8_gt_u"; 397 OperatorCode[OperatorCode["i16x8_le_s"] = 1036339] = "i16x8_le_s"; 398 OperatorCode[OperatorCode["i16x8_le_u"] = 1036340] = "i16x8_le_u"; 399 OperatorCode[OperatorCode["i16x8_ge_s"] = 1036341] = "i16x8_ge_s"; 400 OperatorCode[OperatorCode["i16x8_ge_u"] = 1036342] = "i16x8_ge_u"; 401 OperatorCode[OperatorCode["i32x4_eq"] = 1036343] = "i32x4_eq"; 402 OperatorCode[OperatorCode["i32x4_ne"] = 1036344] = "i32x4_ne"; 403 OperatorCode[OperatorCode["i32x4_lt_s"] = 1036345] = "i32x4_lt_s"; 404 OperatorCode[OperatorCode["i32x4_lt_u"] = 1036346] = "i32x4_lt_u"; 405 OperatorCode[OperatorCode["i32x4_gt_s"] = 1036347] = "i32x4_gt_s"; 406 OperatorCode[OperatorCode["i32x4_gt_u"] = 1036348] = "i32x4_gt_u"; 407 OperatorCode[OperatorCode["i32x4_le_s"] = 1036349] = "i32x4_le_s"; 408 OperatorCode[OperatorCode["i32x4_le_u"] = 1036350] = "i32x4_le_u"; 409 OperatorCode[OperatorCode["i32x4_ge_s"] = 1036351] = "i32x4_ge_s"; 410 OperatorCode[OperatorCode["i32x4_ge_u"] = 1036352] = "i32x4_ge_u"; 411 OperatorCode[OperatorCode["f32x4_eq"] = 1036353] = "f32x4_eq"; 412 OperatorCode[OperatorCode["f32x4_ne"] = 1036354] = "f32x4_ne"; 413 OperatorCode[OperatorCode["f32x4_lt"] = 1036355] = "f32x4_lt"; 414 OperatorCode[OperatorCode["f32x4_gt"] = 1036356] = "f32x4_gt"; 415 OperatorCode[OperatorCode["f32x4_le"] = 1036357] = "f32x4_le"; 416 OperatorCode[OperatorCode["f32x4_ge"] = 1036358] = "f32x4_ge"; 417 OperatorCode[OperatorCode["f64x2_eq"] = 1036359] = "f64x2_eq"; 418 OperatorCode[OperatorCode["f64x2_ne"] = 1036360] = "f64x2_ne"; 419 OperatorCode[OperatorCode["f64x2_lt"] = 1036361] = "f64x2_lt"; 420 OperatorCode[OperatorCode["f64x2_gt"] = 1036362] = "f64x2_gt"; 421 OperatorCode[OperatorCode["f64x2_le"] = 1036363] = "f64x2_le"; 422 OperatorCode[OperatorCode["f64x2_ge"] = 1036364] = "f64x2_ge"; 423 OperatorCode[OperatorCode["v128_not"] = 1036365] = "v128_not"; 424 OperatorCode[OperatorCode["v128_and"] = 1036366] = "v128_and"; 425 OperatorCode[OperatorCode["v128_andnot"] = 1036367] = "v128_andnot"; 426 OperatorCode[OperatorCode["v128_or"] = 1036368] = "v128_or"; 427 OperatorCode[OperatorCode["v128_xor"] = 1036369] = "v128_xor"; 428 OperatorCode[OperatorCode["v128_bitselect"] = 1036370] = "v128_bitselect"; 429 OperatorCode[OperatorCode["v128_any_true"] = 1036371] = "v128_any_true"; 430 OperatorCode[OperatorCode["v128_load8_lane"] = 1036372] = "v128_load8_lane"; 431 OperatorCode[OperatorCode["v128_load16_lane"] = 1036373] = "v128_load16_lane"; 432 OperatorCode[OperatorCode["v128_load32_lane"] = 1036374] = "v128_load32_lane"; 433 OperatorCode[OperatorCode["v128_load64_lane"] = 1036375] = "v128_load64_lane"; 434 OperatorCode[OperatorCode["v128_store8_lane"] = 1036376] = "v128_store8_lane"; 435 OperatorCode[OperatorCode["v128_store16_lane"] = 1036377] = "v128_store16_lane"; 436 OperatorCode[OperatorCode["v128_store32_lane"] = 1036378] = "v128_store32_lane"; 437 OperatorCode[OperatorCode["v128_store64_lane"] = 1036379] = "v128_store64_lane"; 438 OperatorCode[OperatorCode["v128_load32_zero"] = 1036380] = "v128_load32_zero"; 439 OperatorCode[OperatorCode["v128_load64_zero"] = 1036381] = "v128_load64_zero"; 440 OperatorCode[OperatorCode["f32x4_demote_f64x2_zero"] = 1036382] = "f32x4_demote_f64x2_zero"; 441 OperatorCode[OperatorCode["f64x2_promote_low_f32x4"] = 1036383] = "f64x2_promote_low_f32x4"; 442 OperatorCode[OperatorCode["i8x16_abs"] = 1036384] = "i8x16_abs"; 443 OperatorCode[OperatorCode["i8x16_neg"] = 1036385] = "i8x16_neg"; 444 OperatorCode[OperatorCode["i8x16_popcnt"] = 1036386] = "i8x16_popcnt"; 445 OperatorCode[OperatorCode["i8x16_all_true"] = 1036387] = "i8x16_all_true"; 446 OperatorCode[OperatorCode["i8x16_bitmask"] = 1036388] = "i8x16_bitmask"; 447 OperatorCode[OperatorCode["i8x16_narrow_i16x8_s"] = 1036389] = "i8x16_narrow_i16x8_s"; 448 OperatorCode[OperatorCode["i8x16_narrow_i16x8_u"] = 1036390] = "i8x16_narrow_i16x8_u"; 449 OperatorCode[OperatorCode["f32x4_ceil"] = 1036391] = "f32x4_ceil"; 450 OperatorCode[OperatorCode["f32x4_floor"] = 1036392] = "f32x4_floor"; 451 OperatorCode[OperatorCode["f32x4_trunc"] = 1036393] = "f32x4_trunc"; 452 OperatorCode[OperatorCode["f32x4_nearest"] = 1036394] = "f32x4_nearest"; 453 OperatorCode[OperatorCode["i8x16_shl"] = 1036395] = "i8x16_shl"; 454 OperatorCode[OperatorCode["i8x16_shr_s"] = 1036396] = "i8x16_shr_s"; 455 OperatorCode[OperatorCode["i8x16_shr_u"] = 1036397] = "i8x16_shr_u"; 456 OperatorCode[OperatorCode["i8x16_add"] = 1036398] = "i8x16_add"; 457 OperatorCode[OperatorCode["i8x16_add_sat_s"] = 1036399] = "i8x16_add_sat_s"; 458 OperatorCode[OperatorCode["i8x16_add_sat_u"] = 1036400] = "i8x16_add_sat_u"; 459 OperatorCode[OperatorCode["i8x16_sub"] = 1036401] = "i8x16_sub"; 460 OperatorCode[OperatorCode["i8x16_sub_sat_s"] = 1036402] = "i8x16_sub_sat_s"; 461 OperatorCode[OperatorCode["i8x16_sub_sat_u"] = 1036403] = "i8x16_sub_sat_u"; 462 OperatorCode[OperatorCode["f64x2_ceil"] = 1036404] = "f64x2_ceil"; 463 OperatorCode[OperatorCode["f64x2_floor"] = 1036405] = "f64x2_floor"; 464 OperatorCode[OperatorCode["i8x16_min_s"] = 1036406] = "i8x16_min_s"; 465 OperatorCode[OperatorCode["i8x16_min_u"] = 1036407] = "i8x16_min_u"; 466 OperatorCode[OperatorCode["i8x16_max_s"] = 1036408] = "i8x16_max_s"; 467 OperatorCode[OperatorCode["i8x16_max_u"] = 1036409] = "i8x16_max_u"; 468 OperatorCode[OperatorCode["f64x2_trunc"] = 1036410] = "f64x2_trunc"; 469 OperatorCode[OperatorCode["i8x16_avgr_u"] = 1036411] = "i8x16_avgr_u"; 470 OperatorCode[OperatorCode["i16x8_extadd_pairwise_i8x16_s"] = 1036412] = "i16x8_extadd_pairwise_i8x16_s"; 471 OperatorCode[OperatorCode["i16x8_extadd_pairwise_i8x16_u"] = 1036413] = "i16x8_extadd_pairwise_i8x16_u"; 472 OperatorCode[OperatorCode["i32x4_extadd_pairwise_i16x8_s"] = 1036414] = "i32x4_extadd_pairwise_i16x8_s"; 473 OperatorCode[OperatorCode["i32x4_extadd_pairwise_i16x8_u"] = 1036415] = "i32x4_extadd_pairwise_i16x8_u"; 474 OperatorCode[OperatorCode["i16x8_abs"] = 1036416] = "i16x8_abs"; 475 OperatorCode[OperatorCode["i16x8_neg"] = 1036417] = "i16x8_neg"; 476 OperatorCode[OperatorCode["i16x8_q15mulr_sat_s"] = 1036418] = "i16x8_q15mulr_sat_s"; 477 OperatorCode[OperatorCode["i16x8_all_true"] = 1036419] = "i16x8_all_true"; 478 OperatorCode[OperatorCode["i16x8_bitmask"] = 1036420] = "i16x8_bitmask"; 479 OperatorCode[OperatorCode["i16x8_narrow_i32x4_s"] = 1036421] = "i16x8_narrow_i32x4_s"; 480 OperatorCode[OperatorCode["i16x8_narrow_i32x4_u"] = 1036422] = "i16x8_narrow_i32x4_u"; 481 OperatorCode[OperatorCode["i16x8_extend_low_i8x16_s"] = 1036423] = "i16x8_extend_low_i8x16_s"; 482 OperatorCode[OperatorCode["i16x8_extend_high_i8x16_s"] = 1036424] = "i16x8_extend_high_i8x16_s"; 483 OperatorCode[OperatorCode["i16x8_extend_low_i8x16_u"] = 1036425] = "i16x8_extend_low_i8x16_u"; 484 OperatorCode[OperatorCode["i16x8_extend_high_i8x16_u"] = 1036426] = "i16x8_extend_high_i8x16_u"; 485 OperatorCode[OperatorCode["i16x8_shl"] = 1036427] = "i16x8_shl"; 486 OperatorCode[OperatorCode["i16x8_shr_s"] = 1036428] = "i16x8_shr_s"; 487 OperatorCode[OperatorCode["i16x8_shr_u"] = 1036429] = "i16x8_shr_u"; 488 OperatorCode[OperatorCode["i16x8_add"] = 1036430] = "i16x8_add"; 489 OperatorCode[OperatorCode["i16x8_add_sat_s"] = 1036431] = "i16x8_add_sat_s"; 490 OperatorCode[OperatorCode["i16x8_add_sat_u"] = 1036432] = "i16x8_add_sat_u"; 491 OperatorCode[OperatorCode["i16x8_sub"] = 1036433] = "i16x8_sub"; 492 OperatorCode[OperatorCode["i16x8_sub_sat_s"] = 1036434] = "i16x8_sub_sat_s"; 493 OperatorCode[OperatorCode["i16x8_sub_sat_u"] = 1036435] = "i16x8_sub_sat_u"; 494 OperatorCode[OperatorCode["f64x2_nearest"] = 1036436] = "f64x2_nearest"; 495 OperatorCode[OperatorCode["i16x8_mul"] = 1036437] = "i16x8_mul"; 496 OperatorCode[OperatorCode["i16x8_min_s"] = 1036438] = "i16x8_min_s"; 497 OperatorCode[OperatorCode["i16x8_min_u"] = 1036439] = "i16x8_min_u"; 498 OperatorCode[OperatorCode["i16x8_max_s"] = 1036440] = "i16x8_max_s"; 499 OperatorCode[OperatorCode["i16x8_max_u"] = 1036441] = "i16x8_max_u"; 500 OperatorCode[OperatorCode["i16x8_avgr_u"] = 1036443] = "i16x8_avgr_u"; 501 OperatorCode[OperatorCode["i16x8_extmul_low_i8x16_s"] = 1036444] = "i16x8_extmul_low_i8x16_s"; 502 OperatorCode[OperatorCode["i16x8_extmul_high_i8x16_s"] = 1036445] = "i16x8_extmul_high_i8x16_s"; 503 OperatorCode[OperatorCode["i16x8_extmul_low_i8x16_u"] = 1036446] = "i16x8_extmul_low_i8x16_u"; 504 OperatorCode[OperatorCode["i16x8_extmul_high_i8x16_u"] = 1036447] = "i16x8_extmul_high_i8x16_u"; 505 OperatorCode[OperatorCode["i32x4_abs"] = 1036448] = "i32x4_abs"; 506 OperatorCode[OperatorCode["i32x4_neg"] = 1036449] = "i32x4_neg"; 507 OperatorCode[OperatorCode["i32x4_all_true"] = 1036451] = "i32x4_all_true"; 508 OperatorCode[OperatorCode["i32x4_bitmask"] = 1036452] = "i32x4_bitmask"; 509 OperatorCode[OperatorCode["i32x4_extend_low_i16x8_s"] = 1036455] = "i32x4_extend_low_i16x8_s"; 510 OperatorCode[OperatorCode["i32x4_extend_high_i16x8_s"] = 1036456] = "i32x4_extend_high_i16x8_s"; 511 OperatorCode[OperatorCode["i32x4_extend_low_i16x8_u"] = 1036457] = "i32x4_extend_low_i16x8_u"; 512 OperatorCode[OperatorCode["i32x4_extend_high_i16x8_u"] = 1036458] = "i32x4_extend_high_i16x8_u"; 513 OperatorCode[OperatorCode["i32x4_shl"] = 1036459] = "i32x4_shl"; 514 OperatorCode[OperatorCode["i32x4_shr_s"] = 1036460] = "i32x4_shr_s"; 515 OperatorCode[OperatorCode["i32x4_shr_u"] = 1036461] = "i32x4_shr_u"; 516 OperatorCode[OperatorCode["i32x4_add"] = 1036462] = "i32x4_add"; 517 OperatorCode[OperatorCode["i32x4_sub"] = 1036465] = "i32x4_sub"; 518 OperatorCode[OperatorCode["i32x4_mul"] = 1036469] = "i32x4_mul"; 519 OperatorCode[OperatorCode["i32x4_min_s"] = 1036470] = "i32x4_min_s"; 520 OperatorCode[OperatorCode["i32x4_min_u"] = 1036471] = "i32x4_min_u"; 521 OperatorCode[OperatorCode["i32x4_max_s"] = 1036472] = "i32x4_max_s"; 522 OperatorCode[OperatorCode["i32x4_max_u"] = 1036473] = "i32x4_max_u"; 523 OperatorCode[OperatorCode["i32x4_dot_i16x8_s"] = 1036474] = "i32x4_dot_i16x8_s"; 524 OperatorCode[OperatorCode["i32x4_extmul_low_i16x8_s"] = 1036476] = "i32x4_extmul_low_i16x8_s"; 525 OperatorCode[OperatorCode["i32x4_extmul_high_i16x8_s"] = 1036477] = "i32x4_extmul_high_i16x8_s"; 526 OperatorCode[OperatorCode["i32x4_extmul_low_i16x8_u"] = 1036478] = "i32x4_extmul_low_i16x8_u"; 527 OperatorCode[OperatorCode["i32x4_extmul_high_i16x8_u"] = 1036479] = "i32x4_extmul_high_i16x8_u"; 528 OperatorCode[OperatorCode["i64x2_abs"] = 1036480] = "i64x2_abs"; 529 OperatorCode[OperatorCode["i64x2_neg"] = 1036481] = "i64x2_neg"; 530 OperatorCode[OperatorCode["i64x2_all_true"] = 1036483] = "i64x2_all_true"; 531 OperatorCode[OperatorCode["i64x2_bitmask"] = 1036484] = "i64x2_bitmask"; 532 OperatorCode[OperatorCode["i64x2_extend_low_i32x4_s"] = 1036487] = "i64x2_extend_low_i32x4_s"; 533 OperatorCode[OperatorCode["i64x2_extend_high_i32x4_s"] = 1036488] = "i64x2_extend_high_i32x4_s"; 534 OperatorCode[OperatorCode["i64x2_extend_low_i32x4_u"] = 1036489] = "i64x2_extend_low_i32x4_u"; 535 OperatorCode[OperatorCode["i64x2_extend_high_i32x4_u"] = 1036490] = "i64x2_extend_high_i32x4_u"; 536 OperatorCode[OperatorCode["i64x2_shl"] = 1036491] = "i64x2_shl"; 537 OperatorCode[OperatorCode["i64x2_shr_s"] = 1036492] = "i64x2_shr_s"; 538 OperatorCode[OperatorCode["i64x2_shr_u"] = 1036493] = "i64x2_shr_u"; 539 OperatorCode[OperatorCode["i64x2_add"] = 1036494] = "i64x2_add"; 540 OperatorCode[OperatorCode["i64x2_sub"] = 1036497] = "i64x2_sub"; 541 OperatorCode[OperatorCode["i64x2_mul"] = 1036501] = "i64x2_mul"; 542 OperatorCode[OperatorCode["i64x2_eq"] = 1036502] = "i64x2_eq"; 543 OperatorCode[OperatorCode["i64x2_ne"] = 1036503] = "i64x2_ne"; 544 OperatorCode[OperatorCode["i64x2_lt_s"] = 1036504] = "i64x2_lt_s"; 545 OperatorCode[OperatorCode["i64x2_gt_s"] = 1036505] = "i64x2_gt_s"; 546 OperatorCode[OperatorCode["i64x2_le_s"] = 1036506] = "i64x2_le_s"; 547 OperatorCode[OperatorCode["i64x2_ge_s"] = 1036507] = "i64x2_ge_s"; 548 OperatorCode[OperatorCode["i64x2_extmul_low_i32x4_s"] = 1036508] = "i64x2_extmul_low_i32x4_s"; 549 OperatorCode[OperatorCode["i64x2_extmul_high_i32x4_s"] = 1036509] = "i64x2_extmul_high_i32x4_s"; 550 OperatorCode[OperatorCode["i64x2_extmul_low_i32x4_u"] = 1036510] = "i64x2_extmul_low_i32x4_u"; 551 OperatorCode[OperatorCode["i64x2_extmul_high_i32x4_u"] = 1036511] = "i64x2_extmul_high_i32x4_u"; 552 OperatorCode[OperatorCode["f32x4_abs"] = 1036512] = "f32x4_abs"; 553 OperatorCode[OperatorCode["f32x4_neg"] = 1036513] = "f32x4_neg"; 554 OperatorCode[OperatorCode["f32x4_sqrt"] = 1036515] = "f32x4_sqrt"; 555 OperatorCode[OperatorCode["f32x4_add"] = 1036516] = "f32x4_add"; 556 OperatorCode[OperatorCode["f32x4_sub"] = 1036517] = "f32x4_sub"; 557 OperatorCode[OperatorCode["f32x4_mul"] = 1036518] = "f32x4_mul"; 558 OperatorCode[OperatorCode["f32x4_div"] = 1036519] = "f32x4_div"; 559 OperatorCode[OperatorCode["f32x4_min"] = 1036520] = "f32x4_min"; 560 OperatorCode[OperatorCode["f32x4_max"] = 1036521] = "f32x4_max"; 561 OperatorCode[OperatorCode["f32x4_pmin"] = 1036522] = "f32x4_pmin"; 562 OperatorCode[OperatorCode["f32x4_pmax"] = 1036523] = "f32x4_pmax"; 563 OperatorCode[OperatorCode["f64x2_abs"] = 1036524] = "f64x2_abs"; 564 OperatorCode[OperatorCode["f64x2_neg"] = 1036525] = "f64x2_neg"; 565 OperatorCode[OperatorCode["f64x2_sqrt"] = 1036527] = "f64x2_sqrt"; 566 OperatorCode[OperatorCode["f64x2_add"] = 1036528] = "f64x2_add"; 567 OperatorCode[OperatorCode["f64x2_sub"] = 1036529] = "f64x2_sub"; 568 OperatorCode[OperatorCode["f64x2_mul"] = 1036530] = "f64x2_mul"; 569 OperatorCode[OperatorCode["f64x2_div"] = 1036531] = "f64x2_div"; 570 OperatorCode[OperatorCode["f64x2_min"] = 1036532] = "f64x2_min"; 571 OperatorCode[OperatorCode["f64x2_max"] = 1036533] = "f64x2_max"; 572 OperatorCode[OperatorCode["f64x2_pmin"] = 1036534] = "f64x2_pmin"; 573 OperatorCode[OperatorCode["f64x2_pmax"] = 1036535] = "f64x2_pmax"; 574 OperatorCode[OperatorCode["i32x4_trunc_sat_f32x4_s"] = 1036536] = "i32x4_trunc_sat_f32x4_s"; 575 OperatorCode[OperatorCode["i32x4_trunc_sat_f32x4_u"] = 1036537] = "i32x4_trunc_sat_f32x4_u"; 576 OperatorCode[OperatorCode["f32x4_convert_i32x4_s"] = 1036538] = "f32x4_convert_i32x4_s"; 577 OperatorCode[OperatorCode["f32x4_convert_i32x4_u"] = 1036539] = "f32x4_convert_i32x4_u"; 578 OperatorCode[OperatorCode["i32x4_trunc_sat_f64x2_s_zero"] = 1036540] = "i32x4_trunc_sat_f64x2_s_zero"; 579 OperatorCode[OperatorCode["i32x4_trunc_sat_f64x2_u_zero"] = 1036541] = "i32x4_trunc_sat_f64x2_u_zero"; 580 OperatorCode[OperatorCode["f64x2_convert_low_i32x4_s"] = 1036542] = "f64x2_convert_low_i32x4_s"; 581 OperatorCode[OperatorCode["f64x2_convert_low_i32x4_u"] = 1036543] = "f64x2_convert_low_i32x4_u"; 582 // Relaxed SIMD 583 OperatorCode[OperatorCode["i8x16_relaxed_swizzle"] = 1036544] = "i8x16_relaxed_swizzle"; 584 OperatorCode[OperatorCode["i32x4_relaxed_trunc_f32x4_s"] = 1036545] = "i32x4_relaxed_trunc_f32x4_s"; 585 OperatorCode[OperatorCode["i32x4_relaxed_trunc_f32x4_u"] = 1036546] = "i32x4_relaxed_trunc_f32x4_u"; 586 OperatorCode[OperatorCode["i32x4_relaxed_trunc_f64x2_s_zero"] = 1036547] = "i32x4_relaxed_trunc_f64x2_s_zero"; 587 OperatorCode[OperatorCode["i32x4_relaxed_trunc_f64x2_u_zero"] = 1036548] = "i32x4_relaxed_trunc_f64x2_u_zero"; 588 OperatorCode[OperatorCode["f32x4_relaxed_madd"] = 1036549] = "f32x4_relaxed_madd"; 589 OperatorCode[OperatorCode["f32x4_relaxed_nmadd"] = 1036550] = "f32x4_relaxed_nmadd"; 590 OperatorCode[OperatorCode["f64x2_relaxed_madd"] = 1036551] = "f64x2_relaxed_madd"; 591 OperatorCode[OperatorCode["f64x2_relaxed_nmadd"] = 1036552] = "f64x2_relaxed_nmadd"; 592 OperatorCode[OperatorCode["i8x16_relaxed_laneselect"] = 1036553] = "i8x16_relaxed_laneselect"; 593 OperatorCode[OperatorCode["i16x8_relaxed_laneselect"] = 1036554] = "i16x8_relaxed_laneselect"; 594 OperatorCode[OperatorCode["i32x4_relaxed_laneselect"] = 1036555] = "i32x4_relaxed_laneselect"; 595 OperatorCode[OperatorCode["i64x2_relaxed_laneselect"] = 1036556] = "i64x2_relaxed_laneselect"; 596 OperatorCode[OperatorCode["f32x4_relaxed_min"] = 1036557] = "f32x4_relaxed_min"; 597 OperatorCode[OperatorCode["f32x4_relaxed_max"] = 1036558] = "f32x4_relaxed_max"; 598 OperatorCode[OperatorCode["f64x2_relaxed_min"] = 1036559] = "f64x2_relaxed_min"; 599 OperatorCode[OperatorCode["f64x2_relaxed_max"] = 1036560] = "f64x2_relaxed_max"; 600 OperatorCode[OperatorCode["i16x8_relaxed_q15mulr_s"] = 1036561] = "i16x8_relaxed_q15mulr_s"; 601 OperatorCode[OperatorCode["i16x8_relaxed_dot_i8x16_i7x16_s"] = 1036562] = "i16x8_relaxed_dot_i8x16_i7x16_s"; 602 OperatorCode[OperatorCode["i32x4_relaxed_dot_i8x16_i7x16_add_s"] = 1036563] = "i32x4_relaxed_dot_i8x16_i7x16_add_s"; 603 // GC proposal. 604 OperatorCode[OperatorCode["struct_new"] = 64256] = "struct_new"; 605 OperatorCode[OperatorCode["struct_new_default"] = 64257] = "struct_new_default"; 606 OperatorCode[OperatorCode["struct_get"] = 64258] = "struct_get"; 607 OperatorCode[OperatorCode["struct_get_s"] = 64259] = "struct_get_s"; 608 OperatorCode[OperatorCode["struct_get_u"] = 64260] = "struct_get_u"; 609 OperatorCode[OperatorCode["struct_set"] = 64261] = "struct_set"; 610 OperatorCode[OperatorCode["array_new"] = 64262] = "array_new"; 611 OperatorCode[OperatorCode["array_new_default"] = 64263] = "array_new_default"; 612 OperatorCode[OperatorCode["array_new_fixed"] = 64264] = "array_new_fixed"; 613 OperatorCode[OperatorCode["array_new_data"] = 64265] = "array_new_data"; 614 OperatorCode[OperatorCode["array_new_elem"] = 64266] = "array_new_elem"; 615 OperatorCode[OperatorCode["array_get"] = 64267] = "array_get"; 616 OperatorCode[OperatorCode["array_get_s"] = 64268] = "array_get_s"; 617 OperatorCode[OperatorCode["array_get_u"] = 64269] = "array_get_u"; 618 OperatorCode[OperatorCode["array_set"] = 64270] = "array_set"; 619 OperatorCode[OperatorCode["array_len"] = 64271] = "array_len"; 620 OperatorCode[OperatorCode["array_fill"] = 64272] = "array_fill"; 621 OperatorCode[OperatorCode["array_copy"] = 64273] = "array_copy"; 622 OperatorCode[OperatorCode["array_init_data"] = 64274] = "array_init_data"; 623 OperatorCode[OperatorCode["array_init_elem"] = 64275] = "array_init_elem"; 624 OperatorCode[OperatorCode["ref_test"] = 64276] = "ref_test"; 625 OperatorCode[OperatorCode["ref_test_null"] = 64277] = "ref_test_null"; 626 OperatorCode[OperatorCode["ref_cast"] = 64278] = "ref_cast"; 627 OperatorCode[OperatorCode["ref_cast_null"] = 64279] = "ref_cast_null"; 628 OperatorCode[OperatorCode["br_on_cast"] = 64280] = "br_on_cast"; 629 OperatorCode[OperatorCode["br_on_cast_fail"] = 64281] = "br_on_cast_fail"; 630 OperatorCode[OperatorCode["any_convert_extern"] = 64282] = "any_convert_extern"; 631 OperatorCode[OperatorCode["extern_convert_any"] = 64283] = "extern_convert_any"; 632 OperatorCode[OperatorCode["ref_i31"] = 64284] = "ref_i31"; 633 OperatorCode[OperatorCode["i31_get_s"] = 64285] = "i31_get_s"; 634 OperatorCode[OperatorCode["i31_get_u"] = 64286] = "i31_get_u"; 635 })(OperatorCode = exports.OperatorCode || (exports.OperatorCode = {})); 636 exports.OperatorCodeNames = [ 637 "unreachable", 638 "nop", 639 "block", 640 "loop", 641 "if", 642 "else", 643 "try", 644 "catch", 645 "throw", 646 "rethrow", 647 "throw_ref", 648 "end", 649 "br", 650 "br_if", 651 "br_table", 652 "return", 653 "call", 654 "call_indirect", 655 "return_call", 656 "return_call_indirect", 657 "call_ref", 658 "return_call_ref", 659 undefined, 660 "let", 661 "delegate", 662 "catch_all", 663 "drop", 664 "select", 665 "select", 666 undefined, 667 undefined, 668 "try_table", 669 "local.get", 670 "local.set", 671 "local.tee", 672 "global.get", 673 "global.set", 674 "table.get", 675 "table.set", 676 undefined, 677 "i32.load", 678 "i64.load", 679 "f32.load", 680 "f64.load", 681 "i32.load8_s", 682 "i32.load8_u", 683 "i32.load16_s", 684 "i32.load16_u", 685 "i64.load8_s", 686 "i64.load8_u", 687 "i64.load16_s", 688 "i64.load16_u", 689 "i64.load32_s", 690 "i64.load32_u", 691 "i32.store", 692 "i64.store", 693 "f32.store", 694 "f64.store", 695 "i32.store8", 696 "i32.store16", 697 "i64.store8", 698 "i64.store16", 699 "i64.store32", 700 "memory.size", 701 "memory.grow", 702 "i32.const", 703 "i64.const", 704 "f32.const", 705 "f64.const", 706 "i32.eqz", 707 "i32.eq", 708 "i32.ne", 709 "i32.lt_s", 710 "i32.lt_u", 711 "i32.gt_s", 712 "i32.gt_u", 713 "i32.le_s", 714 "i32.le_u", 715 "i32.ge_s", 716 "i32.ge_u", 717 "i64.eqz", 718 "i64.eq", 719 "i64.ne", 720 "i64.lt_s", 721 "i64.lt_u", 722 "i64.gt_s", 723 "i64.gt_u", 724 "i64.le_s", 725 "i64.le_u", 726 "i64.ge_s", 727 "i64.ge_u", 728 "f32.eq", 729 "f32.ne", 730 "f32.lt", 731 "f32.gt", 732 "f32.le", 733 "f32.ge", 734 "f64.eq", 735 "f64.ne", 736 "f64.lt", 737 "f64.gt", 738 "f64.le", 739 "f64.ge", 740 "i32.clz", 741 "i32.ctz", 742 "i32.popcnt", 743 "i32.add", 744 "i32.sub", 745 "i32.mul", 746 "i32.div_s", 747 "i32.div_u", 748 "i32.rem_s", 749 "i32.rem_u", 750 "i32.and", 751 "i32.or", 752 "i32.xor", 753 "i32.shl", 754 "i32.shr_s", 755 "i32.shr_u", 756 "i32.rotl", 757 "i32.rotr", 758 "i64.clz", 759 "i64.ctz", 760 "i64.popcnt", 761 "i64.add", 762 "i64.sub", 763 "i64.mul", 764 "i64.div_s", 765 "i64.div_u", 766 "i64.rem_s", 767 "i64.rem_u", 768 "i64.and", 769 "i64.or", 770 "i64.xor", 771 "i64.shl", 772 "i64.shr_s", 773 "i64.shr_u", 774 "i64.rotl", 775 "i64.rotr", 776 "f32.abs", 777 "f32.neg", 778 "f32.ceil", 779 "f32.floor", 780 "f32.trunc", 781 "f32.nearest", 782 "f32.sqrt", 783 "f32.add", 784 "f32.sub", 785 "f32.mul", 786 "f32.div", 787 "f32.min", 788 "f32.max", 789 "f32.copysign", 790 "f64.abs", 791 "f64.neg", 792 "f64.ceil", 793 "f64.floor", 794 "f64.trunc", 795 "f64.nearest", 796 "f64.sqrt", 797 "f64.add", 798 "f64.sub", 799 "f64.mul", 800 "f64.div", 801 "f64.min", 802 "f64.max", 803 "f64.copysign", 804 "i32.wrap_i64", 805 "i32.trunc_f32_s", 806 "i32.trunc_f32_u", 807 "i32.trunc_f64_s", 808 "i32.trunc_f64_u", 809 "i64.extend_i32_s", 810 "i64.extend_i32_u", 811 "i64.trunc_f32_s", 812 "i64.trunc_f32_u", 813 "i64.trunc_f64_s", 814 "i64.trunc_f64_u", 815 "f32.convert_i32_s", 816 "f32.convert_i32_u", 817 "f32.convert_i64_s", 818 "f32.convert_i64_u", 819 "f32.demote_f64", 820 "f64.convert_i32_s", 821 "f64.convert_i32_u", 822 "f64.convert_i64_s", 823 "f64.convert_i64_u", 824 "f64.promote_f32", 825 "i32.reinterpret_f32", 826 "i64.reinterpret_f64", 827 "f32.reinterpret_i32", 828 "f64.reinterpret_i64", 829 "i32.extend8_s", 830 "i32.extend16_s", 831 "i64.extend8_s", 832 "i64.extend16_s", 833 "i64.extend32_s", 834 undefined, 835 undefined, 836 undefined, 837 undefined, 838 undefined, 839 undefined, 840 undefined, 841 undefined, 842 undefined, 843 undefined, 844 undefined, 845 "ref.null", 846 "ref.is_null", 847 "ref.func", 848 "ref.eq", 849 "ref.as_non_null", 850 "br_on_null", 851 "br_on_non_null", 852 undefined, 853 undefined, 854 undefined, 855 undefined, 856 undefined, 857 undefined, 858 undefined, 859 undefined, 860 undefined, 861 undefined, 862 undefined, 863 undefined, 864 undefined, 865 undefined, 866 undefined, 867 undefined, 868 undefined, 869 undefined, 870 undefined, 871 undefined, 872 undefined, 873 undefined, 874 undefined, 875 undefined, 876 undefined, 877 undefined, 878 undefined, 879 undefined, 880 undefined, 881 undefined, 882 undefined, 883 undefined, 884 undefined, 885 undefined, 886 undefined, 887 undefined, 888 undefined, 889 undefined, 890 undefined, 891 undefined, 892 undefined, 893 ]; 894 [ 895 "i32.trunc_sat_f32_s", 896 "i32.trunc_sat_f32_u", 897 "i32.trunc_sat_f64_s", 898 "i32.trunc_sat_f64_u", 899 "i64.trunc_sat_f32_s", 900 "i64.trunc_sat_f32_u", 901 "i64.trunc_sat_f64_s", 902 "i64.trunc_sat_f64_u", 903 "memory.init", 904 "data.drop", 905 "memory.copy", 906 "memory.fill", 907 "table.init", 908 "elem.drop", 909 "table.copy", 910 "table.grow", 911 "table.size", 912 "table.fill", 913 ].forEach(function (s, i) { 914 exports.OperatorCodeNames[0xfc00 | i] = s; 915 }); 916 [ 917 "v128.load", 918 "i16x8.load8x8_s", 919 "i16x8.load8x8_u", 920 "i32x4.load16x4_s", 921 "i32x4.load16x4_u", 922 "i64x2.load32x2_s", 923 "i64x2.load32x2_u", 924 "v8x16.load_splat", 925 "v16x8.load_splat", 926 "v32x4.load_splat", 927 "v64x2.load_splat", 928 "v128.store", 929 "v128.const", 930 "i8x16.shuffle", 931 "i8x16.swizzle", 932 "i8x16.splat", 933 "i16x8.splat", 934 "i32x4.splat", 935 "i64x2.splat", 936 "f32x4.splat", 937 "f64x2.splat", 938 "i8x16.extract_lane_s", 939 "i8x16.extract_lane_u", 940 "i8x16.replace_lane", 941 "i16x8.extract_lane_s", 942 "i16x8.extract_lane_u", 943 "i16x8.replace_lane", 944 "i32x4.extract_lane", 945 "i32x4.replace_lane", 946 "i64x2.extract_lane", 947 "i64x2.replace_lane", 948 "f32x4.extract_lane", 949 "f32x4.replace_lane", 950 "f64x2.extract_lane", 951 "f64x2.replace_lane", 952 "i8x16.eq", 953 "i8x16.ne", 954 "i8x16.lt_s", 955 "i8x16.lt_u", 956 "i8x16.gt_s", 957 "i8x16.gt_u", 958 "i8x16.le_s", 959 "i8x16.le_u", 960 "i8x16.ge_s", 961 "i8x16.ge_u", 962 "i16x8.eq", 963 "i16x8.ne", 964 "i16x8.lt_s", 965 "i16x8.lt_u", 966 "i16x8.gt_s", 967 "i16x8.gt_u", 968 "i16x8.le_s", 969 "i16x8.le_u", 970 "i16x8.ge_s", 971 "i16x8.ge_u", 972 "i32x4.eq", 973 "i32x4.ne", 974 "i32x4.lt_s", 975 "i32x4.lt_u", 976 "i32x4.gt_s", 977 "i32x4.gt_u", 978 "i32x4.le_s", 979 "i32x4.le_u", 980 "i32x4.ge_s", 981 "i32x4.ge_u", 982 "f32x4.eq", 983 "f32x4.ne", 984 "f32x4.lt", 985 "f32x4.gt", 986 "f32x4.le", 987 "f32x4.ge", 988 "f64x2.eq", 989 "f64x2.ne", 990 "f64x2.lt", 991 "f64x2.gt", 992 "f64x2.le", 993 "f64x2.ge", 994 "v128.not", 995 "v128.and", 996 "v128.andnot", 997 "v128.or", 998 "v128.xor", 999 "v128.bitselect", 1000 "v128.any_true", 1001 "v128.load8_lane", 1002 "v128.load16_lane", 1003 "v128.load32_lane", 1004 "v128.load64_lane", 1005 "v128.store8_lane", 1006 "v128.store16_lane", 1007 "v128.store32_lane", 1008 "v128.store64_lane", 1009 "v128.load32_zero", 1010 "v128.load64_zero", 1011 "f32x4.demote_f64x2_zero", 1012 "f64x2.promote_low_f32x4", 1013 "i8x16.abs", 1014 "i8x16.neg", 1015 "i8x16_popcnt", 1016 "i8x16.all_true", 1017 "i8x16.bitmask", 1018 "i8x16.narrow_i16x8_s", 1019 "i8x16.narrow_i16x8_u", 1020 "f32x4.ceil", 1021 "f32x4.floor", 1022 "f32x4.trunc", 1023 "f32x4.nearest", 1024 "i8x16.shl", 1025 "i8x16.shr_s", 1026 "i8x16.shr_u", 1027 "i8x16.add", 1028 "i8x16.add_sat_s", 1029 "i8x16.add_sat_u", 1030 "i8x16.sub", 1031 "i8x16.sub_sat_s", 1032 "i8x16.sub_sat_u", 1033 "f64x2.ceil", 1034 "f64x2.floor", 1035 "i8x16.min_s", 1036 "i8x16.min_u", 1037 "i8x16.max_s", 1038 "i8x16.max_u", 1039 "f64x2.trunc", 1040 "i8x16.avgr_u", 1041 "i16x8.extadd_pairwise_i8x16_s", 1042 "i16x8.extadd_pairwise_i8x16_u", 1043 "i32x4.extadd_pairwise_i16x8_s", 1044 "i32x4.extadd_pairwise_i16x8_u", 1045 "i16x8.abs", 1046 "i16x8.neg", 1047 "i16x8.q15mulr_sat_s", 1048 "i16x8.all_true", 1049 "i16x8.bitmask", 1050 "i16x8.narrow_i32x4_s", 1051 "i16x8.narrow_i32x4_u", 1052 "i16x8.extend_low_i8x16_s", 1053 "i16x8.extend_high_i8x16_s", 1054 "i16x8.extend_low_i8x16_u", 1055 "i16x8.extend_high_i8x16_u", 1056 "i16x8.shl", 1057 "i16x8.shr_s", 1058 "i16x8.shr_u", 1059 "i16x8.add", 1060 "i16x8.add_sat_s", 1061 "i16x8.add_sat_u", 1062 "i16x8.sub", 1063 "i16x8.sub_sat_s", 1064 "i16x8.sub_sat_u", 1065 "f64x2.nearest", 1066 "i16x8.mul", 1067 "i16x8.min_s", 1068 "i16x8.min_u", 1069 "i16x8.max_s", 1070 "i16x8.max_u", 1071 undefined, 1072 "i16x8.avgr_u", 1073 "i16x8.extmul_low_i8x16_s", 1074 "i16x8.extmul_high_i8x16_s", 1075 "i16x8.extmul_low_i8x16_u", 1076 "i16x8.extmul_high_i8x16_u", 1077 "i32x4.abs", 1078 "i32x4.neg", 1079 undefined, 1080 "i32x4.all_true", 1081 "i32x4.bitmask", 1082 undefined, 1083 undefined, 1084 "i32x4.extend_low_i16x8_s", 1085 "i32x4.extend_high_i16x8_s", 1086 "i32x4.extend_low_i16x8_u", 1087 "i32x4.extend_high_i16x8_u", 1088 "i32x4.shl", 1089 "i32x4.shr_s", 1090 "i32x4.shr_u", 1091 "i32x4.add", 1092 undefined, 1093 undefined, 1094 "i32x4.sub", 1095 undefined, 1096 undefined, 1097 undefined, 1098 "i32x4.mul", 1099 "i32x4.min_s", 1100 "i32x4.min_u", 1101 "i32x4.max_s", 1102 "i32x4.max_u", 1103 "i32x4.dot_i16x8_s", 1104 undefined, 1105 "i32x4.extmul_low_i16x8_s", 1106 "i32x4.extmul_high_i16x8_s", 1107 "i32x4.extmul_low_i16x8_u", 1108 "i32x4.extmul_high_i16x8_u", 1109 "i64x2.abs", 1110 "i64x2.neg", 1111 undefined, 1112 "i64x2.all_true", 1113 "i64x2.bitmask", 1114 undefined, 1115 undefined, 1116 "i64x2.extend_low_i32x4_s", 1117 "i64x2.extend_high_i32x4_s", 1118 "i64x2.extend_low_i32x4_u", 1119 "i64x2.extend_high_i32x4_u", 1120 "i64x2.shl", 1121 "i64x2.shr_s", 1122 "i64x2.shr_u", 1123 "i64x2.add", 1124 undefined, 1125 undefined, 1126 "i64x2.sub", 1127 undefined, 1128 undefined, 1129 undefined, 1130 "i64x2.mul", 1131 "i64x2.eq", 1132 "i64x2.ne", 1133 "i64x2.lt_s", 1134 "i64x2.gt_s", 1135 "i64x2.le_s", 1136 "i64x2.ge_s", 1137 "i64x2.extmul_low_i32x4_s", 1138 "i64x2.extmul_high_i32x4_s", 1139 "i64x2.extmul_low_i32x4_u", 1140 "i64x2.extmul_high_i32x4_u", 1141 "f32x4.abs", 1142 "f32x4.neg", 1143 undefined, 1144 "f32x4.sqrt", 1145 "f32x4.add", 1146 "f32x4.sub", 1147 "f32x4.mul", 1148 "f32x4.div", 1149 "f32x4.min", 1150 "f32x4.max", 1151 "f32x4.pmin", 1152 "f32x4.pmax", 1153 "f64x2.abs", 1154 "f64x2.neg", 1155 undefined, 1156 "f64x2.sqrt", 1157 "f64x2.add", 1158 "f64x2.sub", 1159 "f64x2.mul", 1160 "f64x2.div", 1161 "f64x2.min", 1162 "f64x2.max", 1163 "f64x2.pmin", 1164 "f64x2.pmax", 1165 "i32x4.trunc_sat_f32x4_s", 1166 "i32x4.trunc_sat_f32x4_u", 1167 "f32x4.convert_i32x4_s", 1168 "f32x4.convert_i32x4_u", 1169 "i32x4.trunc_sat_f64x2_s_zero", 1170 "i32x4.trunc_sat_f64x2_u_zero", 1171 "f64x2.convert_low_i32x4_s", 1172 "f64x2.convert_low_i32x4_u", 1173 "i8x16.relaxed_swizzle", 1174 "i32x4.relaxed_trunc_f32x4_s", 1175 "i32x4.relaxed_trunc_f32x4_u", 1176 "i32x4.relaxed_trunc_f64x2_s_zero", 1177 "i32x4.relaxed_trunc_f64x2_u_zero", 1178 "f32x4.relaxed_madd", 1179 "f32x4.relaxed_nmadd", 1180 "f64x2.relaxed_madd", 1181 "f64x2.relaxed_nmadd", 1182 "i8x16.relaxed_laneselect", 1183 "i16x8.relaxed_laneselect", 1184 "i32x4.relaxed_laneselect", 1185 "i64x2.relaxed_laneselect", 1186 "f32x4.relaxed_min", 1187 "f32x4.relaxed_max", 1188 "f64x2.relaxed_min", 1189 "f64x2.relaxed_max", 1190 "i16x8.relaxed_q15mulr_s", 1191 "i16x8.relaxed_dot_i8x16_i7x16_s", 1192 "i32x4.relaxed_dot_i8x16_i7x16_add_s", 1193 ].forEach(function (s, i) { 1194 exports.OperatorCodeNames[0xfd000 | i] = s; 1195 }); 1196 [ 1197 "memory.atomic.notify", 1198 "memory.atomic.wait32", 1199 "memory.atomic.wait64", 1200 "atomic.fence", 1201 undefined, 1202 undefined, 1203 undefined, 1204 undefined, 1205 undefined, 1206 undefined, 1207 undefined, 1208 undefined, 1209 undefined, 1210 undefined, 1211 undefined, 1212 undefined, 1213 "i32.atomic.load", 1214 "i64.atomic.load", 1215 "i32.atomic.load8_u", 1216 "i32.atomic.load16_u", 1217 "i64.atomic.load8_u", 1218 "i64.atomic.load16_u", 1219 "i64.atomic.load32_u", 1220 "i32.atomic.store", 1221 "i64.atomic.store", 1222 "i32.atomic.store8", 1223 "i32.atomic.store16", 1224 "i64.atomic.store8", 1225 "i64.atomic.store16", 1226 "i64.atomic.store32", 1227 "i32.atomic.rmw.add", 1228 "i64.atomic.rmw.add", 1229 "i32.atomic.rmw8.add_u", 1230 "i32.atomic.rmw16.add_u", 1231 "i64.atomic.rmw8.add_u", 1232 "i64.atomic.rmw16.add_u", 1233 "i64.atomic.rmw32.add_u", 1234 "i32.atomic.rmw.sub", 1235 "i64.atomic.rmw.sub", 1236 "i32.atomic.rmw8.sub_u", 1237 "i32.atomic.rmw16.sub_u", 1238 "i64.atomic.rmw8.sub_u", 1239 "i64.atomic.rmw16.sub_u", 1240 "i64.atomic.rmw32.sub_u", 1241 "i32.atomic.rmw.and", 1242 "i64.atomic.rmw.and", 1243 "i32.atomic.rmw8.and_u", 1244 "i32.atomic.rmw16.and_u", 1245 "i64.atomic.rmw8.and_u", 1246 "i64.atomic.rmw16.and_u", 1247 "i64.atomic.rmw32.and_u", 1248 "i32.atomic.rmw.or", 1249 "i64.atomic.rmw.or", 1250 "i32.atomic.rmw8.or_u", 1251 "i32.atomic.rmw16.or_u", 1252 "i64.atomic.rmw8.or_u", 1253 "i64.atomic.rmw16.or_u", 1254 "i64.atomic.rmw32.or_u", 1255 "i32.atomic.rmw.xor", 1256 "i64.atomic.rmw.xor", 1257 "i32.atomic.rmw8.xor_u", 1258 "i32.atomic.rmw16.xor_u", 1259 "i64.atomic.rmw8.xor_u", 1260 "i64.atomic.rmw16.xor_u", 1261 "i64.atomic.rmw32.xor_u", 1262 "i32.atomic.rmw.xchg", 1263 "i64.atomic.rmw.xchg", 1264 "i32.atomic.rmw8.xchg_u", 1265 "i32.atomic.rmw16.xchg_u", 1266 "i64.atomic.rmw8.xchg_u", 1267 "i64.atomic.rmw16.xchg_u", 1268 "i64.atomic.rmw32.xchg_u", 1269 "i32.atomic.rmw.cmpxchg", 1270 "i64.atomic.rmw.cmpxchg", 1271 "i32.atomic.rmw8.cmpxchg_u", 1272 "i32.atomic.rmw16.cmpxchg_u", 1273 "i64.atomic.rmw8.cmpxchg_u", 1274 "i64.atomic.rmw16.cmpxchg_u", 1275 "i64.atomic.rmw32.cmpxchg_u", 1276 ].forEach(function (s, i) { 1277 exports.OperatorCodeNames[0xfe00 | i] = s; 1278 }); 1279 [ 1280 "struct.new", 1281 "struct.new_default", 1282 "struct.get", 1283 "struct.get_s", 1284 "struct.get_u", 1285 "struct.set", 1286 "array.new", 1287 "array.new_default", 1288 "array.new_fixed", 1289 "array.new_data", 1290 "array.new_elem", 1291 "array.get", 1292 "array.get_s", 1293 "array.get_u", 1294 "array.set", 1295 "array.len", 1296 "array.fill", 1297 "array.copy", 1298 "array.init_data", 1299 "array.init_elem", 1300 "ref.test", 1301 "ref.test", 1302 "ref.cast", 1303 "ref.cast", 1304 "br_on_cast", 1305 "br_on_cast_fail", 1306 "any.convert_extern", 1307 "extern.convert_any", 1308 "ref.i31", 1309 "i31.get_s", 1310 "i31.get_u", 1311 ].forEach(function (s, i) { 1312 exports.OperatorCodeNames[0xfb00 | i] = s; 1313 }); 1314 var ExternalKind; 1315 (function (ExternalKind) { 1316 ExternalKind[ExternalKind["Function"] = 0] = "Function"; 1317 ExternalKind[ExternalKind["Table"] = 1] = "Table"; 1318 ExternalKind[ExternalKind["Memory"] = 2] = "Memory"; 1319 ExternalKind[ExternalKind["Global"] = 3] = "Global"; 1320 ExternalKind[ExternalKind["Tag"] = 4] = "Tag"; 1321 })(ExternalKind = exports.ExternalKind || (exports.ExternalKind = {})); 1322 var TypeKind; 1323 (function (TypeKind) { 1324 TypeKind[TypeKind["unspecified"] = 0] = "unspecified"; 1325 TypeKind[TypeKind["i32"] = -1] = "i32"; 1326 TypeKind[TypeKind["i64"] = -2] = "i64"; 1327 TypeKind[TypeKind["f32"] = -3] = "f32"; 1328 TypeKind[TypeKind["f64"] = -4] = "f64"; 1329 TypeKind[TypeKind["v128"] = -5] = "v128"; 1330 TypeKind[TypeKind["i8"] = -8] = "i8"; 1331 TypeKind[TypeKind["i16"] = -9] = "i16"; 1332 TypeKind[TypeKind["nullexnref"] = -12] = "nullexnref"; 1333 TypeKind[TypeKind["nullfuncref"] = -13] = "nullfuncref"; 1334 TypeKind[TypeKind["nullref"] = -15] = "nullref"; 1335 TypeKind[TypeKind["nullexternref"] = -14] = "nullexternref"; 1336 TypeKind[TypeKind["funcref"] = -16] = "funcref"; 1337 TypeKind[TypeKind["externref"] = -17] = "externref"; 1338 TypeKind[TypeKind["anyref"] = -18] = "anyref"; 1339 TypeKind[TypeKind["eqref"] = -19] = "eqref"; 1340 TypeKind[TypeKind["i31ref"] = -20] = "i31ref"; 1341 TypeKind[TypeKind["structref"] = -21] = "structref"; 1342 TypeKind[TypeKind["arrayref"] = -22] = "arrayref"; 1343 TypeKind[TypeKind["exnref"] = -23] = "exnref"; 1344 TypeKind[TypeKind["ref"] = -28] = "ref"; 1345 TypeKind[TypeKind["ref_null"] = -29] = "ref_null"; 1346 TypeKind[TypeKind["func"] = -32] = "func"; 1347 TypeKind[TypeKind["struct"] = -33] = "struct"; 1348 TypeKind[TypeKind["array"] = -34] = "array"; 1349 TypeKind[TypeKind["subtype"] = -48] = "subtype"; 1350 TypeKind[TypeKind["subtype_final"] = -49] = "subtype_final"; 1351 TypeKind[TypeKind["rec_group"] = -50] = "rec_group"; 1352 TypeKind[TypeKind["empty_block_type"] = -64] = "empty_block_type"; 1353 })(TypeKind = exports.TypeKind || (exports.TypeKind = {})); 1354 var FieldDef = /** @class */ (function () { 1355 function FieldDef() { 1356 } 1357 return FieldDef; 1358 }()); 1359 exports.FieldDef = FieldDef; 1360 var FuncDef = /** @class */ (function () { 1361 function FuncDef() { 1362 } 1363 return FuncDef; 1364 }()); 1365 exports.FuncDef = FuncDef; 1366 var Type = exports.Type = /** @class */ (function () { 1367 function Type(code) { 1368 this.code = code; 1369 } 1370 Object.defineProperty(Type.prototype, "isIndex", { 1371 get: function () { 1372 return this.code >= 0; 1373 }, 1374 enumerable: false, 1375 configurable: true 1376 }); 1377 Object.defineProperty(Type.prototype, "kind", { 1378 get: function () { 1379 return this.code >= 0 ? 0 /* TypeKind.unspecified */ : this.code; 1380 }, 1381 enumerable: false, 1382 configurable: true 1383 }); 1384 Object.defineProperty(Type.prototype, "index", { 1385 get: function () { 1386 return this.code < 0 ? -1 : this.code; 1387 }, 1388 enumerable: false, 1389 configurable: true 1390 }); 1391 // Convenience singletons. 1392 Type.funcref = new Type(-16 /* TypeKind.funcref */); 1393 Type.externref = new Type(-17 /* TypeKind.externref */); 1394 Type.exnref = new Type(-23 /* TypeKind.exnref */); 1395 return Type; 1396 }()); 1397 var RefType = /** @class */ (function (_super) { 1398 __extends(RefType, _super); 1399 function RefType(kind, ref_index) { 1400 var _this = this; 1401 if (kind != -28 /* TypeKind.ref */ && kind !== -29 /* TypeKind.ref_null */) { 1402 throw new Error("Unexpected type kind: ".concat(kind, "}")); 1403 } 1404 _this = _super.call(this, kind) || this; 1405 _this.ref_index = ref_index; 1406 return _this; 1407 } 1408 Object.defineProperty(RefType.prototype, "isNullable", { 1409 get: function () { 1410 return this.kind == -29 /* TypeKind.ref_null */; 1411 }, 1412 enumerable: false, 1413 configurable: true 1414 }); 1415 return RefType; 1416 }(Type)); 1417 exports.RefType = RefType; 1418 var CatchHandlerKind; 1419 (function (CatchHandlerKind) { 1420 CatchHandlerKind[CatchHandlerKind["Catch"] = 0] = "Catch"; 1421 CatchHandlerKind[CatchHandlerKind["CatchRef"] = 1] = "CatchRef"; 1422 CatchHandlerKind[CatchHandlerKind["CatchAll"] = 2] = "CatchAll"; 1423 CatchHandlerKind[CatchHandlerKind["CatchAllRef"] = 3] = "CatchAllRef"; 1424 })(CatchHandlerKind = exports.CatchHandlerKind || (exports.CatchHandlerKind = {})); 1425 var CatchHandler = /** @class */ (function () { 1426 function CatchHandler() { 1427 } 1428 return CatchHandler; 1429 }()); 1430 exports.CatchHandler = CatchHandler; 1431 var RelocType; 1432 (function (RelocType) { 1433 RelocType[RelocType["FunctionIndex_LEB"] = 0] = "FunctionIndex_LEB"; 1434 RelocType[RelocType["TableIndex_SLEB"] = 1] = "TableIndex_SLEB"; 1435 RelocType[RelocType["TableIndex_I32"] = 2] = "TableIndex_I32"; 1436 RelocType[RelocType["GlobalAddr_LEB"] = 3] = "GlobalAddr_LEB"; 1437 RelocType[RelocType["GlobalAddr_SLEB"] = 4] = "GlobalAddr_SLEB"; 1438 RelocType[RelocType["GlobalAddr_I32"] = 5] = "GlobalAddr_I32"; 1439 RelocType[RelocType["TypeIndex_LEB"] = 6] = "TypeIndex_LEB"; 1440 RelocType[RelocType["GlobalIndex_LEB"] = 7] = "GlobalIndex_LEB"; 1441 })(RelocType = exports.RelocType || (exports.RelocType = {})); 1442 var LinkingType; 1443 (function (LinkingType) { 1444 LinkingType[LinkingType["StackPointer"] = 1] = "StackPointer"; 1445 })(LinkingType = exports.LinkingType || (exports.LinkingType = {})); 1446 var NameType; 1447 (function (NameType) { 1448 NameType[NameType["Module"] = 0] = "Module"; 1449 NameType[NameType["Function"] = 1] = "Function"; 1450 NameType[NameType["Local"] = 2] = "Local"; 1451 NameType[NameType["Label"] = 3] = "Label"; 1452 NameType[NameType["Type"] = 4] = "Type"; 1453 NameType[NameType["Table"] = 5] = "Table"; 1454 NameType[NameType["Memory"] = 6] = "Memory"; 1455 NameType[NameType["Global"] = 7] = "Global"; 1456 NameType[NameType["Elem"] = 8] = "Elem"; 1457 NameType[NameType["Data"] = 9] = "Data"; 1458 NameType[NameType["Field"] = 10] = "Field"; 1459 NameType[NameType["Tag"] = 11] = "Tag"; 1460 })(NameType = exports.NameType || (exports.NameType = {})); 1461 var BinaryReaderState; 1462 (function (BinaryReaderState) { 1463 BinaryReaderState[BinaryReaderState["ERROR"] = -1] = "ERROR"; 1464 BinaryReaderState[BinaryReaderState["INITIAL"] = 0] = "INITIAL"; 1465 BinaryReaderState[BinaryReaderState["BEGIN_WASM"] = 1] = "BEGIN_WASM"; 1466 BinaryReaderState[BinaryReaderState["END_WASM"] = 2] = "END_WASM"; 1467 BinaryReaderState[BinaryReaderState["BEGIN_SECTION"] = 3] = "BEGIN_SECTION"; 1468 BinaryReaderState[BinaryReaderState["END_SECTION"] = 4] = "END_SECTION"; 1469 BinaryReaderState[BinaryReaderState["SKIPPING_SECTION"] = 5] = "SKIPPING_SECTION"; 1470 BinaryReaderState[BinaryReaderState["READING_SECTION_RAW_DATA"] = 6] = "READING_SECTION_RAW_DATA"; 1471 BinaryReaderState[BinaryReaderState["SECTION_RAW_DATA"] = 7] = "SECTION_RAW_DATA"; 1472 BinaryReaderState[BinaryReaderState["TYPE_SECTION_ENTRY"] = 11] = "TYPE_SECTION_ENTRY"; 1473 BinaryReaderState[BinaryReaderState["IMPORT_SECTION_ENTRY"] = 12] = "IMPORT_SECTION_ENTRY"; 1474 BinaryReaderState[BinaryReaderState["FUNCTION_SECTION_ENTRY"] = 13] = "FUNCTION_SECTION_ENTRY"; 1475 BinaryReaderState[BinaryReaderState["TABLE_SECTION_ENTRY"] = 14] = "TABLE_SECTION_ENTRY"; 1476 BinaryReaderState[BinaryReaderState["MEMORY_SECTION_ENTRY"] = 15] = "MEMORY_SECTION_ENTRY"; 1477 BinaryReaderState[BinaryReaderState["GLOBAL_SECTION_ENTRY"] = 16] = "GLOBAL_SECTION_ENTRY"; 1478 BinaryReaderState[BinaryReaderState["EXPORT_SECTION_ENTRY"] = 17] = "EXPORT_SECTION_ENTRY"; 1479 BinaryReaderState[BinaryReaderState["DATA_SECTION_ENTRY"] = 18] = "DATA_SECTION_ENTRY"; 1480 BinaryReaderState[BinaryReaderState["NAME_SECTION_ENTRY"] = 19] = "NAME_SECTION_ENTRY"; 1481 BinaryReaderState[BinaryReaderState["ELEMENT_SECTION_ENTRY"] = 20] = "ELEMENT_SECTION_ENTRY"; 1482 BinaryReaderState[BinaryReaderState["LINKING_SECTION_ENTRY"] = 21] = "LINKING_SECTION_ENTRY"; 1483 BinaryReaderState[BinaryReaderState["START_SECTION_ENTRY"] = 22] = "START_SECTION_ENTRY"; 1484 BinaryReaderState[BinaryReaderState["TAG_SECTION_ENTRY"] = 23] = "TAG_SECTION_ENTRY"; 1485 BinaryReaderState[BinaryReaderState["BEGIN_INIT_EXPRESSION_BODY"] = 25] = "BEGIN_INIT_EXPRESSION_BODY"; 1486 BinaryReaderState[BinaryReaderState["INIT_EXPRESSION_OPERATOR"] = 26] = "INIT_EXPRESSION_OPERATOR"; 1487 BinaryReaderState[BinaryReaderState["END_INIT_EXPRESSION_BODY"] = 27] = "END_INIT_EXPRESSION_BODY"; 1488 BinaryReaderState[BinaryReaderState["BEGIN_FUNCTION_BODY"] = 28] = "BEGIN_FUNCTION_BODY"; 1489 BinaryReaderState[BinaryReaderState["READING_FUNCTION_HEADER"] = 29] = "READING_FUNCTION_HEADER"; 1490 BinaryReaderState[BinaryReaderState["CODE_OPERATOR"] = 30] = "CODE_OPERATOR"; 1491 BinaryReaderState[BinaryReaderState["END_FUNCTION_BODY"] = 31] = "END_FUNCTION_BODY"; 1492 BinaryReaderState[BinaryReaderState["SKIPPING_FUNCTION_BODY"] = 32] = "SKIPPING_FUNCTION_BODY"; 1493 BinaryReaderState[BinaryReaderState["BEGIN_ELEMENT_SECTION_ENTRY"] = 33] = "BEGIN_ELEMENT_SECTION_ENTRY"; 1494 BinaryReaderState[BinaryReaderState["ELEMENT_SECTION_ENTRY_BODY"] = 34] = "ELEMENT_SECTION_ENTRY_BODY"; 1495 BinaryReaderState[BinaryReaderState["END_ELEMENT_SECTION_ENTRY"] = 35] = "END_ELEMENT_SECTION_ENTRY"; 1496 BinaryReaderState[BinaryReaderState["BEGIN_DATA_SECTION_ENTRY"] = 36] = "BEGIN_DATA_SECTION_ENTRY"; 1497 BinaryReaderState[BinaryReaderState["DATA_SECTION_ENTRY_BODY"] = 37] = "DATA_SECTION_ENTRY_BODY"; 1498 BinaryReaderState[BinaryReaderState["END_DATA_SECTION_ENTRY"] = 38] = "END_DATA_SECTION_ENTRY"; 1499 BinaryReaderState[BinaryReaderState["BEGIN_GLOBAL_SECTION_ENTRY"] = 39] = "BEGIN_GLOBAL_SECTION_ENTRY"; 1500 BinaryReaderState[BinaryReaderState["END_GLOBAL_SECTION_ENTRY"] = 40] = "END_GLOBAL_SECTION_ENTRY"; 1501 BinaryReaderState[BinaryReaderState["RELOC_SECTION_HEADER"] = 41] = "RELOC_SECTION_HEADER"; 1502 BinaryReaderState[BinaryReaderState["RELOC_SECTION_ENTRY"] = 42] = "RELOC_SECTION_ENTRY"; 1503 BinaryReaderState[BinaryReaderState["SOURCE_MAPPING_URL"] = 43] = "SOURCE_MAPPING_URL"; 1504 BinaryReaderState[BinaryReaderState["BEGIN_OFFSET_EXPRESSION_BODY"] = 44] = "BEGIN_OFFSET_EXPRESSION_BODY"; 1505 BinaryReaderState[BinaryReaderState["OFFSET_EXPRESSION_OPERATOR"] = 45] = "OFFSET_EXPRESSION_OPERATOR"; 1506 BinaryReaderState[BinaryReaderState["END_OFFSET_EXPRESSION_BODY"] = 46] = "END_OFFSET_EXPRESSION_BODY"; 1507 BinaryReaderState[BinaryReaderState["BEGIN_REC_GROUP"] = 47] = "BEGIN_REC_GROUP"; 1508 BinaryReaderState[BinaryReaderState["END_REC_GROUP"] = 48] = "END_REC_GROUP"; 1509 BinaryReaderState[BinaryReaderState["DATA_COUNT_SECTION_ENTRY"] = 49] = "DATA_COUNT_SECTION_ENTRY"; 1510 })(BinaryReaderState = exports.BinaryReaderState || (exports.BinaryReaderState = {})); 1511 var DataSegmentType; 1512 (function (DataSegmentType) { 1513 DataSegmentType[DataSegmentType["Active"] = 0] = "Active"; 1514 DataSegmentType[DataSegmentType["Passive"] = 1] = "Passive"; 1515 DataSegmentType[DataSegmentType["ActiveWithMemoryIndex"] = 2] = "ActiveWithMemoryIndex"; 1516 })(DataSegmentType || (DataSegmentType = {})); 1517 function isActiveDataSegmentType(segmentType) { 1518 switch (segmentType) { 1519 case 0 /* DataSegmentType.Active */: 1520 case 2 /* DataSegmentType.ActiveWithMemoryIndex */: 1521 return true; 1522 default: 1523 return false; 1524 } 1525 } 1526 var DataMode; 1527 (function (DataMode) { 1528 DataMode[DataMode["Active"] = 0] = "Active"; 1529 DataMode[DataMode["Passive"] = 1] = "Passive"; 1530 })(DataMode = exports.DataMode || (exports.DataMode = {})); 1531 var ElementSegmentType; 1532 (function (ElementSegmentType) { 1533 ElementSegmentType[ElementSegmentType["LegacyActiveFuncrefExternval"] = 0] = "LegacyActiveFuncrefExternval"; 1534 ElementSegmentType[ElementSegmentType["PassiveExternval"] = 1] = "PassiveExternval"; 1535 ElementSegmentType[ElementSegmentType["ActiveExternval"] = 2] = "ActiveExternval"; 1536 ElementSegmentType[ElementSegmentType["DeclaredExternval"] = 3] = "DeclaredExternval"; 1537 ElementSegmentType[ElementSegmentType["LegacyActiveFuncrefElemexpr"] = 4] = "LegacyActiveFuncrefElemexpr"; 1538 ElementSegmentType[ElementSegmentType["PassiveElemexpr"] = 5] = "PassiveElemexpr"; 1539 ElementSegmentType[ElementSegmentType["ActiveElemexpr"] = 6] = "ActiveElemexpr"; 1540 ElementSegmentType[ElementSegmentType["DeclaredElemexpr"] = 7] = "DeclaredElemexpr"; 1541 })(ElementSegmentType || (ElementSegmentType = {})); 1542 function isActiveElementSegmentType(segmentType) { 1543 switch (segmentType) { 1544 case 0 /* ElementSegmentType.LegacyActiveFuncrefExternval */: 1545 case 2 /* ElementSegmentType.ActiveExternval */: 1546 case 4 /* ElementSegmentType.LegacyActiveFuncrefElemexpr */: 1547 case 6 /* ElementSegmentType.ActiveElemexpr */: 1548 return true; 1549 default: 1550 return false; 1551 } 1552 } 1553 function isExternvalElementSegmentType(segmentType) { 1554 switch (segmentType) { 1555 case 0 /* ElementSegmentType.LegacyActiveFuncrefExternval */: 1556 case 1 /* ElementSegmentType.PassiveExternval */: 1557 case 2 /* ElementSegmentType.ActiveExternval */: 1558 case 3 /* ElementSegmentType.DeclaredExternval */: 1559 return true; 1560 default: 1561 return false; 1562 } 1563 } 1564 var ElementMode; 1565 (function (ElementMode) { 1566 ElementMode[ElementMode["Active"] = 0] = "Active"; 1567 ElementMode[ElementMode["Passive"] = 1] = "Passive"; 1568 ElementMode[ElementMode["Declarative"] = 2] = "Declarative"; 1569 })(ElementMode = exports.ElementMode || (exports.ElementMode = {})); 1570 var DataRange = /** @class */ (function () { 1571 function DataRange(start, end) { 1572 this.start = start; 1573 this.end = end; 1574 } 1575 DataRange.prototype.offset = function (delta) { 1576 this.start += delta; 1577 this.end += delta; 1578 }; 1579 return DataRange; 1580 }()); 1581 var TagAttribute; 1582 (function (TagAttribute) { 1583 TagAttribute[TagAttribute["Exception"] = 0] = "Exception"; 1584 })(TagAttribute = exports.TagAttribute || (exports.TagAttribute = {})); 1585 var Int64 = /** @class */ (function () { 1586 function Int64(data) { 1587 this._data = data || new Uint8Array(8); 1588 } 1589 Int64.prototype.toInt32 = function () { 1590 return (this._data[0] | 1591 (this._data[1] << 8) | 1592 (this._data[2] << 16) | 1593 (this._data[3] << 24)); 1594 }; 1595 Int64.prototype.toDouble = function () { 1596 var power = 1; 1597 var sum; 1598 if (this._data[7] & 0x80) { 1599 sum = -1; 1600 for (var i = 0; i < 8; i++, power *= 256) 1601 sum -= power * (0xff ^ this._data[i]); 1602 } 1603 else { 1604 sum = 0; 1605 for (var i = 0; i < 8; i++, power *= 256) 1606 sum += power * this._data[i]; 1607 } 1608 return sum; 1609 }; 1610 Int64.prototype.toString = function () { 1611 var low = (this._data[0] | 1612 (this._data[1] << 8) | 1613 (this._data[2] << 16) | 1614 (this._data[3] << 24)) >>> 1615 0; 1616 var high = (this._data[4] | 1617 (this._data[5] << 8) | 1618 (this._data[6] << 16) | 1619 (this._data[7] << 24)) >>> 1620 0; 1621 if (low === 0 && high === 0) { 1622 return "0"; 1623 } 1624 var sign = false; 1625 if (high >> 31) { 1626 high = 4294967296 - high; 1627 if (low > 0) { 1628 high--; 1629 low = 4294967296 - low; 1630 } 1631 sign = true; 1632 } 1633 var buf = []; 1634 while (high > 0) { 1635 var t = (high % 10) * 4294967296 + low; 1636 high = Math.floor(high / 10); 1637 buf.unshift((t % 10).toString()); 1638 low = Math.floor(t / 10); 1639 } 1640 while (low > 0) { 1641 buf.unshift((low % 10).toString()); 1642 low = Math.floor(low / 10); 1643 } 1644 if (sign) 1645 buf.unshift("-"); 1646 return buf.join(""); 1647 }; 1648 Object.defineProperty(Int64.prototype, "data", { 1649 get: function () { 1650 return this._data; 1651 }, 1652 enumerable: false, 1653 configurable: true 1654 }); 1655 return Int64; 1656 }()); 1657 exports.Int64 = Int64; 1658 var BinaryReader = /** @class */ (function () { 1659 function BinaryReader() { 1660 this._data = null; 1661 this._pos = 0; 1662 this._length = 0; 1663 this._eof = false; 1664 this.state = 0 /* BinaryReaderState.INITIAL */; 1665 this.result = null; 1666 this.error = null; 1667 this._sectionEntriesLeft = 0; 1668 this._sectionId = -1 /* SectionCode.Unknown */; 1669 this._sectionRange = null; 1670 this._functionRange = null; 1671 this._segmentType = 0; 1672 this._segmentEntriesLeft = 0; 1673 this._recGroupTypesLeft = 0; 1674 } 1675 Object.defineProperty(BinaryReader.prototype, "data", { 1676 get: function () { 1677 return this._data; 1678 }, 1679 enumerable: false, 1680 configurable: true 1681 }); 1682 Object.defineProperty(BinaryReader.prototype, "position", { 1683 get: function () { 1684 return this._pos; 1685 }, 1686 enumerable: false, 1687 configurable: true 1688 }); 1689 Object.defineProperty(BinaryReader.prototype, "length", { 1690 get: function () { 1691 return this._length; 1692 }, 1693 enumerable: false, 1694 configurable: true 1695 }); 1696 BinaryReader.prototype.setData = function (buffer, pos, length, eof) { 1697 var posDelta = pos - this._pos; 1698 this._data = new Uint8Array(buffer); 1699 this._pos = pos; 1700 this._length = length; 1701 this._eof = eof === undefined ? true : eof; 1702 if (this._sectionRange) 1703 this._sectionRange.offset(posDelta); 1704 if (this._functionRange) 1705 this._functionRange.offset(posDelta); 1706 }; 1707 BinaryReader.prototype.hasBytes = function (n) { 1708 return this._pos + n <= this._length; 1709 }; 1710 BinaryReader.prototype.hasMoreBytes = function () { 1711 return this.hasBytes(1); 1712 }; 1713 BinaryReader.prototype.readUint8 = function () { 1714 return this._data[this._pos++]; 1715 }; 1716 BinaryReader.prototype.readInt32 = function () { 1717 var b1 = this._data[this._pos++]; 1718 var b2 = this._data[this._pos++]; 1719 var b3 = this._data[this._pos++]; 1720 var b4 = this._data[this._pos++]; 1721 return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24); 1722 }; 1723 BinaryReader.prototype.readUint32 = function () { 1724 return this.readInt32(); 1725 }; 1726 BinaryReader.prototype.peekInt32 = function () { 1727 var b1 = this._data[this._pos]; 1728 var b2 = this._data[this._pos + 1]; 1729 var b3 = this._data[this._pos + 2]; 1730 var b4 = this._data[this._pos + 3]; 1731 return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24); 1732 }; 1733 BinaryReader.prototype.hasVarIntBytes = function () { 1734 var pos = this._pos; 1735 while (pos < this._length) { 1736 if ((this._data[pos++] & 0x80) == 0) 1737 return true; 1738 } 1739 return false; 1740 }; 1741 BinaryReader.prototype.readVarUint1 = function () { 1742 return this.readUint8(); 1743 }; 1744 BinaryReader.prototype.readVarInt7 = function () { 1745 return (this.readUint8() << 25) >> 25; 1746 }; 1747 BinaryReader.prototype.readVarUint7 = function () { 1748 return this.readUint8(); 1749 }; 1750 BinaryReader.prototype.readVarInt32 = function () { 1751 var result = 0; 1752 var shift = 0; 1753 while (true) { 1754 var byte = this.readUint8(); 1755 result |= (byte & 0x7f) << shift; 1756 shift += 7; 1757 if ((byte & 0x80) === 0) 1758 break; 1759 } 1760 if (shift >= 32) 1761 return result; 1762 var ashift = 32 - shift; 1763 return (result << ashift) >> ashift; 1764 }; 1765 BinaryReader.prototype.readVarUint32 = function () { 1766 var result = 0; 1767 var shift = 0; 1768 while (true) { 1769 var byte = this.readUint8(); 1770 result |= (byte & 0x7f) << shift; 1771 shift += 7; 1772 if ((byte & 0x80) === 0) 1773 break; 1774 } 1775 return result >>> 0; 1776 }; 1777 BinaryReader.prototype.readVarInt64 = function () { 1778 var result = new Uint8Array(8); 1779 var i = 0; 1780 var c = 0; 1781 var shift = 0; 1782 while (true) { 1783 var byte = this.readUint8(); 1784 c |= (byte & 0x7f) << shift; 1785 shift += 7; 1786 if (shift > 8) { 1787 result[i++] = c & 0xff; 1788 c >>= 8; 1789 shift -= 8; 1790 } 1791 if ((byte & 0x80) === 0) 1792 break; 1793 } 1794 var ashift = 32 - shift; 1795 c = (c << ashift) >> ashift; 1796 while (i < 8) { 1797 result[i++] = c & 0xff; 1798 c >>= 8; 1799 } 1800 return new Int64(result); 1801 }; 1802 // Reads any "s33" (signed 33-bit integer) value correctly; no guarantees 1803 // outside that range. 1804 BinaryReader.prototype.readHeapType = function () { 1805 var lsb = this.readUint8(); 1806 if (lsb & 0x80) { 1807 // Has more data than one byte. 1808 var tail = this.readVarInt32(); 1809 return (tail - 1) * 128 + lsb; 1810 } 1811 else { 1812 return (lsb << 25) >> 25; 1813 } 1814 }; 1815 BinaryReader.prototype.readType = function () { 1816 var kind = this.readHeapType(); 1817 if (kind >= 0) { 1818 return new Type(kind); 1819 } 1820 switch (kind) { 1821 case -29 /* TypeKind.ref_null */: 1822 case -28 /* TypeKind.ref */: 1823 var index = this.readHeapType(); 1824 return new RefType(kind, index); 1825 case -1 /* TypeKind.i32 */: 1826 case -2 /* TypeKind.i64 */: 1827 case -3 /* TypeKind.f32 */: 1828 case -4 /* TypeKind.f64 */: 1829 case -5 /* TypeKind.v128 */: 1830 case -8 /* TypeKind.i8 */: 1831 case -9 /* TypeKind.i16 */: 1832 case -16 /* TypeKind.funcref */: 1833 case -17 /* TypeKind.externref */: 1834 case -23 /* TypeKind.exnref */: 1835 case -18 /* TypeKind.anyref */: 1836 case -19 /* TypeKind.eqref */: 1837 case -20 /* TypeKind.i31ref */: 1838 case -14 /* TypeKind.nullexternref */: 1839 case -13 /* TypeKind.nullfuncref */: 1840 case -12 /* TypeKind.nullexnref */: 1841 case -21 /* TypeKind.structref */: 1842 case -22 /* TypeKind.arrayref */: 1843 case -15 /* TypeKind.nullref */: 1844 case -32 /* TypeKind.func */: 1845 case -33 /* TypeKind.struct */: 1846 case -34 /* TypeKind.array */: 1847 case -48 /* TypeKind.subtype */: 1848 case -50 /* TypeKind.rec_group */: 1849 case -49 /* TypeKind.subtype_final */: 1850 case -64 /* TypeKind.empty_block_type */: 1851 return new Type(kind); 1852 default: 1853 throw new Error("Unknown type kind: ".concat(kind)); 1854 } 1855 }; 1856 BinaryReader.prototype.readStringBytes = function () { 1857 var length = this.readVarUint32(); 1858 return this.readBytes(length); 1859 }; 1860 BinaryReader.prototype.readBytes = function (length) { 1861 var result = this._data.subarray(this._pos, this._pos + length); 1862 this._pos += length; 1863 return new Uint8Array(result); // making a clone of the data 1864 }; 1865 BinaryReader.prototype.skipBytes = function (length) { 1866 this._pos += length; 1867 }; 1868 BinaryReader.prototype.hasStringBytes = function () { 1869 if (!this.hasVarIntBytes()) 1870 return false; 1871 var pos = this._pos; 1872 var length = this.readVarUint32(); 1873 var result = this.hasBytes(length); 1874 this._pos = pos; 1875 return result; 1876 }; 1877 BinaryReader.prototype.hasSectionPayload = function () { 1878 return this.hasBytes(this._sectionRange.end - this._pos); 1879 }; 1880 BinaryReader.prototype.readFuncType = function () { 1881 var paramCount = this.readVarUint32(); 1882 var paramTypes = new Array(paramCount); 1883 for (var i = 0; i < paramCount; i++) 1884 paramTypes[i] = this.readType(); 1885 var returnCount = this.readVarUint32(); 1886 var returnTypes = new Array(returnCount); 1887 for (var i = 0; i < returnCount; i++) 1888 returnTypes[i] = this.readType(); 1889 return { 1890 form: -32 /* TypeKind.func */, 1891 params: paramTypes, 1892 returns: returnTypes, 1893 }; 1894 }; 1895 BinaryReader.prototype.readBaseType = function () { 1896 var form = this.readVarInt7(); 1897 switch (form) { 1898 case -32 /* TypeKind.func */: 1899 return this.readFuncType(); 1900 case -33 /* TypeKind.struct */: 1901 return this.readStructType(); 1902 case -34 /* TypeKind.array */: 1903 return this.readArrayType(); 1904 default: 1905 throw new Error("Unknown type kind: ".concat(form)); 1906 } 1907 }; 1908 BinaryReader.prototype.readSubtype = function (final) { 1909 var supertypesCount = this.readVarUint32(); 1910 var supertypes = new Array(supertypesCount); 1911 for (var i = 0; i < supertypesCount; i++) { 1912 supertypes[i] = this.readHeapType(); 1913 } 1914 var result = this.readBaseType(); 1915 result.supertypes = supertypes; 1916 result.final = final; 1917 return result; 1918 }; 1919 BinaryReader.prototype.readStructType = function () { 1920 var fieldCount = this.readVarUint32(); 1921 var fieldTypes = new Array(fieldCount); 1922 var fieldMutabilities = new Array(fieldCount); 1923 for (var i = 0; i < fieldCount; i++) { 1924 fieldTypes[i] = this.readType(); 1925 fieldMutabilities[i] = !!this.readVarUint1(); 1926 } 1927 return { 1928 form: -33 /* TypeKind.struct */, 1929 fields: fieldTypes, 1930 mutabilities: fieldMutabilities, 1931 }; 1932 }; 1933 BinaryReader.prototype.readArrayType = function () { 1934 var elementType = this.readType(); 1935 var mutability = !!this.readVarUint1(); 1936 return { 1937 form: -34 /* TypeKind.array */, 1938 elementType: elementType, 1939 mutability: mutability, 1940 }; 1941 }; 1942 BinaryReader.prototype.readResizableLimits = function (maxPresent) { 1943 var initial = this.readVarUint32(); 1944 var maximum; 1945 if (maxPresent) { 1946 maximum = this.readVarUint32(); 1947 } 1948 return { initial: initial, maximum: maximum }; 1949 }; 1950 BinaryReader.prototype.readTableType = function () { 1951 var elementType = this.readType(); 1952 var flags = this.readVarUint32(); 1953 var limits = this.readResizableLimits(!!(flags & 0x01)); 1954 return { elementType: elementType, limits: limits }; 1955 }; 1956 BinaryReader.prototype.readMemoryType = function () { 1957 var flags = this.readVarUint32(); 1958 var shared = !!(flags & 0x02); 1959 return { 1960 limits: this.readResizableLimits(!!(flags & 0x01)), 1961 shared: shared, 1962 }; 1963 }; 1964 BinaryReader.prototype.readGlobalType = function () { 1965 if (!this.hasVarIntBytes()) { 1966 return null; 1967 } 1968 var pos = this._pos; 1969 var contentType = this.readType(); 1970 if (!this.hasVarIntBytes()) { 1971 this._pos = pos; 1972 return null; 1973 } 1974 var mutability = this.readVarUint1(); 1975 return { contentType: contentType, mutability: mutability }; 1976 }; 1977 BinaryReader.prototype.readTagType = function () { 1978 var attribute = this.readVarUint32(); 1979 var typeIndex = this.readVarUint32(); 1980 return { 1981 attribute: attribute, 1982 typeIndex: typeIndex, 1983 }; 1984 }; 1985 BinaryReader.prototype.readTypeEntryCommon = function (form) { 1986 switch (form) { 1987 case -32 /* TypeKind.func */: 1988 this.result = this.readFuncType(); 1989 break; 1990 case -48 /* TypeKind.subtype */: 1991 this.result = this.readSubtype(false); 1992 break; 1993 case -49 /* TypeKind.subtype_final */: 1994 this.result = this.readSubtype(true); 1995 break; 1996 case -33 /* TypeKind.struct */: 1997 this.result = this.readStructType(); 1998 break; 1999 case -34 /* TypeKind.array */: 2000 this.result = this.readArrayType(); 2001 break; 2002 case -1 /* TypeKind.i32 */: 2003 case -2 /* TypeKind.i64 */: 2004 case -3 /* TypeKind.f32 */: 2005 case -4 /* TypeKind.f64 */: 2006 case -5 /* TypeKind.v128 */: 2007 case -8 /* TypeKind.i8 */: 2008 case -9 /* TypeKind.i16 */: 2009 case -16 /* TypeKind.funcref */: 2010 case -17 /* TypeKind.externref */: 2011 case -23 /* TypeKind.exnref */: 2012 case -18 /* TypeKind.anyref */: 2013 case -19 /* TypeKind.eqref */: 2014 this.result = { 2015 form: form, 2016 }; 2017 break; 2018 default: 2019 throw new Error("Unknown type kind: ".concat(form)); 2020 } 2021 }; 2022 BinaryReader.prototype.readTypeEntry = function () { 2023 if (this._sectionEntriesLeft === 0) { 2024 this.skipSection(); 2025 return this.read(); 2026 } 2027 var form = this.readVarInt7(); 2028 if (form == -50 /* TypeKind.rec_group */) { 2029 this.state = 47 /* BinaryReaderState.BEGIN_REC_GROUP */; 2030 this.result = null; 2031 this._recGroupTypesLeft = this.readVarUint32(); 2032 } 2033 else { 2034 this.state = 11 /* BinaryReaderState.TYPE_SECTION_ENTRY */; 2035 this.readTypeEntryCommon(form); 2036 this._sectionEntriesLeft--; 2037 } 2038 return true; 2039 }; 2040 BinaryReader.prototype.readRecGroupEntry = function () { 2041 if (this._recGroupTypesLeft === 0) { 2042 this.state = 48 /* BinaryReaderState.END_REC_GROUP */; 2043 this.result = null; 2044 this._sectionEntriesLeft--; 2045 this._recGroupTypesLeft = -1; 2046 return true; 2047 } 2048 this.state = 11 /* BinaryReaderState.TYPE_SECTION_ENTRY */; 2049 var form = this.readVarInt7(); 2050 this.readTypeEntryCommon(form); 2051 this._recGroupTypesLeft--; 2052 return true; 2053 }; 2054 BinaryReader.prototype.readImportEntry = function () { 2055 if (this._sectionEntriesLeft === 0) { 2056 this.skipSection(); 2057 return this.read(); 2058 } 2059 this.state = 12 /* BinaryReaderState.IMPORT_SECTION_ENTRY */; 2060 var module = this.readStringBytes(); 2061 var field = this.readStringBytes(); 2062 var kind = this.readUint8(); 2063 var funcTypeIndex; 2064 var type; 2065 switch (kind) { 2066 case 0 /* ExternalKind.Function */: 2067 funcTypeIndex = this.readVarUint32(); 2068 break; 2069 case 1 /* ExternalKind.Table */: 2070 type = this.readTableType(); 2071 break; 2072 case 2 /* ExternalKind.Memory */: 2073 type = this.readMemoryType(); 2074 break; 2075 case 3 /* ExternalKind.Global */: 2076 type = this.readGlobalType(); 2077 break; 2078 case 4 /* ExternalKind.Tag */: 2079 type = this.readTagType(); 2080 break; 2081 } 2082 this.result = { 2083 module: module, 2084 field: field, 2085 kind: kind, 2086 funcTypeIndex: funcTypeIndex, 2087 type: type, 2088 }; 2089 this._sectionEntriesLeft--; 2090 return true; 2091 }; 2092 BinaryReader.prototype.readExportEntry = function () { 2093 if (this._sectionEntriesLeft === 0) { 2094 this.skipSection(); 2095 return this.read(); 2096 } 2097 var field = this.readStringBytes(); 2098 var kind = this.readUint8(); 2099 var index = this.readVarUint32(); 2100 this.state = 17 /* BinaryReaderState.EXPORT_SECTION_ENTRY */; 2101 this.result = { field: field, kind: kind, index: index }; 2102 this._sectionEntriesLeft--; 2103 return true; 2104 }; 2105 BinaryReader.prototype.readFunctionEntry = function () { 2106 if (this._sectionEntriesLeft === 0) { 2107 this.skipSection(); 2108 return this.read(); 2109 } 2110 var typeIndex = this.readVarUint32(); 2111 this.state = 13 /* BinaryReaderState.FUNCTION_SECTION_ENTRY */; 2112 this.result = { typeIndex: typeIndex }; 2113 this._sectionEntriesLeft--; 2114 return true; 2115 }; 2116 BinaryReader.prototype.readTableEntry = function () { 2117 if (this._sectionEntriesLeft === 0) { 2118 this.skipSection(); 2119 return this.read(); 2120 } 2121 this.state = 14 /* BinaryReaderState.TABLE_SECTION_ENTRY */; 2122 this.result = this.readTableType(); 2123 this._sectionEntriesLeft--; 2124 return true; 2125 }; 2126 BinaryReader.prototype.readMemoryEntry = function () { 2127 if (this._sectionEntriesLeft === 0) { 2128 this.skipSection(); 2129 return this.read(); 2130 } 2131 this.state = 15 /* BinaryReaderState.MEMORY_SECTION_ENTRY */; 2132 this.result = this.readMemoryType(); 2133 this._sectionEntriesLeft--; 2134 return true; 2135 }; 2136 BinaryReader.prototype.readTagEntry = function () { 2137 if (this._sectionEntriesLeft === 0) { 2138 this.skipSection(); 2139 return this.read(); 2140 } 2141 this.state = 23 /* BinaryReaderState.TAG_SECTION_ENTRY */; 2142 this.result = this.readTagType(); 2143 this._sectionEntriesLeft--; 2144 return true; 2145 }; 2146 BinaryReader.prototype.readGlobalEntry = function () { 2147 if (this._sectionEntriesLeft === 0) { 2148 this.skipSection(); 2149 return this.read(); 2150 } 2151 var globalType = this.readGlobalType(); 2152 if (!globalType) { 2153 this.state = 16 /* BinaryReaderState.GLOBAL_SECTION_ENTRY */; 2154 return false; 2155 } 2156 this.state = 39 /* BinaryReaderState.BEGIN_GLOBAL_SECTION_ENTRY */; 2157 this.result = { 2158 type: globalType, 2159 }; 2160 this._sectionEntriesLeft--; 2161 return true; 2162 }; 2163 BinaryReader.prototype.readElementEntry = function () { 2164 if (this._sectionEntriesLeft === 0) { 2165 this.skipSection(); 2166 return this.read(); 2167 } 2168 var pos = this._pos; 2169 if (!this.hasMoreBytes()) { 2170 this.state = 20 /* BinaryReaderState.ELEMENT_SECTION_ENTRY */; 2171 return false; 2172 } 2173 var segmentType = this.readUint8(); 2174 var mode, tableIndex; 2175 switch (segmentType) { 2176 case 0 /* ElementSegmentType.LegacyActiveFuncrefExternval */: 2177 case 4 /* ElementSegmentType.LegacyActiveFuncrefElemexpr */: 2178 mode = 0 /* ElementMode.Active */; 2179 tableIndex = 0; 2180 break; 2181 case 1 /* ElementSegmentType.PassiveExternval */: 2182 case 5 /* ElementSegmentType.PassiveElemexpr */: 2183 mode = 1 /* ElementMode.Passive */; 2184 break; 2185 case 2 /* ElementSegmentType.ActiveExternval */: 2186 case 6 /* ElementSegmentType.ActiveElemexpr */: 2187 mode = 0 /* ElementMode.Active */; 2188 if (!this.hasVarIntBytes()) { 2189 this.state = 20 /* BinaryReaderState.ELEMENT_SECTION_ENTRY */; 2190 this._pos = pos; 2191 return false; 2192 } 2193 tableIndex = this.readVarUint32(); 2194 break; 2195 case 3 /* ElementSegmentType.DeclaredExternval */: 2196 case 7 /* ElementSegmentType.DeclaredElemexpr */: 2197 mode = 2 /* ElementMode.Declarative */; 2198 break; 2199 default: 2200 throw new Error("Unsupported element segment type ".concat(segmentType)); 2201 } 2202 this.state = 33 /* BinaryReaderState.BEGIN_ELEMENT_SECTION_ENTRY */; 2203 this.result = { mode: mode, tableIndex: tableIndex }; 2204 this._sectionEntriesLeft--; 2205 this._segmentType = segmentType; 2206 return true; 2207 }; 2208 BinaryReader.prototype.readElementEntryBody = function () { 2209 var elementType = Type.funcref; 2210 switch (this._segmentType) { 2211 case 1 /* ElementSegmentType.PassiveExternval */: 2212 case 2 /* ElementSegmentType.ActiveExternval */: 2213 case 3 /* ElementSegmentType.DeclaredExternval */: 2214 if (!this.hasMoreBytes()) 2215 return false; 2216 // We just skip the 0x00 byte, the `elemkind` byte 2217 // is reserved for future versions of WebAssembly. 2218 this.skipBytes(1); 2219 break; 2220 case 5 /* ElementSegmentType.PassiveElemexpr */: 2221 case 6 /* ElementSegmentType.ActiveElemexpr */: 2222 case 7 /* ElementSegmentType.DeclaredElemexpr */: 2223 if (!this.hasMoreBytes()) 2224 return false; 2225 elementType = this.readType(); 2226 break; 2227 case 0 /* ElementSegmentType.LegacyActiveFuncrefExternval */: 2228 case 4 /* ElementSegmentType.LegacyActiveFuncrefElemexpr */: 2229 // The element type is implicitly `funcref`. 2230 break; 2231 default: 2232 throw new Error("Unsupported element segment type ".concat(this._segmentType)); 2233 } 2234 this.state = 34 /* BinaryReaderState.ELEMENT_SECTION_ENTRY_BODY */; 2235 this.result = { elementType: elementType }; 2236 return true; 2237 }; 2238 BinaryReader.prototype.readDataEntry = function () { 2239 if (this._sectionEntriesLeft === 0) { 2240 this.skipSection(); 2241 return this.read(); 2242 } 2243 var pos = this._pos; 2244 if (!this.hasVarIntBytes()) { 2245 this.state = 18 /* BinaryReaderState.DATA_SECTION_ENTRY */; 2246 return false; 2247 } 2248 var segmentType = this.readVarUint32(); 2249 var mode, memoryIndex; 2250 switch (segmentType) { 2251 case 0 /* DataSegmentType.Active */: 2252 mode = 0 /* DataMode.Active */; 2253 memoryIndex = 0; 2254 break; 2255 case 1 /* DataSegmentType.Passive */: 2256 mode = 1 /* DataMode.Passive */; 2257 break; 2258 case 2 /* DataSegmentType.ActiveWithMemoryIndex */: 2259 mode = 0 /* DataMode.Active */; 2260 if (!this.hasVarIntBytes()) { 2261 this._pos = pos; 2262 this.state = 18 /* BinaryReaderState.DATA_SECTION_ENTRY */; 2263 return false; 2264 } 2265 memoryIndex = this.readVarUint32(); 2266 break; 2267 default: 2268 throw new Error("Unsupported data segment type ".concat(segmentType)); 2269 } 2270 this.state = 36 /* BinaryReaderState.BEGIN_DATA_SECTION_ENTRY */; 2271 this.result = { mode: mode, memoryIndex: memoryIndex }; 2272 this._sectionEntriesLeft--; 2273 this._segmentType = segmentType; 2274 return true; 2275 }; 2276 BinaryReader.prototype.readDataCountEntry = function () { 2277 if (this._sectionEntriesLeft === 0) { 2278 this.skipSection(); 2279 return this.read(); 2280 } 2281 this.state = 49 /* BinaryReaderState.DATA_COUNT_SECTION_ENTRY */; 2282 this.result = this.readVarUint32(); 2283 this._sectionEntriesLeft--; 2284 return true; 2285 }; 2286 BinaryReader.prototype.readDataEntryBody = function () { 2287 if (!this.hasStringBytes()) { 2288 return false; 2289 } 2290 this.state = 37 /* BinaryReaderState.DATA_SECTION_ENTRY_BODY */; 2291 this.result = { 2292 data: this.readStringBytes(), 2293 }; 2294 return true; 2295 }; 2296 BinaryReader.prototype.readInitExpressionBody = function () { 2297 this.state = 25 /* BinaryReaderState.BEGIN_INIT_EXPRESSION_BODY */; 2298 this.result = null; 2299 return true; 2300 }; 2301 BinaryReader.prototype.readOffsetExpressionBody = function () { 2302 this.state = 44 /* BinaryReaderState.BEGIN_OFFSET_EXPRESSION_BODY */; 2303 this.result = null; 2304 return true; 2305 }; 2306 BinaryReader.prototype.readMemoryImmediate = function () { 2307 var flags = this.readVarUint32(); 2308 var offset = this.readVarUint32(); 2309 return { flags: flags, offset: offset }; 2310 }; 2311 BinaryReader.prototype.readNameMap = function () { 2312 var count = this.readVarUint32(); 2313 var result = []; 2314 for (var i = 0; i < count; i++) { 2315 var index = this.readVarUint32(); 2316 var name = this.readStringBytes(); 2317 result.push({ index: index, name: name }); 2318 } 2319 return result; 2320 }; 2321 BinaryReader.prototype.readNameEntry = function () { 2322 var pos = this._pos; 2323 if (pos >= this._sectionRange.end) { 2324 this.skipSection(); 2325 return this.read(); 2326 } 2327 if (!this.hasVarIntBytes()) 2328 return false; 2329 var type = this.readVarUint7(); 2330 if (!this.hasVarIntBytes()) { 2331 this._pos = pos; 2332 return false; 2333 } 2334 var payloadLength = this.readVarUint32(); 2335 if (!this.hasBytes(payloadLength)) { 2336 this._pos = pos; 2337 return false; 2338 } 2339 var result; 2340 switch (type) { 2341 case 0 /* NameType.Module */: 2342 result = { 2343 type: type, 2344 moduleName: this.readStringBytes(), 2345 }; 2346 break; 2347 case 1 /* NameType.Function */: 2348 case 11 /* NameType.Tag */: 2349 case 4 /* NameType.Type */: 2350 case 5 /* NameType.Table */: 2351 case 6 /* NameType.Memory */: 2352 case 7 /* NameType.Global */: 2353 result = { 2354 type: type, 2355 names: this.readNameMap(), 2356 }; 2357 break; 2358 case 2 /* NameType.Local */: 2359 var funcsLength = this.readVarUint32(); 2360 var funcs = []; 2361 for (var i = 0; i < funcsLength; i++) { 2362 var funcIndex = this.readVarUint32(); 2363 funcs.push({ 2364 index: funcIndex, 2365 locals: this.readNameMap(), 2366 }); 2367 } 2368 result = { 2369 type: type, 2370 funcs: funcs, 2371 }; 2372 break; 2373 case 10 /* NameType.Field */: 2374 var typesLength = this.readVarUint32(); 2375 var types = []; 2376 for (var i = 0; i < typesLength; i++) { 2377 var fieldIndex = this.readVarUint32(); 2378 types.push({ 2379 index: fieldIndex, 2380 fields: this.readNameMap(), 2381 }); 2382 } 2383 result = { 2384 type: type, 2385 types: types, 2386 }; 2387 break; 2388 default: 2389 // Skip this unknown name subsection (as per specification, 2390 // custom section errors shouldn't cause Wasm parsing to fail). 2391 this.skipBytes(payloadLength); 2392 return this.read(); 2393 } 2394 this.state = 19 /* BinaryReaderState.NAME_SECTION_ENTRY */; 2395 this.result = result; 2396 return true; 2397 }; 2398 BinaryReader.prototype.readRelocHeader = function () { 2399 // See https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md 2400 if (!this.hasVarIntBytes()) { 2401 return false; 2402 } 2403 var pos = this._pos; 2404 var sectionId = this.readVarUint7(); 2405 var sectionName; 2406 if (sectionId === 0 /* SectionCode.Custom */) { 2407 if (!this.hasStringBytes()) { 2408 this._pos = pos; 2409 return false; 2410 } 2411 sectionName = this.readStringBytes(); 2412 } 2413 this.state = 41 /* BinaryReaderState.RELOC_SECTION_HEADER */; 2414 this.result = { 2415 id: sectionId, 2416 name: sectionName, 2417 }; 2418 return true; 2419 }; 2420 BinaryReader.prototype.readLinkingEntry = function () { 2421 if (this._sectionEntriesLeft === 0) { 2422 this.skipSection(); 2423 return this.read(); 2424 } 2425 if (!this.hasVarIntBytes()) 2426 return false; 2427 var pos = this._pos; 2428 var type = this.readVarUint32(); 2429 var index; 2430 switch (type) { 2431 case 1 /* LinkingType.StackPointer */: 2432 if (!this.hasVarIntBytes()) { 2433 this._pos = pos; 2434 return false; 2435 } 2436 index = this.readVarUint32(); 2437 break; 2438 default: 2439 this.error = new Error("Bad linking type: ".concat(type)); 2440 this.state = -1 /* BinaryReaderState.ERROR */; 2441 return true; 2442 } 2443 this.state = 21 /* BinaryReaderState.LINKING_SECTION_ENTRY */; 2444 this.result = { type: type, index: index }; 2445 this._sectionEntriesLeft--; 2446 return true; 2447 }; 2448 BinaryReader.prototype.readSourceMappingURL = function () { 2449 if (!this.hasStringBytes()) 2450 return false; 2451 var url = this.readStringBytes(); 2452 this.state = 43 /* BinaryReaderState.SOURCE_MAPPING_URL */; 2453 this.result = { url: url }; 2454 return true; 2455 }; 2456 BinaryReader.prototype.readRelocEntry = function () { 2457 if (this._sectionEntriesLeft === 0) { 2458 this.skipSection(); 2459 return this.read(); 2460 } 2461 if (!this.hasVarIntBytes()) 2462 return false; 2463 var pos = this._pos; 2464 var type = this.readVarUint7(); 2465 if (!this.hasVarIntBytes()) { 2466 this._pos = pos; 2467 return false; 2468 } 2469 var offset = this.readVarUint32(); 2470 if (!this.hasVarIntBytes()) { 2471 this._pos = pos; 2472 return false; 2473 } 2474 var index = this.readVarUint32(); 2475 var addend; 2476 switch (type) { 2477 case 0 /* RelocType.FunctionIndex_LEB */: 2478 case 1 /* RelocType.TableIndex_SLEB */: 2479 case 2 /* RelocType.TableIndex_I32 */: 2480 case 6 /* RelocType.TypeIndex_LEB */: 2481 case 7 /* RelocType.GlobalIndex_LEB */: 2482 break; 2483 case 3 /* RelocType.GlobalAddr_LEB */: 2484 case 4 /* RelocType.GlobalAddr_SLEB */: 2485 case 5 /* RelocType.GlobalAddr_I32 */: 2486 if (!this.hasVarIntBytes()) { 2487 this._pos = pos; 2488 return false; 2489 } 2490 addend = this.readVarUint32(); 2491 break; 2492 default: 2493 this.error = new Error("Bad relocation type: ".concat(type)); 2494 this.state = -1 /* BinaryReaderState.ERROR */; 2495 return true; 2496 } 2497 this.state = 42 /* BinaryReaderState.RELOC_SECTION_ENTRY */; 2498 this.result = { 2499 type: type, 2500 offset: offset, 2501 index: index, 2502 addend: addend, 2503 }; 2504 this._sectionEntriesLeft--; 2505 return true; 2506 }; 2507 BinaryReader.prototype.readCodeOperator_0xfb = function () { 2508 // The longest instructions have: 2 bytes opcode, 5 bytes type index, 2509 // 5 bytes field index. 2510 var MAX_CODE_OPERATOR_0XFB_SIZE = 12; 2511 if (!this._eof && !this.hasBytes(MAX_CODE_OPERATOR_0XFB_SIZE)) { 2512 return false; 2513 } 2514 var code, brDepth, refType, srcType, fieldIndex, segmentIndex, len, literal; 2515 code = this._data[this._pos++] | 0xfb00; 2516 switch (code) { 2517 case 64280 /* OperatorCode.br_on_cast */: 2518 case 64281 /* OperatorCode.br_on_cast_fail */: 2519 literal = this.readUint8(); 2520 brDepth = this.readVarUint32(); 2521 srcType = this.readHeapType(); 2522 refType = this.readHeapType(); 2523 break; 2524 case 64267 /* OperatorCode.array_get */: 2525 case 64268 /* OperatorCode.array_get_s */: 2526 case 64269 /* OperatorCode.array_get_u */: 2527 case 64270 /* OperatorCode.array_set */: 2528 case 64262 /* OperatorCode.array_new */: 2529 case 64263 /* OperatorCode.array_new_default */: 2530 case 64256 /* OperatorCode.struct_new */: 2531 case 64257 /* OperatorCode.struct_new_default */: 2532 refType = this.readVarUint32(); 2533 break; 2534 case 64264 /* OperatorCode.array_new_fixed */: 2535 refType = this.readVarUint32(); 2536 len = this.readVarUint32(); 2537 break; 2538 case 64272 /* OperatorCode.array_fill */: 2539 refType = this.readVarUint32(); 2540 break; 2541 case 64273 /* OperatorCode.array_copy */: 2542 refType = this.readVarUint32(); 2543 srcType = this.readVarUint32(); 2544 break; 2545 case 64258 /* OperatorCode.struct_get */: 2546 case 64259 /* OperatorCode.struct_get_s */: 2547 case 64260 /* OperatorCode.struct_get_u */: 2548 case 64261 /* OperatorCode.struct_set */: 2549 refType = this.readVarUint32(); 2550 fieldIndex = this.readVarUint32(); 2551 break; 2552 case 64265 /* OperatorCode.array_new_data */: 2553 case 64266 /* OperatorCode.array_new_elem */: 2554 case 64274 /* OperatorCode.array_init_data */: 2555 case 64275 /* OperatorCode.array_init_elem */: 2556 refType = this.readVarUint32(); 2557 segmentIndex = this.readVarUint32(); 2558 break; 2559 case 64276 /* OperatorCode.ref_test */: 2560 case 64277 /* OperatorCode.ref_test_null */: 2561 case 64278 /* OperatorCode.ref_cast */: 2562 case 64279 /* OperatorCode.ref_cast_null */: 2563 refType = this.readHeapType(); 2564 break; 2565 case 64271 /* OperatorCode.array_len */: 2566 case 64283 /* OperatorCode.extern_convert_any */: 2567 case 64282 /* OperatorCode.any_convert_extern */: 2568 case 64284 /* OperatorCode.ref_i31 */: 2569 case 64285 /* OperatorCode.i31_get_s */: 2570 case 64286 /* OperatorCode.i31_get_u */: 2571 break; 2572 default: 2573 this.error = new Error("Unknown operator: 0x".concat(code.toString(16).padStart(4, "0"))); 2574 this.state = -1 /* BinaryReaderState.ERROR */; 2575 return true; 2576 } 2577 this.result = { 2578 code: code, 2579 blockType: undefined, 2580 refType: refType, 2581 srcType: srcType, 2582 brDepth: brDepth, 2583 brTable: undefined, 2584 tableIndex: undefined, 2585 funcIndex: undefined, 2586 typeIndex: undefined, 2587 localIndex: undefined, 2588 globalIndex: undefined, 2589 fieldIndex: fieldIndex, 2590 memoryAddress: undefined, 2591 literal: literal, 2592 segmentIndex: segmentIndex, 2593 destinationIndex: undefined, 2594 len: len, 2595 lines: undefined, 2596 lineIndex: undefined, 2597 }; 2598 return true; 2599 }; 2600 BinaryReader.prototype.readCodeOperator_0xfc = function () { 2601 if (!this.hasVarIntBytes()) { 2602 return false; 2603 } 2604 var code = this.readVarUint32() | 0xfc00; 2605 var reserved, segmentIndex, destinationIndex, tableIndex; 2606 switch (code) { 2607 case 64512 /* OperatorCode.i32_trunc_sat_f32_s */: 2608 case 64513 /* OperatorCode.i32_trunc_sat_f32_u */: 2609 case 64514 /* OperatorCode.i32_trunc_sat_f64_s */: 2610 case 64515 /* OperatorCode.i32_trunc_sat_f64_u */: 2611 case 64516 /* OperatorCode.i64_trunc_sat_f32_s */: 2612 case 64517 /* OperatorCode.i64_trunc_sat_f32_u */: 2613 case 64518 /* OperatorCode.i64_trunc_sat_f64_s */: 2614 case 64519 /* OperatorCode.i64_trunc_sat_f64_u */: 2615 break; 2616 case 64522 /* OperatorCode.memory_copy */: 2617 // Currently memory index must be zero. 2618 reserved = this.readVarUint1(); 2619 reserved = this.readVarUint1(); 2620 break; 2621 case 64523 /* OperatorCode.memory_fill */: 2622 reserved = this.readVarUint1(); 2623 break; 2624 case 64524 /* OperatorCode.table_init */: 2625 segmentIndex = this.readVarUint32(); 2626 tableIndex = this.readVarUint32(); 2627 break; 2628 case 64526 /* OperatorCode.table_copy */: 2629 tableIndex = this.readVarUint32(); 2630 destinationIndex = this.readVarUint32(); 2631 break; 2632 case 64527 /* OperatorCode.table_grow */: 2633 case 64528 /* OperatorCode.table_size */: 2634 case 64529 /* OperatorCode.table_fill */: 2635 tableIndex = this.readVarUint32(); 2636 break; 2637 case 64520 /* OperatorCode.memory_init */: 2638 segmentIndex = this.readVarUint32(); 2639 reserved = this.readVarUint1(); 2640 break; 2641 case 64521 /* OperatorCode.data_drop */: 2642 case 64525 /* OperatorCode.elem_drop */: 2643 segmentIndex = this.readVarUint32(); 2644 break; 2645 default: 2646 this.error = new Error("Unknown operator: 0x".concat(code.toString(16).padStart(4, "0"))); 2647 this.state = -1 /* BinaryReaderState.ERROR */; 2648 return true; 2649 } 2650 this.result = { 2651 code: code, 2652 blockType: undefined, 2653 selectType: undefined, 2654 refType: undefined, 2655 srcType: undefined, 2656 brDepth: undefined, 2657 brTable: undefined, 2658 funcIndex: undefined, 2659 typeIndex: undefined, 2660 tableIndex: tableIndex, 2661 localIndex: undefined, 2662 globalIndex: undefined, 2663 fieldIndex: undefined, 2664 memoryAddress: undefined, 2665 literal: undefined, 2666 segmentIndex: segmentIndex, 2667 destinationIndex: destinationIndex, 2668 len: undefined, 2669 lines: undefined, 2670 lineIndex: undefined, 2671 }; 2672 return true; 2673 }; 2674 BinaryReader.prototype.readCodeOperator_0xfd = function () { 2675 var MAX_CODE_OPERATOR_0XFD_SIZE = 17; 2676 var pos = this._pos; 2677 if (!this._eof && pos + MAX_CODE_OPERATOR_0XFD_SIZE > this._length) { 2678 return false; 2679 } 2680 if (!this.hasVarIntBytes()) { 2681 return false; 2682 } 2683 var code = this.readVarUint32() | 0xfd000; 2684 var memoryAddress; 2685 var literal; 2686 var lineIndex; 2687 var lines; 2688 switch (code) { 2689 case 1036288 /* OperatorCode.v128_load */: 2690 case 1036289 /* OperatorCode.i16x8_load8x8_s */: 2691 case 1036290 /* OperatorCode.i16x8_load8x8_u */: 2692 case 1036291 /* OperatorCode.i32x4_load16x4_s */: 2693 case 1036292 /* OperatorCode.i32x4_load16x4_u */: 2694 case 1036293 /* OperatorCode.i64x2_load32x2_s */: 2695 case 1036294 /* OperatorCode.i64x2_load32x2_u */: 2696 case 1036295 /* OperatorCode.v8x16_load_splat */: 2697 case 1036296 /* OperatorCode.v16x8_load_splat */: 2698 case 1036297 /* OperatorCode.v32x4_load_splat */: 2699 case 1036298 /* OperatorCode.v64x2_load_splat */: 2700 case 1036299 /* OperatorCode.v128_store */: 2701 case 1036380 /* OperatorCode.v128_load32_zero */: 2702 case 1036381 /* OperatorCode.v128_load64_zero */: 2703 memoryAddress = this.readMemoryImmediate(); 2704 break; 2705 case 1036300 /* OperatorCode.v128_const */: 2706 literal = this.readBytes(16); 2707 break; 2708 case 1036301 /* OperatorCode.i8x16_shuffle */: 2709 lines = new Uint8Array(16); 2710 for (var i = 0; i < lines.length; i++) { 2711 lines[i] = this.readUint8(); 2712 } 2713 break; 2714 case 1036309 /* OperatorCode.i8x16_extract_lane_s */: 2715 case 1036310 /* OperatorCode.i8x16_extract_lane_u */: 2716 case 1036311 /* OperatorCode.i8x16_replace_lane */: 2717 case 1036312 /* OperatorCode.i16x8_extract_lane_s */: 2718 case 1036313 /* OperatorCode.i16x8_extract_lane_u */: 2719 case 1036314 /* OperatorCode.i16x8_replace_lane */: 2720 case 1036315 /* OperatorCode.i32x4_extract_lane */: 2721 case 1036316 /* OperatorCode.i32x4_replace_lane */: 2722 case 1036317 /* OperatorCode.i64x2_extract_lane */: 2723 case 1036318 /* OperatorCode.i64x2_replace_lane */: 2724 case 1036319 /* OperatorCode.f32x4_extract_lane */: 2725 case 1036320 /* OperatorCode.f32x4_replace_lane */: 2726 case 1036321 /* OperatorCode.f64x2_extract_lane */: 2727 case 1036322 /* OperatorCode.f64x2_replace_lane */: 2728 lineIndex = this.readUint8(); 2729 break; 2730 case 1036372 /* OperatorCode.v128_load8_lane */: 2731 case 1036373 /* OperatorCode.v128_load16_lane */: 2732 case 1036374 /* OperatorCode.v128_load32_lane */: 2733 case 1036375 /* OperatorCode.v128_load64_lane */: 2734 case 1036376 /* OperatorCode.v128_store8_lane */: 2735 case 1036377 /* OperatorCode.v128_store16_lane */: 2736 case 1036378 /* OperatorCode.v128_store32_lane */: 2737 case 1036379 /* OperatorCode.v128_store64_lane */: 2738 memoryAddress = this.readMemoryImmediate(); 2739 lineIndex = this.readUint8(); 2740 break; 2741 case 1036302 /* OperatorCode.i8x16_swizzle */: 2742 case 1036303 /* OperatorCode.i8x16_splat */: 2743 case 1036304 /* OperatorCode.i16x8_splat */: 2744 case 1036305 /* OperatorCode.i32x4_splat */: 2745 case 1036306 /* OperatorCode.i64x2_splat */: 2746 case 1036307 /* OperatorCode.f32x4_splat */: 2747 case 1036308 /* OperatorCode.f64x2_splat */: 2748 case 1036323 /* OperatorCode.i8x16_eq */: 2749 case 1036324 /* OperatorCode.i8x16_ne */: 2750 case 1036325 /* OperatorCode.i8x16_lt_s */: 2751 case 1036326 /* OperatorCode.i8x16_lt_u */: 2752 case 1036327 /* OperatorCode.i8x16_gt_s */: 2753 case 1036328 /* OperatorCode.i8x16_gt_u */: 2754 case 1036329 /* OperatorCode.i8x16_le_s */: 2755 case 1036330 /* OperatorCode.i8x16_le_u */: 2756 case 1036331 /* OperatorCode.i8x16_ge_s */: 2757 case 1036332 /* OperatorCode.i8x16_ge_u */: 2758 case 1036333 /* OperatorCode.i16x8_eq */: 2759 case 1036334 /* OperatorCode.i16x8_ne */: 2760 case 1036335 /* OperatorCode.i16x8_lt_s */: 2761 case 1036336 /* OperatorCode.i16x8_lt_u */: 2762 case 1036337 /* OperatorCode.i16x8_gt_s */: 2763 case 1036338 /* OperatorCode.i16x8_gt_u */: 2764 case 1036339 /* OperatorCode.i16x8_le_s */: 2765 case 1036340 /* OperatorCode.i16x8_le_u */: 2766 case 1036341 /* OperatorCode.i16x8_ge_s */: 2767 case 1036342 /* OperatorCode.i16x8_ge_u */: 2768 case 1036343 /* OperatorCode.i32x4_eq */: 2769 case 1036344 /* OperatorCode.i32x4_ne */: 2770 case 1036345 /* OperatorCode.i32x4_lt_s */: 2771 case 1036346 /* OperatorCode.i32x4_lt_u */: 2772 case 1036347 /* OperatorCode.i32x4_gt_s */: 2773 case 1036348 /* OperatorCode.i32x4_gt_u */: 2774 case 1036349 /* OperatorCode.i32x4_le_s */: 2775 case 1036350 /* OperatorCode.i32x4_le_u */: 2776 case 1036351 /* OperatorCode.i32x4_ge_s */: 2777 case 1036352 /* OperatorCode.i32x4_ge_u */: 2778 case 1036353 /* OperatorCode.f32x4_eq */: 2779 case 1036354 /* OperatorCode.f32x4_ne */: 2780 case 1036355 /* OperatorCode.f32x4_lt */: 2781 case 1036356 /* OperatorCode.f32x4_gt */: 2782 case 1036357 /* OperatorCode.f32x4_le */: 2783 case 1036358 /* OperatorCode.f32x4_ge */: 2784 case 1036359 /* OperatorCode.f64x2_eq */: 2785 case 1036360 /* OperatorCode.f64x2_ne */: 2786 case 1036361 /* OperatorCode.f64x2_lt */: 2787 case 1036362 /* OperatorCode.f64x2_gt */: 2788 case 1036363 /* OperatorCode.f64x2_le */: 2789 case 1036364 /* OperatorCode.f64x2_ge */: 2790 case 1036365 /* OperatorCode.v128_not */: 2791 case 1036366 /* OperatorCode.v128_and */: 2792 case 1036367 /* OperatorCode.v128_andnot */: 2793 case 1036368 /* OperatorCode.v128_or */: 2794 case 1036369 /* OperatorCode.v128_xor */: 2795 case 1036370 /* OperatorCode.v128_bitselect */: 2796 case 1036371 /* OperatorCode.v128_any_true */: 2797 case 1036382 /* OperatorCode.f32x4_demote_f64x2_zero */: 2798 case 1036383 /* OperatorCode.f64x2_promote_low_f32x4 */: 2799 case 1036384 /* OperatorCode.i8x16_abs */: 2800 case 1036385 /* OperatorCode.i8x16_neg */: 2801 case 1036386 /* OperatorCode.i8x16_popcnt */: 2802 case 1036387 /* OperatorCode.i8x16_all_true */: 2803 case 1036388 /* OperatorCode.i8x16_bitmask */: 2804 case 1036389 /* OperatorCode.i8x16_narrow_i16x8_s */: 2805 case 1036390 /* OperatorCode.i8x16_narrow_i16x8_u */: 2806 case 1036391 /* OperatorCode.f32x4_ceil */: 2807 case 1036392 /* OperatorCode.f32x4_floor */: 2808 case 1036393 /* OperatorCode.f32x4_trunc */: 2809 case 1036394 /* OperatorCode.f32x4_nearest */: 2810 case 1036395 /* OperatorCode.i8x16_shl */: 2811 case 1036396 /* OperatorCode.i8x16_shr_s */: 2812 case 1036397 /* OperatorCode.i8x16_shr_u */: 2813 case 1036398 /* OperatorCode.i8x16_add */: 2814 case 1036399 /* OperatorCode.i8x16_add_sat_s */: 2815 case 1036400 /* OperatorCode.i8x16_add_sat_u */: 2816 case 1036401 /* OperatorCode.i8x16_sub */: 2817 case 1036402 /* OperatorCode.i8x16_sub_sat_s */: 2818 case 1036403 /* OperatorCode.i8x16_sub_sat_u */: 2819 case 1036404 /* OperatorCode.f64x2_ceil */: 2820 case 1036405 /* OperatorCode.f64x2_floor */: 2821 case 1036406 /* OperatorCode.i8x16_min_s */: 2822 case 1036407 /* OperatorCode.i8x16_min_u */: 2823 case 1036408 /* OperatorCode.i8x16_max_s */: 2824 case 1036409 /* OperatorCode.i8x16_max_u */: 2825 case 1036410 /* OperatorCode.f64x2_trunc */: 2826 case 1036411 /* OperatorCode.i8x16_avgr_u */: 2827 case 1036412 /* OperatorCode.i16x8_extadd_pairwise_i8x16_s */: 2828 case 1036413 /* OperatorCode.i16x8_extadd_pairwise_i8x16_u */: 2829 case 1036414 /* OperatorCode.i32x4_extadd_pairwise_i16x8_s */: 2830 case 1036415 /* OperatorCode.i32x4_extadd_pairwise_i16x8_u */: 2831 case 1036416 /* OperatorCode.i16x8_abs */: 2832 case 1036417 /* OperatorCode.i16x8_neg */: 2833 case 1036418 /* OperatorCode.i16x8_q15mulr_sat_s */: 2834 case 1036419 /* OperatorCode.i16x8_all_true */: 2835 case 1036420 /* OperatorCode.i16x8_bitmask */: 2836 case 1036421 /* OperatorCode.i16x8_narrow_i32x4_s */: 2837 case 1036422 /* OperatorCode.i16x8_narrow_i32x4_u */: 2838 case 1036423 /* OperatorCode.i16x8_extend_low_i8x16_s */: 2839 case 1036424 /* OperatorCode.i16x8_extend_high_i8x16_s */: 2840 case 1036425 /* OperatorCode.i16x8_extend_low_i8x16_u */: 2841 case 1036426 /* OperatorCode.i16x8_extend_high_i8x16_u */: 2842 case 1036427 /* OperatorCode.i16x8_shl */: 2843 case 1036428 /* OperatorCode.i16x8_shr_s */: 2844 case 1036429 /* OperatorCode.i16x8_shr_u */: 2845 case 1036430 /* OperatorCode.i16x8_add */: 2846 case 1036431 /* OperatorCode.i16x8_add_sat_s */: 2847 case 1036432 /* OperatorCode.i16x8_add_sat_u */: 2848 case 1036433 /* OperatorCode.i16x8_sub */: 2849 case 1036434 /* OperatorCode.i16x8_sub_sat_s */: 2850 case 1036435 /* OperatorCode.i16x8_sub_sat_u */: 2851 case 1036436 /* OperatorCode.f64x2_nearest */: 2852 case 1036437 /* OperatorCode.i16x8_mul */: 2853 case 1036438 /* OperatorCode.i16x8_min_s */: 2854 case 1036439 /* OperatorCode.i16x8_min_u */: 2855 case 1036440 /* OperatorCode.i16x8_max_s */: 2856 case 1036441 /* OperatorCode.i16x8_max_u */: 2857 case 1036443 /* OperatorCode.i16x8_avgr_u */: 2858 case 1036444 /* OperatorCode.i16x8_extmul_low_i8x16_s */: 2859 case 1036445 /* OperatorCode.i16x8_extmul_high_i8x16_s */: 2860 case 1036446 /* OperatorCode.i16x8_extmul_low_i8x16_u */: 2861 case 1036447 /* OperatorCode.i16x8_extmul_high_i8x16_u */: 2862 case 1036448 /* OperatorCode.i32x4_abs */: 2863 case 1036449 /* OperatorCode.i32x4_neg */: 2864 case 1036451 /* OperatorCode.i32x4_all_true */: 2865 case 1036452 /* OperatorCode.i32x4_bitmask */: 2866 case 1036455 /* OperatorCode.i32x4_extend_low_i16x8_s */: 2867 case 1036456 /* OperatorCode.i32x4_extend_high_i16x8_s */: 2868 case 1036457 /* OperatorCode.i32x4_extend_low_i16x8_u */: 2869 case 1036458 /* OperatorCode.i32x4_extend_high_i16x8_u */: 2870 case 1036459 /* OperatorCode.i32x4_shl */: 2871 case 1036460 /* OperatorCode.i32x4_shr_s */: 2872 case 1036461 /* OperatorCode.i32x4_shr_u */: 2873 case 1036462 /* OperatorCode.i32x4_add */: 2874 case 1036465 /* OperatorCode.i32x4_sub */: 2875 case 1036469 /* OperatorCode.i32x4_mul */: 2876 case 1036470 /* OperatorCode.i32x4_min_s */: 2877 case 1036471 /* OperatorCode.i32x4_min_u */: 2878 case 1036472 /* OperatorCode.i32x4_max_s */: 2879 case 1036473 /* OperatorCode.i32x4_max_u */: 2880 case 1036474 /* OperatorCode.i32x4_dot_i16x8_s */: 2881 case 1036476 /* OperatorCode.i32x4_extmul_low_i16x8_s */: 2882 case 1036477 /* OperatorCode.i32x4_extmul_high_i16x8_s */: 2883 case 1036478 /* OperatorCode.i32x4_extmul_low_i16x8_u */: 2884 case 1036479 /* OperatorCode.i32x4_extmul_high_i16x8_u */: 2885 case 1036480 /* OperatorCode.i64x2_abs */: 2886 case 1036481 /* OperatorCode.i64x2_neg */: 2887 case 1036483 /* OperatorCode.i64x2_all_true */: 2888 case 1036484 /* OperatorCode.i64x2_bitmask */: 2889 case 1036487 /* OperatorCode.i64x2_extend_low_i32x4_s */: 2890 case 1036488 /* OperatorCode.i64x2_extend_high_i32x4_s */: 2891 case 1036489 /* OperatorCode.i64x2_extend_low_i32x4_u */: 2892 case 1036490 /* OperatorCode.i64x2_extend_high_i32x4_u */: 2893 case 1036491 /* OperatorCode.i64x2_shl */: 2894 case 1036492 /* OperatorCode.i64x2_shr_s */: 2895 case 1036493 /* OperatorCode.i64x2_shr_u */: 2896 case 1036494 /* OperatorCode.i64x2_add */: 2897 case 1036497 /* OperatorCode.i64x2_sub */: 2898 case 1036501 /* OperatorCode.i64x2_mul */: 2899 case 1036502 /* OperatorCode.i64x2_eq */: 2900 case 1036503 /* OperatorCode.i64x2_ne */: 2901 case 1036504 /* OperatorCode.i64x2_lt_s */: 2902 case 1036505 /* OperatorCode.i64x2_gt_s */: 2903 case 1036506 /* OperatorCode.i64x2_le_s */: 2904 case 1036507 /* OperatorCode.i64x2_ge_s */: 2905 case 1036508 /* OperatorCode.i64x2_extmul_low_i32x4_s */: 2906 case 1036509 /* OperatorCode.i64x2_extmul_high_i32x4_s */: 2907 case 1036510 /* OperatorCode.i64x2_extmul_low_i32x4_u */: 2908 case 1036511 /* OperatorCode.i64x2_extmul_high_i32x4_u */: 2909 case 1036512 /* OperatorCode.f32x4_abs */: 2910 case 1036512 /* OperatorCode.f32x4_abs */: 2911 case 1036513 /* OperatorCode.f32x4_neg */: 2912 case 1036515 /* OperatorCode.f32x4_sqrt */: 2913 case 1036516 /* OperatorCode.f32x4_add */: 2914 case 1036517 /* OperatorCode.f32x4_sub */: 2915 case 1036518 /* OperatorCode.f32x4_mul */: 2916 case 1036519 /* OperatorCode.f32x4_div */: 2917 case 1036520 /* OperatorCode.f32x4_min */: 2918 case 1036521 /* OperatorCode.f32x4_max */: 2919 case 1036522 /* OperatorCode.f32x4_pmin */: 2920 case 1036523 /* OperatorCode.f32x4_pmax */: 2921 case 1036524 /* OperatorCode.f64x2_abs */: 2922 case 1036525 /* OperatorCode.f64x2_neg */: 2923 case 1036527 /* OperatorCode.f64x2_sqrt */: 2924 case 1036528 /* OperatorCode.f64x2_add */: 2925 case 1036529 /* OperatorCode.f64x2_sub */: 2926 case 1036530 /* OperatorCode.f64x2_mul */: 2927 case 1036531 /* OperatorCode.f64x2_div */: 2928 case 1036532 /* OperatorCode.f64x2_min */: 2929 case 1036533 /* OperatorCode.f64x2_max */: 2930 case 1036534 /* OperatorCode.f64x2_pmin */: 2931 case 1036535 /* OperatorCode.f64x2_pmax */: 2932 case 1036536 /* OperatorCode.i32x4_trunc_sat_f32x4_s */: 2933 case 1036537 /* OperatorCode.i32x4_trunc_sat_f32x4_u */: 2934 case 1036538 /* OperatorCode.f32x4_convert_i32x4_s */: 2935 case 1036539 /* OperatorCode.f32x4_convert_i32x4_u */: 2936 case 1036540 /* OperatorCode.i32x4_trunc_sat_f64x2_s_zero */: 2937 case 1036541 /* OperatorCode.i32x4_trunc_sat_f64x2_u_zero */: 2938 case 1036542 /* OperatorCode.f64x2_convert_low_i32x4_s */: 2939 case 1036543 /* OperatorCode.f64x2_convert_low_i32x4_u */: 2940 break; 2941 case 1036544 /* OperatorCode.i8x16_relaxed_swizzle */: 2942 case 1036545 /* OperatorCode.i32x4_relaxed_trunc_f32x4_s */: 2943 case 1036546 /* OperatorCode.i32x4_relaxed_trunc_f32x4_u */: 2944 case 1036547 /* OperatorCode.i32x4_relaxed_trunc_f64x2_s_zero */: 2945 case 1036548 /* OperatorCode.i32x4_relaxed_trunc_f64x2_u_zero */: 2946 case 1036549 /* OperatorCode.f32x4_relaxed_madd */: 2947 case 1036550 /* OperatorCode.f32x4_relaxed_nmadd */: 2948 case 1036551 /* OperatorCode.f64x2_relaxed_madd */: 2949 case 1036552 /* OperatorCode.f64x2_relaxed_nmadd */: 2950 case 1036553 /* OperatorCode.i8x16_relaxed_laneselect */: 2951 case 1036554 /* OperatorCode.i16x8_relaxed_laneselect */: 2952 case 1036555 /* OperatorCode.i32x4_relaxed_laneselect */: 2953 case 1036556 /* OperatorCode.i64x2_relaxed_laneselect */: 2954 case 1036557 /* OperatorCode.f32x4_relaxed_min */: 2955 case 1036558 /* OperatorCode.f32x4_relaxed_max */: 2956 case 1036559 /* OperatorCode.f64x2_relaxed_min */: 2957 case 1036560 /* OperatorCode.f64x2_relaxed_max */: 2958 case 1036561 /* OperatorCode.i16x8_relaxed_q15mulr_s */: 2959 case 1036562 /* OperatorCode.i16x8_relaxed_dot_i8x16_i7x16_s */: 2960 case 1036563 /* OperatorCode.i32x4_relaxed_dot_i8x16_i7x16_add_s */: 2961 break; 2962 default: 2963 this.error = new Error("Unknown operator: 0x".concat(code.toString(16).padStart(4, "0"))); 2964 this.state = -1 /* BinaryReaderState.ERROR */; 2965 return true; 2966 } 2967 this.result = { 2968 code: code, 2969 blockType: undefined, 2970 selectType: undefined, 2971 refType: undefined, 2972 srcType: undefined, 2973 brDepth: undefined, 2974 brTable: undefined, 2975 funcIndex: undefined, 2976 typeIndex: undefined, 2977 localIndex: undefined, 2978 globalIndex: undefined, 2979 fieldIndex: undefined, 2980 memoryAddress: memoryAddress, 2981 literal: literal, 2982 segmentIndex: undefined, 2983 destinationIndex: undefined, 2984 len: undefined, 2985 lines: lines, 2986 lineIndex: lineIndex, 2987 }; 2988 return true; 2989 }; 2990 BinaryReader.prototype.readCodeOperator_0xfe = function () { 2991 var MAX_CODE_OPERATOR_0XFE_SIZE = 11; 2992 var pos = this._pos; 2993 if (!this._eof && pos + MAX_CODE_OPERATOR_0XFE_SIZE > this._length) { 2994 return false; 2995 } 2996 if (!this.hasVarIntBytes()) { 2997 return false; 2998 } 2999 var code = this.readVarUint32() | 0xfe00; 3000 var memoryAddress; 3001 switch (code) { 3002 case 65024 /* OperatorCode.memory_atomic_notify */: 3003 case 65025 /* OperatorCode.memory_atomic_wait32 */: 3004 case 65026 /* OperatorCode.memory_atomic_wait64 */: 3005 case 65040 /* OperatorCode.i32_atomic_load */: 3006 case 65041 /* OperatorCode.i64_atomic_load */: 3007 case 65042 /* OperatorCode.i32_atomic_load8_u */: 3008 case 65043 /* OperatorCode.i32_atomic_load16_u */: 3009 case 65044 /* OperatorCode.i64_atomic_load8_u */: 3010 case 65045 /* OperatorCode.i64_atomic_load16_u */: 3011 case 65046 /* OperatorCode.i64_atomic_load32_u */: 3012 case 65047 /* OperatorCode.i32_atomic_store */: 3013 case 65048 /* OperatorCode.i64_atomic_store */: 3014 case 65049 /* OperatorCode.i32_atomic_store8 */: 3015 case 65050 /* OperatorCode.i32_atomic_store16 */: 3016 case 65051 /* OperatorCode.i64_atomic_store8 */: 3017 case 65052 /* OperatorCode.i64_atomic_store16 */: 3018 case 65053 /* OperatorCode.i64_atomic_store32 */: 3019 case 65054 /* OperatorCode.i32_atomic_rmw_add */: 3020 case 65055 /* OperatorCode.i64_atomic_rmw_add */: 3021 case 65056 /* OperatorCode.i32_atomic_rmw8_add_u */: 3022 case 65057 /* OperatorCode.i32_atomic_rmw16_add_u */: 3023 case 65058 /* OperatorCode.i64_atomic_rmw8_add_u */: 3024 case 65059 /* OperatorCode.i64_atomic_rmw16_add_u */: 3025 case 65060 /* OperatorCode.i64_atomic_rmw32_add_u */: 3026 case 65061 /* OperatorCode.i32_atomic_rmw_sub */: 3027 case 65062 /* OperatorCode.i64_atomic_rmw_sub */: 3028 case 65063 /* OperatorCode.i32_atomic_rmw8_sub_u */: 3029 case 65064 /* OperatorCode.i32_atomic_rmw16_sub_u */: 3030 case 65065 /* OperatorCode.i64_atomic_rmw8_sub_u */: 3031 case 65066 /* OperatorCode.i64_atomic_rmw16_sub_u */: 3032 case 65067 /* OperatorCode.i64_atomic_rmw32_sub_u */: 3033 case 65068 /* OperatorCode.i32_atomic_rmw_and */: 3034 case 65069 /* OperatorCode.i64_atomic_rmw_and */: 3035 case 65070 /* OperatorCode.i32_atomic_rmw8_and_u */: 3036 case 65071 /* OperatorCode.i32_atomic_rmw16_and_u */: 3037 case 65072 /* OperatorCode.i64_atomic_rmw8_and_u */: 3038 case 65073 /* OperatorCode.i64_atomic_rmw16_and_u */: 3039 case 65074 /* OperatorCode.i64_atomic_rmw32_and_u */: 3040 case 65075 /* OperatorCode.i32_atomic_rmw_or */: 3041 case 65076 /* OperatorCode.i64_atomic_rmw_or */: 3042 case 65077 /* OperatorCode.i32_atomic_rmw8_or_u */: 3043 case 65078 /* OperatorCode.i32_atomic_rmw16_or_u */: 3044 case 65079 /* OperatorCode.i64_atomic_rmw8_or_u */: 3045 case 65080 /* OperatorCode.i64_atomic_rmw16_or_u */: 3046 case 65081 /* OperatorCode.i64_atomic_rmw32_or_u */: 3047 case 65082 /* OperatorCode.i32_atomic_rmw_xor */: 3048 case 65083 /* OperatorCode.i64_atomic_rmw_xor */: 3049 case 65084 /* OperatorCode.i32_atomic_rmw8_xor_u */: 3050 case 65085 /* OperatorCode.i32_atomic_rmw16_xor_u */: 3051 case 65086 /* OperatorCode.i64_atomic_rmw8_xor_u */: 3052 case 65087 /* OperatorCode.i64_atomic_rmw16_xor_u */: 3053 case 65088 /* OperatorCode.i64_atomic_rmw32_xor_u */: 3054 case 65089 /* OperatorCode.i32_atomic_rmw_xchg */: 3055 case 65090 /* OperatorCode.i64_atomic_rmw_xchg */: 3056 case 65091 /* OperatorCode.i32_atomic_rmw8_xchg_u */: 3057 case 65092 /* OperatorCode.i32_atomic_rmw16_xchg_u */: 3058 case 65093 /* OperatorCode.i64_atomic_rmw8_xchg_u */: 3059 case 65094 /* OperatorCode.i64_atomic_rmw16_xchg_u */: 3060 case 65095 /* OperatorCode.i64_atomic_rmw32_xchg_u */: 3061 case 65096 /* OperatorCode.i32_atomic_rmw_cmpxchg */: 3062 case 65097 /* OperatorCode.i64_atomic_rmw_cmpxchg */: 3063 case 65098 /* OperatorCode.i32_atomic_rmw8_cmpxchg_u */: 3064 case 65099 /* OperatorCode.i32_atomic_rmw16_cmpxchg_u */: 3065 case 65100 /* OperatorCode.i64_atomic_rmw8_cmpxchg_u */: 3066 case 65101 /* OperatorCode.i64_atomic_rmw16_cmpxchg_u */: 3067 case 65102 /* OperatorCode.i64_atomic_rmw32_cmpxchg_u */: 3068 memoryAddress = this.readMemoryImmediate(); 3069 break; 3070 case 65027 /* OperatorCode.atomic_fence */: { 3071 var consistency_model = this.readUint8(); 3072 if (consistency_model != 0) { 3073 this.error = new Error("atomic.fence consistency model must be 0"); 3074 this.state = -1 /* BinaryReaderState.ERROR */; 3075 return true; 3076 } 3077 break; 3078 } 3079 default: 3080 this.error = new Error("Unknown operator: 0x".concat(code.toString(16).padStart(4, "0"))); 3081 this.state = -1 /* BinaryReaderState.ERROR */; 3082 return true; 3083 } 3084 this.result = { 3085 code: code, 3086 blockType: undefined, 3087 selectType: undefined, 3088 refType: undefined, 3089 srcType: undefined, 3090 brDepth: undefined, 3091 brTable: undefined, 3092 funcIndex: undefined, 3093 typeIndex: undefined, 3094 localIndex: undefined, 3095 globalIndex: undefined, 3096 fieldIndex: undefined, 3097 memoryAddress: memoryAddress, 3098 literal: undefined, 3099 segmentIndex: undefined, 3100 destinationIndex: undefined, 3101 len: undefined, 3102 lines: undefined, 3103 lineIndex: undefined, 3104 }; 3105 return true; 3106 }; 3107 BinaryReader.prototype.readCodeOperator = function () { 3108 switch (this.state) { 3109 case 30 /* BinaryReaderState.CODE_OPERATOR */: 3110 if (this._pos >= this._functionRange.end) { 3111 this.skipFunctionBody(); 3112 return this.read(); 3113 } 3114 break; 3115 case 26 /* BinaryReaderState.INIT_EXPRESSION_OPERATOR */: 3116 if (this.result && 3117 this.result.code === 11 /* OperatorCode.end */) { 3118 this.state = 27 /* BinaryReaderState.END_INIT_EXPRESSION_BODY */; 3119 this.result = null; 3120 return true; 3121 } 3122 break; 3123 case 45 /* BinaryReaderState.OFFSET_EXPRESSION_OPERATOR */: 3124 if (this.result && 3125 this.result.code === 11 /* OperatorCode.end */) { 3126 this.state = 46 /* BinaryReaderState.END_OFFSET_EXPRESSION_BODY */; 3127 this.result = null; 3128 return true; 3129 } 3130 break; 3131 } 3132 var code, blockType, selectType, refType, brDepth, brTable, tryTable, relativeDepth, funcIndex, typeIndex, tableIndex, localIndex, globalIndex, tagIndex, memoryAddress, literal, reserved; 3133 if (this.state === 26 /* BinaryReaderState.INIT_EXPRESSION_OPERATOR */ && 3134 this._sectionId === 9 /* SectionCode.Element */ && 3135 isExternvalElementSegmentType(this._segmentType)) { 3136 // We are reading a `vec(funcidx)` here, which is a dense encoding 3137 // for a sequence of `((ref.func y) end)` instructions. 3138 if (this.result && 3139 this.result.code === 210 /* OperatorCode.ref_func */) { 3140 code = 11 /* OperatorCode.end */; 3141 } 3142 else { 3143 if (!this.hasVarIntBytes()) 3144 return false; 3145 code = 210 /* OperatorCode.ref_func */; 3146 funcIndex = this.readVarUint32(); 3147 } 3148 } 3149 else { 3150 var MAX_CODE_OPERATOR_SIZE = 11; // i64.const or load/store 3151 var pos = this._pos; 3152 if (!this._eof && pos + MAX_CODE_OPERATOR_SIZE > this._length) { 3153 return false; 3154 } 3155 code = this._data[this._pos++]; 3156 switch (code) { 3157 case 2 /* OperatorCode.block */: 3158 case 3 /* OperatorCode.loop */: 3159 case 4 /* OperatorCode.if */: 3160 case 6 /* OperatorCode.try */: 3161 blockType = this.readType(); 3162 break; 3163 case 12 /* OperatorCode.br */: 3164 case 13 /* OperatorCode.br_if */: 3165 case 213 /* OperatorCode.br_on_null */: 3166 case 214 /* OperatorCode.br_on_non_null */: 3167 brDepth = this.readVarUint32(); 3168 break; 3169 case 14 /* OperatorCode.br_table */: 3170 var tableCount = this.readVarUint32(); 3171 if (!this.hasBytes(tableCount + 1)) { 3172 // We need at least (tableCount + 1) bytes 3173 this._pos = pos; 3174 return false; 3175 } 3176 brTable = []; 3177 for (var i = 0; i <= tableCount; i++) { 3178 // including default 3179 if (!this.hasVarIntBytes()) { 3180 this._pos = pos; 3181 return false; 3182 } 3183 brTable.push(this.readVarUint32()); 3184 } 3185 break; 3186 case 9 /* OperatorCode.rethrow */: 3187 case 24 /* OperatorCode.delegate */: 3188 relativeDepth = this.readVarUint32(); 3189 break; 3190 case 7 /* OperatorCode.catch */: 3191 case 8 /* OperatorCode.throw */: 3192 tagIndex = this.readVarInt32(); 3193 break; 3194 case 31 /* OperatorCode.try_table */: 3195 blockType = this.readType(); 3196 var tableCount = this.readVarUint32(); 3197 if (!this.hasBytes(2 * tableCount)) { 3198 // We need at least (2 * tableCount) bytes 3199 this._pos = pos; 3200 return false; 3201 } 3202 tryTable = []; 3203 for (var i = 0; i < tableCount; i++) { 3204 if (!this.hasVarIntBytes()) { 3205 this._pos = pos; 3206 return false; 3207 } 3208 var kind = this.readVarUint32(); 3209 var tagIndex; 3210 if (kind == CatchHandlerKind.Catch || 3211 kind == CatchHandlerKind.CatchRef) { 3212 if (!this.hasVarIntBytes()) { 3213 this._pos = pos; 3214 return false; 3215 } 3216 tagIndex = this.readVarUint32(); 3217 } 3218 if (!this.hasVarIntBytes()) { 3219 this._pos = pos; 3220 return false; 3221 } 3222 var depth = this.readVarUint32(); 3223 tryTable.push({ kind: kind, depth: depth, tagIndex: tagIndex }); 3224 } 3225 break; 3226 case 208 /* OperatorCode.ref_null */: 3227 refType = this.readHeapType(); 3228 break; 3229 case 16 /* OperatorCode.call */: 3230 case 18 /* OperatorCode.return_call */: 3231 case 210 /* OperatorCode.ref_func */: 3232 funcIndex = this.readVarUint32(); 3233 break; 3234 case 17 /* OperatorCode.call_indirect */: 3235 case 19 /* OperatorCode.return_call_indirect */: 3236 typeIndex = this.readVarUint32(); 3237 reserved = this.readVarUint1(); 3238 break; 3239 case 32 /* OperatorCode.local_get */: 3240 case 33 /* OperatorCode.local_set */: 3241 case 34 /* OperatorCode.local_tee */: 3242 localIndex = this.readVarUint32(); 3243 break; 3244 case 35 /* OperatorCode.global_get */: 3245 case 36 /* OperatorCode.global_set */: 3246 globalIndex = this.readVarUint32(); 3247 break; 3248 case 37 /* OperatorCode.table_get */: 3249 case 38 /* OperatorCode.table_set */: 3250 tableIndex = this.readVarUint32(); 3251 break; 3252 case 20 /* OperatorCode.call_ref */: 3253 case 21 /* OperatorCode.return_call_ref */: 3254 typeIndex = this.readHeapType(); 3255 break; 3256 case 40 /* OperatorCode.i32_load */: 3257 case 41 /* OperatorCode.i64_load */: 3258 case 42 /* OperatorCode.f32_load */: 3259 case 43 /* OperatorCode.f64_load */: 3260 case 44 /* OperatorCode.i32_load8_s */: 3261 case 45 /* OperatorCode.i32_load8_u */: 3262 case 46 /* OperatorCode.i32_load16_s */: 3263 case 47 /* OperatorCode.i32_load16_u */: 3264 case 48 /* OperatorCode.i64_load8_s */: 3265 case 49 /* OperatorCode.i64_load8_u */: 3266 case 50 /* OperatorCode.i64_load16_s */: 3267 case 51 /* OperatorCode.i64_load16_u */: 3268 case 52 /* OperatorCode.i64_load32_s */: 3269 case 53 /* OperatorCode.i64_load32_u */: 3270 case 54 /* OperatorCode.i32_store */: 3271 case 55 /* OperatorCode.i64_store */: 3272 case 56 /* OperatorCode.f32_store */: 3273 case 57 /* OperatorCode.f64_store */: 3274 case 58 /* OperatorCode.i32_store8 */: 3275 case 59 /* OperatorCode.i32_store16 */: 3276 case 60 /* OperatorCode.i64_store8 */: 3277 case 61 /* OperatorCode.i64_store16 */: 3278 case 62 /* OperatorCode.i64_store32 */: 3279 memoryAddress = this.readMemoryImmediate(); 3280 break; 3281 case 63 /* OperatorCode.memory_size */: 3282 case 64 /* OperatorCode.memory_grow */: 3283 reserved = this.readVarUint1(); 3284 break; 3285 case 65 /* OperatorCode.i32_const */: 3286 literal = this.readVarInt32(); 3287 break; 3288 case 66 /* OperatorCode.i64_const */: 3289 literal = this.readVarInt64(); 3290 break; 3291 case 67 /* OperatorCode.f32_const */: 3292 literal = new DataView(this._data.buffer, this._data.byteOffset).getFloat32(this._pos, true); 3293 this._pos += 4; 3294 break; 3295 case 68 /* OperatorCode.f64_const */: 3296 literal = new DataView(this._data.buffer, this._data.byteOffset).getFloat64(this._pos, true); 3297 this._pos += 8; 3298 break; 3299 case 28 /* OperatorCode.select_with_type */: 3300 var num_types = this.readVarInt32(); 3301 // Only 1 is a valid value currently. 3302 if (num_types == 1) { 3303 selectType = this.readType(); 3304 } 3305 break; 3306 case 251 /* OperatorCode.prefix_0xfb */: 3307 if (this.readCodeOperator_0xfb()) { 3308 return true; 3309 } 3310 this._pos = pos; 3311 return false; 3312 case 252 /* OperatorCode.prefix_0xfc */: 3313 if (this.readCodeOperator_0xfc()) { 3314 return true; 3315 } 3316 this._pos = pos; 3317 return false; 3318 case 253 /* OperatorCode.prefix_0xfd */: 3319 if (this.readCodeOperator_0xfd()) { 3320 return true; 3321 } 3322 this._pos = pos; 3323 return false; 3324 case 254 /* OperatorCode.prefix_0xfe */: 3325 if (this.readCodeOperator_0xfe()) { 3326 return true; 3327 } 3328 this._pos = pos; 3329 return false; 3330 case 0 /* OperatorCode.unreachable */: 3331 case 1 /* OperatorCode.nop */: 3332 case 5 /* OperatorCode.else */: 3333 case 11 /* OperatorCode.end */: 3334 case 15 /* OperatorCode.return */: 3335 case 25 /* OperatorCode.catch_all */: 3336 case 26 /* OperatorCode.drop */: 3337 case 27 /* OperatorCode.select */: 3338 case 69 /* OperatorCode.i32_eqz */: 3339 case 70 /* OperatorCode.i32_eq */: 3340 case 71 /* OperatorCode.i32_ne */: 3341 case 72 /* OperatorCode.i32_lt_s */: 3342 case 73 /* OperatorCode.i32_lt_u */: 3343 case 74 /* OperatorCode.i32_gt_s */: 3344 case 75 /* OperatorCode.i32_gt_u */: 3345 case 76 /* OperatorCode.i32_le_s */: 3346 case 77 /* OperatorCode.i32_le_u */: 3347 case 78 /* OperatorCode.i32_ge_s */: 3348 case 79 /* OperatorCode.i32_ge_u */: 3349 case 80 /* OperatorCode.i64_eqz */: 3350 case 81 /* OperatorCode.i64_eq */: 3351 case 82 /* OperatorCode.i64_ne */: 3352 case 83 /* OperatorCode.i64_lt_s */: 3353 case 84 /* OperatorCode.i64_lt_u */: 3354 case 85 /* OperatorCode.i64_gt_s */: 3355 case 86 /* OperatorCode.i64_gt_u */: 3356 case 87 /* OperatorCode.i64_le_s */: 3357 case 88 /* OperatorCode.i64_le_u */: 3358 case 89 /* OperatorCode.i64_ge_s */: 3359 case 90 /* OperatorCode.i64_ge_u */: 3360 case 91 /* OperatorCode.f32_eq */: 3361 case 92 /* OperatorCode.f32_ne */: 3362 case 93 /* OperatorCode.f32_lt */: 3363 case 94 /* OperatorCode.f32_gt */: 3364 case 95 /* OperatorCode.f32_le */: 3365 case 96 /* OperatorCode.f32_ge */: 3366 case 97 /* OperatorCode.f64_eq */: 3367 case 98 /* OperatorCode.f64_ne */: 3368 case 99 /* OperatorCode.f64_lt */: 3369 case 100 /* OperatorCode.f64_gt */: 3370 case 101 /* OperatorCode.f64_le */: 3371 case 102 /* OperatorCode.f64_ge */: 3372 case 103 /* OperatorCode.i32_clz */: 3373 case 104 /* OperatorCode.i32_ctz */: 3374 case 105 /* OperatorCode.i32_popcnt */: 3375 case 106 /* OperatorCode.i32_add */: 3376 case 107 /* OperatorCode.i32_sub */: 3377 case 108 /* OperatorCode.i32_mul */: 3378 case 109 /* OperatorCode.i32_div_s */: 3379 case 110 /* OperatorCode.i32_div_u */: 3380 case 111 /* OperatorCode.i32_rem_s */: 3381 case 112 /* OperatorCode.i32_rem_u */: 3382 case 113 /* OperatorCode.i32_and */: 3383 case 114 /* OperatorCode.i32_or */: 3384 case 115 /* OperatorCode.i32_xor */: 3385 case 116 /* OperatorCode.i32_shl */: 3386 case 117 /* OperatorCode.i32_shr_s */: 3387 case 118 /* OperatorCode.i32_shr_u */: 3388 case 119 /* OperatorCode.i32_rotl */: 3389 case 120 /* OperatorCode.i32_rotr */: 3390 case 121 /* OperatorCode.i64_clz */: 3391 case 122 /* OperatorCode.i64_ctz */: 3392 case 123 /* OperatorCode.i64_popcnt */: 3393 case 124 /* OperatorCode.i64_add */: 3394 case 125 /* OperatorCode.i64_sub */: 3395 case 126 /* OperatorCode.i64_mul */: 3396 case 127 /* OperatorCode.i64_div_s */: 3397 case 128 /* OperatorCode.i64_div_u */: 3398 case 129 /* OperatorCode.i64_rem_s */: 3399 case 130 /* OperatorCode.i64_rem_u */: 3400 case 131 /* OperatorCode.i64_and */: 3401 case 132 /* OperatorCode.i64_or */: 3402 case 133 /* OperatorCode.i64_xor */: 3403 case 134 /* OperatorCode.i64_shl */: 3404 case 135 /* OperatorCode.i64_shr_s */: 3405 case 136 /* OperatorCode.i64_shr_u */: 3406 case 137 /* OperatorCode.i64_rotl */: 3407 case 138 /* OperatorCode.i64_rotr */: 3408 case 139 /* OperatorCode.f32_abs */: 3409 case 140 /* OperatorCode.f32_neg */: 3410 case 141 /* OperatorCode.f32_ceil */: 3411 case 142 /* OperatorCode.f32_floor */: 3412 case 143 /* OperatorCode.f32_trunc */: 3413 case 144 /* OperatorCode.f32_nearest */: 3414 case 145 /* OperatorCode.f32_sqrt */: 3415 case 146 /* OperatorCode.f32_add */: 3416 case 147 /* OperatorCode.f32_sub */: 3417 case 148 /* OperatorCode.f32_mul */: 3418 case 149 /* OperatorCode.f32_div */: 3419 case 150 /* OperatorCode.f32_min */: 3420 case 151 /* OperatorCode.f32_max */: 3421 case 152 /* OperatorCode.f32_copysign */: 3422 case 153 /* OperatorCode.f64_abs */: 3423 case 154 /* OperatorCode.f64_neg */: 3424 case 155 /* OperatorCode.f64_ceil */: 3425 case 156 /* OperatorCode.f64_floor */: 3426 case 157 /* OperatorCode.f64_trunc */: 3427 case 158 /* OperatorCode.f64_nearest */: 3428 case 159 /* OperatorCode.f64_sqrt */: 3429 case 160 /* OperatorCode.f64_add */: 3430 case 161 /* OperatorCode.f64_sub */: 3431 case 162 /* OperatorCode.f64_mul */: 3432 case 163 /* OperatorCode.f64_div */: 3433 case 164 /* OperatorCode.f64_min */: 3434 case 165 /* OperatorCode.f64_max */: 3435 case 166 /* OperatorCode.f64_copysign */: 3436 case 167 /* OperatorCode.i32_wrap_i64 */: 3437 case 168 /* OperatorCode.i32_trunc_f32_s */: 3438 case 169 /* OperatorCode.i32_trunc_f32_u */: 3439 case 170 /* OperatorCode.i32_trunc_f64_s */: 3440 case 171 /* OperatorCode.i32_trunc_f64_u */: 3441 case 172 /* OperatorCode.i64_extend_i32_s */: 3442 case 173 /* OperatorCode.i64_extend_i32_u */: 3443 case 174 /* OperatorCode.i64_trunc_f32_s */: 3444 case 175 /* OperatorCode.i64_trunc_f32_u */: 3445 case 176 /* OperatorCode.i64_trunc_f64_s */: 3446 case 177 /* OperatorCode.i64_trunc_f64_u */: 3447 case 178 /* OperatorCode.f32_convert_i32_s */: 3448 case 179 /* OperatorCode.f32_convert_i32_u */: 3449 case 180 /* OperatorCode.f32_convert_i64_s */: 3450 case 181 /* OperatorCode.f32_convert_i64_u */: 3451 case 182 /* OperatorCode.f32_demote_f64 */: 3452 case 183 /* OperatorCode.f64_convert_i32_s */: 3453 case 184 /* OperatorCode.f64_convert_i32_u */: 3454 case 185 /* OperatorCode.f64_convert_i64_s */: 3455 case 186 /* OperatorCode.f64_convert_i64_u */: 3456 case 187 /* OperatorCode.f64_promote_f32 */: 3457 case 188 /* OperatorCode.i32_reinterpret_f32 */: 3458 case 189 /* OperatorCode.i64_reinterpret_f64 */: 3459 case 190 /* OperatorCode.f32_reinterpret_i32 */: 3460 case 191 /* OperatorCode.f64_reinterpret_i64 */: 3461 case 192 /* OperatorCode.i32_extend8_s */: 3462 case 193 /* OperatorCode.i32_extend16_s */: 3463 case 194 /* OperatorCode.i64_extend8_s */: 3464 case 195 /* OperatorCode.i64_extend16_s */: 3465 case 196 /* OperatorCode.i64_extend32_s */: 3466 case 209 /* OperatorCode.ref_is_null */: 3467 case 212 /* OperatorCode.ref_as_non_null */: 3468 case 211 /* OperatorCode.ref_eq */: 3469 case 10 /* OperatorCode.throw_ref */: 3470 break; 3471 default: 3472 this.error = new Error("Unknown operator: ".concat(code)); 3473 this.state = -1 /* BinaryReaderState.ERROR */; 3474 return true; 3475 } 3476 } 3477 this.result = { 3478 code: code, 3479 blockType: blockType, 3480 selectType: selectType, 3481 refType: refType, 3482 srcType: undefined, 3483 brDepth: brDepth, 3484 brTable: brTable, 3485 tryTable: tryTable, 3486 relativeDepth: relativeDepth, 3487 tableIndex: tableIndex, 3488 funcIndex: funcIndex, 3489 typeIndex: typeIndex, 3490 localIndex: localIndex, 3491 globalIndex: globalIndex, 3492 fieldIndex: undefined, 3493 tagIndex: tagIndex, 3494 memoryAddress: memoryAddress, 3495 literal: literal, 3496 segmentIndex: undefined, 3497 destinationIndex: undefined, 3498 len: undefined, 3499 lines: undefined, 3500 lineIndex: undefined, 3501 }; 3502 return true; 3503 }; 3504 BinaryReader.prototype.readFunctionBody = function () { 3505 if (this._sectionEntriesLeft === 0) { 3506 this.skipSection(); 3507 return this.read(); 3508 } 3509 if (!this.hasVarIntBytes()) 3510 return false; 3511 var pos = this._pos; 3512 var size = this.readVarUint32(); 3513 var bodyEnd = this._pos + size; 3514 if (!this.hasVarIntBytes()) { 3515 this._pos = pos; 3516 return false; 3517 } 3518 var localCount = this.readVarUint32(); 3519 var locals = []; 3520 for (var i = 0; i < localCount; i++) { 3521 if (!this.hasVarIntBytes()) { 3522 this._pos = pos; 3523 return false; 3524 } 3525 var count = this.readVarUint32(); 3526 if (!this.hasVarIntBytes()) { 3527 this._pos = pos; 3528 return false; 3529 } 3530 var type = this.readType(); 3531 locals.push({ count: count, type: type }); 3532 } 3533 var bodyStart = this._pos; 3534 this.state = 28 /* BinaryReaderState.BEGIN_FUNCTION_BODY */; 3535 this.result = { 3536 locals: locals, 3537 }; 3538 this._functionRange = new DataRange(bodyStart, bodyEnd); 3539 this._sectionEntriesLeft--; 3540 return true; 3541 }; 3542 BinaryReader.prototype.readSectionHeader = function () { 3543 if (this._pos >= this._length && this._eof) { 3544 this._sectionId = -1 /* SectionCode.Unknown */; 3545 this._sectionRange = null; 3546 this.result = null; 3547 this.state = 2 /* BinaryReaderState.END_WASM */; 3548 return true; 3549 } 3550 // TODO: Handle _eof. 3551 if (this._pos < this._length - 4) { 3552 var magicNumber = this.peekInt32(); 3553 if (magicNumber === WASM_MAGIC_NUMBER) { 3554 this._sectionId = -1 /* SectionCode.Unknown */; 3555 this._sectionRange = null; 3556 this.result = null; 3557 this.state = 2 /* BinaryReaderState.END_WASM */; 3558 return true; 3559 } 3560 } 3561 if (!this.hasVarIntBytes()) 3562 return false; 3563 var sectionStart = this._pos; 3564 var id = this.readVarUint7(); 3565 if (!this.hasVarIntBytes()) { 3566 this._pos = sectionStart; 3567 return false; 3568 } 3569 var payloadLength = this.readVarUint32(); 3570 var name = null; 3571 var payloadEnd = this._pos + payloadLength; 3572 if (id == 0) { 3573 if (!this.hasStringBytes()) { 3574 this._pos = sectionStart; 3575 return false; 3576 } 3577 name = this.readStringBytes(); 3578 } 3579 this.result = { id: id, name: name }; 3580 this._sectionId = id; 3581 this._sectionRange = new DataRange(this._pos, payloadEnd); 3582 this.state = 3 /* BinaryReaderState.BEGIN_SECTION */; 3583 return true; 3584 }; 3585 BinaryReader.prototype.readSectionRawData = function () { 3586 var payloadLength = this._sectionRange.end - this._sectionRange.start; 3587 if (!this.hasBytes(payloadLength)) { 3588 return false; 3589 } 3590 this.state = 7 /* BinaryReaderState.SECTION_RAW_DATA */; 3591 this.result = this.readBytes(payloadLength); 3592 return true; 3593 }; 3594 BinaryReader.prototype.readSectionBody = function () { 3595 if (this._pos >= this._sectionRange.end) { 3596 this.result = null; 3597 this.state = 4 /* BinaryReaderState.END_SECTION */; 3598 this._sectionId = -1 /* SectionCode.Unknown */; 3599 this._sectionRange = null; 3600 return true; 3601 } 3602 var currentSection = this.result; 3603 switch (currentSection.id) { 3604 case 1 /* SectionCode.Type */: 3605 if (!this.hasSectionPayload()) 3606 return false; 3607 this._sectionEntriesLeft = this.readVarUint32(); 3608 this._recGroupTypesLeft = -1; 3609 return this.readTypeEntry(); 3610 case 2 /* SectionCode.Import */: 3611 if (!this.hasSectionPayload()) 3612 return false; 3613 this._sectionEntriesLeft = this.readVarUint32(); 3614 return this.readImportEntry(); 3615 case 7 /* SectionCode.Export */: 3616 if (!this.hasSectionPayload()) 3617 return false; 3618 this._sectionEntriesLeft = this.readVarUint32(); 3619 return this.readExportEntry(); 3620 case 3 /* SectionCode.Function */: 3621 if (!this.hasSectionPayload()) 3622 return false; 3623 this._sectionEntriesLeft = this.readVarUint32(); 3624 return this.readFunctionEntry(); 3625 case 4 /* SectionCode.Table */: 3626 if (!this.hasSectionPayload()) 3627 return false; 3628 this._sectionEntriesLeft = this.readVarUint32(); 3629 return this.readTableEntry(); 3630 case 5 /* SectionCode.Memory */: 3631 if (!this.hasSectionPayload()) 3632 return false; 3633 this._sectionEntriesLeft = this.readVarUint32(); 3634 return this.readMemoryEntry(); 3635 case 6 /* SectionCode.Global */: 3636 if (!this.hasVarIntBytes()) 3637 return false; 3638 this._sectionEntriesLeft = this.readVarUint32(); 3639 return this.readGlobalEntry(); 3640 case 8 /* SectionCode.Start */: 3641 if (!this.hasVarIntBytes()) 3642 return false; 3643 this.state = 22 /* BinaryReaderState.START_SECTION_ENTRY */; 3644 this.result = { index: this.readVarUint32() }; 3645 return true; 3646 case 10 /* SectionCode.Code */: 3647 if (!this.hasVarIntBytes()) 3648 return false; 3649 this._sectionEntriesLeft = this.readVarUint32(); 3650 this.state = 29 /* BinaryReaderState.READING_FUNCTION_HEADER */; 3651 return this.readFunctionBody(); 3652 case 9 /* SectionCode.Element */: 3653 if (!this.hasVarIntBytes()) 3654 return false; 3655 this._sectionEntriesLeft = this.readVarUint32(); 3656 return this.readElementEntry(); 3657 case 11 /* SectionCode.Data */: 3658 if (!this.hasVarIntBytes()) 3659 return false; 3660 this._sectionEntriesLeft = this.readVarUint32(); 3661 return this.readDataEntry(); 3662 case 12 /* SectionCode.DataCount */: 3663 if (!this.hasVarIntBytes()) 3664 return false; 3665 this._sectionEntriesLeft = this.readVarUint32(); 3666 return this.readDataCountEntry(); 3667 case 13 /* SectionCode.Tag */: 3668 if (!this.hasVarIntBytes()) 3669 return false; 3670 this._sectionEntriesLeft = this.readVarUint32(); 3671 return this.readTagEntry(); 3672 case 0 /* SectionCode.Custom */: 3673 var customSectionName = (0, exports.bytesToString)(currentSection.name); 3674 if (customSectionName === "name") { 3675 return this.readNameEntry(); 3676 } 3677 if (customSectionName.indexOf("reloc.") === 0) { 3678 return this.readRelocHeader(); 3679 } 3680 if (customSectionName === "linking") { 3681 if (!this.hasVarIntBytes()) 3682 return false; 3683 this._sectionEntriesLeft = this.readVarUint32(); 3684 return this.readLinkingEntry(); 3685 } 3686 if (customSectionName === "sourceMappingURL") { 3687 return this.readSourceMappingURL(); 3688 } 3689 return this.readSectionRawData(); 3690 default: 3691 this.error = new Error("Unsupported section: ".concat(this._sectionId)); 3692 this.state = -1 /* BinaryReaderState.ERROR */; 3693 return true; 3694 } 3695 }; 3696 BinaryReader.prototype.read = function () { 3697 switch (this.state) { 3698 case 0 /* BinaryReaderState.INITIAL */: 3699 if (!this.hasBytes(8)) 3700 return false; 3701 var magicNumber = this.readUint32(); 3702 if (magicNumber != WASM_MAGIC_NUMBER) { 3703 this.error = new Error("Bad magic number"); 3704 this.state = -1 /* BinaryReaderState.ERROR */; 3705 return true; 3706 } 3707 var version = this.readUint32(); 3708 if (version != WASM_SUPPORTED_VERSION && 3709 version != WASM_SUPPORTED_EXPERIMENTAL_VERSION) { 3710 this.error = new Error("Bad version number ".concat(version)); 3711 this.state = -1 /* BinaryReaderState.ERROR */; 3712 return true; 3713 } 3714 this.result = { magicNumber: magicNumber, version: version }; 3715 this.state = 1 /* BinaryReaderState.BEGIN_WASM */; 3716 return true; 3717 case 2 /* BinaryReaderState.END_WASM */: 3718 this.result = null; 3719 this.state = 1 /* BinaryReaderState.BEGIN_WASM */; 3720 if (this.hasMoreBytes()) { 3721 this.state = 0 /* BinaryReaderState.INITIAL */; 3722 return this.read(); 3723 } 3724 return false; 3725 case -1 /* BinaryReaderState.ERROR */: 3726 return true; 3727 case 1 /* BinaryReaderState.BEGIN_WASM */: 3728 case 4 /* BinaryReaderState.END_SECTION */: 3729 return this.readSectionHeader(); 3730 case 3 /* BinaryReaderState.BEGIN_SECTION */: 3731 return this.readSectionBody(); 3732 case 5 /* BinaryReaderState.SKIPPING_SECTION */: 3733 if (!this.hasSectionPayload()) { 3734 return false; 3735 } 3736 this.state = 4 /* BinaryReaderState.END_SECTION */; 3737 this._pos = this._sectionRange.end; 3738 this._sectionId = -1 /* SectionCode.Unknown */; 3739 this._sectionRange = null; 3740 this.result = null; 3741 return true; 3742 case 32 /* BinaryReaderState.SKIPPING_FUNCTION_BODY */: 3743 this.state = 31 /* BinaryReaderState.END_FUNCTION_BODY */; 3744 this._pos = this._functionRange.end; 3745 this._functionRange = null; 3746 this.result = null; 3747 return true; 3748 case 11 /* BinaryReaderState.TYPE_SECTION_ENTRY */: 3749 if (this._recGroupTypesLeft >= 0) { 3750 return this.readRecGroupEntry(); 3751 } 3752 return this.readTypeEntry(); 3753 case 47 /* BinaryReaderState.BEGIN_REC_GROUP */: 3754 return this.readRecGroupEntry(); 3755 case 48 /* BinaryReaderState.END_REC_GROUP */: 3756 return this.readTypeEntry(); 3757 case 12 /* BinaryReaderState.IMPORT_SECTION_ENTRY */: 3758 return this.readImportEntry(); 3759 case 17 /* BinaryReaderState.EXPORT_SECTION_ENTRY */: 3760 return this.readExportEntry(); 3761 case 13 /* BinaryReaderState.FUNCTION_SECTION_ENTRY */: 3762 return this.readFunctionEntry(); 3763 case 14 /* BinaryReaderState.TABLE_SECTION_ENTRY */: 3764 return this.readTableEntry(); 3765 case 15 /* BinaryReaderState.MEMORY_SECTION_ENTRY */: 3766 return this.readMemoryEntry(); 3767 case 23 /* BinaryReaderState.TAG_SECTION_ENTRY */: 3768 return this.readTagEntry(); 3769 case 16 /* BinaryReaderState.GLOBAL_SECTION_ENTRY */: 3770 case 40 /* BinaryReaderState.END_GLOBAL_SECTION_ENTRY */: 3771 return this.readGlobalEntry(); 3772 case 39 /* BinaryReaderState.BEGIN_GLOBAL_SECTION_ENTRY */: 3773 return this.readInitExpressionBody(); 3774 case 20 /* BinaryReaderState.ELEMENT_SECTION_ENTRY */: 3775 case 35 /* BinaryReaderState.END_ELEMENT_SECTION_ENTRY */: 3776 return this.readElementEntry(); 3777 case 33 /* BinaryReaderState.BEGIN_ELEMENT_SECTION_ENTRY */: 3778 if (isActiveElementSegmentType(this._segmentType)) { 3779 return this.readOffsetExpressionBody(); 3780 } 3781 else { 3782 // passive or declared element segment 3783 return this.readElementEntryBody(); 3784 } 3785 case 34 /* BinaryReaderState.ELEMENT_SECTION_ENTRY_BODY */: 3786 if (!this.hasVarIntBytes()) 3787 return false; 3788 this._segmentEntriesLeft = this.readVarUint32(); 3789 if (this._segmentEntriesLeft === 0) { 3790 this.state = 35 /* BinaryReaderState.END_ELEMENT_SECTION_ENTRY */; 3791 this.result = null; 3792 return true; 3793 } 3794 return this.readInitExpressionBody(); 3795 case 49 /* BinaryReaderState.DATA_COUNT_SECTION_ENTRY */: 3796 return this.readDataCountEntry(); 3797 case 18 /* BinaryReaderState.DATA_SECTION_ENTRY */: 3798 case 38 /* BinaryReaderState.END_DATA_SECTION_ENTRY */: 3799 return this.readDataEntry(); 3800 case 36 /* BinaryReaderState.BEGIN_DATA_SECTION_ENTRY */: 3801 if (isActiveDataSegmentType(this._segmentType)) { 3802 return this.readOffsetExpressionBody(); 3803 } 3804 else { 3805 // passive data segment 3806 return this.readDataEntryBody(); 3807 } 3808 case 37 /* BinaryReaderState.DATA_SECTION_ENTRY_BODY */: 3809 this.state = 38 /* BinaryReaderState.END_DATA_SECTION_ENTRY */; 3810 this.result = null; 3811 return true; 3812 case 27 /* BinaryReaderState.END_INIT_EXPRESSION_BODY */: 3813 switch (this._sectionId) { 3814 case 6 /* SectionCode.Global */: 3815 this.state = 40 /* BinaryReaderState.END_GLOBAL_SECTION_ENTRY */; 3816 return true; 3817 case 9 /* SectionCode.Element */: 3818 if (--this._segmentEntriesLeft > 0) { 3819 return this.readInitExpressionBody(); 3820 } 3821 this.state = 35 /* BinaryReaderState.END_ELEMENT_SECTION_ENTRY */; 3822 this.result = null; 3823 return true; 3824 } 3825 this.error = new Error("Unexpected section type: ".concat(this._sectionId)); 3826 this.state = -1 /* BinaryReaderState.ERROR */; 3827 return true; 3828 case 46 /* BinaryReaderState.END_OFFSET_EXPRESSION_BODY */: 3829 if (this._sectionId === 11 /* SectionCode.Data */) { 3830 return this.readDataEntryBody(); 3831 } 3832 else { 3833 return this.readElementEntryBody(); 3834 } 3835 case 19 /* BinaryReaderState.NAME_SECTION_ENTRY */: 3836 return this.readNameEntry(); 3837 case 41 /* BinaryReaderState.RELOC_SECTION_HEADER */: 3838 if (!this.hasVarIntBytes()) 3839 return false; 3840 this._sectionEntriesLeft = this.readVarUint32(); 3841 return this.readRelocEntry(); 3842 case 21 /* BinaryReaderState.LINKING_SECTION_ENTRY */: 3843 return this.readLinkingEntry(); 3844 case 43 /* BinaryReaderState.SOURCE_MAPPING_URL */: 3845 this.state = 4 /* BinaryReaderState.END_SECTION */; 3846 this.result = null; 3847 return true; 3848 case 42 /* BinaryReaderState.RELOC_SECTION_ENTRY */: 3849 return this.readRelocEntry(); 3850 case 29 /* BinaryReaderState.READING_FUNCTION_HEADER */: 3851 case 31 /* BinaryReaderState.END_FUNCTION_BODY */: 3852 return this.readFunctionBody(); 3853 case 28 /* BinaryReaderState.BEGIN_FUNCTION_BODY */: 3854 this.state = 30 /* BinaryReaderState.CODE_OPERATOR */; 3855 return this.readCodeOperator(); 3856 case 25 /* BinaryReaderState.BEGIN_INIT_EXPRESSION_BODY */: 3857 this.state = 26 /* BinaryReaderState.INIT_EXPRESSION_OPERATOR */; 3858 return this.readCodeOperator(); 3859 case 44 /* BinaryReaderState.BEGIN_OFFSET_EXPRESSION_BODY */: 3860 this.state = 45 /* BinaryReaderState.OFFSET_EXPRESSION_OPERATOR */; 3861 return this.readCodeOperator(); 3862 case 30 /* BinaryReaderState.CODE_OPERATOR */: 3863 case 26 /* BinaryReaderState.INIT_EXPRESSION_OPERATOR */: 3864 case 45 /* BinaryReaderState.OFFSET_EXPRESSION_OPERATOR */: 3865 return this.readCodeOperator(); 3866 case 6 /* BinaryReaderState.READING_SECTION_RAW_DATA */: 3867 return this.readSectionRawData(); 3868 case 22 /* BinaryReaderState.START_SECTION_ENTRY */: 3869 case 7 /* BinaryReaderState.SECTION_RAW_DATA */: 3870 this.state = 4 /* BinaryReaderState.END_SECTION */; 3871 this.result = null; 3872 return true; 3873 default: 3874 this.error = new Error("Unsupported state: ".concat(this.state)); 3875 this.state = -1 /* BinaryReaderState.ERROR */; 3876 return true; 3877 } 3878 }; 3879 BinaryReader.prototype.skipSection = function () { 3880 if (this.state === -1 /* BinaryReaderState.ERROR */ || 3881 this.state === 0 /* BinaryReaderState.INITIAL */ || 3882 this.state === 4 /* BinaryReaderState.END_SECTION */ || 3883 this.state === 1 /* BinaryReaderState.BEGIN_WASM */ || 3884 this.state === 2 /* BinaryReaderState.END_WASM */) 3885 return; 3886 this.state = 5 /* BinaryReaderState.SKIPPING_SECTION */; 3887 }; 3888 BinaryReader.prototype.skipFunctionBody = function () { 3889 if (this.state !== 28 /* BinaryReaderState.BEGIN_FUNCTION_BODY */ && 3890 this.state !== 30 /* BinaryReaderState.CODE_OPERATOR */) 3891 return; 3892 this.state = 32 /* BinaryReaderState.SKIPPING_FUNCTION_BODY */; 3893 }; 3894 BinaryReader.prototype.skipInitExpression = function () { 3895 while (this.state === 26 /* BinaryReaderState.INIT_EXPRESSION_OPERATOR */) 3896 this.readCodeOperator(); 3897 }; 3898 BinaryReader.prototype.fetchSectionRawData = function () { 3899 if (this.state !== 3 /* BinaryReaderState.BEGIN_SECTION */) { 3900 this.error = new Error("Unsupported state: ".concat(this.state)); 3901 this.state = -1 /* BinaryReaderState.ERROR */; 3902 return; 3903 } 3904 this.state = 6 /* BinaryReaderState.READING_SECTION_RAW_DATA */; 3905 }; 3906 return BinaryReader; 3907 }()); 3908 exports.BinaryReader = BinaryReader; 3909 if (typeof TextDecoder !== "undefined") { 3910 try { 3911 exports.bytesToString = (function () { 3912 var utf8Decoder = new TextDecoder("utf-8"); 3913 utf8Decoder.decode(new Uint8Array([97, 208, 144])); 3914 return function (b) { return utf8Decoder.decode(b); }; 3915 })(); 3916 } 3917 catch (_) { 3918 /* ignore */ 3919 } 3920 } 3921 if (!exports.bytesToString) { 3922 exports.bytesToString = function (b) { 3923 var str = String.fromCharCode.apply(null, b); 3924 return decodeURIComponent(escape(str)); 3925 }; 3926 }