mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
rename CodeBuilder methods
This commit is contained in:
parent
c5ee41af25
commit
041e26e807
3 changed files with 44 additions and 38 deletions
|
@ -315,7 +315,7 @@ impl<'a> WasmBackend<'a> {
|
|||
location: StackMemoryLocation::PointerArg(local_id),
|
||||
..
|
||||
} => {
|
||||
self.code_builder.push(GetLocal(local_id.0));
|
||||
self.code_builder.add_one(GetLocal(local_id.0));
|
||||
self.code_builder.set_top_symbol(*sym);
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ impl<'a> WasmBackend<'a> {
|
|||
location: StackMemoryLocation::FrameOffset(offset),
|
||||
..
|
||||
} => {
|
||||
self.code_builder.extend(&[
|
||||
self.code_builder.add_many(&[
|
||||
GetLocal(self.stack_frame_pointer.unwrap().0),
|
||||
I32Const(offset as i32),
|
||||
I32Add,
|
||||
|
@ -379,9 +379,9 @@ impl<'a> WasmBackend<'a> {
|
|||
panic!("Cannot store {:?} with alignment of {:?}", value_type, size);
|
||||
}
|
||||
};
|
||||
self.code_builder.push(GetLocal(to_ptr.0));
|
||||
self.code_builder.add_one(GetLocal(to_ptr.0));
|
||||
self.load_symbols(&[from_symbol]);
|
||||
self.code_builder.push(store_instruction);
|
||||
self.code_builder.add_one(store_instruction);
|
||||
size
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ impl<'a> WasmBackend<'a> {
|
|||
debug_assert!(to_value_type == from_value_type);
|
||||
debug_assert!(to_size == from_size);
|
||||
self.load_symbols(&[from_symbol]);
|
||||
self.code_builder.push(SetLocal(to_local_id.0));
|
||||
self.code_builder.add_one(SetLocal(to_local_id.0));
|
||||
self.symbol_storage_map.insert(from_symbol, to.clone());
|
||||
}
|
||||
|
||||
|
@ -430,8 +430,8 @@ impl<'a> WasmBackend<'a> {
|
|||
) => {
|
||||
debug_assert!(to_value_type == from_value_type);
|
||||
debug_assert!(to_size == from_size);
|
||||
self.code_builder.push(GetLocal(from_local_id.0));
|
||||
self.code_builder.push(SetLocal(to_local_id.0));
|
||||
self.code_builder
|
||||
.add_many(&[GetLocal(from_local_id.0), SetLocal(to_local_id.0)]);
|
||||
}
|
||||
|
||||
(
|
||||
|
@ -486,7 +486,7 @@ impl<'a> WasmBackend<'a> {
|
|||
let local_id = self.get_next_local_id();
|
||||
if vm_state != VirtualMachineSymbolState::NotYetPushed {
|
||||
self.code_builder.load_symbol(symbol, vm_state, local_id);
|
||||
self.code_builder.push(SetLocal(local_id.0));
|
||||
self.code_builder.add_one(SetLocal(local_id.0));
|
||||
}
|
||||
|
||||
self.locals.push(Local::new(1, value_type));
|
||||
|
@ -512,17 +512,18 @@ impl<'a> WasmBackend<'a> {
|
|||
/// start a loop that leaves a value on the stack
|
||||
fn start_loop_with_return(&mut self, value_type: ValueType) {
|
||||
self.block_depth += 1;
|
||||
self.code_builder.push(Loop(BlockType::Value(value_type)));
|
||||
self.code_builder
|
||||
.add_one(Loop(BlockType::Value(value_type)));
|
||||
}
|
||||
|
||||
fn start_block(&mut self, block_type: BlockType) {
|
||||
self.block_depth += 1;
|
||||
self.code_builder.push(Block(block_type));
|
||||
self.code_builder.add_one(Block(block_type));
|
||||
}
|
||||
|
||||
fn end_block(&mut self) {
|
||||
self.block_depth -= 1;
|
||||
self.code_builder.push(End);
|
||||
self.code_builder.add_one(End);
|
||||
}
|
||||
|
||||
fn build_stmt(&mut self, stmt: &Stmt<'a>, ret_layout: &Layout<'a>) -> Result<(), String> {
|
||||
|
@ -560,7 +561,7 @@ impl<'a> WasmBackend<'a> {
|
|||
);
|
||||
}
|
||||
|
||||
self.code_builder.push(Br(self.block_depth)); // jump to end of function (stack frame pop)
|
||||
self.code_builder.add_one(Br(self.block_depth)); // jump to end of function (stack frame pop)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -614,7 +615,7 @@ impl<'a> WasmBackend<'a> {
|
|||
|
||||
_ => {
|
||||
self.load_symbols(&[*sym]);
|
||||
self.code_builder.push(Br(self.block_depth)); // jump to end of function (for stack frame pop)
|
||||
self.code_builder.add_one(Br(self.block_depth)); // jump to end of function (for stack frame pop)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,13 +648,13 @@ impl<'a> WasmBackend<'a> {
|
|||
// put the cond_symbol on the top of the stack
|
||||
self.load_symbols(&[*cond_symbol]);
|
||||
|
||||
self.code_builder.push(I32Const(*value as i32));
|
||||
self.code_builder.add_one(I32Const(*value as i32));
|
||||
|
||||
// compare the 2 topmost values
|
||||
self.code_builder.push(I32Eq);
|
||||
self.code_builder.add_one(I32Eq);
|
||||
|
||||
// "break" out of `i` surrounding blocks
|
||||
self.code_builder.push(BrIf(i as u32));
|
||||
self.code_builder.add_one(BrIf(i as u32));
|
||||
}
|
||||
|
||||
// if we never jumped because a value matched, we're in the default case
|
||||
|
@ -718,7 +719,7 @@ impl<'a> WasmBackend<'a> {
|
|||
|
||||
// jump
|
||||
let levels = self.block_depth - target;
|
||||
self.code_builder.push(Br(levels));
|
||||
self.code_builder.add_one(Br(levels));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -756,7 +757,7 @@ impl<'a> WasmBackend<'a> {
|
|||
let wasm_layout = WasmLayout::new(layout);
|
||||
let push = wasm_layout.stack_memory() == 0;
|
||||
let pops = arguments.len();
|
||||
self.code_builder.call(function_location.body, pops, push);
|
||||
self.code_builder.add_call(function_location.body, pops, push);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -800,7 +801,7 @@ impl<'a> WasmBackend<'a> {
|
|||
return Err(format!("loading literal, {:?}, is not yet implemented", x));
|
||||
}
|
||||
};
|
||||
self.code_builder.push(instruction);
|
||||
self.code_builder.add_one(instruction);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -893,7 +894,7 @@ impl<'a> WasmBackend<'a> {
|
|||
return Err(format!("unsupported low-level op {:?}", lowlevel));
|
||||
}
|
||||
};
|
||||
self.code_builder.extend(instructions);
|
||||
self.code_builder.add_many(instructions);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue