Phase 7.10: buxc2 now compiles multi-statement Bux programs
Parser (src_bux/parser.bux): - Block stores statements as linked list (firstStmt/lastStmt/nextStmt) - Block struct: added firstStmt, lastStmt fields - Stmt struct: added nextStmt field HIR Lowering (src_bux/hir_lower.bux): - Lcx_LowerBlock: iterates statement linked list, chains HirNodes via child3 - hIf: else block stored in extraData (child3 reserved for block chaining) C Backend (src_bux/c_backend.bux): - hBlock: emits statements via child3 linked list with proper indentation - hStore: combines alloca + value into single declaration (int x = value;) - hIf: full if/else emission with proper newlines - Function decl: proper return types and parameter types (not just "int") - int main() wrapper: generated when Main function exists - No duplicate return 0 when body already has return Tested: - buxc2 compiles hello world program → runs correctly - buxc2 compiles multi-statement program (let, if, function calls) → runs correctly - All 18 examples still pass, all unit tests pass
This commit is contained in:
@@ -127,6 +127,8 @@ struct Block {
|
||||
line: uint32,
|
||||
column: uint32,
|
||||
stmtCount: int,
|
||||
firstStmt: *Stmt,
|
||||
lastStmt: *Stmt,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -170,6 +172,8 @@ struct Stmt {
|
||||
refStmtElse: *Block, // else block
|
||||
// Else-if chain
|
||||
elseIfCount: int,
|
||||
// Linked list
|
||||
nextStmt: *Stmt,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user