stage1 重构测试且成功00-05

This commit is contained in:
zzy
2026-07-05 21:45:43 +08:00
parent 51d8510b79
commit e2e0ebc21f
39 changed files with 1090 additions and 461 deletions

22
stage1/test11_enum.spl Normal file
View File

@@ -0,0 +1,22 @@
/* ===== 模块5复合类型 =====
* test11_enum — 枚举
* 难度3/5
* 验证点enum 定义、简单枚举值、带数据枚举变体
*/
#[extern("vm")] fn vm_printf(fmt: *u8, ...) void;
type Color = enum {
Red,
Green,
Blue,
}
type Expr = enum {
Int: i32,
Add: struct { left: *Expr, right: *Expr },
}
fn main() i32 {
vm_printf("enum values: %d %d %d\n", Color.Red, Color.Green, Color.Blue);
ret 0;
}