mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-11 06:27:56 -05:00
Add unimplemented yield instruction
This commit is contained in:
@@ -55,6 +55,7 @@ pub enum InstructionByte {
|
||||
Next = 0x34,
|
||||
UnpackIterRes = 0x35,
|
||||
Cat = 0x36,
|
||||
Yield = 0x37,
|
||||
}
|
||||
|
||||
impl InstructionByte {
|
||||
@@ -117,6 +118,7 @@ impl InstructionByte {
|
||||
0x34 => Next,
|
||||
0x35 => UnpackIterRes,
|
||||
0x36 => Cat,
|
||||
0x37 => Yield,
|
||||
|
||||
_ => panic!("Unrecognized instruction: {}", byte),
|
||||
};
|
||||
|
||||
@@ -293,6 +293,7 @@ pub enum Instruction {
|
||||
Next(Register, Register),
|
||||
UnpackIterRes(Register, Register, Register),
|
||||
Cat(Value, Register),
|
||||
Yield(Value, Register),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Instruction {
|
||||
@@ -461,6 +462,9 @@ impl std::fmt::Display for Instruction {
|
||||
Instruction::Cat(iterables, register) => {
|
||||
write!(f, "cat {} {}", iterables, register)
|
||||
}
|
||||
Instruction::Yield(value, register) => {
|
||||
write!(f, "yield {} {}", value, register)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -526,6 +530,7 @@ impl Instruction {
|
||||
Next(..) => InstructionByte::Next,
|
||||
UnpackIterRes(..) => InstructionByte::UnpackIterRes,
|
||||
Cat(..) => InstructionByte::Cat,
|
||||
Yield(..) => InstructionByte::Yield,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,6 +244,10 @@ impl Assembler {
|
||||
self.value(iterables);
|
||||
self.register(dst);
|
||||
}
|
||||
Yield(value, dst) => {
|
||||
self.value(value);
|
||||
self.register(dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,6 +230,7 @@ impl<'a> AssemblyParser<'a> {
|
||||
("next", InstructionByte::Next),
|
||||
("unpack_iter_res", InstructionByte::UnpackIterRes),
|
||||
("cat", InstructionByte::Cat),
|
||||
("yield", InstructionByte::Yield),
|
||||
]);
|
||||
|
||||
for (word, instruction) in instruction_word_map {
|
||||
@@ -695,6 +696,7 @@ impl<'a> AssemblyParser<'a> {
|
||||
self.assemble_register(),
|
||||
),
|
||||
Cat => Instruction::Cat(self.assemble_value(), self.assemble_register()),
|
||||
Yield => Instruction::Yield(self.assemble_value(), self.assemble_register()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ pub fn instruction_mutates_this(instruction: &Instruction) -> bool {
|
||||
| SetCatch(_, reg)
|
||||
| ConstSubCall(_, _, _, reg)
|
||||
| ThisSubCall(_, _, _, reg)
|
||||
| Cat(_, reg) => reg == &Register::This,
|
||||
| Cat(_, reg)
|
||||
| Yield(_, reg) => reg == &Register::This,
|
||||
|
||||
Next(iter, res) => iter == &Register::This || res == &Register::This,
|
||||
UnpackIterRes(_, value_reg, done_reg) => {
|
||||
|
||||
@@ -245,7 +245,8 @@ where
|
||||
| Import(arg, _)
|
||||
| ImportStar(arg, _)
|
||||
| Throw(arg)
|
||||
| Cat(arg, _) => {
|
||||
| Cat(arg, _)
|
||||
| Yield(arg, _) => {
|
||||
self.value(Some(owner), arg);
|
||||
}
|
||||
OpPlus(arg1, arg2, _)
|
||||
|
||||
@@ -549,6 +549,10 @@ impl StackFrameTrait for BytecodeStackFrame {
|
||||
|
||||
return Ok(FrameStepOk::Push(Box::new(cat_frame)));
|
||||
}
|
||||
|
||||
Yield => {
|
||||
panic!("TODO: yield");
|
||||
}
|
||||
};
|
||||
|
||||
Ok(FrameStepOk::Continue)
|
||||
|
||||
Reference in New Issue
Block a user