Skip to content

Commit 5d71374

Browse files
:)
1 parent e0ebae5 commit 5d71374

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

example/test.gila

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11

22

33
foo fn(x:u32,y:u32) do
4+
print(x)
45
return y
56
end
67

7-
a=foo(55,44)
8-
b=foo(66,77)
8+
foo(55,44)
9+
foo(66,77)
10+
foo(88,99)

src/codegen.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,15 @@ impl SlotManager {
434434
}
435435
}
436436

437-
pub fn find_contiguous_slots(&mut self, num: u8) -> u8 {
437+
pub fn find_contiguous_slots(&mut self, existing_slots: &Vec<u8>) -> u8 {
438438
// Find the next unused slot (incrementally grow slot numbers)
439439

440440
for i in 0..255 {
441441
let mut counter = 0;
442-
while !self.is_allocated(i + counter) && counter < num {
442+
while !self.is_allocated(i + counter) && counter < existing_slots.len() as u8 {
443443
counter += 1;
444444
}
445-
if counter == num {
445+
if counter == existing_slots.len() as u8 {
446446
return i;
447447
}
448448
}
@@ -1294,7 +1294,7 @@ impl BytecodeGenerator<'_> {
12941294

12951295
// todo find a register to put the args into!!!
12961296

1297-
let contiguous_slot = find_contiguous_slots!(self, arg_registers.len() as u8);
1297+
let contiguous_slot = find_contiguous_slots!(self, &arg_registers);
12981298

12991299
let mut new_arg_registers: Vec<u8> = vec![];
13001300
for i in 0..arg_registers.len() {

0 commit comments

Comments
 (0)