maybe fixed

This commit is contained in:
mlokr 2024-09-01 23:14:48 +02:00
parent 9bdacfffb2
commit cbe6f98dff
No known key found for this signature in database
GPG key ID: DEA147DDEE644993
3 changed files with 50 additions and 8 deletions

View file

@ -456,17 +456,20 @@ main := fn(): int {
#### comptime_min_reg_leak
```hb
a := @use("math.hb").min(100, 50)
main := fn(): int {
return a
}
// in module: math.hb
SIZEOF_INT := 32
SHIFT := SIZEOF_INT - 1
min := fn(a: int, b: int): int {
c := a - b
return b + (c & c >> SHIFT)
}
a := min(100, 50)
main := fn(): int {
return a
}
```
#### different_types
@ -574,3 +577,38 @@ main := fn(): int {
return 1
}
```
#### structs_in_registers
```hb
ColorBGRA := struct {b: u8, g: u8, r: u8, a: u8}
MAGENTA := ColorBGRA.{b: 205, g: 0, r: 205, a: 255}
main := fn(): int {
color := MAGENTA
return color.r
}
```
#### comptime_function_from_another_file
```hb
stn := @use("stn.hb")
CONST_A := 100
CONST_B := 50
a := stn.math.min(CONST_A, CONST_B)
main := fn(): int {
return a
}
// in module: stn.hb
math := @use("math.hb")
// in module: math.hb
SIZEOF_INT := 32
SHIFT := SIZEOF_INT - 1
min := fn(a: int, b: int): int {
c := a - b
return b + (c & c >> SHIFT)
}
```

View file

@ -1852,7 +1852,7 @@ impl Codegen {
self.tasks.push(Some(FTask {
// FIXME: this will fuck us
file: self.ci.file,
file: fuc.file,
id: func_id as _,
}));
@ -2929,7 +2929,7 @@ impl Codegen {
match name {
Ok(_) => self.report(pos, format_args!("undefined indentifier: {lit_name}")),
Err("main") => self.report(pos, format_args!("missing main function: {f}")),
Err(name) => unimplemented!("somehow we did not handle: {name:?}"),
Err(name) => self.report(pos, format_args!("undefined indentifier: {name}")),
}
};
@ -3353,6 +3353,7 @@ mod tests {
sort_something_viredly => README;
hex_octal_binary_literals => README;
comptime_min_reg_leak => README;
// structs_in_registers => README;
comptime_function_from_another_file => README;
}
}

View file

@ -0,0 +1,3 @@
code size: 255
ret: 50
status: Ok(())