Index: src/wasm/module-decoder.cc |
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc |
index 865d481bed89a42552db5465e57155b849fdfab1..90065616d93db85ef9dbe817302f6b8a06028f86 100644 |
--- a/src/wasm/module-decoder.cc |
+++ b/src/wasm/module-decoder.cc |
@@ -318,7 +318,7 @@ |
// ===== Imported global ========================================= |
import->index = static_cast<uint32_t>(module->globals.size()); |
module->globals.push_back( |
- {kAstStmt, false, WasmInitExpr(), 0, true, false}); |
+ {kAstStmt, false, NO_INIT, 0, true, false}); |
WasmGlobal* global = &module->globals.back(); |
global->type = consume_value_type(); |
global->mutability = consume_u8("mutability") != 0; |
@@ -399,8 +399,7 @@ |
TRACE("DecodeGlobal[%d] module+%d\n", i, |
static_cast<int>(pc_ - start_)); |
// Add an uninitialized global and pass a pointer to it. |
- module->globals.push_back( |
- {kAstStmt, false, WasmInitExpr(), 0, false, false}); |
+ module->globals.push_back({kAstStmt, false, NO_INIT, 0, false, false}); |
WasmGlobal* global = &module->globals.back(); |
DecodeGlobalInModule(module, i, global); |
} |
@@ -546,9 +545,9 @@ |
TRACE("DecodeDataSegment[%d] module+%d\n", i, |
static_cast<int>(pc_ - start_)); |
module->data_segments.push_back({ |
- WasmInitExpr(), // dest_addr |
- 0, // source_offset |
- 0 // source_size |
+ NO_INIT, // dest_addr |
+ 0, // source_offset |
+ 0 // source_size |
}); |
WasmDataSegment* segment = &module->data_segments.back(); |
DecodeDataSegmentInModule(module, segment); |
@@ -648,19 +647,13 @@ |
const byte* pos = pc(); |
global->init = consume_init_expr(module, kAstStmt); |
switch (global->init.kind) { |
- case WasmInitExpr::kGlobalIndex: { |
- uint32_t other_index = global->init.val.global_index; |
- if (other_index >= index) { |
+ case WasmInitExpr::kGlobalIndex: |
+ if (global->init.val.global_index >= index) { |
error("invalid global index in init expression"); |
- } else if (module->globals[other_index].type != global->type) { |
- error(pos, pos, |
- "type mismatch in global initialization " |
- "(from global #%u), expected %s, got %s", |
- other_index, WasmOpcodes::TypeName(global->type), |
- WasmOpcodes::TypeName(module->globals[other_index].type)); |
+ } else if (module->globals[index].type != global->type) { |
+ error("type mismatch in global initialization"); |
} |
break; |
- } |
default: |
if (global->type != TypeOf(module, global->init)) { |
error(pos, pos, |