From 64bd41067ac997857cbf4ff3da0d287c753d0bda Mon Sep 17 00:00:00 2001 From: dimgigov Date: Tue, 9 Jun 2026 15:48:38 +0300 Subject: [PATCH] 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 --- src/c_backend.bux | 27 --------------------------- src/hir_lower.bux | 5 ----- src/lexer.bux | 5 ----- src/parser.bux | 6 ------ 4 files changed, 43 deletions(-) diff --git a/src/c_backend.bux b/src/c_backend.bux index e41370d..0d2f059 100644 --- a/src/c_backend.bux +++ b/src/c_backend.bux @@ -748,9 +748,6 @@ func CBE_StructHasValueStructField(st: *HirStruct) -> bool { var fi: int = 0; while fi < st.fieldCount { 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, "*") { return true; } @@ -760,16 +757,11 @@ func CBE_StructHasValueStructField(st: *HirStruct) -> bool { } 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, st.name); StringBuilder_Append(&cbe.sb, " {\n"); var fi: int = 0; - Print("[DEBUG c emit] "); Print(st.name); Print(" fieldCount="); PrintInt(st.fieldCount as int64); PrintLine(""); 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, " "); var ft: String = st.fields[fi].typeName; 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 { - Print("[DEBUG CBackend_Generate] structCount="); PrintInt(mod.structCount as int64); PrintLine(""); let cbe: *CEmitter = bux_alloc(sizeof(CEmitter)) as *CEmitter; cbe.sb = StringBuilder_NewCap(8192); cbe.indent = 0; @@ -870,7 +861,6 @@ func CBackend_Generate(mod: *HirModule) -> String { // Forward declare all struct types (skip generics) var si: int = 0; 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]) { StringBuilder_Append(&cbe.sb, "typedef struct "); 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, ";\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; } StringBuilder_Append(&cbe.sb, "\n"); @@ -1000,15 +987,9 @@ func CBackend_Generate(mod: *HirModule) -> String { continue; } 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; continue; } - if String_Eq(mod.structs[si].name, "Decl") { - Print("[DEBUG c pass1] Decl emitting\n"); - } CBE_EmitStructDef(cbe, &mod.structs[si]); si = si + 1; } @@ -1020,17 +1001,9 @@ func CBackend_Generate(mod: *HirModule) -> String { continue; } 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; 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]); si = si + 1; } diff --git a/src/hir_lower.bux b/src/hir_lower.bux index 722f950..f16e2c5 100644 --- a/src/hir_lower.bux +++ b/src/hir_lower.bux @@ -712,7 +712,6 @@ func Lcx_LowerParam(out: *HirParam, p: *Param) { // --------------------------------------------------------------------------- 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; f.name = decl.strValue; f.isPublic = decl.isPublic; @@ -828,7 +827,6 @@ func HirLower_LowerModule(mod: *Module, sema: *Sema) -> *HirModule { // Iterate declarations var decl: *Decl = mod.firstItem; 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 { let f: *HirFunc = Lcx_LowerFunc(ctx, decl); ctx.funcs[ctx.funcCount] = *f; @@ -849,9 +847,7 @@ func HirLower_LowerModule(mod: *Module, sema: *Sema) -> *HirModule { } } if decl.kind == dkExternFunc { - Print("[DEBUG hir_lower] lowering extern func "); Print(decl.strValue); PrintLine(""); let f: *HirFunc = Lcx_LowerFunc(ctx, decl); - Print("[DEBUG hir_lower] extern func lowered ok"); PrintLine(""); ctx.externFuncs[ctx.externCount] = *f; 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].fieldCount = decl.fieldCount; 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; while fi < decl.fieldCount { var fname: String = ""; diff --git a/src/lexer.bux b/src/lexer.bux index ae3e801..74951d8 100644 --- a/src/lexer.bux +++ b/src/lexer.bux @@ -323,11 +323,6 @@ func lexScanIdent(lex: *Lexer) { lex.tokens[lex.tokenCount] = tok; 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))); - } } // --------------------------------------------------------------------------- diff --git a/src/parser.bux b/src/parser.bux index 6ea8d54..be416bc 100644 --- a/src/parser.bux +++ b/src/parser.bux @@ -1172,11 +1172,6 @@ func parserParseFuncDecl(p: *Parser, isPublic: bool, isExtern: bool, isAsync: bo // Body if !isExtern && parserCheck(p, tkLBrace) { 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 { d.refBody = null as *Block; } @@ -1242,7 +1237,6 @@ func parserParseStructDecl(p: *Parser, isPublic: bool) -> *Decl { fieldCount = fieldCount + 1; } d.fieldCount = fieldCount; - PrintLine(String_Concat("DEBUG parser endStruct fieldCount=", bux_int_to_str(fieldCount as int64))); discard parserExpect(p, tkRBrace, "expected '}'"); return d; }