From d104761e3c213504f5a6dfb63059fc905fe6799f Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 4 Aug 2022 15:46:32 +0200 Subject: enum --- bootstrap/test.cff | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'bootstrap/test.cff') diff --git a/bootstrap/test.cff b/bootstrap/test.cff index ba47c6d..d962b16 100644 --- a/bootstrap/test.cff +++ b/bootstrap/test.cff @@ -1,7 +1,30 @@ -typedef v3f ["!"[~-1] - 30]f32; +typedef v3f ["!"[~-1] - as(int)30.0]f32; + +enum Color { + Red = 7, + Green = -10, + Blue, +} + +fn best() Color { + return :Green; +} + +fn hex(c Color) u32 { + switch (c) { + case :Red do return 0xFF0000; + case :Green do return 0x00FF00; + case :Blue do return 0x0000FF; + } +} 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)); return; } -- cgit v1.2.3