Branch local scoping
This commit is contained in:
parent
eacd907c3b
commit
2098fef856
|
@ -160,8 +160,8 @@ mod tests {
|
|||
d
|
||||
} else {
|
||||
// Test 2 only
|
||||
// let d = (a - b); // 4
|
||||
// c = (c * d); // 40
|
||||
let d = (a - b); // 4
|
||||
c = (c * d); // 40
|
||||
d
|
||||
};
|
||||
|
||||
|
|
|
@ -161,15 +161,21 @@ impl<'a> FunctionTranslator<'a> {
|
|||
}
|
||||
|
||||
pub fn translate_branch_body(&mut self, branch_body: &ast::BranchBody) -> Option<Value> {
|
||||
let scope_size = self.locals.len();
|
||||
|
||||
for stmt in branch_body.statements.iter() {
|
||||
self.translate_statement(stmt);
|
||||
}
|
||||
|
||||
if let Some(tail_expr) = &branch_body.tail_expr {
|
||||
let tail_val = if let Some(tail_expr) = &branch_body.tail_expr {
|
||||
Some(self.translate_expr(tail_expr))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
self.locals.truncate(scope_size);
|
||||
|
||||
tail_val
|
||||
}
|
||||
|
||||
pub fn translate_binary_op(
|
||||
|
|
Loading…
Reference in New Issue