Skip to content

Commit 94dc851

Browse files
committed
interpreter: add dest register to function calls
1 parent 8a6296c commit 94dc851

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

interpreter/src/ir.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub enum Instruction {
7777
StoreRecord(BinaryArg),
7878
IntrinsicCall(CallArgs),
7979
OutputCall(OutputCallArgs),
80-
UserCall(IndCallArgs),
80+
UserCall(CallArgs),
8181
IndirectCall(CallArgs),
8282
Jump(JumpArg),
8383
Return(RetArg),
@@ -94,9 +94,9 @@ pub type MemArg = (Reg, NonLocal);
9494
pub type JumpArg = Label;
9595
pub type RetArg = MaybeImm;
9696
pub type BranchArg = (MaybeImm, Label, Label);
97-
pub type CallArgs = (Reg, Reg, NonLocal);
97+
pub type CallArgs = (Reg, Reg, Reg, NonLocal);
9898
pub type OutputCallArgs = (Reg, Reg, Command, Option<Redirection>);
99-
pub type IndCallArgs = (Reg, Reg, Reg);
99+
pub type IndCallArgs = (Reg, Reg, Reg, Reg);
100100

101101
#[repr(u8)]
102102
#[derive(Clone, Copy, Debug)]
@@ -195,17 +195,18 @@ impl Display for Instruction {
195195
Self::Return(src) => {
196196
write!(f, "{op} {src}")
197197
}
198-
Self::IntrinsicCall((dest, code, args)) | Self::IndirectCall((dest, code, args)) => {
199-
write!(f, "{dest} <- {op} {code}, {args}")
198+
Self::IntrinsicCall((dest, start, end, fun))
199+
| Self::IndirectCall((dest, start, end, fun)) => {
200+
write!(f, "{dest} <- {op} {fun}, {start}..{end}")
200201
}
201202
Self::OutputCall((start, end, call, Some(redir))) => {
202203
write!(f, "{call}{redir:?} {start}..{end}")
203204
}
204205
Self::OutputCall((start, end, call, None)) => {
205206
write!(f, "{call} {start}..{end}")
206207
}
207-
Self::UserCall((dest, src, args)) => {
208-
write!(f, "{dest} <- {op} {src}, {args}")
208+
Self::UserCall((dest, start, end, fun)) => {
209+
write!(f, "{dest} <- {op} {fun}, {start}..{end}")
209210
}
210211
}
211212
}

interpreter/src/vm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ impl Interpreter<'_> {
213213
Instruction::StoreRecord(_) => todo!(),
214214
Instruction::StoreBuiltinScalar((_dest, _imm, _src)) => todo!(),
215215
Instruction::StoreBuiltinArray((_dest, _src, _start, _end)) => todo!(),
216-
Instruction::IntrinsicCall((_dest, _code, _args)) => todo!(),
216+
Instruction::IntrinsicCall((_dest, _start, _end, _fun)) => todo!(),
217217
Instruction::OutputCall((start, end, fun, redir)) => {
218218
self.intrinsic_print(start, end, fun, redir);
219219
}
220-
Instruction::UserCall((_dest, _code, _args)) => todo!(),
221-
Instruction::IndirectCall((_dest, _code, _args)) => todo!(),
220+
Instruction::UserCall((_dest, _start, _end, _fun)) => todo!(),
221+
Instruction::IndirectCall((_dest, _start, _end, _fun)) => todo!(),
222222
Instruction::Jump(Label(label)) => {
223223
self.program_counter = label as _;
224224
continue;

0 commit comments

Comments
 (0)