cleanup(selfhost): remove 24 DEBUG prints + stale parser HACK

- Remove DEBUG prints from c_backend.bux, hir_lower.bux, lexer.bux, parser.bux
- Remove HACK for stray } in parserParseFuncDecl (no longer needed after
  Decl refactor in 4a86009)
- Clean selfhost check/build output
This commit is contained in:
2026-06-09 15:48:38 +03:00
parent 4a860095fd
commit 64bd41067a
4 changed files with 0 additions and 43 deletions
-27
View File
@@ -748,9 +748,6 @@ func CBE_StructHasValueStructField(st: *HirStruct) -> bool {
var fi: int = 0; var fi: int = 0;
while fi < st.fieldCount { while fi < st.fieldCount {
let ft: String = st.fields[fi].typeName; let ft: String = st.fields[fi].typeName;
if String_Eq(st.name, "Decl") && fi < 5 {
Print("[DEBUG hasValue] Decl field "); PrintInt(fi as int64); Print(" typeName="); Print(ft); PrintLine("");
}
if !CBE_IsPrimitiveTypeName(ft) && !String_EndsWith(ft, "*") { if !CBE_IsPrimitiveTypeName(ft) && !String_EndsWith(ft, "*") {
return true; return true;
} }
@@ -760,16 +757,11 @@ func CBE_StructHasValueStructField(st: *HirStruct) -> bool {
} }
func CBE_EmitStructDef(cbe: *CEmitter, st: *HirStruct) { func CBE_EmitStructDef(cbe: *CEmitter, st: *HirStruct) {
Print("[DEBUG c struct] name="); Print(st.name); Print(" fieldCount="); PrintInt(st.fieldCount as int64); PrintLine("");
StringBuilder_Append(&cbe.sb, "struct "); StringBuilder_Append(&cbe.sb, "struct ");
StringBuilder_Append(&cbe.sb, st.name); StringBuilder_Append(&cbe.sb, st.name);
StringBuilder_Append(&cbe.sb, " {\n"); StringBuilder_Append(&cbe.sb, " {\n");
var fi: int = 0; var fi: int = 0;
Print("[DEBUG c emit] "); Print(st.name); Print(" fieldCount="); PrintInt(st.fieldCount as int64); PrintLine("");
while fi < st.fieldCount { while fi < st.fieldCount {
if String_Eq(st.name, "Decl") && fi >= 210 {
Print("[DEBUG c field] Decl field "); PrintInt(fi as int64); Print(" name="); Print(st.fields[fi].name); PrintLine("");
}
StringBuilder_Append(&cbe.sb, " "); StringBuilder_Append(&cbe.sb, " ");
var ft: String = st.fields[fi].typeName; var ft: String = st.fields[fi].typeName;
if String_Eq(ft, "int") || String_Eq(ft, "") { if String_Eq(ft, "int") || String_Eq(ft, "") {
@@ -838,7 +830,6 @@ func CBE_GetExprTypeName(mod: *HirModule, node: *HirNode) -> String {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
func CBackend_Generate(mod: *HirModule) -> String { func CBackend_Generate(mod: *HirModule) -> String {
Print("[DEBUG CBackend_Generate] structCount="); PrintInt(mod.structCount as int64); PrintLine("");
let cbe: *CEmitter = bux_alloc(sizeof(CEmitter)) as *CEmitter; let cbe: *CEmitter = bux_alloc(sizeof(CEmitter)) as *CEmitter;
cbe.sb = StringBuilder_NewCap(8192); cbe.sb = StringBuilder_NewCap(8192);
cbe.indent = 0; cbe.indent = 0;
@@ -870,7 +861,6 @@ func CBackend_Generate(mod: *HirModule) -> String {
// Forward declare all struct types (skip generics) // Forward declare all struct types (skip generics)
var si: int = 0; var si: int = 0;
while si < mod.structCount { while si < mod.structCount {
Print("[DEBUG c struct name] "); Print(mod.structs[si].name); Print(" fieldCount="); PrintInt(mod.structs[si].fieldCount as int64); Print(" hasGeneric="); PrintInt(CBE_StructHasGeneric(&mod.structs[si]) as int64); PrintLine("");
if !CBE_StructHasGeneric(&mod.structs[si]) { if !CBE_StructHasGeneric(&mod.structs[si]) {
StringBuilder_Append(&cbe.sb, "typedef struct "); StringBuilder_Append(&cbe.sb, "typedef struct ");
StringBuilder_Append(&cbe.sb, mod.structs[si].name); StringBuilder_Append(&cbe.sb, mod.structs[si].name);
@@ -878,9 +868,6 @@ func CBackend_Generate(mod: *HirModule) -> String {
StringBuilder_Append(&cbe.sb, mod.structs[si].name); StringBuilder_Append(&cbe.sb, mod.structs[si].name);
StringBuilder_Append(&cbe.sb, ";\n"); StringBuilder_Append(&cbe.sb, ";\n");
} }
if String_Eq(mod.structs[si].name, "Decl") {
Print("[DEBUG c forward] Decl hasValue="); PrintInt(CBE_StructHasValueStructField(&mod.structs[si]) as int64); PrintLine("");
}
si = si + 1; si = si + 1;
} }
StringBuilder_Append(&cbe.sb, "\n"); StringBuilder_Append(&cbe.sb, "\n");
@@ -1000,15 +987,9 @@ func CBackend_Generate(mod: *HirModule) -> String {
continue; continue;
} }
if CBE_StructHasValueStructField(&mod.structs[si]) { if CBE_StructHasValueStructField(&mod.structs[si]) {
if String_Eq(mod.structs[si].name, "Decl") {
Print("[DEBUG c pass1] Decl skipped (has value struct field)\n");
}
si = si + 1; si = si + 1;
continue; continue;
} }
if String_Eq(mod.structs[si].name, "Decl") {
Print("[DEBUG c pass1] Decl emitting\n");
}
CBE_EmitStructDef(cbe, &mod.structs[si]); CBE_EmitStructDef(cbe, &mod.structs[si]);
si = si + 1; si = si + 1;
} }
@@ -1020,17 +1001,9 @@ func CBackend_Generate(mod: *HirModule) -> String {
continue; continue;
} }
if !CBE_StructHasValueStructField(&mod.structs[si]) { if !CBE_StructHasValueStructField(&mod.structs[si]) {
if String_Eq(mod.structs[si].name, "Decl") {
Print("[DEBUG c pass2] Decl skipped (no value struct field)\n");
}
si = si + 1; si = si + 1;
continue; continue;
} }
if String_Eq(mod.structs[si].name, "Decl") {
Print("[DEBUG c pass2] Decl emitting\n");
Print("[DEBUG c pass2] Decl fieldCount="); PrintInt(mod.structs[si].fieldCount as int64); PrintLine("");
Print("[DEBUG c pass2] Decl name="); Print(mod.structs[si].name); PrintLine("");
}
CBE_EmitStructDef(cbe, &mod.structs[si]); CBE_EmitStructDef(cbe, &mod.structs[si]);
si = si + 1; si = si + 1;
} }
-5
View File
@@ -712,7 +712,6 @@ func Lcx_LowerParam(out: *HirParam, p: *Param) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
func Lcx_LowerFunc(ctx: *LowerCtx, decl: *Decl) -> *HirFunc { func Lcx_LowerFunc(ctx: *LowerCtx, decl: *Decl) -> *HirFunc {
Print("[DEBUG Lcx_LowerFunc] name="); Print(decl.strValue); PrintLine("");
let f: *HirFunc = bux_alloc(sizeof(HirFunc)) as *HirFunc; let f: *HirFunc = bux_alloc(sizeof(HirFunc)) as *HirFunc;
f.name = decl.strValue; f.name = decl.strValue;
f.isPublic = decl.isPublic; f.isPublic = decl.isPublic;
@@ -828,7 +827,6 @@ func HirLower_LowerModule(mod: *Module, sema: *Sema) -> *HirModule {
// Iterate declarations // Iterate declarations
var decl: *Decl = mod.firstItem; var decl: *Decl = mod.firstItem;
while decl != null as *Decl { while decl != null as *Decl {
Print("[DEBUG hir_lower] decl kind="); PrintInt(decl.kind as int64); Print(" name="); Print(decl.strValue); PrintLine("");
if decl.kind == dkFunc && decl.refBody != null as *Block { if decl.kind == dkFunc && decl.refBody != null as *Block {
let f: *HirFunc = Lcx_LowerFunc(ctx, decl); let f: *HirFunc = Lcx_LowerFunc(ctx, decl);
ctx.funcs[ctx.funcCount] = *f; ctx.funcs[ctx.funcCount] = *f;
@@ -849,9 +847,7 @@ func HirLower_LowerModule(mod: *Module, sema: *Sema) -> *HirModule {
} }
} }
if decl.kind == dkExternFunc { if decl.kind == dkExternFunc {
Print("[DEBUG hir_lower] lowering extern func "); Print(decl.strValue); PrintLine("");
let f: *HirFunc = Lcx_LowerFunc(ctx, decl); let f: *HirFunc = Lcx_LowerFunc(ctx, decl);
Print("[DEBUG hir_lower] extern func lowered ok"); PrintLine("");
ctx.externFuncs[ctx.externCount] = *f; ctx.externFuncs[ctx.externCount] = *f;
ctx.externCount = ctx.externCount + 1; ctx.externCount = ctx.externCount + 1;
} }
@@ -861,7 +857,6 @@ func HirLower_LowerModule(mod: *Module, sema: *Sema) -> *HirModule {
hm.structs[si].name = decl.strValue; hm.structs[si].name = decl.strValue;
hm.structs[si].fieldCount = decl.fieldCount; hm.structs[si].fieldCount = decl.fieldCount;
hm.structs[si].fields = bux_alloc(decl.fieldCount as uint * sizeof(HirStructField)) as *HirStructField; hm.structs[si].fields = bux_alloc(decl.fieldCount as uint * sizeof(HirStructField)) as *HirStructField;
Print("[DEBUG hir struct] name="); Print(decl.strValue); Print(" fieldCount="); PrintInt(decl.fieldCount as int64); PrintLine("");
var fi: int = 0; var fi: int = 0;
while fi < decl.fieldCount { while fi < decl.fieldCount {
var fname: String = ""; var fname: String = "";
-5
View File
@@ -323,11 +323,6 @@ func lexScanIdent(lex: *Lexer) {
lex.tokens[lex.tokenCount] = tok; lex.tokens[lex.tokenCount] = tok;
lex.tokenCount = lex.tokenCount + 1; lex.tokenCount = lex.tokenCount + 1;
} }
if String_StartsWith(tok.text, "field") {
PrintLine(String_Concat("DEBUG lexer ident=", tok.text));
PrintLine(String_Concat("DEBUG lexer addr=", bux_int_to_str(tok.text as int64)));
PrintLine(String_Concat("DEBUG lexer pos=", bux_int_to_str(lex.tokenCount as int64)));
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
-6
View File
@@ -1172,11 +1172,6 @@ func parserParseFuncDecl(p: *Parser, isPublic: bool, isExtern: bool, isAsync: bo
// Body // Body
if !isExtern && parserCheck(p, tkLBrace) { if !isExtern && parserCheck(p, tkLBrace) {
d.refBody = parserParseBlock(p); d.refBody = parserParseBlock(p);
// HACK: if parserParseBlock left a stray } at current position,
// consume it. Without this, the module handler exits early.
if parserCheck(p, tkRBrace) {
discard parserAdvance(p);
}
} else { } else {
d.refBody = null as *Block; d.refBody = null as *Block;
} }
@@ -1242,7 +1237,6 @@ func parserParseStructDecl(p: *Parser, isPublic: bool) -> *Decl {
fieldCount = fieldCount + 1; fieldCount = fieldCount + 1;
} }
d.fieldCount = fieldCount; d.fieldCount = fieldCount;
PrintLine(String_Concat("DEBUG parser endStruct fieldCount=", bux_int_to_str(fieldCount as int64)));
discard parserExpect(p, tkRBrace, "expected '}'"); discard parserExpect(p, tkRBrace, "expected '}'");
return d; return d;
} }