OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/wasm/module-decoder.h" | 5 #include "src/wasm/module-decoder.h" |
6 | 6 |
7 #include "src/base/functional.h" | 7 #include "src/base/functional.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/flags.h" | 9 #include "src/flags.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 0, // module_name_offset | 273 0, // module_name_offset |
274 0, // field_name_offset | 274 0, // field_name_offset |
275 0, // field_name_length | 275 0, // field_name_length |
276 kExternalFunction, // kind | 276 kExternalFunction, // kind |
277 0 // index | 277 0 // index |
278 }); | 278 }); |
279 WasmImport* import = &module->import_table.back(); | 279 WasmImport* import = &module->import_table.back(); |
280 const byte* pos = pc_; | 280 const byte* pos = pc_; |
281 import->module_name_offset = | 281 import->module_name_offset = |
282 consume_string(&import->module_name_length, true); | 282 consume_string(&import->module_name_length, true); |
283 if (import->module_name_length == 0) { | |
284 error(pos, "import module name cannot be NULL"); | |
285 } | |
286 import->field_name_offset = | 283 import->field_name_offset = |
287 consume_string(&import->field_name_length, true); | 284 consume_string(&import->field_name_length, true); |
288 | 285 |
289 import->kind = static_cast<WasmExternalKind>(consume_u8("import kind")); | 286 import->kind = static_cast<WasmExternalKind>(consume_u8("import kind")); |
290 switch (import->kind) { | 287 switch (import->kind) { |
291 case kExternalFunction: { | 288 case kExternalFunction: { |
292 // ===== Imported function ======================================= | 289 // ===== Imported function ======================================= |
293 import->index = static_cast<uint32_t>(module->functions.size()); | 290 import->index = static_cast<uint32_t>(module->functions.size()); |
294 module->num_imported_functions++; | 291 module->num_imported_functions++; |
295 module->functions.push_back({nullptr, // sig | 292 module->functions.push_back({nullptr, // sig |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 table.push_back(std::move(func_asm_offsets)); | 1221 table.push_back(std::move(func_asm_offsets)); |
1225 } | 1222 } |
1226 if (decoder.more()) decoder.error("unexpected additional bytes"); | 1223 if (decoder.more()) decoder.error("unexpected additional bytes"); |
1227 | 1224 |
1228 return decoder.toResult(std::move(table)); | 1225 return decoder.toResult(std::move(table)); |
1229 } | 1226 } |
1230 | 1227 |
1231 } // namespace wasm | 1228 } // namespace wasm |
1232 } // namespace internal | 1229 } // namespace internal |
1233 } // namespace v8 | 1230 } // namespace v8 |
OLD | NEW |