summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2023-12-03 00:09:39 +0100
committerHenry Gressmann <mail@henrygressmann.de>2023-12-03 00:09:39 +0100
commit0b3dc0eb015fadeee3d6417451e6951cb8a6d751 (patch)
treed80587326dce02de8d570d0e338c57077237cf2c /crates
parent7f72605405443482add128cb66b7d09e6bb59de9 (diff)
docs: update readme
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates')
-rw-r--r--crates/parser/src/conversion.rs2
-rw-r--r--crates/types/src/instructions.rs7
2 files changed, 6 insertions, 3 deletions
diff --git a/crates/parser/src/conversion.rs b/crates/parser/src/conversion.rs
index ee30db9..86810a1 100644
--- a/crates/parser/src/conversion.rs
+++ b/crates/parser/src/conversion.rs
@@ -109,7 +109,7 @@ pub fn process_operators<'a>(
.targets()
.collect::<Result<Vec<u32>, wasmparser::BinaryReaderError>>()?
.into_iter()
- .map(Instruction::Br),
+ .map(Instruction::BrLabel),
);
}
op => instructions.push(process_operator(&op)?),
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs
index dca99fe..2be0ce7 100644
--- a/crates/types/src/instructions.rs
+++ b/crates/types/src/instructions.rs
@@ -16,7 +16,9 @@ pub struct MemArg {
/// A WebAssembly Instruction
/// See https://webassembly.github.io/spec/core/binary/instructions.html
-/// Currently includes all instructions from the MVP (1.0) spec
+/// These are our own internal bytecode instructions so they may not match the spec exactly.
+/// Wasm Bytecode can map to multiple of these instructions.
+/// For example, `br_table` stores the jump lables in the following `br_label` instructions to keep this enum small.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Instruction {
// Control Instructions
@@ -30,7 +32,8 @@ pub enum Instruction {
End,
Br(LabelAddr),
BrIf(LabelAddr),
- BrTable(u32), // not to spec, has to be followed by multiple Br instructions with labels
+ BrTable(u32), // has to be followed by multiple BrLabel instructions
+ BrLabel(LabelAddr),
Return,
Call(FuncAddr),
CallIndirect(TypeAddr, TableAddr),