Reduced ECode to C compatible vairant

This commit is contained in:
Edward R. Gonzalez 2024-12-03 15:19:39 -05:00
parent 72d088c566
commit e00b2f8afb
18 changed files with 956 additions and 1003 deletions

View File

@ -24,31 +24,29 @@ char const* debug_str(Code self)
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Invalid:
case CT_NewLine:
case Invalid: case CT_Access_Private:
case NewLine: case CT_Access_Protected:
case Access_Private: case CT_Access_Public:
case Access_Protected:
case Access_Public:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) if ( self->Next )
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
break; break;
case Untyped: case CT_Untyped:
case Execution: case CT_Execution:
case Comment: case CT_Comment:
case PlatformAttributes: case CT_PlatformAttributes:
case Preprocess_Define: case CT_Preprocess_Define:
case Preprocess_Include: case CT_Preprocess_Include:
case Preprocess_Pragma: case CT_Preprocess_Pragma:
case Preprocess_If: case CT_Preprocess_If:
case Preprocess_ElIf: case CT_Preprocess_ElIf:
case Preprocess_Else: case CT_Preprocess_Else:
case Preprocess_IfDef: case CT_Preprocess_IfDef:
case Preprocess_IfNotDef: case CT_Preprocess_IfNotDef:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) if ( self->Next )
@ -57,8 +55,8 @@ char const* debug_str(Code self)
append_fmt( result, "\n\tContent: %S", self->Content ); append_fmt( result, "\n\tContent: %S", self->Content );
break; break;
case Class: case CT_Class:
case Struct: case CT_Struct:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
break; break;
case Class_Fwd: case CT_Class_Fwd:
case Struct_Fwd: case CT_Struct_Fwd:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tParentType : %s", self->ParentType ? type_str(self->ParentType) : "Null" );
break; break;
case Constructor: case CT_Constructor:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
break; break;
case Constructor_Fwd: case CT_Constructor_Fwd:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
break; break;
case Destructor: case CT_Destructor:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
break; break;
case Destructor_Fwd: case CT_Destructor_Fwd:
break; break;
case Enum: case CT_Enum:
case Enum_Class: case CT_Enum_Class:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
break; break;
case Enum_Fwd: case CT_Enum_Fwd:
case Enum_Class_Fwd: case CT_Enum_Class_Fwd:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tUnderlying Type : %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" );
break; break;
case Extern_Linkage: case CT_Extern_Linkage:
case Namespace: case CT_Namespace:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tBody: %S", self->Body ? debug_str(self->Body) : "Null" );
break; break;
case Friend: case CT_Friend:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? to_string(self->Declaration) : "Null" );
break; break;
case Function: case CT_Function:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
break; break;
case Function_Fwd: case CT_Function_Fwd:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
break; break;
case Module: case CT_Module:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) if ( self->Next )
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
break; break;
case ECode::Operator: case CT_Operator:
case Operator_Member: case CT_Operator_Member:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) if ( self->Next )
@ -218,8 +216,8 @@ char const* debug_str(Code self)
append_fmt( result, "\n\tOp : %S", to_str( self->Op ) ); append_fmt( result, "\n\tOp : %S", to_str( self->Op ) );
break; break;
case Operator_Fwd: case CT_Operator_Fwd:
case Operator_Member_Fwd: case CT_Operator_Member_Fwd:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) if ( self->Next )
@ -233,7 +231,7 @@ char const* debug_str(Code self)
append_fmt( result, "\n\tOp : %S", to_str( self->Op ) ); append_fmt( result, "\n\tOp : %S", to_str( self->Op ) );
break; break;
case Operator_Cast: case CT_Operator_Cast:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
break; break;
case Operator_Cast_Fwd: case CT_Operator_Cast_Fwd:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tValueType : %S", self->ValueType ? to_string(self->ValueType) : "Null" );
break; break;
case Parameters: case CT_Parameters:
append_fmt( result, "\n\tNumEntries: %d", self->NumEntries ); append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
append_fmt( result, "\n\tLast : %S", self->Last->Name ); append_fmt( result, "\n\tLast : %S", self->Last->Name );
append_fmt( result, "\n\tNext : %S", self->Next->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" ); append_fmt( result, "\n\tValue : %S", self->Value ? to_string(self->Value) : "Null" );
break; break;
case Specifiers: case CT_Specifiers:
{ {
append_fmt( result, "\n\tNumEntries: %d", self->NumEntries ); append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
GEN_NS append( result, "\n\tArrSpecs: " ); GEN_NS append( result, "\n\tArrSpecs: " );
@ -281,7 +279,7 @@ char const* debug_str(Code self)
} }
break; break;
case Template: case CT_Template:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? to_string(self->Declaration) : "Null" );
break; break;
case Typedef: case CT_Typedef:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" );
break; break;
case Typename: case CT_Typename:
append_fmt( result, "\n\tAttributes : %S", self->Attributes ? to_string(self->Attributes) : "Null" ); 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\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" );
append_fmt( result, "\n\tReturnType : %S", self->ReturnType ? to_string(self->ReturnType) : "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" ); append_fmt( result, "\n\tArrExpr : %S", self->ArrExpr ? to_string(self->ArrExpr) : "Null" );
break; break;
case Union: case CT_Union:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
break; break;
case Using: case CT_Using:
if ( self->Prev ) if ( self->Prev )
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" ); append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
if ( self->Next ) 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" ); append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" );
break; break;
case Variable: case CT_Variable:
if ( self->Parent && self->Parent->Type == Variable ) if ( self->Parent && self->Parent->Type == CT_Variable )
{ {
// Its a NextVar // Its a NextVar
append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" ); 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) Code duplicate(Code self)
{ {
using namespace ECode;
Code result = make_code(); Code result = make_code();
mem_copy( result.ast, self.ast, sizeof( AST ) ); mem_copy( result.ast, self.ast, sizeof( AST ) );
@ -387,9 +383,7 @@ void to_string( Code self, String* result )
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Invalid:
case Invalid:
#ifdef GEN_DONT_ALLOW_INVALID_CODE #ifdef GEN_DONT_ALLOW_INVALID_CODE
log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name ); log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name );
#else #else
@ -397,197 +391,197 @@ void to_string( Code self, String* result )
#endif #endif
break; break;
case NewLine: case CT_NewLine:
append( result,"\n"); append( result,"\n");
break; break;
case Untyped: case CT_Untyped:
case Execution: case CT_Execution:
case Comment: case CT_Comment:
case PlatformAttributes: case CT_PlatformAttributes:
append( result, self->Content ); append( result, self->Content );
break; break;
case Access_Private: case CT_Access_Private:
case Access_Protected: case CT_Access_Protected:
case Access_Public: case CT_Access_Public:
append( result, self->Name ); append( result, self->Name );
break; break;
case Class: case CT_Class:
to_string_def(cast(CodeClass, self), result ); to_string_def(cast(CodeClass, self), result );
break; break;
case Class_Fwd: case CT_Class_Fwd:
to_string_fwd(cast(CodeClass, self), result ); to_string_fwd(cast(CodeClass, self), result );
break; break;
case Constructor: case CT_Constructor:
to_string_def(cast(CodeConstructor, self), result ); to_string_def(cast(CodeConstructor, self), result );
break; break;
case Constructor_Fwd: case CT_Constructor_Fwd:
to_string_fwd(cast(CodeConstructor, self), result ); to_string_fwd(cast(CodeConstructor, self), result );
break; break;
case Destructor: case CT_Destructor:
to_string_def(cast(CodeDestructor, self), result ); to_string_def(cast(CodeDestructor, self), result );
break; break;
case Destructor_Fwd: case CT_Destructor_Fwd:
to_string_fwd(cast(CodeDestructor, self), result ); to_string_fwd(cast(CodeDestructor, self), result );
break; break;
case Enum: case CT_Enum:
to_string_def(cast(CodeEnum, self), result ); to_string_def(cast(CodeEnum, self), result );
break; break;
case Enum_Fwd: case CT_Enum_Fwd:
to_string_fwd(cast(CodeEnum, self), result ); to_string_fwd(cast(CodeEnum, self), result );
break; break;
case Enum_Class: case CT_Enum_Class:
to_string_class_def(cast(CodeEnum, self), result ); to_string_class_def(cast(CodeEnum, self), result );
break; break;
case Enum_Class_Fwd: case CT_Enum_Class_Fwd:
to_string_class_fwd(cast(CodeEnum, self), result ); to_string_class_fwd(cast(CodeEnum, self), result );
break; break;
case Export_Body: case CT_Export_Body:
to_string_export(cast(CodeBody, self), result ); to_string_export(cast(CodeBody, self), result );
break; break;
case Extern_Linkage: case CT_Extern_Linkage:
to_string(cast(CodeExtern, self), result ); to_string(cast(CodeExtern, self), result );
break; break;
case Friend: case CT_Friend:
to_string(cast(CodeFriend, self), result ); to_string(cast(CodeFriend, self), result );
break; break;
case Function: case CT_Function:
to_string_def(cast(CodeFn, self), result ); to_string_def(cast(CodeFn, self), result );
break; break;
case Function_Fwd: case CT_Function_Fwd:
to_string_fwd(cast(CodeFn, self), result ); to_string_fwd(cast(CodeFn, self), result );
break; break;
case Module: case CT_Module:
to_string(cast(CodeModule, self), result ); to_string(cast(CodeModule, self), result );
break; break;
case Namespace: case CT_Namespace:
to_string(cast(CodeNS, self), result ); to_string(cast(CodeNS, self), result );
break; break;
case ECode::Operator: case CT_Operator:
case Operator_Member: case CT_Operator_Member:
to_string_def(cast(CodeOperator, self), result ); to_string_def(cast(CodeOperator, self), result );
break; break;
case Operator_Fwd: case CT_Operator_Fwd:
case Operator_Member_Fwd: case CT_Operator_Member_Fwd:
to_string_fwd(cast(CodeOperator, self), result ); to_string_fwd(cast(CodeOperator, self), result );
break; break;
case Operator_Cast: case CT_Operator_Cast:
to_string_def(cast(CodeOpCast, self), result ); to_string_def(cast(CodeOpCast, self), result );
break; break;
case Operator_Cast_Fwd: case CT_Operator_Cast_Fwd:
to_string_fwd(cast(CodeOpCast, self), result ); to_string_fwd(cast(CodeOpCast, self), result );
break; break;
case Parameters: case CT_Parameters:
to_string(cast(CodeParam, self), result ); to_string(cast(CodeParam, self), result );
break; break;
case Preprocess_Define: case CT_Preprocess_Define:
to_string(cast(CodeDefine, self), result ); to_string(cast(CodeDefine, self), result );
break; break;
case Preprocess_If: case CT_Preprocess_If:
to_string_if(cast(CodePreprocessCond, self), result ); to_string_if(cast(CodePreprocessCond, self), result );
break; break;
case Preprocess_IfDef: case CT_Preprocess_IfDef:
to_string_ifdef(cast(CodePreprocessCond, self), result ); to_string_ifdef(cast(CodePreprocessCond, self), result );
break; break;
case Preprocess_IfNotDef: case CT_Preprocess_IfNotDef:
to_string_ifndef(cast(CodePreprocessCond, self), result ); to_string_ifndef(cast(CodePreprocessCond, self), result );
break; break;
case Preprocess_Include: case CT_Preprocess_Include:
to_string(cast(CodeInclude, self), result ); to_string(cast(CodeInclude, self), result );
break; break;
case Preprocess_ElIf: case CT_Preprocess_ElIf:
to_string_elif(cast(CodePreprocessCond, self), result ); to_string_elif(cast(CodePreprocessCond, self), result );
break; break;
case Preprocess_Else: case CT_Preprocess_Else:
to_string_else(cast(CodePreprocessCond, self), result ); to_string_else(cast(CodePreprocessCond, self), result );
break; break;
case Preprocess_EndIf: case CT_Preprocess_EndIf:
to_string_endif(cast(CodePreprocessCond, self), result ); to_string_endif(cast(CodePreprocessCond, self), result );
break; break;
case Preprocess_Pragma: case CT_Preprocess_Pragma:
to_string(cast(CodePragma, self), result ); to_string(cast(CodePragma, self), result );
break; break;
case Specifiers: case CT_Specifiers:
to_string(cast(CodeSpecifiers, self), result ); to_string(cast(CodeSpecifiers, self), result );
break; break;
case Struct: case CT_Struct:
to_string_def(cast(CodeStruct, self), result ); to_string_def(cast(CodeStruct, self), result );
break; break;
case Struct_Fwd: case CT_Struct_Fwd:
to_string_fwd(cast(CodeStruct, self), result ); to_string_fwd(cast(CodeStruct, self), result );
break; break;
case Template: case CT_Template:
to_string(cast(CodeTemplate, self), result ); to_string(cast(CodeTemplate, self), result );
break; break;
case Typedef: case CT_Typedef:
to_string(cast(CodeTypedef, self), result ); to_string(cast(CodeTypedef, self), result );
break; break;
case Typename: case CT_Typename:
to_string(cast(CodeType, self), result ); to_string(cast(CodeTypename, self), result );
break; break;
case Union: case CT_Union:
to_string( cast(CodeUnion, self), result ); to_string( cast(CodeUnion, self), result );
break; break;
case Using: case CT_Using:
to_string(cast(CodeUsing, self), result ); to_string(cast(CodeUsing, self), result );
break; break;
case Using_Namespace: case CT_Using_Namespace:
to_string_ns(cast(CodeUsing, self), result ); to_string_ns(cast(CodeUsing, self), result );
break; break;
case Variable: case CT_Variable:
to_string(cast(CodeVar, self), result ); to_string(cast(CodeVar, self), result );
break; break;
case Enum_Body: case CT_Enum_Body:
case Class_Body: case CT_Class_Body:
case Extern_Linkage_Body: case CT_Extern_Linkage_Body:
case Function_Body: case CT_Function_Body:
case Global_Body: case CT_Global_Body:
case Namespace_Body: case CT_Namespace_Body:
case Struct_Body: case CT_Struct_Body:
case Union_Body: case CT_Union_Body:
to_string( cast(CodeBody, self), result ); to_string( cast(CodeBody, self), result );
break; break;
} }
@ -620,8 +614,6 @@ bool is_equal( Code self, Code other )
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode;
#define check_member_val( val ) \ #define check_member_val( val ) \
if ( self->val != other->val ) \ if ( self->val != other->val ) \
{ \ { \
@ -701,30 +693,30 @@ bool is_equal( Code self, Code other )
} \ } \
} }
case NewLine: case CT_NewLine:
case Access_Public: case CT_Access_Public:
case Access_Protected: case CT_Access_Protected:
case Access_Private: case CT_Access_Private:
case Preprocess_Else: case CT_Preprocess_Else:
case Preprocess_EndIf: case CT_Preprocess_EndIf:
return true; return true;
// Comments are not validated. // Comments are not validated.
case Comment: case CT_Comment:
return true; return true;
case Execution: case CT_Execution:
case PlatformAttributes: case CT_PlatformAttributes:
case Untyped: case CT_Untyped:
{ {
check_member_content( Content ); check_member_content( Content );
return true; return true;
} }
case Class_Fwd: case CT_Class_Fwd:
case Struct_Fwd: case CT_Struct_Fwd:
{ {
check_member_str( Name ); check_member_str( Name );
check_member_ast( ParentType ); check_member_ast( ParentType );
@ -734,8 +726,8 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Class: case CT_Class:
case Struct: case CT_Struct:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -747,7 +739,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Constructor: case CT_Constructor:
{ {
check_member_ast( InitializerList ); check_member_ast( InitializerList );
check_member_ast( Params ); check_member_ast( Params );
@ -756,7 +748,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Constructor_Fwd: case CT_Constructor_Fwd:
{ {
check_member_ast( InitializerList ); check_member_ast( InitializerList );
check_member_ast( Params ); check_member_ast( Params );
@ -764,7 +756,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Destructor: case CT_Destructor:
{ {
check_member_ast( Specs ); check_member_ast( Specs );
check_member_ast( Body ); check_member_ast( Body );
@ -772,15 +764,15 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Destructor_Fwd: case CT_Destructor_Fwd:
{ {
check_member_ast( Specs ); check_member_ast( Specs );
return true; return true;
} }
case Enum: case CT_Enum:
case Enum_Class: case CT_Enum_Class:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -791,8 +783,8 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Enum_Fwd: case CT_Enum_Fwd:
case Enum_Class_Fwd: case CT_Enum_Class_Fwd:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -802,7 +794,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Extern_Linkage: case CT_Extern_Linkage:
{ {
check_member_str( Name ); check_member_str( Name );
check_member_ast( Body ); check_member_ast( Body );
@ -810,7 +802,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Friend: case CT_Friend:
{ {
check_member_str( Name ); check_member_str( Name );
check_member_ast( Declaration ); check_member_ast( Declaration );
@ -818,7 +810,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Function: case CT_Function:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -831,7 +823,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Function_Fwd: case CT_Function_Fwd:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -843,7 +835,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Module: case CT_Module:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -851,7 +843,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Namespace: case CT_Namespace:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -860,8 +852,8 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case ECode::Operator: case CT_Operator:
case Operator_Member: case CT_Operator_Member:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -874,8 +866,8 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Operator_Fwd: case CT_Operator_Fwd:
case Operator_Member_Fwd: case CT_Operator_Member_Fwd:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -887,7 +879,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Operator_Cast: case CT_Operator_Cast:
{ {
check_member_str( Name ); check_member_str( Name );
check_member_ast( Specs ); check_member_ast( Specs );
@ -897,7 +889,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Operator_Cast_Fwd: case CT_Operator_Cast_Fwd:
{ {
check_member_str( Name ); check_member_str( Name );
check_member_ast( Specs ); check_member_ast( Specs );
@ -906,7 +898,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Parameters: case CT_Parameters:
{ {
if ( self->NumEntries > 1 ) if ( self->NumEntries > 1 )
{ {
@ -991,7 +983,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Preprocess_Define: case CT_Preprocess_Define:
{ {
check_member_str( Name ); check_member_str( Name );
check_member_content( Content ); check_member_content( Content );
@ -999,25 +991,25 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Preprocess_If: case CT_Preprocess_If:
case Preprocess_IfDef: case CT_Preprocess_IfDef:
case Preprocess_IfNotDef: case CT_Preprocess_IfNotDef:
case Preprocess_ElIf: case CT_Preprocess_ElIf:
{ {
check_member_content( Content ); check_member_content( Content );
return true; return true;
} }
case Preprocess_Include: case CT_Preprocess_Include:
case Preprocess_Pragma: case CT_Preprocess_Pragma:
{ {
check_member_content( Content ); check_member_content( Content );
return true; return true;
} }
case Specifiers: case CT_Specifiers:
{ {
check_member_val( NumEntries ); check_member_val( NumEntries );
check_member_str( Name ); check_member_str( Name );
@ -1028,7 +1020,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Template: case CT_Template:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -1038,7 +1030,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Typedef: case CT_Typedef:
{ {
check_member_val( IsFunction ); check_member_val( IsFunction );
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
@ -1048,7 +1040,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Typename: case CT_Typename:
{ {
check_member_val( IsParamPack ); check_member_val( IsParamPack );
check_member_str( Name ); check_member_str( Name );
@ -1058,7 +1050,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Union: case CT_Union:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -1068,8 +1060,8 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Using: case CT_Using:
case Using_Namespace: case CT_Using_Namespace:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -1079,7 +1071,7 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Variable: case CT_Variable:
{ {
check_member_val( ModuleFlags ); check_member_val( ModuleFlags );
check_member_str( Name ); check_member_str( Name );
@ -1093,13 +1085,13 @@ bool is_equal( Code self, Code other )
return true; return true;
} }
case Class_Body: case CT_Class_Body:
case Enum_Body: case CT_Enum_Body:
case Export_Body: case CT_Export_Body:
case Global_Body: case CT_Global_Body:
case Namespace_Body: case CT_Namespace_Body:
case Struct_Body: case CT_Struct_Body:
case Union_Body: case CT_Union_Body:
{ {
check_member_ast( Front ); check_member_ast( Front );
check_member_ast( Back ); check_member_ast( Back );
@ -1155,8 +1147,6 @@ bool is_equal( Code self, Code other )
bool validate_body(Code self) bool validate_body(Code self)
{ {
using namespace ECode;
#define CheckEntries( Unallowed_Types ) \ #define CheckEntries( Unallowed_Types ) \
do \ do \
{ \ { \
@ -1174,65 +1164,65 @@ bool validate_body(Code self)
switch ( self->Type ) switch ( self->Type )
{ {
case Class_Body: case CT_Class_Body:
CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES ); CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES );
break; break;
case Enum_Body: case CT_Enum_Body:
for ( Code entry : cast(CodeBody, self) ) 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) ); log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %s", GEN_NS debug_str(entry) );
return false; return false;
} }
} }
break; break;
case Export_Body: case CT_Export_Body:
CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES ); CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES );
break; break;
case Extern_Linkage: case CT_Extern_Linkage:
CheckEntries( GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES ); CheckEntries( GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES );
break; break;
case Function_Body: case CT_Function_Body:
CheckEntries( GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES ); CheckEntries( GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES );
break; break;
case Global_Body: case CT_Global_Body:
for (Code entry : cast(CodeBody, self)) for (Code entry : cast(CodeBody, self))
{ {
switch (entry->Type) switch (entry->Type)
{ {
case Access_Public: case CT_Access_Public:
case Access_Protected: case CT_Access_Protected:
case Access_Private: case CT_Access_Private:
case PlatformAttributes: case CT_PlatformAttributes:
case Class_Body: case CT_Class_Body:
case Enum_Body: case CT_Enum_Body:
case Execution: case CT_Execution:
case Friend: case CT_Friend:
case Function_Body: case CT_Function_Body:
case Global_Body: case CT_Global_Body:
case Namespace_Body: case CT_Namespace_Body:
case Operator_Member: case CT_Operator_Member:
case Operator_Member_Fwd: case CT_Operator_Member_Fwd:
case Parameters: case CT_Parameters:
case Specifiers: case CT_Specifiers:
case Struct_Body: case CT_Struct_Body:
case Typename: case CT_Typename:
log_failure("AST::validate_body: Invalid entry in body %s", GEN_NS debug_str(entry)); log_failure("AST::validate_body: Invalid entry in body %s", GEN_NS debug_str(entry));
return false; return false;
} }
} }
break; break;
case Namespace_Body: case CT_Namespace_Body:
CheckEntries( GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES ); CheckEntries( GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES );
break; break;
case Struct_Body: case CT_Struct_Body:
CheckEntries( GEN_AST_BODY_STRUCT_UNALLOWED_TYPES ); CheckEntries( GEN_AST_BODY_STRUCT_UNALLOWED_TYPES );
break; break;
case Union_Body: case CT_Union_Body:
for ( Code entry : cast(CodeBody, {self->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) ); log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %s", GEN_NS debug_str(entry) );
return false; return false;

View File

@ -67,7 +67,7 @@ struct AST_Stmt_While;
struct AST_Struct; struct AST_Struct;
struct AST_Template; struct AST_Template;
struct AST_Type; struct AST_Typename;
struct AST_Typedef; struct AST_Typedef;
struct AST_Union; struct AST_Union;
struct AST_Using; struct AST_Using;
@ -145,7 +145,7 @@ Define_Code(Stmt_While);
Define_Code(Struct); Define_Code(Struct);
Define_Code(Template); Define_Code(Template);
Define_Code(Type); Define_Code(Typename);
Define_Code(Typedef); Define_Code(Typedef);
Define_Code(Union); Define_Code(Union);
Define_Code(Using); Define_Code(Using);
@ -260,7 +260,7 @@ struct Code
operator CodeSpecifiers() const; operator CodeSpecifiers() const;
operator CodeStruct() const; operator CodeStruct() const;
operator CodeTemplate() const; operator CodeTemplate() const;
operator CodeType() const; operator CodeTypename() const;
operator CodeTypedef() const; operator CodeTypedef() const;
operator CodeUnion() const; operator CodeUnion() const;
operator CodeUsing() const; operator CodeUsing() const;
@ -294,7 +294,7 @@ int AST_ArrSpecs_Cap =
- sizeof(parser::Token*) - sizeof(parser::Token*)
- sizeof(AST*) - sizeof(AST*)
- sizeof(StringCached) - sizeof(StringCached)
- sizeof(CodeT) - sizeof(CodeType)
- sizeof(ModuleFlag) - sizeof(ModuleFlag)
- sizeof(int) - sizeof(int)
) )
@ -353,7 +353,7 @@ struct AST
parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing. parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
// CodeFlag CodeFlags; // CodeFlag CodeFlags;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
union { union {

View File

@ -1,78 +1,78 @@
# define GEN_AST_BODY_CLASS_UNALLOWED_TYPES \ # define GEN_AST_BODY_CLASS_UNALLOWED_TYPES \
case PlatformAttributes: \ case CT_PlatformAttributes: \
case Class_Body: \ case CT_Class_Body: \
case Enum_Body: \ case CT_Enum_Body: \
case Extern_Linkage: \ case CT_Extern_Linkage: \
case Function_Body: \ case CT_Function_Body: \
case Function_Fwd: \ case CT_Function_Fwd: \
case Global_Body: \ case CT_Global_Body: \
case Namespace: \ case CT_Namespace: \
case Namespace_Body: \ case CT_Namespace_Body: \
case ECode::Operator: \ case CT_Operator: \
case Operator_Fwd: \ case CT_Operator_Fwd: \
case Parameters: \ case CT_Parameters: \
case Specifiers: \ case CT_Specifiers: \
case Struct_Body: \ case CT_Struct_Body: \
case Typename: case CT_Typename:
# define GEN_AST_BODY_STRUCT_UNALLOWED_TYPES GEN_AST_BODY_CLASS_UNALLOWED_TYPES # define GEN_AST_BODY_STRUCT_UNALLOWED_TYPES GEN_AST_BODY_CLASS_UNALLOWED_TYPES
# define GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES \ # define GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES \
case Access_Public: \ case CT_Access_Public: \
case Access_Protected: \ case CT_Access_Protected: \
case Access_Private: \ case CT_Access_Private: \
case PlatformAttributes: \ case CT_PlatformAttributes: \
case Class_Body: \ case CT_Class_Body: \
case Enum_Body: \ case CT_Enum_Body: \
case Extern_Linkage: \ case CT_Extern_Linkage: \
case Friend: \ case CT_Friend: \
case Function_Body: \ case CT_Function_Body: \
case Function_Fwd: \ case CT_Function_Fwd: \
case Global_Body: \ case CT_Global_Body: \
case Namespace: \ case CT_Namespace: \
case Namespace_Body: \ case CT_Namespace_Body: \
case ECode::Operator: \ case CT_Operator: \
case Operator_Fwd: \ case CT_Operator_Fwd: \
case Operator_Member: \ case CT_Operator_Member: \
case Operator_Member_Fwd: \ case CT_Operator_Member_Fwd: \
case Parameters: \ case CT_Parameters: \
case Specifiers: \ case CT_Specifiers: \
case Struct_Body: \ case CT_Struct_Body: \
case Typename: case CT_Typename:
# define GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES \ # define GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES \
case Access_Public: \ case CT_Access_Public: \
case Access_Protected: \ case CT_Access_Protected: \
case Access_Private: \ case CT_Access_Private: \
case PlatformAttributes: \ case CT_PlatformAttributes: \
case Class_Body: \ case CT_Class_Body: \
case Enum_Body: \ case CT_Enum_Body: \
case Execution: \ case CT_Execution: \
case Friend: \ case CT_Friend: \
case Function_Body: \ case CT_Function_Body: \
case Namespace_Body: \ case CT_Namespace_Body: \
case Operator_Member: \ case CT_Operator_Member: \
case Operator_Member_Fwd: \ case CT_Operator_Member_Fwd: \
case Parameters: \ case CT_Parameters: \
case Specifiers: \ case CT_Specifiers: \
case Struct_Body: \ case CT_Struct_Body: \
case Typename: case CT_Typename:
# define GEN_AST_BODY_EXPORT_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES # 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_EXTERN_LINKAGE_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
# define GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES \ # define GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES \
case Access_Public: \ case CT_Access_Public: \
case Access_Protected: \ case CT_Access_Protected: \
case Access_Private: \ case CT_Access_Private: \
case PlatformAttributes: \ case CT_PlatformAttributes: \
case Class_Body: \ case CT_Class_Body: \
case Enum_Body: \ case CT_Enum_Body: \
case Execution: \ case CT_Execution: \
case Friend: \ case CT_Friend: \
case Function_Body: \ case CT_Function_Body: \
case Namespace_Body: \ case CT_Namespace_Body: \
case Operator_Member: \ case CT_Operator_Member: \
case Operator_Member_Fwd: \ case CT_Operator_Member_Fwd: \
case Parameters: \ case CT_Parameters: \
case Specifiers: \ case CT_Specifiers: \
case Struct_Body: \ case CT_Struct_Body: \
case Typename: case CT_Typename:

View File

@ -18,7 +18,7 @@ struct AST_Body
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries; s32 NumEntries;
}; };
@ -35,7 +35,7 @@ struct AST_Attributes
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_BaseClass) == sizeof(AST), "ERROR: AST_BaseClass is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not the same size as AST"); 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 CodeComment InlineCmt; // Only supported by forward declarations
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ]; char _PAD_SPECS_ [ sizeof(AST*) ];
CodeType ParentType; CodeTypename ParentType;
char _PAD_PARAMS_[ sizeof(AST*) ]; char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
CodeType Prev; CodeTypename Prev;
CodeType Next; CodeTypename Next;
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
AccessSpec ParentAccess; AccessSpec ParentAccess;
}; };
@ -119,7 +119,7 @@ struct AST_Constructor
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is not the same size as AST"); 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; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPEC_ [ sizeof(AST*) ]; char _PAD_SPEC_ [ sizeof(AST*) ];
CodeType UnderlyingType; CodeTypename UnderlyingType;
Code UnderlyingTypeMacro; Code UnderlyingTypeMacro;
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
@ -184,7 +184,7 @@ struct AST_Enum
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
b32 EnumUnderlyingMacro; b32 EnumUnderlyingMacro;
}; };
@ -201,7 +201,7 @@ struct AST_Exec
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Expr) == sizeof(AST), "ERROR: AST_Expr is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the same size as AST"); 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; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeType ReturnType; CodeTypename ReturnType;
CodeParam Params; CodeParam Params;
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ]; char _PAD_PROPERTIES_ [ sizeof(AST*) ];
@ -542,7 +542,7 @@ struct AST_Fn
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
@ -556,7 +556,7 @@ struct AST_Module
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
@ -577,7 +577,7 @@ struct AST_NS
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
@ -592,7 +592,7 @@ struct AST_Operator
CodeComment InlineCmt; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeType ReturnType; CodeTypename ReturnType;
CodeParam Params; CodeParam Params;
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ]; char _PAD_PROPERTIES_ [ sizeof(AST*) ];
@ -603,7 +603,7 @@ struct AST_Operator
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
Operator Op; Operator Op;
}; };
@ -615,10 +615,10 @@ struct AST_OpCast
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
char _PAD_PROPERTIES_[ sizeof(AST*) ]; char _PAD_PROPERTIES_[ sizeof(AST*) ];
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeType ValueType; CodeTypename ValueType;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_3_[ sizeof(AST*) ]; char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
@ -629,7 +629,7 @@ struct AST_OpCast
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST"); 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*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
CodeType ValueType; CodeTypename ValueType;
Code Macro; Code Macro;
Code Value; Code Value;
Code PostNameMacro; // Thanks Unreal Code PostNameMacro; // Thanks Unreal
// char _PAD_PROPERTIES_3_[sizeof( AST* )]; // char _PAD_PROPERTIES_3_[sizeof( AST* )];
}; };
}; };
@ -653,7 +653,7 @@ struct AST_Param
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries; s32 NumEntries;
}; };
@ -670,7 +670,7 @@ struct AST_Pragma
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_PreprocessCond is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries; s32 NumEntries;
}; };
@ -717,7 +717,7 @@ struct AST_Stmt
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Stmt) == sizeof(AST), "ERROR: AST_Stmt is not the same size as AST"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; 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"); 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; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ]; char _PAD_SPECS_ [ sizeof(AST*) ];
CodeType ParentType; CodeTypename ParentType;
char _PAD_PARAMS_[ sizeof(AST*) ]; char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
CodeType Prev; CodeTypename Prev;
CodeType Next; CodeTypename Next;
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
AccessSpec ParentAccess; AccessSpec ParentAccess;
}; };
@ -961,7 +961,7 @@ struct AST_Template
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
@ -976,12 +976,12 @@ struct AST_Type
struct struct
{ {
char _PAD_INLINE_CMT_[ sizeof(AST*) ]; char _PAD_INLINE_CMT_[ sizeof(AST*) ];
CodeAttributes Attributes; CodeAttributes Attributes;
CodeSpecifiers Specs; CodeSpecifiers Specs;
Code QualifierID; Code QualifierID;
// CodeType ReturnType; // Only used for function signatures // CodeTypename ReturnType; // Only used for function signatures
// CodeParam Params; // Only used for function signatures // CodeParam Params; // Only used for function signatures
Code ArrExpr; Code ArrExpr;
// CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures // CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
}; };
}; };
@ -990,14 +990,14 @@ struct AST_Type
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
b32 IsParamPack; b32 IsParamPack;
}; };
static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST"); static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST");
#endif #endif
struct AST_Type struct AST_Typename
{ {
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
@ -1006,7 +1006,7 @@ struct AST_Type
char _PAD_INLINE_CMT_[ sizeof(AST*) ]; char _PAD_INLINE_CMT_[ sizeof(AST*) ];
CodeAttributes Attributes; CodeAttributes Attributes;
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeType ReturnType; // Only used for function signatures CodeTypename ReturnType; // Only used for function signatures
CodeParam Params; // Only used for function signatures CodeParam Params; // Only used for function signatures
Code ArrExpr; Code ArrExpr;
CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
@ -1017,11 +1017,11 @@ struct AST_Type
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
b32 IsParamPack; 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 struct AST_Typedef
{ {
@ -1040,7 +1040,7 @@ struct AST_Typedef
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
b32 IsFunction; b32 IsFunction;
}; };
@ -1064,7 +1064,7 @@ struct AST_Union
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
@ -1079,7 +1079,7 @@ struct AST_Using
CodeComment InlineCmt; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ]; char _PAD_SPECS_ [ sizeof(AST*) ];
CodeType UnderlyingType; CodeTypename UnderlyingType;
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
}; };
}; };
@ -1088,7 +1088,7 @@ struct AST_Using
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
@ -1103,7 +1103,7 @@ struct AST_Var
CodeComment InlineCmt; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeType ValueType; CodeTypename ValueType;
Code BitfieldSize; Code BitfieldSize;
Code Value; Code Value;
CodeVar NextVar; CodeVar NextVar;
@ -1114,7 +1114,7 @@ struct AST_Var
parser::Token* Tok; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
s32 VarConstructorInit; s32 VarConstructorInit;
}; };

View File

@ -13,24 +13,23 @@ String to_string(CodeBody body)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( body.ast->Type ) switch ( body.ast->Type )
{ {
using namespace ECode; case CT_Untyped:
case Untyped: case CT_Execution:
case Execution:
append( & result, rcast(AST*, body.ast)->Content ); append( & result, rcast(AST*, body.ast)->Content );
break; break;
case Enum_Body: case CT_Enum_Body:
case Class_Body: case CT_Class_Body:
case Extern_Linkage_Body: case CT_Extern_Linkage_Body:
case Function_Body: case CT_Function_Body:
case Global_Body: case CT_Global_Body:
case Namespace_Body: case CT_Namespace_Body:
case Struct_Body: case CT_Struct_Body:
case Union_Body: case CT_Union_Body:
to_string( body, & result ); to_string( body, & result );
break; break;
case Export_Body: case CT_Export_Body:
to_string_export( body, & result ); to_string_export( body, & result );
break; break;
} }
@ -77,11 +76,10 @@ String to_string(CodeConstructor self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch (self->Type) switch (self->Type)
{ {
using namespace ECode; case CT_Constructor:
case Constructor:
to_string_def( self, & result ); to_string_def( self, & result );
break; break;
case Constructor_Fwd: case CT_Constructor_Fwd:
to_string_fwd( self, & result ); to_string_fwd( self, & result );
break; break;
} }
@ -141,11 +139,10 @@ String to_string( CodeClass self )
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Class:
case Class:
to_string_def(self, & result ); to_string_def(self, & result );
break; break;
case Class_Fwd: case CT_Class_Fwd:
to_string_fwd(self, & result ); to_string_fwd(self, & result );
break; 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) ); 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 ) if ( interface )
append( result, "\n" ); append( result, "\n" );
while ( interface ) while ( interface )
{ {
append_fmt( result, ", %S", to_string(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 ) 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) ); 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"); append( result, ";\n");
} }
@ -213,7 +210,7 @@ void to_string_fwd( CodeClass self, String* result )
else append_fmt( result, "class %S", ast->Name ); else append_fmt( result, "class %S", ast->Name );
// Check if it can have an end-statement // 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 ) if ( ast->InlineCmt )
append_fmt( result, "; // %S\n", ast->InlineCmt->Content ); append_fmt( result, "; // %S\n", ast->InlineCmt->Content );
@ -237,11 +234,10 @@ String to_string(CodeDestructor self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Destructor:
case Destructor:
to_string_def( self, & result ); to_string_def( self, & result );
break; break;
case Destructor_Fwd: case CT_Destructor_Fwd:
to_string_fwd( self, & result ); to_string_fwd( self, & result );
break; break;
} }
@ -295,17 +291,16 @@ String to_string(CodeEnum self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Enum:
case Enum:
to_string_def(self, & result ); to_string_def(self, & result );
break; break;
case Enum_Fwd: case CT_Enum_Fwd:
to_string_fwd(self, & result ); to_string_fwd(self, & result );
break; break;
case Enum_Class: case CT_Enum_Class:
to_string_class_def(self, & result ); to_string_class_def(self, & result );
break; break;
case Enum_Class_Fwd: case CT_Enum_Class_Fwd:
to_string_class_fwd(self, & result ); to_string_class_fwd(self, & result );
break; 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) ); 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"); append( result, ";\n");
} }
@ -358,7 +353,7 @@ void to_string_fwd(CodeEnum self, String* result )
else else
append_fmt( result, "enum %S", self->Name ); 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 ) if ( self->InlineCmt )
append_fmt( result, "; %S", self->InlineCmt->Content ); 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) ); 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"); 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) ); 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 ) if ( self->InlineCmt )
append_fmt( result, "; %S", self->InlineCmt->Content ); 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) ); 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, ";" ); append( result, ";" );
} }
@ -470,11 +465,10 @@ String to_string(CodeFn self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Function:
case Function:
to_string_def(self, & result ); to_string_def(self, & result );
break; break;
case Function_Fwd: case CT_Function_Fwd:
to_string_fwd(self, & result ); to_string_fwd(self, & result );
break; break;
} }
@ -635,13 +629,12 @@ String to_string(CodeOperator self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Operator:
case ECode::Operator: case CT_Operator_Member:
case Operator_Member:
to_string_def( self, & result ); to_string_def( self, & result );
break; break;
case Operator_Fwd: case CT_Operator_Fwd:
case Operator_Member_Fwd: case CT_Operator_Member_Fwd:
to_string_fwd( self, & result ); to_string_fwd( self, & result );
break; break;
} }
@ -758,11 +751,10 @@ String to_string(CodeOpCast self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Operator_Cast:
case Operator_Cast:
to_string_def(self, & result ); to_string_def(self, & result );
break; break;
case Operator_Cast_Fwd: case CT_Operator_Cast_Fwd:
to_string_fwd(self, & result ); to_string_fwd(self, & result );
break; break;
} }
@ -893,23 +885,22 @@ String to_string(CodePreprocessCond self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Preprocess_If:
case Preprocess_If:
to_string_if( self, & result ); to_string_if( self, & result );
break; break;
case Preprocess_IfDef: case CT_Preprocess_IfDef:
to_string_ifdef( self, & result ); to_string_ifdef( self, & result );
break; break;
case Preprocess_IfNotDef: case CT_Preprocess_IfNotDef:
to_string_ifndef( self, & result ); to_string_ifndef( self, & result );
break; break;
case Preprocess_ElIf: case CT_Preprocess_ElIf:
to_string_elif( self, & result ); to_string_elif( self, & result );
break; break;
case Preprocess_Else: case CT_Preprocess_Else:
to_string_else( self, & result ); to_string_else( self, & result );
break; break;
case Preprocess_EndIf: case CT_Preprocess_EndIf:
to_string_endif( self, & result ); to_string_endif( self, & result );
break; break;
} }
@ -985,11 +976,10 @@ String to_string(CodeStruct self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Struct:
case Struct:
to_string_def( self, & result ); to_string_def( self, & result );
break; break;
case Struct_Fwd: case CT_Struct_Fwd:
to_string_fwd( self, & result ); to_string_fwd( self, & result );
break; 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) ); 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 ) if ( interface )
append( result, "\n" ); append( result, "\n" );
while ( interface ) while ( interface )
{ {
append_fmt( result, ", %S", GEN_NS to_string(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 ) 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) ); 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"); append( result, ";\n");
} }
@ -1056,7 +1046,7 @@ void to_string_fwd( CodeStruct self, String* result )
else append_fmt( result, "struct %S", ast->Name ); 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 ) if ( ast->InlineCmt )
append_fmt( result, "; %S", ast->InlineCmt->Content ); append_fmt( result, "; %S", ast->InlineCmt->Content );
@ -1103,7 +1093,7 @@ void to_string(CodeTypedef self, String* result )
else else
append_fmt( result, "%S %S", GEN_NS to_string(self->UnderlyingType), self->Name ); 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) ); 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"); append( result, "\n");
} }
String to_string(CodeType self) String to_string(CodeTypename self)
{ {
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
to_string( self, & result ); to_string( self, & result );
return 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 defined(GEN_USE_NEW_TYPENAME_PARSING)
if ( self->ReturnType && self->Params ) 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"); append( result, ";\n");
} }
@ -1219,11 +1209,10 @@ String to_string(CodeUsing self)
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( self->Type ) switch ( self->Type )
{ {
using namespace ECode; case CT_Using:
case Using:
to_string( self, & result ); to_string( self, & result );
break; break;
case Using_Namespace: case CT_Using_Namespace:
to_string_ns( self, & result ); to_string_ns( self, & result );
break; break;
} }
@ -1282,7 +1271,7 @@ String to_string(CodeVar self)
void to_string(CodeVar self, String* result ) 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 ) // Its a comma-separated variable ( a NextVar )

View File

@ -103,8 +103,8 @@ void to_string_endif (CodePreprocessCond cond, String* result );
String to_string(CodeTemplate self); String to_string(CodeTemplate self);
void to_string(CodeTemplate self, String* result); void to_string(CodeTemplate self, String* result);
String to_string(CodeType self); String to_string(CodeTypename self);
void to_string(CodeType self, String* result); void to_string(CodeTypename self, String* result);
String to_string(CodeTypedef self); String to_string(CodeTypedef self);
void to_string(CodeTypedef self, String* result); void to_string(CodeTypedef self, String* result);
@ -927,19 +927,19 @@ struct CodeTemplate
AST_Template* ast; AST_Template* ast;
}; };
struct CodeType struct CodeTypename
{ {
#if GEN_SUPPORT_CPP_MEMBER_FEATURES #if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code( CodeType ); Using_Code( CodeTypename );
String to_string() { return GEN_NS to_string(* this); } String to_string() { return GEN_NS to_string(* this); }
void to_string( String& result ) { return GEN_NS to_string(* this, & result); } void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
#endif #endif
Using_CodeOps( CodeType ); Using_CodeOps( CodeTypename );
operator Code(); operator Code();
AST_Type* operator->(); AST_Typename* operator->();
AST_Type* ast; AST_Typename* ast;
}; };
struct CodeTypedef struct CodeTypedef
@ -1040,7 +1040,7 @@ struct InvalidCode_ImplictCaster
operator CodeSpecifiers () const { return cast(CodeSpecifiers, Code_Invalid); } operator CodeSpecifiers () const { return cast(CodeSpecifiers, Code_Invalid); }
operator CodeStruct () const { return cast(CodeStruct, Code_Invalid); } operator CodeStruct () const { return cast(CodeStruct, Code_Invalid); }
operator CodeTemplate () const { return cast(CodeTemplate, 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 CodeTypedef () const { return cast(CodeTypedef, Code_Invalid); }
operator CodeUnion () const { return cast(CodeUnion, Code_Invalid); } operator CodeUnion () const { return cast(CodeUnion, Code_Invalid); }
operator CodeUsing () const { return cast(CodeUsing, Code_Invalid); } operator CodeUsing () const { return cast(CodeUsing, Code_Invalid); }

View File

@ -661,7 +661,7 @@ inline AST_Template* CodeTemplate::operator->()
return ast; return ast;
} }
inline CodeType& CodeType::operator=( Code other ) inline CodeTypename& CodeTypename::operator=( Code other )
{ {
if ( other.ast && other->Parent ) if ( other.ast && other->Parent )
{ {
@ -672,17 +672,17 @@ inline CodeType& CodeType::operator=( Code other )
return *this; return *this;
} }
inline CodeType::operator bool() inline CodeTypename::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
} }
inline CodeType::operator Code() inline CodeTypename::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
} }
inline AST_Type* CodeType::operator->() inline AST_Typename* CodeTypename::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
@ -935,9 +935,9 @@ inline Code::operator CodeTemplate() const
return { (AST_Template*)ast }; 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 inline Code::operator CodeTypedef() const

View File

@ -5,140 +5,136 @@
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
namespace ECode typedef enum CodeType_Def CodeType;
enum CodeType_Def : u32
{ {
enum Type : u32 CT_Invalid,
{ CT_Untyped,
Invalid, CT_NewLine,
Untyped, CT_Comment,
NewLine, CT_Access_Private,
Comment, CT_Access_Protected,
Access_Private, CT_Access_Public,
Access_Protected, CT_PlatformAttributes,
Access_Public, CT_Class,
PlatformAttributes, CT_Class_Fwd,
Class, CT_Class_Body,
Class_Fwd, CT_Constructor,
Class_Body, CT_Constructor_Fwd,
Constructor, CT_Destructor,
Constructor_Fwd, CT_Destructor_Fwd,
Destructor, CT_Enum,
Destructor_Fwd, CT_Enum_Fwd,
Enum, CT_Enum_Body,
Enum_Fwd, CT_Enum_Class,
Enum_Body, CT_Enum_Class_Fwd,
Enum_Class, CT_Execution,
Enum_Class_Fwd, CT_Export_Body,
Execution, CT_Extern_Linkage,
Export_Body, CT_Extern_Linkage_Body,
Extern_Linkage, CT_Friend,
Extern_Linkage_Body, CT_Function,
Friend, CT_Function_Fwd,
Function, CT_Function_Body,
Function_Fwd, CT_Global_Body,
Function_Body, CT_Module,
Global_Body, CT_Namespace,
Module, CT_Namespace_Body,
Namespace, CT_Operator,
Namespace_Body, CT_Operator_Fwd,
Operator, CT_Operator_Member,
Operator_Fwd, CT_Operator_Member_Fwd,
Operator_Member, CT_Operator_Cast,
Operator_Member_Fwd, CT_Operator_Cast_Fwd,
Operator_Cast, CT_Parameters,
Operator_Cast_Fwd, CT_Preprocess_Define,
Parameters, CT_Preprocess_Include,
Preprocess_Define, CT_Preprocess_If,
Preprocess_Include, CT_Preprocess_IfDef,
Preprocess_If, CT_Preprocess_IfNotDef,
Preprocess_IfDef, CT_Preprocess_ElIf,
Preprocess_IfNotDef, CT_Preprocess_Else,
Preprocess_ElIf, CT_Preprocess_EndIf,
Preprocess_Else, CT_Preprocess_Pragma,
Preprocess_EndIf, CT_Specifiers,
Preprocess_Pragma, CT_Struct,
Specifiers, CT_Struct_Fwd,
Struct, CT_Struct_Body,
Struct_Fwd, CT_Template,
Struct_Body, CT_Typedef,
Template, CT_Typename,
Typedef, CT_Union,
Typename, CT_Union_Body,
Union, CT_Using,
Union_Body, CT_Using_Namespace,
Using, CT_Variable,
Using_Namespace, CT_NumTypes
Variable, };
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" },
}; };
return lookup[type];
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;

View File

@ -97,36 +97,36 @@ extern CodeSpecifiers spec_thread_local;
extern CodeSpecifiers spec_virtual; extern CodeSpecifiers spec_virtual;
extern CodeSpecifiers spec_volatile; extern CodeSpecifiers spec_volatile;
extern CodeType t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance) extern CodeTypename t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance)
extern CodeType t_auto; extern CodeTypename t_auto;
extern CodeType t_void; extern CodeTypename t_void;
extern CodeType t_int; extern CodeTypename t_int;
extern CodeType t_bool; extern CodeTypename t_bool;
extern CodeType t_char; extern CodeTypename t_char;
extern CodeType t_wchar_t; extern CodeTypename t_wchar_t;
extern CodeType t_class; extern CodeTypename t_class;
extern CodeType t_typename; extern CodeTypename t_typename;
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
// Predefined typename codes. Are set to readonly and are setup during gen::init() // 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 CodeTypename t_s8;
extern CodeType t_s16; extern CodeTypename t_s16;
extern CodeType t_s32; extern CodeTypename t_s32;
extern CodeType t_s64; extern CodeTypename t_s64;
extern CodeType t_u8; extern CodeTypename t_u8;
extern CodeType t_u16; extern CodeTypename t_u16;
extern CodeType t_u32; extern CodeTypename t_u32;
extern CodeType t_u64; extern CodeTypename t_u64;
extern CodeType t_ssize; extern CodeTypename t_ssize;
extern CodeType t_usize; extern CodeTypename t_usize;
extern CodeType t_f32; extern CodeTypename t_f32;
extern CodeType t_f64; extern CodeTypename t_f64;
#endif #endif
#pragma endregion Constants #pragma endregion Constants

View File

@ -37,15 +37,15 @@ bool is_body(Code self)
GEN_ASSERT(self != nullptr); GEN_ASSERT(self != nullptr);
switch (self->Type) switch (self->Type)
{ {
case ECode::Enum_Body: case CT_Enum_Body:
case ECode::Class_Body: case CT_Class_Body:
case ECode::Union_Body: case CT_Union_Body:
case ECode::Export_Body: case CT_Export_Body:
case ECode::Global_Body: case CT_Global_Body:
case ECode::Struct_Body: case CT_Struct_Body:
case ECode::Function_Body: case CT_Function_Body:
case ECode::Namespace_Body: case CT_Namespace_Body:
case ECode::Extern_Linkage_Body: case CT_Extern_Linkage_Body:
return true; return true;
} }
return false; return false;
@ -69,7 +69,7 @@ Code* entry( Code self, u32 idx )
inline inline
bool is_valid(Code self) bool is_valid(Code self)
{ {
return self.ast != nullptr && self.ast->Type != CodeT::Invalid; return self.ast != nullptr && self.ast->Type != CT_Invalid;
} }
inline inline
bool has_entries(AST* self) bool has_entries(AST* self)
@ -100,7 +100,7 @@ inline
char const* type_str(Code self) char const* type_str(Code self)
{ {
GEN_ASSERT(self != nullptr); GEN_ASSERT(self != nullptr);
return ECode::to_str( self->Type ); return to_str( self->Type );
} }
#pragma endregion Code #pragma endregion Code
@ -140,10 +140,10 @@ Code end(CodeBody body ){
#pragma region CodeClass #pragma region CodeClass
inline inline
void add_interface( CodeClass self, CodeType type ) void add_interface( CodeClass self, CodeTypename type )
{ {
GEN_ASSERT(self.ast !=nullptr); GEN_ASSERT(self.ast !=nullptr);
CodeType possible_slot = self->ParentType; CodeTypename possible_slot = self->ParentType;
if ( possible_slot.ast ) if ( possible_slot.ast )
{ {
// Were adding an interface to parent type, so we need to make sure the parent type is public. // 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 ) 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; possible_slot.ast = type.ast;
@ -317,9 +317,9 @@ Specifier* end(CodeSpecifiers self)
#pragma region CodeStruct #pragma region CodeStruct
inline 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 ) if ( possible_slot.ast )
{ {
// Were adding an interface to parent type, so we need to make sure the parent type is public. // 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 ) 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; possible_slot.ast = type.ast;
@ -339,24 +339,23 @@ void add_interface(CodeStruct self, CodeType type )
#pragma region Interface #pragma region Interface
inline inline
CodeBody def_body( CodeT type ) CodeBody def_body( CodeType type )
{ {
switch ( type ) switch ( type )
{ {
using namespace ECode; case CT_Class_Body:
case Class_Body: case CT_Enum_Body:
case Enum_Body: case CT_Export_Body:
case Export_Body: case CT_Extern_Linkage:
case Extern_Linkage: case CT_Function_Body:
case Function_Body: case CT_Global_Body:
case Global_Body: case CT_Namespace_Body:
case Namespace_Body: case CT_Struct_Body:
case Struct_Body: case CT_Union_Body:
case Union_Body:
break; break;
default: 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; return (CodeBody)Code_Invalid;
} }

View File

@ -81,23 +81,23 @@ void define_constants()
Code_Invalid = make_code(); Code_Invalid = make_code();
set_global(Code_Invalid); set_global(Code_Invalid);
t_empty = (CodeType) make_code(); t_empty = (CodeTypename) make_code();
t_empty->Type = ECode::Typename; t_empty->Type = CT_Typename;
t_empty->Name = get_cached_string( txt("") ); t_empty->Name = get_cached_string( txt("") );
set_global(t_empty); set_global(t_empty);
access_private = make_code(); 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") ); access_private->Name = get_cached_string( txt("private:\n") );
set_global(access_private); set_global(access_private);
access_protected = make_code(); 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") ); access_protected->Name = get_cached_string( txt("protected:\n") );
set_global(access_protected); set_global(access_protected);
access_public = make_code(); 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") ); access_public->Name = get_cached_string( txt("public:\n") );
set_global(access_public); set_global(access_public);
@ -108,39 +108,39 @@ void define_constants()
set_global(attrib_api_import); set_global(attrib_api_import);
module_global_fragment = make_code(); 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->Name = get_cached_string( txt("module;") );
module_global_fragment->Content = module_global_fragment->Name; module_global_fragment->Content = module_global_fragment->Name;
set_global(module_global_fragment); set_global(module_global_fragment);
module_private_fragment = make_code(); 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->Name = get_cached_string( txt("module : private;") );
module_private_fragment->Content = module_private_fragment->Name; module_private_fragment->Content = module_private_fragment->Name;
set_global(module_private_fragment); set_global(module_private_fragment);
fmt_newline = make_code(); fmt_newline = make_code();
fmt_newline->Type = ECode::NewLine; fmt_newline->Type = CT_NewLine;
set_global(fmt_newline); set_global(fmt_newline);
pragma_once = (CodePragma) make_code(); 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->Name = get_cached_string( txt("once") );
pragma_once->Content = pragma_once->Name; pragma_once->Content = pragma_once->Name;
set_global(pragma_once); set_global(pragma_once);
param_varadic = (CodeType) make_code(); param_varadic = (CodeTypename) make_code();
param_varadic->Type = ECode::Parameters; param_varadic->Type = CT_Parameters;
param_varadic->Name = get_cached_string( txt("...") ); param_varadic->Name = get_cached_string( txt("...") );
param_varadic->ValueType = t_empty; param_varadic->ValueType = t_empty;
set_global(param_varadic); set_global(param_varadic);
preprocess_else = (CodePreprocessCond) make_code(); preprocess_else = (CodePreprocessCond) make_code();
preprocess_else->Type = ECode::Preprocess_Else; preprocess_else->Type = CT_Preprocess_Else;
set_global(preprocess_else); set_global(preprocess_else);
preprocess_endif = (CodePreprocessCond) make_code(); preprocess_endif = (CodePreprocessCond) make_code();
preprocess_endif->Type = ECode::Preprocess_EndIf; preprocess_endif->Type = CT_Preprocess_EndIf;
set_global(preprocess_endif); set_global(preprocess_endif);
# define def_constant_code_type( Type_ ) \ # define def_constant_code_type( Type_ ) \

View File

@ -44,11 +44,11 @@ CodeComment def_comment ( StrC content );
struct Opts_def_struct { struct Opts_def_struct {
Code body; Code body;
CodeType parent; CodeTypename parent;
AccessSpec parent_access; AccessSpec parent_access;
CodeAttributes attributes; CodeAttributes attributes;
ModuleFlag mflags; ModuleFlag mflags;
CodeType* interfaces; CodeTypename* interfaces;
s32 num_interfaces; s32 num_interfaces;
}; };
CodeClass def_class( StrC name, Opts_def_struct otps GEN_PARAM_DEFAULT ); 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 { struct Opts_def_enum {
Code body; Code body;
CodeType type; CodeTypename type;
EnumT specifier; EnumT specifier;
CodeAttributes attributes; CodeAttributes attributes;
ModuleFlag mflags; ModuleFlag mflags;
@ -83,7 +83,7 @@ CodeFriend def_friend ( Code symbol );
struct Opts_def_function { struct Opts_def_function {
CodeParam params; CodeParam params;
CodeType ret_type; CodeTypename ret_type;
Code body; Code body;
CodeSpecifiers specs; CodeSpecifiers specs;
CodeAttributes attrs; CodeAttributes attrs;
@ -100,7 +100,7 @@ CodeNS def_namespace( StrC name, Code body, Opts_def_namespace opts GEN_PAR
struct Opts_def_operator { struct Opts_def_operator {
CodeParam params; CodeParam params;
CodeType ret_type; CodeTypename ret_type;
Code body; Code body;
CodeSpecifiers specifiers; CodeSpecifiers specifiers;
CodeAttributes attributes; CodeAttributes attributes;
@ -112,10 +112,10 @@ struct Opts_def_operator_cast {
Code body; Code body;
CodeSpecifiers specs; 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; }; 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 ); CodePragma def_pragma( StrC directive );
CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content ); CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content );
@ -132,7 +132,7 @@ struct Opts_def_type {
CodeSpecifiers specifiers; CodeSpecifiers specifiers;
CodeAttributes attributes; 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 { struct Opts_def_typedef {
CodeAttributes attributes; CodeAttributes attributes;
@ -161,10 +161,10 @@ struct Opts_def_variable
CodeAttributes attributes; CodeAttributes attributes;
ModuleFlag mflags; 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. // 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, // 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. /// 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 ); CodeOpCast parse_operator_cast( StrC operator_def );
CodeStruct parse_struct ( StrC struct_def ); CodeStruct parse_struct ( StrC struct_def );
CodeTemplate parse_template ( StrC template_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 ); CodeTypedef parse_typedef ( StrC typedef_def );
CodeUnion parse_union ( StrC union_def ); CodeUnion parse_union ( StrC union_def );
CodeUsing parse_using ( StrC using_def ); CodeUsing parse_using ( StrC using_def );

View File

@ -180,7 +180,7 @@ CodeBody parse_global_body( StrC def )
Context.Tokens = toks; Context.Tokens = toks;
push_scope(); push_scope();
CodeBody result = parse_global_nspace( ECode::Global_Body ); CodeBody result = parse_global_nspace( CT_Global_Body );
pop(& Context); pop(& Context);
return result; return result;
} }
@ -253,7 +253,7 @@ CodeTemplate parse_template( StrC def )
return parse_template(); return parse_template();
} }
CodeType parse_type( StrC def ) CodeTypename parse_type( StrC def )
{ {
GEN_USING_NS_PARSER; GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );

View File

@ -112,7 +112,7 @@ Code untyped_str( StrC content )
Code Code
result = make_code(); result = make_code();
result->Name = get_cached_string( content ); result->Name = get_cached_string( content );
result->Type = ECode::Untyped; result->Type = CT_Untyped;
result->Content = result->Name; result->Content = result->Name;
if ( result->Name == nullptr ) if ( result->Name == nullptr )
@ -143,7 +143,7 @@ Code untyped_fmt( char const* fmt, ...)
Code Code
result = make_code(); result = make_code();
result->Name = get_cached_string( { str_len(fmt, MaxNameLength), fmt } ); 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 } ); result->Content = get_cached_string( { length, buf } );
if ( result->Name == nullptr ) if ( result->Name == nullptr )
@ -174,7 +174,7 @@ Code untyped_token_fmt( s32 num_tokens, ... )
Code Code
result = make_code(); result = make_code();
result->Name = get_cached_string( { length, buf } ); result->Name = get_cached_string( { length, buf } );
result->Type = ECode::Untyped; result->Type = CT_Untyped;
result->Content = result->Name; result->Content = result->Name;
if ( result->Name == nullptr ) if ( result->Name == nullptr )

File diff suppressed because it is too large Load Diff

View File

@ -203,13 +203,13 @@ internal Code parse_class_struct ( TokType which,
internal CodeDefine parse_define (); internal CodeDefine parse_define ();
internal Code parse_expression (); internal Code parse_expression ();
internal Code parse_forward_or_definition ( TokType which, bool is_inplace ); 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_function_body ();
internal Code parse_global_nspace (); internal Code parse_global_nspace ();
internal Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ); internal Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers );
internal Token parse_identifier ( bool* possible_member_function = nullptr ); internal Token parse_identifier ( bool* possible_member_function = nullptr );
internal CodeInclude parse_include (); 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 Code parse_operator_function_or_variable( bool expects_function, CodeAttributes attributes, CodeSpecifiers specifiers );
internal CodePragma parse_pragma (); internal CodePragma parse_pragma ();
internal CodeParam parse_params ( bool use_template_capture = false ); 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_simple_preprocess ( TokType which );
internal Code parse_static_assert (); internal Code parse_static_assert ();
internal void parse_template_args ( Token& token ); 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 CodeVar parse_variable_declaration_list ();
internal CodeClass parse_class ( bool inplace_def = false ); 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 CodeStruct parse_struct ( bool inplace_def = false );
internal CodeVar parse_variable (); internal CodeVar parse_variable ();
internal CodeTemplate parse_template (); 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 CodeTypedef parse_typedef ();
internal CodeUnion parse_union ( bool inplace_def = false ); internal CodeUnion parse_union ( bool inplace_def = false );
internal CodeUsing parse_using (); internal CodeUsing parse_using ();
@ -668,7 +668,7 @@ CodeAttributes parse_attributes()
String name_stripped = strip_formatting( attribute_txt, strip_formatting_dont_preserve_newlines ); String name_stripped = strip_formatting( attribute_txt, strip_formatting_dont_preserve_newlines );
Code result = make_code(); Code result = make_code();
result->Type = ECode::PlatformAttributes; result->Type = CT_PlatformAttributes;
result->Name = get_cached_string( name_stripped ); result->Name = get_cached_string( name_stripped );
result->Content = result->Name; result->Content = result->Name;
// result->Token = // result->Token =
@ -692,7 +692,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
Token name { nullptr, 0, Tok_Invalid }; Token name { nullptr, 0, Tok_Invalid };
AccessSpec access = AccessSpec_Default; AccessSpec access = AccessSpec_Default;
CodeType parent = { nullptr }; CodeTypename parent = { nullptr };
CodeBody body = { nullptr }; CodeBody body = { nullptr };
CodeAttributes attributes = { nullptr }; CodeAttributes attributes = { nullptr };
ModuleFlag mflags = ModuleFlag_None; ModuleFlag mflags = ModuleFlag_None;
@ -721,9 +721,9 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
local_persist local_persist
char interface_arr_mem[ kilobytes(4) ] {0}; char interface_arr_mem[ kilobytes(4) ] {0};
Array<CodeType> interfaces; { Array<CodeTypename> interfaces; {
Arena arena = arena_init_from_memory( interface_arr_mem, kilobytes(4) ); Arena arena = arena_init_from_memory( interface_arr_mem, kilobytes(4) );
interfaces = array_init_reserve<CodeType>( allocator_info(& arena), 4 ); interfaces = array_init_reserve<CodeTypename>( 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. // 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 } ); result = def_class( to_str(name), { body, parent, access, attributes, mflags } );
else 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 ) if ( inline_cmt )
result->InlineCmt = inline_cmt; result->InlineCmt = inline_cmt;
@ -793,7 +793,6 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
internal neverinline internal neverinline
CodeBody parse_class_struct_body( TokType which, Token name ) CodeBody parse_class_struct_body( TokType which, Token name )
{ {
using namespace ECode;
push_scope(); push_scope();
eat( Tok_BraceCurly_Open ); eat( Tok_BraceCurly_Open );
@ -803,10 +802,10 @@ CodeBody parse_class_struct_body( TokType which, Token name )
result = (CodeBody) make_code(); result = (CodeBody) make_code();
if ( which == Tok_Decl_Class ) if ( which == Tok_Decl_Class )
result->Type = Class_Body; result->Type = CT_Class_Body;
else else
result->Type = Struct_Body; result->Type = CT_Struct_Body;
while ( left && currtok_noskip.Type != Tok_BraceCurly_Close ) while ( left && currtok_noskip.Type != Tok_BraceCurly_Close )
{ {
@ -1139,7 +1138,7 @@ CodeComment parse_comment()
CodeComment CodeComment
result = (CodeComment) make_code(); result = (CodeComment) make_code();
result->Type = ECode::Comment; result->Type = CT_Comment;
result->Content = get_cached_string( to_str(currtok_noskip) ); result->Content = get_cached_string( to_str(currtok_noskip) );
result->Name = result->Content; result->Name = result->Content;
// result->Token = currtok_noskip; // result->Token = currtok_noskip;
@ -1314,7 +1313,7 @@ CodeDefine parse_define()
CodeDefine CodeDefine
define = (CodeDefine) make_code(); define = (CodeDefine) make_code();
define->Type = ECode::Preprocess_Define; define->Type = CT_Preprocess_Define;
if ( ! check( Tok_Identifier ) ) if ( ! check( Tok_Identifier ) )
{ {
@ -1429,7 +1428,7 @@ CodeFn parse_function_after_name(
ModuleFlag mflags ModuleFlag mflags
, CodeAttributes attributes , CodeAttributes attributes
, CodeSpecifiers specifiers , CodeSpecifiers specifiers
, CodeType ret_type , CodeTypename ret_type
, Token name , Token name
) )
{ {
@ -1489,8 +1488,6 @@ CodeFn parse_function_after_name(
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>; <InlineCmt> // <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>; <InlineCmt>
} }
using namespace ECode;
String String
name_stripped = string_make( GlobalAllocator, to_str(name) ); name_stripped = string_make( GlobalAllocator, to_str(name) );
strip_space(name_stripped); strip_space(name_stripped);
@ -1504,8 +1501,8 @@ CodeFn parse_function_after_name(
{ {
switch ( body->Type ) switch ( body->Type )
{ {
case Function_Body: case CT_Function_Body:
case Untyped: case CT_Untyped:
break; break;
default: default:
@ -1516,12 +1513,12 @@ CodeFn parse_function_after_name(
} }
} }
result->Type = Function; result->Type = CT_Function;
result->Body = body; result->Body = body;
} }
else else
{ {
result->Type = Function_Fwd; result->Type = CT_Function_Fwd;
} }
if ( attributes ) if ( attributes )
@ -1545,14 +1542,14 @@ CodeFn parse_function_after_name(
internal internal
Code parse_function_body() Code parse_function_body()
{ {
using namespace ECode;
push_scope(); push_scope();
eat( Tok_BraceCurly_Open ); eat( Tok_BraceCurly_Open );
CodeBody CodeBody
result = (CodeBody) make_code(); result = (CodeBody) make_code();
result->Type = Function_Body; result->Type = CT_Function_Body;
// TODO : Support actual parsing of function body // TODO : Support actual parsing of function body
Token start = currtok_noskip; Token start = currtok_noskip;
@ -1585,16 +1582,14 @@ Code parse_function_body()
} }
internal neverinline internal neverinline
CodeBody parse_global_nspace( CodeT which ) CodeBody parse_global_nspace( CodeType which )
{ {
using namespace ECode;
push_scope(); 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; return InvalidCode;
if ( which != Global_Body ) if ( which != CT_Global_Body )
eat( Tok_BraceCurly_Open ); eat( Tok_BraceCurly_Open );
// { // {
@ -1645,7 +1640,7 @@ CodeBody parse_global_nspace( CodeT which )
break; break;
case Tok_Decl_Extern_Linkage: 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) ); log_failure( "Nested extern linkage\n%s", to_string(Context) );
member = parse_extern_link(); member = parse_extern_link();
@ -1733,7 +1728,7 @@ CodeBody parse_global_nspace( CodeT which )
break; break;
case Tok_Module_Export: case Tok_Module_Export:
if ( which == Export_Body ) if ( which == CT_Export_Body )
log_failure( "Nested export declaration\n%s", to_string(Context) ); log_failure( "Nested export declaration\n%s", to_string(Context) );
member = parse_export_body(); member = parse_export_body();
@ -1888,7 +1883,7 @@ CodeBody parse_global_nspace( CodeT which )
append(result, member ); append(result, member );
} }
if ( which != Global_Body ) if ( which != CT_Global_Body )
eat( Tok_BraceCurly_Close ); eat( Tok_BraceCurly_Close );
// { <Body> } // { <Body> }
@ -2107,7 +2102,7 @@ CodeInclude parse_include()
CodeInclude CodeInclude
include = (CodeInclude) make_code(); include = (CodeInclude) make_code();
include->Type = ECode::Preprocess_Include; include->Type = CT_Preprocess_Include;
eat( Tok_Preprocess_Include ); eat( Tok_Preprocess_Include );
// #include // #include
@ -2132,7 +2127,7 @@ CodeOperator parse_operator_after_ret_type(
ModuleFlag mflags ModuleFlag mflags
, CodeAttributes attributes , CodeAttributes attributes
, CodeSpecifiers specifiers , CodeSpecifiers specifiers
, CodeType ret_type , CodeTypename ret_type
) )
{ {
push_scope(); push_scope();
@ -2506,7 +2501,7 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
} }
#endif #endif
CodeType type = parse_type(); CodeTypename type = parse_type();
// <Attributes> <Specifiers> <ReturnType/ValueType> // <Attributes> <Specifiers> <ReturnType/ValueType>
if ( type == InvalidCode ) if ( type == InvalidCode )
@ -2588,7 +2583,7 @@ CodePragma parse_pragma()
CodePragma CodePragma
pragma = (CodePragma) make_code(); pragma = (CodePragma) make_code();
pragma->Type = ECode::Preprocess_Pragma; pragma->Type = CT_Preprocess_Pragma;
eat( Tok_Preprocess_Pragma ); eat( Tok_Preprocess_Pragma );
// #pragma // #pragma
@ -2612,7 +2607,7 @@ CodePragma parse_pragma()
internal inline internal inline
CodeParam parse_params( bool use_template_capture ) CodeParam parse_params( bool use_template_capture )
{ {
using namespace ECode;
push_scope(); push_scope();
if ( ! use_template_capture ) if ( ! use_template_capture )
@ -2641,11 +2636,11 @@ CodeParam parse_params( bool use_template_capture )
return { nullptr }; return { nullptr };
} }
Code macro = { nullptr }; Code macro = { nullptr };
CodeType type = { nullptr }; CodeTypename type = { nullptr };
Code value = { nullptr }; Code value = { nullptr };
Token name = NullToken; Token name = NullToken;
Code post_name_macro = { nullptr }; Code post_name_macro = { nullptr };
if ( check( Tok_Varadic_Argument ) ) if ( check( Tok_Varadic_Argument ) )
{ {
@ -2741,7 +2736,7 @@ CodeParam parse_params( bool use_template_capture )
} }
CodeParam result = ( CodeParam )make_code(); CodeParam result = ( CodeParam )make_code();
result->Type = Parameters; result->Type = CT_Parameters;
result->Macro = macro; result->Macro = macro;
@ -2857,7 +2852,7 @@ CodeParam parse_params( bool use_template_capture )
} }
CodeParam param = ( CodeParam )make_code(); CodeParam param = ( CodeParam )make_code();
param->Type = Parameters; param->Type = CT_Parameters;
param->Macro = macro; param->Macro = macro;
@ -2908,7 +2903,7 @@ CodePreprocessCond parse_preprocess_cond()
CodePreprocessCond CodePreprocessCond
cond = (CodePreprocessCond) make_code(); 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 ); eat( currtok.Type );
// #<Conditional> // #<Conditional>
@ -3013,7 +3008,7 @@ Code parse_static_assert()
Code Code
assert = make_code(); assert = make_code();
assert->Type = ECode::Untyped; assert->Type = CT_Untyped;
Token content = currtok; Token content = currtok;
@ -3093,7 +3088,7 @@ CodeVar parse_variable_after_name(
ModuleFlag mflags ModuleFlag mflags
, CodeAttributes attributes , CodeAttributes attributes
, CodeSpecifiers specifiers , CodeSpecifiers specifiers
, CodeType type , CodeTypename type
, StrC name , StrC name
) )
{ {
@ -3221,11 +3216,9 @@ CodeVar parse_variable_after_name(
} }
} }
using namespace ECode;
CodeVar CodeVar
result = (CodeVar) make_code(); result = (CodeVar) make_code();
result->Type = Variable; result->Type = CT_Variable;
result->Name = get_cached_string( name ); result->Name = get_cached_string( name );
result->ModuleFlags = mflags; result->ModuleFlags = mflags;
@ -3430,13 +3423,13 @@ CodeConstructor parse_constructor( CodeSpecifiers specifiers )
if ( initializer_list ) if ( initializer_list )
result->InitializerList = initializer_list; result->InitializerList = initializer_list;
if ( body && body->Type == ECode::Function_Body ) if ( body && body->Type == CT_Function_Body )
{ {
result->Body = body; result->Body = body;
result->Type = ECode::Constructor; result->Type = CT_Constructor;
} }
else else
result->Type = ECode::Constructor_Fwd; result->Type = CT_Constructor_Fwd;
if ( inline_cmt ) if ( inline_cmt )
result->InlineCmt = inline_cmt; result->InlineCmt = inline_cmt;
@ -3540,13 +3533,13 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
if ( specifiers ) if ( specifiers )
result->Specs = specifiers; result->Specs = specifiers;
if ( body && body->Type == ECode::Function_Body ) if ( body && body->Type == CT_Function_Body )
{ {
result->Body = body; result->Body = body;
result->Type = ECode::Destructor; result->Type = CT_Destructor;
} }
else else
result->Type = ECode::Destructor_Fwd; result->Type = CT_Destructor_Fwd;
if ( inline_cmt ) if ( inline_cmt )
result->InlineCmt = inline_cmt; result->InlineCmt = inline_cmt;
@ -3558,7 +3551,6 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
internal internal
CodeEnum parse_enum( bool inplace_def ) CodeEnum parse_enum( bool inplace_def )
{ {
using namespace ECode;
push_scope(); push_scope();
Specifier specs_found[16] { Spec_NumSpecifiers }; Specifier specs_found[16] { Spec_NumSpecifiers };
@ -3566,9 +3558,9 @@ CodeEnum parse_enum( bool inplace_def )
CodeAttributes attributes = { nullptr }; CodeAttributes attributes = { nullptr };
Token name = { nullptr, 0, Tok_Invalid }; Token name = { nullptr, 0, Tok_Invalid };
Code array_expr = { nullptr }; Code array_expr = { nullptr };
CodeType type = { nullptr }; CodeTypename type = { nullptr };
char entries_code[ kilobytes(128) ] { 0 }; char entries_code[ kilobytes(128) ] { 0 };
s32 entries_length = 0; s32 entries_length = 0;
@ -3629,7 +3621,7 @@ CodeEnum parse_enum( bool inplace_def )
if ( currtok.Type == Tok_BraceCurly_Open ) if ( currtok.Type == Tok_BraceCurly_Open )
{ {
body = (CodeBody) make_code(); body = (CodeBody) make_code();
body->Type = ECode::Enum_Body; body->Type = CT_Enum_Body;
eat( Tok_BraceCurly_Open ); eat( Tok_BraceCurly_Open );
// enum <class> <Attributes> <Name> : <UnderlyingType> { // enum <class> <Attributes> <Name> : <UnderlyingType> {
@ -3771,19 +3763,17 @@ CodeEnum parse_enum( bool inplace_def )
// enum <class> <Attributes> <Name> : <UnderlyingType> { <Body> }; <InlineCmt> // enum <class> <Attributes> <Name> : <UnderlyingType> { <Body> }; <InlineCmt>
} }
using namespace ECode;
CodeEnum CodeEnum
result = (CodeEnum) make_code(); result = (CodeEnum) make_code();
if ( body.ast ) if ( body.ast )
{ {
result->Type = is_enum_class ? Enum_Class : Enum; result->Type = is_enum_class ? CT_Enum_Class : CT_Enum;
result->Body = body; result->Body = body;
} }
else 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) ); result->Name = get_cached_string( to_str(name) );
@ -3812,7 +3802,7 @@ internal inline
CodeBody parse_export_body() CodeBody parse_export_body()
{ {
push_scope(); push_scope();
CodeBody result = parse_global_nspace( ECode::Export_Body ); CodeBody result = parse_global_nspace( CT_Export_Body );
pop(& Context); pop(& Context);
return result; return result;
} }
@ -3821,7 +3811,7 @@ internal inline
CodeBody parse_extern_link_body() CodeBody parse_extern_link_body()
{ {
push_scope(); push_scope();
CodeBody result = parse_global_nspace( ECode::Extern_Linkage_Body ); CodeBody result = parse_global_nspace( CT_Extern_Linkage_Body );
pop(& Context); pop(& Context);
return result; return result;
} }
@ -3843,7 +3833,7 @@ CodeExtern parse_extern_link()
CodeExtern CodeExtern
result = (CodeExtern) make_code(); result = (CodeExtern) make_code();
result->Type = ECode::Extern_Linkage; result->Type = CT_Extern_Linkage;
result->Name = get_cached_string( to_str(name) ); result->Name = get_cached_string( to_str(name) );
Code entry = parse_extern_link_body(); Code entry = parse_extern_link_body();
@ -3864,7 +3854,6 @@ CodeExtern parse_extern_link()
internal internal
CodeFriend parse_friend() CodeFriend parse_friend()
{ {
using namespace ECode;
push_scope(); push_scope();
eat( Tok_Decl_Friend ); eat( Tok_Decl_Friend );
@ -3873,7 +3862,7 @@ CodeFriend parse_friend()
CodeFn function = { nullptr }; CodeFn function = { nullptr };
// Type declaration or return type // Type declaration or return type
CodeType type = parse_type(); CodeTypename type = parse_type();
if ( type == Code_Invalid ) if ( type == Code_Invalid )
{ {
pop(& Context); pop(& Context);
@ -3905,7 +3894,7 @@ CodeFriend parse_friend()
} }
CodeComment inline_cmt = NullCode; CodeComment inline_cmt = NullCode;
if ( function && function->Type == ECode::Function_Fwd ) if ( function && function->Type == CT_Function_Fwd )
{ {
Token stmt_end = currtok; Token stmt_end = currtok;
eat( Tok_Statement_End ); eat( Tok_Statement_End );
@ -3919,7 +3908,7 @@ CodeFriend parse_friend()
} }
CodeFriend result = ( CodeFriend )make_code(); CodeFriend result = ( CodeFriend )make_code();
result->Type = Friend; result->Type = CT_Friend;
if ( function ) if ( function )
result->Declaration = function; result->Declaration = function;
@ -3991,7 +3980,7 @@ CodeFn parse_function()
} }
// <export> <Attributes> <Specifiers> // <export> <Attributes> <Specifiers>
CodeType ret_type = parse_type(); CodeTypename ret_type = parse_type();
if ( ret_type == Code_Invalid ) if ( ret_type == Code_Invalid )
{ {
pop(& Context); pop(& Context);
@ -4027,7 +4016,7 @@ CodeNS parse_namespace()
Context.Scope->Name = name; Context.Scope->Name = name;
// namespace <Name> // namespace <Name>
CodeBody body = parse_global_nspace( ECode::Namespace_Body ); CodeBody body = parse_global_nspace( CT_Namespace_Body );
if ( body == Code_Invalid ) if ( body == Code_Invalid )
{ {
pop(& Context); pop(& Context);
@ -4037,7 +4026,7 @@ CodeNS parse_namespace()
CodeNS CodeNS
result = (CodeNS) make_code(); result = (CodeNS) make_code();
result->Type = ECode::Namespace; result->Type = CT_Namespace;
result->Name = get_cached_string( to_str(name) ); result->Name = get_cached_string( to_str(name) );
result->Body = body; result->Body = body;
@ -4103,7 +4092,7 @@ CodeOperator parse_operator()
// <export> <Attributes> <Specifiers> // <export> <Attributes> <Specifiers>
// Parse Return Type // Parse Return Type
CodeType ret_type = parse_type(); CodeTypename ret_type = parse_type();
// <export> <Attributes> <Specifiers> <ReturnType> // <export> <Attributes> <Specifiers> <ReturnType>
CodeOperator result = parse_operator_after_ret_type( mflags, attributes, specifiers, ret_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) if (body)
{ {
result->Type = ECode::Operator_Cast; result->Type = CT_Operator_Cast;
result->Body = body; result->Body = body;
} }
else else
{ {
result->Type = ECode::Operator_Cast_Fwd; result->Type = CT_Operator_Cast_Fwd;
} }
if ( specifiers ) if ( specifiers )
@ -4411,7 +4400,7 @@ CodeTemplate parse_template()
} }
CodeTemplate result = ( CodeTemplate )make_code(); CodeTemplate result = ( CodeTemplate )make_code();
result->Type = ECode::Template; result->Type = CT_Template;
result->Params = params; result->Params = params;
result->Declaration = definition; result->Declaration = definition;
result->ModuleFlags = mflags; 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. The excess whitespace cannot be stripped however, because there is no semantic awareness within the first capture group.
*/ */
internal internal
CodeType parse_type( bool from_template, bool* typedef_is_function ) CodeTypename parse_type( bool from_template, bool* typedef_is_function )
{ {
push_scope(); push_scope();
@ -4603,8 +4592,8 @@ else if ( currtok.Type == Tok_DeclType )
// <Attributes> <Specifiers> <Identifier> <Specifiers> // <Attributes> <Specifiers> <Identifier> <Specifiers>
// For function type signatures // For function type signatures
CodeType return_type = NullCode; CodeTypename return_type = NullCode;
CodeParam params = NullCode; CodeParam params = NullCode;
#ifdef GEN_USE_NEW_TYPENAME_PARSING #ifdef GEN_USE_NEW_TYPENAME_PARSING
CodeParam params_nested = NullCode; 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 // 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. // The previous information with exception to attributes will be considered the return type.
return_type = ( CodeType )make_code(); return_type = ( CodeTypename )make_code();
return_type->Type = ECode::Typename; return_type->Type = CT_Typename;
// String // String
// name_stripped = String::make( GlobalAllocator, name ); // name_stripped = String::make( GlobalAllocator, name );
@ -4815,10 +4804,8 @@ else if ( currtok.Type == Tok_DeclType )
// <Attributes> <All kinds of nonsense> ... // <Attributes> <All kinds of nonsense> ...
} }
using namespace ECode; CodeTypename result = ( CodeTypename )make_code();
result->Type = CT_Typename;
CodeType result = ( CodeType )make_code();
result->Type = Typename;
// result->Token = Context.Scope->Start; // result->Token = Context.Scope->Start;
// Need to wait until were using the new parsing method to do this. // Need to wait until were using the new parsing method to do this.
@ -5049,11 +5036,9 @@ CodeTypedef parse_typedef()
inline_cmt = parse_comment(); inline_cmt = parse_comment();
// <ModuleFalgs> typedef <UnderlyingType> <Name> <ArrayExpr>; <InlineCmt> // <ModuleFalgs> typedef <UnderlyingType> <Name> <ArrayExpr>; <InlineCmt>
using namespace ECode;
CodeTypedef CodeTypedef
result = (CodeTypedef) make_code(); result = (CodeTypedef) make_code();
result->Type = Typedef; result->Type = CT_Typedef;
result->ModuleFlags = mflags; result->ModuleFlags = mflags;
if ( is_function ) 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. // 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 ) if ( type->Type == CT_Typename && array_expr && array_expr->Type != CT_Invalid )
cast(CodeType, type)->ArrExpr = array_expr; cast(CodeTypename, type)->ArrExpr = array_expr;
if ( inline_cmt ) if ( inline_cmt )
result->InlineCmt = inline_cmt; result->InlineCmt = inline_cmt;
@ -5119,7 +5104,7 @@ CodeUnion parse_union( bool inplace_def )
// <ModuleFlags> union <Attributes> <Name> { // <ModuleFlags> union <Attributes> <Name> {
body = make_code(); body = make_code();
body->Type = ECode::Union_Body; body->Type = CT_Union_Body;
while ( ! check_noskip( Tok_BraceCurly_Close ) ) while ( ! check_noskip( Tok_BraceCurly_Close ) )
{ {
@ -5208,7 +5193,7 @@ CodeUnion parse_union( bool inplace_def )
CodeUnion CodeUnion
result = (CodeUnion) make_code(); result = (CodeUnion) make_code();
result->Type = ECode::Union; result->Type = CT_Union;
result->ModuleFlags = mflags; result->ModuleFlags = mflags;
if ( name ) if ( name )
@ -5232,9 +5217,9 @@ CodeUsing parse_using()
Specifier specs_found[16] { Spec_Invalid }; Specifier specs_found[16] { Spec_Invalid };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
Token name = { nullptr, 0, Tok_Invalid }; Token name = { nullptr, 0, Tok_Invalid };
Code array_expr = { nullptr }; Code array_expr = { nullptr };
CodeType type = { nullptr }; CodeTypename type = { nullptr };
bool is_namespace = false; bool is_namespace = false;
@ -5292,8 +5277,6 @@ CodeUsing parse_using()
} }
// <ModuleFlags> using <namespace> <Attributes> <Name> = <UnderlyingType>; <InlineCmt> // <ModuleFlags> using <namespace> <Attributes> <Name> = <UnderlyingType>; <InlineCmt>
using namespace ECode;
CodeUsing CodeUsing
result = (CodeUsing) make_code(); result = (CodeUsing) make_code();
result->Name = get_cached_string( to_str(name) ); result->Name = get_cached_string( to_str(name) );
@ -5301,11 +5284,11 @@ CodeUsing parse_using()
if ( is_namespace) if ( is_namespace)
{ {
result->Type = Using_Namespace; result->Type = CT_Using_Namespace;
} }
else else
{ {
result->Type = Using; result->Type = CT_Using;
if ( type ) if ( type )
result->UnderlyingType = type; result->UnderlyingType = type;
@ -5330,7 +5313,7 @@ CodeVar parse_variable()
push_scope(); push_scope();
Specifier specs_found[16] { Spec_NumSpecifiers }; Specifier specs_found[16] { Spec_NumSpecifiers };
s32 NumSpecifiers = 0; s32 NumSpecifiers = 0;
ModuleFlag mflags = ModuleFlag_None; ModuleFlag mflags = ModuleFlag_None;
CodeAttributes attributes = { nullptr }; CodeAttributes attributes = { nullptr };
@ -5349,8 +5332,7 @@ CodeVar parse_variable()
while ( left && is_specifier(currtok) ) while ( left && is_specifier(currtok) )
{ {
Specifier spec = to_specifier( to_str(currtok) ); Specifier spec = to_specifier( to_str(currtok) );
switch ( spec )
switch ( spec )
{ {
case Spec_Const: case Spec_Const:
case Spec_Constexpr: case Spec_Constexpr:
@ -5386,7 +5368,7 @@ CodeVar parse_variable()
} }
// <ModuleFlags> <Attributes> <Specifiers> // <ModuleFlags> <Attributes> <Specifiers>
CodeType type = parse_type(); CodeTypename type = parse_type();
// <ModuleFlags> <Attributes> <Specifiers> <ValueType> // <ModuleFlags> <Attributes> <Specifiers> <ValueType>
if ( type == Code_Invalid ) if ( type == Code_Invalid )

View File

@ -72,36 +72,36 @@ global CodeSpecifiers spec_thread_local;
global CodeSpecifiers spec_virtual; global CodeSpecifiers spec_virtual;
global CodeSpecifiers spec_volatile; global CodeSpecifiers spec_volatile;
global CodeType t_empty; global CodeTypename t_empty;
global CodeType t_auto; global CodeTypename t_auto;
global CodeType t_void; global CodeTypename t_void;
global CodeType t_int; global CodeTypename t_int;
global CodeType t_bool; global CodeTypename t_bool;
global CodeType t_char; global CodeTypename t_char;
global CodeType t_wchar_t; global CodeTypename t_wchar_t;
global CodeType t_class; global CodeTypename t_class;
global CodeType t_typename; global CodeTypename t_typename;
global Array< StringCached > PreprocessorDefines; global Array< StringCached > PreprocessorDefines;
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
global CodeType t_b32; global CodeTypename t_b32;
global CodeType t_s8; global CodeTypename t_s8;
global CodeType t_s16; global CodeTypename t_s16;
global CodeType t_s32; global CodeTypename t_s32;
global CodeType t_s64; global CodeTypename t_s64;
global CodeType t_u8; global CodeTypename t_u8;
global CodeType t_u16; global CodeTypename t_u16;
global CodeType t_u32; global CodeTypename t_u32;
global CodeType t_u64; global CodeTypename t_u64;
global CodeType t_ssize; global CodeTypename t_ssize;
global CodeType t_usize; global CodeTypename t_usize;
global CodeType t_f32; global CodeTypename t_f32;
global CodeType t_f64; global CodeTypename t_f64;
#endif #endif
#pragma endregion Constants #pragma endregion Constants

View File

@ -27,17 +27,17 @@ CodeBody gen_ecode( char const* path )
{ {
char const* code = node.string; 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 ); 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 { <entries> NumTypes };")); CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", (StrC)enum_entries, "enum CodeType_Def : u32 { <entries> CT_NumTypes };"));
#pragma push_macro("local_persist") #pragma push_macro("local_persist")
#undef local_persist #undef local_persist
CodeFn to_str = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize( CodeFn to_str = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
inline inline
StrC to_str( Type type ) StrC to_str( CodeType type )
{ {
local_persist local_persist
StrC lookup[] { StrC lookup[] {
@ -49,10 +49,11 @@ CodeBody gen_ecode( char const* path )
))); )));
#pragma pop_macro("local_persist") #pragma pop_macro("local_persist")
CodeNS nspace = def_namespace( name(ECode), def_namespace_body( args( enum_code, to_str ) ) ); //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) ) ); //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 ) 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_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_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_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_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_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 )); 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_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_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_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_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_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 ))); 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_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_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_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_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_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 )); CodeBody impl_cast_using = parse_global_body( token_fmt( "typename", StrC name(Using), cast_tmpl ));