fixing non pointer struct method receiver not counting as use

forgot to strip pointer

Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
Jakub Doka 2024-12-14 15:19:02 +01:00
parent fae75072f4
commit 5aeeedbdce
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
4 changed files with 39 additions and 2 deletions

View file

@ -692,7 +692,6 @@ modify := fn($num: ^uint): void {
}
```
#### fb_driver
```hb
arm_fb_ptr := fn(): uint return 100
@ -733,6 +732,36 @@ main := fn(): uint {
### Purely Testing Examples
#### method_receiver_by_value
```hb
$log := fn(ptr: ^u8): void return @eca(0, ptr)
Struct := struct {
ptr: ^u8,
print := fn(self: Self, rhs: Self): void {
log(self.ptr)
log(rhs.ptr)
}
}
Struct2 := struct {
ptr: ^u8,
print2 := fn(self: ^Self, rhs: ^Self): void {
log(self.ptr)
log(rhs.ptr)
}
}
main := fn(): void {
lhs := Struct.("Hello, World!\0")
rhs := Struct.("Goodbye, World!\0")
lhs.print(rhs)
lhs2 := Struct2.("Hello, World!\0")
rhs2 := Struct2.("Goodbye, World!\0")
lhs2.print2(&rhs2)
}
```
#### comparing_floating_points
```hb
main := fn(): uint {

View file

@ -1121,7 +1121,7 @@ pub struct AbleOsExecutableHeader {
#[cfg(test)]
pub fn test_run_vm(out: &[u8], output: &mut String) {
use core::fmt::Write;
use core::{ffi::CStr, fmt::Write};
let mut stack = [0_u64; 1024 * 20];
@ -1138,6 +1138,12 @@ pub fn test_run_vm(out: &[u8], output: &mut String) {
match vm.run() {
Ok(hbvm::VmRunOk::End) => break Ok(()),
Ok(hbvm::VmRunOk::Ecall) => match vm.read_reg(2).0 {
0 => writeln!(
output,
"{}",
unsafe { CStr::from_ptr(vm.read_reg(3).0 as _) }.to_str().unwrap()
)
.unwrap(),
1 => writeln!(output, "ev: Ecall").unwrap(), // compatibility with a test
69 => {
let [size, align] = [vm.read_reg(3).0 as usize, vm.read_reg(4).0 as usize];

View file

@ -4591,6 +4591,7 @@ impl<'a> Codegen<'a> {
_ => {}
}
self.assert_ty(func.pos(), caller, ty, fa!("caller argument {}", carg.name));
self.strip_ptr(caller);
self.add_clobbers(*caller, &mut clobbered_aliases);
self.ci.nodes.lock(caller.id);
inps.push(caller.id);
@ -5987,6 +5988,7 @@ mod tests {
fb_driver;
// Purely Testing Examples;
method_receiver_by_value;
comparing_floating_points;
pointer_comparison;
different_function_destinations;