feat(selfhost): function types (func(Params) -> Ret)

- Add tekFunc AST node and TypeExprList linked list for params
- Parse func(T, U) -> R syntax in parser.bux
- Resolve tekFunc to tyFunc in sema.bux
- Track original TypeExpr via Symbol.refType for params/lets/consts/funcs
- Build C function-pointer type names in hir_lower.bux (Ret (*)(Params))
- Lower indirect calls through function-typed values as hCallIndirect
- Add CBE_CParamDecl helper in c_backend.bux to embed name inside (*)
- Emit hCallIndirect and function-pointer variable declarations
- _test_funcptr now builds and runs with selfhost buxc2
This commit is contained in:
2026-06-08 23:39:15 +03:00
parent 2e536488e6
commit 0c41c7bb25
7 changed files with 305 additions and 78 deletions
+14 -5
View File
@@ -28,19 +28,28 @@ const tekSlice: int = 2;
const tekPointer: int = 3;
const tekTuple: int = 4;
const tekSelf: int = 5;
const tekFunc: int = 6;
struct TypeExprList {
te: *TypeExpr,
next: *TypeExprList,
}
struct TypeExpr {
kind: int,
line: uint32,
column: uint32,
typeName: String, // for tekNamed
pathStr: String, // for tekPath (segments joined with ::)
pathCount: int, // number of path segments
typeArgName0: String, // up to 2 type args
typeName: String, // for tekNamed / diagnostic name for tekFunc
pathStr: String, // for tekPath (segments joined with ::)
pathCount: int, // number of path segments
typeArgName0: String, // up to 2 type args
typeArgName1: String,
typeArgCount: int,
sliceElement: *TypeExpr, // for tekSlice
sliceElement: *TypeExpr, // for tekSlice
pointerPointee: *TypeExpr, // for tekPointer
funcParams: *TypeExprList, // for tekFunc
funcRet: *TypeExpr, // for tekFunc
funcParamCount: int, // for tekFunc
}
// ---------------------------------------------------------------------------