mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-10 14:08:09 -05:00
Add unimplemented yield* instruction
This commit is contained in:
@@ -56,6 +56,7 @@ pub enum InstructionByte {
|
||||
UnpackIterRes = 0x35,
|
||||
Cat = 0x36,
|
||||
Yield = 0x37,
|
||||
YieldStar = 0x38,
|
||||
}
|
||||
|
||||
impl InstructionByte {
|
||||
@@ -119,6 +120,7 @@ impl InstructionByte {
|
||||
0x35 => UnpackIterRes,
|
||||
0x36 => Cat,
|
||||
0x37 => Yield,
|
||||
0x38 => YieldStar,
|
||||
|
||||
_ => panic!("Unrecognized instruction: {}", byte),
|
||||
};
|
||||
|
||||
@@ -299,6 +299,7 @@ pub enum Instruction {
|
||||
UnpackIterRes(Register, Register, Register),
|
||||
Cat(Value, Register),
|
||||
Yield(Value, Register),
|
||||
YieldStar(Value, Register),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Instruction {
|
||||
@@ -470,6 +471,9 @@ impl std::fmt::Display for Instruction {
|
||||
Instruction::Yield(value, register) => {
|
||||
write!(f, "yield {} {}", value, register)
|
||||
}
|
||||
Instruction::YieldStar(value, register) => {
|
||||
write!(f, "yield* {} {}", value, register)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -536,6 +540,7 @@ impl Instruction {
|
||||
UnpackIterRes(..) => InstructionByte::UnpackIterRes,
|
||||
Cat(..) => InstructionByte::Cat,
|
||||
Yield(..) => InstructionByte::Yield,
|
||||
YieldStar(..) => InstructionByte::YieldStar,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,6 +251,10 @@ impl Assembler {
|
||||
self.value(value);
|
||||
self.register(dst);
|
||||
}
|
||||
YieldStar(value, dst) => {
|
||||
self.value(value);
|
||||
self.register(dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -231,6 +231,7 @@ impl<'a> AssemblyParser<'a> {
|
||||
("unpack_iter_res", InstructionByte::UnpackIterRes),
|
||||
("cat", InstructionByte::Cat),
|
||||
("yield", InstructionByte::Yield),
|
||||
("yield*", InstructionByte::YieldStar),
|
||||
]);
|
||||
|
||||
for (word, instruction) in instruction_word_map {
|
||||
@@ -704,6 +705,7 @@ impl<'a> AssemblyParser<'a> {
|
||||
),
|
||||
Cat => Instruction::Cat(self.assemble_value(), self.assemble_register()),
|
||||
Yield => Instruction::Yield(self.assemble_value(), self.assemble_register()),
|
||||
YieldStar => Instruction::Yield(self.assemble_value(), self.assemble_register()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1225,7 +1225,10 @@ impl<'a> ExpressionCompiler<'a> {
|
||||
}
|
||||
};
|
||||
|
||||
let instr = Instruction::Yield(self.fnc.use_(arg_compiled), dst.clone());
|
||||
let instr = match yield_expr.delegate {
|
||||
false => Instruction::Yield(self.fnc.use_(arg_compiled), dst.clone()),
|
||||
true => Instruction::YieldStar(self.fnc.use_(arg_compiled), dst.clone()),
|
||||
};
|
||||
|
||||
self.fnc.push(instr);
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ pub fn instruction_mutates_this(instruction: &Instruction) -> bool {
|
||||
| ConstSubCall(_, _, _, reg)
|
||||
| ThisSubCall(_, _, _, reg)
|
||||
| Cat(_, reg)
|
||||
| Yield(_, reg) => reg == &Register::This,
|
||||
| Yield(_, reg)
|
||||
| YieldStar(_, reg) => reg == &Register::This,
|
||||
|
||||
Next(iter, res) => iter == &Register::This || res == &Register::This,
|
||||
UnpackIterRes(_, value_reg, done_reg) => {
|
||||
|
||||
@@ -246,7 +246,8 @@ where
|
||||
| ImportStar(arg, _)
|
||||
| Throw(arg)
|
||||
| Cat(arg, _)
|
||||
| Yield(arg, _) => {
|
||||
| Yield(arg, _)
|
||||
| YieldStar(arg, _) => {
|
||||
self.value(Some(owner), arg);
|
||||
}
|
||||
OpPlus(arg1, arg2, _)
|
||||
|
||||
@@ -555,6 +555,10 @@ impl StackFrameTrait for BytecodeStackFrame {
|
||||
Yield => {
|
||||
panic!("TODO: yield");
|
||||
}
|
||||
|
||||
YieldStar => {
|
||||
panic!("TODO: yield*");
|
||||
}
|
||||
};
|
||||
|
||||
Ok(FrameStepOk::Continue)
|
||||
|
||||
Reference in New Issue
Block a user