mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Compile throw expressions
This commit is contained in:
@@ -293,7 +293,9 @@ impl CaptureFinder {
|
||||
}
|
||||
}
|
||||
Switch(_) => std::panic!("Not implemented: Switch statement"),
|
||||
Throw(_) => std::panic!("Not implemented: Throw statement"),
|
||||
Throw(throw) => {
|
||||
self.expr(scope, &throw.arg);
|
||||
}
|
||||
Try(_) => std::panic!("Not implemented: Try statement"),
|
||||
While(while_) => {
|
||||
self.expr(scope, &while_.test);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1398,8 +1398,8 @@ impl ScopeAnalysis {
|
||||
}
|
||||
}
|
||||
}
|
||||
Stmt::Throw(throw_) => {
|
||||
self.expr(&scope, &throw_.arg);
|
||||
Stmt::Throw(throw) => {
|
||||
self.expr(&scope, &throw.arg);
|
||||
}
|
||||
Stmt::Try(try_) => {
|
||||
self.block_stmt(&scope, &try_.block);
|
||||
|
||||
Reference in New Issue
Block a user