updating tests and fixing bug

This commit is contained in:
mlokr 2024-09-04 18:48:25 +02:00
parent ed1b9459fc
commit 937c107dec
No known key found for this signature in database
GPG key ID: DEA147DDEE644993
5 changed files with 25 additions and 8 deletions

View file

@ -733,7 +733,7 @@ some_func := fn($Elem: type): void {
}
main := fn(): void {
some_func(0)
some_func(u8)
return
}
```

View file

@ -1740,12 +1740,12 @@ impl Codegen {
}
}
ty::Kind::Slice(arr) => {
let arr = &self.tys.arrays[arr as usize];
let arr = self.tys.arrays[arr as usize];
let item_size = self.tys.size_of(arr.ty);
for (i, value) in fields.iter().enumerate() {
let loc = loc.as_ref().offset(i as u32 * item_size);
let value =
self.expr_ctx(value, Ctx::default().with_loc(loc).with_ty(ty))?;
self.expr_ctx(value, Ctx::default().with_loc(loc).with_ty(arr.ty))?;
self.ci.free_loc(value.loc);
}
}

View file

@ -2,11 +2,11 @@ main:
ADDI64 r254, r254, -72d
ST r31, r254, 48a, 24h
LI64 r32, 1d
ST r32, r254, 0a, 24h
ST r32, r254, 0a, 8h
LI64 r32, 2d
ST r32, r254, 8a, 24h
ST r32, r254, 8a, 8h
LI64 r32, 4d
ST r32, r254, 16a, 24h
ST r32, r254, 16a, 8h
ADDI64 r32, r254, 0d
ADDI64 r33, r254, 24d
BMC r32, r33, 24h

View file

@ -1,11 +1,12 @@
main:
ADDI64 r254, r254, -24d
ST r31, r254, 0a, 24h
LRA r32, r0, :string
LRA r32, r0, :abඞ
56789
CP r2, r32
JAL r31, r0, :str_len
CP r32, r1
LRA r33, r0, :string
LRA r33, r0, :fff
CP r2, r33
JAL r31, r0, :str_len
CP r33, r1

View file

@ -0,0 +1,16 @@
main:
ADDI64 r254, r254, -8d
ST r31, r254, 0a, 8h
JAL r31, r0, :some_func
LD r31, r254, 0a, 8h
ADDI64 r254, r254, 8d
JALA r0, r31, 0a
some_func:
ADDI64 r254, r254, -8d
ST r31, r254, 0a, 8h
LD r31, r254, 0a, 8h
ADDI64 r254, r254, 8d
JALA r0, r31, 0a
code size: 133
ret: 0
status: Ok(())