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