fix(selfhost): resolve all sema errors — 0 undeclared identifiers
- Add forward declarations for mutually-recursive parser functions (parserParseExpr, parserParseStmt, parserParseBlock, parserParsePrimary, parserParsePostfixExpr, parserParseBinaryPrec) - Fix HIR lowering: skip forward decls (refBody==null) to avoid duplicate function entries and array overflow - Bump funcs/externFuncs array size 256→512 to handle large modules - Update PLAN.md with progress Sema: 0 errors (was 7, then 2, now 0) Remaining: C backend struct ordering (pre-existing, Iter/StringBuilder)
This commit is contained in:
+4
-4
@@ -601,9 +601,9 @@ func HirLower_LowerModule(mod: *Module, sema: *Sema) -> *HirModule {
|
||||
let ctx: *LowerCtx = bux_alloc(sizeof(LowerCtx)) as *LowerCtx;
|
||||
ctx.module = mod;
|
||||
ctx.scope = sema.scope;
|
||||
ctx.funcs = bux_alloc(256 as uint * sizeof(HirFunc)) as *HirFunc;
|
||||
ctx.funcs = bux_alloc(512 as uint * sizeof(HirFunc)) as *HirFunc;
|
||||
ctx.funcCount = 0;
|
||||
ctx.externFuncs = bux_alloc(256 as uint * sizeof(HirFunc)) as *HirFunc;
|
||||
ctx.externFuncs = bux_alloc(512 as uint * sizeof(HirFunc)) as *HirFunc;
|
||||
ctx.externCount = 0;
|
||||
ctx.varCounter = 0;
|
||||
|
||||
@@ -624,7 +624,7 @@ func HirLower_LowerModule(mod: *Module, sema: *Sema) -> *HirModule {
|
||||
// Iterate declarations
|
||||
var decl: *Decl = mod.firstItem;
|
||||
while decl != null as *Decl {
|
||||
if decl.kind == dkFunc {
|
||||
if decl.kind == dkFunc && decl.refBody != null as *Block {
|
||||
let f: *HirFunc = Lcx_LowerFunc(ctx, decl);
|
||||
ctx.funcs[ctx.funcCount] = *f;
|
||||
ctx.funcCount = ctx.funcCount + 1;
|
||||
@@ -633,7 +633,7 @@ func HirLower_LowerModule(mod: *Module, sema: *Sema) -> *HirModule {
|
||||
let implTypeName: String = decl.strValue;
|
||||
var implDecl: *Decl = decl.childDecl1;
|
||||
while implDecl != null as *Decl {
|
||||
if implDecl.kind == dkFunc {
|
||||
if implDecl.kind == dkFunc && implDecl.refBody != null as *Block {
|
||||
let mangled: String = String_Concat(implTypeName, "_");
|
||||
implDecl.strValue = String_Concat(mangled, implDecl.strValue);
|
||||
let f: *HirFunc = Lcx_LowerFunc(ctx, implDecl);
|
||||
|
||||
+10
-2
@@ -4,6 +4,14 @@ module Parser {
|
||||
|
||||
extern func bux_strlen(s: String) -> uint;
|
||||
|
||||
// Forward declarations for mutual recursion
|
||||
func parserParseExpr(p: *Parser) -> *Expr;
|
||||
func parserParseStmt(p: *Parser) -> *Stmt;
|
||||
func parserParseBlock(p: *Parser) -> *Block;
|
||||
func parserParsePrimary(p: *Parser) -> *Expr;
|
||||
func parserParsePostfixExpr(p: *Parser) -> *Expr;
|
||||
func parserParseBinaryPrec(p: *Parser, minPrec: int) -> *Expr;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parser state
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -326,7 +334,7 @@ func parserParsePrimary(p: *Parser) -> *Expr {
|
||||
// Postfix: call, index, field access, as, is, ?
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func parserParsePostfix(p: *Parser) -> *Expr {
|
||||
func parserParsePostfixExpr(p: *Parser) -> *Expr {
|
||||
var left: *Expr = parserParsePrimary(p);
|
||||
|
||||
while true {
|
||||
@@ -566,7 +574,7 @@ func parserPrecedence(op: int) -> int {
|
||||
}
|
||||
|
||||
func parserParseBinaryPrec(p: *Parser, minPrec: int) -> *Expr {
|
||||
var left: *Expr = parserParsePostfix(p);
|
||||
var left: *Expr = parserParsePostfixExpr(p);
|
||||
while true {
|
||||
let op: int = parserPeek(p, 0);
|
||||
let prec: int = parserPrecedence(op);
|
||||
|
||||
Reference in New Issue
Block a user