From 0fec7de747d93586eda66ce190f5f3d6715421a4 Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 4 Aug 2022 22:36:59 +0200 Subject: struct,unions, compound literals; mostly --- bootstrap/test.cff | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'bootstrap/test.cff') diff --git a/bootstrap/test.cff b/bootstrap/test.cff index 89a21eb..651c2ce 100644 --- a/bootstrap/test.cff +++ b/bootstrap/test.cff @@ -1,30 +1,28 @@ -typedef v3f ["!"[~-1] - as(i16)30.4f64]f32; -enum Color { - Red = 7, - Green = -10, - Blue, +struct Vec2f; +struct Vec2f { + x f32, + y f32, } -fn best() Color { - return :Green; +union Val { + x i64, + lo i32, + y f64, } -fn hex(c Color) u32 { - switch (c) { - case :Red; return 0xFF0000; - case :Green; return 0x00FF00; - case :Blue; return 0x0000FF; - } -} +static xs *void = {}; extern fn main (argc int, argv **u8) void { extern fn printf(fmt *const u8, ...) int; - printf("red %d\n", Color:Red); - printf("green %d\n", Color:Green); - printf("blue %d\n", Color:Blue); - printf("red ! %.8X\n", hex(:Red)); - + let x Vec2f = { .y: 1, .x: 2.4 }; + printf("v = { %g, %g }\n", x.x, x.y); + + let is [10]int = { [4] = 1, 2, [1 - 1] = 3 }; + for let i = 0; i < 10; ++i { + printf("%d\n", is[i]); + } + return; } -- cgit v1.2.3