This patch adds the following arguments: 1. `--dump-ast` or `-d`: This dumps the Abstract Syntax Tree 2. `--dont-emit-llvm` or `-L`: This skips the LLVM generation step only parsing and type checking. Useful for debugging. Besides this, formatting of the time each compiler step took is also improved and easier to read now. Signed-off-by: Slendi <slendi@socopon.com>
194 lines
4.2 KiB
Plaintext
194 lines
4.2 KiB
Plaintext
\enum MyEnum {
|
|
\ EnumItem1,
|
|
\ EnumItem2 = 1,
|
|
\ EnumItem3,
|
|
\ EnumItem4,
|
|
\}
|
|
\
|
|
\enum MyTypedEnum : i8 {
|
|
\ EnumItem1,
|
|
\ EnumItem2,
|
|
\ EnumItem3 = 105,
|
|
\ EnumItem4,
|
|
\}
|
|
|
|
struct Vec2 {
|
|
x y: f32,
|
|
}
|
|
|
|
struct Rect {
|
|
pos size: Vec2,
|
|
}
|
|
|
|
let CONSTPOS :: .Vec2 {20.0 20.0}
|
|
let CONSTSZ :: .Vec2 {100.0 100.0}
|
|
let CONST :: .Rect {(CONSTPOS) (CONSTSZ)}
|
|
|
|
\ FIXME: LLVM IR geneartion is borked
|
|
\ let CONST :: .Rect { .Vec2 { 20.0 20.0 } .Vec2 { 100.0 100.0 } }
|
|
|
|
struct Color {
|
|
r g b a: u8,
|
|
}
|
|
|
|
let KEY_R :: 82
|
|
|
|
fn InitWindow(w h: i32, title: []u8)
|
|
fn CloseWindow
|
|
fn BeginDrawing
|
|
fn SetTargetFPS(fps: i32)
|
|
fn EndDrawing
|
|
fn DrawFPS(x y: i32)
|
|
fn WindowShouldClose i32
|
|
fn TextSubtext(text: []u8, start end: i32) []u8
|
|
fn IsKeyPressed(key: i32) u1
|
|
|
|
struct Rectangle {
|
|
x y w h: f32,
|
|
}
|
|
|
|
fn ColorToRaylib(c: Color) u32 {
|
|
ret c.a as u32 << 24 as u32 | c.b as u32 << 16 as u32 | c.g as u32 << 8 as u32 | c.r
|
|
}
|
|
|
|
fn ClearBackgroundWrap(c: Color) {
|
|
fn ClearBackground(c: u32)
|
|
ClearBackground (ColorToRaylib c)
|
|
}
|
|
|
|
fn DrawRectangleWrap(x y w h: i32, c: Color) {
|
|
fn DrawRectangle(x y w h: i32, c: u32)
|
|
DrawRectangle x y w h (ColorToRaylib c)
|
|
}
|
|
|
|
fn DrawCircleWrap(x y: i32, r: f32, c: Color) {
|
|
fn DrawCircle(x y: i32, r: f32, c: u32)
|
|
DrawCircle x y r (ColorToRaylib c)
|
|
}
|
|
|
|
fn DrawRectangleRecWrap(r: Rectangle, c: Color) {
|
|
fn DrawRectangleRec(r: Rectangle, c: u32)
|
|
DrawRectangleRec r (ColorToRaylib c)
|
|
}
|
|
|
|
fn DrawTextWrap(text: []u8, x y size: i32, c: Color) {
|
|
fn DrawText(text: []u8, x y size: i32, c: u32)
|
|
DrawText text x y size (ColorToRaylib c)
|
|
}
|
|
|
|
let WHITE :: .Color {255 255 255 255}
|
|
let BLACK :: .Color {0 0 0 255}
|
|
let RED :: .Color {255 0 0 255}
|
|
let BLUE :: .Color {0 0 255 255}
|
|
|
|
InitWindow 800 450 Raylib
|
|
SetTargetFPS 60
|
|
|
|
fn GetScreenWidth i32
|
|
fn GetScreenHeight i32
|
|
|
|
fn DrawRect(rect: Rect, c: Color) {
|
|
DrawRectangleWrap (rect.pos.x as i32) (rect.pos.y as i32) (rect.size.x as i32) (rect.size.y as i32) c
|
|
}
|
|
|
|
let logox := GetScreenWidth / 2 - 128
|
|
let logoy := GetScreenHeight / 2 - 128
|
|
|
|
\ FIXME: Cannot inline
|
|
let fc := 0
|
|
let lc := 0
|
|
let top_side_rec_width := 16
|
|
let left_side_rec_height := 16
|
|
let bottom_side_rec_width := 16
|
|
let right_side_rec_height := 16
|
|
|
|
let state := 0
|
|
let alpha := 1.0
|
|
|
|
for WindowShouldClose == 0 {
|
|
if state == 0 {
|
|
if ++fc == 120 {
|
|
state = 1
|
|
fc = 0
|
|
}
|
|
} elif state == 1 {
|
|
top_side_rec_width = top_side_rec_width + 4
|
|
left_side_rec_height = left_side_rec_height + 4
|
|
|
|
if top_side_rec_width == 256 {
|
|
state = 2
|
|
}
|
|
} elif state == 2 {
|
|
bottom_side_rec_width = bottom_side_rec_width + 4
|
|
right_side_rec_height = right_side_rec_height + 4
|
|
|
|
if bottom_side_rec_width == 256 {
|
|
state = 3
|
|
}
|
|
} elif state == 3 {
|
|
if ++fc / 12 != 0 {
|
|
++lc
|
|
fc = 0
|
|
}
|
|
|
|
if lc >= 10 {
|
|
alpha = alpha - 0.01
|
|
if alpha <= 0.0 {
|
|
alpha = 0.0
|
|
state = 4
|
|
}
|
|
}
|
|
} elif IsKeyPressed(KEY_R) { \
|
|
fc = lc = 0
|
|
|
|
top_side_rec_width = 16
|
|
left_side_rec_height = 16
|
|
bottom_side_rec_width = 16
|
|
right_side_rec_height = 16
|
|
|
|
state = 0
|
|
alpha = 1.0
|
|
}
|
|
|
|
BeginDrawing
|
|
ClearBackgroundWrap WHITE
|
|
DrawFPS 20 20
|
|
|
|
DrawRect CONST RED
|
|
|
|
if state == 0 {
|
|
if (fc/15)%2 != 0 {
|
|
DrawRectangleWrap logox logoy 16 16 BLACK
|
|
}
|
|
} elif state == 1 {
|
|
DrawRectangleWrap logox logoy top_side_rec_width 16 BLACK
|
|
DrawRectangleWrap logox logoy 16 left_side_rec_height BLACK
|
|
} elif state == 2 {
|
|
DrawRectangleWrap logox logoy top_side_rec_width 16 BLACK
|
|
DrawRectangleWrap logox logoy 16 left_side_rec_height BLACK
|
|
|
|
DrawRectangleWrap logox+240 logoy 16 right_side_rec_height BLACK
|
|
DrawRectangleWrap logox logoy+240 bottom_side_rec_width 16 BLACK
|
|
} elif state == 3 {
|
|
let colorw := .Color{255 255 255 (alpha*255.0) as u8}
|
|
let colorb := .Color{0 0 0 (alpha*255.0) as u8}
|
|
\ FIXME: ADD field access assignment
|
|
\color.a = (alpha * 255.0) as u8
|
|
DrawRectangleWrap logox logoy top_side_rec_width 16 colorb
|
|
DrawRectangleWrap logox logoy+16 16 left_side_rec_height-32 colorb
|
|
|
|
DrawRectangleWrap logox+240 logoy+16 16 right_side_rec_height-32 cbolor
|
|
DrawRectangleWrap logox logoy+240 bottom_side_rec_width 16 colorb
|
|
|
|
DrawRectangleWrap GetScreenWidth/2-112 GetScreenHeight/2-112 224 224 colorw
|
|
|
|
DrawTextWrap (TextSubtext raylib 0 lc) GetScreenWidth/2-44 GetScreenHeight/2+48 50 colorb
|
|
} else {
|
|
DrawTextWrap "[R] REPLAY" 340 200 20 BLACK
|
|
}
|
|
|
|
EndDrawing
|
|
}
|
|
CloseWindow
|
|
|