mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
this_subcall
This commit is contained in:
@@ -289,6 +289,7 @@ pub enum Instruction {
|
||||
UnsetCatch,
|
||||
ConstSubCall(Value, Value, Value, Register),
|
||||
RequireMutableThis,
|
||||
ThisSubCall(Value, Value, Value, Register),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Instruction {
|
||||
@@ -437,6 +438,13 @@ impl std::fmt::Display for Instruction {
|
||||
)
|
||||
}
|
||||
Instruction::RequireMutableThis => write!(f, "require_mutable_this"),
|
||||
Instruction::ThisSubCall(obj, subscript, args, register) => {
|
||||
write!(
|
||||
f,
|
||||
"this_subcall {} {} {} {}",
|
||||
obj, subscript, args, register
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -498,6 +506,7 @@ impl Instruction {
|
||||
UnsetCatch => InstructionByte::UnsetCatch,
|
||||
ConstSubCall(..) => InstructionByte::ConstSubCall,
|
||||
RequireMutableThis => InstructionByte::RequireMutableThis,
|
||||
ThisSubCall(..) => InstructionByte::ThisSubCall,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,8 @@ impl Assembler {
|
||||
}
|
||||
Apply(arg1, arg2, arg3, dst)
|
||||
| SubCall(arg1, arg2, arg3, dst)
|
||||
| ConstSubCall(arg1, arg2, arg3, dst) => {
|
||||
| ConstSubCall(arg1, arg2, arg3, dst)
|
||||
| ThisSubCall(arg1, arg2, arg3, dst) => {
|
||||
self.value(arg1);
|
||||
self.value(arg2);
|
||||
self.value(arg3);
|
||||
|
||||
@@ -226,6 +226,7 @@ impl<'a> AssemblyParser<'a> {
|
||||
("unset_catch", InstructionByte::UnsetCatch),
|
||||
("const_subcall", InstructionByte::ConstSubCall),
|
||||
("require_mutable_this", InstructionByte::RequireMutableThis),
|
||||
("this_subcall", InstructionByte::ThisSubCall),
|
||||
]);
|
||||
|
||||
for (word, instruction) in instruction_word_map {
|
||||
@@ -678,6 +679,12 @@ impl<'a> AssemblyParser<'a> {
|
||||
self.assemble_register(),
|
||||
),
|
||||
RequireMutableThis => Instruction::RequireMutableThis,
|
||||
ThisSubCall => Instruction::ThisSubCall(
|
||||
self.assemble_value(),
|
||||
self.assemble_value(),
|
||||
self.assemble_value(),
|
||||
self.assemble_register(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ pub fn instruction_mutates_this(instruction: &Instruction) -> bool {
|
||||
| Import(_, reg)
|
||||
| ImportStar(_, reg)
|
||||
| SetCatch(_, reg)
|
||||
| ConstSubCall(_, _, _, reg) => reg == &Register::This,
|
||||
| ConstSubCall(_, _, _, reg)
|
||||
| ThisSubCall(_, _, _, reg) => reg == &Register::This,
|
||||
|
||||
Apply(_, ctx, _, reg) | SubCall(ctx, _, _, reg) => {
|
||||
reg == &Register::This
|
||||
|
||||
@@ -282,7 +282,8 @@ where
|
||||
}
|
||||
Apply(arg1, arg2, arg3, _)
|
||||
| SubCall(arg1, arg2, arg3, _)
|
||||
| ConstSubCall(arg1, arg2, arg3, _) => {
|
||||
| ConstSubCall(arg1, arg2, arg3, _)
|
||||
| ThisSubCall(arg1, arg2, arg3, _) => {
|
||||
self.value(Some(owner), arg1);
|
||||
self.value(Some(owner), arg2);
|
||||
self.value(Some(owner), arg3);
|
||||
|
||||
Reference in New Issue
Block a user