diff options
| author | Henry Gressmann <mail@henrygressmann.de> | 2023-12-18 15:01:30 +0100 |
|---|---|---|
| committer | Henry Gressmann <mail@henrygressmann.de> | 2023-12-18 15:01:30 +0100 |
| commit | 8f33b67404160ce8cf35a22c0d0993112b5abe9c (patch) | |
| tree | a94aa18a777d4d47c1b5dbc25abe0851883938c2 /crates/types | |
| parent | 45c740b7d7553d3016cf5c73b891f512a9975afe (diff) | |
feat: global parsing, improve testsuite
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/types')
| -rw-r--r-- | crates/types/src/instructions.rs | 9 | ||||
| -rw-r--r-- | crates/types/src/lib.rs | 9 |
2 files changed, 17 insertions, 1 deletions
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index d8aff7b..3f7b2ef 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -19,6 +19,15 @@ type BrTableLen = usize; type EndOffset = usize; type ElseOffset = usize; +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum ConstInstruction { + I32Const(i32), + I64Const(i64), + F32Const(f32), + F64Const(f64), + GlobalGet(GlobalAddr), +} + /// A WebAssembly Instruction /// /// These are our own internal bytecode instructions so they may not match the spec exactly. diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index b7bf623..ddc8ce4 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -52,9 +52,9 @@ pub struct TinyWasmModule { /// The exports of the WebAssembly module. pub exports: Box<[Export]>, + pub globals: Box<[Global]>, // pub tables: Option<TableType>, // pub memories: Option<MemoryType>, - // pub globals: Option<GlobalType>, // pub elements: Option<ElementSectionReader<'a>>, // pub imports: Option<ImportSectionReader<'a>>, // pub data_segments: Option<DataSectionReader<'a>>, @@ -293,3 +293,10 @@ pub struct Export { /// The index of the exported item. pub index: u32, } + +#[derive(Debug, Clone)] +pub struct Global { + pub mutable: bool, + pub ty: ValType, + pub init: ConstInstruction, +} |
