diff options
Diffstat (limited to 'src/binary-reader.cc')
-rw-r--r-- | src/binary-reader.cc | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/binary-reader.cc b/src/binary-reader.cc index c01216e4..33fd3337 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -1343,22 +1343,22 @@ Result BinaryReader::ReadFunctionBody(Offset end_offset) { } case Opcode::TableInit: { + Index segment; + CHECK_RESULT(ReadIndex(&segment, "elem segment index")); uint8_t reserved; CHECK_RESULT(ReadU8(&reserved, "reserved table index")); ERROR_UNLESS(reserved == 0, "reserved value must be 0"); - Index segment; - CHECK_RESULT(ReadIndex(&segment, "elem segment index")); CALLBACK(OnTableInitExpr, segment); CALLBACK(OnOpcodeUint32Uint32, segment, reserved); break; } case Opcode::MemoryInit: { + Index segment; + CHECK_RESULT(ReadIndex(&segment, "elem segment index")); uint8_t reserved; CHECK_RESULT(ReadU8(&reserved, "reserved memory index")); ERROR_UNLESS(reserved == 0, "reserved value must be 0"); - Index segment; - CHECK_RESULT(ReadIndex(&segment, "elem segment index")); CALLBACK(OnMemoryInitExpr, segment); CALLBACK(OnOpcodeUint32Uint32, segment, reserved); break; @@ -1377,26 +1377,33 @@ Result BinaryReader::ReadFunctionBody(Offset end_offset) { break; } - case Opcode::MemoryCopy: case Opcode::MemoryFill: { uint8_t reserved; CHECK_RESULT(ReadU8(&reserved, "reserved memory index")); ERROR_UNLESS(reserved == 0, "reserved value must be 0"); - if (opcode == Opcode::MemoryCopy) { - CALLBACK(OnMemoryCopyExpr); - } else { - CALLBACK(OnMemoryFillExpr); - } + CALLBACK(OnMemoryFillExpr); CALLBACK(OnOpcodeUint32, reserved); break; } + case Opcode::MemoryCopy: { + uint8_t reserved; + CHECK_RESULT(ReadU8(&reserved, "reserved memory index")); + ERROR_UNLESS(reserved == 0, "reserved value must be 0"); + CHECK_RESULT(ReadU8(&reserved, "reserved memory index")); + ERROR_UNLESS(reserved == 0, "reserved value must be 0"); + CALLBACK(OnMemoryCopyExpr); + CALLBACK(OnOpcodeUint32Uint32, reserved, reserved); + break; + } case Opcode::TableCopy: { uint8_t reserved; CHECK_RESULT(ReadU8(&reserved, "reserved table index")); ERROR_UNLESS(reserved == 0, "reserved value must be 0"); + CHECK_RESULT(ReadU8(&reserved, "reserved table index")); + ERROR_UNLESS(reserved == 0, "reserved value must be 0"); CALLBACK(OnTableCopyExpr); - CALLBACK(OnOpcodeUint32, reserved); + CALLBACK(OnOpcodeUint32Uint32, reserved, reserved); break; } |