stage2 修复大量AI生成的风格问题 stage1 修复对于vm abi的错误生成
This commit is contained in:
1 parent
0e38858785
commit
76f980654c
40 files changed
+619
-938
No files matched your search
+2
-15
@@ -1,14 +1,7 @@
|
||||
// Expect retcode = 0
|
||||
|
||||
// 丰富诊断(参考 rustc / Clang / Swift 的设计,不照搬 stage1 C 实现):
|
||||
// Severity Note/Help/Warning/Error/Fatal
|
||||
// Code 固定语义枚举 + 稳定 E 码;集中管理,利于 diff
|
||||
// Span 字节区间 {file,start,end};file 是 Sources 的下标,NO_FILE 表示无位置
|
||||
// Label 主/次标签(span + 文本),可多个
|
||||
// Child 子诊断(note/help,可带 span),挂在条目上
|
||||
// 渲染:人类可读(源码行 + caret 下划线)与 JSON(字段稳定)双格式。
|
||||
// 位置只存下标,渲染时经 Sources 解析行列/取行,避免复制文件名。
|
||||
// 消息按拥有型 Str 保存;条目拥有其 labels/children;clear/drop 释放全部内部资源。
|
||||
// 丰富诊断:Severity / 稳定 E 码 / Span / Label / Child,渲染为人类可读或 JSON。
|
||||
// 位置只存下标,渲染时经 Sources 解析行列;条目拥有其字符串与 labels/children。
|
||||
|
||||
type .{ .Error, .Status, .make } = @import("./utils/error.spl");
|
||||
type .{ .Vec } = @import("./utils/vec.spl");
|
||||
@@ -181,7 +174,6 @@ fn has_error(self: Diag): bool { ret self.errors > 0; }
|
||||
|
||||
fn has_fatal(self: Diag): bool { ret self.fatals > 0; }
|
||||
|
||||
// ---- 采集 ----
|
||||
|
||||
// 追加一条诊断,返回其下标(失败返回 no_file())。span 为主位置。
|
||||
fn emit(self: *Diag, severity: Severity, stage: Stage, code: Code, span: Span,
|
||||
@@ -265,7 +257,6 @@ fn attach_child(self: *Diag, severity: Severity, span: Span, msg: []u8): Status
|
||||
ret .Ok;
|
||||
}
|
||||
|
||||
// ---- 名称 ----
|
||||
|
||||
fn severity_name(severity: Severity): []u8 {
|
||||
match severity {
|
||||
@@ -370,7 +361,6 @@ fn code_name(code: Code): []u8 {
|
||||
ret "none";
|
||||
}
|
||||
|
||||
// ---- 渲染:公共小工具 ----
|
||||
|
||||
fn append_num(out: *ByteBuffer, value: usize): Status {
|
||||
ret append_usize(out, value, 10, false);
|
||||
@@ -519,7 +509,6 @@ fn render_human(self: *Diag, out: *ByteBuffer): Status {
|
||||
ret .Ok;
|
||||
}
|
||||
|
||||
// ---- JSON 渲染(字段稳定,供 LSP / diff 工具)----
|
||||
|
||||
fn append_json_hex4(out: *ByteBuffer, b: u8): Status {
|
||||
var hex: []u8 = "0123456789abcdef";
|
||||
@@ -661,7 +650,6 @@ fn render_json(self: *Diag, out: *ByteBuffer): Status {
|
||||
ret ByteBuffer.append_byte(out, ']');
|
||||
}
|
||||
|
||||
// ---- 生命周期 ----
|
||||
|
||||
fn drop_item(it: *Item) {
|
||||
Str.drop(&it.message);
|
||||
@@ -700,7 +688,6 @@ fn drop(self: *Diag) {
|
||||
self.sources = null;
|
||||
}
|
||||
|
||||
// ---- 测试辅助 ----
|
||||
|
||||
fn view(text: []u8): ByteView {
|
||||
ret ByteView.from_slice(text);
|
||||
|
||||
Reference in new issue
Block a user