diff --git a/.gitignore b/.gitignore index ff1fd37..da8e37e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ speedcat.pdb test.exe hello.ll *.ll -*.exe \ No newline at end of file +*.exe +*.dSYM +.DS_Store +raylib diff --git a/build_test.sh b/build_test.sh new file mode 100755 index 0000000..a89dd53 --- /dev/null +++ b/build_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +odin run src -o:none -debug -out:speedcat '-extra-linker-flags:-L/opt/homebrew/opt/llvm/lib' -- test_type_checker.cat +clang -I/opt/homebrew/include /opt/homebrew/lib/libraylib.a -lm -framework Cocoa -framework OpenGL -framework IOKit test_type_checker.ll test.c -o raylib diff --git a/test.c b/test.c index f30fcba..fc97a8b 100644 --- a/test.c +++ b/test.c @@ -1,7 +1,24 @@ -#include #include -int32_t meow(int32_t x) { - printf("%d\n", x); - return 500; +void ClearBackground(uint64_t rgba); +void ClearBackgroundWrap(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + ClearBackground((uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 | + (uint64_t)a); +} + +void DrawRectangle(uint32_t x, uint32_t y, uint32_t width, uint32_t height, + uint64_t rgba); +void DrawRectangleWrap(uint32_t x, uint32_t y, uint32_t width, uint32_t height, + uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + DrawRectangle(x, y, width, height, + (uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 | + (uint64_t)a); +} + +void DrawCircle(uint32_t x, uint32_t y, float radius, uint64_t rgba); +void DrawCircleWrap(uint32_t x, uint32_t y, float radius, uint8_t r, uint8_t g, + uint8_t b, uint8_t a) { + DrawCircle(x, y, radius, + (uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 | + (uint64_t)a); } diff --git a/test_type_checker.cat b/test_type_checker.cat index 520eec8..76fe55a 100644 --- a/test_type_checker.cat +++ b/test_type_checker.cat @@ -40,31 +40,31 @@ \ \(meow (add 60 9)) -> meow -struct Color "packed" { - r g b a: u8, +struct Color { + a b g r: u8, } fn InitWindow(w h: i32, title: i32) fn CloseWindow -fn ClearBackground(c: Color) +fn ClearBackgroundWrap(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 DrawRectangleWrap(x y w h: i32, c: Color) +fn DrawCircleWrap(x y: i32, r: f32, c: Color) fn WindowShouldClose i32 -let white :: .Color{255 255 255 255} +let white :: .Color{255 69 69 69} let red :: .Color{255 0 0 255} -let blue :: .Color{0 0 255 255} +let blue :: .Color{255 0 255 255} InitWindow 640 480 0 for WindowShouldClose == 0 { BeginDrawing - ClearBackground white + ClearBackgroundWrap white DrawFPS 20 20 - \DrawRectangle 80 80 100 200 red - \DrawCircle 90 90 100.0 blue + DrawRectangleWrap 80 80 100 200 red + DrawCircleWrap 200 200 100.0 blue EndDrawing } CloseWindow