reduce ESpecifier to c-compatiable enum

This commit is contained in:
Edward R. Gonzalez 2024-12-03 13:14:14 -05:00
parent d45908fb32
commit c6fba23173
15 changed files with 375 additions and 379 deletions

View File

@ -273,7 +273,7 @@ char const* debug_str(Code self)
s32 left = self->NumEntries; s32 left = self->NumEntries;
while ( left-- ) while ( left-- )
{ {
StrC spec = ESpecifier::to_str( self->ArrSpecs[idx] ); StrC spec = to_str( self->ArrSpecs[idx] );
append_fmt( result, "%.*s, ", spec.Len, spec.Ptr ); append_fmt( result, "%.*s, ", spec.Len, spec.Ptr );
idx++; idx++;
} }

View File

@ -337,7 +337,7 @@ struct AST
}; };
StringCached Content; // Attributes, Comment, Execution, Include StringCached Content; // Attributes, Comment, Execution, Include
struct { struct {
SpecifierT ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers Specifier ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers
Code NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used. Code NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
}; };
}; };

View File

@ -12,7 +12,7 @@
struct AST_Body struct AST_Body
{ {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
Code Front; Code Front;
Code Back; Code Back;
parser::Token* Tok; parser::Token* Tok;
@ -27,7 +27,7 @@ static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same
struct AST_Attributes struct AST_Attributes
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -44,7 +44,7 @@ static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is
struct AST_BaseClass struct AST_BaseClass
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
Code Prev; Code Prev;
Code Next; Code Next;
@ -60,7 +60,7 @@ static_assert( sizeof(AST_BaseClass) == sizeof(AST), "ERROR: AST_BaseClass is no
struct AST_Comment struct AST_Comment
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -76,7 +76,7 @@ static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not th
struct AST_Class struct AST_Class
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; // Only supported by forward declarations CodeComment InlineCmt; // Only supported by forward declarations
@ -102,7 +102,7 @@ static_assert( sizeof(AST_Class) == sizeof(AST), "ERROR: AST_Class is not the sa
struct AST_Constructor struct AST_Constructor
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; // Only supported by forward declarations CodeComment InlineCmt; // Only supported by forward declarations
@ -127,7 +127,7 @@ static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor i
struct AST_Define struct AST_Define
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -143,7 +143,7 @@ static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the
struct AST_Destructor struct AST_Destructor
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -167,7 +167,7 @@ static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is
struct AST_Enum struct AST_Enum
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -193,7 +193,7 @@ static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same
struct AST_Exec struct AST_Exec
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -210,7 +210,7 @@ static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same
struct AST_Expr struct AST_Expr
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -225,7 +225,7 @@ static_assert( sizeof(AST_Expr) == sizeof(AST), "ERROR: AST_Expr is not the same
struct AST_Expr_Assign struct AST_Expr_Assign
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -240,7 +240,7 @@ static_assert( sizeof(AST_Expr_Assign) == sizeof(AST), "ERROR: AST_Expr_Assign i
struct AST_Expr_Alignof struct AST_Expr_Alignof
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -255,7 +255,7 @@ static_assert( sizeof(AST_Expr_Alignof) == sizeof(AST), "ERROR: AST_Expr_Alignof
struct AST_Expr_Binary struct AST_Expr_Binary
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -270,7 +270,7 @@ static_assert( sizeof(AST_Expr_Binary) == sizeof(AST), "ERROR: AST_Expr_Binary i
struct AST_Expr_CStyleCast struct AST_Expr_CStyleCast
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -285,7 +285,7 @@ static_assert( sizeof(AST_Expr_CStyleCast) == sizeof(AST), "ERROR: AST_Expr_CSty
struct AST_Expr_FunctionalCast struct AST_Expr_FunctionalCast
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -300,7 +300,7 @@ static_assert( sizeof(AST_Expr_FunctionalCast) == sizeof(AST), "ERROR: AST_Expr_
struct AST_Expr_CppCast struct AST_Expr_CppCast
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -315,7 +315,7 @@ static_assert( sizeof(AST_Expr_CppCast) == sizeof(AST), "ERROR: AST_Expr_CppCast
struct AST_Expr_ProcCall struct AST_Expr_ProcCall
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -330,7 +330,7 @@ static_assert( sizeof(AST_Expr_ProcCall) == sizeof(AST), "ERROR: AST_Expr_Identi
struct AST_Expr_Decltype struct AST_Expr_Decltype
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -345,7 +345,7 @@ static_assert( sizeof(AST_Expr_Decltype) == sizeof(AST), "ERROR: AST_Expr_Declty
struct AST_Expr_Comma struct AST_Expr_Comma
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -360,7 +360,7 @@ static_assert( sizeof(AST_Expr_Comma) == sizeof(AST), "ERROR: AST_Expr_Comma is
struct AST_Expr_AMS struct AST_Expr_AMS
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -375,7 +375,7 @@ static_assert( sizeof(AST_Expr_AMS) == sizeof(AST), "ERROR: AST_Expr_AMS is not
struct AST_Expr_Sizeof struct AST_Expr_Sizeof
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -390,7 +390,7 @@ static_assert( sizeof(AST_Expr_Sizeof) == sizeof(AST), "ERROR: AST_Expr_Sizeof i
struct AST_Expr_Subscript struct AST_Expr_Subscript
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -405,7 +405,7 @@ static_assert( sizeof(AST_Expr_Subscript) == sizeof(AST), "ERROR: AST_Expr_Subsc
struct AST_Expr_Ternary struct AST_Expr_Ternary
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -420,7 +420,7 @@ static_assert( sizeof(AST_Expr_Ternary) == sizeof(AST), "ERROR: AST_Expr_Ternary
struct AST_Expr_UnaryPrefix struct AST_Expr_UnaryPrefix
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -435,7 +435,7 @@ static_assert( sizeof(AST_Expr_UnaryPrefix) == sizeof(AST), "ERROR: AST_Expr_Una
struct AST_Expr_UnaryPostfix struct AST_Expr_UnaryPostfix
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -450,7 +450,7 @@ static_assert( sizeof(AST_Expr_UnaryPostfix) == sizeof(AST), "ERROR: AST_Expr_Un
struct AST_Expr_Element struct AST_Expr_Element
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -466,7 +466,7 @@ static_assert( sizeof(AST_Expr_Element) == sizeof(AST), "ERROR: AST_Expr_Element
struct AST_Extern struct AST_Extern
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
@ -487,7 +487,7 @@ static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the
struct AST_Include struct AST_Include
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -503,7 +503,7 @@ static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not th
struct AST_Friend struct AST_Friend
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -525,7 +525,7 @@ static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the
struct AST_Fn struct AST_Fn
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -550,7 +550,7 @@ static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same siz
struct AST_Module struct AST_Module
{ {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
Code Prev; Code Prev;
Code Next; Code Next;
parser::Token* Tok; parser::Token* Tok;
@ -565,7 +565,7 @@ static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the
struct AST_NS struct AST_NS
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct { struct {
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
CodeBody Body; CodeBody Body;
@ -586,7 +586,7 @@ static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same siz
struct AST_Operator struct AST_Operator
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -612,7 +612,7 @@ static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not
struct AST_OpCast struct AST_OpCast
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -637,7 +637,7 @@ static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the
struct AST_Param struct AST_Param
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
@ -662,7 +662,7 @@ static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the sa
struct AST_Pragma struct AST_Pragma
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -678,7 +678,7 @@ static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the
struct AST_PreprocessCond struct AST_PreprocessCond
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -693,7 +693,7 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess
struct AST_Specifiers struct AST_Specifiers
{ {
SpecifierT ArrSpecs[ AST_ArrSpecs_Cap ]; Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
CodeSpecifiers NextSpecs; CodeSpecifiers NextSpecs;
Code Prev; Code Prev;
Code Next; Code Next;
@ -710,7 +710,7 @@ static_assert( sizeof(AST_Specifiers) == sizeof(AST), "ERROR: AST_Specifier is n
struct AST_Stmt struct AST_Stmt
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -725,7 +725,7 @@ static_assert( sizeof(AST_Stmt) == sizeof(AST), "ERROR: AST_Stmt is not the same
struct AST_Stmt_Break struct AST_Stmt_Break
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -740,7 +740,7 @@ static_assert( sizeof(AST_Stmt_Break) == sizeof(AST), "ERROR: AST_Stmt_Break is
struct AST_Stmt_Case struct AST_Stmt_Case
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -755,7 +755,7 @@ static_assert( sizeof(AST_Stmt_Case) == sizeof(AST), "ERROR: AST_Stmt_Case is no
struct AST_Stmt_Continue struct AST_Stmt_Continue
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -770,7 +770,7 @@ static_assert( sizeof(AST_Stmt_Continue) == sizeof(AST), "ERROR: AST_Stmt_Contin
struct AST_Stmt_Decl struct AST_Stmt_Decl
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -785,7 +785,7 @@ static_assert( sizeof(AST_Stmt_Decl) == sizeof(AST), "ERROR: AST_Stmt_Decl is no
struct AST_Stmt_Do struct AST_Stmt_Do
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -800,7 +800,7 @@ static_assert( sizeof(AST_Stmt_Do) == sizeof(AST), "ERROR: AST_Stmt_Do is not th
struct AST_Stmt_Expr struct AST_Stmt_Expr
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -815,7 +815,7 @@ static_assert( sizeof(AST_Stmt_Expr) == sizeof(AST), "ERROR: AST_Stmt_Expr is no
struct AST_Stmt_Else struct AST_Stmt_Else
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -830,7 +830,7 @@ static_assert( sizeof(AST_Stmt_Else) == sizeof(AST), "ERROR: AST_Stmt_Else is no
struct AST_Stmt_If struct AST_Stmt_If
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -845,7 +845,7 @@ static_assert( sizeof(AST_Stmt_If) == sizeof(AST), "ERROR: AST_Stmt_If is not th
struct AST_Stmt_For struct AST_Stmt_For
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -860,7 +860,7 @@ static_assert( sizeof(AST_Stmt_For) == sizeof(AST), "ERROR: AST_Stmt_For is not
struct AST_Stmt_Goto struct AST_Stmt_Goto
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -875,7 +875,7 @@ static_assert( sizeof(AST_Stmt_Goto) == sizeof(AST), "ERROR: AST_Stmt_Goto is no
struct AST_Stmt_Label struct AST_Stmt_Label
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -890,7 +890,7 @@ static_assert( sizeof(AST_Stmt_Label) == sizeof(AST), "ERROR: AST_Stmt_Label is
struct AST_Stmt_Switch struct AST_Stmt_Switch
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -905,7 +905,7 @@ static_assert( sizeof(AST_Stmt_Switch) == sizeof(AST), "ERROR: AST_Stmt_Switch i
struct AST_Stmt_While struct AST_Stmt_While
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
@ -921,7 +921,7 @@ static_assert( sizeof(AST_Stmt_While) == sizeof(AST), "ERROR: AST_Stmt_While is
struct AST_Struct struct AST_Struct
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -947,7 +947,7 @@ static_assert( sizeof(AST_Struct) == sizeof(AST), "ERROR: AST_Struct is not the
struct AST_Template struct AST_Template
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
@ -972,7 +972,7 @@ static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not
struct AST_Type struct AST_Type
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_INLINE_CMT_[ sizeof(AST*) ]; char _PAD_INLINE_CMT_[ sizeof(AST*) ];
@ -1000,7 +1000,7 @@ static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same
struct AST_Type struct AST_Type
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_INLINE_CMT_[ sizeof(AST*) ]; char _PAD_INLINE_CMT_[ sizeof(AST*) ];
@ -1026,7 +1026,7 @@ static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same
struct AST_Typedef struct AST_Typedef
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -1049,7 +1049,7 @@ static_assert( sizeof(AST_Typedef) == sizeof(AST), "ERROR: AST_Typedef is not th
struct AST_Union struct AST_Union
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_INLINE_CMT_[ sizeof(AST*) ]; char _PAD_INLINE_CMT_[ sizeof(AST*) ];
@ -1073,7 +1073,7 @@ static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the sa
struct AST_Using struct AST_Using
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -1097,7 +1097,7 @@ static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the sa
struct AST_Var struct AST_Var
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;

View File

@ -256,7 +256,7 @@ void to_string_def(CodeDestructor self, String* result )
} }
else if ( self->Specs ) else if ( self->Specs )
{ {
if ( has(self->Specs, ESpecifier::Virtual ) ) if ( has(self->Specs, Spec_Virtual ) )
append_fmt( result, "virtual ~%S()", self->Parent->Name ); append_fmt( result, "virtual ~%S()", self->Parent->Name );
else else
append_fmt( result, "~%S()", self->Parent->Name ); append_fmt( result, "~%S()", self->Parent->Name );
@ -271,12 +271,12 @@ void to_string_fwd(CodeDestructor self, String* result )
{ {
if ( self->Specs ) if ( self->Specs )
{ {
if ( has(self->Specs, ESpecifier::Virtual ) ) if ( has(self->Specs, Spec_Virtual ) )
append_fmt( result, "virtual ~%S();\n", self->Parent->Name ); append_fmt( result, "virtual ~%S();\n", self->Parent->Name );
else else
append_fmt( result, "~%S()", self->Parent->Name ); append_fmt( result, "~%S()", self->Parent->Name );
if ( has(self->Specs, ESpecifier::Pure ) ) if ( has(self->Specs, Spec_Pure ) )
append( result, " = 0;" ); append( result, " = 0;" );
else if (self->Body) else if (self->Body)
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) ); append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
@ -492,11 +492,11 @@ void to_string_def(CodeFn self, String* result )
bool prefix_specs = false; bool prefix_specs = false;
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ! ESpecifier::is_trailing( spec ) ) if ( ! is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
prefix_specs = true; prefix_specs = true;
@ -521,11 +521,11 @@ void to_string_def(CodeFn self, String* result )
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ESpecifier::is_trailing( spec ) ) if ( is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
} }
} }
@ -545,11 +545,11 @@ void to_string_fwd(CodeFn self, String* result )
b32 prefix_specs = false; b32 prefix_specs = false;
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ! ESpecifier::is_trailing( spec ) || ! (spec != ESpecifier::Pure) ) if ( ! is_trailing( spec ) || ! (spec != Spec_Pure) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
prefix_specs = true; prefix_specs = true;
@ -576,17 +576,17 @@ void to_string_fwd(CodeFn self, String* result )
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ESpecifier::is_trailing( spec ) ) if ( is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
} }
} }
} }
if ( self->Specs && has(self->Specs, ESpecifier::Pure ) >= 0 ) if ( self->Specs && has(self->Specs, Spec_Pure ) >= 0 )
append( result, " = 0;" ); append( result, " = 0;" );
else if (self->Body) else if (self->Body)
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) ); append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
@ -661,11 +661,11 @@ void to_string_def(CodeOperator self, String* result )
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ! ESpecifier::is_trailing( spec ) ) if ( ! is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
} }
} }
@ -687,11 +687,11 @@ void to_string_def(CodeOperator self, String* result )
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ESpecifier::is_trailing( spec ) ) if ( is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
} }
} }
@ -712,11 +712,11 @@ void to_string_fwd(CodeOperator self, String* result )
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ! ESpecifier::is_trailing( spec ) ) if ( ! is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
} }
} }
@ -737,11 +737,11 @@ void to_string_fwd(CodeOperator self, String* result )
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ESpecifier::is_trailing( spec ) ) if ( is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
} }
} }
@ -773,11 +773,11 @@ void to_string_def(CodeOpCast self, String* result )
{ {
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ! ESpecifier::is_trailing( spec ) ) if ( ! is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr ); append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr );
} }
} }
@ -787,11 +787,11 @@ void to_string_def(CodeOpCast self, String* result )
else else
append_fmt( result, "operator %S()", to_string(self->ValueType) ); append_fmt( result, "operator %S()", to_string(self->ValueType) );
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ESpecifier::is_trailing( spec ) ) if ( is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
} }
} }
@ -810,22 +810,22 @@ void to_string_fwd(CodeOpCast self, String* result )
{ {
if ( self->Specs ) if ( self->Specs )
{ {
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ! ESpecifier::is_trailing( spec ) ) if ( ! is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr ); append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr );
} }
} }
append_fmt( result, "operator %S()", to_string(self->ValueType) ); append_fmt( result, "operator %S()", to_string(self->ValueType) );
for ( SpecifierT spec : self->Specs ) for ( Specifier spec : self->Specs )
{ {
if ( ESpecifier::is_trailing( spec ) ) if ( is_trailing( spec ) )
{ {
StrC spec_str = ESpecifier::to_str( spec ); StrC spec_str = to_str( spec );
append_fmt( result, " %*s", spec_str.Len, spec_str.Ptr ); append_fmt( result, " %*s", spec_str.Len, spec_str.Ptr );
} }
} }
@ -973,7 +973,7 @@ void to_string( CodeSpecifiers self, String* result )
s32 left = self->NumEntries; s32 left = self->NumEntries;
while ( left-- ) while ( left-- )
{ {
StrC spec = ESpecifier::to_str( self->ArrSpecs[idx] ); StrC spec = to_str( self->ArrSpecs[idx] );
append_fmt( result, "%.*s ", spec.Len, spec.Ptr ); append_fmt( result, "%.*s ", spec.Len, spec.Ptr );
idx++; idx++;
} }

View File

@ -27,14 +27,14 @@ void to_string (CodeParam params, String* result );
CodeParam begin(CodeParam params); CodeParam begin(CodeParam params);
CodeParam end (CodeParam params); CodeParam end (CodeParam params);
bool append (CodeSpecifiers specifiers, SpecifierT spec); bool append (CodeSpecifiers specifiers, Specifier spec);
s32 has (CodeSpecifiers specifiers, SpecifierT spec); s32 has (CodeSpecifiers specifiers, Specifier spec);
s32 remove (CodeSpecifiers specifiers, SpecifierT to_remove ); s32 remove (CodeSpecifiers specifiers, Specifier to_remove );
String to_string(CodeSpecifiers specifiers); String to_string(CodeSpecifiers specifiers);
void to_string(CodeSpecifiers specifiers, String* result); void to_string(CodeSpecifiers specifiers, String* result);
SpecifierT* begin(CodeSpecifiers specifiers ); Specifier* begin(CodeSpecifiers specifiers );
SpecifierT* end (CodeSpecifiers specifiers); Specifier* end (CodeSpecifiers specifiers);
void add_interface(CodeStruct self, CodeType interface); void add_interface(CodeStruct self, CodeType interface);
String to_string (CodeStruct self); String to_string (CodeStruct self);

View File

@ -5,94 +5,90 @@
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
namespace ESpecifier typedef enum Specifier_Def Specifier;
enum Specifier_Def : u32
{ {
enum Type : u32 Spec_Invalid,
{ Spec_Consteval,
Invalid, Spec_Constexpr,
Consteval, Spec_Constinit,
Constexpr, Spec_Explicit,
Constinit, Spec_External_Linkage,
Explicit, Spec_ForceInline,
External_Linkage, Spec_Global,
ForceInline, Spec_Inline,
Global, Spec_Internal_Linkage,
Inline, Spec_Local_Persist,
Internal_Linkage, Spec_Mutable,
Local_Persist, Spec_NeverInline,
Mutable, Spec_Ptr,
NeverInline, Spec_Ref,
Ptr, Spec_Register,
Ref, Spec_RValue,
Register, Spec_Static,
RValue, Spec_Thread_Local,
Static, Spec_Virtual,
Thread_Local, Spec_Const,
Virtual, Spec_Final,
Const, Spec_NoExceptions,
Final, Spec_Override,
NoExceptions, Spec_Pure,
Override, Spec_Volatile,
Pure, Spec_NumSpecifiers
Volatile, };
NumSpecifiers
inline bool is_trailing( Specifier specifier )
{
return specifier > Spec_Virtual;
}
inline StrC to_str( Specifier type )
{
local_persist StrC lookup[] {
{ sizeof( "INVALID" ), "INVALID" },
{ sizeof( "consteval" ), "consteval" },
{ sizeof( "constexpr" ), "constexpr" },
{ sizeof( "constinit" ), "constinit" },
{ sizeof( "explicit" ), "explicit" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "forceinline" ), "forceinline" },
{ sizeof( "global" ), "global" },
{ sizeof( "inline" ), "inline" },
{ sizeof( "internal" ), "internal" },
{ sizeof( "local_persist" ), "local_persist" },
{ sizeof( "mutable" ), "mutable" },
{ sizeof( "neverinline" ), "neverinline" },
{ sizeof( "*" ), "*" },
{ sizeof( "&" ), "&" },
{ sizeof( "register" ), "register" },
{ sizeof( "&&" ), "&&" },
{ sizeof( "static" ), "static" },
{ sizeof( "thread_local" ), "thread_local" },
{ sizeof( "virtual" ), "virtual" },
{ sizeof( "const" ), "const" },
{ sizeof( "final" ), "final" },
{ sizeof( "noexcept" ), "noexcept" },
{ sizeof( "override" ), "override" },
{ sizeof( "= 0" ), "= 0" },
{ sizeof( "volatile" ), "volatile" },
}; };
return lookup[type];
}
inline bool is_trailing( Type specifier ) inline Specifier to_specifier( StrC str )
{
local_persist u32 keymap[Spec_NumSpecifiers];
do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
{ {
return specifier > Virtual; StrC enum_str = to_str( (Specifier)index );
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
} }
do_once_end u32 hash = crc32( str.Ptr, str.Len );
inline StrC to_str( Type type ) for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
{ {
local_persist StrC lookup[] { if ( keymap[index] == hash )
{ sizeof( "INVALID" ), "INVALID" }, return (Specifier)index;
{ sizeof( "consteval" ), "consteval" },
{ sizeof( "constexpr" ), "constexpr" },
{ sizeof( "constinit" ), "constinit" },
{ sizeof( "explicit" ), "explicit" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "forceinline" ), "forceinline" },
{ sizeof( "global" ), "global" },
{ sizeof( "inline" ), "inline" },
{ sizeof( "internal" ), "internal" },
{ sizeof( "local_persist" ), "local_persist" },
{ sizeof( "mutable" ), "mutable" },
{ sizeof( "neverinline" ), "neverinline" },
{ sizeof( "*" ), "*" },
{ sizeof( "&" ), "&" },
{ sizeof( "register" ), "register" },
{ sizeof( "&&" ), "&&" },
{ sizeof( "static" ), "static" },
{ sizeof( "thread_local" ), "thread_local" },
{ sizeof( "virtual" ), "virtual" },
{ sizeof( "const" ), "const" },
{ sizeof( "final" ), "final" },
{ sizeof( "noexcept" ), "noexcept" },
{ sizeof( "override" ), "override" },
{ sizeof( "= 0" ), "= 0" },
{ sizeof( "volatile" ), "volatile" },
};
return lookup[type];
} }
return Spec_Invalid;
inline Type to_type( StrC str ) }
{
local_persist u32 keymap[NumSpecifiers];
do_once_start for ( u32 index = 0; index < NumSpecifiers; index++ )
{
StrC enum_str = to_str( (Type)index );
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
}
do_once_end u32 hash = crc32( str.Ptr, str.Len );
for ( u32 index = 0; index < NumSpecifiers; index++ )
{
if ( keymap[index] == hash )
return (Type)index;
}
return Invalid;
}
} // namespace ESpecifier
using SpecifierT = ESpecifier::Type;

View File

@ -8,7 +8,7 @@
GEN_NS_PARSER_BEGIN GEN_NS_PARSER_BEGIN
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" ) #define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" )
typedef TokType_Def TokType; typedef enum TokType_Def TokType;
enum TokType_Def : u32 enum TokType_Def : u32
{ {
@ -216,7 +216,7 @@ inline StrC to_str( TokType type )
return lookup[type]; return lookup[type];
} }
inline TokType to_type( StrC str ) inline TokType to_toktype( StrC str )
{ {
local_persist u32 keymap[Tok_NumTokens]; local_persist u32 keymap[Tok_NumTokens];
do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ ) do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ )

View File

@ -232,7 +232,7 @@ CodeParam end(CodeParam params)
#pragma region CodeSpecifiers #pragma region CodeSpecifiers
inline inline
bool append(CodeSpecifiers self, SpecifierT spec ) bool append(CodeSpecifiers self, Specifier spec )
{ {
if ( self.ast == nullptr ) if ( self.ast == nullptr )
{ {
@ -250,7 +250,7 @@ bool append(CodeSpecifiers self, SpecifierT spec )
return true; return true;
} }
inline inline
s32 has(CodeSpecifiers self, SpecifierT spec) s32 has(CodeSpecifiers self, Specifier spec)
{ {
GEN_ASSERT(self.ast != nullptr); GEN_ASSERT(self.ast != nullptr);
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) { for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
@ -260,7 +260,7 @@ s32 has(CodeSpecifiers self, SpecifierT spec)
return -1; return -1;
} }
inline inline
s32 remove( CodeSpecifiers self, SpecifierT to_remove ) s32 remove( CodeSpecifiers self, Specifier to_remove )
{ {
AST_Specifiers* ast = self.ast; AST_Specifiers* ast = self.ast;
if ( ast == nullptr ) if ( ast == nullptr )
@ -280,7 +280,7 @@ s32 remove( CodeSpecifiers self, SpecifierT to_remove )
s32 next = 0; s32 next = 0;
for(; next < self->NumEntries; ++ curr, ++ next) for(; next < self->NumEntries; ++ curr, ++ next)
{ {
SpecifierT spec = self->ArrSpecs[next]; Specifier spec = self->ArrSpecs[next];
if (spec == to_remove) if (spec == to_remove)
{ {
result = next; result = next;
@ -301,7 +301,7 @@ s32 remove( CodeSpecifiers self, SpecifierT to_remove )
return result; return result;
} }
inline inline
SpecifierT* begin(CodeSpecifiers self) Specifier* begin(CodeSpecifiers self)
{ {
if ( self.ast ) if ( self.ast )
return & self->ArrSpecs[0]; return & self->ArrSpecs[0];
@ -309,7 +309,7 @@ SpecifierT* begin(CodeSpecifiers self)
return nullptr; return nullptr;
} }
inline inline
SpecifierT* end(CodeSpecifiers self) Specifier* end(CodeSpecifiers self)
{ {
return self->ArrSpecs + self->NumEntries; return self->ArrSpecs + self->NumEntries;
} }

View File

@ -192,32 +192,32 @@ void define_constants()
# undef internal # undef internal
# undef local_persist # undef local_persist
# undef neverinline # undef neverinline
def_constant_spec( const, ESpecifier::Const ); def_constant_spec( const, Spec_Const );
def_constant_spec( consteval, ESpecifier::Consteval ); def_constant_spec( consteval, Spec_Consteval );
def_constant_spec( constexpr, ESpecifier::Constexpr ); def_constant_spec( constexpr, Spec_Constexpr );
def_constant_spec( constinit, ESpecifier::Constinit ); def_constant_spec( constinit, Spec_Constinit );
def_constant_spec( extern_linkage, ESpecifier::External_Linkage ); def_constant_spec( extern_linkage, Spec_External_Linkage );
def_constant_spec( final, ESpecifier::Final ); def_constant_spec( final, Spec_Final );
def_constant_spec( forceinline, ESpecifier::ForceInline ); def_constant_spec( forceinline, Spec_ForceInline );
def_constant_spec( global, ESpecifier::Global ); def_constant_spec( global, Spec_Global );
def_constant_spec( inline, ESpecifier::Inline ); def_constant_spec( inline, Spec_Inline );
def_constant_spec( internal_linkage, ESpecifier::Internal_Linkage ); def_constant_spec( internal_linkage, Spec_Internal_Linkage );
def_constant_spec( local_persist, ESpecifier::Local_Persist ); def_constant_spec( local_persist, Spec_Local_Persist );
def_constant_spec( mutable, ESpecifier::Mutable ); def_constant_spec( mutable, Spec_Mutable );
def_constant_spec( neverinline, ESpecifier::NeverInline ); def_constant_spec( neverinline, Spec_NeverInline );
def_constant_spec( noexcept, ESpecifier::NoExceptions ); def_constant_spec( noexcept, Spec_NoExceptions );
def_constant_spec( override, ESpecifier::Override ); def_constant_spec( override, Spec_Override );
def_constant_spec( ptr, ESpecifier::Ptr ); def_constant_spec( ptr, Spec_Ptr );
def_constant_spec( pure, ESpecifier::Pure ) def_constant_spec( pure, Spec_Pure )
def_constant_spec( ref, ESpecifier::Ref ); def_constant_spec( ref, Spec_Ref );
def_constant_spec( register, ESpecifier::Register ); def_constant_spec( register, Spec_Register );
def_constant_spec( rvalue, ESpecifier::RValue ); def_constant_spec( rvalue, Spec_RValue );
def_constant_spec( static_member, ESpecifier::Static ); def_constant_spec( static_member, Spec_Static );
def_constant_spec( thread_local, ESpecifier::Thread_Local ); def_constant_spec( thread_local, Spec_Thread_Local );
def_constant_spec( virtual, ESpecifier::Virtual ); def_constant_spec( virtual, Spec_Virtual );
def_constant_spec( volatile, ESpecifier::Volatile) def_constant_spec( volatile, Spec_Volatile)
spec_local_persist = def_specifiers( 1, ESpecifier::Local_Persist ); spec_local_persist = def_specifiers( 1, Spec_Local_Persist );
set_global(spec_local_persist); set_global(spec_local_persist);
# pragma pop_macro("forceinline") # pragma pop_macro("forceinline")

View File

@ -120,7 +120,7 @@ CodePragma def_pragma( StrC directive );
CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content ); CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content );
CodeSpecifiers def_specifier( SpecifierT specifier ); CodeSpecifiers def_specifier( Specifier specifier );
CodeStruct def_struct( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT ); CodeStruct def_struct( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT );
@ -186,7 +186,7 @@ CodeBody def_namespace_body ( s32 num, Code* codes );
CodeParam def_params ( s32 num, ... ); CodeParam def_params ( s32 num, ... );
CodeParam def_params ( s32 num, CodeParam* params ); CodeParam def_params ( s32 num, CodeParam* params );
CodeSpecifiers def_specifiers ( s32 num, ... ); CodeSpecifiers def_specifiers ( s32 num, ... );
CodeSpecifiers def_specifiers ( s32 num, SpecifierT* specs ); CodeSpecifiers def_specifiers ( s32 num, Specifier* specs );
CodeBody def_struct_body ( s32 num, ... ); CodeBody def_struct_body ( s32 num, ... );
CodeBody def_struct_body ( s32 num, Code* codes ); CodeBody def_struct_body ( s32 num, Code* codes );
CodeBody def_union_body ( s32 num, ... ); CodeBody def_union_body ( s32 num, ... );

View File

@ -36,30 +36,30 @@ CodeConstructor parse_constructor( StrC def )
// TODO(Ed): Constructors can have prefix attributes // TODO(Ed): Constructors can have prefix attributes
CodeSpecifiers specifiers; CodeSpecifiers specifiers;
SpecifierT specs_found[ 16 ] { ESpecifier::NumSpecifiers }; Specifier specs_found[ 16 ] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
b32 ignore_spec = false; b32 ignore_spec = false;
switch ( spec ) switch ( spec )
{ {
case ESpecifier::Constexpr : case Spec_Constexpr :
case ESpecifier::Explicit: case Spec_Explicit:
case ESpecifier::Inline : case Spec_Inline :
case ESpecifier::ForceInline : case Spec_ForceInline :
case ESpecifier::NeverInline : case Spec_NeverInline :
break; break;
case ESpecifier::Const : case Spec_Const :
ignore_spec = true; ignore_spec = true;
break; break;
default : default :
log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), to_string(Context) ); log_failure( "Invalid specifier %s for variable\n%s", to_str( spec ), to_string(Context) );
pop(& Context); pop(& Context);
return InvalidCode; return InvalidCode;
} }

View File

@ -1158,7 +1158,7 @@ CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC expr )
return result; return result;
} }
CodeSpecifiers def_specifier( SpecifierT spec ) CodeSpecifiers def_specifier( Specifier spec )
{ {
CodeSpecifiers CodeSpecifiers
result = (CodeSpecifiers) make_code(); result = (CodeSpecifiers) make_code();
@ -2149,7 +2149,7 @@ CodeSpecifiers def_specifiers( s32 num, ... )
va_start(va, num); va_start(va, num);
do do
{ {
SpecifierT type = (SpecifierT)va_arg(va, int); Specifier type = (Specifier)va_arg(va, int);
append(result, type ); append(result, type );
} }
@ -2159,7 +2159,7 @@ CodeSpecifiers def_specifiers( s32 num, ... )
return result; return result;
} }
CodeSpecifiers def_specifiers( s32 num, SpecifierT* specs ) CodeSpecifiers def_specifiers( s32 num, Specifier* specs )
{ {
if ( num <= 0 ) if ( num <= 0 )
{ {

View File

@ -233,7 +233,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
ctx->token.Length++; ctx->token.Length++;
} }
ctx->token.Type = to_type( to_str(ctx->token) ); ctx->token.Type = to_toktype( to_str(ctx->token) );
bool is_preprocessor = ctx->token.Type >= Tok_Preprocess_Define && ctx->token.Type <= Tok_Preprocess_Pragma; bool is_preprocessor = ctx->token.Type >= Tok_Preprocess_Define && ctx->token.Type <= Tok_Preprocess_Pragma;
if ( ! is_preprocessor ) if ( ! is_preprocessor )
@ -458,7 +458,7 @@ void lex_found_token( LexContext* ctx )
return; return;
} }
TokType type = to_type( to_str(ctx->token) ); TokType type = to_toktype( to_str(ctx->token) );
if (type <= Tok_Access_Public && type >= Tok_Access_Private ) if (type <= Tok_Access_Public && type >= Tok_Access_Private )
{ {

View File

@ -989,39 +989,39 @@ CodeBody parse_class_struct_body( TokType which, Token name )
case Tok_Spec_Volatile: case Tok_Spec_Volatile:
case Tok_Spec_Virtual: case Tok_Spec_Virtual:
{ {
SpecifierT specs_found[16] { ESpecifier::NumSpecifiers }; Specifier specs_found[16] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
b32 ignore_spec = false; b32 ignore_spec = false;
switch ( spec ) switch ( spec )
{ {
case ESpecifier::Constexpr: case Spec_Constexpr:
case ESpecifier::Constinit: case Spec_Constinit:
case ESpecifier::Explicit: case Spec_Explicit:
case ESpecifier::Inline: case Spec_Inline:
case ESpecifier::ForceInline: case Spec_ForceInline:
case ESpecifier::Mutable: case Spec_Mutable:
case ESpecifier::NeverInline: case Spec_NeverInline:
case ESpecifier::Static: case Spec_Static:
case ESpecifier::Volatile: case Spec_Volatile:
case ESpecifier::Virtual: case Spec_Virtual:
break; break;
case ESpecifier::Consteval: case Spec_Consteval:
expects_function = true; expects_function = true;
break; break;
case ESpecifier::Const : case Spec_Const :
ignore_spec = true; ignore_spec = true;
break; break;
default: default:
log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str(spec), to_string(Context) ); log_failure( "Invalid specifier %s for variable\n%s", to_str(spec), to_string(Context) );
pop(& Context); pop(& Context);
return InvalidCode; return InvalidCode;
} }
@ -1182,13 +1182,13 @@ Code parse_complicated_definition( TokType which )
} }
Token tok = tokens.Arr[ idx - 1 ]; Token tok = tokens.Arr[ idx - 1 ];
if ( is_specifier(tok) && is_trailing( ESpecifier::to_type( to_str(tok))) ) if ( is_specifier(tok) && is_trailing( to_specifier( to_str(tok))) )
{ {
// <which> <type_identifier>(...) <specifier> ...; // <which> <type_identifier>(...) <specifier> ...;
s32 spec_idx = idx - 1; s32 spec_idx = idx - 1;
Token spec = tokens.Arr[spec_idx]; Token spec = tokens.Arr[spec_idx];
while ( is_specifier(spec) && is_trailing( ESpecifier::to_type( to_str(spec))) ) while ( is_specifier(spec) && is_trailing( to_specifier( to_str(spec))) )
{ {
-- spec_idx; -- spec_idx;
spec = tokens.Arr[spec_idx]; spec = tokens.Arr[spec_idx];
@ -1442,12 +1442,12 @@ CodeFn parse_function_after_name(
{ {
if ( specifiers.ast == nullptr ) if ( specifiers.ast == nullptr )
{ {
specifiers = def_specifier( ESpecifier::to_type( to_str(currtok)) ); specifiers = def_specifier( to_specifier( to_str(currtok)) );
eat( currtok.Type ); eat( currtok.Type );
continue; continue;
} }
append(specifiers, ESpecifier::to_type( to_str(currtok)) ); append(specifiers, to_specifier( to_str(currtok)) );
eat( currtok.Type ); eat( currtok.Type );
} }
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers> // <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>
@ -1467,7 +1467,7 @@ CodeFn parse_function_after_name(
else if ( check(Tok_Operator) && currtok.Text[0] == '=' ) else if ( check(Tok_Operator) && currtok.Text[0] == '=' )
{ {
eat(Tok_Operator); eat(Tok_Operator);
append(specifiers, ESpecifier::Pure ); append(specifiers, Spec_Pure );
eat( Tok_Number); eat( Tok_Number);
Token stmt_end = currtok; Token stmt_end = currtok;
@ -1768,40 +1768,40 @@ CodeBody parse_global_nspace( CodeT which )
case Tok_Spec_NeverInline: case Tok_Spec_NeverInline:
case Tok_Spec_Static: case Tok_Spec_Static:
{ {
SpecifierT specs_found[16] { ESpecifier::NumSpecifiers }; Specifier specs_found[16] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
bool ignore_spec = false; bool ignore_spec = false;
switch ( spec ) switch ( spec )
{ {
case ESpecifier::Constexpr: case Spec_Constexpr:
case ESpecifier::Constinit: case Spec_Constinit:
case ESpecifier::ForceInline: case Spec_ForceInline:
case ESpecifier::Global: case Spec_Global:
case ESpecifier::External_Linkage: case Spec_External_Linkage:
case ESpecifier::Internal_Linkage: case Spec_Internal_Linkage:
case ESpecifier::Inline: case Spec_Inline:
case ESpecifier::Mutable: case Spec_Mutable:
case ESpecifier::NeverInline: case Spec_NeverInline:
case ESpecifier::Static: case Spec_Static:
case ESpecifier::Volatile: case Spec_Volatile:
break; break;
case ESpecifier::Consteval: case Spec_Consteval:
expects_function = true; expects_function = true;
break; break;
case ESpecifier::Const: case Spec_Const:
ignore_spec = true; ignore_spec = true;
break; break;
default: default:
StrC spec_str = ESpecifier::to_str(spec); StrC spec_str = to_str(spec);
log_failure( "Invalid specifier %.*s for variable\n%s", spec_str.Len, spec_str, to_string(Context) ); log_failure( "Invalid specifier %.*s for variable\n%s", spec_str.Len, spec_str, to_string(Context) );
pop(& Context); pop(& Context);
@ -2445,12 +2445,12 @@ CodeOperator parse_operator_after_ret_type(
{ {
if ( specifiers.ast == nullptr ) if ( specifiers.ast == nullptr )
{ {
specifiers = def_specifier( ESpecifier::to_type( to_str(currtok)) ); specifiers = def_specifier( to_specifier( to_str(currtok)) );
eat( currtok.Type ); eat( currtok.Type );
continue; continue;
} }
append(specifiers, ESpecifier::to_type( to_str(currtok)) ); append(specifiers, to_specifier( to_str(currtok)) );
eat( currtok.Type ); eat( currtok.Type );
} }
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers> // <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers>
@ -3284,12 +3284,12 @@ CodeVar parse_variable_declaration_list()
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
switch ( spec ) switch ( spec )
{ {
case ESpecifier::Const: case Spec_Const:
if ( specifiers->NumEntries && specifiers->ArrSpecs[ specifiers->NumEntries - 1 ] != ESpecifier::Ptr ) if ( specifiers->NumEntries && specifiers->ArrSpecs[ specifiers->NumEntries - 1 ] != Spec_Ptr )
{ {
log_failure( "Error, const specifier must come after pointer specifier for variable declaration proceeding comma\n" log_failure( "Error, const specifier must come after pointer specifier for variable declaration proceeding comma\n"
"(Parser will add and continue to specifiers, but will most likely fail to compile)\n%s" "(Parser will add and continue to specifiers, but will most likely fail to compile)\n%s"
@ -3299,9 +3299,9 @@ CodeVar parse_variable_declaration_list()
} }
break; break;
case ESpecifier::Ptr: case Spec_Ptr:
case ESpecifier::Ref: case Spec_Ref:
case ESpecifier::RValue: case Spec_RValue:
break; break;
default: default:
@ -3457,9 +3457,9 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
if ( check( Tok_Spec_Virtual ) ) if ( check( Tok_Spec_Virtual ) )
{ {
if ( specifiers ) if ( specifiers )
append(specifiers, ESpecifier::Virtual ); append(specifiers, Spec_Virtual );
else else
specifiers = def_specifier( ESpecifier::Virtual ); specifiers = def_specifier( Spec_Virtual );
eat( Tok_Spec_Virtual ); eat( Tok_Spec_Virtual );
} }
// <Virtual Specifier> // <Virtual Specifier>
@ -3500,7 +3500,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
eat( Tok_Number ); eat( Tok_Number );
// <Virtual Specifier> ~<Name>() = 0 // <Virtual Specifier> ~<Name>() = 0
append(specifiers, ESpecifier::Pure ); append(specifiers, Spec_Pure );
} }
else if ( left && str_compare( upcoming.Text, "default", sizeof("default") - 1 ) == 0) else if ( left && str_compare( upcoming.Text, "default", sizeof("default") - 1 ) == 0)
{ {
@ -3562,7 +3562,7 @@ CodeEnum parse_enum( bool inplace_def )
using namespace ECode; using namespace ECode;
push_scope(); push_scope();
SpecifierT specs_found[16] { ESpecifier::NumSpecifiers }; Specifier specs_found[16] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
CodeAttributes attributes = { nullptr }; CodeAttributes attributes = { nullptr };
@ -3939,7 +3939,7 @@ CodeFn parse_function()
{ {
push_scope(); push_scope();
SpecifierT specs_found[16] { ESpecifier::NumSpecifiers }; Specifier specs_found[16] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
CodeAttributes attributes = { nullptr }; CodeAttributes attributes = { nullptr };
@ -3958,27 +3958,27 @@ CodeFn parse_function()
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
switch ( spec ) switch ( spec )
{ {
case ESpecifier::Const: case Spec_Const:
case ESpecifier::Consteval: case Spec_Consteval:
case ESpecifier::Constexpr: case Spec_Constexpr:
case ESpecifier::External_Linkage: case Spec_External_Linkage:
case ESpecifier::ForceInline: case Spec_ForceInline:
case ESpecifier::Inline: case Spec_Inline:
case ESpecifier::NeverInline: case Spec_NeverInline:
case ESpecifier::Static: case Spec_Static:
break; break;
default: default:
log_failure( "Invalid specifier %s for functon\n%s", ESpecifier::to_str(spec), to_string(Context) ); log_failure( "Invalid specifier %s for functon\n%s", to_str(spec), to_string(Context) );
pop(& Context); pop(& Context);
return InvalidCode; return InvalidCode;
} }
if ( spec == ESpecifier::Const ) if ( spec == Spec_Const )
continue; continue;
specs_found[NumSpecifiers] = spec; specs_found[NumSpecifiers] = spec;
@ -4056,7 +4056,7 @@ CodeOperator parse_operator()
CodeSpecifiers specifiers = { nullptr }; CodeSpecifiers specifiers = { nullptr };
ModuleFlag mflags = ModuleFlag_None; ModuleFlag mflags = ModuleFlag_None;
SpecifierT specs_found[16] { ESpecifier::NumSpecifiers }; Specifier specs_found[16] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
if ( check(Tok_Module_Export) ) if ( check(Tok_Module_Export) )
@ -4071,25 +4071,25 @@ CodeOperator parse_operator()
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
switch ( spec ) switch ( spec )
{ {
case ESpecifier::Const: case Spec_Const:
case ESpecifier::Constexpr: case Spec_Constexpr:
case ESpecifier::ForceInline: case Spec_ForceInline:
case ESpecifier::Inline: case Spec_Inline:
case ESpecifier::NeverInline: case Spec_NeverInline:
case ESpecifier::Static: case Spec_Static:
break; break;
default: default:
log_failure( "Invalid specifier " "%s" " for operator\n%s", ESpecifier::to_str(spec), to_string(Context) ); log_failure( "Invalid specifier " "%s" " for operator\n%s", to_str(spec), to_string(Context) );
pop(& Context); pop(& Context);
return InvalidCode; return InvalidCode;
} }
if ( spec == ESpecifier::Const ) if ( spec == Spec_Const )
continue; continue;
specs_found[NumSpecifiers] = spec; specs_found[NumSpecifiers] = spec;
@ -4154,10 +4154,10 @@ CodeOpCast parse_operator_cast( CodeSpecifiers specifiers )
if ( check(Tok_Spec_Const)) if ( check(Tok_Spec_Const))
{ {
if ( specifiers.ast == nullptr ) if ( specifiers.ast == nullptr )
specifiers = def_specifier( ESpecifier::Const ); specifiers = def_specifier( Spec_Const );
else else
append(specifiers, ESpecifier::Const ); append(specifiers, Spec_Const );
eat( Tok_Spec_Const ); eat( Tok_Spec_Const );
} }
@ -4302,7 +4302,7 @@ CodeTemplate parse_template()
bool expects_function = false; bool expects_function = false;
SpecifierT specs_found[ 16 ] { ESpecifier::NumSpecifiers }; Specifier specs_found[ 16 ] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
attributes = parse_attributes(); attributes = parse_attributes();
@ -4312,36 +4312,36 @@ CodeTemplate parse_template()
{ {
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
switch ( spec ) switch ( spec )
{ {
case ESpecifier::Const : case Spec_Const :
case ESpecifier::Constexpr : case Spec_Constexpr :
case ESpecifier::Constinit : case Spec_Constinit :
case ESpecifier::External_Linkage : case Spec_External_Linkage :
case ESpecifier::Global : case Spec_Global :
case ESpecifier::Inline : case Spec_Inline :
case ESpecifier::ForceInline : case Spec_ForceInline :
case ESpecifier::Local_Persist : case Spec_Local_Persist :
case ESpecifier::Mutable : case Spec_Mutable :
case ESpecifier::Static : case Spec_Static :
case ESpecifier::Thread_Local : case Spec_Thread_Local :
case ESpecifier::Volatile : case Spec_Volatile :
break; break;
case ESpecifier::Consteval : case Spec_Consteval :
expects_function = true; expects_function = true;
break; break;
default : default :
log_failure( "Invalid specifier %s for variable or function\n%s", ESpecifier::to_str( spec ), to_string(Context) ); log_failure( "Invalid specifier %s for variable or function\n%s", to_str( spec ), to_string(Context) );
pop(& Context); pop(& Context);
return InvalidCode; return InvalidCode;
} }
// Ignore const it will be handled by the type // Ignore const it will be handled by the type
if ( spec == ESpecifier::Const ) if ( spec == Spec_Const )
break; break;
specs_found[ NumSpecifiers ] = spec; specs_found[ NumSpecifiers ] = spec;
@ -4442,7 +4442,7 @@ CodeType parse_type( bool from_template, bool* typedef_is_function )
Token context_tok = prevtok; Token context_tok = prevtok;
SpecifierT specs_found[ 16 ] { ESpecifier::NumSpecifiers }; Specifier specs_found[ 16 ] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
Token name = { nullptr, 0, Tok_Invalid }; Token name = { nullptr, 0, Tok_Invalid };
@ -4454,9 +4454,9 @@ CodeType parse_type( bool from_template, bool* typedef_is_function )
// Prefix specifiers // Prefix specifiers
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
if ( spec != ESpecifier::Const ) if ( spec != Spec_Const )
{ {
log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, to_string(Context) ); log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, to_string(Context) );
pop(& Context); pop(& Context);
@ -4580,9 +4580,9 @@ else if ( currtok.Type == Tok_DeclType )
// Suffix specifiers for typename. // Suffix specifiers for typename.
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
if ( spec != ESpecifier::Const && spec != ESpecifier::Ptr && spec != ESpecifier::Ref && spec != ESpecifier::RValue ) if ( spec != Spec_Const && spec != Spec_Ptr && spec != Spec_Ref && spec != Spec_RValue )
{ {
log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, to_string(Context) ); log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, to_string(Context) );
pop(& Context); pop(& Context);
@ -4677,7 +4677,7 @@ else if ( currtok.Type == Tok_DeclType )
#else #else
if ( NumSpecifiers ) if ( NumSpecifiers )
return_type->Specs = def_specifiers( NumSpecifiers, ( SpecifierT* )specs_found ); return_type->Specs = def_specifiers( NumSpecifiers, ( Specifier* )specs_found );
// Reset specifiers, the function itself will have its own suffix specifiers possibly. // Reset specifiers, the function itself will have its own suffix specifiers possibly.
NumSpecifiers = 0; NumSpecifiers = 0;
@ -4713,9 +4713,9 @@ else if ( currtok.Type == Tok_DeclType )
// Binding specifiers // Binding specifiers
while ( left && currtok.is_specifier() ) while ( left && currtok.is_specifier() )
{ {
SpecifierT spec = ESpecifier::to_type( currtok ); Specifier spec = to_type( currtok );
if ( spec != ESpecifier::Ptr && spec != ESpecifier::Ref && spec != ESpecifier::RValue ) if ( spec != Spec_Ptr && spec != Spec_Ref && spec != Spec_RValue )
{ {
log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, to_string(Context) ); log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, to_string(Context) );
pop(& Context); pop(& Context);
@ -4780,12 +4780,12 @@ else if ( currtok.Type == Tok_DeclType )
// Look for suffix specifiers for the function // Look for suffix specifiers for the function
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
if ( spec != ESpecifier::Const if ( spec != Spec_Const
// TODO : Add support for NoExcept, l-value, volatile, l-value, etc // TODO : Add support for NoExcept, l-value, volatile, l-value, etc
// && spec != ESpecifier::NoExcept // && spec != Spec_NoExcept
&& spec != ESpecifier::RValue ) && spec != Spec_RValue )
{ {
log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, to_string(Context) ); log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, to_string(Context) );
pop(& Context); pop(& Context);
@ -4852,7 +4852,7 @@ else if ( currtok.Type == Tok_DeclType )
#else #else
if ( NumSpecifiers ) if ( NumSpecifiers )
{ {
Code specifiers = def_specifiers( NumSpecifiers, ( SpecifierT* )specs_found ); Code specifiers = def_specifiers( NumSpecifiers, ( Specifier* )specs_found );
result->Specs = specifiers; result->Specs = specifiers;
} }
#endif #endif
@ -5230,7 +5230,7 @@ CodeUsing parse_using()
{ {
push_scope(); push_scope();
SpecifierT specs_found[16] { ESpecifier::Invalid }; Specifier specs_found[16] { Spec_Invalid };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
Token name = { nullptr, 0, Tok_Invalid }; Token name = { nullptr, 0, Tok_Invalid };
@ -5330,7 +5330,7 @@ CodeVar parse_variable()
{ {
push_scope(); push_scope();
SpecifierT specs_found[16] { ESpecifier::NumSpecifiers }; Specifier specs_found[16] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
ModuleFlag mflags = ModuleFlag_None; ModuleFlag mflags = ModuleFlag_None;
@ -5349,31 +5349,31 @@ CodeVar parse_variable()
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
SpecifierT spec = ESpecifier::to_type( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
switch ( spec ) switch ( spec )
{ {
case ESpecifier::Const: case Spec_Const:
case ESpecifier::Constexpr: case Spec_Constexpr:
case ESpecifier::Constinit: case Spec_Constinit:
case ESpecifier::External_Linkage: case Spec_External_Linkage:
case ESpecifier::Global: case Spec_Global:
case ESpecifier::Inline: case Spec_Inline:
case ESpecifier::Local_Persist: case Spec_Local_Persist:
case ESpecifier::Mutable: case Spec_Mutable:
case ESpecifier::Static: case Spec_Static:
case ESpecifier::Thread_Local: case Spec_Thread_Local:
case ESpecifier::Volatile: case Spec_Volatile:
break; break;
default: default:
log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), to_string(Context) ); log_failure( "Invalid specifier %s for variable\n%s", to_str( spec ), to_string(Context) );
pop(& Context); pop(& Context);
return InvalidCode; return InvalidCode;
} }
// Ignore const specifiers, they're handled by the type // Ignore const specifiers, they're handled by the type
if ( spec == ESpecifier::Const ) if ( spec == Spec_Const )
break; break;
specs_found[NumSpecifiers] = spec; specs_found[NumSpecifiers] = spec;

View File

@ -132,23 +132,23 @@ CodeBody gen_especifier( char const* path )
char const* enum_str = enum_strs[idx].string; char const* enum_str = enum_strs[idx].string;
char const* entry_to_str = str_strs [idx].string; char const* entry_to_str = str_strs [idx].string;
append_fmt( & enum_entries, "%s,\n", enum_str ); append_fmt( & enum_entries, "Spec_%s,\n", enum_str );
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str); append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
} }
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize( CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize(
enum Type : u32 enum Specifier_Def : u32
{ {
<entries> <entries>
NumSpecifiers Spec_NumSpecifiers
}; };
))); )));
CodeFn is_trailing = parse_function(token_fmt("specifier", (StrC)to_str_entries, stringize( CodeFn is_trailing = parse_function(token_fmt("specifier", (StrC)to_str_entries, stringize(
inline inline
bool is_trailing( Type specifier ) bool is_trailing( Specifier specifier )
{ {
return specifier > Virtual; return specifier > Spec_Virtual;
} }
))); )));
@ -164,7 +164,7 @@ CodeBody gen_especifier( char const* path )
#undef neverinline #undef neverinline
CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, stringize( CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, stringize(
inline inline
StrC to_str( Type type ) StrC to_str( Specifier type )
{ {
local_persist local_persist
StrC lookup[] { StrC lookup[] {
@ -177,14 +177,14 @@ CodeBody gen_especifier( char const* path )
CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize( CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
inline inline
Type to_type( StrC str ) Specifier to_specifier( StrC str )
{ {
local_persist local_persist
u32 keymap[ NumSpecifiers ]; u32 keymap[ Spec_NumSpecifiers ];
do_once_start do_once_start
for ( u32 index = 0; index < NumSpecifiers; index++ ) for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
{ {
StrC enum_str = to_str( (Type)index ); StrC enum_str = to_str( (Specifier)index );
// We subtract 1 to remove the null terminator // We subtract 1 to remove the null terminator
// This is because the tokens lexed are not null terminated. // This is because the tokens lexed are not null terminated.
@ -194,13 +194,13 @@ CodeBody gen_especifier( char const* path )
u32 hash = crc32( str.Ptr, str.Len ); u32 hash = crc32( str.Ptr, str.Len );
for ( u32 index = 0; index < NumSpecifiers; index++ ) for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
{ {
if ( keymap[index] == hash ) if ( keymap[index] == hash )
return (Type)index; return (Specifier)index;
} }
return Invalid; return Spec_Invalid;
} }
))); )));
#pragma pop_macro("local_persist") #pragma pop_macro("local_persist")
@ -209,11 +209,11 @@ CodeBody gen_especifier( char const* path )
#pragma pop_macro("forceinline") #pragma pop_macro("forceinline")
#pragma pop_macro("neverinline") #pragma pop_macro("neverinline")
CodeNS nspace = def_namespace( name(ESpecifier), def_namespace_body( args( enum_code, is_trailing, to_str, to_type ) ) ); //CodeNS nspace = def_namespace( name(ESpecifier), def_namespace_body( args( enum_code, is_trailing, to_str, to_type ) ) );
//CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) );
CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier_Def Specifier; ));
CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) ); return def_global_body( args( specifier_t, enum_code, is_trailing, to_str, to_type, fmt_newline ) );
return def_global_body( args( nspace, specifier_t, fmt_newline ) );
} }
CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
@ -305,7 +305,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize( CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
inline inline
TokType to_type( StrC str ) TokType to_toktype( StrC str )
{ {
local_persist local_persist
u32 keymap[ Tok_NumTokens ]; u32 keymap[ Tok_NumTokens ];
@ -336,7 +336,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
#pragma pop_macro("do_once_end") #pragma pop_macro("do_once_end")
//CodeNS nspace = def_namespace( name(ETokType), def_namespace_body( args( attribute_entires_def, enum_code, to_str, to_type ) ) ); //CodeNS nspace = def_namespace( name(ETokType), def_namespace_body( args( attribute_entires_def, enum_code, to_str, to_type ) ) );
CodeTypedef td_toktype = parse_typedef( code( typedef TokType_Def TokType; )); CodeTypedef td_toktype = parse_typedef( code( typedef enum TokType_Def TokType; ));
return def_global_body( args( return def_global_body( args(
attribute_entires_def, attribute_entires_def,