speedcat/test_type_checker.cat
Slendi 81b0c139ef Add initial support for structs
There is an issue with calling C functions sadly because LLVM seems to
prefer passing each element as its own parameter than "packing" them
into 64 bit registers.

Signed-off-by: Slendi <slendi@socopon.com>
2024-03-26 13:32:51 +02:00

72 lines
1.1 KiB
Plaintext

\\let asdf := 0b1101 as f32
\\let poop :: 12.0 + 2.0 * asdf
\
\\fn name(a b: f32) i32 {
\\ ret (a + b) as i32
\\}
\
\\name 123.0 456.0
\
\\let arr: []i32, arr2: [69]u8, ptr: ^i32
\
\fn meow(val: i32) i32
\
\let amogus := 500 + (meow 8008135)
\
\meow 69 * amogus + 420
\
\let a b := 5 1
\
\if a == 5 {
\ if b {
\ meow 123
\ } else {
\ meow 69
\ }
\} elif a == 2 {
\ meow 456
\} else {
\ meow 420
\}
\
\fn add(a b: i32) i32 {
\ ret a + b
\}
\
\for a != 0 {
\ meow (1 << a) >> 1
\ a = a - 1
\}
\
\(meow (add 60 9)) -> meow
struct Color "packed" {
r g b a: u8,
}
fn InitWindow(w h: i32, title: i32)
fn CloseWindow
fn ClearBackground(c: Color)
fn BeginDrawing
fn EndDrawing
fn DrawFPS(x y: i32)
fn DrawRectangle(x y w h: i32, c: Color)
fn DrawCircle(x y: i32, r: f32, c: Color)
fn WindowShouldClose i32
let white :: .Color{255 255 255 255}
let red :: .Color{255 0 0 255}
let blue :: .Color{0 0 255 255}
InitWindow 640 480 0
for WindowShouldClose == 0 {
BeginDrawing
ClearBackground white
DrawFPS 20 20
\DrawRectangle 80 80 100 200 red
\DrawCircle 90 90 100.0 blue
EndDrawing
}
CloseWindow