mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Compare commits
5 Commits
63ebd0d094
...
e00b2f8afb
Author | SHA1 | Date | |
---|---|---|---|
e00b2f8afb | |||
72d088c566 | |||
c6fba23173 | |||
d45908fb32 | |||
a7c9dad9fd |
@ -243,7 +243,12 @@ int gen_main()
|
|||||||
Code untyped = scan_file( "components/interface.untyped.cpp" );
|
Code untyped = scan_file( "components/interface.untyped.cpp" );
|
||||||
|
|
||||||
CodeBody etoktype = gen_etoktype( "enums/ETokType.csv", "enums/AttributeTokens.csv" );
|
CodeBody etoktype = gen_etoktype( "enums/ETokType.csv", "enums/AttributeTokens.csv" );
|
||||||
CodeNS nspaced_etoktype = def_namespace( name(parser), def_namespace_body( args(etoktype)) );
|
//CodeNS nspaced_etoktype = def_namespace( name(parser), def_namespace_body( args(etoktype)) );
|
||||||
|
CodeBody nspaced_etoktype = def_global_body( args(
|
||||||
|
untyped_str(txt("GEN_NS_PARSER_BEGIN\n")),
|
||||||
|
etoktype,
|
||||||
|
untyped_str(txt("GEN_NS_PARSER_END\n"))
|
||||||
|
));
|
||||||
|
|
||||||
Builder
|
Builder
|
||||||
src = Builder::open( "gen/gen.cpp" );
|
src = Builder::open( "gen/gen.cpp" );
|
||||||
|
@ -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 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: " );
|
||||||
@ -273,7 +271,7 @@ char const* debug_str(Code self)
|
|||||||
s32 left = self->NumEntries;
|
s32 left = self->NumEntries;
|
||||||
while ( left-- )
|
while ( left-- )
|
||||||
{
|
{
|
||||||
StrC spec = ESpecifier::to_str( self->ArrSpecs[idx] );
|
StrC spec = to_str( self->ArrSpecs[idx] );
|
||||||
append_fmt( result, "%.*s, ", spec.Len, spec.Ptr );
|
append_fmt( result, "%.*s, ", spec.Len, spec.Ptr );
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
@ -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 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 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;
|
||||||
|
@ -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)
|
||||||
)
|
)
|
||||||
@ -337,7 +337,7 @@ struct AST
|
|||||||
};
|
};
|
||||||
StringCached Content; // Attributes, Comment, Execution, Include
|
StringCached Content; // Attributes, Comment, Execution, Include
|
||||||
struct {
|
struct {
|
||||||
SpecifierT ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers
|
Specifier ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers
|
||||||
Code NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
Code NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -353,13 +353,13 @@ 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 {
|
||||||
b32 IsFunction; // Used by typedef to not serialize the name field.
|
b32 IsFunction; // Used by typedef to not serialize the name field.
|
||||||
b32 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
|
b32 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
|
||||||
OperatorT Op;
|
Operator Op;
|
||||||
AccessSpec ParentAccess;
|
AccessSpec ParentAccess;
|
||||||
s32 NumEntries;
|
s32 NumEntries;
|
||||||
s32 VarConstructorInit; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
|
s32 VarConstructorInit; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
|
||||||
|
@ -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 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 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:
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||||
}
|
}
|
||||||
@ -256,7 +252,7 @@ void to_string_def(CodeDestructor self, String* result )
|
|||||||
}
|
}
|
||||||
else if ( self->Specs )
|
else if ( self->Specs )
|
||||||
{
|
{
|
||||||
if ( has(self->Specs, ESpecifier::Virtual ) )
|
if ( has(self->Specs, Spec_Virtual ) )
|
||||||
append_fmt( result, "virtual ~%S()", self->Parent->Name );
|
append_fmt( result, "virtual ~%S()", self->Parent->Name );
|
||||||
else
|
else
|
||||||
append_fmt( result, "~%S()", self->Parent->Name );
|
append_fmt( result, "~%S()", self->Parent->Name );
|
||||||
@ -271,12 +267,12 @@ void to_string_fwd(CodeDestructor self, String* result )
|
|||||||
{
|
{
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
if ( has(self->Specs, ESpecifier::Virtual ) )
|
if ( has(self->Specs, Spec_Virtual ) )
|
||||||
append_fmt( result, "virtual ~%S();\n", self->Parent->Name );
|
append_fmt( result, "virtual ~%S();\n", self->Parent->Name );
|
||||||
else
|
else
|
||||||
append_fmt( result, "~%S()", self->Parent->Name );
|
append_fmt( result, "~%S()", self->Parent->Name );
|
||||||
|
|
||||||
if ( has(self->Specs, ESpecifier::Pure ) )
|
if ( has(self->Specs, Spec_Pure ) )
|
||||||
append( result, " = 0;" );
|
append( result, " = 0;" );
|
||||||
else if (self->Body)
|
else if (self->Body)
|
||||||
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
|
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -492,11 +486,11 @@ void to_string_def(CodeFn self, String* result )
|
|||||||
bool prefix_specs = false;
|
bool prefix_specs = false;
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ! ESpecifier::is_trailing( spec ) )
|
if ( ! is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
|
|
||||||
prefix_specs = true;
|
prefix_specs = true;
|
||||||
@ -521,11 +515,11 @@ void to_string_def(CodeFn self, String* result )
|
|||||||
|
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ESpecifier::is_trailing( spec ) )
|
if ( is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -545,11 +539,11 @@ void to_string_fwd(CodeFn self, String* result )
|
|||||||
b32 prefix_specs = false;
|
b32 prefix_specs = false;
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ! ESpecifier::is_trailing( spec ) || ! (spec != ESpecifier::Pure) )
|
if ( ! is_trailing( spec ) || ! (spec != Spec_Pure) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
|
|
||||||
prefix_specs = true;
|
prefix_specs = true;
|
||||||
@ -576,17 +570,17 @@ void to_string_fwd(CodeFn self, String* result )
|
|||||||
|
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ESpecifier::is_trailing( spec ) )
|
if ( is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( self->Specs && has(self->Specs, ESpecifier::Pure ) >= 0 )
|
if ( self->Specs && has(self->Specs, Spec_Pure ) >= 0 )
|
||||||
append( result, " = 0;" );
|
append( result, " = 0;" );
|
||||||
else if (self->Body)
|
else if (self->Body)
|
||||||
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
|
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
|
||||||
@ -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 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;
|
||||||
}
|
}
|
||||||
@ -661,11 +654,11 @@ void to_string_def(CodeOperator self, String* result )
|
|||||||
|
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ! ESpecifier::is_trailing( spec ) )
|
if ( ! is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -687,11 +680,11 @@ void to_string_def(CodeOperator self, String* result )
|
|||||||
|
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ESpecifier::is_trailing( spec ) )
|
if ( is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -712,11 +705,11 @@ void to_string_fwd(CodeOperator self, String* result )
|
|||||||
|
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ! ESpecifier::is_trailing( spec ) )
|
if ( ! is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -737,11 +730,11 @@ void to_string_fwd(CodeOperator self, String* result )
|
|||||||
|
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ESpecifier::is_trailing( spec ) )
|
if ( is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -773,11 +765,11 @@ void to_string_def(CodeOpCast self, String* result )
|
|||||||
{
|
{
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ! ESpecifier::is_trailing( spec ) )
|
if ( ! is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -787,11 +779,11 @@ void to_string_def(CodeOpCast self, String* result )
|
|||||||
else
|
else
|
||||||
append_fmt( result, "operator %S()", to_string(self->ValueType) );
|
append_fmt( result, "operator %S()", to_string(self->ValueType) );
|
||||||
|
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ESpecifier::is_trailing( spec ) )
|
if ( is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -810,22 +802,22 @@ void to_string_fwd(CodeOpCast self, String* result )
|
|||||||
{
|
{
|
||||||
if ( self->Specs )
|
if ( self->Specs )
|
||||||
{
|
{
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ! ESpecifier::is_trailing( spec ) )
|
if ( ! is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
append_fmt( result, "operator %S()", to_string(self->ValueType) );
|
append_fmt( result, "operator %S()", to_string(self->ValueType) );
|
||||||
|
|
||||||
for ( SpecifierT spec : self->Specs )
|
for ( Specifier spec : self->Specs )
|
||||||
{
|
{
|
||||||
if ( ESpecifier::is_trailing( spec ) )
|
if ( is_trailing( spec ) )
|
||||||
{
|
{
|
||||||
StrC spec_str = ESpecifier::to_str( spec );
|
StrC spec_str = to_str( spec );
|
||||||
append_fmt( result, " %*s", spec_str.Len, spec_str.Ptr );
|
append_fmt( result, " %*s", spec_str.Len, spec_str.Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -973,7 +964,7 @@ void to_string( CodeSpecifiers self, String* result )
|
|||||||
s32 left = self->NumEntries;
|
s32 left = self->NumEntries;
|
||||||
while ( left-- )
|
while ( left-- )
|
||||||
{
|
{
|
||||||
StrC spec = ESpecifier::to_str( self->ArrSpecs[idx] );
|
StrC spec = to_str( self->ArrSpecs[idx] );
|
||||||
append_fmt( result, "%.*s ", spec.Len, spec.Ptr );
|
append_fmt( result, "%.*s ", spec.Len, spec.Ptr );
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
@ -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 )
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@ void to_string (CodeParam params, String* result );
|
|||||||
CodeParam begin(CodeParam params);
|
CodeParam begin(CodeParam params);
|
||||||
CodeParam end (CodeParam params);
|
CodeParam end (CodeParam params);
|
||||||
|
|
||||||
bool append (CodeSpecifiers specifiers, SpecifierT spec);
|
bool append (CodeSpecifiers specifiers, Specifier spec);
|
||||||
s32 has (CodeSpecifiers specifiers, SpecifierT spec);
|
s32 has (CodeSpecifiers specifiers, Specifier spec);
|
||||||
s32 remove (CodeSpecifiers specifiers, SpecifierT to_remove );
|
s32 remove (CodeSpecifiers specifiers, Specifier to_remove );
|
||||||
String to_string(CodeSpecifiers specifiers);
|
String to_string(CodeSpecifiers specifiers);
|
||||||
void to_string(CodeSpecifiers specifiers, String* result);
|
void to_string(CodeSpecifiers specifiers, String* result);
|
||||||
|
|
||||||
SpecifierT* begin(CodeSpecifiers specifiers );
|
Specifier* begin(CodeSpecifiers specifiers );
|
||||||
SpecifierT* end (CodeSpecifiers specifiers);
|
Specifier* end (CodeSpecifiers specifiers);
|
||||||
|
|
||||||
void add_interface(CodeStruct self, CodeType interface);
|
void add_interface(CodeStruct self, CodeType interface);
|
||||||
String to_string (CodeStruct self);
|
String to_string (CodeStruct self);
|
||||||
@ -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); }
|
||||||
|
@ -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
|
||||||
|
@ -5,75 +5,75 @@
|
|||||||
|
|
||||||
// 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 Type : u32
|
|
||||||
{
|
|
||||||
Invalid,
|
|
||||||
Untyped,
|
|
||||||
NewLine,
|
|
||||||
Comment,
|
|
||||||
Access_Private,
|
|
||||||
Access_Protected,
|
|
||||||
Access_Public,
|
|
||||||
PlatformAttributes,
|
|
||||||
Class,
|
|
||||||
Class_Fwd,
|
|
||||||
Class_Body,
|
|
||||||
Constructor,
|
|
||||||
Constructor_Fwd,
|
|
||||||
Destructor,
|
|
||||||
Destructor_Fwd,
|
|
||||||
Enum,
|
|
||||||
Enum_Fwd,
|
|
||||||
Enum_Body,
|
|
||||||
Enum_Class,
|
|
||||||
Enum_Class_Fwd,
|
|
||||||
Execution,
|
|
||||||
Export_Body,
|
|
||||||
Extern_Linkage,
|
|
||||||
Extern_Linkage_Body,
|
|
||||||
Friend,
|
|
||||||
Function,
|
|
||||||
Function_Fwd,
|
|
||||||
Function_Body,
|
|
||||||
Global_Body,
|
|
||||||
Module,
|
|
||||||
Namespace,
|
|
||||||
Namespace_Body,
|
|
||||||
Operator,
|
|
||||||
Operator_Fwd,
|
|
||||||
Operator_Member,
|
|
||||||
Operator_Member_Fwd,
|
|
||||||
Operator_Cast,
|
|
||||||
Operator_Cast_Fwd,
|
|
||||||
Parameters,
|
|
||||||
Preprocess_Define,
|
|
||||||
Preprocess_Include,
|
|
||||||
Preprocess_If,
|
|
||||||
Preprocess_IfDef,
|
|
||||||
Preprocess_IfNotDef,
|
|
||||||
Preprocess_ElIf,
|
|
||||||
Preprocess_Else,
|
|
||||||
Preprocess_EndIf,
|
|
||||||
Preprocess_Pragma,
|
|
||||||
Specifiers,
|
|
||||||
Struct,
|
|
||||||
Struct_Fwd,
|
|
||||||
Struct_Body,
|
|
||||||
Template,
|
|
||||||
Typedef,
|
|
||||||
Typename,
|
|
||||||
Union,
|
|
||||||
Union_Body,
|
|
||||||
Using,
|
|
||||||
Using_Namespace,
|
|
||||||
Variable,
|
|
||||||
NumTypes
|
|
||||||
};
|
|
||||||
|
|
||||||
inline StrC to_str( Type type )
|
enum CodeType_Def : u32
|
||||||
{
|
{
|
||||||
|
CT_Invalid,
|
||||||
|
CT_Untyped,
|
||||||
|
CT_NewLine,
|
||||||
|
CT_Comment,
|
||||||
|
CT_Access_Private,
|
||||||
|
CT_Access_Protected,
|
||||||
|
CT_Access_Public,
|
||||||
|
CT_PlatformAttributes,
|
||||||
|
CT_Class,
|
||||||
|
CT_Class_Fwd,
|
||||||
|
CT_Class_Body,
|
||||||
|
CT_Constructor,
|
||||||
|
CT_Constructor_Fwd,
|
||||||
|
CT_Destructor,
|
||||||
|
CT_Destructor_Fwd,
|
||||||
|
CT_Enum,
|
||||||
|
CT_Enum_Fwd,
|
||||||
|
CT_Enum_Body,
|
||||||
|
CT_Enum_Class,
|
||||||
|
CT_Enum_Class_Fwd,
|
||||||
|
CT_Execution,
|
||||||
|
CT_Export_Body,
|
||||||
|
CT_Extern_Linkage,
|
||||||
|
CT_Extern_Linkage_Body,
|
||||||
|
CT_Friend,
|
||||||
|
CT_Function,
|
||||||
|
CT_Function_Fwd,
|
||||||
|
CT_Function_Body,
|
||||||
|
CT_Global_Body,
|
||||||
|
CT_Module,
|
||||||
|
CT_Namespace,
|
||||||
|
CT_Namespace_Body,
|
||||||
|
CT_Operator,
|
||||||
|
CT_Operator_Fwd,
|
||||||
|
CT_Operator_Member,
|
||||||
|
CT_Operator_Member_Fwd,
|
||||||
|
CT_Operator_Cast,
|
||||||
|
CT_Operator_Cast_Fwd,
|
||||||
|
CT_Parameters,
|
||||||
|
CT_Preprocess_Define,
|
||||||
|
CT_Preprocess_Include,
|
||||||
|
CT_Preprocess_If,
|
||||||
|
CT_Preprocess_IfDef,
|
||||||
|
CT_Preprocess_IfNotDef,
|
||||||
|
CT_Preprocess_ElIf,
|
||||||
|
CT_Preprocess_Else,
|
||||||
|
CT_Preprocess_EndIf,
|
||||||
|
CT_Preprocess_Pragma,
|
||||||
|
CT_Specifiers,
|
||||||
|
CT_Struct,
|
||||||
|
CT_Struct_Fwd,
|
||||||
|
CT_Struct_Body,
|
||||||
|
CT_Template,
|
||||||
|
CT_Typedef,
|
||||||
|
CT_Typename,
|
||||||
|
CT_Union,
|
||||||
|
CT_Union_Body,
|
||||||
|
CT_Using,
|
||||||
|
CT_Using_Namespace,
|
||||||
|
CT_Variable,
|
||||||
|
CT_NumTypes
|
||||||
|
};
|
||||||
|
|
||||||
|
inline StrC to_str( CodeType type )
|
||||||
|
{
|
||||||
local_persist StrC lookup[] {
|
local_persist StrC lookup[] {
|
||||||
{ sizeof( "Invalid" ), "Invalid" },
|
{ sizeof( "Invalid" ), "Invalid" },
|
||||||
{ sizeof( "Untyped" ), "Untyped" },
|
{ sizeof( "Untyped" ), "Untyped" },
|
||||||
@ -137,8 +137,4 @@ namespace ECode
|
|||||||
{ sizeof( "Variable" ), "Variable" },
|
{ sizeof( "Variable" ), "Variable" },
|
||||||
};
|
};
|
||||||
return lookup[type];
|
return lookup[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ECode
|
|
||||||
|
|
||||||
using CodeT = ECode::Type;
|
|
||||||
|
@ -5,62 +5,62 @@
|
|||||||
|
|
||||||
// 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 EOperator
|
typedef enum Operator_Def Operator;
|
||||||
{
|
|
||||||
enum Type : u32
|
|
||||||
{
|
|
||||||
Invalid,
|
|
||||||
Assign,
|
|
||||||
Assign_Add,
|
|
||||||
Assign_Subtract,
|
|
||||||
Assign_Multiply,
|
|
||||||
Assign_Divide,
|
|
||||||
Assign_Modulo,
|
|
||||||
Assign_BAnd,
|
|
||||||
Assign_BOr,
|
|
||||||
Assign_BXOr,
|
|
||||||
Assign_LShift,
|
|
||||||
Assign_RShift,
|
|
||||||
Increment,
|
|
||||||
Decrement,
|
|
||||||
Unary_Plus,
|
|
||||||
Unary_Minus,
|
|
||||||
UnaryNot,
|
|
||||||
Add,
|
|
||||||
Subtract,
|
|
||||||
Multiply,
|
|
||||||
Divide,
|
|
||||||
Modulo,
|
|
||||||
BNot,
|
|
||||||
BAnd,
|
|
||||||
BOr,
|
|
||||||
BXOr,
|
|
||||||
LShift,
|
|
||||||
RShift,
|
|
||||||
LAnd,
|
|
||||||
LOr,
|
|
||||||
LEqual,
|
|
||||||
LNot,
|
|
||||||
Lesser,
|
|
||||||
Greater,
|
|
||||||
LesserEqual,
|
|
||||||
GreaterEqual,
|
|
||||||
Subscript,
|
|
||||||
Indirection,
|
|
||||||
AddressOf,
|
|
||||||
MemberOfPointer,
|
|
||||||
PtrToMemOfPtr,
|
|
||||||
FunctionCall,
|
|
||||||
Comma,
|
|
||||||
New,
|
|
||||||
NewArray,
|
|
||||||
Delete,
|
|
||||||
DeleteArray,
|
|
||||||
NumOps
|
|
||||||
};
|
|
||||||
|
|
||||||
inline StrC to_str( Type op )
|
enum Operator_Def : u32
|
||||||
{
|
{
|
||||||
|
Op_Invalid,
|
||||||
|
Op_Assign,
|
||||||
|
Op_Assign_Add,
|
||||||
|
Op_Assign_Subtract,
|
||||||
|
Op_Assign_Multiply,
|
||||||
|
Op_Assign_Divide,
|
||||||
|
Op_Assign_Modulo,
|
||||||
|
Op_Assign_BAnd,
|
||||||
|
Op_Assign_BOr,
|
||||||
|
Op_Assign_BXOr,
|
||||||
|
Op_Assign_LShift,
|
||||||
|
Op_Assign_RShift,
|
||||||
|
Op_Increment,
|
||||||
|
Op_Decrement,
|
||||||
|
Op_Unary_Plus,
|
||||||
|
Op_Unary_Minus,
|
||||||
|
Op_UnaryNot,
|
||||||
|
Op_Add,
|
||||||
|
Op_Subtract,
|
||||||
|
Op_Multiply,
|
||||||
|
Op_Divide,
|
||||||
|
Op_Modulo,
|
||||||
|
Op_BNot,
|
||||||
|
Op_BAnd,
|
||||||
|
Op_BOr,
|
||||||
|
Op_BXOr,
|
||||||
|
Op_LShift,
|
||||||
|
Op_RShift,
|
||||||
|
Op_LAnd,
|
||||||
|
Op_LOr,
|
||||||
|
Op_LEqual,
|
||||||
|
Op_LNot,
|
||||||
|
Op_Lesser,
|
||||||
|
Op_Greater,
|
||||||
|
Op_LesserEqual,
|
||||||
|
Op_GreaterEqual,
|
||||||
|
Op_Subscript,
|
||||||
|
Op_Indirection,
|
||||||
|
Op_AddressOf,
|
||||||
|
Op_MemberOfPointer,
|
||||||
|
Op_PtrToMemOfPtr,
|
||||||
|
Op_FunctionCall,
|
||||||
|
Op_Comma,
|
||||||
|
Op_New,
|
||||||
|
Op_NewArray,
|
||||||
|
Op_Delete,
|
||||||
|
Op_DeleteArray,
|
||||||
|
NumOps
|
||||||
|
};
|
||||||
|
|
||||||
|
inline StrC to_str( Operator op )
|
||||||
|
{
|
||||||
local_persist StrC lookup[] {
|
local_persist StrC lookup[] {
|
||||||
{ sizeof( "INVALID" ), "INVALID" },
|
{ sizeof( "INVALID" ), "INVALID" },
|
||||||
{ sizeof( "=" ), "=" },
|
{ sizeof( "=" ), "=" },
|
||||||
@ -111,8 +111,4 @@ namespace EOperator
|
|||||||
{ sizeof( "delete[]" ), "delete[]" },
|
{ sizeof( "delete[]" ), "delete[]" },
|
||||||
};
|
};
|
||||||
return lookup[op];
|
return lookup[op];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace EOperator
|
|
||||||
|
|
||||||
using OperatorT = EOperator::Type;
|
|
||||||
|
@ -5,46 +5,46 @@
|
|||||||
|
|
||||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||||
|
|
||||||
namespace ESpecifier
|
typedef enum Specifier_Def Specifier;
|
||||||
|
|
||||||
|
enum Specifier_Def : u32
|
||||||
{
|
{
|
||||||
enum Type : u32
|
Spec_Invalid,
|
||||||
{
|
Spec_Consteval,
|
||||||
Invalid,
|
Spec_Constexpr,
|
||||||
Consteval,
|
Spec_Constinit,
|
||||||
Constexpr,
|
Spec_Explicit,
|
||||||
Constinit,
|
Spec_External_Linkage,
|
||||||
Explicit,
|
Spec_ForceInline,
|
||||||
External_Linkage,
|
Spec_Global,
|
||||||
ForceInline,
|
Spec_Inline,
|
||||||
Global,
|
Spec_Internal_Linkage,
|
||||||
Inline,
|
Spec_Local_Persist,
|
||||||
Internal_Linkage,
|
Spec_Mutable,
|
||||||
Local_Persist,
|
Spec_NeverInline,
|
||||||
Mutable,
|
Spec_Ptr,
|
||||||
NeverInline,
|
Spec_Ref,
|
||||||
Ptr,
|
Spec_Register,
|
||||||
Ref,
|
Spec_RValue,
|
||||||
Register,
|
Spec_Static,
|
||||||
RValue,
|
Spec_Thread_Local,
|
||||||
Static,
|
Spec_Virtual,
|
||||||
Thread_Local,
|
Spec_Const,
|
||||||
Virtual,
|
Spec_Final,
|
||||||
Const,
|
Spec_NoExceptions,
|
||||||
Final,
|
Spec_Override,
|
||||||
NoExceptions,
|
Spec_Pure,
|
||||||
Override,
|
Spec_Volatile,
|
||||||
Pure,
|
Spec_NumSpecifiers
|
||||||
Volatile,
|
};
|
||||||
NumSpecifiers
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool is_trailing( Type specifier )
|
inline bool is_trailing( Specifier specifier )
|
||||||
{
|
{
|
||||||
return specifier > Virtual;
|
return specifier > Spec_Virtual;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline StrC to_str( Type type )
|
inline StrC to_str( Specifier type )
|
||||||
{
|
{
|
||||||
local_persist StrC lookup[] {
|
local_persist StrC lookup[] {
|
||||||
{ sizeof( "INVALID" ), "INVALID" },
|
{ sizeof( "INVALID" ), "INVALID" },
|
||||||
{ sizeof( "consteval" ), "consteval" },
|
{ sizeof( "consteval" ), "consteval" },
|
||||||
@ -74,25 +74,21 @@ namespace ESpecifier
|
|||||||
{ sizeof( "volatile" ), "volatile" },
|
{ sizeof( "volatile" ), "volatile" },
|
||||||
};
|
};
|
||||||
return lookup[type];
|
return lookup[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Type to_type( StrC str )
|
inline Specifier to_specifier( StrC str )
|
||||||
|
{
|
||||||
|
local_persist u32 keymap[Spec_NumSpecifiers];
|
||||||
|
do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
|
||||||
{
|
{
|
||||||
local_persist u32 keymap[NumSpecifiers];
|
StrC enum_str = to_str( (Specifier)index );
|
||||||
do_once_start for ( u32 index = 0; index < NumSpecifiers; index++ )
|
|
||||||
{
|
|
||||||
StrC enum_str = to_str( (Type)index );
|
|
||||||
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
||||||
}
|
}
|
||||||
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
||||||
for ( u32 index = 0; index < NumSpecifiers; index++ )
|
for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
|
||||||
{
|
{
|
||||||
if ( keymap[index] == hash )
|
if ( keymap[index] == hash )
|
||||||
return (Type)index;
|
return (Specifier)index;
|
||||||
}
|
}
|
||||||
return Invalid;
|
return Spec_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ESpecifier
|
|
||||||
|
|
||||||
using SpecifierT = ESpecifier::Type;
|
|
||||||
|
@ -5,116 +5,115 @@
|
|||||||
|
|
||||||
// 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 parser
|
GEN_NS_PARSER_BEGIN
|
||||||
|
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" )
|
||||||
|
|
||||||
|
typedef enum TokType_Def TokType;
|
||||||
|
|
||||||
|
enum TokType_Def : u32
|
||||||
{
|
{
|
||||||
namespace ETokType
|
Tok_Invalid,
|
||||||
{
|
Tok_Access_Private,
|
||||||
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Attribute_API_Import, "GEN_API_Import_Code" )
|
Tok_Access_Protected,
|
||||||
|
Tok_Access_Public,
|
||||||
|
Tok_Access_MemberSymbol,
|
||||||
|
Tok_Access_StaticSymbol,
|
||||||
|
Tok_Ampersand,
|
||||||
|
Tok_Ampersand_DBL,
|
||||||
|
Tok_Assign_Classifer,
|
||||||
|
Tok_Attribute_Open,
|
||||||
|
Tok_Attribute_Close,
|
||||||
|
Tok_BraceCurly_Open,
|
||||||
|
Tok_BraceCurly_Close,
|
||||||
|
Tok_BraceSquare_Open,
|
||||||
|
Tok_BraceSquare_Close,
|
||||||
|
Tok_Capture_Start,
|
||||||
|
Tok_Capture_End,
|
||||||
|
Tok_Comment,
|
||||||
|
Tok_Comment_End,
|
||||||
|
Tok_Comment_Start,
|
||||||
|
Tok_Char,
|
||||||
|
Tok_Comma,
|
||||||
|
Tok_Decl_Class,
|
||||||
|
Tok_Decl_GNU_Attribute,
|
||||||
|
Tok_Decl_MSVC_Attribute,
|
||||||
|
Tok_Decl_Enum,
|
||||||
|
Tok_Decl_Extern_Linkage,
|
||||||
|
Tok_Decl_Friend,
|
||||||
|
Tok_Decl_Module,
|
||||||
|
Tok_Decl_Namespace,
|
||||||
|
Tok_Decl_Operator,
|
||||||
|
Tok_Decl_Struct,
|
||||||
|
Tok_Decl_Template,
|
||||||
|
Tok_Decl_Typedef,
|
||||||
|
Tok_Decl_Using,
|
||||||
|
Tok_Decl_Union,
|
||||||
|
Tok_Identifier,
|
||||||
|
Tok_Module_Import,
|
||||||
|
Tok_Module_Export,
|
||||||
|
Tok_NewLine,
|
||||||
|
Tok_Number,
|
||||||
|
Tok_Operator,
|
||||||
|
Tok_Preprocess_Hash,
|
||||||
|
Tok_Preprocess_Define,
|
||||||
|
Tok_Preprocess_If,
|
||||||
|
Tok_Preprocess_IfDef,
|
||||||
|
Tok_Preprocess_IfNotDef,
|
||||||
|
Tok_Preprocess_ElIf,
|
||||||
|
Tok_Preprocess_Else,
|
||||||
|
Tok_Preprocess_EndIf,
|
||||||
|
Tok_Preprocess_Include,
|
||||||
|
Tok_Preprocess_Pragma,
|
||||||
|
Tok_Preprocess_Content,
|
||||||
|
Tok_Preprocess_Macro,
|
||||||
|
Tok_Preprocess_Unsupported,
|
||||||
|
Tok_Spec_Alignas,
|
||||||
|
Tok_Spec_Const,
|
||||||
|
Tok_Spec_Consteval,
|
||||||
|
Tok_Spec_Constexpr,
|
||||||
|
Tok_Spec_Constinit,
|
||||||
|
Tok_Spec_Explicit,
|
||||||
|
Tok_Spec_Extern,
|
||||||
|
Tok_Spec_Final,
|
||||||
|
Tok_Spec_ForceInline,
|
||||||
|
Tok_Spec_Global,
|
||||||
|
Tok_Spec_Inline,
|
||||||
|
Tok_Spec_Internal_Linkage,
|
||||||
|
Tok_Spec_LocalPersist,
|
||||||
|
Tok_Spec_Mutable,
|
||||||
|
Tok_Spec_NeverInline,
|
||||||
|
Tok_Spec_Override,
|
||||||
|
Tok_Spec_Static,
|
||||||
|
Tok_Spec_ThreadLocal,
|
||||||
|
Tok_Spec_Volatile,
|
||||||
|
Tok_Spec_Virtual,
|
||||||
|
Tok_Star,
|
||||||
|
Tok_Statement_End,
|
||||||
|
Tok_StaticAssert,
|
||||||
|
Tok_String,
|
||||||
|
Tok_Type_Typename,
|
||||||
|
Tok_Type_Unsigned,
|
||||||
|
Tok_Type_Signed,
|
||||||
|
Tok_Type_Short,
|
||||||
|
Tok_Type_Long,
|
||||||
|
Tok_Type_bool,
|
||||||
|
Tok_Type_char,
|
||||||
|
Tok_Type_int,
|
||||||
|
Tok_Type_double,
|
||||||
|
Tok_Type_MS_int8,
|
||||||
|
Tok_Type_MS_int16,
|
||||||
|
Tok_Type_MS_int32,
|
||||||
|
Tok_Type_MS_int64,
|
||||||
|
Tok_Type_MS_W64,
|
||||||
|
Tok_Varadic_Argument,
|
||||||
|
Tok___Attributes_Start,
|
||||||
|
Tok_Attribute_API_Export,
|
||||||
|
Tok_Attribute_API_Import,
|
||||||
|
Tok_NumTokens
|
||||||
|
};
|
||||||
|
|
||||||
enum Type : u32
|
inline StrC to_str( TokType type )
|
||||||
{
|
{
|
||||||
Invalid,
|
|
||||||
Access_Private,
|
|
||||||
Access_Protected,
|
|
||||||
Access_Public,
|
|
||||||
Access_MemberSymbol,
|
|
||||||
Access_StaticSymbol,
|
|
||||||
Ampersand,
|
|
||||||
Ampersand_DBL,
|
|
||||||
Assign_Classifer,
|
|
||||||
Attribute_Open,
|
|
||||||
Attribute_Close,
|
|
||||||
BraceCurly_Open,
|
|
||||||
BraceCurly_Close,
|
|
||||||
BraceSquare_Open,
|
|
||||||
BraceSquare_Close,
|
|
||||||
Capture_Start,
|
|
||||||
Capture_End,
|
|
||||||
Comment,
|
|
||||||
Comment_End,
|
|
||||||
Comment_Start,
|
|
||||||
Char,
|
|
||||||
Comma,
|
|
||||||
Decl_Class,
|
|
||||||
Decl_GNU_Attribute,
|
|
||||||
Decl_MSVC_Attribute,
|
|
||||||
Decl_Enum,
|
|
||||||
Decl_Extern_Linkage,
|
|
||||||
Decl_Friend,
|
|
||||||
Decl_Module,
|
|
||||||
Decl_Namespace,
|
|
||||||
Decl_Operator,
|
|
||||||
Decl_Struct,
|
|
||||||
Decl_Template,
|
|
||||||
Decl_Typedef,
|
|
||||||
Decl_Using,
|
|
||||||
Decl_Union,
|
|
||||||
Identifier,
|
|
||||||
Module_Import,
|
|
||||||
Module_Export,
|
|
||||||
NewLine,
|
|
||||||
Number,
|
|
||||||
Operator,
|
|
||||||
Preprocess_Hash,
|
|
||||||
Preprocess_Define,
|
|
||||||
Preprocess_If,
|
|
||||||
Preprocess_IfDef,
|
|
||||||
Preprocess_IfNotDef,
|
|
||||||
Preprocess_ElIf,
|
|
||||||
Preprocess_Else,
|
|
||||||
Preprocess_EndIf,
|
|
||||||
Preprocess_Include,
|
|
||||||
Preprocess_Pragma,
|
|
||||||
Preprocess_Content,
|
|
||||||
Preprocess_Macro,
|
|
||||||
Preprocess_Unsupported,
|
|
||||||
Spec_Alignas,
|
|
||||||
Spec_Const,
|
|
||||||
Spec_Consteval,
|
|
||||||
Spec_Constexpr,
|
|
||||||
Spec_Constinit,
|
|
||||||
Spec_Explicit,
|
|
||||||
Spec_Extern,
|
|
||||||
Spec_Final,
|
|
||||||
Spec_ForceInline,
|
|
||||||
Spec_Global,
|
|
||||||
Spec_Inline,
|
|
||||||
Spec_Internal_Linkage,
|
|
||||||
Spec_LocalPersist,
|
|
||||||
Spec_Mutable,
|
|
||||||
Spec_NeverInline,
|
|
||||||
Spec_Override,
|
|
||||||
Spec_Static,
|
|
||||||
Spec_ThreadLocal,
|
|
||||||
Spec_Volatile,
|
|
||||||
Spec_Virtual,
|
|
||||||
Star,
|
|
||||||
Statement_End,
|
|
||||||
StaticAssert,
|
|
||||||
String,
|
|
||||||
Type_Typename,
|
|
||||||
Type_Unsigned,
|
|
||||||
Type_Signed,
|
|
||||||
Type_Short,
|
|
||||||
Type_Long,
|
|
||||||
Type_bool,
|
|
||||||
Type_char,
|
|
||||||
Type_int,
|
|
||||||
Type_double,
|
|
||||||
Type_MS_int8,
|
|
||||||
Type_MS_int16,
|
|
||||||
Type_MS_int32,
|
|
||||||
Type_MS_int64,
|
|
||||||
Type_MS_W64,
|
|
||||||
Varadic_Argument,
|
|
||||||
__Attributes_Start,
|
|
||||||
Attribute_API_Export,
|
|
||||||
Attribute_API_Import,
|
|
||||||
NumTokens
|
|
||||||
};
|
|
||||||
|
|
||||||
inline StrC to_str( Type type )
|
|
||||||
{
|
|
||||||
local_persist StrC lookup[] {
|
local_persist StrC lookup[] {
|
||||||
{ sizeof( "__invalid__" ), "__invalid__" },
|
{ sizeof( "__invalid__" ), "__invalid__" },
|
||||||
{ sizeof( "private" ), "private" },
|
{ sizeof( "private" ), "private" },
|
||||||
@ -215,27 +214,23 @@ namespace parser
|
|||||||
{ sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" },
|
{ sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" },
|
||||||
};
|
};
|
||||||
return lookup[type];
|
return lookup[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Type to_type( StrC str )
|
inline TokType to_toktype( StrC str )
|
||||||
|
{
|
||||||
|
local_persist u32 keymap[Tok_NumTokens];
|
||||||
|
do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||||
{
|
{
|
||||||
local_persist u32 keymap[NumTokens];
|
StrC enum_str = to_str( (TokType)index );
|
||||||
do_once_start for ( u32 index = 0; index < NumTokens; index++ )
|
|
||||||
{
|
|
||||||
StrC enum_str = to_str( (Type)index );
|
|
||||||
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
||||||
}
|
}
|
||||||
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
||||||
for ( u32 index = 0; index < NumTokens; index++ )
|
for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||||
{
|
{
|
||||||
if ( keymap[index] == hash )
|
if ( keymap[index] == hash )
|
||||||
return (Type)index;
|
return (TokType)index;
|
||||||
}
|
|
||||||
return Invalid;
|
|
||||||
}
|
}
|
||||||
|
return Tok_Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ETokType
|
GEN_NS_PARSER_END
|
||||||
|
|
||||||
using TokType = ETokType::Type;
|
|
||||||
|
|
||||||
} // namespace parser
|
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
@ -232,7 +232,7 @@ CodeParam end(CodeParam params)
|
|||||||
|
|
||||||
#pragma region CodeSpecifiers
|
#pragma region CodeSpecifiers
|
||||||
inline
|
inline
|
||||||
bool append(CodeSpecifiers self, SpecifierT spec )
|
bool append(CodeSpecifiers self, Specifier spec )
|
||||||
{
|
{
|
||||||
if ( self.ast == nullptr )
|
if ( self.ast == nullptr )
|
||||||
{
|
{
|
||||||
@ -250,7 +250,7 @@ bool append(CodeSpecifiers self, SpecifierT spec )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
inline
|
inline
|
||||||
s32 has(CodeSpecifiers self, SpecifierT spec)
|
s32 has(CodeSpecifiers self, Specifier spec)
|
||||||
{
|
{
|
||||||
GEN_ASSERT(self.ast != nullptr);
|
GEN_ASSERT(self.ast != nullptr);
|
||||||
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
|
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
|
||||||
@ -260,7 +260,7 @@ s32 has(CodeSpecifiers self, SpecifierT spec)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
inline
|
inline
|
||||||
s32 remove( CodeSpecifiers self, SpecifierT to_remove )
|
s32 remove( CodeSpecifiers self, Specifier to_remove )
|
||||||
{
|
{
|
||||||
AST_Specifiers* ast = self.ast;
|
AST_Specifiers* ast = self.ast;
|
||||||
if ( ast == nullptr )
|
if ( ast == nullptr )
|
||||||
@ -280,7 +280,7 @@ s32 remove( CodeSpecifiers self, SpecifierT to_remove )
|
|||||||
s32 next = 0;
|
s32 next = 0;
|
||||||
for(; next < self->NumEntries; ++ curr, ++ next)
|
for(; next < self->NumEntries; ++ curr, ++ next)
|
||||||
{
|
{
|
||||||
SpecifierT spec = self->ArrSpecs[next];
|
Specifier spec = self->ArrSpecs[next];
|
||||||
if (spec == to_remove)
|
if (spec == to_remove)
|
||||||
{
|
{
|
||||||
result = next;
|
result = next;
|
||||||
@ -301,7 +301,7 @@ s32 remove( CodeSpecifiers self, SpecifierT to_remove )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
inline
|
inline
|
||||||
SpecifierT* begin(CodeSpecifiers self)
|
Specifier* begin(CodeSpecifiers self)
|
||||||
{
|
{
|
||||||
if ( self.ast )
|
if ( self.ast )
|
||||||
return & self->ArrSpecs[0];
|
return & self->ArrSpecs[0];
|
||||||
@ -309,7 +309,7 @@ SpecifierT* begin(CodeSpecifiers self)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
inline
|
inline
|
||||||
SpecifierT* end(CodeSpecifiers self)
|
Specifier* end(CodeSpecifiers self)
|
||||||
{
|
{
|
||||||
return self->ArrSpecs + self->NumEntries;
|
return self->ArrSpecs + self->NumEntries;
|
||||||
}
|
}
|
||||||
@ -317,9 +317,9 @@ SpecifierT* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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_ ) \
|
||||||
@ -192,32 +192,32 @@ void define_constants()
|
|||||||
# undef internal
|
# undef internal
|
||||||
# undef local_persist
|
# undef local_persist
|
||||||
# undef neverinline
|
# undef neverinline
|
||||||
def_constant_spec( const, ESpecifier::Const );
|
def_constant_spec( const, Spec_Const );
|
||||||
def_constant_spec( consteval, ESpecifier::Consteval );
|
def_constant_spec( consteval, Spec_Consteval );
|
||||||
def_constant_spec( constexpr, ESpecifier::Constexpr );
|
def_constant_spec( constexpr, Spec_Constexpr );
|
||||||
def_constant_spec( constinit, ESpecifier::Constinit );
|
def_constant_spec( constinit, Spec_Constinit );
|
||||||
def_constant_spec( extern_linkage, ESpecifier::External_Linkage );
|
def_constant_spec( extern_linkage, Spec_External_Linkage );
|
||||||
def_constant_spec( final, ESpecifier::Final );
|
def_constant_spec( final, Spec_Final );
|
||||||
def_constant_spec( forceinline, ESpecifier::ForceInline );
|
def_constant_spec( forceinline, Spec_ForceInline );
|
||||||
def_constant_spec( global, ESpecifier::Global );
|
def_constant_spec( global, Spec_Global );
|
||||||
def_constant_spec( inline, ESpecifier::Inline );
|
def_constant_spec( inline, Spec_Inline );
|
||||||
def_constant_spec( internal_linkage, ESpecifier::Internal_Linkage );
|
def_constant_spec( internal_linkage, Spec_Internal_Linkage );
|
||||||
def_constant_spec( local_persist, ESpecifier::Local_Persist );
|
def_constant_spec( local_persist, Spec_Local_Persist );
|
||||||
def_constant_spec( mutable, ESpecifier::Mutable );
|
def_constant_spec( mutable, Spec_Mutable );
|
||||||
def_constant_spec( neverinline, ESpecifier::NeverInline );
|
def_constant_spec( neverinline, Spec_NeverInline );
|
||||||
def_constant_spec( noexcept, ESpecifier::NoExceptions );
|
def_constant_spec( noexcept, Spec_NoExceptions );
|
||||||
def_constant_spec( override, ESpecifier::Override );
|
def_constant_spec( override, Spec_Override );
|
||||||
def_constant_spec( ptr, ESpecifier::Ptr );
|
def_constant_spec( ptr, Spec_Ptr );
|
||||||
def_constant_spec( pure, ESpecifier::Pure )
|
def_constant_spec( pure, Spec_Pure )
|
||||||
def_constant_spec( ref, ESpecifier::Ref );
|
def_constant_spec( ref, Spec_Ref );
|
||||||
def_constant_spec( register, ESpecifier::Register );
|
def_constant_spec( register, Spec_Register );
|
||||||
def_constant_spec( rvalue, ESpecifier::RValue );
|
def_constant_spec( rvalue, Spec_RValue );
|
||||||
def_constant_spec( static_member, ESpecifier::Static );
|
def_constant_spec( static_member, Spec_Static );
|
||||||
def_constant_spec( thread_local, ESpecifier::Thread_Local );
|
def_constant_spec( thread_local, Spec_Thread_Local );
|
||||||
def_constant_spec( virtual, ESpecifier::Virtual );
|
def_constant_spec( virtual, Spec_Virtual );
|
||||||
def_constant_spec( volatile, ESpecifier::Volatile)
|
def_constant_spec( volatile, Spec_Volatile)
|
||||||
|
|
||||||
spec_local_persist = def_specifiers( 1, ESpecifier::Local_Persist );
|
spec_local_persist = def_specifiers( 1, Spec_Local_Persist );
|
||||||
set_global(spec_local_persist);
|
set_global(spec_local_persist);
|
||||||
|
|
||||||
# pragma pop_macro("forceinline")
|
# pragma pop_macro("forceinline")
|
||||||
|
@ -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,27 +100,27 @@ 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;
|
||||||
ModuleFlag mflags;
|
ModuleFlag mflags;
|
||||||
};
|
};
|
||||||
CodeOperator def_operator( OperatorT op, StrC nspace, Opts_def_operator opts GEN_PARAM_DEFAULT );
|
CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator opts GEN_PARAM_DEFAULT );
|
||||||
|
|
||||||
struct Opts_def_operator_cast {
|
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 );
|
||||||
|
|
||||||
CodeSpecifiers def_specifier( SpecifierT specifier );
|
CodeSpecifiers def_specifier( Specifier specifier );
|
||||||
|
|
||||||
CodeStruct def_struct( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT );
|
CodeStruct def_struct( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT );
|
||||||
|
|
||||||
@ -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.
|
||||||
@ -186,7 +186,7 @@ CodeBody def_namespace_body ( s32 num, Code* codes );
|
|||||||
CodeParam def_params ( s32 num, ... );
|
CodeParam def_params ( s32 num, ... );
|
||||||
CodeParam def_params ( s32 num, CodeParam* params );
|
CodeParam def_params ( s32 num, CodeParam* params );
|
||||||
CodeSpecifiers def_specifiers ( s32 num, ... );
|
CodeSpecifiers def_specifiers ( s32 num, ... );
|
||||||
CodeSpecifiers def_specifiers ( s32 num, SpecifierT* specs );
|
CodeSpecifiers def_specifiers ( s32 num, Specifier* specs );
|
||||||
CodeBody def_struct_body ( s32 num, ... );
|
CodeBody def_struct_body ( s32 num, ... );
|
||||||
CodeBody def_struct_body ( s32 num, Code* codes );
|
CodeBody def_struct_body ( s32 num, Code* codes );
|
||||||
CodeBody def_union_body ( s32 num, ... );
|
CodeBody def_union_body ( s32 num, ... );
|
||||||
@ -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 );
|
||||||
|
@ -10,23 +10,24 @@
|
|||||||
|
|
||||||
CodeClass parse_class( StrC def )
|
CodeClass parse_class( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
|
|
||||||
parser::TokArray toks = parser::lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
return InvalidCode;
|
return InvalidCode;
|
||||||
|
|
||||||
parser::Context.Tokens = toks;
|
Context.Tokens = toks;
|
||||||
push_scope();
|
push_scope();
|
||||||
CodeClass result = (CodeClass) parser::parse_class_struct( parser::TokType::Decl_Class );
|
CodeClass result = (CodeClass) parse_class_struct( Tok_Decl_Class );
|
||||||
parser::Context.pop();
|
pop(& Context);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeConstructor parse_constructor( StrC def )
|
CodeConstructor parse_constructor( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -35,31 +36,31 @@ CodeConstructor parse_constructor( StrC def )
|
|||||||
// TODO(Ed): Constructors can have prefix attributes
|
// TODO(Ed): Constructors can have prefix attributes
|
||||||
|
|
||||||
CodeSpecifiers specifiers;
|
CodeSpecifiers specifiers;
|
||||||
SpecifierT specs_found[ 16 ] { ESpecifier::NumSpecifiers };
|
Specifier specs_found[ 16 ] { Spec_NumSpecifiers };
|
||||||
s32 NumSpecifiers = 0;
|
s32 NumSpecifiers = 0;
|
||||||
|
|
||||||
while ( left && is_specifier(currtok) )
|
while ( left && is_specifier(currtok) )
|
||||||
{
|
{
|
||||||
SpecifierT spec = ESpecifier::to_type( to_str(currtok) );
|
Specifier spec = to_specifier( to_str(currtok) );
|
||||||
|
|
||||||
b32 ignore_spec = false;
|
b32 ignore_spec = false;
|
||||||
|
|
||||||
switch ( spec )
|
switch ( spec )
|
||||||
{
|
{
|
||||||
case ESpecifier::Constexpr :
|
case Spec_Constexpr :
|
||||||
case ESpecifier::Explicit:
|
case Spec_Explicit:
|
||||||
case ESpecifier::Inline :
|
case Spec_Inline :
|
||||||
case ESpecifier::ForceInline :
|
case Spec_ForceInline :
|
||||||
case ESpecifier::NeverInline :
|
case Spec_NeverInline :
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESpecifier::Const :
|
case Spec_Const :
|
||||||
ignore_spec = true;
|
ignore_spec = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), Context.to_string() );
|
log_failure( "Invalid specifier %s for variable\n%s", to_str( spec ), to_string(Context) );
|
||||||
Context.pop();
|
pop(& Context);
|
||||||
return InvalidCode;
|
return InvalidCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +86,8 @@ CodeConstructor parse_constructor( StrC def )
|
|||||||
|
|
||||||
CodeDestructor parse_destructor( StrC def )
|
CodeDestructor parse_destructor( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -102,13 +103,13 @@ CodeDestructor parse_destructor( StrC def )
|
|||||||
|
|
||||||
CodeEnum parse_enum( StrC def )
|
CodeEnum parse_enum( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
{
|
{
|
||||||
Context.pop();
|
pop(& Context);
|
||||||
return InvalidCode;
|
return InvalidCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,8 +119,8 @@ CodeEnum parse_enum( StrC def )
|
|||||||
|
|
||||||
CodeBody parse_export_body( StrC def )
|
CodeBody parse_export_body( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -131,8 +132,8 @@ CodeBody parse_export_body( StrC def )
|
|||||||
|
|
||||||
CodeExtern parse_extern_link( StrC def )
|
CodeExtern parse_extern_link( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -144,8 +145,8 @@ CodeExtern parse_extern_link( StrC def )
|
|||||||
|
|
||||||
CodeFriend parse_friend( StrC def )
|
CodeFriend parse_friend( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -157,8 +158,8 @@ CodeFriend parse_friend( StrC def )
|
|||||||
|
|
||||||
CodeFn parse_function( StrC def )
|
CodeFn parse_function( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -170,8 +171,8 @@ CodeFn parse_function( StrC def )
|
|||||||
|
|
||||||
CodeBody parse_global_body( StrC def )
|
CodeBody parse_global_body( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -179,15 +180,15 @@ 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 );
|
||||||
Context.pop();
|
pop(& Context);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeNS parse_namespace( StrC def )
|
CodeNS parse_namespace( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -199,8 +200,8 @@ CodeNS parse_namespace( StrC def )
|
|||||||
|
|
||||||
CodeOperator parse_operator( StrC def )
|
CodeOperator parse_operator( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -212,8 +213,8 @@ CodeOperator parse_operator( StrC def )
|
|||||||
|
|
||||||
CodeOpCast parse_operator_cast( StrC def )
|
CodeOpCast parse_operator_cast( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -225,8 +226,8 @@ CodeOpCast parse_operator_cast( StrC def )
|
|||||||
|
|
||||||
CodeStruct parse_struct( StrC def )
|
CodeStruct parse_struct( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -234,15 +235,15 @@ CodeStruct parse_struct( StrC def )
|
|||||||
|
|
||||||
Context.Tokens = toks;
|
Context.Tokens = toks;
|
||||||
push_scope();
|
push_scope();
|
||||||
CodeStruct result = (CodeStruct) parse_class_struct( TokType::Decl_Struct );
|
CodeStruct result = (CodeStruct) parse_class_struct( Tok_Decl_Struct );
|
||||||
Context.pop();
|
pop(& Context);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeTemplate parse_template( StrC def )
|
CodeTemplate parse_template( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -252,10 +253,10 @@ 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;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -267,8 +268,8 @@ CodeType parse_type( StrC def )
|
|||||||
|
|
||||||
CodeTypedef parse_typedef( StrC def )
|
CodeTypedef parse_typedef( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -280,8 +281,8 @@ CodeTypedef parse_typedef( StrC def )
|
|||||||
|
|
||||||
CodeUnion parse_union( StrC def )
|
CodeUnion parse_union( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -293,8 +294,8 @@ CodeUnion parse_union( StrC def )
|
|||||||
|
|
||||||
CodeUsing parse_using( StrC def )
|
CodeUsing parse_using( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
@ -306,8 +307,8 @@ CodeUsing parse_using( StrC def )
|
|||||||
|
|
||||||
CodeVar parse_variable( StrC def )
|
CodeVar parse_variable( StrC def )
|
||||||
{
|
{
|
||||||
|
GEN_USING_NS_PARSER;
|
||||||
check_parse_args( def );
|
check_parse_args( def );
|
||||||
using namespace parser;
|
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
if ( toks.Arr == nullptr )
|
if ( toks.Arr == nullptr )
|
||||||
|
@ -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
@ -33,7 +33,7 @@ struct Token
|
|||||||
u32 Flags;
|
u32 Flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Token NullToken { nullptr, 0, TokType::Invalid, false, 0, TF_Null };
|
constexpr Token NullToken { nullptr, 0, Tok_Invalid, false, 0, TF_Null };
|
||||||
|
|
||||||
AccessSpec to_access_specifier(Token tok)
|
AccessSpec to_access_specifier(Token tok)
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ StrC to_str(Token tok)
|
|||||||
|
|
||||||
bool is_valid( Token tok )
|
bool is_valid( Token tok )
|
||||||
{
|
{
|
||||||
return tok.Text && tok.Length && tok.Type != TokType::Invalid;
|
return tok.Text && tok.Length && tok.Type != Tok_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_access_operator(Token tok)
|
bool is_access_operator(Token tok)
|
||||||
@ -94,7 +94,7 @@ String to_string(Token tok)
|
|||||||
{
|
{
|
||||||
String result = string_make_reserve( GlobalAllocator, kilobytes(4) );
|
String result = string_make_reserve( GlobalAllocator, kilobytes(4) );
|
||||||
|
|
||||||
StrC type_str = ETokType::to_str( tok.Type );
|
StrC type_str = to_str( tok.Type );
|
||||||
|
|
||||||
append_fmt( & result, "Line: %d Column: %d, Type: %.*s Content: %.*s"
|
append_fmt( & result, "Line: %d Column: %d, Type: %.*s Content: %.*s"
|
||||||
, tok.Line, tok.Column
|
, tok.Line, tok.Column
|
||||||
@ -117,7 +117,7 @@ Token* current(TokArray* self, bool skip_formatting )
|
|||||||
{
|
{
|
||||||
if ( skip_formatting )
|
if ( skip_formatting )
|
||||||
{
|
{
|
||||||
while ( self->Arr[self->Idx].Type == TokType::NewLine || self->Arr[self->Idx].Type == TokType::Comment )
|
while ( self->Arr[self->Idx].Type == Tok_NewLine || self->Arr[self->Idx].Type == Tok_Comment )
|
||||||
self->Idx++;
|
self->Idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ Token* previous(TokArray self, bool skip_formatting)
|
|||||||
|
|
||||||
if ( skip_formatting )
|
if ( skip_formatting )
|
||||||
{
|
{
|
||||||
while ( self.Arr[idx].Type == TokType::NewLine )
|
while ( self.Arr[idx].Type == Tok_NewLine )
|
||||||
idx --;
|
idx --;
|
||||||
|
|
||||||
return & self.Arr[idx];
|
return & self.Arr[idx];
|
||||||
@ -145,7 +145,7 @@ Token* next(TokArray self, bool skip_formatting)
|
|||||||
|
|
||||||
if ( skip_formatting )
|
if ( skip_formatting )
|
||||||
{
|
{
|
||||||
while ( self.Arr[idx].Type == TokType::NewLine )
|
while ( self.Arr[idx].Type == Tok_NewLine )
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
return & self.Arr[idx + 1];
|
return & self.Arr[idx + 1];
|
||||||
@ -221,7 +221,7 @@ forceinline
|
|||||||
s32 lex_preprocessor_directive( LexContext* ctx )
|
s32 lex_preprocessor_directive( LexContext* ctx )
|
||||||
{
|
{
|
||||||
char const* hash = ctx->scanner;
|
char const* hash = ctx->scanner;
|
||||||
append( & Tokens, { hash, 1, TokType::Preprocess_Hash, ctx->line, ctx->column, TF_Preprocess } );
|
append( & Tokens, { hash, 1, Tok_Preprocess_Hash, ctx->line, ctx->column, TF_Preprocess } );
|
||||||
|
|
||||||
move_forward();
|
move_forward();
|
||||||
SkipWhitespace();
|
SkipWhitespace();
|
||||||
@ -233,12 +233,12 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
|||||||
ctx->token.Length++;
|
ctx->token.Length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->token.Type = ETokType::to_type( to_str(ctx->token) );
|
ctx->token.Type = to_toktype( to_str(ctx->token) );
|
||||||
|
|
||||||
bool is_preprocessor = ctx->token.Type >= TokType::Preprocess_Define && ctx->token.Type <= TokType::Preprocess_Pragma;
|
bool is_preprocessor = ctx->token.Type >= Tok_Preprocess_Define && ctx->token.Type <= Tok_Preprocess_Pragma;
|
||||||
if ( ! is_preprocessor )
|
if ( ! is_preprocessor )
|
||||||
{
|
{
|
||||||
ctx->token.Type = TokType::Preprocess_Unsupported;
|
ctx->token.Type = Tok_Preprocess_Unsupported;
|
||||||
|
|
||||||
// Its an unsupported directive, skip it
|
// Its an unsupported directive, skip it
|
||||||
s32 within_string = false;
|
s32 within_string = false;
|
||||||
@ -301,14 +301,14 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
|||||||
return Lex_Continue; // Skip found token, its all handled here.
|
return Lex_Continue; // Skip found token, its all handled here.
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ctx->token.Type == TokType::Preprocess_Else || ctx->token.Type == TokType::Preprocess_EndIf )
|
if ( ctx->token.Type == Tok_Preprocess_Else || ctx->token.Type == Tok_Preprocess_EndIf )
|
||||||
{
|
{
|
||||||
ctx->token.Flags |= TF_Preprocess_Cond;
|
ctx->token.Flags |= TF_Preprocess_Cond;
|
||||||
append( & Tokens, ctx->token );
|
append( & Tokens, ctx->token );
|
||||||
end_line();
|
end_line();
|
||||||
return Lex_Continue;
|
return Lex_Continue;
|
||||||
}
|
}
|
||||||
else if ( ctx->token.Type >= TokType::Preprocess_If && ctx->token.Type <= TokType::Preprocess_ElIf )
|
else if ( ctx->token.Type >= Tok_Preprocess_If && ctx->token.Type <= Tok_Preprocess_ElIf )
|
||||||
{
|
{
|
||||||
ctx->token.Flags |= TF_Preprocess_Cond;
|
ctx->token.Flags |= TF_Preprocess_Cond;
|
||||||
}
|
}
|
||||||
@ -317,9 +317,9 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
|||||||
|
|
||||||
SkipWhitespace();
|
SkipWhitespace();
|
||||||
|
|
||||||
if ( ctx->token.Type == TokType::Preprocess_Define )
|
if ( ctx->token.Type == Tok_Preprocess_Define )
|
||||||
{
|
{
|
||||||
Token name = { ctx->scanner, 0, TokType::Identifier, ctx->line, ctx->column, TF_Preprocess };
|
Token name = { ctx->scanner, 0, Tok_Identifier, ctx->line, ctx->column, TF_Preprocess };
|
||||||
|
|
||||||
name.Text = ctx->scanner;
|
name.Text = ctx->scanner;
|
||||||
name.Length = 1;
|
name.Length = 1;
|
||||||
@ -343,11 +343,11 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
|||||||
set(& ctx->defines, key, to_str(name) );
|
set(& ctx->defines, key, to_str(name) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Token preprocess_content = { ctx->scanner, 0, TokType::Preprocess_Content, ctx->line, ctx->column, TF_Preprocess };
|
Token preprocess_content = { ctx->scanner, 0, Tok_Preprocess_Content, ctx->line, ctx->column, TF_Preprocess };
|
||||||
|
|
||||||
if ( ctx->token.Type == TokType::Preprocess_Include )
|
if ( ctx->token.Type == Tok_Preprocess_Include )
|
||||||
{
|
{
|
||||||
preprocess_content.Type = TokType::String;
|
preprocess_content.Type = Tok_String;
|
||||||
|
|
||||||
if ( current != '"' && current != '<' )
|
if ( current != '"' && current != '<' )
|
||||||
{
|
{
|
||||||
@ -452,31 +452,31 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
|||||||
forceinline
|
forceinline
|
||||||
void lex_found_token( LexContext* ctx )
|
void lex_found_token( LexContext* ctx )
|
||||||
{
|
{
|
||||||
if ( ctx->token.Type != TokType::Invalid )
|
if ( ctx->token.Type != Tok_Invalid )
|
||||||
{
|
{
|
||||||
append( & Tokens, ctx->token );
|
append( & Tokens, ctx->token );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokType type = ETokType::to_type( to_str(ctx->token) );
|
TokType type = to_toktype( to_str(ctx->token) );
|
||||||
|
|
||||||
if (type <= TokType::Access_Public && type >= TokType::Access_Private )
|
if (type <= Tok_Access_Public && type >= Tok_Access_Private )
|
||||||
{
|
{
|
||||||
ctx->token.Flags |= TF_AccessSpecifier;
|
ctx->token.Flags |= TF_AccessSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type > TokType::__Attributes_Start )
|
if ( type > Tok___Attributes_Start )
|
||||||
{
|
{
|
||||||
ctx->token.Flags |= TF_Attribute;
|
ctx->token.Flags |= TF_Attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type == ETokType::Decl_Extern_Linkage )
|
if ( type == Tok_Decl_Extern_Linkage )
|
||||||
{
|
{
|
||||||
SkipWhitespace();
|
SkipWhitespace();
|
||||||
|
|
||||||
if ( current != '"' )
|
if ( current != '"' )
|
||||||
{
|
{
|
||||||
type = ETokType::Spec_Extern;
|
type = Tok_Spec_Extern;
|
||||||
ctx->token.Flags |= TF_Specifier;
|
ctx->token.Flags |= TF_Specifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,9 +485,9 @@ void lex_found_token( LexContext* ctx )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( type <= TokType::Star && type >= TokType::Spec_Alignas)
|
if ( ( type <= Tok_Star && type >= Tok_Spec_Alignas)
|
||||||
|| type == TokType::Ampersand
|
|| type == Tok_Ampersand
|
||||||
|| type == TokType::Ampersand_DBL )
|
|| type == Tok_Ampersand_DBL )
|
||||||
{
|
{
|
||||||
ctx->token.Type = type;
|
ctx->token.Type = type;
|
||||||
ctx->token.Flags |= TF_Specifier;
|
ctx->token.Flags |= TF_Specifier;
|
||||||
@ -496,7 +496,7 @@ void lex_found_token( LexContext* ctx )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( type != TokType::Invalid )
|
if ( type != Tok_Invalid )
|
||||||
{
|
{
|
||||||
ctx->token.Type = type;
|
ctx->token.Type = type;
|
||||||
append( & Tokens, ctx->token );
|
append( & Tokens, ctx->token );
|
||||||
@ -512,7 +512,7 @@ void lex_found_token( LexContext* ctx )
|
|||||||
StrC* define = get(ctx->defines, key );
|
StrC* define = get(ctx->defines, key );
|
||||||
if ( define )
|
if ( define )
|
||||||
{
|
{
|
||||||
ctx->token.Type = TokType::Preprocess_Macro;
|
ctx->token.Type = Tok_Preprocess_Macro;
|
||||||
|
|
||||||
// Want to ignore any arguments the define may have as they can be execution expressions.
|
// Want to ignore any arguments the define may have as they can be execution expressions.
|
||||||
if ( ctx->left && current == '(' )
|
if ( ctx->left && current == '(' )
|
||||||
@ -548,7 +548,7 @@ void lex_found_token( LexContext* ctx )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ctx->token.Type = TokType::Identifier;
|
ctx->token.Type = Tok_Identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
append( & Tokens, ctx->token );
|
append( & Tokens, ctx->token );
|
||||||
@ -607,7 +607,7 @@ TokArray lex( StrC content )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
c.token = { c.scanner, 0, TokType::Invalid, c.line, c.column, TF_Null };
|
c.token = { c.scanner, 0, Tok_Invalid, c.line, c.column, TF_Null };
|
||||||
|
|
||||||
bool is_define = false;
|
bool is_define = false;
|
||||||
|
|
||||||
@ -623,7 +623,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
move_forward();
|
move_forward();
|
||||||
|
|
||||||
c.token.Type = TokType::NewLine;
|
c.token.Type = Tok_NewLine;
|
||||||
c.token.Length++;
|
c.token.Length++;
|
||||||
|
|
||||||
append( & Tokens, c.token );
|
append( & Tokens, c.token );
|
||||||
@ -655,7 +655,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Access_MemberSymbol;
|
c.token.Type = Tok_Access_MemberSymbol;
|
||||||
c.token.Flags = TF_AccessOperator;
|
c.token.Flags = TF_AccessOperator;
|
||||||
|
|
||||||
if (c.left) {
|
if (c.left) {
|
||||||
@ -668,7 +668,7 @@ TokArray lex( StrC content )
|
|||||||
if( current == '.' )
|
if( current == '.' )
|
||||||
{
|
{
|
||||||
c.token.Length = 3;
|
c.token.Length = 3;
|
||||||
c.token.Type = TokType::Varadic_Argument;
|
c.token.Type = Tok_Varadic_Argument;
|
||||||
c.token.Flags = TF_Null;
|
c.token.Flags = TF_Null;
|
||||||
move_forward();
|
move_forward();
|
||||||
}
|
}
|
||||||
@ -686,7 +686,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Ampersand;
|
c.token.Type = Tok_Ampersand;
|
||||||
c.token.Flags |= TF_Operator;
|
c.token.Flags |= TF_Operator;
|
||||||
c.token.Flags |= TF_Specifier;
|
c.token.Flags |= TF_Specifier;
|
||||||
|
|
||||||
@ -696,7 +696,7 @@ TokArray lex( StrC content )
|
|||||||
if ( current == '&' ) // &&
|
if ( current == '&' ) // &&
|
||||||
{
|
{
|
||||||
c.token.Length = 2;
|
c.token.Length = 2;
|
||||||
c.token.Type = TokType::Ampersand_DBL;
|
c.token.Type = Tok_Ampersand_DBL;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -708,9 +708,9 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Assign_Classifer;
|
c.token.Type = Tok_Assign_Classifer;
|
||||||
// Can be either a classifier (ParentType, Bitfield width), or ternary else
|
// Can be either a classifier (ParentType, Bitfield width), or ternary else
|
||||||
// token.Type = TokType::Colon;
|
// token.Type = Tok_Colon;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -718,7 +718,7 @@ TokArray lex( StrC content )
|
|||||||
if ( current == ':' )
|
if ( current == ':' )
|
||||||
{
|
{
|
||||||
move_forward();
|
move_forward();
|
||||||
c.token.Type = TokType::Access_StaticSymbol;
|
c.token.Type = Tok_Access_StaticSymbol;
|
||||||
c.token.Length++;
|
c.token.Length++;
|
||||||
}
|
}
|
||||||
goto FoundToken;
|
goto FoundToken;
|
||||||
@ -727,7 +727,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::BraceCurly_Open;
|
c.token.Type = Tok_BraceCurly_Open;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -737,7 +737,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::BraceCurly_Close;
|
c.token.Type = Tok_BraceCurly_Close;
|
||||||
c.token.Flags = TF_EndDefinition;
|
c.token.Flags = TF_EndDefinition;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
@ -750,7 +750,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::BraceSquare_Open;
|
c.token.Type = Tok_BraceSquare_Open;
|
||||||
if ( c.left )
|
if ( c.left )
|
||||||
{
|
{
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -758,7 +758,7 @@ TokArray lex( StrC content )
|
|||||||
if ( current == ']' )
|
if ( current == ']' )
|
||||||
{
|
{
|
||||||
c.token.Length = 2;
|
c.token.Length = 2;
|
||||||
c.token.Type = TokType::Operator;
|
c.token.Type = Tok_Operator;
|
||||||
move_forward();
|
move_forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -768,7 +768,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::BraceSquare_Close;
|
c.token.Type = Tok_BraceSquare_Close;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -778,7 +778,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Capture_Start;
|
c.token.Type = Tok_Capture_Start;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -788,7 +788,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Capture_End;
|
c.token.Type = Tok_Capture_End;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -798,7 +798,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Char;
|
c.token.Type = Tok_Char;
|
||||||
c.token.Flags = TF_Literal;
|
c.token.Flags = TF_Literal;
|
||||||
|
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -832,7 +832,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Comma;
|
c.token.Type = Tok_Comma;
|
||||||
c.token.Flags = TF_Operator;
|
c.token.Flags = TF_Operator;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
@ -843,7 +843,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Star;
|
c.token.Type = Tok_Star;
|
||||||
c.token.Flags |= TF_Specifier;
|
c.token.Flags |= TF_Specifier;
|
||||||
c.token.Flags |= TF_Operator;
|
c.token.Flags |= TF_Operator;
|
||||||
|
|
||||||
@ -854,7 +854,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Length++;
|
c.token.Length++;
|
||||||
c.token.Flags |= TF_Assign;
|
c.token.Flags |= TF_Assign;
|
||||||
// c.token.Type = TokType::Assign_Multiply;
|
// c.token.Type = Tok_Assign_Multiply;
|
||||||
|
|
||||||
if ( c.left )
|
if ( c.left )
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -866,7 +866,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Statement_End;
|
c.token.Type = Tok_Statement_End;
|
||||||
c.token.Flags = TF_EndDefinition;
|
c.token.Flags = TF_EndDefinition;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
@ -879,7 +879,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::String;
|
c.token.Type = Tok_String;
|
||||||
c.token.Flags |= TF_Literal;
|
c.token.Flags |= TF_Literal;
|
||||||
|
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -913,8 +913,8 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Operator;
|
c.token.Type = Tok_Operator;
|
||||||
// c.token.Type = TokType::Ternary;
|
// c.token.Type = Tok_Ternary;
|
||||||
c.token.Flags = TF_Operator;
|
c.token.Flags = TF_Operator;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
@ -926,8 +926,8 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Operator;
|
c.token.Type = Tok_Operator;
|
||||||
// c.token.Type = TokType::Assign;
|
// c.token.Type = Tok_Assign;
|
||||||
c.token.Flags = TF_Operator;
|
c.token.Flags = TF_Operator;
|
||||||
c.token.Flags |= TF_Assign;
|
c.token.Flags |= TF_Assign;
|
||||||
|
|
||||||
@ -947,44 +947,44 @@ TokArray lex( StrC content )
|
|||||||
}
|
}
|
||||||
case '+':
|
case '+':
|
||||||
{
|
{
|
||||||
// c.token.Type = TokType::Add
|
// c.token.Type = Tok_Add
|
||||||
|
|
||||||
}
|
}
|
||||||
case '%':
|
case '%':
|
||||||
{
|
{
|
||||||
// c.token.Type = TokType::Modulo;
|
// c.token.Type = Tok_Modulo;
|
||||||
|
|
||||||
}
|
}
|
||||||
case '^':
|
case '^':
|
||||||
{
|
{
|
||||||
// c.token.Type = TokType::B_XOr;
|
// c.token.Type = Tok_B_XOr;
|
||||||
}
|
}
|
||||||
case '~':
|
case '~':
|
||||||
{
|
{
|
||||||
// c.token.Type = TokType::Unary_Not;
|
// c.token.Type = Tok_Unary_Not;
|
||||||
|
|
||||||
}
|
}
|
||||||
case '!':
|
case '!':
|
||||||
{
|
{
|
||||||
// c.token.Type = TokType::L_Not;
|
// c.token.Type = Tok_L_Not;
|
||||||
}
|
}
|
||||||
case '<':
|
case '<':
|
||||||
{
|
{
|
||||||
// c.token.Type = TokType::Lesser;
|
// c.token.Type = Tok_Lesser;
|
||||||
|
|
||||||
}
|
}
|
||||||
case '>':
|
case '>':
|
||||||
{
|
{
|
||||||
// c.token.Type = TokType::Greater;
|
// c.token.Type = Tok_Greater;
|
||||||
|
|
||||||
}
|
}
|
||||||
case '|':
|
case '|':
|
||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Operator;
|
c.token.Type = Tok_Operator;
|
||||||
c.token.Flags = TF_Operator;
|
c.token.Flags = TF_Operator;
|
||||||
// token.Type = TokType::L_Or;
|
// token.Type = Tok_L_Or;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -994,7 +994,7 @@ TokArray lex( StrC content )
|
|||||||
c.token.Length++;
|
c.token.Length++;
|
||||||
c.token.Flags |= TF_Assign;
|
c.token.Flags |= TF_Assign;
|
||||||
// token.Flags |= TokFlags::Assignment;
|
// token.Flags |= TokFlags::Assignment;
|
||||||
// token.Type = TokType::Assign_L_Or;
|
// token.Type = Tok_Assign_L_Or;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -1014,8 +1014,8 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Operator;
|
c.token.Type = Tok_Operator;
|
||||||
// token.Type = TokType::Subtract;
|
// token.Type = Tok_Subtract;
|
||||||
c.token.Flags = TF_Operator;
|
c.token.Flags = TF_Operator;
|
||||||
if ( c.left )
|
if ( c.left )
|
||||||
{
|
{
|
||||||
@ -1024,13 +1024,13 @@ TokArray lex( StrC content )
|
|||||||
if ( current == '>' )
|
if ( current == '>' )
|
||||||
{
|
{
|
||||||
c.token.Length++;
|
c.token.Length++;
|
||||||
// token.Type = TokType::Access_PointerToMemberSymbol;
|
// token.Type = Tok_Access_PointerToMemberSymbol;
|
||||||
c.token.Flags |= TF_AccessOperator;
|
c.token.Flags |= TF_AccessOperator;
|
||||||
move_forward();
|
move_forward();
|
||||||
|
|
||||||
if ( current == '*' )
|
if ( current == '*' )
|
||||||
{
|
{
|
||||||
// token.Type = TokType::Access_PointerToMemberOfPointerSymbol;
|
// token.Type = Tok_Access_PointerToMemberOfPointerSymbol;
|
||||||
c.token.Length++;
|
c.token.Length++;
|
||||||
move_forward();
|
move_forward();
|
||||||
}
|
}
|
||||||
@ -1038,7 +1038,7 @@ TokArray lex( StrC content )
|
|||||||
else if ( current == '=' )
|
else if ( current == '=' )
|
||||||
{
|
{
|
||||||
c.token.Length++;
|
c.token.Length++;
|
||||||
// token.Type = TokType::Assign_Subtract;
|
// token.Type = Tok_Assign_Subtract;
|
||||||
c.token.Flags |= TF_Assign;
|
c.token.Flags |= TF_Assign;
|
||||||
|
|
||||||
if (c.left)
|
if (c.left)
|
||||||
@ -1058,8 +1058,8 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Operator;
|
c.token.Type = Tok_Operator;
|
||||||
// token.Type = TokType::Divide;
|
// token.Type = Tok_Divide;
|
||||||
c.token.Flags = TF_Operator;
|
c.token.Flags = TF_Operator;
|
||||||
move_forward();
|
move_forward();
|
||||||
|
|
||||||
@ -1074,7 +1074,7 @@ TokArray lex( StrC content )
|
|||||||
}
|
}
|
||||||
else if ( current == '/' )
|
else if ( current == '/' )
|
||||||
{
|
{
|
||||||
c.token.Type = TokType::Comment;
|
c.token.Type = Tok_Comment;
|
||||||
c.token.Length = 2;
|
c.token.Length = 2;
|
||||||
c.token.Flags = TF_Null;
|
c.token.Flags = TF_Null;
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -1100,7 +1100,7 @@ TokArray lex( StrC content )
|
|||||||
}
|
}
|
||||||
else if ( current == '*' )
|
else if ( current == '*' )
|
||||||
{
|
{
|
||||||
c.token.Type = TokType::Comment;
|
c.token.Type = Tok_Comment;
|
||||||
c.token.Length = 2;
|
c.token.Length = 2;
|
||||||
c.token.Flags = TF_Null;
|
c.token.Flags = TF_Null;
|
||||||
move_forward();
|
move_forward();
|
||||||
@ -1160,7 +1160,7 @@ TokArray lex( StrC content )
|
|||||||
|
|
||||||
c.token.Text = c.scanner;
|
c.token.Text = c.scanner;
|
||||||
c.token.Length = 1;
|
c.token.Length = 1;
|
||||||
c.token.Type = TokType::Number;
|
c.token.Type = Tok_Number;
|
||||||
c.token.Flags = TF_Literal;
|
c.token.Flags = TF_Literal;
|
||||||
move_forward();
|
move_forward();
|
||||||
|
|
||||||
@ -1230,7 +1230,7 @@ TokArray lex( StrC content )
|
|||||||
{
|
{
|
||||||
log_fmt( "Token %d Type: %s : %.*s\n"
|
log_fmt( "Token %d Type: %s : %.*s\n"
|
||||||
, idx
|
, idx
|
||||||
, ETokType::to_str( Tokens[ idx ].Type ).Ptr
|
, to_str( Tokens[ idx ].Type ).Ptr
|
||||||
, Tokens[ idx ].Length, Tokens[ idx ].Text
|
, Tokens[ idx ].Length, Tokens[ idx ].Text
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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
|
||||||
|
@ -135,6 +135,7 @@
|
|||||||
# if GEN_COMPILER_C
|
# if GEN_COMPILER_C
|
||||||
# define GEN_NS_PARSER_BEGIN
|
# define GEN_NS_PARSER_BEGIN
|
||||||
# define GEN_NS_PARSER_END
|
# define GEN_NS_PARSER_END
|
||||||
|
# define GEN_USING_NS_PARSER
|
||||||
# define GEN_NS_ENUM_BEGIN
|
# define GEN_NS_ENUM_BEGIN
|
||||||
# define GEN_NS_ENUM_END
|
# define GEN_NS_ENUM_END
|
||||||
# define GEN_NS
|
# define GEN_NS
|
||||||
@ -143,6 +144,7 @@
|
|||||||
# else
|
# else
|
||||||
# define GEN_NS_PARSER_BEGIN namespace parser {
|
# define GEN_NS_PARSER_BEGIN namespace parser {
|
||||||
# define GEN_NS_PARSER_END }
|
# define GEN_NS_PARSER_END }
|
||||||
|
# define GEN_USING_NS_PARSER using namespace parser
|
||||||
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
|
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
|
||||||
# define GEN_NS_ENUM_END }
|
# define GEN_NS_ENUM_END }
|
||||||
# define GEN_NS ::
|
# define GEN_NS ::
|
||||||
@ -152,6 +154,7 @@
|
|||||||
#else
|
#else
|
||||||
# define GEN_NS_PARSER_BEGIN namespace parser {
|
# define GEN_NS_PARSER_BEGIN namespace parser {
|
||||||
# define GEN_NS_PARSER_END }
|
# define GEN_NS_PARSER_END }
|
||||||
|
# define GEN_USING_NS_PARSER using namespace parser
|
||||||
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
|
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
|
||||||
# define GEN_NS_ENUM_END }
|
# define GEN_NS_ENUM_END }
|
||||||
# define GEN_NS gen::
|
# define GEN_NS gen::
|
||||||
|
@ -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 )
|
||||||
@ -76,12 +77,12 @@ CodeBody gen_eoperator( char const* path )
|
|||||||
char const* enum_str = enum_strs[idx].string;
|
char const* enum_str = enum_strs[idx].string;
|
||||||
char const* entry_to_str = str_strs [idx].string;
|
char const* entry_to_str = str_strs [idx].string;
|
||||||
|
|
||||||
append_fmt( & enum_entries, "%s,\n", enum_str );
|
append_fmt( & enum_entries, "Op_%s,\n", enum_str );
|
||||||
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize(
|
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize(
|
||||||
enum Type : u32
|
enum Operator_Def : u32
|
||||||
{
|
{
|
||||||
<entries>
|
<entries>
|
||||||
NumOps
|
NumOps
|
||||||
@ -92,7 +93,7 @@ CodeBody gen_eoperator( char const* path )
|
|||||||
#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 op )
|
StrC to_str( Operator op )
|
||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
StrC lookup[] {
|
StrC lookup[] {
|
||||||
@ -104,11 +105,11 @@ CodeBody gen_eoperator( char const* path )
|
|||||||
)));
|
)));
|
||||||
#pragma pop_macro("local_persist")
|
#pragma pop_macro("local_persist")
|
||||||
|
|
||||||
CodeNS nspace = def_namespace( name(EOperator), def_namespace_body( args( enum_code, to_str ) ) );
|
//CodeNS nspace = def_namespace( name(EOperator), def_namespace_body( args( enum_code, to_str ) ) );
|
||||||
|
//CodeUsing operator_t = def_using( name(OperatorT), def_type( name(EOperator::Type) ) );
|
||||||
|
CodeTypedef operator_t = parse_typedef(code( typedef enum Operator_Def Operator; ));
|
||||||
|
|
||||||
CodeUsing operator_t = def_using( name(OperatorT), def_type( name(EOperator::Type) ) );
|
return def_global_body( args( operator_t, enum_code, to_str, fmt_newline ) );
|
||||||
|
|
||||||
return def_global_body( args( nspace, operator_t, fmt_newline ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeBody gen_especifier( char const* path )
|
CodeBody gen_especifier( char const* path )
|
||||||
@ -132,23 +133,23 @@ CodeBody gen_especifier( char const* path )
|
|||||||
char const* enum_str = enum_strs[idx].string;
|
char const* enum_str = enum_strs[idx].string;
|
||||||
char const* entry_to_str = str_strs [idx].string;
|
char const* entry_to_str = str_strs [idx].string;
|
||||||
|
|
||||||
append_fmt( & enum_entries, "%s,\n", enum_str );
|
append_fmt( & enum_entries, "Spec_%s,\n", enum_str );
|
||||||
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize(
|
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize(
|
||||||
enum Type : u32
|
enum Specifier_Def : u32
|
||||||
{
|
{
|
||||||
<entries>
|
<entries>
|
||||||
NumSpecifiers
|
Spec_NumSpecifiers
|
||||||
};
|
};
|
||||||
)));
|
)));
|
||||||
|
|
||||||
CodeFn is_trailing = parse_function(token_fmt("specifier", (StrC)to_str_entries, stringize(
|
CodeFn is_trailing = parse_function(token_fmt("specifier", (StrC)to_str_entries, stringize(
|
||||||
inline
|
inline
|
||||||
bool is_trailing( Type specifier )
|
bool is_trailing( Specifier specifier )
|
||||||
{
|
{
|
||||||
return specifier > Virtual;
|
return specifier > Spec_Virtual;
|
||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ CodeBody gen_especifier( char const* path )
|
|||||||
#undef neverinline
|
#undef neverinline
|
||||||
CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, stringize(
|
CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, stringize(
|
||||||
inline
|
inline
|
||||||
StrC to_str( Type type )
|
StrC to_str( Specifier type )
|
||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
StrC lookup[] {
|
StrC lookup[] {
|
||||||
@ -177,14 +178,14 @@ CodeBody gen_especifier( char const* path )
|
|||||||
|
|
||||||
CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
|
CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
|
||||||
inline
|
inline
|
||||||
Type to_type( StrC str )
|
Specifier to_specifier( StrC str )
|
||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
u32 keymap[ NumSpecifiers ];
|
u32 keymap[ Spec_NumSpecifiers ];
|
||||||
do_once_start
|
do_once_start
|
||||||
for ( u32 index = 0; index < NumSpecifiers; index++ )
|
for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
|
||||||
{
|
{
|
||||||
StrC enum_str = to_str( (Type)index );
|
StrC enum_str = to_str( (Specifier)index );
|
||||||
|
|
||||||
// We subtract 1 to remove the null terminator
|
// We subtract 1 to remove the null terminator
|
||||||
// This is because the tokens lexed are not null terminated.
|
// This is because the tokens lexed are not null terminated.
|
||||||
@ -194,13 +195,13 @@ CodeBody gen_especifier( char const* path )
|
|||||||
|
|
||||||
u32 hash = crc32( str.Ptr, str.Len );
|
u32 hash = crc32( str.Ptr, str.Len );
|
||||||
|
|
||||||
for ( u32 index = 0; index < NumSpecifiers; index++ )
|
for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
|
||||||
{
|
{
|
||||||
if ( keymap[index] == hash )
|
if ( keymap[index] == hash )
|
||||||
return (Type)index;
|
return (Specifier)index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Invalid;
|
return Spec_Invalid;
|
||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
#pragma pop_macro("local_persist")
|
#pragma pop_macro("local_persist")
|
||||||
@ -209,11 +210,11 @@ CodeBody gen_especifier( char const* path )
|
|||||||
#pragma pop_macro("forceinline")
|
#pragma pop_macro("forceinline")
|
||||||
#pragma pop_macro("neverinline")
|
#pragma pop_macro("neverinline")
|
||||||
|
|
||||||
CodeNS nspace = def_namespace( name(ESpecifier), def_namespace_body( args( enum_code, is_trailing, to_str, to_type ) ) );
|
//CodeNS nspace = def_namespace( name(ESpecifier), def_namespace_body( args( enum_code, is_trailing, to_str, to_type ) ) );
|
||||||
|
//CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) );
|
||||||
|
CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier_Def Specifier; ));
|
||||||
|
|
||||||
CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) );
|
return def_global_body( args( specifier_t, enum_code, is_trailing, to_str, to_type, fmt_newline ) );
|
||||||
|
|
||||||
return def_global_body( args( nspace, specifier_t, fmt_newline ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
||||||
@ -249,7 +250,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
|||||||
char const* enum_str = enum_strs[idx].string;
|
char const* enum_str = enum_strs[idx].string;
|
||||||
char const* entry_to_str = enum_str_strs [idx].string;
|
char const* entry_to_str = enum_str_strs [idx].string;
|
||||||
|
|
||||||
append_fmt( & enum_entries, "%s,\n", enum_str );
|
append_fmt( & enum_entries, "Tok_%s,\n", enum_str );
|
||||||
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,9 +259,9 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
|||||||
char const* attribute_str = attribute_strs[idx].string;
|
char const* attribute_str = attribute_strs[idx].string;
|
||||||
char const* entry_to_str = attribute_str_strs [idx].string;
|
char const* entry_to_str = attribute_str_strs [idx].string;
|
||||||
|
|
||||||
append_fmt( & attribute_entries, "Attribute_%s,\n", attribute_str );
|
append_fmt( & attribute_entries, "Tok_Attribute_%s,\n", attribute_str );
|
||||||
append_fmt( & to_str_attributes, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
append_fmt( & to_str_attributes, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||||
append_fmt( & attribute_define_entries, "Entry( Attribute_%s, \"%s\" )", attribute_str, entry_to_str );
|
append_fmt( & attribute_define_entries, "Entry( Tok_Attribute_%s, \"%s\" )", attribute_str, entry_to_str );
|
||||||
|
|
||||||
if ( idx < num(attribute_strs) - 1 )
|
if ( idx < num(attribute_strs) - 1 )
|
||||||
append( & attribute_define_entries, " \\\n");
|
append( & attribute_define_entries, " \\\n");
|
||||||
@ -275,11 +276,11 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
|||||||
|
|
||||||
// We cannot parse this enum, it has Attribute names as enums
|
// We cannot parse this enum, it has Attribute names as enums
|
||||||
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, "attribute_toks", (StrC)attribute_entries, stringize(
|
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, "attribute_toks", (StrC)attribute_entries, stringize(
|
||||||
enum Type : u32
|
enum TokType_Def : u32
|
||||||
{
|
{
|
||||||
<entries>
|
<entries>
|
||||||
<attribute_toks>
|
<attribute_toks>
|
||||||
NumTokens
|
Tok_NumTokens
|
||||||
};
|
};
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -291,7 +292,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
|||||||
#undef do_once_end
|
#undef do_once_end
|
||||||
CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, "attribute_toks", (StrC)to_str_attributes, stringize(
|
CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, "attribute_toks", (StrC)to_str_attributes, stringize(
|
||||||
inline
|
inline
|
||||||
StrC to_str( Type type )
|
StrC to_str( TokType type )
|
||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
StrC lookup[] {
|
StrC lookup[] {
|
||||||
@ -305,14 +306,14 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
|||||||
|
|
||||||
CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
|
CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
|
||||||
inline
|
inline
|
||||||
Type to_type( StrC str )
|
TokType to_toktype( StrC str )
|
||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
u32 keymap[ NumTokens ];
|
u32 keymap[ Tok_NumTokens ];
|
||||||
do_once_start
|
do_once_start
|
||||||
for ( u32 index = 0; index < NumTokens; index++ )
|
for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||||
{
|
{
|
||||||
StrC enum_str = to_str( (Type)index );
|
StrC enum_str = to_str( (TokType)index );
|
||||||
|
|
||||||
// We subtract 1 to remove the null terminator
|
// We subtract 1 to remove the null terminator
|
||||||
// This is because the tokens lexed are not null terminated.
|
// This is because the tokens lexed are not null terminated.
|
||||||
@ -322,23 +323,29 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
|
|||||||
|
|
||||||
u32 hash = crc32( str.Ptr, str.Len );
|
u32 hash = crc32( str.Ptr, str.Len );
|
||||||
|
|
||||||
for ( u32 index = 0; index < NumTokens; index++ )
|
for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||||
{
|
{
|
||||||
if ( keymap[index] == hash )
|
if ( keymap[index] == hash )
|
||||||
return (Type)index;
|
return (TokType)index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Invalid;
|
return Tok_Invalid;
|
||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
#pragma pop_macro("local_persist")
|
#pragma pop_macro("local_persist")
|
||||||
#pragma pop_macro("do_once_start")
|
#pragma pop_macro("do_once_start")
|
||||||
#pragma pop_macro("do_once_end")
|
#pragma pop_macro("do_once_end")
|
||||||
|
|
||||||
CodeNS nspace = def_namespace( name(ETokType), def_namespace_body( args( attribute_entires_def, enum_code, to_str, to_type ) ) );
|
//CodeNS nspace = def_namespace( name(ETokType), def_namespace_body( args( attribute_entires_def, enum_code, to_str, to_type ) ) );
|
||||||
CodeUsing td_toktype = def_using( name(TokType), def_type( name(ETokType::Type) ) );
|
CodeTypedef td_toktype = parse_typedef( code( typedef enum TokType_Def TokType; ));
|
||||||
|
|
||||||
return def_global_body( args( nspace, td_toktype ) );
|
return def_global_body( args(
|
||||||
|
attribute_entires_def,
|
||||||
|
td_toktype,
|
||||||
|
enum_code,
|
||||||
|
to_str,
|
||||||
|
to_type
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeBody gen_ast_inlines()
|
CodeBody gen_ast_inlines()
|
||||||
@ -417,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 ));
|
||||||
@ -441,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 )));
|
||||||
@ -477,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 ));
|
||||||
|
Loading…
Reference in New Issue
Block a user