summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry <mail@henrygressmann.de>2023-12-23 18:35:49 +0100
committerHenry <mail@henrygressmann.de>2023-12-23 18:35:49 +0100
commit4ee0bacbf79c41661b24e6cb9e4420cca33dc039 (patch)
treeacdfdade801fa435472293ff46279dd0a0898828
parent154d5fe5311ede2be44036900ad7598fe5fc8664 (diff)
chore: parse element sections, improve contributing.md
Signed-off-by: Henry <mail@henrygressmann.de>
-rw-r--r--CONTRIBUTING.md14
-rw-r--r--crates/parser/src/conversion.rs53
-rw-r--r--crates/parser/src/lib.rs1
-rw-r--r--crates/parser/src/module.rs12
-rw-r--r--crates/tinywasm/tests/generated/mvp.csv2
-rw-r--r--crates/tinywasm/tests/generated/progress-mvp.svg6
-rw-r--r--crates/types/src/lib.rs25
7 files changed, 95 insertions, 18 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2b0b8b8..73d93ce 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,17 +1,21 @@
-# Common Commands
+# Scripts and Commands
-> To improve the development experience, a number of aliases have been added to the `.cargo/config.toml` file. These can be run using `cargo <command>`.
+> To improve the development experience, a number of custom commands and aliases have been added to the `.cargo/config.toml` file. These can be run using `cargo <command>`.
-- **`cargo dev`**\
+- **`cargo dev [args]`**\
e.g. `cargo dev -f check ./examples/wasm/call.wat -a i32:0`\
- Run the development version of the tinywasm-cli. This is the main command used for developing new features.
+ Run the development version of the tinywasm-cli. This is the main command used for developing new features.\
+ See [tinywasm-cli](./crates/cli) for more information.
- **`cargo generate-charts`**\
- Generate test result charts
+ Generate test result charts from the previous test runs. This is used to generate the charts in the [README](./README.md).
- **`cargo test-mvp`**\
Run the WebAssembly MVP (1.0) test suite. Be sure to cloned this repo with `--recursive` or initialize the submodules with `git submodule update --init --recursive`
+- **`cargo test-wast <path>`**\
+ Run a single WAST test file. e.g. `cargo test-wast ./examples/wast/i32.wast`
+
- **`cargo version-dev`**\
Bump the version to the next dev version. This should be used after a release so test results are not overwritten. Does not create a new github release.
diff --git a/crates/parser/src/conversion.rs b/crates/parser/src/conversion.rs
index 700cb0c..2c78e67 100644
--- a/crates/parser/src/conversion.rs
+++ b/crates/parser/src/conversion.rs
@@ -1,13 +1,62 @@
use alloc::{boxed::Box, format, string::ToString, vec::Vec};
use log::info;
use tinywasm_types::{
- BlockArgs, ConstInstruction, Export, ExternalKind, FuncType, Global, GlobalType, Import, ImportKind, Instruction,
- MemArg, MemoryArch, MemoryType, TableType, ValType,
+ BlockArgs, ConstInstruction, ElementItem, Export, ExternalKind, FuncType, Global, GlobalType, Import, ImportKind,
+ Instruction, MemArg, MemoryArch, MemoryType, TableType, ValType,
};
use wasmparser::{FuncValidator, OperatorsReader, ValidatorResources};
use crate::{module::CodeSection, Result};
+pub(crate) fn convert_module_elements<'a, T: IntoIterator<Item = wasmparser::Result<wasmparser::Element<'a>>>>(
+ elements: T,
+) -> Result<Vec<tinywasm_types::Element>> {
+ let elements = elements
+ .into_iter()
+ .map(|element| convert_module_element(element?))
+ .collect::<Result<Vec<_>>>()?;
+ Ok(elements)
+}
+
+pub(crate) fn convert_module_element(element: wasmparser::Element<'_>) -> Result<tinywasm_types::Element> {
+ let kind = match element.kind {
+ wasmparser::ElementKind::Active {
+ table_index,
+ offset_expr,
+ } => tinywasm_types::ElementKind::Active {
+ table: table_index,
+ offset: process_const_operators(offset_expr.get_operators_reader())?,
+ },
+ wasmparser::ElementKind::Passive => tinywasm_types::ElementKind::Passive,
+ wasmparser::ElementKind::Declared => tinywasm_types::ElementKind::Declared,
+ };
+
+ let items = match element.items {
+ wasmparser::ElementItems::Functions(funcs) => funcs
+ .into_iter()
+ .map(|func| Ok(ElementItem::Func(func?)))
+ .collect::<Result<Vec<_>>>()?
+ .into_boxed_slice(),
+
+ wasmparser::ElementItems::Expressions(exprs) => exprs
+ .into_iter()
+ .map(|expr| {
+ Ok(ElementItem::Expr(process_const_operators(
+ expr?.get_operators_reader(),
+ )?))
+ })
+ .collect::<Result<Vec<_>>>()?
+ .into_boxed_slice(),
+ };
+
+ Ok(tinywasm_types::Element {
+ kind,
+ items,
+ ty: convert_valtype(&element.ty),
+ range: element.range,
+ })
+}
+
pub(crate) fn convert_module_data_sections<'a, T: IntoIterator<Item = wasmparser::Result<wasmparser::Data<'a>>>>(
data_sections: T,
) -> Result<Vec<tinywasm_types::Data>> {
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index f1477f9..22e2661 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -128,6 +128,7 @@ impl TryFrom<ModuleReader> for TinyWasmModule {
memory_types: reader.memory_types.into_boxed_slice(),
imports: reader.imports.into_boxed_slice(),
data: reader.data.into_boxed_slice(),
+ elements: reader.elements.into_boxed_slice(),
})
}
}
diff --git a/crates/parser/src/module.rs b/crates/parser/src/module.rs
index fdad900..660a702 100644
--- a/crates/parser/src/module.rs
+++ b/crates/parser/src/module.rs
@@ -2,7 +2,7 @@ use crate::log::debug;
use crate::{conversion, ParseError, Result};
use alloc::{boxed::Box, format, vec::Vec};
use core::fmt::Debug;
-use tinywasm_types::{Data, Export, FuncType, Global, Import, Instruction, MemoryType, TableType, ValType};
+use tinywasm_types::{Data, Element, Export, FuncType, Global, Import, Instruction, MemoryType, TableType, ValType};
use wasmparser::{Payload, Validator};
#[derive(Debug, Clone, PartialEq)]
@@ -25,6 +25,7 @@ pub struct ModuleReader {
pub memory_types: Vec<MemoryType>,
pub imports: Vec<Import>,
pub data: Vec<Data>,
+ pub elements: Vec<Element>,
// pub element_section: Option<ElementSectionReader<'a>>,
pub end_reached: bool,
@@ -122,11 +123,10 @@ impl ModuleReader {
validator.memory_section(&reader)?;
self.memory_types = conversion::convert_module_memories(reader)?;
}
- ElementSection(_reader) => {
- return Err(ParseError::UnsupportedSection("Element section".into()));
- // debug!("Found element section");
- // validator.element_section(&reader)?;
- // self.element_section = Some(reader);
+ ElementSection(reader) => {
+ debug!("Found element section");
+ validator.element_section(&reader)?;
+ self.elements = conversion::convert_module_elements(reader)?;
}
DataSection(reader) => {
if !self.data.is_empty() {
diff --git a/crates/tinywasm/tests/generated/mvp.csv b/crates/tinywasm/tests/generated/mvp.csv
index 37ea08e..0ba833a 100644
--- a/crates/tinywasm/tests/generated/mvp.csv
+++ b/crates/tinywasm/tests/generated/mvp.csv
@@ -1,4 +1,4 @@
0.0.3,9258,7567,[{"name":"address.wast","passed":0,"failed":54},{"name":"align.wast","passed":0,"failed":109},{"name":"binary-leb128.wast","passed":66,"failed":25},{"name":"binary.wast","passed":104,"failed":8},{"name":"block.wast","passed":0,"failed":171},{"name":"br.wast","passed":0,"failed":21},{"name":"br_if.wast","passed":0,"failed":30},{"name":"br_table.wast","passed":0,"failed":25},{"name":"call.wast","passed":0,"failed":22},{"name":"call_indirect.wast","passed":0,"failed":56},{"name":"comments.wast","passed":4,"failed":4},{"name":"const.wast","passed":702,"failed":76},{"name":"conversions.wast","passed":0,"failed":93},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":0,"failed":61},{"name":"elem.wast","passed":0,"failed":76},{"name":"endianness.wast","passed":0,"failed":1},{"name":"exports.wast","passed":21,"failed":73},{"name":"f32.wast","passed":1005,"failed":1509},{"name":"f32_bitwise.wast","passed":1,"failed":363},{"name":"f32_cmp.wast","passed":2401,"failed":6},{"name":"f64.wast","passed":1005,"failed":1509},{"name":"f64_bitwise.wast","passed":1,"failed":363},{"name":"f64_cmp.wast","passed":2401,"failed":6},{"name":"fac.wast","passed":0,"failed":2},{"name":"float_exprs.wast","passed":269,"failed":591},{"name":"float_literals.wast","passed":34,"failed":129},{"name":"float_memory.wast","passed":0,"failed":6},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":4,"failed":75},{"name":"func_ptrs.wast","passed":0,"failed":16},{"name":"global.wast","passed":4,"failed":49},{"name":"i32.wast","passed":0,"failed":96},{"name":"i64.wast","passed":0,"failed":42},{"name":"if.wast","passed":0,"failed":118},{"name":"imports.wast","passed":1,"failed":156},{"name":"inline-module.wast","passed":0,"failed":1},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":5,"failed":46},{"name":"labels.wast","passed":1,"failed":28},{"name":"left-to-right.wast","passed":0,"failed":1},{"name":"linking.wast","passed":1,"failed":66},{"name":"load.wast","passed":0,"failed":60},{"name":"local_get.wast","passed":2,"failed":34},{"name":"local_set.wast","passed":5,"failed":48},{"name":"local_tee.wast","passed":0,"failed":42},{"name":"loop.wast","passed":0,"failed":43},{"name":"memory.wast","passed":0,"failed":34},{"name":"memory_grow.wast","passed":0,"failed":19},{"name":"memory_redundancy.wast","passed":0,"failed":1},{"name":"memory_size.wast","passed":0,"failed":6},{"name":"memory_trap.wast","passed":0,"failed":172},{"name":"names.wast","passed":484,"failed":1},{"name":"nop.wast","passed":0,"failed":5},{"name":"return.wast","passed":0,"failed":21},{"name":"select.wast","passed":0,"failed":32},{"name":"skip-stack-guard-page.wast","passed":0,"failed":11},{"name":"stack.wast","passed":0,"failed":2},{"name":"start.wast","passed":0,"failed":10},{"name":"store.wast","passed":0,"failed":59},{"name":"switch.wast","passed":1,"failed":27},{"name":"token.wast","passed":16,"failed":42},{"name":"traps.wast","passed":3,"failed":33},{"name":"type.wast","passed":1,"failed":2},{"name":"unreachable.wast","passed":0,"failed":59},{"name":"unreached-invalid.wast","passed":0,"failed":118},{"name":"unwind.wast","passed":1,"failed":49},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":0,"failed":176}]
0.0.4,9258,10909,[{"name":"address.wast","passed":0,"failed":54},{"name":"align.wast","passed":0,"failed":109},{"name":"binary-leb128.wast","passed":66,"failed":25},{"name":"binary.wast","passed":104,"failed":8},{"name":"block.wast","passed":0,"failed":171},{"name":"br.wast","passed":0,"failed":21},{"name":"br_if.wast","passed":0,"failed":30},{"name":"br_table.wast","passed":0,"failed":25},{"name":"call.wast","passed":0,"failed":22},{"name":"call_indirect.wast","passed":0,"failed":56},{"name":"comments.wast","passed":4,"failed":4},{"name":"const.wast","passed":702,"failed":76},{"name":"conversions.wast","passed":0,"failed":93},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":0,"failed":61},{"name":"elem.wast","passed":0,"failed":76},{"name":"endianness.wast","passed":0,"failed":1},{"name":"exports.wast","passed":21,"failed":73},{"name":"f32.wast","passed":1005,"failed":1509},{"name":"f32_bitwise.wast","passed":1,"failed":363},{"name":"f32_cmp.wast","passed":2401,"failed":6},{"name":"f64.wast","passed":1005,"failed":1509},{"name":"f64_bitwise.wast","passed":1,"failed":363},{"name":"f64_cmp.wast","passed":2401,"failed":6},{"name":"fac.wast","passed":0,"failed":2},{"name":"float_exprs.wast","passed":269,"failed":591},{"name":"float_literals.wast","passed":34,"failed":129},{"name":"float_memory.wast","passed":0,"failed":6},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":4,"failed":75},{"name":"func_ptrs.wast","passed":0,"failed":16},{"name":"global.wast","passed":4,"failed":49},{"name":"i32.wast","passed":0,"failed":96},{"name":"i64.wast","passed":0,"failed":42},{"name":"if.wast","passed":0,"failed":118},{"name":"imports.wast","passed":1,"failed":156},{"name":"inline-module.wast","passed":0,"failed":1},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":5,"failed":46},{"name":"labels.wast","passed":1,"failed":28},{"name":"left-to-right.wast","passed":0,"failed":1},{"name":"linking.wast","passed":1,"failed":66},{"name":"load.wast","passed":0,"failed":60},{"name":"local_get.wast","passed":2,"failed":34},{"name":"local_set.wast","passed":5,"failed":48},{"name":"local_tee.wast","passed":0,"failed":42},{"name":"loop.wast","passed":0,"failed":43},{"name":"memory.wast","passed":0,"failed":34},{"name":"memory_grow.wast","passed":0,"failed":19},{"name":"memory_redundancy.wast","passed":0,"failed":1},{"name":"memory_size.wast","passed":0,"failed":6},{"name":"memory_trap.wast","passed":0,"failed":172},{"name":"names.wast","passed":484,"failed":1},{"name":"nop.wast","passed":0,"failed":5},{"name":"return.wast","passed":0,"failed":21},{"name":"select.wast","passed":0,"failed":32},{"name":"skip-stack-guard-page.wast","passed":0,"failed":11},{"name":"stack.wast","passed":0,"failed":2},{"name":"start.wast","passed":0,"failed":10},{"name":"store.wast","passed":0,"failed":59},{"name":"switch.wast","passed":1,"failed":27},{"name":"token.wast","passed":16,"failed":42},{"name":"traps.wast","passed":3,"failed":33},{"name":"type.wast","passed":1,"failed":2},{"name":"unreachable.wast","passed":0,"failed":59},{"name":"unreached-invalid.wast","passed":0,"failed":118},{"name":"unwind.wast","passed":1,"failed":49},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":0,"failed":176}]
0.0.5,11135,9093,[{"name":"address.wast","passed":1,"failed":259},{"name":"align.wast","passed":108,"failed":48},{"name":"binary-leb128.wast","passed":78,"failed":13},{"name":"binary.wast","passed":107,"failed":5},{"name":"block.wast","passed":170,"failed":53},{"name":"br.wast","passed":20,"failed":77},{"name":"br_if.wast","passed":29,"failed":89},{"name":"br_table.wast","passed":24,"failed":150},{"name":"call.wast","passed":18,"failed":73},{"name":"call_indirect.wast","passed":34,"failed":136},{"name":"comments.wast","passed":5,"failed":3},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":25,"failed":594},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":22,"failed":39},{"name":"elem.wast","passed":27,"failed":72},{"name":"endianness.wast","passed":1,"failed":68},{"name":"exports.wast","passed":90,"failed":6},{"name":"f32.wast","passed":1018,"failed":1496},{"name":"f32_bitwise.wast","passed":4,"failed":360},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":1018,"failed":1496},{"name":"f64_bitwise.wast","passed":4,"failed":360},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":1,"failed":7},{"name":"float_exprs.wast","passed":275,"failed":625},{"name":"float_literals.wast","passed":112,"failed":51},{"name":"float_memory.wast","passed":0,"failed":90},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":81,"failed":91},{"name":"func_ptrs.wast","passed":7,"failed":29},{"name":"global.wast","passed":50,"failed":60},{"name":"i32.wast","passed":85,"failed":375},{"name":"i64.wast","passed":31,"failed":385},{"name":"if.wast","passed":116,"failed":125},{"name":"imports.wast","passed":23,"failed":160},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":25,"failed":26},{"name":"labels.wast","passed":13,"failed":16},{"name":"left-to-right.wast","passed":0,"failed":96},{"name":"linking.wast","passed":5,"failed":127},{"name":"load.wast","passed":59,"failed":38},{"name":"local_get.wast","passed":18,"failed":18},{"name":"local_set.wast","passed":38,"failed":15},{"name":"local_tee.wast","passed":41,"failed":56},{"name":"loop.wast","passed":42,"failed":78},{"name":"memory.wast","passed":30,"failed":49},{"name":"memory_grow.wast","passed":11,"failed":85},{"name":"memory_redundancy.wast","passed":1,"failed":7},{"name":"memory_size.wast","passed":6,"failed":36},{"name":"memory_trap.wast","passed":1,"failed":181},{"name":"names.wast","passed":484,"failed":2},{"name":"nop.wast","passed":4,"failed":84},{"name":"return.wast","passed":20,"failed":64},{"name":"select.wast","passed":28,"failed":120},{"name":"skip-stack-guard-page.wast","passed":1,"failed":10},{"name":"stack.wast","passed":2,"failed":5},{"name":"start.wast","passed":4,"failed":16},{"name":"store.wast","passed":59,"failed":9},{"name":"switch.wast","passed":2,"failed":26},{"name":"token.wast","passed":39,"failed":19},{"name":"traps.wast","passed":4,"failed":32},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":0,"failed":64},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unwind.wast","passed":9,"failed":41},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}]
-0.0.6-alpha.0,11286,8942,[{"name":"address.wast","passed":5,"failed":255},{"name":"align.wast","passed":108,"failed":48},{"name":"binary-leb128.wast","passed":85,"failed":6},{"name":"binary.wast","passed":109,"failed":3},{"name":"block.wast","passed":170,"failed":53},{"name":"br.wast","passed":20,"failed":77},{"name":"br_if.wast","passed":29,"failed":89},{"name":"br_table.wast","passed":24,"failed":150},{"name":"call.wast","passed":18,"failed":73},{"name":"call_indirect.wast","passed":34,"failed":136},{"name":"comments.wast","passed":5,"failed":3},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":25,"failed":594},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":47,"failed":14},{"name":"elem.wast","passed":27,"failed":72},{"name":"endianness.wast","passed":1,"failed":68},{"name":"exports.wast","passed":90,"failed":6},{"name":"f32.wast","passed":1018,"failed":1496},{"name":"f32_bitwise.wast","passed":4,"failed":360},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":1018,"failed":1496},{"name":"f64_bitwise.wast","passed":4,"failed":360},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":1,"failed":7},{"name":"float_exprs.wast","passed":279,"failed":621},{"name":"float_literals.wast","passed":112,"failed":51},{"name":"float_memory.wast","passed":6,"failed":84},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":81,"failed":91},{"name":"func_ptrs.wast","passed":8,"failed":28},{"name":"global.wast","passed":51,"failed":59},{"name":"i32.wast","passed":85,"failed":375},{"name":"i64.wast","passed":31,"failed":385},{"name":"if.wast","passed":116,"failed":125},{"name":"imports.wast","passed":71,"failed":112},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":51,"failed":57},{"name":"int_literals.wast","passed":25,"failed":26},{"name":"labels.wast","passed":13,"failed":16},{"name":"left-to-right.wast","passed":0,"failed":96},{"name":"linking.wast","passed":17,"failed":115},{"name":"load.wast","passed":59,"failed":38},{"name":"local_get.wast","passed":18,"failed":18},{"name":"local_set.wast","passed":38,"failed":15},{"name":"local_tee.wast","passed":41,"failed":56},{"name":"loop.wast","passed":42,"failed":78},{"name":"memory.wast","passed":34,"failed":45},{"name":"memory_grow.wast","passed":11,"failed":85},{"name":"memory_redundancy.wast","passed":1,"failed":7},{"name":"memory_size.wast","passed":6,"failed":36},{"name":"memory_trap.wast","passed":2,"failed":180},{"name":"names.wast","passed":485,"failed":1},{"name":"nop.wast","passed":4,"failed":84},{"name":"return.wast","passed":20,"failed":64},{"name":"select.wast","passed":28,"failed":120},{"name":"skip-stack-guard-page.wast","passed":1,"failed":10},{"name":"stack.wast","passed":2,"failed":5},{"name":"start.wast","passed":9,"failed":11},{"name":"store.wast","passed":59,"failed":9},{"name":"switch.wast","passed":2,"failed":26},{"name":"token.wast","passed":56,"failed":2},{"name":"traps.wast","passed":4,"failed":32},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":0,"failed":64},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unwind.wast","passed":9,"failed":41},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}]
+0.0.6-alpha.0,11414,8814,[{"name":"address.wast","passed":5,"failed":255},{"name":"align.wast","passed":108,"failed":48},{"name":"binary-leb128.wast","passed":90,"failed":1},{"name":"binary.wast","passed":110,"failed":2},{"name":"block.wast","passed":174,"failed":49},{"name":"br.wast","passed":32,"failed":65},{"name":"br_if.wast","passed":36,"failed":82},{"name":"br_table.wast","passed":25,"failed":149},{"name":"call.wast","passed":20,"failed":71},{"name":"call_indirect.wast","passed":36,"failed":134},{"name":"comments.wast","passed":5,"failed":3},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":25,"failed":594},{"name":"custom.wast","passed":11,"failed":0},{"name":"data.wast","passed":47,"failed":14},{"name":"elem.wast","passed":50,"failed":49},{"name":"endianness.wast","passed":1,"failed":68},{"name":"exports.wast","passed":90,"failed":6},{"name":"f32.wast","passed":1018,"failed":1496},{"name":"f32_bitwise.wast","passed":4,"failed":360},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":1018,"failed":1496},{"name":"f64_bitwise.wast","passed":4,"failed":360},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":1,"failed":7},{"name":"float_exprs.wast","passed":279,"failed":621},{"name":"float_literals.wast","passed":112,"failed":51},{"name":"float_memory.wast","passed":6,"failed":84},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":82,"failed":90},{"name":"func_ptrs.wast","passed":10,"failed":26},{"name":"global.wast","passed":51,"failed":59},{"name":"i32.wast","passed":85,"failed":375},{"name":"i64.wast","passed":31,"failed":385},{"name":"if.wast","passed":117,"failed":124},{"name":"imports.wast","passed":74,"failed":109},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":51,"failed":57},{"name":"int_literals.wast","passed":25,"failed":26},{"name":"labels.wast","passed":13,"failed":16},{"name":"left-to-right.wast","passed":1,"failed":95},{"name":"linking.wast","passed":21,"failed":111},{"name":"load.wast","passed":60,"failed":37},{"name":"local_get.wast","passed":18,"failed":18},{"name":"local_set.wast","passed":38,"failed":15},{"name":"local_tee.wast","passed":43,"failed":54},{"name":"loop.wast","passed":46,"failed":74},{"name":"memory.wast","passed":34,"failed":45},{"name":"memory_grow.wast","passed":12,"failed":84},{"name":"memory_redundancy.wast","passed":1,"failed":7},{"name":"memory_size.wast","passed":6,"failed":36},{"name":"memory_trap.wast","passed":2,"failed":180},{"name":"names.wast","passed":485,"failed":1},{"name":"nop.wast","passed":5,"failed":83},{"name":"return.wast","passed":21,"failed":63},{"name":"select.wast","passed":28,"failed":120},{"name":"skip-stack-guard-page.wast","passed":1,"failed":10},{"name":"stack.wast","passed":2,"failed":5},{"name":"start.wast","passed":9,"failed":11},{"name":"store.wast","passed":59,"failed":9},{"name":"switch.wast","passed":2,"failed":26},{"name":"token.wast","passed":58,"failed":0},{"name":"traps.wast","passed":4,"failed":32},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":46,"failed":18},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unwind.wast","passed":9,"failed":41},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}]
diff --git a/crates/tinywasm/tests/generated/progress-mvp.svg b/crates/tinywasm/tests/generated/progress-mvp.svg
index 8715df5..8bb754f 100644
--- a/crates/tinywasm/tests/generated/progress-mvp.svg
+++ b/crates/tinywasm/tests/generated/progress-mvp.svg
@@ -49,11 +49,11 @@ v0.0.5 (11135)
</text>
<polyline fill="none" opacity="1" stroke="#000000" stroke-width="1" points="648,345 648,350 "/>
<text x="875" y="355" dy="0.76em" text-anchor="middle" font-family="Victor Mono" font-size="12.096774193548388" opacity="1" fill="#000000">
-v0.0.6-alpha.0 (11286)
+v0.0.6-alpha.0 (11414)
</text>
<polyline fill="none" opacity="1" stroke="#000000" stroke-width="1" points="875,345 875,350 "/>
<rect x="85" y="212" width="217" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
-<rect x="767" y="183" width="217" height="161" opacity="0.5" fill="#0000FF" stroke="none"/>
-<rect x="312" y="212" width="217" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
+<rect x="767" y="181" width="217" height="163" opacity="0.5" fill="#0000FF" stroke="none"/>
<rect x="539" y="185" width="218" height="159" opacity="0.5" fill="#0000FF" stroke="none"/>
+<rect x="312" y="212" width="217" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
</svg>
diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs
index 2e76ac5..85bfcd2 100644
--- a/crates/types/src/lib.rs
+++ b/crates/types/src/lib.rs
@@ -67,7 +67,9 @@ pub struct TinyWasmModule {
/// Data segments of the WebAssembly module.
pub data: Box<[Data]>,
- // pub elements: Option<ElementSectionReader<'a>>,
+
+ /// Element segments of the WebAssembly module.
+ pub elements: Box<[Element]>,
}
/// A WebAssembly value.
@@ -366,3 +368,24 @@ pub enum DataKind {
Active { mem: MemAddr, offset: ConstInstruction },
Passive,
}
+
+#[derive(Debug, Clone)]
+pub struct Element {
+ pub kind: ElementKind,
+ pub items: Box<[ElementItem]>,
+ pub range: Range<usize>,
+ pub ty: ValType,
+}
+
+#[derive(Debug, Clone)]
+pub enum ElementKind {
+ Passive,
+ Active { table: TableAddr, offset: ConstInstruction },
+ Declared,
+}
+
+#[derive(Debug, Clone)]
+pub enum ElementItem {
+ Func(FuncAddr),
+ Expr(ConstInstruction),
+}