Compile throw expressions

This commit is contained in:
Andrew Morris
2023-03-21 14:29:38 +11:00
parent 8b535f4f03
commit f43e83cffe
3 changed files with 13 additions and 4 deletions

View File

@@ -796,7 +796,14 @@ impl FunctionCompiler {
self.if_(if_, scope);
}
Switch(switch) => self.todo(switch.span, "Switch statement"),
Throw(throw) => self.todo(throw.span, "Throw statement"),
Throw(throw) => {
let mut expression_compiler = ExpressionCompiler { fnc: self, scope };
let arg = expression_compiler.compile(&throw.arg, None);
let instr = Instruction::Throw(self.use_(arg));
self.push(instr);
}
Try(try_) => self.todo(try_.span, "Try statement"),
While(while_) => {
self.while_(while_, scope);