diff --git a/hblang/README.md b/hblang/README.md index f2ed519..4990af1 100644 --- a/hblang/README.md +++ b/hblang/README.md @@ -557,4 +557,36 @@ main := fn(): int { } return 1 } +``` + +#### comptime_function_from_another_file +```hb +.{min} := @use("math.hb") +a := 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) +} +``` + +#### using_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 +} ``` \ No newline at end of file diff --git a/hblang/src/codegen.rs b/hblang/src/codegen.rs index acf9b5c..c628df1 100644 --- a/hblang/src/codegen.rs +++ b/hblang/src/codegen.rs @@ -3341,5 +3341,7 @@ mod tests { comptime_pointers => README; sort_something_viredly => README; hex_octal_binary_literals => README; + comptime_function_from_another_file => README; + using_structs_in_registers => README; } }