feat(selfhost): generic monomorphization + collection-based for-in loops
- Add on-demand generic function/struct monomorphization in HIR lower
- Lcx_SubstituteType: substitute type params and mangle names (e.g. Array<int> -> Array_int)
- Lcx_GenerateFuncInstance: clone generic func with active substitution
- Lcx_GenerateStructInstance: create concrete struct definitions
- Detect generic calls (ekCall) and struct inits (ekStructInit)
- Parser: propagate generic type args from ident to ekStructInit node
- Fix duplicate HIR constant: hIndexPtr and hCall both had value 18,
causing index expressions to emit as comma expressions in C backend
- Implement collection-based for-in desugaring:
for x in arr { body } -> __iter = Array_Iter_T(&arr);
while Iter_HasNext_T(&__iter) { x = Iter_Next_T(&__iter); body }
Selfhost loop remains deterministic. All golden tests and examples pass.
This commit is contained in:
@@ -678,6 +678,10 @@ func parserParsePostfixExpr(p: *Parser) -> *Expr {
|
||||
e.structName = typeName;
|
||||
e.structFieldCount = fieldCount;
|
||||
e.child1 = firstField;
|
||||
// Propagate generic type args from the identifier
|
||||
e.genericTypeArg0 = left.genericTypeArg0;
|
||||
e.genericTypeArg1 = left.genericTypeArg1;
|
||||
e.genericTypeArgCount = left.genericTypeArgCount;
|
||||
left = e;
|
||||
continue;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user