Skip to content

Commit

Permalink
generate the simplest WASM module
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Jan 23, 2025
1 parent 9bc6d35 commit 5a05a81
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lib/src/wasm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,14 @@ impl WasmModuleBuilder {
rule_id: RuleId,
global: bool,
) -> InstrSeqBuilder {
if self.num_rules == self.rules_per_func {
self.finish_rule_func();
self.num_rules = 0;
}
self.num_rules += 1;
self.rule_id = rule_id;
self.global_rule = global;
/*if self.num_rules == self.rules_per_func {
self.finish_rule_func();
self.num_rules = 0;
}
self.num_rules += 1;
self.rule_id = rule_id;
self.global_rule = global;
*/

self.rules_func.func_body()
}
Expand All @@ -275,7 +276,7 @@ impl WasmModuleBuilder {
/// Each call to [`WasmModuleBuilder::start_rule`] must be followed by a
/// call to this function once the code for rule has been emitted.
pub fn finish_rule(&mut self) {
let rule_no_match =
/*let rule_no_match =
self.function_id(wasm::export__rule_no_match.mangled_name);
let rule_match =
Expand Down Expand Up @@ -322,6 +323,7 @@ impl WasmModuleBuilder {
else_.i32_const(self.rule_id.into()).call(rule_match);
},
);
*/
}

/// Starts a new namespace.
Expand Down Expand Up @@ -368,7 +370,7 @@ impl WasmModuleBuilder {
}

fn finish_namespace_block(&mut self) {
if !self
/*if !self
.namespace_func
.instr_seq(self.namespace_block)
.instrs()
Expand All @@ -382,11 +384,11 @@ impl WasmModuleBuilder {
self.namespace_block =
self.namespace_func.dangling_instr_seq(None).id();
}
}*/
}

fn finish_namespace_func(&mut self) {
let namespace_func = mem::replace(
/*let namespace_func = mem::replace(
&mut self.namespace_func,
FunctionBuilder::new(&mut self.module.types, &[], &[]),
);
Expand All @@ -396,11 +398,11 @@ impl WasmModuleBuilder {
self.main_func.func_body().call(
self.module.funcs.add_local(namespace_func.local_func(Vec::new())),
);
);*/
}

fn finish_rule_func(&mut self) {
let mut rule_func = mem::replace(
/*let mut rule_func = mem::replace(
&mut self.rules_func,
FunctionBuilder::new(
&mut self.module.types,
Expand Down Expand Up @@ -430,7 +432,7 @@ impl WasmModuleBuilder {
// block, preventing any other rule in the namespace from being
// executed.
namespace_block.br_if(namespace_block_id);
}
}*/
}

fn gen_check_for_pattern_match(
Expand Down

0 comments on commit 5a05a81

Please sign in to comment.