interpreter: Allow statements to choose their own return value (reduces code duplication)
This commit is contained in:
parent
ffa313eea8
commit
bb3eecd190
@ -649,18 +649,7 @@ pub mod interpret {
|
|||||||
let mut env = env.frame("block");
|
let mut env = env.frame("block");
|
||||||
let mut out = ConValue::Empty;
|
let mut out = ConValue::Empty;
|
||||||
for stmt in stmts {
|
for stmt in stmts {
|
||||||
let Stmt { kind, semi, .. } = stmt;
|
out = stmt.interpret(&mut env)?;
|
||||||
out = match (kind, semi) {
|
|
||||||
(StmtKind::Expr(_), Semi::Unterminated) => stmt.interpret(&mut env)?,
|
|
||||||
(StmtKind::Expr(_), _) => {
|
|
||||||
stmt.interpret(&mut env)?;
|
|
||||||
ConValue::Empty
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
stmt.interpret(&mut env)?;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user