stage3 ai编写并提供测试用例并重构nob
This commit is contained in:
1 parent
2c531f23de
commit
b4831c8d1c
150 files changed
+15838
-231
No files matched your search
@@ -0,0 +1,25 @@
|
||||
// 元编程模块:HIR 反射接口。必须显式 `type meta = @import("meta")` 后使用。
|
||||
type Ref = @import("./spl_ir.spl").Ref;
|
||||
type Node = @import("./spl_ir.spl").Node;
|
||||
type ErrorCode = @import("./error_code.spl").ErrorCode;
|
||||
type .{ .number } = @import("./error_code.spl");
|
||||
|
||||
// hook 的固定前缀签名;`#hook(kind)` 只是声明信息,实际种类由签名和挂载位置决定。
|
||||
// 自定义参数接在固定前缀之后,因此这三个别名只约束前缀,不约束完整签名。
|
||||
type Decorator = fn(Ref): Ref;
|
||||
type ParamHook = fn(Ref, Ref): Ref;
|
||||
type ImplHook = fn(type, type): Ref;
|
||||
|
||||
// 四个原语都由 comptime VM 的宿主桥实现:参数/结果可能来自运行中的 VM,
|
||||
// 不能依赖 sema 在分析期把实参折成常量。
|
||||
#builtin(reflect) #extern(builtin) comptime fn reflect(t: type): Ref;
|
||||
#builtin(build) #extern(builtin) comptime fn build(n: Ref): type;
|
||||
#builtin(inspect) #extern(builtin) comptime fn inspect(n: Ref): Node;
|
||||
#builtin(construct) #extern(builtin) comptime fn construct(n: Node): Ref;
|
||||
// 宏诊断:内部只接收数字,公共入口使用 ErrorCode。
|
||||
#builtin(error) #extern(builtin) comptime fn error_raw(code: usize): void;
|
||||
|
||||
comptime fn error(code: ErrorCode): void {
|
||||
@error_raw(number(code));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user