From e00b2f8afbde47a4e08fff762c4da2b3eed28f7a Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 3 Dec 2024 15:19:39 -0500 Subject: [PATCH] Reduced ECode to C compatible vairant --- project/components/ast.cpp | 402 +++++++++++----------- project/components/ast.hpp | 10 +- project/components/ast_case_macros.cpp | 138 ++++---- project/components/ast_types.hpp | 180 +++++----- project/components/code_serialization.cpp | 125 +++---- project/components/code_types.hpp | 18 +- project/components/gen/ast_inlines.hpp | 12 +- project/components/gen/ecode.hpp | 266 +++++++------- project/components/header_end.hpp | 44 +-- project/components/inlines.hpp | 57 ++- project/components/interface.cpp | 26 +- project/components/interface.hpp | 22 +- project/components/interface.parsing.cpp | 4 +- project/components/interface.untyped.cpp | 6 +- project/components/interface.upfront.cpp | 394 +++++++++++---------- project/components/parser.cpp | 192 +++++------ project/components/static_data.cpp | 44 +-- project/helpers/helper.hpp | 19 +- 18 files changed, 956 insertions(+), 1003 deletions(-) diff --git a/project/components/ast.cpp b/project/components/ast.cpp index 2c2143a..b1d5cd2 100644 --- a/project/components/ast.cpp +++ b/project/components/ast.cpp @@ -24,31 +24,29 @@ char const* debug_str(Code self) switch ( self->Type ) { - using namespace ECode; - - case Invalid: - case NewLine: - case Access_Private: - case Access_Protected: - case Access_Public: + case CT_Invalid: + case CT_NewLine: + case CT_Access_Private: + case CT_Access_Protected: + case CT_Access_Public: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); break; - case Untyped: - case Execution: - case Comment: - case PlatformAttributes: - case Preprocess_Define: - case Preprocess_Include: - case Preprocess_Pragma: - case Preprocess_If: - case Preprocess_ElIf: - case Preprocess_Else: - case Preprocess_IfDef: - case Preprocess_IfNotDef: + case CT_Untyped: + case CT_Execution: + case CT_Comment: + case CT_PlatformAttributes: + case CT_Preprocess_Define: + case CT_Preprocess_Include: + case CT_Preprocess_Pragma: + case CT_Preprocess_If: + case CT_Preprocess_ElIf: + case CT_Preprocess_Else: + case CT_Preprocess_IfDef: + case CT_Preprocess_IfNotDef: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -57,8 +55,8 @@ char const* debug_str(Code self) append_fmt( result, "\n\tContent: %S", self->Content ); break; - case Class: - case Struct: + case CT_Class: + case CT_Struct: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -71,8 +69,8 @@ char const* debug_str(Code self) append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" ); break; - case Class_Fwd: - case Struct_Fwd: + case CT_Class_Fwd: + case CT_Struct_Fwd: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -84,7 +82,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tParentType : %s", self->ParentType ? type_str(self->ParentType) : "Null" ); break; - case Constructor: + case CT_Constructor: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -97,7 +95,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" ); break; - case Constructor_Fwd: + case CT_Constructor_Fwd: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -109,7 +107,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" ); break; - case Destructor: + case CT_Destructor: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -120,11 +118,11 @@ char const* debug_str(Code self) append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" ); break; - case Destructor_Fwd: + case CT_Destructor_Fwd: break; - case Enum: - case Enum_Class: + case CT_Enum: + case CT_Enum_Class: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -136,8 +134,8 @@ char const* debug_str(Code self) append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" ); break; - case Enum_Fwd: - case Enum_Class_Fwd: + case CT_Enum_Fwd: + case CT_Enum_Class_Fwd: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -148,8 +146,8 @@ char const* debug_str(Code self) append_fmt( result, "\n\tUnderlying Type : %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" ); break; - case Extern_Linkage: - case Namespace: + case CT_Extern_Linkage: + case CT_Namespace: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -158,7 +156,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tBody: %S", self->Body ? debug_str(self->Body) : "Null" ); break; - case Friend: + case CT_Friend: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -168,7 +166,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? to_string(self->Declaration) : "Null" ); break; - case Function: + case CT_Function: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -182,7 +180,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" ); break; - case Function_Fwd: + case CT_Function_Fwd: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -195,15 +193,15 @@ char const* debug_str(Code self) append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" ); break; - case Module: + case CT_Module: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); break; - case ECode::Operator: - case Operator_Member: + case CT_Operator: + case CT_Operator_Member: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -218,8 +216,8 @@ char const* debug_str(Code self) append_fmt( result, "\n\tOp : %S", to_str( self->Op ) ); break; - case Operator_Fwd: - case Operator_Member_Fwd: + case CT_Operator_Fwd: + case CT_Operator_Member_Fwd: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -233,7 +231,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tOp : %S", to_str( self->Op ) ); break; - case Operator_Cast: + case CT_Operator_Cast: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -245,7 +243,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" ); break; - case Operator_Cast_Fwd: + case CT_Operator_Cast_Fwd: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -256,7 +254,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tValueType : %S", self->ValueType ? to_string(self->ValueType) : "Null" ); break; - case Parameters: + case CT_Parameters: append_fmt( result, "\n\tNumEntries: %d", self->NumEntries ); append_fmt( result, "\n\tLast : %S", self->Last->Name ); append_fmt( result, "\n\tNext : %S", self->Next->Name ); @@ -264,7 +262,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tValue : %S", self->Value ? to_string(self->Value) : "Null" ); break; - case Specifiers: + case CT_Specifiers: { append_fmt( result, "\n\tNumEntries: %d", self->NumEntries ); GEN_NS append( result, "\n\tArrSpecs: " ); @@ -281,7 +279,7 @@ char const* debug_str(Code self) } break; - case Template: + case CT_Template: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -291,7 +289,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? to_string(self->Declaration) : "Null" ); break; - case Typedef: + case CT_Typedef: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -301,7 +299,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" ); break; - case Typename: + case CT_Typename: append_fmt( result, "\n\tAttributes : %S", self->Attributes ? to_string(self->Attributes) : "Null" ); append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" ); append_fmt( result, "\n\tReturnType : %S", self->ReturnType ? to_string(self->ReturnType) : "Null" ); @@ -309,7 +307,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tArrExpr : %S", self->ArrExpr ? to_string(self->ArrExpr) : "Null" ); break; - case Union: + case CT_Union: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -319,7 +317,7 @@ char const* debug_str(Code self) append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" ); break; - case Using: + case CT_Using: if ( self->Prev ) append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); if ( self->Next ) @@ -330,9 +328,9 @@ char const* debug_str(Code self) append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" ); break; - case Variable: + case CT_Variable: - if ( self->Parent && self->Parent->Type == Variable ) + if ( self->Parent && self->Parent->Type == CT_Variable ) { // Its a NextVar append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" ); @@ -362,8 +360,6 @@ char const* debug_str(Code self) Code duplicate(Code self) { - using namespace ECode; - Code result = make_code(); mem_copy( result.ast, self.ast, sizeof( AST ) ); @@ -387,9 +383,7 @@ void to_string( Code self, String* result ) switch ( self->Type ) { - using namespace ECode; - - case Invalid: + case CT_Invalid: #ifdef GEN_DONT_ALLOW_INVALID_CODE log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name ); #else @@ -397,197 +391,197 @@ void to_string( Code self, String* result ) #endif break; - case NewLine: + case CT_NewLine: append( result,"\n"); break; - case Untyped: - case Execution: - case Comment: - case PlatformAttributes: + case CT_Untyped: + case CT_Execution: + case CT_Comment: + case CT_PlatformAttributes: append( result, self->Content ); break; - case Access_Private: - case Access_Protected: - case Access_Public: + case CT_Access_Private: + case CT_Access_Protected: + case CT_Access_Public: append( result, self->Name ); break; - case Class: + case CT_Class: to_string_def(cast(CodeClass, self), result ); break; - case Class_Fwd: + case CT_Class_Fwd: to_string_fwd(cast(CodeClass, self), result ); break; - case Constructor: + case CT_Constructor: to_string_def(cast(CodeConstructor, self), result ); break; - case Constructor_Fwd: + case CT_Constructor_Fwd: to_string_fwd(cast(CodeConstructor, self), result ); break; - case Destructor: + case CT_Destructor: to_string_def(cast(CodeDestructor, self), result ); break; - case Destructor_Fwd: + case CT_Destructor_Fwd: to_string_fwd(cast(CodeDestructor, self), result ); break; - case Enum: + case CT_Enum: to_string_def(cast(CodeEnum, self), result ); break; - case Enum_Fwd: + case CT_Enum_Fwd: to_string_fwd(cast(CodeEnum, self), result ); break; - case Enum_Class: + case CT_Enum_Class: to_string_class_def(cast(CodeEnum, self), result ); break; - case Enum_Class_Fwd: + case CT_Enum_Class_Fwd: to_string_class_fwd(cast(CodeEnum, self), result ); break; - case Export_Body: + case CT_Export_Body: to_string_export(cast(CodeBody, self), result ); break; - case Extern_Linkage: + case CT_Extern_Linkage: to_string(cast(CodeExtern, self), result ); break; - case Friend: + case CT_Friend: to_string(cast(CodeFriend, self), result ); break; - case Function: + case CT_Function: to_string_def(cast(CodeFn, self), result ); break; - case Function_Fwd: + case CT_Function_Fwd: to_string_fwd(cast(CodeFn, self), result ); break; - case Module: + case CT_Module: to_string(cast(CodeModule, self), result ); break; - case Namespace: + case CT_Namespace: to_string(cast(CodeNS, self), result ); break; - case ECode::Operator: - case Operator_Member: + case CT_Operator: + case CT_Operator_Member: to_string_def(cast(CodeOperator, self), result ); break; - case Operator_Fwd: - case Operator_Member_Fwd: + case CT_Operator_Fwd: + case CT_Operator_Member_Fwd: to_string_fwd(cast(CodeOperator, self), result ); break; - case Operator_Cast: + case CT_Operator_Cast: to_string_def(cast(CodeOpCast, self), result ); break; - case Operator_Cast_Fwd: + case CT_Operator_Cast_Fwd: to_string_fwd(cast(CodeOpCast, self), result ); break; - case Parameters: + case CT_Parameters: to_string(cast(CodeParam, self), result ); break; - case Preprocess_Define: + case CT_Preprocess_Define: to_string(cast(CodeDefine, self), result ); break; - case Preprocess_If: + case CT_Preprocess_If: to_string_if(cast(CodePreprocessCond, self), result ); break; - case Preprocess_IfDef: + case CT_Preprocess_IfDef: to_string_ifdef(cast(CodePreprocessCond, self), result ); break; - case Preprocess_IfNotDef: + case CT_Preprocess_IfNotDef: to_string_ifndef(cast(CodePreprocessCond, self), result ); break; - case Preprocess_Include: + case CT_Preprocess_Include: to_string(cast(CodeInclude, self), result ); break; - case Preprocess_ElIf: + case CT_Preprocess_ElIf: to_string_elif(cast(CodePreprocessCond, self), result ); break; - case Preprocess_Else: + case CT_Preprocess_Else: to_string_else(cast(CodePreprocessCond, self), result ); break; - case Preprocess_EndIf: + case CT_Preprocess_EndIf: to_string_endif(cast(CodePreprocessCond, self), result ); break; - case Preprocess_Pragma: + case CT_Preprocess_Pragma: to_string(cast(CodePragma, self), result ); break; - case Specifiers: + case CT_Specifiers: to_string(cast(CodeSpecifiers, self), result ); break; - case Struct: + case CT_Struct: to_string_def(cast(CodeStruct, self), result ); break; - case Struct_Fwd: + case CT_Struct_Fwd: to_string_fwd(cast(CodeStruct, self), result ); break; - case Template: + case CT_Template: to_string(cast(CodeTemplate, self), result ); break; - case Typedef: + case CT_Typedef: to_string(cast(CodeTypedef, self), result ); break; - case Typename: - to_string(cast(CodeType, self), result ); + case CT_Typename: + to_string(cast(CodeTypename, self), result ); break; - case Union: + case CT_Union: to_string( cast(CodeUnion, self), result ); break; - case Using: + case CT_Using: to_string(cast(CodeUsing, self), result ); break; - case Using_Namespace: + case CT_Using_Namespace: to_string_ns(cast(CodeUsing, self), result ); break; - case Variable: + case CT_Variable: to_string(cast(CodeVar, self), result ); break; - case Enum_Body: - case Class_Body: - case Extern_Linkage_Body: - case Function_Body: - case Global_Body: - case Namespace_Body: - case Struct_Body: - case Union_Body: + case CT_Enum_Body: + case CT_Class_Body: + case CT_Extern_Linkage_Body: + case CT_Function_Body: + case CT_Global_Body: + case CT_Namespace_Body: + case CT_Struct_Body: + case CT_Union_Body: to_string( cast(CodeBody, self), result ); break; } @@ -620,8 +614,6 @@ bool is_equal( Code self, Code other ) switch ( self->Type ) { - using namespace ECode; - #define check_member_val( val ) \ if ( self->val != other->val ) \ { \ @@ -701,30 +693,30 @@ bool is_equal( Code self, Code other ) } \ } - case NewLine: - case Access_Public: - case Access_Protected: - case Access_Private: - case Preprocess_Else: - case Preprocess_EndIf: + case CT_NewLine: + case CT_Access_Public: + case CT_Access_Protected: + case CT_Access_Private: + case CT_Preprocess_Else: + case CT_Preprocess_EndIf: return true; // Comments are not validated. - case Comment: + case CT_Comment: return true; - case Execution: - case PlatformAttributes: - case Untyped: + case CT_Execution: + case CT_PlatformAttributes: + case CT_Untyped: { check_member_content( Content ); return true; } - case Class_Fwd: - case Struct_Fwd: + case CT_Class_Fwd: + case CT_Struct_Fwd: { check_member_str( Name ); check_member_ast( ParentType ); @@ -734,8 +726,8 @@ bool is_equal( Code self, Code other ) return true; } - case Class: - case Struct: + case CT_Class: + case CT_Struct: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -747,7 +739,7 @@ bool is_equal( Code self, Code other ) return true; } - case Constructor: + case CT_Constructor: { check_member_ast( InitializerList ); check_member_ast( Params ); @@ -756,7 +748,7 @@ bool is_equal( Code self, Code other ) return true; } - case Constructor_Fwd: + case CT_Constructor_Fwd: { check_member_ast( InitializerList ); check_member_ast( Params ); @@ -764,7 +756,7 @@ bool is_equal( Code self, Code other ) return true; } - case Destructor: + case CT_Destructor: { check_member_ast( Specs ); check_member_ast( Body ); @@ -772,15 +764,15 @@ bool is_equal( Code self, Code other ) return true; } - case Destructor_Fwd: + case CT_Destructor_Fwd: { check_member_ast( Specs ); return true; } - case Enum: - case Enum_Class: + case CT_Enum: + case CT_Enum_Class: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -791,8 +783,8 @@ bool is_equal( Code self, Code other ) return true; } - case Enum_Fwd: - case Enum_Class_Fwd: + case CT_Enum_Fwd: + case CT_Enum_Class_Fwd: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -802,7 +794,7 @@ bool is_equal( Code self, Code other ) return true; } - case Extern_Linkage: + case CT_Extern_Linkage: { check_member_str( Name ); check_member_ast( Body ); @@ -810,7 +802,7 @@ bool is_equal( Code self, Code other ) return true; } - case Friend: + case CT_Friend: { check_member_str( Name ); check_member_ast( Declaration ); @@ -818,7 +810,7 @@ bool is_equal( Code self, Code other ) return true; } - case Function: + case CT_Function: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -831,7 +823,7 @@ bool is_equal( Code self, Code other ) return true; } - case Function_Fwd: + case CT_Function_Fwd: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -843,7 +835,7 @@ bool is_equal( Code self, Code other ) return true; } - case Module: + case CT_Module: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -851,7 +843,7 @@ bool is_equal( Code self, Code other ) return true; } - case Namespace: + case CT_Namespace: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -860,8 +852,8 @@ bool is_equal( Code self, Code other ) return true; } - case ECode::Operator: - case Operator_Member: + case CT_Operator: + case CT_Operator_Member: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -874,8 +866,8 @@ bool is_equal( Code self, Code other ) return true; } - case Operator_Fwd: - case Operator_Member_Fwd: + case CT_Operator_Fwd: + case CT_Operator_Member_Fwd: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -887,7 +879,7 @@ bool is_equal( Code self, Code other ) return true; } - case Operator_Cast: + case CT_Operator_Cast: { check_member_str( Name ); check_member_ast( Specs ); @@ -897,7 +889,7 @@ bool is_equal( Code self, Code other ) return true; } - case Operator_Cast_Fwd: + case CT_Operator_Cast_Fwd: { check_member_str( Name ); check_member_ast( Specs ); @@ -906,7 +898,7 @@ bool is_equal( Code self, Code other ) return true; } - case Parameters: + case CT_Parameters: { if ( self->NumEntries > 1 ) { @@ -991,7 +983,7 @@ bool is_equal( Code self, Code other ) return true; } - case Preprocess_Define: + case CT_Preprocess_Define: { check_member_str( Name ); check_member_content( Content ); @@ -999,25 +991,25 @@ bool is_equal( Code self, Code other ) return true; } - case Preprocess_If: - case Preprocess_IfDef: - case Preprocess_IfNotDef: - case Preprocess_ElIf: + case CT_Preprocess_If: + case CT_Preprocess_IfDef: + case CT_Preprocess_IfNotDef: + case CT_Preprocess_ElIf: { check_member_content( Content ); return true; } - case Preprocess_Include: - case Preprocess_Pragma: + case CT_Preprocess_Include: + case CT_Preprocess_Pragma: { check_member_content( Content ); return true; } - case Specifiers: + case CT_Specifiers: { check_member_val( NumEntries ); check_member_str( Name ); @@ -1028,7 +1020,7 @@ bool is_equal( Code self, Code other ) return true; } - case Template: + case CT_Template: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -1038,7 +1030,7 @@ bool is_equal( Code self, Code other ) return true; } - case Typedef: + case CT_Typedef: { check_member_val( IsFunction ); check_member_val( ModuleFlags ); @@ -1048,7 +1040,7 @@ bool is_equal( Code self, Code other ) return true; } - case Typename: + case CT_Typename: { check_member_val( IsParamPack ); check_member_str( Name ); @@ -1058,7 +1050,7 @@ bool is_equal( Code self, Code other ) return true; } - case Union: + case CT_Union: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -1068,8 +1060,8 @@ bool is_equal( Code self, Code other ) return true; } - case Using: - case Using_Namespace: + case CT_Using: + case CT_Using_Namespace: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -1079,7 +1071,7 @@ bool is_equal( Code self, Code other ) return true; } - case Variable: + case CT_Variable: { check_member_val( ModuleFlags ); check_member_str( Name ); @@ -1093,13 +1085,13 @@ bool is_equal( Code self, Code other ) return true; } - case Class_Body: - case Enum_Body: - case Export_Body: - case Global_Body: - case Namespace_Body: - case Struct_Body: - case Union_Body: + case CT_Class_Body: + case CT_Enum_Body: + case CT_Export_Body: + case CT_Global_Body: + case CT_Namespace_Body: + case CT_Struct_Body: + case CT_Union_Body: { check_member_ast( Front ); check_member_ast( Back ); @@ -1155,8 +1147,6 @@ bool is_equal( Code self, Code other ) bool validate_body(Code self) { - using namespace ECode; - #define CheckEntries( Unallowed_Types ) \ do \ { \ @@ -1174,65 +1164,65 @@ bool validate_body(Code self) switch ( self->Type ) { - case Class_Body: + case CT_Class_Body: CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES ); break; - case Enum_Body: + case CT_Enum_Body: for ( Code entry : cast(CodeBody, self) ) { - if ( entry->Type != Untyped ) + if ( entry->Type != CT_Untyped ) { log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %s", GEN_NS debug_str(entry) ); return false; } } break; - case Export_Body: + case CT_Export_Body: CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES ); break; - case Extern_Linkage: + case CT_Extern_Linkage: CheckEntries( GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES ); break; - case Function_Body: + case CT_Function_Body: CheckEntries( GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES ); break; - case Global_Body: + case CT_Global_Body: for (Code entry : cast(CodeBody, self)) { switch (entry->Type) { - case Access_Public: - case Access_Protected: - case Access_Private: - case PlatformAttributes: - case Class_Body: - case Enum_Body: - case Execution: - case Friend: - case Function_Body: - case Global_Body: - case Namespace_Body: - case Operator_Member: - case Operator_Member_Fwd: - case Parameters: - case Specifiers: - case Struct_Body: - case Typename: + case CT_Access_Public: + case CT_Access_Protected: + case CT_Access_Private: + case CT_PlatformAttributes: + case CT_Class_Body: + case CT_Enum_Body: + case CT_Execution: + case CT_Friend: + case CT_Function_Body: + case CT_Global_Body: + case CT_Namespace_Body: + case CT_Operator_Member: + case CT_Operator_Member_Fwd: + case CT_Parameters: + case CT_Specifiers: + case CT_Struct_Body: + case CT_Typename: log_failure("AST::validate_body: Invalid entry in body %s", GEN_NS debug_str(entry)); return false; } } break; - case Namespace_Body: + case CT_Namespace_Body: CheckEntries( GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES ); break; - case Struct_Body: + case CT_Struct_Body: CheckEntries( GEN_AST_BODY_STRUCT_UNALLOWED_TYPES ); break; - case Union_Body: + case CT_Union_Body: for ( Code entry : cast(CodeBody, {self->Body}) ) { - if ( entry->Type != Untyped ) + if ( entry->Type != CT_Untyped ) { log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %s", GEN_NS debug_str(entry) ); return false; diff --git a/project/components/ast.hpp b/project/components/ast.hpp index bf096a9..bfabbb8 100644 --- a/project/components/ast.hpp +++ b/project/components/ast.hpp @@ -67,7 +67,7 @@ struct AST_Stmt_While; struct AST_Struct; struct AST_Template; -struct AST_Type; +struct AST_Typename; struct AST_Typedef; struct AST_Union; struct AST_Using; @@ -145,7 +145,7 @@ Define_Code(Stmt_While); Define_Code(Struct); Define_Code(Template); -Define_Code(Type); +Define_Code(Typename); Define_Code(Typedef); Define_Code(Union); Define_Code(Using); @@ -260,7 +260,7 @@ struct Code operator CodeSpecifiers() const; operator CodeStruct() const; operator CodeTemplate() const; - operator CodeType() const; + operator CodeTypename() const; operator CodeTypedef() const; operator CodeUnion() const; operator CodeUsing() const; @@ -294,7 +294,7 @@ int AST_ArrSpecs_Cap = - sizeof(parser::Token*) - sizeof(AST*) - sizeof(StringCached) - - sizeof(CodeT) + - sizeof(CodeType) - sizeof(ModuleFlag) - sizeof(int) ) @@ -353,7 +353,7 @@ struct AST parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing. Code Parent; StringCached Name; - CodeT Type; + CodeType Type; // CodeFlag CodeFlags; ModuleFlag ModuleFlags; union { diff --git a/project/components/ast_case_macros.cpp b/project/components/ast_case_macros.cpp index e7c38e9..8f1c9fa 100644 --- a/project/components/ast_case_macros.cpp +++ b/project/components/ast_case_macros.cpp @@ -1,78 +1,78 @@ # define GEN_AST_BODY_CLASS_UNALLOWED_TYPES \ - case PlatformAttributes: \ - case Class_Body: \ - case Enum_Body: \ - case Extern_Linkage: \ - case Function_Body: \ - case Function_Fwd: \ - case Global_Body: \ - case Namespace: \ - case Namespace_Body: \ - case ECode::Operator: \ - case Operator_Fwd: \ - case Parameters: \ - case Specifiers: \ - case Struct_Body: \ - case Typename: + case CT_PlatformAttributes: \ + case CT_Class_Body: \ + case CT_Enum_Body: \ + case CT_Extern_Linkage: \ + case CT_Function_Body: \ + case CT_Function_Fwd: \ + case CT_Global_Body: \ + case CT_Namespace: \ + case CT_Namespace_Body: \ + case CT_Operator: \ + case CT_Operator_Fwd: \ + case CT_Parameters: \ + case CT_Specifiers: \ + case CT_Struct_Body: \ + case CT_Typename: # define GEN_AST_BODY_STRUCT_UNALLOWED_TYPES GEN_AST_BODY_CLASS_UNALLOWED_TYPES # define GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES \ - case Access_Public: \ - case Access_Protected: \ - case Access_Private: \ - case PlatformAttributes: \ - case Class_Body: \ - case Enum_Body: \ - case Extern_Linkage: \ - case Friend: \ - case Function_Body: \ - case Function_Fwd: \ - case Global_Body: \ - case Namespace: \ - case Namespace_Body: \ - case ECode::Operator: \ - case Operator_Fwd: \ - case Operator_Member: \ - case Operator_Member_Fwd: \ - case Parameters: \ - case Specifiers: \ - case Struct_Body: \ - case Typename: + case CT_Access_Public: \ + case CT_Access_Protected: \ + case CT_Access_Private: \ + case CT_PlatformAttributes: \ + case CT_Class_Body: \ + case CT_Enum_Body: \ + case CT_Extern_Linkage: \ + case CT_Friend: \ + case CT_Function_Body: \ + case CT_Function_Fwd: \ + case CT_Global_Body: \ + case CT_Namespace: \ + case CT_Namespace_Body: \ + case CT_Operator: \ + case CT_Operator_Fwd: \ + case CT_Operator_Member: \ + case CT_Operator_Member_Fwd: \ + case CT_Parameters: \ + case CT_Specifiers: \ + case CT_Struct_Body: \ + case CT_Typename: -# define GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES \ - case Access_Public: \ - case Access_Protected: \ - case Access_Private: \ - case PlatformAttributes: \ - case Class_Body: \ - case Enum_Body: \ - case Execution: \ - case Friend: \ - case Function_Body: \ - case Namespace_Body: \ - case Operator_Member: \ - case Operator_Member_Fwd: \ - case Parameters: \ - case Specifiers: \ - case Struct_Body: \ - case Typename: +# define GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES \ + case CT_Access_Public: \ + case CT_Access_Protected: \ + case CT_Access_Private: \ + case CT_PlatformAttributes: \ + case CT_Class_Body: \ + case CT_Enum_Body: \ + case CT_Execution: \ + case CT_Friend: \ + case CT_Function_Body: \ + case CT_Namespace_Body: \ + case CT_Operator_Member: \ + case CT_Operator_Member_Fwd: \ + case CT_Parameters: \ + case CT_Specifiers: \ + case CT_Struct_Body: \ + case CT_Typename: # define GEN_AST_BODY_EXPORT_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES # define GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES # define GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES \ - case Access_Public: \ - case Access_Protected: \ - case Access_Private: \ - case PlatformAttributes: \ - case Class_Body: \ - case Enum_Body: \ - case Execution: \ - case Friend: \ - case Function_Body: \ - case Namespace_Body: \ - case Operator_Member: \ - case Operator_Member_Fwd: \ - case Parameters: \ - case Specifiers: \ - case Struct_Body: \ - case Typename: + case CT_Access_Public: \ + case CT_Access_Protected: \ + case CT_Access_Private: \ + case CT_PlatformAttributes: \ + case CT_Class_Body: \ + case CT_Enum_Body: \ + case CT_Execution: \ + case CT_Friend: \ + case CT_Function_Body: \ + case CT_Namespace_Body: \ + case CT_Operator_Member: \ + case CT_Operator_Member_Fwd: \ + case CT_Parameters: \ + case CT_Specifiers: \ + case CT_Struct_Body: \ + case CT_Typename: diff --git a/project/components/ast_types.hpp b/project/components/ast_types.hpp index b11fdc0..7825287 100644 --- a/project/components/ast_types.hpp +++ b/project/components/ast_types.hpp @@ -18,7 +18,7 @@ struct AST_Body parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; s32 NumEntries; }; @@ -35,7 +35,7 @@ struct AST_Attributes parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is not the same size as AST"); @@ -51,7 +51,7 @@ struct AST_BaseClass parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_BaseClass) == sizeof(AST), "ERROR: AST_BaseClass is not the same size as AST"); @@ -68,7 +68,7 @@ struct AST_Comment parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not the same size as AST"); @@ -82,18 +82,18 @@ struct AST_Class CodeComment InlineCmt; // Only supported by forward declarations CodeAttributes Attributes; char _PAD_SPECS_ [ sizeof(AST*) ]; - CodeType ParentType; + CodeTypename ParentType; char _PAD_PARAMS_[ sizeof(AST*) ]; CodeBody Body; char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; }; }; - CodeType Prev; - CodeType Next; + CodeTypename Prev; + CodeTypename Next; parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; AccessSpec ParentAccess; }; @@ -119,7 +119,7 @@ struct AST_Constructor parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor is not the same size as AST"); @@ -135,7 +135,7 @@ struct AST_Define parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the same size as AST"); @@ -159,7 +159,7 @@ struct AST_Destructor parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is not the same size as AST"); @@ -173,7 +173,7 @@ struct AST_Enum CodeComment InlineCmt; CodeAttributes Attributes; char _PAD_SPEC_ [ sizeof(AST*) ]; - CodeType UnderlyingType; + CodeTypename UnderlyingType; Code UnderlyingTypeMacro; CodeBody Body; char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; @@ -184,7 +184,7 @@ struct AST_Enum parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; b32 EnumUnderlyingMacro; }; @@ -201,7 +201,7 @@ struct AST_Exec parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST"); @@ -217,7 +217,7 @@ struct AST_Expr parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr) == sizeof(AST), "ERROR: AST_Expr is not the same size as AST"); @@ -232,7 +232,7 @@ struct AST_Expr_Assign parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Assign) == sizeof(AST), "ERROR: AST_Expr_Assign is not the same size as AST"); @@ -247,7 +247,7 @@ struct AST_Expr_Alignof parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Alignof) == sizeof(AST), "ERROR: AST_Expr_Alignof is not the same size as AST"); @@ -262,7 +262,7 @@ struct AST_Expr_Binary parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Binary) == sizeof(AST), "ERROR: AST_Expr_Binary is not the same size as AST"); @@ -277,7 +277,7 @@ struct AST_Expr_CStyleCast parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_CStyleCast) == sizeof(AST), "ERROR: AST_Expr_CStyleCast is not the same size as AST"); @@ -292,7 +292,7 @@ struct AST_Expr_FunctionalCast parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_FunctionalCast) == sizeof(AST), "ERROR: AST_Expr_FunctionalCast is not the same size as AST"); @@ -307,7 +307,7 @@ struct AST_Expr_CppCast parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_CppCast) == sizeof(AST), "ERROR: AST_Expr_CppCast is not the same size as AST"); @@ -322,7 +322,7 @@ struct AST_Expr_ProcCall parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_ProcCall) == sizeof(AST), "ERROR: AST_Expr_Identifier is not the same size as AST"); @@ -337,7 +337,7 @@ struct AST_Expr_Decltype parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Decltype) == sizeof(AST), "ERROR: AST_Expr_Decltype is not the same size as AST"); @@ -352,7 +352,7 @@ struct AST_Expr_Comma parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Comma) == sizeof(AST), "ERROR: AST_Expr_Comma is not the same size as AST"); @@ -367,7 +367,7 @@ struct AST_Expr_AMS parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_AMS) == sizeof(AST), "ERROR: AST_Expr_AMS is not the same size as AST"); @@ -382,7 +382,7 @@ struct AST_Expr_Sizeof parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Sizeof) == sizeof(AST), "ERROR: AST_Expr_Sizeof is not the same size as AST"); @@ -397,7 +397,7 @@ struct AST_Expr_Subscript parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Subscript) == sizeof(AST), "ERROR: AST_Expr_Subscript is not the same size as AST"); @@ -412,7 +412,7 @@ struct AST_Expr_Ternary parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Ternary) == sizeof(AST), "ERROR: AST_Expr_Ternary is not the same size as AST"); @@ -427,7 +427,7 @@ struct AST_Expr_UnaryPrefix parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_UnaryPrefix) == sizeof(AST), "ERROR: AST_Expr_UnaryPrefix is not the same size as AST"); @@ -442,7 +442,7 @@ struct AST_Expr_UnaryPostfix parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_UnaryPostfix) == sizeof(AST), "ERROR: AST_Expr_UnaryPostfix is not the same size as AST"); @@ -457,7 +457,7 @@ struct AST_Expr_Element parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Expr_Element) == sizeof(AST), "ERROR: AST_Expr_Element is not the same size as AST"); @@ -479,7 +479,7 @@ struct AST_Extern parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the same size as AST"); @@ -495,7 +495,7 @@ struct AST_Include parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not the same size as AST"); @@ -517,7 +517,7 @@ struct AST_Friend parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the same size as AST"); @@ -531,7 +531,7 @@ struct AST_Fn CodeComment InlineCmt; CodeAttributes Attributes; CodeSpecifiers Specs; - CodeType ReturnType; + CodeTypename ReturnType; CodeParam Params; CodeBody Body; char _PAD_PROPERTIES_ [ sizeof(AST*) ]; @@ -542,7 +542,7 @@ struct AST_Fn parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; char _PAD_UNUSED_[ sizeof(u32) ]; }; @@ -556,7 +556,7 @@ struct AST_Module parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; char _PAD_UNUSED_[ sizeof(u32) ]; }; @@ -577,7 +577,7 @@ struct AST_NS parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; char _PAD_UNUSED_[ sizeof(u32) ]; }; @@ -592,7 +592,7 @@ struct AST_Operator CodeComment InlineCmt; CodeAttributes Attributes; CodeSpecifiers Specs; - CodeType ReturnType; + CodeTypename ReturnType; CodeParam Params; CodeBody Body; char _PAD_PROPERTIES_ [ sizeof(AST*) ]; @@ -603,7 +603,7 @@ struct AST_Operator parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; Operator Op; }; @@ -615,10 +615,10 @@ struct AST_OpCast char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { - CodeComment InlineCmt; - char _PAD_PROPERTIES_[ sizeof(AST*) ]; - CodeSpecifiers Specs; - CodeType ValueType; + CodeComment InlineCmt; + char _PAD_PROPERTIES_[ sizeof(AST*) ]; + CodeSpecifiers Specs; + CodeTypename ValueType; char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; CodeBody Body; char _PAD_PROPERTIES_3_[ sizeof(AST*) ]; @@ -629,7 +629,7 @@ struct AST_OpCast parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST"); @@ -640,11 +640,11 @@ struct AST_Param char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { - char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; - CodeType ValueType; - Code Macro; - Code Value; - Code PostNameMacro; // Thanks Unreal + char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; + CodeTypename ValueType; + Code Macro; + Code Value; + Code PostNameMacro; // Thanks Unreal // char _PAD_PROPERTIES_3_[sizeof( AST* )]; }; }; @@ -653,7 +653,7 @@ struct AST_Param parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; s32 NumEntries; }; @@ -670,7 +670,7 @@ struct AST_Pragma parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the same size as AST"); @@ -686,7 +686,7 @@ struct AST_PreprocessCond parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_PreprocessCond is not the same size as AST"); @@ -700,7 +700,7 @@ struct AST_Specifiers parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; s32 NumEntries; }; @@ -717,7 +717,7 @@ struct AST_Stmt parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt) == sizeof(AST), "ERROR: AST_Stmt is not the same size as AST"); @@ -732,7 +732,7 @@ struct AST_Stmt_Break parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Break) == sizeof(AST), "ERROR: AST_Stmt_Break is not the same size as AST"); @@ -747,7 +747,7 @@ struct AST_Stmt_Case parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Case) == sizeof(AST), "ERROR: AST_Stmt_Case is not the same size as AST"); @@ -762,7 +762,7 @@ struct AST_Stmt_Continue parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Continue) == sizeof(AST), "ERROR: AST_Stmt_Continue is not the same size as AST"); @@ -777,7 +777,7 @@ struct AST_Stmt_Decl parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Decl) == sizeof(AST), "ERROR: AST_Stmt_Decl is not the same size as AST"); @@ -792,7 +792,7 @@ struct AST_Stmt_Do parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Do) == sizeof(AST), "ERROR: AST_Stmt_Do is not the same size as AST"); @@ -807,7 +807,7 @@ struct AST_Stmt_Expr parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Expr) == sizeof(AST), "ERROR: AST_Stmt_Expr is not the same size as AST"); @@ -822,7 +822,7 @@ struct AST_Stmt_Else parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Else) == sizeof(AST), "ERROR: AST_Stmt_Else is not the same size as AST"); @@ -837,7 +837,7 @@ struct AST_Stmt_If parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_If) == sizeof(AST), "ERROR: AST_Stmt_If is not the same size as AST"); @@ -852,7 +852,7 @@ struct AST_Stmt_For parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_For) == sizeof(AST), "ERROR: AST_Stmt_For is not the same size as AST"); @@ -867,7 +867,7 @@ struct AST_Stmt_Goto parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Goto) == sizeof(AST), "ERROR: AST_Stmt_Goto is not the same size as AST"); @@ -882,7 +882,7 @@ struct AST_Stmt_Label parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Label) == sizeof(AST), "ERROR: AST_Stmt_Label is not the same size as AST"); @@ -897,7 +897,7 @@ struct AST_Stmt_Switch parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_Switch) == sizeof(AST), "ERROR: AST_Stmt_Switch is not the same size as AST"); @@ -912,7 +912,7 @@ struct AST_Stmt_While parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; }; static_assert( sizeof(AST_Stmt_While) == sizeof(AST), "ERROR: AST_Stmt_While is not the same size as AST"); @@ -927,18 +927,18 @@ struct AST_Struct CodeComment InlineCmt; CodeAttributes Attributes; char _PAD_SPECS_ [ sizeof(AST*) ]; - CodeType ParentType; + CodeTypename ParentType; char _PAD_PARAMS_[ sizeof(AST*) ]; CodeBody Body; char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; }; }; - CodeType Prev; - CodeType Next; + CodeTypename Prev; + CodeTypename Next; parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; AccessSpec ParentAccess; }; @@ -961,7 +961,7 @@ struct AST_Template parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; char _PAD_UNUSED_[ sizeof(u32) ]; }; @@ -976,12 +976,12 @@ struct AST_Type struct { char _PAD_INLINE_CMT_[ sizeof(AST*) ]; - CodeAttributes Attributes; - CodeSpecifiers Specs; - Code QualifierID; - // CodeType ReturnType; // Only used for function signatures - // CodeParam Params; // Only used for function signatures - Code ArrExpr; + CodeAttributes Attributes; + CodeSpecifiers Specs; + Code QualifierID; + // CodeTypename ReturnType; // Only used for function signatures + // CodeParam Params; // Only used for function signatures + Code ArrExpr; // CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures }; }; @@ -990,14 +990,14 @@ struct AST_Type parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; b32 IsParamPack; }; static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST"); #endif -struct AST_Type +struct AST_Typename { union { char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; @@ -1006,7 +1006,7 @@ struct AST_Type char _PAD_INLINE_CMT_[ sizeof(AST*) ]; CodeAttributes Attributes; CodeSpecifiers Specs; - CodeType ReturnType; // Only used for function signatures + CodeTypename ReturnType; // Only used for function signatures CodeParam Params; // Only used for function signatures Code ArrExpr; CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures @@ -1017,11 +1017,11 @@ struct AST_Type parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; b32 IsParamPack; }; -static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST"); +static_assert( sizeof(AST_Typename) == sizeof(AST), "ERROR: AST_Type is not the same size as AST"); struct AST_Typedef { @@ -1040,7 +1040,7 @@ struct AST_Typedef parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; b32 IsFunction; }; @@ -1064,7 +1064,7 @@ struct AST_Union parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; char _PAD_UNUSED_[ sizeof(u32) ]; }; @@ -1079,7 +1079,7 @@ struct AST_Using CodeComment InlineCmt; CodeAttributes Attributes; char _PAD_SPECS_ [ sizeof(AST*) ]; - CodeType UnderlyingType; + CodeTypename UnderlyingType; char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; }; }; @@ -1088,7 +1088,7 @@ struct AST_Using parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; char _PAD_UNUSED_[ sizeof(u32) ]; }; @@ -1103,7 +1103,7 @@ struct AST_Var CodeComment InlineCmt; CodeAttributes Attributes; CodeSpecifiers Specs; - CodeType ValueType; + CodeTypename ValueType; Code BitfieldSize; Code Value; CodeVar NextVar; @@ -1114,7 +1114,7 @@ struct AST_Var parser::Token* Tok; Code Parent; StringCached Name; - CodeT Type; + CodeType Type; ModuleFlag ModuleFlags; s32 VarConstructorInit; }; diff --git a/project/components/code_serialization.cpp b/project/components/code_serialization.cpp index c8254ac..6a5ef38 100644 --- a/project/components/code_serialization.cpp +++ b/project/components/code_serialization.cpp @@ -13,24 +13,23 @@ String to_string(CodeBody body) String result = string_make( GlobalAllocator, "" ); switch ( body.ast->Type ) { - using namespace ECode; - case Untyped: - case Execution: + case CT_Untyped: + case CT_Execution: append( & result, rcast(AST*, body.ast)->Content ); break; - case Enum_Body: - case Class_Body: - case Extern_Linkage_Body: - case Function_Body: - case Global_Body: - case Namespace_Body: - case Struct_Body: - case Union_Body: + case CT_Enum_Body: + case CT_Class_Body: + case CT_Extern_Linkage_Body: + case CT_Function_Body: + case CT_Global_Body: + case CT_Namespace_Body: + case CT_Struct_Body: + case CT_Union_Body: to_string( body, & result ); break; - case Export_Body: + case CT_Export_Body: to_string_export( body, & result ); break; } @@ -77,11 +76,10 @@ String to_string(CodeConstructor self) String result = string_make( GlobalAllocator, "" ); switch (self->Type) { - using namespace ECode; - case Constructor: + case CT_Constructor: to_string_def( self, & result ); break; - case Constructor_Fwd: + case CT_Constructor_Fwd: to_string_fwd( self, & result ); break; } @@ -141,11 +139,10 @@ String to_string( CodeClass self ) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case Class: + case CT_Class: to_string_def(self, & result ); break; - case Class_Fwd: + case CT_Class_Fwd: to_string_fwd(self, & result ); break; } @@ -173,14 +170,14 @@ void to_string_def( CodeClass self, String* result ) append_fmt( result, "%S : %s %S", ast->Name, access_level, to_string(ast->ParentType) ); - CodeType interface = cast(CodeType, ast->ParentType->Next); + CodeTypename interface = cast(CodeTypename, ast->ParentType->Next); if ( interface ) append( result, "\n" ); while ( interface ) { append_fmt( result, ", %S", to_string(interface) ); - interface = interface->Next ? cast(CodeType, interface->Next) : CodeType { nullptr }; + interface = interface->Next ? cast(CodeTypename, interface->Next) : CodeTypename { nullptr }; } } else if ( ast->Name ) @@ -195,7 +192,7 @@ void to_string_def( CodeClass self, String* result ) append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) ); - if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) + if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) append( result, ";\n"); } @@ -213,7 +210,7 @@ void to_string_fwd( CodeClass self, String* result ) else append_fmt( result, "class %S", ast->Name ); // Check if it can have an end-statement - if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) + if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) { if ( ast->InlineCmt ) append_fmt( result, "; // %S\n", ast->InlineCmt->Content ); @@ -237,11 +234,10 @@ String to_string(CodeDestructor self) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case Destructor: + case CT_Destructor: to_string_def( self, & result ); break; - case Destructor_Fwd: + case CT_Destructor_Fwd: to_string_fwd( self, & result ); break; } @@ -295,17 +291,16 @@ String to_string(CodeEnum self) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case Enum: + case CT_Enum: to_string_def(self, & result ); break; - case Enum_Fwd: + case CT_Enum_Fwd: to_string_fwd(self, & result ); break; - case Enum_Class: + case CT_Enum_Class: to_string_class_def(self, & result ); break; - case Enum_Class_Fwd: + case CT_Enum_Class_Fwd: to_string_class_fwd(self, & result ); break; } @@ -341,7 +336,7 @@ void to_string_def(CodeEnum self, String* result ) } else append_fmt( result, "enum %S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) ); - if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) ) + if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) append( result, ";\n"); } @@ -358,7 +353,7 @@ void to_string_fwd(CodeEnum self, String* result ) else append_fmt( result, "enum %S", self->Name ); - if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) ) + if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { if ( self->InlineCmt ) append_fmt( result, "; %S", self->InlineCmt->Content ); @@ -395,7 +390,7 @@ void to_string_class_def(CodeEnum self, String* result ) append_fmt( result, "enum class %S\n{\n%S\n}", GEN_NS to_string(self->Body) ); } - if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) ) + if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) append( result, ";\n"); } @@ -411,7 +406,7 @@ void to_string_class_fwd(CodeEnum self, String* result ) append_fmt( result, "%S : %S", self->Name, to_string(self->UnderlyingType) ); - if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) ) + if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { if ( self->InlineCmt ) append_fmt( result, "; %S", self->InlineCmt->Content ); @@ -454,7 +449,7 @@ void to_string(CodeFriend self, String* result ) { append_fmt( result, "friend %S", GEN_NS to_string(self->Declaration) ); - if ( self->Declaration->Type != ECode::Function && (* result)[ length(* result) - 1 ] != ';' ) + if ( self->Declaration->Type != CT_Function && (* result)[ length(* result) - 1 ] != ';' ) { append( result, ";" ); } @@ -470,11 +465,10 @@ String to_string(CodeFn self) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case Function: + case CT_Function: to_string_def(self, & result ); break; - case Function_Fwd: + case CT_Function_Fwd: to_string_fwd(self, & result ); break; } @@ -635,13 +629,12 @@ String to_string(CodeOperator self) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case ECode::Operator: - case Operator_Member: + case CT_Operator: + case CT_Operator_Member: to_string_def( self, & result ); break; - case Operator_Fwd: - case Operator_Member_Fwd: + case CT_Operator_Fwd: + case CT_Operator_Member_Fwd: to_string_fwd( self, & result ); break; } @@ -758,11 +751,10 @@ String to_string(CodeOpCast self) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case Operator_Cast: + case CT_Operator_Cast: to_string_def(self, & result ); break; - case Operator_Cast_Fwd: + case CT_Operator_Cast_Fwd: to_string_fwd(self, & result ); break; } @@ -893,23 +885,22 @@ String to_string(CodePreprocessCond self) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case Preprocess_If: + case CT_Preprocess_If: to_string_if( self, & result ); break; - case Preprocess_IfDef: + case CT_Preprocess_IfDef: to_string_ifdef( self, & result ); break; - case Preprocess_IfNotDef: + case CT_Preprocess_IfNotDef: to_string_ifndef( self, & result ); break; - case Preprocess_ElIf: + case CT_Preprocess_ElIf: to_string_elif( self, & result ); break; - case Preprocess_Else: + case CT_Preprocess_Else: to_string_else( self, & result ); break; - case Preprocess_EndIf: + case CT_Preprocess_EndIf: to_string_endif( self, & result ); break; } @@ -985,11 +976,10 @@ String to_string(CodeStruct self) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case Struct: + case CT_Struct: to_string_def( self, & result ); break; - case Struct_Fwd: + case CT_Struct_Fwd: to_string_fwd( self, & result ); break; } @@ -1017,14 +1007,14 @@ void to_string_def( CodeStruct self, String* result ) append_fmt( result, "%S : %s %S", ast->Name, access_level, GEN_NS to_string(ast->ParentType) ); - CodeType interface = cast(CodeType, ast->ParentType->Next); + CodeTypename interface = cast(CodeTypename, ast->ParentType->Next); if ( interface ) append( result, "\n" ); while ( interface ) { append_fmt( result, ", %S", GEN_NS to_string(interface) ); - interface = interface->Next ? cast( CodeType, interface->Next) : CodeType { nullptr }; + interface = interface->Next ? cast( CodeTypename, interface->Next) : CodeTypename { nullptr }; } } else if ( ast->Name ) @@ -1039,7 +1029,7 @@ void to_string_def( CodeStruct self, String* result ) append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) ); - if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) + if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) append( result, ";\n"); } @@ -1056,7 +1046,7 @@ void to_string_fwd( CodeStruct self, String* result ) else append_fmt( result, "struct %S", ast->Name ); - if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) + if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) { if ( ast->InlineCmt ) append_fmt( result, "; %S", ast->InlineCmt->Content ); @@ -1103,7 +1093,7 @@ void to_string(CodeTypedef self, String* result ) else append_fmt( result, "%S %S", GEN_NS to_string(self->UnderlyingType), self->Name ); - if ( self->UnderlyingType->Type == ECode::Typename && self->UnderlyingType->ArrExpr ) + if ( self->UnderlyingType->Type == CT_Typename && self->UnderlyingType->ArrExpr ) { append_fmt( result, "[ %S ];", GEN_NS to_string(self->UnderlyingType->ArrExpr) ); @@ -1125,14 +1115,14 @@ void to_string(CodeTypedef self, String* result ) append( result, "\n"); } -String to_string(CodeType self) +String to_string(CodeTypename self) { String result = string_make( GlobalAllocator, "" ); to_string( self, & result ); return result; } -void to_string(CodeType self, String* result ) +void to_string(CodeTypename self, String* result ) { #if defined(GEN_USE_NEW_TYPENAME_PARSING) if ( self->ReturnType && self->Params ) @@ -1210,7 +1200,7 @@ void to_string(CodeUnion self, String* result ) ); } - if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) ) + if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) append( result, ";\n"); } @@ -1219,11 +1209,10 @@ String to_string(CodeUsing self) String result = string_make( GlobalAllocator, "" ); switch ( self->Type ) { - using namespace ECode; - case Using: + case CT_Using: to_string( self, & result ); break; - case Using_Namespace: + case CT_Using_Namespace: to_string_ns( self, & result ); break; } @@ -1282,7 +1271,7 @@ String to_string(CodeVar self) void to_string(CodeVar self, String* result ) { - if ( self->Parent && self->Parent->Type == ECode::Variable ) + if ( self->Parent && self->Parent->Type == CT_Variable ) { // Its a comma-separated variable ( a NextVar ) diff --git a/project/components/code_types.hpp b/project/components/code_types.hpp index 0f4c3f0..6c5a380 100644 --- a/project/components/code_types.hpp +++ b/project/components/code_types.hpp @@ -103,8 +103,8 @@ void to_string_endif (CodePreprocessCond cond, String* result ); String to_string(CodeTemplate self); void to_string(CodeTemplate self, String* result); -String to_string(CodeType self); -void to_string(CodeType self, String* result); +String to_string(CodeTypename self); +void to_string(CodeTypename self, String* result); String to_string(CodeTypedef self); void to_string(CodeTypedef self, String* result); @@ -927,19 +927,19 @@ struct CodeTemplate AST_Template* ast; }; -struct CodeType +struct CodeTypename { #if GEN_SUPPORT_CPP_MEMBER_FEATURES - Using_Code( CodeType ); + Using_Code( CodeTypename ); String to_string() { return GEN_NS to_string(* this); } void to_string( String& result ) { return GEN_NS to_string(* this, & result); } #endif - Using_CodeOps( CodeType ); - operator Code(); - AST_Type* operator->(); - AST_Type* ast; + Using_CodeOps( CodeTypename ); + operator Code(); + AST_Typename* operator->(); + AST_Typename* ast; }; struct CodeTypedef @@ -1040,7 +1040,7 @@ struct InvalidCode_ImplictCaster operator CodeSpecifiers () const { return cast(CodeSpecifiers, Code_Invalid); } operator CodeStruct () const { return cast(CodeStruct, Code_Invalid); } operator CodeTemplate () const { return cast(CodeTemplate, Code_Invalid); } - operator CodeType () const { return cast(CodeType, Code_Invalid); } + operator CodeTypename () const { return cast(CodeTypename, Code_Invalid); } operator CodeTypedef () const { return cast(CodeTypedef, Code_Invalid); } operator CodeUnion () const { return cast(CodeUnion, Code_Invalid); } operator CodeUsing () const { return cast(CodeUsing, Code_Invalid); } diff --git a/project/components/gen/ast_inlines.hpp b/project/components/gen/ast_inlines.hpp index c9c9519..12174a0 100644 --- a/project/components/gen/ast_inlines.hpp +++ b/project/components/gen/ast_inlines.hpp @@ -661,7 +661,7 @@ inline AST_Template* CodeTemplate::operator->() return ast; } -inline CodeType& CodeType::operator=( Code other ) +inline CodeTypename& CodeTypename::operator=( Code other ) { if ( other.ast && other->Parent ) { @@ -672,17 +672,17 @@ inline CodeType& CodeType::operator=( Code other ) return *this; } -inline CodeType::operator bool() +inline CodeTypename::operator bool() { return ast != nullptr; } -inline CodeType::operator Code() +inline CodeTypename::operator Code() { return *rcast( Code*, this ); } -inline AST_Type* CodeType::operator->() +inline AST_Typename* CodeTypename::operator->() { if ( ast == nullptr ) { @@ -935,9 +935,9 @@ inline Code::operator CodeTemplate() const return { (AST_Template*)ast }; } -inline Code::operator CodeType() const +inline Code::operator CodeTypename() const { - return { (AST_Type*)ast }; + return { (AST_Typename*)ast }; } inline Code::operator CodeTypedef() const diff --git a/project/components/gen/ecode.hpp b/project/components/gen/ecode.hpp index 022cb71..a024735 100644 --- a/project/components/gen/ecode.hpp +++ b/project/components/gen/ecode.hpp @@ -5,140 +5,136 @@ // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) -namespace ECode +typedef enum CodeType_Def CodeType; + +enum CodeType_Def : u32 { - enum Type : u32 - { - Invalid, - Untyped, - NewLine, - Comment, - Access_Private, - Access_Protected, - Access_Public, - PlatformAttributes, - Class, - Class_Fwd, - Class_Body, - Constructor, - Constructor_Fwd, - Destructor, - Destructor_Fwd, - Enum, - Enum_Fwd, - Enum_Body, - Enum_Class, - Enum_Class_Fwd, - Execution, - Export_Body, - Extern_Linkage, - Extern_Linkage_Body, - Friend, - Function, - Function_Fwd, - Function_Body, - Global_Body, - Module, - Namespace, - Namespace_Body, - Operator, - Operator_Fwd, - Operator_Member, - Operator_Member_Fwd, - Operator_Cast, - Operator_Cast_Fwd, - Parameters, - Preprocess_Define, - Preprocess_Include, - Preprocess_If, - Preprocess_IfDef, - Preprocess_IfNotDef, - Preprocess_ElIf, - Preprocess_Else, - Preprocess_EndIf, - Preprocess_Pragma, - Specifiers, - Struct, - Struct_Fwd, - Struct_Body, - Template, - Typedef, - Typename, - Union, - Union_Body, - Using, - Using_Namespace, - Variable, - NumTypes + CT_Invalid, + CT_Untyped, + CT_NewLine, + CT_Comment, + CT_Access_Private, + CT_Access_Protected, + CT_Access_Public, + CT_PlatformAttributes, + CT_Class, + CT_Class_Fwd, + CT_Class_Body, + CT_Constructor, + CT_Constructor_Fwd, + CT_Destructor, + CT_Destructor_Fwd, + CT_Enum, + CT_Enum_Fwd, + CT_Enum_Body, + CT_Enum_Class, + CT_Enum_Class_Fwd, + CT_Execution, + CT_Export_Body, + CT_Extern_Linkage, + CT_Extern_Linkage_Body, + CT_Friend, + CT_Function, + CT_Function_Fwd, + CT_Function_Body, + CT_Global_Body, + CT_Module, + CT_Namespace, + CT_Namespace_Body, + CT_Operator, + CT_Operator_Fwd, + CT_Operator_Member, + CT_Operator_Member_Fwd, + CT_Operator_Cast, + CT_Operator_Cast_Fwd, + CT_Parameters, + CT_Preprocess_Define, + CT_Preprocess_Include, + CT_Preprocess_If, + CT_Preprocess_IfDef, + CT_Preprocess_IfNotDef, + CT_Preprocess_ElIf, + CT_Preprocess_Else, + CT_Preprocess_EndIf, + CT_Preprocess_Pragma, + CT_Specifiers, + CT_Struct, + CT_Struct_Fwd, + CT_Struct_Body, + CT_Template, + CT_Typedef, + CT_Typename, + CT_Union, + CT_Union_Body, + CT_Using, + CT_Using_Namespace, + CT_Variable, + CT_NumTypes +}; + +inline StrC to_str( CodeType type ) +{ + local_persist StrC lookup[] { + { sizeof( "Invalid" ), "Invalid" }, + { sizeof( "Untyped" ), "Untyped" }, + { sizeof( "NewLine" ), "NewLine" }, + { sizeof( "Comment" ), "Comment" }, + { sizeof( "Access_Private" ), "Access_Private" }, + { sizeof( "Access_Protected" ), "Access_Protected" }, + { sizeof( "Access_Public" ), "Access_Public" }, + { sizeof( "PlatformAttributes" ), "PlatformAttributes" }, + { sizeof( "Class" ), "Class" }, + { sizeof( "Class_Fwd" ), "Class_Fwd" }, + { sizeof( "Class_Body" ), "Class_Body" }, + { sizeof( "Constructor" ), "Constructor" }, + { sizeof( "Constructor_Fwd" ), "Constructor_Fwd" }, + { sizeof( "Destructor" ), "Destructor" }, + { sizeof( "Destructor_Fwd" ), "Destructor_Fwd" }, + { sizeof( "Enum" ), "Enum" }, + { sizeof( "Enum_Fwd" ), "Enum_Fwd" }, + { sizeof( "Enum_Body" ), "Enum_Body" }, + { sizeof( "Enum_Class" ), "Enum_Class" }, + { sizeof( "Enum_Class_Fwd" ), "Enum_Class_Fwd" }, + { sizeof( "Execution" ), "Execution" }, + { sizeof( "Export_Body" ), "Export_Body" }, + { sizeof( "Extern_Linkage" ), "Extern_Linkage" }, + { sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" }, + { sizeof( "Friend" ), "Friend" }, + { sizeof( "Function" ), "Function" }, + { sizeof( "Function_Fwd" ), "Function_Fwd" }, + { sizeof( "Function_Body" ), "Function_Body" }, + { sizeof( "Global_Body" ), "Global_Body" }, + { sizeof( "Module" ), "Module" }, + { sizeof( "Namespace" ), "Namespace" }, + { sizeof( "Namespace_Body" ), "Namespace_Body" }, + { sizeof( "Operator" ), "Operator" }, + { sizeof( "Operator_Fwd" ), "Operator_Fwd" }, + { sizeof( "Operator_Member" ), "Operator_Member" }, + { sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" }, + { sizeof( "Operator_Cast" ), "Operator_Cast" }, + { sizeof( "Operator_Cast_Fwd" ), "Operator_Cast_Fwd" }, + { sizeof( "Parameters" ), "Parameters" }, + { sizeof( "Preprocess_Define" ), "Preprocess_Define" }, + { sizeof( "Preprocess_Include" ), "Preprocess_Include" }, + { sizeof( "Preprocess_If" ), "Preprocess_If" }, + { sizeof( "Preprocess_IfDef" ), "Preprocess_IfDef" }, + { sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" }, + { sizeof( "Preprocess_ElIf" ), "Preprocess_ElIf" }, + { sizeof( "Preprocess_Else" ), "Preprocess_Else" }, + { sizeof( "Preprocess_EndIf" ), "Preprocess_EndIf" }, + { sizeof( "Preprocess_Pragma" ), "Preprocess_Pragma" }, + { sizeof( "Specifiers" ), "Specifiers" }, + { sizeof( "Struct" ), "Struct" }, + { sizeof( "Struct_Fwd" ), "Struct_Fwd" }, + { sizeof( "Struct_Body" ), "Struct_Body" }, + { sizeof( "Template" ), "Template" }, + { sizeof( "Typedef" ), "Typedef" }, + { sizeof( "Typename" ), "Typename" }, + { sizeof( "Union" ), "Union" }, + { sizeof( "Union_Body" ), "Union_Body" }, + { sizeof( "Using" ), "Using" }, + { sizeof( "Using_Namespace" ), "Using_Namespace" }, + { sizeof( "Variable" ), "Variable" }, }; - - inline StrC to_str( Type type ) - { - local_persist StrC lookup[] { - { sizeof( "Invalid" ), "Invalid" }, - { sizeof( "Untyped" ), "Untyped" }, - { sizeof( "NewLine" ), "NewLine" }, - { sizeof( "Comment" ), "Comment" }, - { sizeof( "Access_Private" ), "Access_Private" }, - { sizeof( "Access_Protected" ), "Access_Protected" }, - { sizeof( "Access_Public" ), "Access_Public" }, - { sizeof( "PlatformAttributes" ), "PlatformAttributes" }, - { sizeof( "Class" ), "Class" }, - { sizeof( "Class_Fwd" ), "Class_Fwd" }, - { sizeof( "Class_Body" ), "Class_Body" }, - { sizeof( "Constructor" ), "Constructor" }, - { sizeof( "Constructor_Fwd" ), "Constructor_Fwd" }, - { sizeof( "Destructor" ), "Destructor" }, - { sizeof( "Destructor_Fwd" ), "Destructor_Fwd" }, - { sizeof( "Enum" ), "Enum" }, - { sizeof( "Enum_Fwd" ), "Enum_Fwd" }, - { sizeof( "Enum_Body" ), "Enum_Body" }, - { sizeof( "Enum_Class" ), "Enum_Class" }, - { sizeof( "Enum_Class_Fwd" ), "Enum_Class_Fwd" }, - { sizeof( "Execution" ), "Execution" }, - { sizeof( "Export_Body" ), "Export_Body" }, - { sizeof( "Extern_Linkage" ), "Extern_Linkage" }, - { sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" }, - { sizeof( "Friend" ), "Friend" }, - { sizeof( "Function" ), "Function" }, - { sizeof( "Function_Fwd" ), "Function_Fwd" }, - { sizeof( "Function_Body" ), "Function_Body" }, - { sizeof( "Global_Body" ), "Global_Body" }, - { sizeof( "Module" ), "Module" }, - { sizeof( "Namespace" ), "Namespace" }, - { sizeof( "Namespace_Body" ), "Namespace_Body" }, - { sizeof( "Operator" ), "Operator" }, - { sizeof( "Operator_Fwd" ), "Operator_Fwd" }, - { sizeof( "Operator_Member" ), "Operator_Member" }, - { sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" }, - { sizeof( "Operator_Cast" ), "Operator_Cast" }, - { sizeof( "Operator_Cast_Fwd" ), "Operator_Cast_Fwd" }, - { sizeof( "Parameters" ), "Parameters" }, - { sizeof( "Preprocess_Define" ), "Preprocess_Define" }, - { sizeof( "Preprocess_Include" ), "Preprocess_Include" }, - { sizeof( "Preprocess_If" ), "Preprocess_If" }, - { sizeof( "Preprocess_IfDef" ), "Preprocess_IfDef" }, - { sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" }, - { sizeof( "Preprocess_ElIf" ), "Preprocess_ElIf" }, - { sizeof( "Preprocess_Else" ), "Preprocess_Else" }, - { sizeof( "Preprocess_EndIf" ), "Preprocess_EndIf" }, - { sizeof( "Preprocess_Pragma" ), "Preprocess_Pragma" }, - { sizeof( "Specifiers" ), "Specifiers" }, - { sizeof( "Struct" ), "Struct" }, - { sizeof( "Struct_Fwd" ), "Struct_Fwd" }, - { sizeof( "Struct_Body" ), "Struct_Body" }, - { sizeof( "Template" ), "Template" }, - { sizeof( "Typedef" ), "Typedef" }, - { sizeof( "Typename" ), "Typename" }, - { sizeof( "Union" ), "Union" }, - { sizeof( "Union_Body" ), "Union_Body" }, - { sizeof( "Using" ), "Using" }, - { sizeof( "Using_Namespace" ), "Using_Namespace" }, - { sizeof( "Variable" ), "Variable" }, - }; - return lookup[type]; - } - -} // namespace ECode - -using CodeT = ECode::Type; + return lookup[type]; +} diff --git a/project/components/header_end.hpp b/project/components/header_end.hpp index 193288c..4529bc7 100644 --- a/project/components/header_end.hpp +++ b/project/components/header_end.hpp @@ -97,36 +97,36 @@ extern CodeSpecifiers spec_thread_local; extern CodeSpecifiers spec_virtual; extern CodeSpecifiers spec_volatile; -extern CodeType t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance) -extern CodeType t_auto; -extern CodeType t_void; -extern CodeType t_int; -extern CodeType t_bool; -extern CodeType t_char; -extern CodeType t_wchar_t; -extern CodeType t_class; -extern CodeType t_typename; +extern CodeTypename t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance) +extern CodeTypename t_auto; +extern CodeTypename t_void; +extern CodeTypename t_int; +extern CodeTypename t_bool; +extern CodeTypename t_char; +extern CodeTypename t_wchar_t; +extern CodeTypename t_class; +extern CodeTypename t_typename; #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS // Predefined typename codes. Are set to readonly and are setup during gen::init() - extern CodeType t_b32; + extern CodeTypename t_b32; - extern CodeType t_s8; - extern CodeType t_s16; - extern CodeType t_s32; - extern CodeType t_s64; + extern CodeTypename t_s8; + extern CodeTypename t_s16; + extern CodeTypename t_s32; + extern CodeTypename t_s64; - extern CodeType t_u8; - extern CodeType t_u16; - extern CodeType t_u32; - extern CodeType t_u64; + extern CodeTypename t_u8; + extern CodeTypename t_u16; + extern CodeTypename t_u32; + extern CodeTypename t_u64; - extern CodeType t_ssize; - extern CodeType t_usize; + extern CodeTypename t_ssize; + extern CodeTypename t_usize; - extern CodeType t_f32; - extern CodeType t_f64; + extern CodeTypename t_f32; + extern CodeTypename t_f64; #endif #pragma endregion Constants diff --git a/project/components/inlines.hpp b/project/components/inlines.hpp index 80d4b86..eff9d64 100644 --- a/project/components/inlines.hpp +++ b/project/components/inlines.hpp @@ -37,15 +37,15 @@ bool is_body(Code self) GEN_ASSERT(self != nullptr); switch (self->Type) { - case ECode::Enum_Body: - case ECode::Class_Body: - case ECode::Union_Body: - case ECode::Export_Body: - case ECode::Global_Body: - case ECode::Struct_Body: - case ECode::Function_Body: - case ECode::Namespace_Body: - case ECode::Extern_Linkage_Body: + case CT_Enum_Body: + case CT_Class_Body: + case CT_Union_Body: + case CT_Export_Body: + case CT_Global_Body: + case CT_Struct_Body: + case CT_Function_Body: + case CT_Namespace_Body: + case CT_Extern_Linkage_Body: return true; } return false; @@ -69,7 +69,7 @@ Code* entry( Code self, u32 idx ) inline bool is_valid(Code self) { - return self.ast != nullptr && self.ast->Type != CodeT::Invalid; + return self.ast != nullptr && self.ast->Type != CT_Invalid; } inline bool has_entries(AST* self) @@ -100,7 +100,7 @@ inline char const* type_str(Code self) { GEN_ASSERT(self != nullptr); - return ECode::to_str( self->Type ); + return to_str( self->Type ); } #pragma endregion Code @@ -140,10 +140,10 @@ Code end(CodeBody body ){ #pragma region CodeClass inline -void add_interface( CodeClass self, CodeType type ) +void add_interface( CodeClass self, CodeTypename type ) { GEN_ASSERT(self.ast !=nullptr); - CodeType possible_slot = self->ParentType; + CodeTypename possible_slot = self->ParentType; if ( possible_slot.ast ) { // Were adding an interface to parent type, so we need to make sure the parent type is public. @@ -154,7 +154,7 @@ void add_interface( CodeClass self, CodeType type ) while ( possible_slot.ast != nullptr ) { - possible_slot.ast = (AST_Type*) possible_slot->Next.ast; + possible_slot.ast = (AST_Typename*) possible_slot->Next.ast; } possible_slot.ast = type.ast; @@ -317,9 +317,9 @@ Specifier* end(CodeSpecifiers self) #pragma region CodeStruct inline -void add_interface(CodeStruct self, CodeType type ) +void add_interface(CodeStruct self, CodeTypename type ) { - CodeType possible_slot = self->ParentType; + CodeTypename possible_slot = self->ParentType; if ( possible_slot.ast ) { // Were adding an interface to parent type, so we need to make sure the parent type is public. @@ -330,7 +330,7 @@ void add_interface(CodeStruct self, CodeType type ) while ( possible_slot.ast != nullptr ) { - possible_slot.ast = (AST_Type*) possible_slot->Next.ast; + possible_slot.ast = (AST_Typename*) possible_slot->Next.ast; } possible_slot.ast = type.ast; @@ -339,24 +339,23 @@ void add_interface(CodeStruct self, CodeType type ) #pragma region Interface inline -CodeBody def_body( CodeT type ) +CodeBody def_body( CodeType type ) { switch ( type ) { - using namespace ECode; - case Class_Body: - case Enum_Body: - case Export_Body: - case Extern_Linkage: - case Function_Body: - case Global_Body: - case Namespace_Body: - case Struct_Body: - case Union_Body: + case CT_Class_Body: + case CT_Enum_Body: + case CT_Export_Body: + case CT_Extern_Linkage: + case CT_Function_Body: + case CT_Global_Body: + case CT_Namespace_Body: + case CT_Struct_Body: + case CT_Union_Body: break; default: - log_failure( "def_body: Invalid type %s", (char const*)ECode::to_str(type) ); + log_failure( "def_body: Invalid type %s", (char const*)to_str(type) ); return (CodeBody)Code_Invalid; } diff --git a/project/components/interface.cpp b/project/components/interface.cpp index c200fad..b0ece77 100644 --- a/project/components/interface.cpp +++ b/project/components/interface.cpp @@ -81,23 +81,23 @@ void define_constants() Code_Invalid = make_code(); set_global(Code_Invalid); - t_empty = (CodeType) make_code(); - t_empty->Type = ECode::Typename; + t_empty = (CodeTypename) make_code(); + t_empty->Type = CT_Typename; t_empty->Name = get_cached_string( txt("") ); set_global(t_empty); access_private = make_code(); - access_private->Type = ECode::Access_Private; + access_private->Type = CT_Access_Private; access_private->Name = get_cached_string( txt("private:\n") ); set_global(access_private); access_protected = make_code(); - access_protected->Type = ECode::Access_Protected; + access_protected->Type = CT_Access_Protected; access_protected->Name = get_cached_string( txt("protected:\n") ); set_global(access_protected); access_public = make_code(); - access_public->Type = ECode::Access_Public; + access_public->Type = CT_Access_Public; access_public->Name = get_cached_string( txt("public:\n") ); set_global(access_public); @@ -108,39 +108,39 @@ void define_constants() set_global(attrib_api_import); module_global_fragment = make_code(); - module_global_fragment->Type = ECode::Untyped; + module_global_fragment->Type = CT_Untyped; module_global_fragment->Name = get_cached_string( txt("module;") ); module_global_fragment->Content = module_global_fragment->Name; set_global(module_global_fragment); module_private_fragment = make_code(); - module_private_fragment->Type = ECode::Untyped; + module_private_fragment->Type = CT_Untyped; module_private_fragment->Name = get_cached_string( txt("module : private;") ); module_private_fragment->Content = module_private_fragment->Name; set_global(module_private_fragment); fmt_newline = make_code(); - fmt_newline->Type = ECode::NewLine; + fmt_newline->Type = CT_NewLine; set_global(fmt_newline); pragma_once = (CodePragma) make_code(); - pragma_once->Type = ECode::Preprocess_Pragma; + pragma_once->Type = CT_Preprocess_Pragma; pragma_once->Name = get_cached_string( txt("once") ); pragma_once->Content = pragma_once->Name; set_global(pragma_once); - param_varadic = (CodeType) make_code(); - param_varadic->Type = ECode::Parameters; + param_varadic = (CodeTypename) make_code(); + param_varadic->Type = CT_Parameters; param_varadic->Name = get_cached_string( txt("...") ); param_varadic->ValueType = t_empty; set_global(param_varadic); preprocess_else = (CodePreprocessCond) make_code(); - preprocess_else->Type = ECode::Preprocess_Else; + preprocess_else->Type = CT_Preprocess_Else; set_global(preprocess_else); preprocess_endif = (CodePreprocessCond) make_code(); - preprocess_endif->Type = ECode::Preprocess_EndIf; + preprocess_endif->Type = CT_Preprocess_EndIf; set_global(preprocess_endif); # define def_constant_code_type( Type_ ) \ diff --git a/project/components/interface.hpp b/project/components/interface.hpp index 8a03605..29895c6 100644 --- a/project/components/interface.hpp +++ b/project/components/interface.hpp @@ -44,11 +44,11 @@ CodeComment def_comment ( StrC content ); struct Opts_def_struct { Code body; - CodeType parent; + CodeTypename parent; AccessSpec parent_access; CodeAttributes attributes; ModuleFlag mflags; - CodeType* interfaces; + CodeTypename* interfaces; s32 num_interfaces; }; CodeClass def_class( StrC name, Opts_def_struct otps GEN_PARAM_DEFAULT ); @@ -70,7 +70,7 @@ CodeDestructor def_destructor( Opts_def_destructor opts GEN_PARAM_DEFAULT ); struct Opts_def_enum { Code body; - CodeType type; + CodeTypename type; EnumT specifier; CodeAttributes attributes; ModuleFlag mflags; @@ -83,7 +83,7 @@ CodeFriend def_friend ( Code symbol ); struct Opts_def_function { CodeParam params; - CodeType ret_type; + CodeTypename ret_type; Code body; CodeSpecifiers specs; CodeAttributes attrs; @@ -100,7 +100,7 @@ CodeNS def_namespace( StrC name, Code body, Opts_def_namespace opts GEN_PAR struct Opts_def_operator { CodeParam params; - CodeType ret_type; + CodeTypename ret_type; Code body; CodeSpecifiers specifiers; CodeAttributes attributes; @@ -112,10 +112,10 @@ struct Opts_def_operator_cast { Code body; CodeSpecifiers specs; }; -CodeOpCast def_operator_cast( CodeType type, Opts_def_operator_cast opts GEN_PARAM_DEFAULT ); +CodeOpCast def_operator_cast( CodeTypename type, Opts_def_operator_cast opts GEN_PARAM_DEFAULT ); struct Opts_def_param { Code value; }; -CodeParam def_param ( CodeType type, StrC name, Opts_def_param opts GEN_PARAM_DEFAULT ); +CodeParam def_param ( CodeTypename type, StrC name, Opts_def_param opts GEN_PARAM_DEFAULT ); CodePragma def_pragma( StrC directive ); CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content ); @@ -132,7 +132,7 @@ struct Opts_def_type { CodeSpecifiers specifiers; CodeAttributes attributes; }; -CodeType def_type( StrC name, Opts_def_type opts GEN_PARAM_DEFAULT ); +CodeTypename def_type( StrC name, Opts_def_type opts GEN_PARAM_DEFAULT ); struct Opts_def_typedef { CodeAttributes attributes; @@ -161,10 +161,10 @@ struct Opts_def_variable CodeAttributes attributes; ModuleFlag mflags; }; -CodeVar def_variable( CodeType type, StrC name, Opts_def_variable opts GEN_PARAM_DEFAULT ); +CodeVar def_variable( CodeTypename type, StrC name, Opts_def_variable opts GEN_PARAM_DEFAULT ); // Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries. -CodeBody def_body( CodeT type ); +CodeBody def_body( CodeTypename type ); // There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num, /// or provide as an array of Code objects. @@ -246,7 +246,7 @@ CodeOperator parse_operator ( StrC operator_def ); CodeOpCast parse_operator_cast( StrC operator_def ); CodeStruct parse_struct ( StrC struct_def ); CodeTemplate parse_template ( StrC template_def ); -CodeType parse_type ( StrC type_def ); +CodeTypename parse_type ( StrC type_def ); CodeTypedef parse_typedef ( StrC typedef_def ); CodeUnion parse_union ( StrC union_def ); CodeUsing parse_using ( StrC using_def ); diff --git a/project/components/interface.parsing.cpp b/project/components/interface.parsing.cpp index e50a39c..112c622 100644 --- a/project/components/interface.parsing.cpp +++ b/project/components/interface.parsing.cpp @@ -180,7 +180,7 @@ CodeBody parse_global_body( StrC def ) Context.Tokens = toks; push_scope(); - CodeBody result = parse_global_nspace( ECode::Global_Body ); + CodeBody result = parse_global_nspace( CT_Global_Body ); pop(& Context); return result; } @@ -253,7 +253,7 @@ CodeTemplate parse_template( StrC def ) return parse_template(); } -CodeType parse_type( StrC def ) +CodeTypename parse_type( StrC def ) { GEN_USING_NS_PARSER; check_parse_args( def ); diff --git a/project/components/interface.untyped.cpp b/project/components/interface.untyped.cpp index f8beb4c..6e6e9d6 100644 --- a/project/components/interface.untyped.cpp +++ b/project/components/interface.untyped.cpp @@ -112,7 +112,7 @@ Code untyped_str( StrC content ) Code result = make_code(); result->Name = get_cached_string( content ); - result->Type = ECode::Untyped; + result->Type = CT_Untyped; result->Content = result->Name; if ( result->Name == nullptr ) @@ -143,7 +143,7 @@ Code untyped_fmt( char const* fmt, ...) Code result = make_code(); result->Name = get_cached_string( { str_len(fmt, MaxNameLength), fmt } ); - result->Type = ECode::Untyped; + result->Type = CT_Untyped; result->Content = get_cached_string( { length, buf } ); if ( result->Name == nullptr ) @@ -174,7 +174,7 @@ Code untyped_token_fmt( s32 num_tokens, ... ) Code result = make_code(); result->Name = get_cached_string( { length, buf } ); - result->Type = ECode::Untyped; + result->Type = CT_Untyped; result->Content = result->Name; if ( result->Name == nullptr ) diff --git a/project/components/interface.upfront.cpp b/project/components/interface.upfront.cpp index e3c86ef..55bfc75 100644 --- a/project/components/interface.upfront.cpp +++ b/project/components/interface.upfront.cpp @@ -5,19 +5,19 @@ #pragma region Upfront -enum class OpValidateResult : u32 +enum OpValidateResult : u32 { - Fail, - Global, - Member + OpValResult_Fail, + OpValResult_Global, + OpValResult_Member }; -OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeType ret_type, CodeSpecifiers specifier ) +OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTypename ret_type, CodeSpecifiers specifier ) { if ( op == Op_Invalid ) { log_failure("gen::def_operator: op cannot be invalid"); - return OpValidateResult::Fail; + return OpValResult_Fail; } #pragma region Helper Macros @@ -25,12 +25,12 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp if ( ! params_code ) \ { \ log_failure("gen::def_operator: params is null and operator%s requires it", to_str(op)); \ - return OpValidateResult::Fail; \ + return OpValResult_Fail; \ } \ - if ( params_code->Type != ECode::Parameters ) \ + if ( params_code->Type != CT_Parameters ) \ { \ - log_failure("gen::def_operator: params is not of Parameters type - %s", debug_str(params_code)); \ - return OpValidateResult::Fail; \ + log_failure("gen::def_operator: params is not of Parameters type - %s", debug_str(params_code)); \ + return OpValResult_Fail; \ } # define check_param_eq_ret() \ @@ -40,10 +40,10 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp "param types: %s\n" \ "return type: %s", \ to_str(op).Ptr, \ - debug_str(params_code), \ - debug_str(ret_type) \ + debug_str(params_code), \ + debug_str(ret_type) \ ); \ - return OpValidateResult::Fail; \ + return OpValResult_Fail; \ } #pragma endregion Helper Macros @@ -52,10 +52,10 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp log_failure("gen::def_operator: ret_type is null but is required by operator%s", to_str(op)); } - if ( ret_type->Type != ECode::Typename ) + if ( ret_type->Type != CT_Typename ) { log_failure("gen::def_operator: ret_type is not of typename type - %s", debug_str(ret_type)); - return OpValidateResult::Fail; + return OpValResult_Fail; } bool is_member_symbol = false; @@ -73,7 +73,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp to_str(op), debug_str(params_code) ); - return OpValidateResult::Fail; + return OpValResult_Fail; } is_member_symbol = true; @@ -104,7 +104,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , params_code->NumEntries , debug_str(params_code) ); - return OpValidateResult::Fail; + return OpValResult_Fail; } break; @@ -113,13 +113,13 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp // If its not set, it just means its a prefix member op. if ( params_code ) { - if ( params_code->Type != ECode::Parameters ) + if ( params_code->Type != CT_Parameters ) { log_failure("gen::def_operator: operator%s params code provided is not of Parameters type - %s" , to_str(op) , debug_str(params_code) ); - return OpValidateResult::Fail; + return OpValResult_Fail; } switch ( params_code->NumEntries ) @@ -141,7 +141,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp "operator%s requires second parameter of non-member definition to be int for post-decrement", to_str(op) ); - return OpValidateResult::Fail; + return OpValResult_Fail; } break; @@ -150,7 +150,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , to_str(op) , params_code->NumEntries ); - return OpValidateResult::Fail; + return OpValResult_Fail; } } break; @@ -162,10 +162,10 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp else { - if ( params_code->Type != ECode::Parameters ) + if ( params_code->Type != CT_Parameters ) { log_failure("gen::def_operator: params is not of Parameters type - %s", debug_str(params_code)); - return OpValidateResult::Fail; + return OpValResult_Fail; } if ( is_equal(params_code->ValueType, ret_type ) ) @@ -177,7 +177,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , debug_str(params_code) , debug_str(ret_type) ); - return OpValidateResult::Fail; + return OpValResult_Fail; } if ( params_code->NumEntries > 1 ) @@ -186,7 +186,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , to_str(op) , params_code->NumEntries ); - return OpValidateResult::Fail; + return OpValResult_Fail; } } break; @@ -207,10 +207,10 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp else { - if ( params_code->Type != ECode::Parameters ) + if ( params_code->Type != CT_Parameters ) { log_failure( "gen::def_operator: params is not of Parameters type - %s", debug_str(params_code) ); - return OpValidateResult::Fail; + return OpValResult_Fail; } if ( params_code->NumEntries > 1 ) @@ -220,7 +220,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp to_str( op ), params_code->NumEntries ); - return OpValidateResult::Fail; + return OpValResult_Fail; } } break; @@ -254,7 +254,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , debug_str(params_code) , debug_str(ret_type) ); - return OpValidateResult::Fail; + return OpValResult_Fail; } break; @@ -263,7 +263,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , to_str(op) , params_code->NumEntries ); - return OpValidateResult::Fail; + return OpValResult_Fail; } break; @@ -273,10 +273,10 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp else { - if ( params_code->Type != ECode::Parameters ) + if ( params_code->Type != CT_Parameters ) { log_failure("gen::def_operator: params is not of Parameters type - %s", debug_str(params_code)); - return OpValidateResult::Fail; + return OpValResult_Fail; } if ( params_code->NumEntries != 1 ) @@ -285,7 +285,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , to_str(op) , params_code->NumEntries ); - return OpValidateResult::Fail; + return OpValResult_Fail; } } @@ -295,7 +295,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , to_str(op) , debug_str(ret_type) ); - return OpValidateResult::Fail; + return OpValResult_Fail; } break; @@ -323,7 +323,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , to_str(op) , params_code->NumEntries ); - return OpValidateResult::Fail; + return OpValResult_Fail; } break; @@ -336,7 +336,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp , to_str(op) , params_code->NumEntries ); - return OpValidateResult::Fail; + return OpValResult_Fail; } else { @@ -348,7 +348,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp if ( params_code ) { log_failure("gen::def_operator: operator%s expects no paramters - %s", to_str(op), debug_str(params_code)); - return OpValidateResult::Fail; + return OpValResult_Fail; } break; @@ -365,7 +365,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp # undef specs } - return is_member_symbol ? OpValidateResult::Member : OpValidateResult::Global; + return is_member_symbol ? OpValResult_Member : OpValResult_Global; # undef check_params # undef check_ret_type # undef check_param_eq_ret @@ -439,7 +439,7 @@ CodeAttributes def_attributes( StrC content ) Code result = make_code(); - result->Type = ECode::PlatformAttributes; + result->Type = CT_PlatformAttributes; result->Name = get_cached_string( content ); result->Content = result->Name; @@ -484,7 +484,7 @@ CodeComment def_comment( StrC content ) Code result = make_code(); - result->Type = ECode::Comment; + result->Type = CT_Comment; result->Name = get_cached_string( cmt_formatted ); result->Content = result->Name; @@ -499,7 +499,7 @@ CodeConstructor def_constructor( Opts_def_constructor p ) Code initializer_list = p.initializer_list; Code body = p.body; - if ( params && params->Type != ECode::Parameters ) + if ( params && params->Type != CT_Parameters ) { log_failure("gen::def_constructor: params must be of Parameters type - %s", debug_str(params)); return InvalidCode; @@ -522,8 +522,8 @@ CodeConstructor def_constructor( Opts_def_constructor p ) { switch ( body->Type ) { - case ECode::Function_Body: - case ECode::Untyped: + case CT_Function_Body: + case CT_Untyped: break; default: @@ -531,12 +531,12 @@ CodeConstructor def_constructor( Opts_def_constructor p ) return InvalidCode; } - result->Type = ECode::Constructor; + result->Type = CT_Constructor; result->Body = body; } else { - result->Type = ECode::Constructor_Fwd; + result->Type = CT_Constructor_Fwd; } return result; @@ -547,20 +547,20 @@ CodeClass def_class( StrC name, Opts_def_struct p ) name_check( def_class, name ); Code body = p.body; - CodeType parent = p.parent; + CodeTypename parent = p.parent; AccessSpec parent_access = p.parent_access; CodeAttributes attributes = p.attributes; ModuleFlag mflags = p.mflags; - CodeType* interfaces = p.interfaces; + CodeTypename* interfaces = p.interfaces; s32 num_interfaces = p.num_interfaces; - if ( attributes && attributes->Type != ECode::PlatformAttributes ) + if ( attributes && attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", debug_str(attributes) ); return InvalidCode; } - if ( parent && ( parent->Type != ECode::Class && parent->Type != ECode::Struct && parent->Type != ECode::Typename && parent->Type != ECode::Untyped ) ) + if ( parent && ( parent->Type != CT_Class && parent->Type != CT_Struct && parent->Type != CT_Typename && parent->Type != CT_Untyped ) ) { log_failure( "gen::def_class: parent provided is not type 'Class', 'Struct', 'Typeanme', or 'Untyped': %s", debug_str(parent) ); return InvalidCode; @@ -575,8 +575,8 @@ CodeClass def_class( StrC name, Opts_def_struct p ) { switch ( body->Type ) { - case ECode::Class_Body: - case ECode::Untyped: + case CT_Class_Body: + case CT_Untyped: break; default: @@ -584,13 +584,13 @@ CodeClass def_class( StrC name, Opts_def_struct p ) return InvalidCode; } - result->Type = ECode::Class; + result->Type = CT_Class; result->Body = body; result->Body->Parent = result; // TODO(Ed): Review this? } else { - result->Type = ECode::Class_Fwd; + result->Type = CT_Class_Fwd; } if ( attributes ) @@ -628,7 +628,7 @@ CodeDefine def_define( StrC name, StrC content ) CodeDefine result = (CodeDefine) make_code(); - result->Type = ECode::Preprocess_Define; + result->Type = CT_Preprocess_Define; result->Name = get_cached_string( name ); if ( content.Len <= 0 || content.Ptr == nullptr ) { @@ -645,7 +645,7 @@ CodeDestructor def_destructor( Opts_def_destructor p ) Code body = p.body; CodeSpecifiers specifiers = p.specifiers; - if ( specifiers && specifiers->Type != ECode::Specifiers ) + if ( specifiers && specifiers->Type != CT_Specifiers ) { log_failure( "gen::def_destructor: specifiers was not a 'Specifiers' type: %s", debug_str(specifiers) ); return InvalidCode; @@ -660,8 +660,8 @@ CodeDestructor def_destructor( Opts_def_destructor p ) { switch ( body->Type ) { - case ECode::Function_Body: - case ECode::Untyped: + case CT_Function_Body: + case CT_Untyped: break; default: @@ -669,12 +669,12 @@ CodeDestructor def_destructor( Opts_def_destructor p ) return InvalidCode; } - result->Type = ECode::Destructor; + result->Type = CT_Destructor; result->Body = body; } else { - result->Type = ECode::Destructor_Fwd; + result->Type = CT_Destructor_Fwd; } return result; @@ -683,20 +683,20 @@ CodeDestructor def_destructor( Opts_def_destructor p ) CodeEnum def_enum( StrC name, Opts_def_enum p ) { Code body = p.body; - CodeType type = p.type; + CodeTypename type = p.type; EnumT specifier = p.specifier; CodeAttributes attributes = p.attributes; ModuleFlag mflags = p.mflags; name_check( def_enum, name ); - if ( type && type->Type != ECode::Typename ) + if ( type && type->Type != CT_Typename ) { log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", debug_str(type) ); return InvalidCode; } - if ( attributes && attributes->Type != ECode::PlatformAttributes ) + if ( attributes && attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", debug_str(attributes) ); return InvalidCode; @@ -711,8 +711,8 @@ CodeEnum def_enum( StrC name, Opts_def_enum p ) { switch ( body->Type ) { - case ECode::Enum_Body: - case ECode::Untyped: + case CT_Enum_Body: + case CT_Untyped: break; default: @@ -721,14 +721,14 @@ CodeEnum def_enum( StrC name, Opts_def_enum p ) } result->Type = specifier == EnumDecl_Class ? - ECode::Enum_Class : ECode::Enum; + CT_Enum_Class : CT_Enum; result->Body = body; } else { result->Type = specifier == EnumDecl_Class ? - ECode::Enum_Class_Fwd : ECode::Enum_Fwd; + CT_Enum_Class_Fwd : CT_Enum_Fwd; } if ( attributes ) @@ -738,7 +738,7 @@ CodeEnum def_enum( StrC name, Opts_def_enum p ) { result->UnderlyingType = type; } - else if ( result->Type != ECode::Enum_Class_Fwd && result->Type != ECode::Enum_Fwd ) + else if ( result->Type != CT_Enum_Class_Fwd && result->Type != CT_Enum_Fwd ) { log_failure( "gen::def_enum: enum forward declaration must have an underlying type" ); return InvalidCode; @@ -757,7 +757,7 @@ CodeExec def_execution( StrC content ) Code result = make_code(); - result->Type = ECode::Execution; + result->Type = CT_Execution; result->Name = get_cached_string( content ); result->Content = result->Name; @@ -769,7 +769,7 @@ CodeExtern def_extern_link( StrC name, Code body ) name_check( def_extern_linkage, name ); null_check( def_extern_linkage, body ); - if ( body->Type != ECode::Extern_Linkage_Body && body->Type != ECode::Untyped ) + if ( body->Type != CT_Extern_Linkage_Body && body->Type != CT_Untyped ) { log_failure("gen::def_extern_linkage: body is not of extern_linkage or untyped type %s", debug_str(body)); return InvalidCode; @@ -777,7 +777,7 @@ CodeExtern def_extern_link( StrC name, Code body ) CodeExtern result = (CodeExtern)make_code(); - result->Type = ECode::Extern_Linkage; + result->Type = CT_Extern_Linkage; result->Name = get_cached_string( name ); result->Body = body; @@ -790,14 +790,14 @@ CodeFriend def_friend( Code declaration ) switch ( declaration->Type ) { - case ECode::Class_Fwd: - case ECode::Function_Fwd: - case ECode::Operator_Fwd: - case ECode::Struct_Fwd: - case ECode::Class: - case ECode::Function: - case ECode::Operator: - case ECode::Struct: + case CT_Class_Fwd: + case CT_Function_Fwd: + case CT_Operator_Fwd: + case CT_Struct_Fwd: + case CT_Class: + case CT_Function: + case CT_Operator: + case CT_Struct: break; default: @@ -807,7 +807,7 @@ CodeFriend def_friend( Code declaration ) CodeFriend result = (CodeFriend) make_code(); - result->Type = ECode::Friend; + result->Type = CT_Friend; result->Declaration = declaration; @@ -817,7 +817,7 @@ CodeFriend def_friend( Code declaration ) CodeFn def_function( StrC name, Opts_def_function p ) { CodeParam params = p.params; - CodeType ret_type = p.ret_type; + CodeTypename ret_type = p.ret_type; Code body = p.body; CodeSpecifiers specifiers = p.specs; CodeAttributes attributes = p.attrs; @@ -825,25 +825,25 @@ CodeFn def_function( StrC name, Opts_def_function p ) name_check( def_function, name ); - if ( params && params->Type != ECode::Parameters ) + if ( params && params->Type != CT_Parameters ) { log_failure( "gen::def_function: params was not a `Parameters` type: %s", debug_str(params) ); return InvalidCode; } - if ( ret_type && ret_type->Type != ECode::Typename ) + if ( ret_type && ret_type->Type != CT_Typename ) { log_failure( "gen::def_function: ret_type was not a Typename: %s", debug_str(ret_type) ); return InvalidCode; } - if ( specifiers && specifiers->Type != ECode::Specifiers ) + if ( specifiers && specifiers->Type != CT_Specifiers ) { log_failure( "gen::def_function: specifiers was not a `Specifiers` type: %s", debug_str(specifiers) ); return InvalidCode; } - if ( attributes && attributes->Type != ECode::PlatformAttributes ) + if ( attributes && attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", debug_str(attributes) ); return InvalidCode; @@ -858,9 +858,9 @@ CodeFn def_function( StrC name, Opts_def_function p ) { switch ( body->Type ) { - case ECode::Function_Body: - case ECode::Execution: - case ECode::Untyped: + case CT_Function_Body: + case CT_Execution: + case CT_Untyped: break; default: @@ -870,12 +870,12 @@ CodeFn def_function( StrC name, Opts_def_function p ) } } - result->Type = ECode::Function; + result->Type = CT_Function; result->Body = body; } else { - result->Type = ECode::Function_Fwd; + result->Type = CT_Function_Fwd; } if ( attributes ) @@ -913,7 +913,7 @@ CodeInclude def_include( StrC path, Opts_def_include p ) Code result = make_code(); - result->Type = ECode::Preprocess_Include; + result->Type = CT_Preprocess_Include; result->Name = get_cached_string( content ); result->Content = result->Name; @@ -926,7 +926,7 @@ CodeModule def_module( StrC name, Opts_def_module p ) Code result = make_code(); - result->Type = ECode::Module; + result->Type = CT_Module; result->Name = get_cached_string( name ); result->Content = result->Name; result->ModuleFlags = p.mflags; @@ -939,7 +939,7 @@ CodeNS def_namespace( StrC name, Code body, Opts_def_namespace p ) name_check( def_namespace, name ); null_check( def_namespace, body); - if ( body && body->Type != ECode::Namespace_Body && body->Type != ECode::Untyped ) + if ( body && body->Type != CT_Namespace_Body && body->Type != CT_Untyped ) { log_failure("gen::def_namespace: body is not of namespace or untyped type %s", debug_str(body)); return InvalidCode; @@ -947,7 +947,7 @@ CodeNS def_namespace( StrC name, Code body, Opts_def_namespace p ) CodeNS result = (CodeNS) make_code(); - result->Type = ECode::Namespace; + result->Type = CT_Namespace; result->Name = get_cached_string( name ); result->ModuleFlags = p.mflags; result->Body = body; @@ -957,19 +957,19 @@ CodeNS def_namespace( StrC name, Code body, Opts_def_namespace p ) CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator p ) { CodeParam params_code = p.params; - CodeType ret_type = p.ret_type; + CodeTypename ret_type = p.ret_type; Code body = p.body; CodeSpecifiers specifiers = p.specifiers; CodeAttributes attributes = p.attributes; ModuleFlag mflags = p.mflags; - if ( attributes && attributes->Type != ECode::PlatformAttributes ) + if ( attributes && attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", debug_str(attributes) ); return InvalidCode; } - if ( specifiers && specifiers->Type != ECode::Specifiers ) + if ( specifiers && specifiers->Type != CT_Specifiers ) { log_failure( "gen::def_operator: Specifiers was provided but its not of specifiers type: %s", debug_str(specifiers) ); return InvalidCode; @@ -977,7 +977,7 @@ CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator p ) OpValidateResult check_result = operator__validate( op, params_code, ret_type, specifiers ); - if ( check_result == OpValidateResult::Fail ) + if ( check_result == OpValResult_Fail ) { return InvalidCode; } @@ -999,9 +999,9 @@ CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator p ) { switch ( body->Type ) { - case ECode::Function_Body: - case ECode::Execution: - case ECode::Untyped: + case CT_Function_Body: + case CT_Execution: + case CT_Untyped: break; default: @@ -1011,15 +1011,15 @@ CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator p ) } } - result->Type = check_result == OpValidateResult::Global ? - ECode::Operator : ECode::Operator_Member; + result->Type = check_result == OpValResult_Global ? + CT_Operator : CT_Operator_Member; result->Body = body; } else { - result->Type = check_result == OpValidateResult::Global ? - ECode::Operator_Fwd : ECode::Operator_Member_Fwd; + result->Type = check_result == OpValResult_Global ? + CT_Operator_Fwd : CT_Operator_Member_Fwd; } if ( attributes ) @@ -1036,14 +1036,14 @@ CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator p ) return result; } -CodeOpCast def_operator_cast( CodeType type, Opts_def_operator_cast p ) +CodeOpCast def_operator_cast( CodeTypename type, Opts_def_operator_cast p ) { Code body = p.body; CodeSpecifiers const_spec = p.specs; null_check( def_operator_cast, type ); - if ( type->Type != ECode::Typename ) + if ( type->Type != CT_Typename ) { log_failure( "gen::def_operator_cast: type is not a typename - %s", debug_str(type) ); return InvalidCode; @@ -1053,9 +1053,9 @@ CodeOpCast def_operator_cast( CodeType type, Opts_def_operator_cast p ) if (body) { - result->Type = ECode::Operator_Cast; + result->Type = CT_Operator_Cast; - if ( body->Type != ECode::Function_Body && body->Type != ECode::Execution ) + if ( body->Type != CT_Function_Body && body->Type != CT_Execution ) { log_failure( "gen::def_operator_cast: body is not of function body or execution type - %s", debug_str(body) ); return InvalidCode; @@ -1065,7 +1065,7 @@ CodeOpCast def_operator_cast( CodeType type, Opts_def_operator_cast p ) } else { - result->Type = ECode::Operator_Cast_Fwd; + result->Type = CT_Operator_Cast_Fwd; } if ( const_spec ) @@ -1077,18 +1077,18 @@ CodeOpCast def_operator_cast( CodeType type, Opts_def_operator_cast p ) return result; } -CodeParam def_param( CodeType type, StrC name, Opts_def_param p ) +CodeParam def_param( CodeTypename type, StrC name, Opts_def_param p ) { name_check( def_param, name ); null_check( def_param, type ); - if ( type->Type != ECode::Typename ) + if ( type->Type != CT_Typename ) { log_failure( "gen::def_param: type is not a typename - %s", debug_str(type) ); return InvalidCode; } - if ( p.value && p.value->Type != ECode::Untyped ) + if ( p.value && p.value->Type != CT_Untyped ) { log_failure( "gen::def_param: value is not untyped - %s", debug_str(p.value) ); return InvalidCode; @@ -1096,7 +1096,7 @@ CodeParam def_param( CodeType type, StrC name, Opts_def_param p ) CodeParam result = (CodeParam) make_code(); - result->Type = ECode::Parameters; + result->Type = CT_Parameters; result->Name = get_cached_string( name ); result->ValueType = type; @@ -1119,7 +1119,7 @@ CodePragma def_pragma( StrC directive ) CodePragma result = (CodePragma) make_code(); - result->Type = ECode::Preprocess_Pragma; + result->Type = CT_Preprocess_Pragma; result->Content = get_cached_string( directive ); return result; @@ -1140,16 +1140,16 @@ CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC expr ) switch (type) { case PreprocessCond_If: - result->Type = ECode::Preprocess_If; + result->Type = CT_Preprocess_If; break; case PreprocessCond_IfDef: - result->Type = ECode::Preprocess_IfDef; + result->Type = CT_Preprocess_IfDef; break; case PreprocessCond_IfNotDef: - result->Type = ECode::Preprocess_IfNotDef; + result->Type = CT_Preprocess_IfNotDef; break; case PreprocessCond_ElIf: - result->Type = ECode::Preprocess_ElIf; + result->Type = CT_Preprocess_ElIf; break; } @@ -1160,7 +1160,7 @@ CodeSpecifiers def_specifier( Specifier spec ) { CodeSpecifiers result = (CodeSpecifiers) make_code(); - result->Type = ECode::Specifiers; + result->Type = CT_Specifiers; append(result, spec ); return result; @@ -1169,26 +1169,26 @@ CodeSpecifiers def_specifier( Specifier spec ) CodeStruct def_struct( StrC name, Opts_def_struct p ) { Code body = p.body; - CodeType parent = p.parent; + CodeTypename parent = p.parent; AccessSpec parent_access = p.parent_access; CodeAttributes attributes = p.attributes; ModuleFlag mflags = p.mflags; - CodeType* interfaces = p.interfaces; + CodeTypename* interfaces = p.interfaces; s32 num_interfaces = p.num_interfaces; - if ( attributes && attributes->Type != ECode::PlatformAttributes ) + if ( attributes && attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", debug_str(attributes) ); return InvalidCode; } - if ( parent && parent->Type != ECode::Typename ) + if ( parent && parent->Type != CT_Typename ) { log_failure( "gen::def_struct: parent was not a `Struct` type - %s", debug_str(parent) ); return InvalidCode; } - if ( body && body->Type != ECode::Struct_Body ) + if ( body && body->Type != CT_Struct_Body ) { log_failure( "gen::def_struct: body was not a Struct_Body type - %s", debug_str(body) ); return InvalidCode; @@ -1203,12 +1203,12 @@ CodeStruct def_struct( StrC name, Opts_def_struct p ) if ( body ) { - result->Type = ECode::Struct; + result->Type = CT_Struct; result->Body = body; } else { - result->Type = ECode::Struct_Fwd; + result->Type = CT_Struct_Fwd; } if ( attributes ) @@ -1235,7 +1235,7 @@ CodeTemplate def_template( CodeParam params, Code declaration, Opts_def_template { null_check( def_template, declaration ); - if ( params && params->Type != ECode::Parameters ) + if ( params && params->Type != CT_Parameters ) { log_failure( "gen::def_template: params is not of parameters type - %s", debug_str(params) ); return InvalidCode; @@ -1243,11 +1243,11 @@ CodeTemplate def_template( CodeParam params, Code declaration, Opts_def_template switch (declaration->Type ) { - case ECode::Class: - case ECode::Function: - case ECode::Struct: - case ECode::Variable: - case ECode::Using: + case CT_Class: + case CT_Function: + case CT_Struct: + case CT_Variable: + case CT_Using: break; default: @@ -1256,14 +1256,14 @@ CodeTemplate def_template( CodeParam params, Code declaration, Opts_def_template CodeTemplate result = (CodeTemplate) make_code(); - result->Type = ECode::Template; + result->Type = CT_Template; result->ModuleFlags = p.mflags; result->Params = params; result->Declaration = declaration; return result; } -CodeType def_type( StrC name, Opts_def_type p ) +CodeTypename def_type( StrC name, Opts_def_type p ) { name_check( def_type, name ); @@ -1271,28 +1271,28 @@ CodeType def_type( StrC name, Opts_def_type p ) CodeSpecifiers specifiers = p.specifiers; CodeAttributes attributes = p.attributes; - if ( attributes && attributes->Type != ECode::PlatformAttributes ) + if ( attributes && attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_type: attributes is not of attributes type - %s", debug_str(attributes) ); return InvalidCode; } - if ( specifiers && specifiers->Type != ECode::Specifiers ) + if ( specifiers && specifiers->Type != CT_Specifiers ) { log_failure( "gen::def_type: specifiers is not of specifiers type - %s", debug_str(specifiers) ); return InvalidCode; } - if ( arrayexpr && arrayexpr->Type != ECode::Untyped ) + if ( arrayexpr && arrayexpr->Type != CT_Untyped ) { log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", debug_str(arrayexpr) ); return InvalidCode; } - CodeType - result = (CodeType) make_code(); + CodeTypename + result = (CodeTypename) make_code(); result->Name = get_cached_string( name ); - result->Type = ECode::Typename; + result->Type = CT_Typename; if ( attributes ) result->Attributes = attributes; @@ -1312,24 +1312,24 @@ CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef p ) switch ( type->Type ) { - case ECode::Class: - case ECode::Class_Fwd: - case ECode::Enum: - case ECode::Enum_Fwd: - case ECode::Enum_Class: - case ECode::Enum_Class_Fwd: - case ECode::Function_Fwd: - case ECode::Struct: - case ECode::Struct_Fwd: - case ECode::Union: - case ECode::Typename: + case CT_Class: + case CT_Class_Fwd: + case CT_Enum: + case CT_Enum_Fwd: + case CT_Enum_Class: + case CT_Enum_Class_Fwd: + case CT_Function_Fwd: + case CT_Struct: + case CT_Struct_Fwd: + case CT_Union: + case CT_Typename: break; default: log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", debug_str(type) ); return InvalidCode; } - if ( p.attributes && p.attributes->Type != ECode::PlatformAttributes ) + if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", debug_str(p.attributes) ); return InvalidCode; @@ -1346,14 +1346,14 @@ CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef p ) CodeTypedef result = (CodeTypedef) make_code(); - result->Type = ECode::Typedef; + result->Type = CT_Typedef; result->ModuleFlags = p.mflags; result->UnderlyingType = type; if ( name.Len <= 0 ) { - if (type->Type != ECode::Untyped) + if (type->Type != CT_Untyped) { log_failure( "gen::def_typedef: name was empty and type was not untyped (indicating its a function typedef) - %s", debug_str(type) ); return InvalidCode; @@ -1375,13 +1375,13 @@ CodeUnion def_union( StrC name, Code body, Opts_def_union p ) { null_check( def_union, body ); - if ( body->Type != ECode::Union_Body ) + if ( body->Type != CT_Union_Body ) { log_failure( "gen::def_union: body was not a Union_Body type - %s", debug_str(body) ); return InvalidCode; } - if ( p.attributes && p.attributes->Type != ECode::PlatformAttributes ) + if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", debug_str(p.attributes) ); return InvalidCode; @@ -1390,7 +1390,7 @@ CodeUnion def_union( StrC name, Code body, Opts_def_union p ) CodeUnion result = (CodeUnion) make_code(); result->ModuleFlags = p.mflags; - result->Type = ECode::Union; + result->Type = CT_Union; if ( name.Ptr ) result->Name = get_cached_string( name ); @@ -1416,7 +1416,7 @@ CodeUsing def_using( StrC name, Code type, Opts_def_using p ) return InvalidCode; } - if ( p.attributes && p.attributes->Type != ECode::PlatformAttributes ) + if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", debug_str(p.attributes) ); return InvalidCode; @@ -1426,7 +1426,7 @@ CodeUsing def_using( StrC name, Code type, Opts_def_using p ) result = (CodeUsing) make_code(); result->Name = get_cached_string( name ); result->ModuleFlags = p.mflags; - result->Type = ECode::Using; + result->Type = CT_Using; result->UnderlyingType = type; @@ -1444,35 +1444,35 @@ CodeUsing def_using_namespace( StrC name ) result = make_code(); result->Name = get_cached_string( name ); result->Content = result->Name; - result->Type = ECode::Using_Namespace; + result->Type = CT_Using_Namespace; return (CodeUsing) result; } -CodeVar def_variable( CodeType type, StrC name, Code value, Opts_def_variable p ) +CodeVar def_variable( CodeTypename type, StrC name, Code value, Opts_def_variable p ) { name_check( def_variable, name ); null_check( def_variable, type ); - if ( p.attributes && p.attributes->Type != ECode::PlatformAttributes ) + if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", debug_str(p.attributes) ); return InvalidCode; } - if ( p.specifiers && p.specifiers->Type != ECode::Specifiers ) + if ( p.specifiers && p.specifiers->Type != CT_Specifiers ) { log_failure( "gen::def_variable: specifiers was not a `Specifiers` type - %s", debug_str(p.specifiers) ); return InvalidCode; } - if ( type->Type != ECode::Typename ) + if ( type->Type != CT_Typename ) { log_failure( "gen::def_variable: type was not a Typename - %s", debug_str(type) ); return InvalidCode; } - if ( value && value->Type != ECode::Untyped ) + if ( value && value->Type != CT_Untyped ) { log_failure( "gen::def_variable: value was not a `Untyped` type - %s", debug_str(value) ); return InvalidCode; @@ -1481,7 +1481,7 @@ CodeVar def_variable( CodeType type, StrC name, Code value, Opts_def_variable p CodeVar result = (CodeVar) make_code(); result->Name = get_cached_string( name ); - result->Type = ECode::Variable; + result->Type = CT_Variable; result->ModuleFlags = p.mflags; result->ValueType = type; @@ -1500,8 +1500,6 @@ CodeVar def_variable( CodeType type, StrC name, Code value, Opts_def_variable p #pragma region Helper Macros for def_**_body functions #define def_body_start( Name_ ) \ -using namespace ECode; \ - \ if ( num <= 0 ) \ { \ log_failure("gen::" stringize(Name_) ": num cannot be zero or negative"); \ @@ -1509,8 +1507,6 @@ if ( num <= 0 ) \ } #define def_body_code_array_start( Name_ ) \ -using namespace ECode; \ - \ if ( num <= 0 ) \ { \ log_failure("gen::" stringize(Name_) ": num cannot be zero or negative"); \ @@ -1530,7 +1526,7 @@ CodeBody def_class_body( s32 num, ... ) def_body_start( def_class_body ); CodeBody result = ( CodeBody )make_code(); - result->Type = Class_Body; + result->Type = CT_Class_Body; va_list va; va_start( va, num ); @@ -1571,7 +1567,7 @@ CodeBody def_class_body( s32 num, Code* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Function_Body; + result->Type = CT_Function_Body; do { @@ -1607,7 +1603,7 @@ CodeBody def_enum_body( s32 num, ... ) CodeBody result = (CodeBody) make_code(); - result->Type = Enum_Body; + result->Type = CT_Enum_Body; va_list va; va_start(va, num); @@ -1622,7 +1618,7 @@ CodeBody def_enum_body( s32 num, ... ) return InvalidCode; } - if ( entry->Type != Untyped && entry->Type != Comment ) + if ( entry->Type != CT_Untyped && entry->Type != CT_Comment ) { log_failure("gen::def_enum_body: Entry type is not allowed - %s. Must be of untyped or comment type.", debug_str(entry) ); return InvalidCode; @@ -1642,7 +1638,7 @@ CodeBody def_enum_body( s32 num, Code* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Enum_Body; + result->Type = CT_Enum_Body; do { @@ -1654,7 +1650,7 @@ CodeBody def_enum_body( s32 num, Code* codes ) return InvalidCode; } - if ( entry->Type != Untyped && entry->Type != Comment ) + if ( entry->Type != CT_Untyped && entry->Type != CT_Comment ) { log_failure("gen::def_enum_body: Entry type is not allowed: %s", debug_str(entry) ); return InvalidCode; @@ -1673,7 +1669,7 @@ CodeBody def_export_body( s32 num, ... ) CodeBody result = (CodeBody) make_code(); - result->Type = Export_Body; + result->Type = CT_Export_Body; va_list va; va_start(va, num); @@ -1712,7 +1708,7 @@ CodeBody def_export_body( s32 num, Code* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Export_Body; + result->Type = CT_Export_Body; do { @@ -1748,7 +1744,7 @@ CodeBody def_extern_link_body( s32 num, ... ) CodeBody result = (CodeBody) make_code(); - result->Type = Extern_Linkage_Body; + result->Type = CT_Extern_Linkage_Body; va_list va; va_start(va, num); @@ -1787,7 +1783,7 @@ CodeBody def_extern_link_body( s32 num, Code* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Extern_Linkage_Body; + result->Type = CT_Extern_Linkage_Body; do { @@ -1824,7 +1820,7 @@ CodeBody def_function_body( s32 num, ... ) CodeBody result = (CodeBody) make_code(); - result->Type = Function_Body; + result->Type = CT_Function_Body; va_list va; va_start(va, num); @@ -1864,7 +1860,7 @@ CodeBody def_function_body( s32 num, Code* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Function_Body; + result->Type = CT_Function_Body; do { @@ -1899,7 +1895,7 @@ CodeBody def_global_body( s32 num, ... ) CodeBody result = (CodeBody) make_code(); - result->Type = Global_Body; + result->Type = CT_Global_Body; va_list va; va_start(va, num); @@ -1916,7 +1912,7 @@ CodeBody def_global_body( s32 num, ... ) switch (entry->Type) { - case Global_Body: + case CT_Global_Body: // result.append( entry.code_cast() ) ; append( result, cast(CodeBody, entry) ); continue; @@ -1943,7 +1939,7 @@ CodeBody def_global_body( s32 num, Code* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Global_Body; + result->Type = CT_Global_Body; do { @@ -1958,7 +1954,7 @@ CodeBody def_global_body( s32 num, Code* codes ) switch (entry->Type) { - case Global_Body: + case CT_Global_Body: append(result, cast(CodeBody, entry) ); continue; @@ -1983,7 +1979,7 @@ CodeBody def_namespace_body( s32 num, ... ) CodeBody result = (CodeBody) make_code(); - result->Type = Namespace_Body; + result->Type = CT_Namespace_Body; va_list va; va_start(va, num); @@ -2022,7 +2018,7 @@ CodeBody def_namespace_body( s32 num, Code* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Global_Body; + result->Type = CT_Global_Body; do { @@ -2063,7 +2059,7 @@ CodeParam def_params( s32 num, ... ) null_check( def_params, param ); - if ( param->Type != Parameters ) + if ( param->Type != CT_Parameters ) { log_failure( "gen::def_params: param %d is not a Parameters", num - num + 1 ); return InvalidCode; @@ -2076,7 +2072,7 @@ CodeParam def_params( s32 num, ... ) pod = va_arg(va, Code_POD); param = pcast( CodeParam, pod ); - if ( param->Type != Parameters ) + if ( param->Type != CT_Parameters ) { log_failure( "gen::def_params: param %d is not a Parameters", num - num + 1 ); return InvalidCode; @@ -2100,7 +2096,7 @@ CodeParam def_params( s32 num, CodeParam* codes ) return InvalidCode; \ } \ \ - if (current->Type != Parameters ) \ + if (current->Type != CT_Parameters ) \ { \ log_failure("gen::def_params: Code in coes array is not of paramter type - %s", debug_str(current) ); \ return InvalidCode; \ @@ -2141,7 +2137,7 @@ CodeSpecifiers def_specifiers( s32 num, ... ) CodeSpecifiers result = (CodeSpecifiers) make_code(); - result->Type = ECode::Specifiers; + result->Type = CT_Specifiers; va_list va; va_start(va, num); @@ -2173,7 +2169,7 @@ CodeSpecifiers def_specifiers( s32 num, Specifier* specs ) CodeSpecifiers result = (CodeSpecifiers) make_code(); - result->Type = ECode::Specifiers; + result->Type = CT_Specifiers; s32 idx = 0; do @@ -2192,7 +2188,7 @@ CodeBody def_struct_body( s32 num, ... ) CodeBody result = (CodeBody) make_code(); - result->Type = Struct_Body; + result->Type = CT_Struct_Body; va_list va; va_start(va, num); @@ -2231,7 +2227,7 @@ CodeBody def_struct_body( s32 num, Code* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Struct_Body; + result->Type = CT_Struct_Body; do { @@ -2267,7 +2263,7 @@ CodeBody def_union_body( s32 num, ... ) CodeBody result = (CodeBody) make_code(); - result->Type = Union_Body; + result->Type = CT_Union_Body; va_list va; va_start(va, num); @@ -2282,7 +2278,7 @@ CodeBody def_union_body( s32 num, ... ) return InvalidCode; } - if ( entry->Type != Untyped && entry->Type != Comment ) + if ( entry->Type != CT_Untyped && entry->Type != CT_Comment ) { log_failure("gen::def_union_body: Entry type is not allowed - %s. Must be of untyped or comment type.", debug_str(entry) ); return InvalidCode; @@ -2302,7 +2298,7 @@ CodeBody def_union_body( s32 num, CodeUnion* codes ) CodeBody result = (CodeBody) make_code(); - result->Type = Union_Body; + result->Type = CT_Union_Body; do { @@ -2314,7 +2310,7 @@ CodeBody def_union_body( s32 num, CodeUnion* codes ) return InvalidCode; } - if ( entry->Type != Untyped && entry->Type != Comment ) + if ( entry->Type != CT_Untyped && entry->Type != CT_Comment ) { log_failure("gen::def_union_body: Entry type is not allowed: %s", debug_str(entry) ); return InvalidCode; diff --git a/project/components/parser.cpp b/project/components/parser.cpp index 5b7b86d..39ec443 100644 --- a/project/components/parser.cpp +++ b/project/components/parser.cpp @@ -203,13 +203,13 @@ internal Code parse_class_struct ( TokType which, internal CodeDefine parse_define (); internal Code parse_expression (); internal Code parse_forward_or_definition ( TokType which, bool is_inplace ); -internal CodeFn parse_function_after_name ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeType ret_type, Token name ); +internal CodeFn parse_function_after_name ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename ret_type, Token name ); internal Code parse_function_body (); internal Code parse_global_nspace (); internal Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ); internal Token parse_identifier ( bool* possible_member_function = nullptr ); internal CodeInclude parse_include (); -internal CodeOperator parse_operator_after_ret_type ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeType ret_type ); +internal CodeOperator parse_operator_after_ret_type ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename ret_type ); internal Code parse_operator_function_or_variable( bool expects_function, CodeAttributes attributes, CodeSpecifiers specifiers ); internal CodePragma parse_pragma (); internal CodeParam parse_params ( bool use_template_capture = false ); @@ -217,7 +217,7 @@ internal CodePreprocessCond parse_preprocess_cond (); internal Code parse_simple_preprocess ( TokType which ); internal Code parse_static_assert (); internal void parse_template_args ( Token& token ); -internal CodeVar parse_variable_after_name ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeType type, StrC name ); +internal CodeVar parse_variable_after_name ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename type, StrC name ); internal CodeVar parse_variable_declaration_list (); internal CodeClass parse_class ( bool inplace_def = false ); @@ -234,7 +234,7 @@ internal CodeOpCast parse_operator_cast ( CodeSpecifiers specifiers = Nul internal CodeStruct parse_struct ( bool inplace_def = false ); internal CodeVar parse_variable (); internal CodeTemplate parse_template (); -internal CodeType parse_type ( bool from_template = false, bool* is_function = nullptr ); +internal CodeTypename parse_type ( bool from_template = false, bool* is_function = nullptr ); internal CodeTypedef parse_typedef (); internal CodeUnion parse_union ( bool inplace_def = false ); internal CodeUsing parse_using (); @@ -668,7 +668,7 @@ CodeAttributes parse_attributes() String name_stripped = strip_formatting( attribute_txt, strip_formatting_dont_preserve_newlines ); Code result = make_code(); - result->Type = ECode::PlatformAttributes; + result->Type = CT_PlatformAttributes; result->Name = get_cached_string( name_stripped ); result->Content = result->Name; // result->Token = @@ -692,7 +692,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) Token name { nullptr, 0, Tok_Invalid }; AccessSpec access = AccessSpec_Default; - CodeType parent = { nullptr }; + CodeTypename parent = { nullptr }; CodeBody body = { nullptr }; CodeAttributes attributes = { nullptr }; ModuleFlag mflags = ModuleFlag_None; @@ -721,9 +721,9 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) local_persist char interface_arr_mem[ kilobytes(4) ] {0}; - Array interfaces; { + Array interfaces; { Arena arena = arena_init_from_memory( interface_arr_mem, kilobytes(4) ); - interfaces = array_init_reserve( allocator_info(& arena), 4 ); + interfaces = array_init_reserve( allocator_info(& arena), 4 ); } // TODO(Ed) : Make an AST_DerivedType, we'll store any arbitary derived type into there as a linear linked list of them. @@ -781,7 +781,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) result = def_class( to_str(name), { body, parent, access, attributes, mflags } ); else - result = def_struct( to_str(name), { body, (CodeType)parent, access, attributes, mflags } ); + result = def_struct( to_str(name), { body, (CodeTypename)parent, access, attributes, mflags } ); if ( inline_cmt ) result->InlineCmt = inline_cmt; @@ -793,7 +793,6 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) internal neverinline CodeBody parse_class_struct_body( TokType which, Token name ) { - using namespace ECode; push_scope(); eat( Tok_BraceCurly_Open ); @@ -803,10 +802,10 @@ CodeBody parse_class_struct_body( TokType which, Token name ) result = (CodeBody) make_code(); if ( which == Tok_Decl_Class ) - result->Type = Class_Body; + result->Type = CT_Class_Body; else - result->Type = Struct_Body; + result->Type = CT_Struct_Body; while ( left && currtok_noskip.Type != Tok_BraceCurly_Close ) { @@ -1139,7 +1138,7 @@ CodeComment parse_comment() CodeComment result = (CodeComment) make_code(); - result->Type = ECode::Comment; + result->Type = CT_Comment; result->Content = get_cached_string( to_str(currtok_noskip) ); result->Name = result->Content; // result->Token = currtok_noskip; @@ -1314,7 +1313,7 @@ CodeDefine parse_define() CodeDefine define = (CodeDefine) make_code(); - define->Type = ECode::Preprocess_Define; + define->Type = CT_Preprocess_Define; if ( ! check( Tok_Identifier ) ) { @@ -1429,7 +1428,7 @@ CodeFn parse_function_after_name( ModuleFlag mflags , CodeAttributes attributes , CodeSpecifiers specifiers - , CodeType ret_type + , CodeTypename ret_type , Token name ) { @@ -1489,8 +1488,6 @@ CodeFn parse_function_after_name( // ( ) ; } - using namespace ECode; - String name_stripped = string_make( GlobalAllocator, to_str(name) ); strip_space(name_stripped); @@ -1504,8 +1501,8 @@ CodeFn parse_function_after_name( { switch ( body->Type ) { - case Function_Body: - case Untyped: + case CT_Function_Body: + case CT_Untyped: break; default: @@ -1516,12 +1513,12 @@ CodeFn parse_function_after_name( } } - result->Type = Function; + result->Type = CT_Function; result->Body = body; } else { - result->Type = Function_Fwd; + result->Type = CT_Function_Fwd; } if ( attributes ) @@ -1545,14 +1542,14 @@ CodeFn parse_function_after_name( internal Code parse_function_body() { - using namespace ECode; + push_scope(); eat( Tok_BraceCurly_Open ); CodeBody result = (CodeBody) make_code(); - result->Type = Function_Body; + result->Type = CT_Function_Body; // TODO : Support actual parsing of function body Token start = currtok_noskip; @@ -1585,16 +1582,14 @@ Code parse_function_body() } internal neverinline -CodeBody parse_global_nspace( CodeT which ) +CodeBody parse_global_nspace( CodeType which ) { - using namespace ECode; - push_scope(); - if ( which != Namespace_Body && which != Global_Body && which != Export_Body && which != Extern_Linkage_Body ) + if ( which != CT_Namespace_Body && which != CT_Global_Body && which != CT_Export_Body && which != CT_Extern_Linkage_Body ) return InvalidCode; - if ( which != Global_Body ) + if ( which != CT_Global_Body ) eat( Tok_BraceCurly_Open ); // { @@ -1645,7 +1640,7 @@ CodeBody parse_global_nspace( CodeT which ) break; case Tok_Decl_Extern_Linkage: - if ( which == Extern_Linkage_Body ) + if ( which == CT_Extern_Linkage_Body ) log_failure( "Nested extern linkage\n%s", to_string(Context) ); member = parse_extern_link(); @@ -1733,7 +1728,7 @@ CodeBody parse_global_nspace( CodeT which ) break; case Tok_Module_Export: - if ( which == Export_Body ) + if ( which == CT_Export_Body ) log_failure( "Nested export declaration\n%s", to_string(Context) ); member = parse_export_body(); @@ -1888,7 +1883,7 @@ CodeBody parse_global_nspace( CodeT which ) append(result, member ); } - if ( which != Global_Body ) + if ( which != CT_Global_Body ) eat( Tok_BraceCurly_Close ); // { } @@ -2107,7 +2102,7 @@ CodeInclude parse_include() CodeInclude include = (CodeInclude) make_code(); - include->Type = ECode::Preprocess_Include; + include->Type = CT_Preprocess_Include; eat( Tok_Preprocess_Include ); // #include @@ -2132,7 +2127,7 @@ CodeOperator parse_operator_after_ret_type( ModuleFlag mflags , CodeAttributes attributes , CodeSpecifiers specifiers - , CodeType ret_type + , CodeTypename ret_type ) { push_scope(); @@ -2506,7 +2501,7 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes } #endif - CodeType type = parse_type(); + CodeTypename type = parse_type(); // if ( type == InvalidCode ) @@ -2588,7 +2583,7 @@ CodePragma parse_pragma() CodePragma pragma = (CodePragma) make_code(); - pragma->Type = ECode::Preprocess_Pragma; + pragma->Type = CT_Preprocess_Pragma; eat( Tok_Preprocess_Pragma ); // #pragma @@ -2612,7 +2607,7 @@ CodePragma parse_pragma() internal inline CodeParam parse_params( bool use_template_capture ) { - using namespace ECode; + push_scope(); if ( ! use_template_capture ) @@ -2641,11 +2636,11 @@ CodeParam parse_params( bool use_template_capture ) return { nullptr }; } - Code macro = { nullptr }; - CodeType type = { nullptr }; - Code value = { nullptr }; - Token name = NullToken; - Code post_name_macro = { nullptr }; + Code macro = { nullptr }; + CodeTypename type = { nullptr }; + Code value = { nullptr }; + Token name = NullToken; + Code post_name_macro = { nullptr }; if ( check( Tok_Varadic_Argument ) ) { @@ -2741,7 +2736,7 @@ CodeParam parse_params( bool use_template_capture ) } CodeParam result = ( CodeParam )make_code(); - result->Type = Parameters; + result->Type = CT_Parameters; result->Macro = macro; @@ -2857,7 +2852,7 @@ CodeParam parse_params( bool use_template_capture ) } CodeParam param = ( CodeParam )make_code(); - param->Type = Parameters; + param->Type = CT_Parameters; param->Macro = macro; @@ -2908,7 +2903,7 @@ CodePreprocessCond parse_preprocess_cond() CodePreprocessCond cond = (CodePreprocessCond) make_code(); - cond->Type = scast(CodeT, currtok.Type - ( Tok_Preprocess_If - ECode::Preprocess_If ) ); + cond->Type = scast(CodeType, currtok.Type - ( Tok_Preprocess_If - CT_Preprocess_If ) ); eat( currtok.Type ); // # @@ -3013,7 +3008,7 @@ Code parse_static_assert() Code assert = make_code(); - assert->Type = ECode::Untyped; + assert->Type = CT_Untyped; Token content = currtok; @@ -3093,7 +3088,7 @@ CodeVar parse_variable_after_name( ModuleFlag mflags , CodeAttributes attributes , CodeSpecifiers specifiers - , CodeType type + , CodeTypename type , StrC name ) { @@ -3221,11 +3216,9 @@ CodeVar parse_variable_after_name( } } - using namespace ECode; - CodeVar result = (CodeVar) make_code(); - result->Type = Variable; + result->Type = CT_Variable; result->Name = get_cached_string( name ); result->ModuleFlags = mflags; @@ -3430,13 +3423,13 @@ CodeConstructor parse_constructor( CodeSpecifiers specifiers ) if ( initializer_list ) result->InitializerList = initializer_list; - if ( body && body->Type == ECode::Function_Body ) + if ( body && body->Type == CT_Function_Body ) { result->Body = body; - result->Type = ECode::Constructor; + result->Type = CT_Constructor; } else - result->Type = ECode::Constructor_Fwd; + result->Type = CT_Constructor_Fwd; if ( inline_cmt ) result->InlineCmt = inline_cmt; @@ -3540,13 +3533,13 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers ) if ( specifiers ) result->Specs = specifiers; - if ( body && body->Type == ECode::Function_Body ) + if ( body && body->Type == CT_Function_Body ) { result->Body = body; - result->Type = ECode::Destructor; + result->Type = CT_Destructor; } else - result->Type = ECode::Destructor_Fwd; + result->Type = CT_Destructor_Fwd; if ( inline_cmt ) result->InlineCmt = inline_cmt; @@ -3558,7 +3551,6 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers ) internal CodeEnum parse_enum( bool inplace_def ) { - using namespace ECode; push_scope(); Specifier specs_found[16] { Spec_NumSpecifiers }; @@ -3566,9 +3558,9 @@ CodeEnum parse_enum( bool inplace_def ) CodeAttributes attributes = { nullptr }; - Token name = { nullptr, 0, Tok_Invalid }; - Code array_expr = { nullptr }; - CodeType type = { nullptr }; + Token name = { nullptr, 0, Tok_Invalid }; + Code array_expr = { nullptr }; + CodeTypename type = { nullptr }; char entries_code[ kilobytes(128) ] { 0 }; s32 entries_length = 0; @@ -3629,7 +3621,7 @@ CodeEnum parse_enum( bool inplace_def ) if ( currtok.Type == Tok_BraceCurly_Open ) { body = (CodeBody) make_code(); - body->Type = ECode::Enum_Body; + body->Type = CT_Enum_Body; eat( Tok_BraceCurly_Open ); // enum : { @@ -3771,19 +3763,17 @@ CodeEnum parse_enum( bool inplace_def ) // enum : { }; } - using namespace ECode; - CodeEnum result = (CodeEnum) make_code(); if ( body.ast ) { - result->Type = is_enum_class ? Enum_Class : Enum; + result->Type = is_enum_class ? CT_Enum_Class : CT_Enum; result->Body = body; } else { - result->Type = is_enum_class ? Enum_Class_Fwd : Enum_Fwd; + result->Type = is_enum_class ? CT_Enum_Class_Fwd : CT_Enum_Fwd; } result->Name = get_cached_string( to_str(name) ); @@ -3812,7 +3802,7 @@ internal inline CodeBody parse_export_body() { push_scope(); - CodeBody result = parse_global_nspace( ECode::Export_Body ); + CodeBody result = parse_global_nspace( CT_Export_Body ); pop(& Context); return result; } @@ -3821,7 +3811,7 @@ internal inline CodeBody parse_extern_link_body() { push_scope(); - CodeBody result = parse_global_nspace( ECode::Extern_Linkage_Body ); + CodeBody result = parse_global_nspace( CT_Extern_Linkage_Body ); pop(& Context); return result; } @@ -3843,7 +3833,7 @@ CodeExtern parse_extern_link() CodeExtern result = (CodeExtern) make_code(); - result->Type = ECode::Extern_Linkage; + result->Type = CT_Extern_Linkage; result->Name = get_cached_string( to_str(name) ); Code entry = parse_extern_link_body(); @@ -3864,7 +3854,6 @@ CodeExtern parse_extern_link() internal CodeFriend parse_friend() { - using namespace ECode; push_scope(); eat( Tok_Decl_Friend ); @@ -3873,7 +3862,7 @@ CodeFriend parse_friend() CodeFn function = { nullptr }; // Type declaration or return type - CodeType type = parse_type(); + CodeTypename type = parse_type(); if ( type == Code_Invalid ) { pop(& Context); @@ -3905,7 +3894,7 @@ CodeFriend parse_friend() } CodeComment inline_cmt = NullCode; - if ( function && function->Type == ECode::Function_Fwd ) + if ( function && function->Type == CT_Function_Fwd ) { Token stmt_end = currtok; eat( Tok_Statement_End ); @@ -3919,7 +3908,7 @@ CodeFriend parse_friend() } CodeFriend result = ( CodeFriend )make_code(); - result->Type = Friend; + result->Type = CT_Friend; if ( function ) result->Declaration = function; @@ -3991,7 +3980,7 @@ CodeFn parse_function() } // - CodeType ret_type = parse_type(); + CodeTypename ret_type = parse_type(); if ( ret_type == Code_Invalid ) { pop(& Context); @@ -4027,7 +4016,7 @@ CodeNS parse_namespace() Context.Scope->Name = name; // namespace - CodeBody body = parse_global_nspace( ECode::Namespace_Body ); + CodeBody body = parse_global_nspace( CT_Namespace_Body ); if ( body == Code_Invalid ) { pop(& Context); @@ -4037,7 +4026,7 @@ CodeNS parse_namespace() CodeNS result = (CodeNS) make_code(); - result->Type = ECode::Namespace; + result->Type = CT_Namespace; result->Name = get_cached_string( to_str(name) ); result->Body = body; @@ -4103,7 +4092,7 @@ CodeOperator parse_operator() // // Parse Return Type - CodeType ret_type = parse_type(); + CodeTypename ret_type = parse_type(); // CodeOperator result = parse_operator_after_ret_type( mflags, attributes, specifiers, ret_type ); @@ -4208,12 +4197,12 @@ CodeOpCast parse_operator_cast( CodeSpecifiers specifiers ) if (body) { - result->Type = ECode::Operator_Cast; + result->Type = CT_Operator_Cast; result->Body = body; } else { - result->Type = ECode::Operator_Cast_Fwd; + result->Type = CT_Operator_Cast_Fwd; } if ( specifiers ) @@ -4411,7 +4400,7 @@ CodeTemplate parse_template() } CodeTemplate result = ( CodeTemplate )make_code(); - result->Type = ECode::Template; + result->Type = CT_Template; result->Params = params; result->Declaration = definition; result->ModuleFlags = mflags; @@ -4435,7 +4424,7 @@ CodeTemplate parse_template() The excess whitespace cannot be stripped however, because there is no semantic awareness within the first capture group. */ internal -CodeType parse_type( bool from_template, bool* typedef_is_function ) +CodeTypename parse_type( bool from_template, bool* typedef_is_function ) { push_scope(); @@ -4603,8 +4592,8 @@ else if ( currtok.Type == Tok_DeclType ) // // For function type signatures - CodeType return_type = NullCode; - CodeParam params = NullCode; + CodeTypename return_type = NullCode; + CodeParam params = NullCode; #ifdef GEN_USE_NEW_TYPENAME_PARSING CodeParam params_nested = NullCode; @@ -4659,8 +4648,8 @@ else if ( currtok.Type == Tok_DeclType ) // By this point, decltype should have been taken care of for return type, along with any all its specifiers // The previous information with exception to attributes will be considered the return type. - return_type = ( CodeType )make_code(); - return_type->Type = ECode::Typename; + return_type = ( CodeTypename )make_code(); + return_type->Type = CT_Typename; // String // name_stripped = String::make( GlobalAllocator, name ); @@ -4815,10 +4804,8 @@ else if ( currtok.Type == Tok_DeclType ) // ... } - using namespace ECode; - - CodeType result = ( CodeType )make_code(); - result->Type = Typename; + CodeTypename result = ( CodeTypename )make_code(); + result->Type = CT_Typename; // result->Token = Context.Scope->Start; // Need to wait until were using the new parsing method to do this. @@ -5049,11 +5036,9 @@ CodeTypedef parse_typedef() inline_cmt = parse_comment(); // typedef ; - using namespace ECode; - CodeTypedef result = (CodeTypedef) make_code(); - result->Type = Typedef; + result->Type = CT_Typedef; result->ModuleFlags = mflags; if ( is_function ) @@ -5074,8 +5059,8 @@ CodeTypedef parse_typedef() } // Type needs to be aware of its parent so that it can be serialized properly. - if ( type->Type == Typename && array_expr && array_expr->Type != Invalid ) - cast(CodeType, type)->ArrExpr = array_expr; + if ( type->Type == CT_Typename && array_expr && array_expr->Type != CT_Invalid ) + cast(CodeTypename, type)->ArrExpr = array_expr; if ( inline_cmt ) result->InlineCmt = inline_cmt; @@ -5119,7 +5104,7 @@ CodeUnion parse_union( bool inplace_def ) // union { body = make_code(); - body->Type = ECode::Union_Body; + body->Type = CT_Union_Body; while ( ! check_noskip( Tok_BraceCurly_Close ) ) { @@ -5208,7 +5193,7 @@ CodeUnion parse_union( bool inplace_def ) CodeUnion result = (CodeUnion) make_code(); - result->Type = ECode::Union; + result->Type = CT_Union; result->ModuleFlags = mflags; if ( name ) @@ -5232,9 +5217,9 @@ CodeUsing parse_using() Specifier specs_found[16] { Spec_Invalid }; s32 NumSpecifiers = 0; - Token name = { nullptr, 0, Tok_Invalid }; - Code array_expr = { nullptr }; - CodeType type = { nullptr }; + Token name = { nullptr, 0, Tok_Invalid }; + Code array_expr = { nullptr }; + CodeTypename type = { nullptr }; bool is_namespace = false; @@ -5292,8 +5277,6 @@ CodeUsing parse_using() } // using = ; - using namespace ECode; - CodeUsing result = (CodeUsing) make_code(); result->Name = get_cached_string( to_str(name) ); @@ -5301,11 +5284,11 @@ CodeUsing parse_using() if ( is_namespace) { - result->Type = Using_Namespace; + result->Type = CT_Using_Namespace; } else { - result->Type = Using; + result->Type = CT_Using; if ( type ) result->UnderlyingType = type; @@ -5330,7 +5313,7 @@ CodeVar parse_variable() push_scope(); Specifier specs_found[16] { Spec_NumSpecifiers }; - s32 NumSpecifiers = 0; + s32 NumSpecifiers = 0; ModuleFlag mflags = ModuleFlag_None; CodeAttributes attributes = { nullptr }; @@ -5349,8 +5332,7 @@ CodeVar parse_variable() while ( left && is_specifier(currtok) ) { Specifier spec = to_specifier( to_str(currtok) ); - - switch ( spec ) + switch ( spec ) { case Spec_Const: case Spec_Constexpr: @@ -5386,7 +5368,7 @@ CodeVar parse_variable() } // - CodeType type = parse_type(); + CodeTypename type = parse_type(); // if ( type == Code_Invalid ) diff --git a/project/components/static_data.cpp b/project/components/static_data.cpp index 8e36df9..92725dc 100644 --- a/project/components/static_data.cpp +++ b/project/components/static_data.cpp @@ -72,36 +72,36 @@ global CodeSpecifiers spec_thread_local; global CodeSpecifiers spec_virtual; global CodeSpecifiers spec_volatile; -global CodeType t_empty; -global CodeType t_auto; -global CodeType t_void; -global CodeType t_int; -global CodeType t_bool; -global CodeType t_char; -global CodeType t_wchar_t; -global CodeType t_class; -global CodeType t_typename; +global CodeTypename t_empty; +global CodeTypename t_auto; +global CodeTypename t_void; +global CodeTypename t_int; +global CodeTypename t_bool; +global CodeTypename t_char; +global CodeTypename t_wchar_t; +global CodeTypename t_class; +global CodeTypename t_typename; global Array< StringCached > PreprocessorDefines; #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS -global CodeType t_b32; +global CodeTypename t_b32; -global CodeType t_s8; -global CodeType t_s16; -global CodeType t_s32; -global CodeType t_s64; +global CodeTypename t_s8; +global CodeTypename t_s16; +global CodeTypename t_s32; +global CodeTypename t_s64; -global CodeType t_u8; -global CodeType t_u16; -global CodeType t_u32; -global CodeType t_u64; +global CodeTypename t_u8; +global CodeTypename t_u16; +global CodeTypename t_u32; +global CodeTypename t_u64; -global CodeType t_ssize; -global CodeType t_usize; +global CodeTypename t_ssize; +global CodeTypename t_usize; -global CodeType t_f32; -global CodeType t_f64; +global CodeTypename t_f32; +global CodeTypename t_f64; #endif #pragma endregion Constants diff --git a/project/helpers/helper.hpp b/project/helpers/helper.hpp index 4bbdd4c..9060585 100644 --- a/project/helpers/helper.hpp +++ b/project/helpers/helper.hpp @@ -27,17 +27,17 @@ CodeBody gen_ecode( char const* path ) { char const* code = node.string; - append_fmt( & enum_entries, "%s,\n", code ); + append_fmt( & enum_entries, "CT_%s,\n", code ); append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code ); } - CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", (StrC)enum_entries, "enum Type : u32 { NumTypes };")); + CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", (StrC)enum_entries, "enum CodeType_Def : u32 { CT_NumTypes };")); #pragma push_macro("local_persist") #undef local_persist CodeFn to_str = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize( inline - StrC to_str( Type type ) + StrC to_str( CodeType type ) { local_persist StrC lookup[] { @@ -49,10 +49,11 @@ CodeBody gen_ecode( char const* path ) ))); #pragma pop_macro("local_persist") - CodeNS nspace = def_namespace( name(ECode), def_namespace_body( args( enum_code, to_str ) ) ); - CodeUsing code_t = def_using( name(CodeT), def_type( name(ECode::Type) ) ); + //CodeNS nspace = def_namespace( name(ECode), def_namespace_body( args( enum_code, to_str ) ) ); + //CodeUsing code_t = def_using( name(CodeT), def_type( name(ECode::Type) ) ); + CodeTypedef code_t = parse_typedef(code(typedef enum CodeType_Def CodeType; )); - return def_global_body( args( nspace, code_t, fmt_newline ) ); + return def_global_body( args( code_t, enum_code, to_str, fmt_newline ) ); } CodeBody gen_eoperator( char const* path ) @@ -423,7 +424,7 @@ CodeBody gen_ast_inlines() CodeBody impl_code_specs = parse_global_body( token_fmt( "typename", StrC name(CodeSpecifiers), code_impl_tmpl )); CodeBody impl_code_struct = parse_global_body( token_fmt( "typename", StrC name(CodeStruct), code_impl_tmpl )); CodeBody impl_code_tmpl = parse_global_body( token_fmt( "typename", StrC name(CodeTemplate), code_impl_tmpl )); - CodeBody impl_code_type = parse_global_body( token_fmt( "typename", StrC name(CodeType), code_impl_tmpl )); + CodeBody impl_code_type = parse_global_body( token_fmt( "typename", StrC name(CodeTypename), code_impl_tmpl )); CodeBody impl_code_typedef = parse_global_body( token_fmt( "typename", StrC name(CodeTypedef), code_impl_tmpl )); CodeBody impl_code_union = parse_global_body( token_fmt( "typename", StrC name(CodeUnion), code_impl_tmpl )); CodeBody impl_code_using = parse_global_body( token_fmt( "typename", StrC name(CodeUsing), code_impl_tmpl )); @@ -447,7 +448,7 @@ CodeBody gen_ast_inlines() append(impl_code_pragma, parse_global_body( token_fmt( "typename", StrC name(Pragma), codetype_impl_tmpl ))); append(impl_code_precond, parse_global_body( token_fmt( "typename", StrC name(PreprocessCond), codetype_impl_tmpl ))); append(impl_code_tmpl, parse_global_body( token_fmt( "typename", StrC name(Template), codetype_impl_tmpl ))); - append(impl_code_type, parse_global_body( token_fmt( "typename", StrC name(Type), codetype_impl_tmpl ))); + append(impl_code_type, parse_global_body( token_fmt( "typename", StrC name(Typename), codetype_impl_tmpl ))); append(impl_code_typedef, parse_global_body( token_fmt( "typename", StrC name(Typedef), codetype_impl_tmpl ))); append(impl_code_union, parse_global_body( token_fmt( "typename", StrC name(Union), codetype_impl_tmpl ))); append(impl_code_using, parse_global_body( token_fmt( "typename", StrC name(Using), codetype_impl_tmpl ))); @@ -483,7 +484,7 @@ CodeBody gen_ast_inlines() CodeBody impl_cast_specs = parse_global_body( token_fmt( "typename", StrC name(Specifiers), cast_tmpl )); CodeBody impl_cast_struct = parse_global_body( token_fmt( "typename", StrC name(Struct), cast_tmpl )); CodeBody impl_cast_tmpl = parse_global_body( token_fmt( "typename", StrC name(Template), cast_tmpl )); - CodeBody impl_cast_type = parse_global_body( token_fmt( "typename", StrC name(Type), cast_tmpl )); + CodeBody impl_cast_type = parse_global_body( token_fmt( "typename", StrC name(Typename), cast_tmpl )); CodeBody impl_cast_typedef = parse_global_body( token_fmt( "typename", StrC name(Typedef), cast_tmpl )); CodeBody impl_cast_union = parse_global_body( token_fmt( "typename", StrC name(Union), cast_tmpl )); CodeBody impl_cast_using = parse_global_body( token_fmt( "typename", StrC name(Using), cast_tmpl ));