mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-14 07:57:57 -05:00
Add unimplemented yield instruction
This commit is contained in:
@@ -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, _)
|
||||
|
||||
Reference in New Issue
Block a user