WIP.
This commit is contained in:
parent
0473031ba4
commit
563092e4f3
|
@ -559,19 +559,27 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
|||
|
||||
wasmparser::Operator::LocalGet { local_index } => {
|
||||
let ty = self.body.locals[*local_index as usize];
|
||||
if self.cur_block.is_some() {
|
||||
let value = self.locals.get(&mut self.body, *local_index);
|
||||
self.op_stack.push((ty, value));
|
||||
} else {
|
||||
self.op_stack.push((ty, Value::undef()));
|
||||
}
|
||||
}
|
||||
|
||||
wasmparser::Operator::LocalSet { local_index } => {
|
||||
let (_, value) = self.op_stack.pop().unwrap();
|
||||
if self.cur_block.is_some() {
|
||||
self.locals.set(*local_index, value);
|
||||
}
|
||||
}
|
||||
|
||||
wasmparser::Operator::LocalTee { local_index } => {
|
||||
let (_ty, value) = *self.op_stack.last().unwrap();
|
||||
if self.cur_block.is_some() {
|
||||
self.locals.set(*local_index, value);
|
||||
}
|
||||
}
|
||||
|
||||
wasmparser::Operator::Call { .. }
|
||||
| wasmparser::Operator::CallIndirect { .. }
|
||||
|
@ -978,12 +986,14 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
|||
.map(|(_ty, value)| *value)
|
||||
.collect::<Vec<_>>();
|
||||
self.emit_cond_branch(cond, frame.br_target(), &args[..], cont, &[]);
|
||||
self.cur_block = Some(cont);
|
||||
self.locals.seal_block_preds(cont, &mut self.body);
|
||||
if self.cur_block.is_some() {
|
||||
self.cur_block = Some(cont);
|
||||
self.locals.start_block(cont);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wasmparser::Operator::BrTable { table } => {
|
||||
// Get the selector index.
|
||||
|
|
10
src/ir.rs
10
src/ir.rs
|
@ -87,6 +87,7 @@ impl FunctionBody {
|
|||
}
|
||||
|
||||
pub fn set_alias(&mut self, value: Value, to: Value) {
|
||||
assert_ne!(to, Value::undef());
|
||||
log::trace!("set_alias: value {:?} to {:?}", value, to);
|
||||
// Resolve the `to` value through all existing aliases.
|
||||
let to = self.resolve_alias(to);
|
||||
|
@ -116,8 +117,15 @@ impl FunctionBody {
|
|||
value
|
||||
}
|
||||
|
||||
pub fn add_blockparam(&mut self, block: BlockId, ty: Type) {
|
||||
pub fn add_blockparam(&mut self, block: BlockId, ty: Type) -> usize {
|
||||
let index = self.blocks[block].params.len();
|
||||
self.blocks[block].params.push(ty);
|
||||
index
|
||||
}
|
||||
|
||||
pub fn add_blockparam_value(&mut self, block: BlockId, ty: Type) -> Value {
|
||||
let index = self.add_blockparam(block, ty);
|
||||
self.add_value(ValueDef::BlockParam(block, index), Some(ty))
|
||||
}
|
||||
|
||||
pub fn add_placeholder(&mut self, ty: Type) -> Value {
|
||||
|
|
Loading…
Reference in a new issue