Generators make regular calls and regular returns

This commit is contained in:
Andrew Morris
2023-06-01 11:08:33 +10:00
parent 6710d98476
commit 95e702b85e
2 changed files with 107 additions and 29 deletions

View File

@@ -31,3 +31,41 @@ impl Clone for StackFrame {
self.clone_to_stack_frame()
}
}
impl Default for StackFrame {
fn default() -> Self {
Box::new(VoidStackFrame {})
}
}
#[derive(Clone)]
struct VoidStackFrame {}
impl StackFrameTrait for VoidStackFrame {
fn write_this(&mut self, _const: bool, _this: Val) -> Result<(), Val> {
Ok(())
}
fn write_param(&mut self, _param: Val) {}
fn step(&mut self) -> FrameStepResult {
Ok(FrameStepOk::Continue)
}
fn apply_call_result(&mut self, _call_result: CallResult) {}
fn get_call_result(&mut self) -> CallResult {
CallResult {
return_: Val::Void,
this: Val::Void,
}
}
fn catch_exception(&mut self, _exception: Val) -> bool {
false
}
fn clone_to_stack_frame(&self) -> StackFrame {
Box::new(self.clone())
}
}