mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
CodeBuilder tracks which local variables are set
This commit is contained in:
parent
8636299155
commit
a76c4420fa
2 changed files with 26 additions and 2 deletions
|
@ -796,7 +796,7 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
|
|||
self.expr(sym, expr, layout, &sym_storage);
|
||||
|
||||
if let StoredValue::Local { local_id, .. } = sym_storage {
|
||||
if !self.code_builder.stack_is_empty() {
|
||||
if !self.code_builder.is_set(local_id) {
|
||||
self.code_builder.set_local(local_id);
|
||||
}
|
||||
}
|
||||
|
@ -1153,7 +1153,11 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
|
|||
};
|
||||
|
||||
match storage {
|
||||
StoredValue::Local { value_type, .. } => {
|
||||
StoredValue::Local {
|
||||
value_type,
|
||||
local_id,
|
||||
..
|
||||
} => {
|
||||
match (lit, value_type) {
|
||||
(Literal::Float(x), ValueType::F64) => self.code_builder.f64_const(*x),
|
||||
(Literal::Float(x), ValueType::F32) => self.code_builder.f32_const(*x as f32),
|
||||
|
@ -1167,6 +1171,7 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
|
|||
(Literal::Byte(x), ValueType::I32) => self.code_builder.i32_const(*x as i32),
|
||||
_ => invalid_error(),
|
||||
};
|
||||
self.code_builder.set_local(*local_id);
|
||||
}
|
||||
|
||||
StoredValue::StackMemory { location, .. } => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue