forked from AbleOS/holey-bytes
maybe fixed
This commit is contained in:
parent
9bdacfffb2
commit
cbe6f98dff
|
@ -456,17 +456,20 @@ main := fn(): int {
|
||||||
|
|
||||||
#### comptime_min_reg_leak
|
#### comptime_min_reg_leak
|
||||||
```hb
|
```hb
|
||||||
|
a := @use("math.hb").min(100, 50)
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
// in module: math.hb
|
||||||
|
|
||||||
SIZEOF_INT := 32
|
SIZEOF_INT := 32
|
||||||
SHIFT := SIZEOF_INT - 1
|
SHIFT := SIZEOF_INT - 1
|
||||||
min := fn(a: int, b: int): int {
|
min := fn(a: int, b: int): int {
|
||||||
c := a - b
|
c := a - b
|
||||||
return b + (c & c >> SHIFT)
|
return b + (c & c >> SHIFT)
|
||||||
}
|
}
|
||||||
a := min(100, 50)
|
|
||||||
|
|
||||||
main := fn(): int {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### different_types
|
#### different_types
|
||||||
|
@ -574,3 +577,38 @@ main := fn(): int {
|
||||||
return 1
|
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)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
@ -1852,7 +1852,7 @@ impl Codegen {
|
||||||
|
|
||||||
self.tasks.push(Some(FTask {
|
self.tasks.push(Some(FTask {
|
||||||
// FIXME: this will fuck us
|
// FIXME: this will fuck us
|
||||||
file: self.ci.file,
|
file: fuc.file,
|
||||||
id: func_id as _,
|
id: func_id as _,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -2929,7 +2929,7 @@ impl Codegen {
|
||||||
match name {
|
match name {
|
||||||
Ok(_) => self.report(pos, format_args!("undefined indentifier: {lit_name}")),
|
Ok(_) => self.report(pos, format_args!("undefined indentifier: {lit_name}")),
|
||||||
Err("main") => self.report(pos, format_args!("missing main function: {f}")),
|
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;
|
sort_something_viredly => README;
|
||||||
hex_octal_binary_literals => README;
|
hex_octal_binary_literals => README;
|
||||||
comptime_min_reg_leak => README;
|
comptime_min_reg_leak => README;
|
||||||
|
// structs_in_registers => README;
|
||||||
|
comptime_function_from_another_file => README;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
code size: 255
|
||||||
|
ret: 50
|
||||||
|
status: Ok(())
|
Loading…
Reference in a new issue