closures with captures: env struct + global instance + body rewriting
- AST: captureCount + captureName0..7 + captureType0..7 in Expr - Sema: Scope_LookupUpTo + closureScope for capture analysis - HIR Lower: env struct generation, capture assignments in skLet, body rewriting (ekIdent -> hFieldAccess on env instance) - C Backend: env struct def + global instance emission for closures - Bootstrap: full capture support in sema, hir_lower, lir_lower, lir_c_backend - Selfhost loop remains deterministic
This commit is contained in:
+23
-2
@@ -18,8 +18,9 @@ const hAlloca: int = 12;
|
||||
const hLoad: int = 13;
|
||||
const hStore: int = 14;
|
||||
const hFieldPtr: int = 15;
|
||||
const hArrowField: int = 16;
|
||||
const hIndexPtr: int = 17;
|
||||
const hFieldAccess: int = 16;
|
||||
const hArrowField: int = 17;
|
||||
const hIndexPtr: int = 18;
|
||||
const hCall: int = 18;
|
||||
const hCallIndirect: int = 19;
|
||||
const hCast: int = 20;
|
||||
@@ -93,6 +94,26 @@ struct HirFunc {
|
||||
retTypeName: String;
|
||||
body: *HirNode;
|
||||
isPublic: bool;
|
||||
// Closure capture metadata
|
||||
captureCount: int;
|
||||
captureName0: String;
|
||||
captureName1: String;
|
||||
captureName2: String;
|
||||
captureName3: String;
|
||||
captureName4: String;
|
||||
captureName5: String;
|
||||
captureName6: String;
|
||||
captureName7: String;
|
||||
captureType0: int;
|
||||
captureType1: int;
|
||||
captureType2: int;
|
||||
captureType3: int;
|
||||
captureType4: int;
|
||||
captureType5: int;
|
||||
captureType6: int;
|
||||
captureType7: int;
|
||||
envStructName: String;
|
||||
envInstanceName: String;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user