Tweak example and native function logic
This commit is contained in:
parent
36da1d0d7c
commit
1ef5ddc013
@ -778,6 +778,8 @@ impl<'src> Compiler<'src> {
|
||||
});
|
||||
}
|
||||
|
||||
if let Some([Operation::Test, Operation::Jump]) = self.get_last_operations() {}
|
||||
|
||||
let (argument, push_back) = self.handle_binary_argument(&left_instruction)?;
|
||||
|
||||
if push_back {
|
||||
|
@ -686,10 +686,10 @@ impl Instruction {
|
||||
function,
|
||||
argument_count,
|
||||
} = Call::from(self);
|
||||
let first_argument = destination.index().saturating_sub(argument_count);
|
||||
let last_argument = destination.index() - 1;
|
||||
let arguments_start = destination.index().saturating_sub(argument_count);
|
||||
let arguments_end = arguments_start + argument_count;
|
||||
|
||||
format!("{destination} = {function}(R{first_argument}..=R{last_argument})")
|
||||
format!("{destination} = {function}(R{arguments_start}..R{arguments_end})")
|
||||
}
|
||||
Operation::CallNative => {
|
||||
let CallNative {
|
||||
@ -697,10 +697,10 @@ impl Instruction {
|
||||
function,
|
||||
argument_count,
|
||||
} = CallNative::from(self);
|
||||
let first_argument = destination.index().saturating_sub(argument_count);
|
||||
let last_argument = destination.index() - 1;
|
||||
let arguments_start = destination.index().saturating_sub(argument_count);
|
||||
let arguments_end = arguments_start + argument_count;
|
||||
|
||||
format!("{destination} = {function}(R{first_argument}..=R{last_argument})")
|
||||
format!("{destination} = {function}(R{arguments_start}..R{arguments_end})")
|
||||
}
|
||||
Operation::Return => {
|
||||
let Return {
|
||||
|
@ -104,10 +104,6 @@ pub fn write<'a>(vm: &'a Vm<'a>, instruction: Instruction) -> Result<Option<Valu
|
||||
let first_argument = to_register.saturating_sub(argument_count);
|
||||
|
||||
for argument_index in first_argument..to_register {
|
||||
if argument_index != first_argument {
|
||||
stdout.write(b" ").map_err(map_err)?;
|
||||
}
|
||||
|
||||
let argument = if let Some(value) = vm.open_register_allow_empty(argument_index)? {
|
||||
value
|
||||
} else {
|
||||
@ -137,10 +133,6 @@ pub fn write_line<'a>(vm: &'a Vm<'a>, instruction: Instruction) -> Result<Option
|
||||
let first_argument = to_register.saturating_sub(argument_count);
|
||||
|
||||
for argument_index in first_argument..to_register {
|
||||
if argument_index != first_argument {
|
||||
stdout.write(b" ").map_err(map_err)?;
|
||||
}
|
||||
|
||||
let argument = if let Some(value) = vm.open_register_allow_empty(argument_index)? {
|
||||
value
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user