rephrase type irgen hook -> irext, to eliminate cases where it'd be very easy to accidentally cause infinite recursion of ir generation (e.g. slice(x) requiring evaluation of 'lhs.count', where lhs == slice(x)). also bring back slice hooks

This commit is contained in:
Ryan Fleury
2025-04-10 15:19:29 -07:00
parent 4a69b8e57a
commit 0dd0f1b8bc
10 changed files with 297 additions and 68 deletions
+11 -5
View File
@@ -352,6 +352,12 @@ struct E_EnumValArray
U64 count;
};
typedef struct E_IRExt E_IRExt;
struct E_IRExt
{
void *user_data;
};
typedef struct E_TypeExpandInfo E_TypeExpandInfo;
struct E_TypeExpandInfo
{
@@ -359,10 +365,10 @@ struct E_TypeExpandInfo
U64 expr_count;
};
#define E_TYPE_IRGEN_FUNCTION_SIG(name) E_IRTreeAndType name(Arena *arena, E_IRTreeAndType *irtree)
#define E_TYPE_IRGEN_FUNCTION_NAME(name) e_type_irgen__##name
#define E_TYPE_IRGEN_FUNCTION_DEF(name) internal E_TYPE_IRGEN_FUNCTION_SIG(E_TYPE_IRGEN_FUNCTION_NAME(name))
typedef E_TYPE_IRGEN_FUNCTION_SIG(E_TypeIRGenFunctionType);
#define E_TYPE_IREXT_FUNCTION_SIG(name) E_IRExt name(Arena *arena, E_Expr *expr, E_IRTreeAndType *irtree)
#define E_TYPE_IREXT_FUNCTION_NAME(name) e_type_irext__##name
#define E_TYPE_IREXT_FUNCTION_DEF(name) internal E_TYPE_IREXT_FUNCTION_SIG(E_TYPE_IREXT_FUNCTION_NAME(name))
typedef E_TYPE_IREXT_FUNCTION_SIG(E_TypeIRExtFunctionType);
#define E_TYPE_ACCESS_FUNCTION_SIG(name) E_IRTreeAndType name(Arena *arena, E_Expr *expr, E_IRTreeAndType *lhs_irtree)
#define E_TYPE_ACCESS_FUNCTION_NAME(name) e_type_access__##name
@@ -415,7 +421,7 @@ struct E_Type
E_Member *members;
E_EnumVal *enum_vals;
E_Expr **args;
E_TypeIRGenFunctionType *irgen;
E_TypeIRExtFunctionType *irext;
E_TypeAccessFunctionType *access;
E_TypeExpandRule expand;
};