diff options
| author | Henry <mail@henrygressmann.de> | 2023-12-22 00:03:03 +0100 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2023-12-22 00:03:03 +0100 |
| commit | 295a48c57672b3e7109c1d650313a00e15a6c01d (patch) | |
| tree | 419a73091059fa16d8c914432d08315beeefb02a /crates/types | |
| parent | fcb92cab9a440931ebc90dfdb94974084d5e066b (diff) | |
feat: improve parser
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/types')
| -rw-r--r-- | crates/types/src/lib.rs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index a6cf037..2e76ac5 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -26,9 +26,9 @@ extern crate alloc; // } mod instructions; -use core::fmt::Debug; +use core::{fmt::Debug, ops::Range}; -use alloc::{boxed::Box, string::String}; +use alloc::boxed::Box; pub use instructions::*; /// A TinyWasm WebAssembly Module @@ -61,9 +61,13 @@ pub struct TinyWasmModule { /// The memories of the WebAssembly module. pub memory_types: Box<[MemoryType]>, + + /// The imports of the WebAssembly module. + pub imports: Box<[Import]>, + + /// Data segments of the WebAssembly module. + pub data: Box<[Data]>, // pub elements: Option<ElementSectionReader<'a>>, - // pub imports: Option<ImportSectionReader<'a>>, - // pub data_segments: Option<DataSectionReader<'a>>, } /// A WebAssembly value. @@ -337,9 +341,8 @@ pub enum MemoryArch { #[derive(Debug, Clone)] pub struct Import { - /// Represents an import in a WebAssembly module. - pub module: String, - pub name: String, + pub module: Box<str>, + pub name: Box<str>, pub kind: ImportKind, } @@ -350,3 +353,16 @@ pub enum ImportKind { Mem(MemoryType), Global(GlobalType), } + +#[derive(Debug, Clone)] +pub struct Data { + pub data: Box<[u8]>, + pub range: Range<usize>, + pub kind: DataKind, +} + +#[derive(Debug, Clone)] +pub enum DataKind { + Active { mem: MemAddr, offset: ConstInstruction }, + Passive, +} |
