Partially implement yield*

This commit is contained in:
Andrew Morris
2023-06-01 17:28:31 +10:00
parent 6b2404119e
commit 97ac17e917
4 changed files with 7 additions and 1 deletions

View File

@@ -560,7 +560,10 @@ impl StackFrameTrait for BytecodeStackFrame {
}
YieldStar => {
panic!("TODO: yield*");
let val = self.decoder.decode_val(&self.registers);
self.decoder.decode_register_index(); // TODO: Use this
return Ok(FrameStepOk::YieldStar(val));
}
};

View File

@@ -172,6 +172,7 @@ impl StackFrameTrait for GeneratorFrame {
.to_dynamic_val(),
this: take(&mut self.generator).to_dynamic_val(),
})),
Ok(FrameStepOk::YieldStar(_)) => panic!("TODO: yield* (as instruction)"),
}
}

View File

@@ -13,6 +13,7 @@ pub enum FrameStepOk {
Pop(CallResult),
Push(StackFrame),
Yield(Val),
YieldStar(Val),
}
pub type FrameStepResult = Result<FrameStepOk, Val>;

View File

@@ -88,6 +88,7 @@ impl VirtualMachine {
}
// TODO: Internal errors
FrameStepOk::Yield(_) => return self.handle_exception("Unexpected yield".to_error()),
FrameStepOk::YieldStar(_) => return self.handle_exception("Unexpected yield*".to_error()),
}
Ok(())