Implements full generic interface support through the compiler pipeline: Parser: TGenericInterfaceDef AST node; IDENT<TypeParams> = interface...end syntax; ParseGenericName helper for class(IFoo<T>) parent/implements lists. AST: TGenericInterfaceDef (ParamNames + IntfDef) and TGenericInterfaceInstance (mangled InstName + TypeDesc) tracked on TProgram.GenericIntfInstances. Symbol table: TInterfaceTypeDesc extended with FReturnTypes parallel list so interface dispatch expressions can resolve return types. Semantic: InstantiateGenericInterface instantiates IFoo<T> on demand from a template; FindTypeOrInstantiate falls through class→interface; parent-as-interface detection moves IFoo<Integer> from ParentName to ImplementsNames; type-safe guard in InstantiateGeneric prevents misidentifying interface templates as class templates; AnalyseMethodCallExpr extended with interface dispatch path. Codegen: EmitInterfaceDefs emits typeinfo for GenericIntfInstances using the mangled name (IEqualityComparer_Integer); itab/impllist names QBEMangle interface names; EmitExpr TMethodCallExpr handles interface dispatch via itab pointer. 13 new tests in cp.test.genericintfs covering parser, semantic, and codegen. |
||
|---|---|---|
| .. | ||
| design.adoc | ||
| grammar.ebnf | ||