mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 03:01:47 -07:00
Significant progress reducing c++ feature usage in the library.
This commit is contained in:
@ -7,20 +7,21 @@ Code Code::Global;
|
||||
Code Code::Invalid;
|
||||
|
||||
// This serializes all the data-members in a "debug" format, where each member is printed with its associated value.
|
||||
char const* AST::debug_str()
|
||||
char const* debug_str(AST* self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
String result = string_make_reserve( GlobalAllocator, kilobytes(1) );
|
||||
|
||||
if ( Parent )
|
||||
append_fmt( result, "\n\tParent : %S %S", Parent->type_str(), Name ? Name : "" );
|
||||
if ( self->Parent )
|
||||
append_fmt( result, "\n\tParent : %S %S", self->Parent->type_str(), self->Name ? self->Name : "" );
|
||||
else
|
||||
append_fmt( result, "\n\tParent : %S", "Null" );
|
||||
|
||||
append_fmt( result, "\n\tName : %S", Name ? Name : "Null" );
|
||||
append_fmt( result, "\n\tType : %S", type_str() );
|
||||
append_fmt( result, "\n\tModule Flags : %S", to_str( ModuleFlags ) );
|
||||
append_fmt( result, "\n\tName : %S", self->Name ? self->Name : "Null" );
|
||||
append_fmt( result, "\n\tType : %S", type_str(self) );
|
||||
append_fmt( result, "\n\tModule Flags : %S", to_str( self->ModuleFlags ) );
|
||||
|
||||
switch ( Type )
|
||||
switch ( self->Type )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
@ -29,10 +30,10 @@ char const* AST::debug_str()
|
||||
case Access_Private:
|
||||
case Access_Protected:
|
||||
case Access_Public:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
break;
|
||||
|
||||
case Untyped:
|
||||
@ -47,75 +48,75 @@ char const* AST::debug_str()
|
||||
case Preprocess_Else:
|
||||
case Preprocess_IfDef:
|
||||
case Preprocess_IfNotDef:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tContent: %S", Content );
|
||||
append_fmt( result, "\n\tContent: %S", self->Content );
|
||||
break;
|
||||
|
||||
case Class:
|
||||
case Struct:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmd : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParentAccess: %s", ParentType ? to_str( ParentAccess ) : "No Parent" );
|
||||
append_fmt( result, "\n\tParentType : %s", ParentType ? ParentType->type_str() : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", self->Attributes ? to_string(self->Attributes) : "Null" );
|
||||
append_fmt( result, "\n\tParentAccess: %s", self->ParentType ? to_str( self->ParentAccess ) : "No Parent" );
|
||||
append_fmt( result, "\n\tParentType : %s", self->ParentType ? type_str(self->ParentType) : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
break;
|
||||
|
||||
case Class_Fwd:
|
||||
case Struct_Fwd:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmd : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParentAccess: %s", ParentType ? to_str( ParentAccess ) : "No Parent" );
|
||||
append_fmt( result, "\n\tParentType : %s", ParentType ? ParentType->type_str() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", self->Attributes ? to_string(self->Attributes) : "Null" );
|
||||
append_fmt( result, "\n\tParentAccess: %s", self->ParentType ? to_str( self->ParentAccess ) : "No Parent" );
|
||||
append_fmt( result, "\n\tParentType : %s", self->ParentType ? type_str(self->ParentType) : "Null" );
|
||||
break;
|
||||
|
||||
case Constructor:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInitializerList: %S", InitializerList ? InitializerList->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" );
|
||||
append_fmt( result, "\n\tInitializerList: %S", self->InitializerList ? to_string(self->InitializerList) : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
break;
|
||||
|
||||
case Constructor_Fwd:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInitializerList: %S", InitializerList ? InitializerList->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" );
|
||||
append_fmt( result, "\n\tInitializerList: %S", self->InitializerList ? to_string(self->InitializerList) : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
|
||||
break;
|
||||
|
||||
case Destructor:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
break;
|
||||
|
||||
case Destructor_Fwd:
|
||||
@ -123,248 +124,248 @@ char const* AST::debug_str()
|
||||
|
||||
case Enum:
|
||||
case Enum_Class:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tUnderlying Type : %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", self->Attributes ? to_string(self->Attributes) : "Null" );
|
||||
append_fmt( result, "\n\tUnderlying Type : %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
break;
|
||||
|
||||
case Enum_Fwd:
|
||||
case Enum_Class_Fwd:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tUnderlying Type : %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", self->Attributes ? to_string(self->Attributes) : "Null" );
|
||||
append_fmt( result, "\n\tUnderlying Type : %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" );
|
||||
break;
|
||||
|
||||
case Extern_Linkage:
|
||||
case Namespace:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tBody: %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tBody: %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
break;
|
||||
|
||||
case Friend:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tDeclaration: %S", Declaration ? Declaration->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? to_string(self->Declaration) : "Null" );
|
||||
break;
|
||||
|
||||
case Function:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "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\tReturnType: %S", self->ReturnType ? to_string(self->ReturnType) : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
break;
|
||||
|
||||
case Function_Fwd:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "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\tReturnType: %S", self->ReturnType ? to_string(self->ReturnType) : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
|
||||
break;
|
||||
|
||||
case Module:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
break;
|
||||
|
||||
case Operator:
|
||||
case Operator_Member:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tOp : %S", to_str( Op ) );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "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\tReturnType: %S", self->ReturnType ? to_string(self->ReturnType) : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
append_fmt( result, "\n\tOp : %S", to_str( self->Op ) );
|
||||
break;
|
||||
|
||||
case Operator_Fwd:
|
||||
case Operator_Member_Fwd:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tOp : %S", to_str( Op ) );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "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\tReturnType: %S", self->ReturnType ? to_string(self->ReturnType) : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
|
||||
append_fmt( result, "\n\tOp : %S", to_str( self->Op ) );
|
||||
break;
|
||||
|
||||
case Operator_Cast:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" );
|
||||
append_fmt( result, "\n\tValueType : %S", self->ValueType ? to_string(self->ValueType) : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
break;
|
||||
|
||||
case Operator_Cast_Fwd:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" );
|
||||
append_fmt( result, "\n\tValueType : %S", self->ValueType ? to_string(self->ValueType) : "Null" );
|
||||
break;
|
||||
|
||||
case Parameters:
|
||||
append_fmt( result, "\n\tNumEntries: %d", NumEntries );
|
||||
append_fmt( result, "\n\tLast : %S", Last->Name );
|
||||
append_fmt( result, "\n\tNext : %S", Next->Name );
|
||||
append_fmt( result, "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tValue : %S", Value ? Value->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
||||
append_fmt( result, "\n\tLast : %S", self->Last->Name );
|
||||
append_fmt( result, "\n\tNext : %S", self->Next->Name );
|
||||
append_fmt( result, "\n\tValueType : %S", self->ValueType ? to_string(self->ValueType) : "Null" );
|
||||
append_fmt( result, "\n\tValue : %S", self->Value ? to_string(self->Value) : "Null" );
|
||||
break;
|
||||
|
||||
case Specifiers:
|
||||
{
|
||||
append_fmt( result, "\n\tNumEntries: %d", NumEntries );
|
||||
append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
||||
GEN_NS append( result, "\n\tArrSpecs: " );
|
||||
|
||||
s32 idx = 0;
|
||||
s32 left = NumEntries;
|
||||
s32 left = self->NumEntries;
|
||||
while ( left-- )
|
||||
{
|
||||
StrC spec = ESpecifier::to_str( ArrSpecs[idx] );
|
||||
StrC spec = ESpecifier::to_str( self->ArrSpecs[idx] );
|
||||
append_fmt( result, "%.*s, ", spec.Len, spec.Ptr );
|
||||
idx++;
|
||||
}
|
||||
append_fmt( result, "\n\tNextSpecs: %S", NextSpecs ? NextSpecs->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tNextSpecs: %S", self->NextSpecs ? debug_str(self->NextSpecs) : "Null" );
|
||||
}
|
||||
break;
|
||||
|
||||
case Template:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tDeclaration: %S", Declaration ? Declaration->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
|
||||
append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? to_string(self->Declaration) : "Null" );
|
||||
break;
|
||||
|
||||
case Typedef:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tUnderlyingType: %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" );
|
||||
break;
|
||||
|
||||
case Typename:
|
||||
append_fmt( result, "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tReturnType : %S", ReturnType ? ReturnType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tArrExpr : %S", ArrExpr ? ArrExpr->to_string() : "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\tReturnType : %S", self->ReturnType ? to_string(self->ReturnType) : "Null" );
|
||||
append_fmt( result, "\n\tParams : %S", self->Params ? to_string(self->Params) : "Null" );
|
||||
append_fmt( result, "\n\tArrExpr : %S", self->ArrExpr ? to_string(self->ArrExpr) : "Null" );
|
||||
break;
|
||||
|
||||
case Union:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tAttributes: %S", self->Attributes ? to_string(self->Attributes) : "Null" );
|
||||
append_fmt( result, "\n\tBody : %S", self->Body ? debug_str(self->Body) : "Null" );
|
||||
break;
|
||||
|
||||
case Using:
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tUnderlyingType: %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", self->Attributes ? to_string(self->Attributes) : "Null" );
|
||||
append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? to_string(self->UnderlyingType) : "Null" );
|
||||
break;
|
||||
|
||||
case Variable:
|
||||
|
||||
if ( Parent && Parent->Type == Variable )
|
||||
if ( self->Parent && self->Parent->Type == Variable )
|
||||
{
|
||||
// Its a NextVar
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tValue : %S", Value ? Value->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBitfieldSize: %S", BitfieldSize ? BitfieldSize->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tNextVar : %S", NextVar ? NextVar->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", self->Specs ? to_string(self->Specs) : "Null" );
|
||||
append_fmt( result, "\n\tValue : %S", self->Value ? to_string(self->Value) : "Null" );
|
||||
append_fmt( result, "\n\tBitfieldSize: %S", self->BitfieldSize ? to_string(self->BitfieldSize) : "Null" );
|
||||
append_fmt( result, "\n\tNextVar : %S", self->NextVar ? debug_str(self->NextVar) : "Null" );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
||||
if ( self->Prev )
|
||||
append_fmt( result, "\n\tPrev: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
if ( self->Next )
|
||||
append_fmt( result, "\n\tNext: %S %S", type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
||||
|
||||
append_fmt( result, "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
||||
append_fmt( result, "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tBitfieldSize: %S", BitfieldSize ? BitfieldSize->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tValue : %S", Value ? Value->to_string() : "Null" );
|
||||
append_fmt( result, "\n\tNextVar : %S", NextVar ? NextVar->debug_str() : "Null" );
|
||||
append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "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\tValueType : %S", self->ValueType ? to_string(self->ValueType) : "Null" );
|
||||
append_fmt( result, "\n\tBitfieldSize: %S", self->BitfieldSize ? to_string(self->BitfieldSize) : "Null" );
|
||||
append_fmt( result, "\n\tValue : %S", self->Value ? to_string(self->Value) : "Null" );
|
||||
append_fmt( result, "\n\tNextVar : %S", self->NextVar ? debug_str(self->NextVar) : "Null" );
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
AST* AST::duplicate()
|
||||
AST* duplicate(AST* self)
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
AST* result = make_code().ast;
|
||||
|
||||
mem_copy( result, this, sizeof( AST ) );
|
||||
mem_copy( result, self, sizeof( AST ) );
|
||||
|
||||
result->Parent = nullptr;
|
||||
return result;
|
||||
@ -412,169 +413,169 @@ void AST::to_string( String& result )
|
||||
break;
|
||||
|
||||
case Class:
|
||||
cast<CodeClass>().to_string_def( result );
|
||||
code_cast<CodeClass>().to_string_def( result );
|
||||
break;
|
||||
|
||||
case Class_Fwd:
|
||||
cast<CodeClass>().to_string_fwd( result );
|
||||
code_cast<CodeClass>().to_string_fwd( result );
|
||||
break;
|
||||
|
||||
case Constructor:
|
||||
cast<CodeConstructor>().to_string_def( result );
|
||||
code_cast<CodeConstructor>().to_string_def( result );
|
||||
break;
|
||||
|
||||
case Constructor_Fwd:
|
||||
cast<CodeConstructor>().to_string_fwd( result );
|
||||
code_cast<CodeConstructor>().to_string_fwd( result );
|
||||
break;
|
||||
|
||||
case Destructor:
|
||||
cast<CodeDestructor>().to_string_def( result );
|
||||
code_cast<CodeDestructor>().to_string_def( result );
|
||||
break;
|
||||
|
||||
case Destructor_Fwd:
|
||||
cast<CodeDestructor>().to_string_fwd( result );
|
||||
code_cast<CodeDestructor>().to_string_fwd( result );
|
||||
break;
|
||||
|
||||
case Enum:
|
||||
cast<CodeEnum>().to_string_def( result );
|
||||
code_cast<CodeEnum>().to_string_def( result );
|
||||
break;
|
||||
|
||||
case Enum_Fwd:
|
||||
cast<CodeEnum>().to_string_fwd( result );
|
||||
code_cast<CodeEnum>().to_string_fwd( result );
|
||||
break;
|
||||
|
||||
case Enum_Class:
|
||||
cast<CodeEnum>().to_string_class_def( result );
|
||||
code_cast<CodeEnum>().to_string_class_def( result );
|
||||
break;
|
||||
|
||||
case Enum_Class_Fwd:
|
||||
cast<CodeEnum>().to_string_class_fwd( result );
|
||||
code_cast<CodeEnum>().to_string_class_fwd( result );
|
||||
break;
|
||||
|
||||
case Export_Body:
|
||||
cast<CodeBody>().to_string_export( result );
|
||||
code_cast<CodeBody>().to_string_export( result );
|
||||
break;
|
||||
|
||||
case Extern_Linkage:
|
||||
cast<CodeExtern>().to_string( result );
|
||||
code_cast<CodeExtern>().to_string( result );
|
||||
break;
|
||||
|
||||
case Friend:
|
||||
cast<CodeFriend>().to_string( result );
|
||||
code_cast<CodeFriend>().to_string( result );
|
||||
break;
|
||||
|
||||
case Function:
|
||||
cast<CodeFn>().to_string_def( result );
|
||||
code_cast<CodeFn>().to_string_def( result );
|
||||
break;
|
||||
|
||||
case Function_Fwd:
|
||||
cast<CodeFn>().to_string_fwd( result );
|
||||
code_cast<CodeFn>().to_string_fwd( result );
|
||||
break;
|
||||
|
||||
case Module:
|
||||
cast<CodeModule>().to_string( result );
|
||||
code_cast<CodeModule>().to_string( result );
|
||||
break;
|
||||
|
||||
case Namespace:
|
||||
cast<CodeNS>().to_string( result );
|
||||
code_cast<CodeNS>().to_string( result );
|
||||
break;
|
||||
|
||||
case Operator:
|
||||
case Operator_Member:
|
||||
cast<CodeOperator>().to_string_def( result );
|
||||
code_cast<CodeOperator>().to_string_def( result );
|
||||
break;
|
||||
|
||||
case Operator_Fwd:
|
||||
case Operator_Member_Fwd:
|
||||
cast<CodeOperator>().to_string_fwd( result );
|
||||
code_cast<CodeOperator>().to_string_fwd( result );
|
||||
break;
|
||||
|
||||
case Operator_Cast:
|
||||
cast<CodeOpCast>().to_string_def( result );
|
||||
code_cast<CodeOpCast>().to_string_def( result );
|
||||
break;
|
||||
|
||||
case Operator_Cast_Fwd:
|
||||
cast<CodeOpCast>().to_string_fwd( result );
|
||||
code_cast<CodeOpCast>().to_string_fwd( result );
|
||||
break;
|
||||
|
||||
case Parameters:
|
||||
cast<CodeParam>().to_string( result );
|
||||
code_cast<CodeParam>().to_string( result );
|
||||
break;
|
||||
|
||||
case Preprocess_Define:
|
||||
cast<CodeDefine>().to_string( result );
|
||||
code_cast<CodeDefine>().to_string( result );
|
||||
break;
|
||||
|
||||
case Preprocess_If:
|
||||
cast<CodePreprocessCond>().to_string_if( result );
|
||||
code_cast<CodePreprocessCond>().to_string_if( result );
|
||||
break;
|
||||
|
||||
case Preprocess_IfDef:
|
||||
cast<CodePreprocessCond>().to_string_ifdef( result );
|
||||
code_cast<CodePreprocessCond>().to_string_ifdef( result );
|
||||
break;
|
||||
|
||||
case Preprocess_IfNotDef:
|
||||
cast<CodePreprocessCond>().to_string_ifndef( result );
|
||||
code_cast<CodePreprocessCond>().to_string_ifndef( result );
|
||||
break;
|
||||
|
||||
case Preprocess_Include:
|
||||
cast<CodeInclude>().to_string( result );
|
||||
code_cast<CodeInclude>().to_string( result );
|
||||
break;
|
||||
|
||||
case Preprocess_ElIf:
|
||||
cast<CodePreprocessCond>().to_string_elif( result );
|
||||
code_cast<CodePreprocessCond>().to_string_elif( result );
|
||||
break;
|
||||
|
||||
case Preprocess_Else:
|
||||
cast<CodePreprocessCond>().to_string_else( result );
|
||||
code_cast<CodePreprocessCond>().to_string_else( result );
|
||||
break;
|
||||
|
||||
case Preprocess_EndIf:
|
||||
cast<CodePreprocessCond>().to_string_endif( result );
|
||||
code_cast<CodePreprocessCond>().to_string_endif( result );
|
||||
break;
|
||||
|
||||
case Preprocess_Pragma:
|
||||
cast<CodePragma>().to_string( result );
|
||||
code_cast<CodePragma>().to_string( result );
|
||||
break;
|
||||
|
||||
case Specifiers:
|
||||
cast<CodeSpecifiers>().to_string( result );
|
||||
code_cast<CodeSpecifiers>().to_string( result );
|
||||
break;
|
||||
|
||||
case Struct:
|
||||
cast<CodeStruct>().to_string_def( result );
|
||||
code_cast<CodeStruct>().to_string_def( result );
|
||||
break;
|
||||
|
||||
case Struct_Fwd:
|
||||
cast<CodeStruct>().to_string_fwd( result );
|
||||
code_cast<CodeStruct>().to_string_fwd( result );
|
||||
break;
|
||||
|
||||
case Template:
|
||||
cast<CodeTemplate>().to_string( result );
|
||||
code_cast<CodeTemplate>().to_string( result );
|
||||
break;
|
||||
|
||||
case Typedef:
|
||||
cast<CodeTypedef>().to_string( result );
|
||||
code_cast<CodeTypedef>().to_string( result );
|
||||
break;
|
||||
|
||||
case Typename:
|
||||
cast<CodeType>().to_string( result );
|
||||
code_cast<CodeType>().to_string( result );
|
||||
break;
|
||||
|
||||
case Union:
|
||||
cast<CodeUnion>().to_string( result );
|
||||
code_cast<CodeUnion>().to_string( result );
|
||||
break;
|
||||
|
||||
case Using:
|
||||
cast<CodeUsing>().to_string( result );
|
||||
code_cast<CodeUsing>().to_string( result );
|
||||
break;
|
||||
|
||||
case Using_Namespace:
|
||||
cast<CodeUsing>().to_string_ns( result );
|
||||
code_cast<CodeUsing>().to_string_ns( result );
|
||||
break;
|
||||
|
||||
case Variable:
|
||||
cast<CodeVar>().to_string( result );
|
||||
code_cast<CodeVar>().to_string( result );
|
||||
break;
|
||||
|
||||
case Enum_Body:
|
||||
@ -585,7 +586,7 @@ void AST::to_string( String& result )
|
||||
case Namespace_Body:
|
||||
case Struct_Body:
|
||||
case Union_Body:
|
||||
cast<CodeBody>().to_string( result );
|
||||
code_cast<CodeBody>().to_string( result );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1157,7 +1158,7 @@ bool AST::validate_body()
|
||||
#define CheckEntries( Unallowed_Types ) \
|
||||
do \
|
||||
{ \
|
||||
for ( Code entry : cast<CodeBody>() ) \
|
||||
for ( Code entry : code_cast<CodeBody>() ) \
|
||||
{ \
|
||||
switch ( entry->Type ) \
|
||||
{ \
|
||||
@ -1175,7 +1176,7 @@ bool AST::validate_body()
|
||||
CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES );
|
||||
break;
|
||||
case Enum_Body:
|
||||
for ( Code entry : cast<CodeBody>() )
|
||||
for ( Code entry : code_cast<CodeBody>() )
|
||||
{
|
||||
if ( entry->Type != Untyped )
|
||||
{
|
||||
@ -1194,7 +1195,7 @@ bool AST::validate_body()
|
||||
CheckEntries( GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES );
|
||||
break;
|
||||
case Global_Body:
|
||||
for (Code entry : cast<CodeBody>())
|
||||
for (Code entry : code_cast<CodeBody>())
|
||||
{
|
||||
switch (entry->Type)
|
||||
{
|
||||
@ -1227,7 +1228,7 @@ bool AST::validate_body()
|
||||
CheckEntries( GEN_AST_BODY_STRUCT_UNALLOWED_TYPES );
|
||||
break;
|
||||
case Union_Body:
|
||||
for ( Code entry : Body->cast<CodeBody>() )
|
||||
for ( Code entry : Body->code_cast<CodeBody>() )
|
||||
{
|
||||
if ( entry->Type != Untyped )
|
||||
{
|
||||
|
@ -146,6 +146,11 @@ namespace parser
|
||||
struct Token;
|
||||
}
|
||||
|
||||
template< class Type> forceinline Type tmpl_cast( Code* self ) { return * rcast( Type*, self ); }
|
||||
#if ! GEN_COMPILER_C && 0
|
||||
template< class Type> forceinline Type tmpl_cast( Code& self ) { return * rcast( Type*, & self ); }
|
||||
#endif
|
||||
|
||||
/*
|
||||
AST* wrapper
|
||||
- Not constantly have to append the '*' as this is written often..
|
||||
@ -178,7 +183,7 @@ struct Code
|
||||
Using_Code( Code );
|
||||
|
||||
template< class Type >
|
||||
forceinline Type cast()
|
||||
forceinline Type code_cast()
|
||||
{
|
||||
return * rcast( Type*, this );
|
||||
}
|
||||
@ -248,33 +253,53 @@ static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" );
|
||||
// Desired width of the AST data structure.
|
||||
constexpr int const AST_POD_Size = 128;
|
||||
|
||||
void append ( AST* self, AST* other );
|
||||
char const* debug_str ( AST* self );
|
||||
AST* duplicate ( AST* self );
|
||||
Code* entry ( AST* self, u32 idx );
|
||||
bool has_entries( AST* self );
|
||||
bool is_body ( AST* self );
|
||||
String to_string ( AST* self );
|
||||
char const* type_str ( AST* self );
|
||||
|
||||
#if GEN_CPP_SUPPORT_REFERENCES
|
||||
void append ( AST& self, AST& other ) { return append(& self, & other); }
|
||||
bool is_body ( AST& self ) { return is_body(& self); }
|
||||
char const* debug_str( AST& self ) { return debug_str( & self ); }
|
||||
String to_string( AST& self ) { return to_string( & self ); }
|
||||
char const* type_str ( AST& self ) { return type_str( & self ); }
|
||||
#endif
|
||||
|
||||
/*
|
||||
Simple AST POD with functionality to seralize into C++ syntax.
|
||||
*/
|
||||
struct AST
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
# pragma region Member Functions
|
||||
void append ( AST* other );
|
||||
char const* debug_str ();
|
||||
AST* duplicate ();
|
||||
Code& entry ( u32 idx );
|
||||
void append ( AST* other ) { GEN_NS append(this, other); }
|
||||
char const* debug_str () { return GEN_NS debug_str(this); }
|
||||
AST* duplicate () { return GEN_NS duplicate(this); }
|
||||
Code* entry ( u32 idx ) { return GEN_NS entry(this, idx); }
|
||||
bool has_entries();
|
||||
bool is_equal ( AST* other );
|
||||
bool is_body();
|
||||
char const* type_str();
|
||||
bool is_body() { return GEN_NS is_body(this); }
|
||||
char const* type_str() { return GEN_NS type_str(this); }
|
||||
bool validate_body();
|
||||
|
||||
String to_string();
|
||||
|
||||
neverinline
|
||||
void to_string( String& result );
|
||||
String to_string(); //{ return GEN_NS to_string(this); }
|
||||
|
||||
template< class Type >
|
||||
forceinline Type cast()
|
||||
forceinline Type code_cast()
|
||||
{
|
||||
return * this;
|
||||
}
|
||||
|
||||
neverinline
|
||||
void to_string( String& result );
|
||||
# pragma endregion Member Functions
|
||||
#endif
|
||||
|
||||
operator Code();
|
||||
operator CodeBody();
|
||||
operator CodeAttributes();
|
||||
@ -305,7 +330,6 @@ struct AST
|
||||
operator CodeUnion();
|
||||
operator CodeUsing();
|
||||
operator CodeVar();
|
||||
# pragma endregion Member Functions
|
||||
|
||||
constexpr static
|
||||
int ArrSpecs_Cap =
|
||||
@ -446,12 +470,9 @@ struct AST_POD
|
||||
};
|
||||
};
|
||||
|
||||
struct test {
|
||||
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
|
||||
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
||||
};
|
||||
|
||||
constexpr int pls = sizeof(test);
|
||||
// TODO(Ed): Convert
|
||||
String to_string ( AST* self ) { return self->to_string(); }
|
||||
|
||||
// Its intended for the AST to have equivalent size to its POD.
|
||||
// All extra functionality within the AST namespace should just be syntatic sugar.
|
||||
|
@ -176,14 +176,14 @@ void CodeClass::to_string_def( String& result )
|
||||
|
||||
append_fmt( result, "%S : %s %S", ast->Name, access_level, ast->ParentType.to_string() );
|
||||
|
||||
CodeType interface = ast->ParentType->Next->cast< CodeType >();
|
||||
CodeType interface = ast->ParentType->Next->code_cast< CodeType >();
|
||||
if ( interface )
|
||||
append( result, "\n" );
|
||||
|
||||
while ( interface )
|
||||
{
|
||||
append_fmt( result, ", %S", interface.to_string() );
|
||||
interface = interface->Next ? interface->Next->cast< CodeType >() : CodeType { nullptr };
|
||||
interface = interface->Next ? interface->Next->code_cast< CodeType >() : CodeType { nullptr };
|
||||
}
|
||||
}
|
||||
else if ( ast->Name )
|
||||
@ -353,7 +353,10 @@ void CodeEnum::to_string_fwd( String& result )
|
||||
if ( ast->Attributes )
|
||||
append_fmt( result, "%S ", ast->Attributes.to_string() );
|
||||
|
||||
append_fmt( result, "enum %S : %S", ast->Name, ast->UnderlyingType.to_string() );
|
||||
if ( ast->UnderlyingType )
|
||||
append_fmt( result, "enum %S : %S", ast->Name, ast->UnderlyingType.to_string() );
|
||||
else
|
||||
append_fmt( result, "enum %S", ast->Name );
|
||||
|
||||
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
|
||||
{
|
||||
@ -1007,14 +1010,14 @@ void CodeStruct::to_string_def( String& result )
|
||||
|
||||
append_fmt( result, "%S : %s %S", ast->Name, access_level, ast->ParentType.to_string() );
|
||||
|
||||
CodeType interface = ast->ParentType->Next->cast< CodeType >();
|
||||
CodeType interface = ast->ParentType->Next->code_cast< CodeType >();
|
||||
if ( interface )
|
||||
append( result, "\n" );
|
||||
|
||||
while ( interface )
|
||||
{
|
||||
append_fmt( result, ", %S", interface.to_string() );
|
||||
interface = interface->Next ? interface->Next->cast< CodeType >() : CodeType { nullptr };
|
||||
interface = interface->Next ? interface->Next->code_cast< CodeType >() : CodeType { nullptr };
|
||||
}
|
||||
}
|
||||
else if ( ast->Name )
|
||||
|
@ -11,37 +11,30 @@ struct CodeBody
|
||||
|
||||
void append( Code other )
|
||||
{
|
||||
if (other.is_body())
|
||||
{
|
||||
append( other.cast<CodeBody>() );
|
||||
GEN_ASSERT(other.ast != nullptr);
|
||||
|
||||
if (other.is_body()) {
|
||||
append( cast(CodeBody, & other) );
|
||||
}
|
||||
raw()->append( other.ast );
|
||||
|
||||
GEN_NS append( raw(), other.ast );
|
||||
}
|
||||
void append( CodeBody body )
|
||||
{
|
||||
for ( Code entry : body )
|
||||
{
|
||||
for ( Code entry : body ) {
|
||||
append( entry );
|
||||
}
|
||||
}
|
||||
bool has_entries()
|
||||
{
|
||||
return rcast( AST*, ast )->has_entries();
|
||||
}
|
||||
bool has_entries() { return GEN_NS has_entries(rcast( AST*, ast )); }
|
||||
AST* raw() { return rcast( AST*, ast ); }
|
||||
|
||||
void to_string( String& result );
|
||||
void to_string_export( String& result );
|
||||
AST* raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
AST_Body* operator->()
|
||||
{
|
||||
return ast;
|
||||
}
|
||||
operator Code()
|
||||
{
|
||||
return * rcast( Code*, this );
|
||||
}
|
||||
|
||||
AST_Body* operator->() { return ast; }
|
||||
|
||||
operator Code() { return * rcast( Code*, this ); }
|
||||
|
||||
#pragma region Iterator
|
||||
Code begin()
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ inline char const* Code::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code Code::duplicate()
|
||||
@ -87,7 +87,7 @@ inline char const* CodeBody::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeBody::duplicate()
|
||||
@ -163,7 +163,7 @@ inline char const* CodeAttributes::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeAttributes::duplicate()
|
||||
@ -259,7 +259,7 @@ inline char const* CodeComment::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeComment::duplicate()
|
||||
@ -355,7 +355,7 @@ inline char const* CodeConstructor::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeConstructor::duplicate()
|
||||
@ -451,7 +451,7 @@ inline char const* CodeClass::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeClass::duplicate()
|
||||
@ -527,7 +527,7 @@ inline char const* CodeDefine::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeDefine::duplicate()
|
||||
@ -623,7 +623,7 @@ inline char const* CodeDestructor::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeDestructor::duplicate()
|
||||
@ -719,7 +719,7 @@ inline char const* CodeEnum::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeEnum::duplicate()
|
||||
@ -815,7 +815,7 @@ inline char const* CodeExec::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeExec::duplicate()
|
||||
@ -911,7 +911,7 @@ inline char const* CodeExtern::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeExtern::duplicate()
|
||||
@ -1007,7 +1007,7 @@ inline char const* CodeFriend::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeFriend::duplicate()
|
||||
@ -1103,7 +1103,7 @@ inline char const* CodeFn::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeFn::duplicate()
|
||||
@ -1199,7 +1199,7 @@ inline char const* CodeInclude::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeInclude::duplicate()
|
||||
@ -1295,7 +1295,7 @@ inline char const* CodeModule::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeModule::duplicate()
|
||||
@ -1391,7 +1391,7 @@ inline char const* CodeNS::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeNS::duplicate()
|
||||
@ -1487,7 +1487,7 @@ inline char const* CodeOperator::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeOperator::duplicate()
|
||||
@ -1583,7 +1583,7 @@ inline char const* CodeOpCast::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeOpCast::duplicate()
|
||||
@ -1679,7 +1679,7 @@ inline char const* CodeParam::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeParam::duplicate()
|
||||
@ -1755,7 +1755,7 @@ inline char const* CodePragma::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodePragma::duplicate()
|
||||
@ -1851,7 +1851,7 @@ inline char const* CodePreprocessCond::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodePreprocessCond::duplicate()
|
||||
@ -1947,7 +1947,7 @@ inline char const* CodeSpecifiers::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeSpecifiers::duplicate()
|
||||
@ -2023,7 +2023,7 @@ inline char const* CodeStruct::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeStruct::duplicate()
|
||||
@ -2099,7 +2099,7 @@ inline char const* CodeTemplate::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeTemplate::duplicate()
|
||||
@ -2195,7 +2195,7 @@ inline char const* CodeType::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeType::duplicate()
|
||||
@ -2291,7 +2291,7 @@ inline char const* CodeTypedef::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeTypedef::duplicate()
|
||||
@ -2387,7 +2387,7 @@ inline char const* CodeUnion::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeUnion::duplicate()
|
||||
@ -2483,7 +2483,7 @@ inline char const* CodeUsing::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeUsing::duplicate()
|
||||
@ -2579,7 +2579,7 @@ inline char const* CodeVar::debug_str()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
return rcast( AST*, ast )->debug_str();
|
||||
return GEN_NS debug_str( rcast( AST*, ast ) );
|
||||
}
|
||||
|
||||
inline Code CodeVar::duplicate()
|
||||
|
@ -4,56 +4,62 @@
|
||||
#endif
|
||||
|
||||
inline
|
||||
void AST::append( AST* other )
|
||||
void append( AST* self, AST* other )
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
GEN_ASSERT(other != nullptr);
|
||||
|
||||
if ( other->Parent )
|
||||
other = other->duplicate();
|
||||
other = duplicate(other);
|
||||
|
||||
other->Parent = this;
|
||||
other->Parent = self;
|
||||
|
||||
if ( Front == nullptr )
|
||||
if ( self->Front == nullptr )
|
||||
{
|
||||
Front = other;
|
||||
Back = other;
|
||||
self->Front = other;
|
||||
self->Back = other;
|
||||
|
||||
NumEntries++;
|
||||
self->NumEntries++;
|
||||
return;
|
||||
}
|
||||
|
||||
AST*
|
||||
Current = Back;
|
||||
Current = self->Back;
|
||||
Current->Next = other;
|
||||
other->Prev = Current;
|
||||
Back = other;
|
||||
NumEntries++;
|
||||
self->Back = other;
|
||||
self->NumEntries++;
|
||||
}
|
||||
|
||||
inline
|
||||
Code& AST::entry( u32 idx )
|
||||
Code* entry( AST* self, u32 idx )
|
||||
{
|
||||
AST** current = & Front;
|
||||
GEN_ASSERT(self != nullptr);
|
||||
AST** current = & self->Front;
|
||||
while ( idx >= 0 && current != nullptr )
|
||||
{
|
||||
if ( idx == 0 )
|
||||
return * rcast( Code*, current);
|
||||
return rcast( Code*, current);
|
||||
|
||||
current = & ( * current )->Next;
|
||||
idx--;
|
||||
}
|
||||
|
||||
return * rcast( Code*, current);
|
||||
return rcast( Code*, current);
|
||||
}
|
||||
|
||||
inline
|
||||
bool AST::has_entries()
|
||||
bool has_entries(AST* self)
|
||||
{
|
||||
return NumEntries > 0;
|
||||
GEN_ASSERT(self != nullptr);
|
||||
return self->NumEntries > 0;
|
||||
}
|
||||
|
||||
inline
|
||||
bool AST::is_body()
|
||||
bool is_body(AST* self)
|
||||
{
|
||||
switch (Type)
|
||||
GEN_ASSERT(self != nullptr);
|
||||
switch (self->Type)
|
||||
{
|
||||
case ECode::Enum_Body:
|
||||
case ECode::Class_Body:
|
||||
@ -70,9 +76,10 @@ bool AST::is_body()
|
||||
}
|
||||
|
||||
inline
|
||||
char const* AST::type_str()
|
||||
char const* type_str(AST* self)
|
||||
{
|
||||
return ECode::to_str( Type );
|
||||
GEN_ASSERT(self != nullptr);
|
||||
return ECode::to_str( self->Type );
|
||||
}
|
||||
|
||||
inline
|
||||
@ -117,7 +124,7 @@ void CodeParam::append( CodeParam other )
|
||||
AST* entry = (AST*) other.ast;
|
||||
|
||||
if ( entry->Parent )
|
||||
entry = entry->duplicate();
|
||||
entry = GEN_NS duplicate( entry );
|
||||
|
||||
entry->Parent = self;
|
||||
|
||||
|
@ -30,7 +30,7 @@ void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, s
|
||||
last = & back(Global_AllocatorBuckets);
|
||||
}
|
||||
|
||||
return alloc_align( allocator_info(* last), size, alignment );
|
||||
return alloc_align( allocator_info(last), size, alignment );
|
||||
}
|
||||
case EAllocation_FREE:
|
||||
{
|
||||
@ -306,7 +306,7 @@ void deinit()
|
||||
do
|
||||
{
|
||||
Pool* code_pool = & CodePools[index];
|
||||
free(* code_pool);
|
||||
free(code_pool);
|
||||
index++;
|
||||
}
|
||||
while ( left--, left );
|
||||
@ -316,7 +316,7 @@ void deinit()
|
||||
do
|
||||
{
|
||||
Arena* string_arena = & StringArenas[index];
|
||||
free(* string_arena);
|
||||
free(string_arena);
|
||||
index++;
|
||||
}
|
||||
while ( left--, left );
|
||||
@ -326,7 +326,7 @@ void deinit()
|
||||
free(CodePools);
|
||||
free(StringArenas);
|
||||
|
||||
free(LexArena);
|
||||
free(& LexArena);
|
||||
|
||||
free(PreprocessorDefines);
|
||||
|
||||
@ -335,7 +335,7 @@ void deinit()
|
||||
do
|
||||
{
|
||||
Arena* bucket = & Global_AllocatorBuckets[ index ];
|
||||
free(* bucket);
|
||||
free(bucket);
|
||||
index++;
|
||||
}
|
||||
while ( left--, left );
|
||||
@ -387,7 +387,7 @@ AllocatorInfo get_string_allocator( s32 str_length )
|
||||
last = & back(StringArenas);
|
||||
}
|
||||
|
||||
return allocator_info(* last);
|
||||
return allocator_info(last);
|
||||
}
|
||||
|
||||
// Will either make or retrive a code string.
|
||||
@ -425,7 +425,7 @@ Code make_code()
|
||||
allocator = & back(CodePools);
|
||||
}
|
||||
|
||||
Code result { rcast( AST*, alloc( allocator_info(* allocator), sizeof(AST) )) };
|
||||
Code result { rcast( AST*, alloc( allocator_info(allocator), sizeof(AST) )) };
|
||||
mem_set( result.ast, 0, sizeof(AST) );
|
||||
// result->Type = ECode::Invalid;
|
||||
|
||||
|
@ -17,7 +17,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
||||
char tok_map_mem[ TokenFmt_TokenMap_MemSize ];
|
||||
|
||||
tok_map_arena = arena_init_from_memory( tok_map_mem, sizeof(tok_map_mem) );
|
||||
tok_map = hashtable_init<StrC>( allocator_info(tok_map_arena) );
|
||||
tok_map = hashtable_init<StrC>( allocator_info(& tok_map_arena) );
|
||||
|
||||
s32 left = num_tokens - 1;
|
||||
|
||||
@ -95,7 +95,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
||||
}
|
||||
|
||||
clear(tok_map);
|
||||
free(tok_map_arena);
|
||||
free(& tok_map_arena);
|
||||
|
||||
ssize result = buf_size - remaining;
|
||||
|
||||
|
@ -1925,7 +1925,7 @@ CodeBody def_global_body( s32 num, ... )
|
||||
switch (entry->Type)
|
||||
{
|
||||
case Global_Body:
|
||||
result.append( entry.cast<CodeBody>() ) ;
|
||||
result.append( entry.code_cast<CodeBody>() ) ;
|
||||
continue;
|
||||
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
@ -1966,7 +1966,7 @@ CodeBody def_global_body( s32 num, Code* codes )
|
||||
switch (entry->Type)
|
||||
{
|
||||
case Global_Body:
|
||||
result.append( entry.cast<CodeBody>() ) ;
|
||||
result.append( entry.code_cast<CodeBody>() ) ;
|
||||
continue;
|
||||
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
|
@ -579,7 +579,7 @@ TokArray lex( StrC content )
|
||||
if ( left <= 0 )
|
||||
{
|
||||
log_failure( "gen::lex: no tokens found (only whitespace provided)" );
|
||||
return { { nullptr }, 0 };
|
||||
return { {}, 0 };
|
||||
}
|
||||
|
||||
foreach( StringCached, entry, PreprocessorDefines )
|
||||
@ -652,7 +652,7 @@ TokArray lex( StrC content )
|
||||
continue;
|
||||
|
||||
case Lex_ReturnNull:
|
||||
return { { nullptr }, 0 };
|
||||
return { {}, 0 };
|
||||
}
|
||||
}
|
||||
case '.':
|
||||
@ -1256,7 +1256,7 @@ TokArray lex( StrC content )
|
||||
if ( num(Tokens) == 0 )
|
||||
{
|
||||
log_failure( "Failed to lex any tokens" );
|
||||
return { { nullptr }, 0 };
|
||||
return { {}, 0 };
|
||||
}
|
||||
|
||||
clear(defines);
|
||||
|
@ -132,12 +132,12 @@ bool TokArray::__eat( TokType type )
|
||||
internal
|
||||
void init()
|
||||
{
|
||||
Tokens = array_init_reserve<Token>( allocator_info(LexArena)
|
||||
Tokens = array_init_reserve<Token>( allocator_info( & LexArena)
|
||||
, ( LexAllocator_Size - sizeof( ArrayHeader ) ) / sizeof(Token)
|
||||
);
|
||||
|
||||
fixed_arena_init(defines_map_arena);
|
||||
defines = hashtable_init_reserve<StrC>( allocator_info(defines_map_arena), 256 );
|
||||
fixed_arena_init(& defines_map_arena);
|
||||
defines = hashtable_init_reserve<StrC>( allocator_info( & defines_map_arena), 256 );
|
||||
}
|
||||
|
||||
internal
|
||||
@ -714,7 +714,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
|
||||
char interface_arr_mem[ kilobytes(4) ] {0};
|
||||
Array<CodeType> interfaces; {
|
||||
Arena arena = arena_init_from_memory( interface_arr_mem, kilobytes(4) );
|
||||
interfaces = array_init_reserve<CodeType>( allocator_info(arena), 4 );
|
||||
interfaces = array_init_reserve<CodeType>( allocator_info(& arena), 4 );
|
||||
}
|
||||
|
||||
// TODO(Ed) : Make an AST_DerivedType, we'll store any arbitary derived type into there as a linear linked list of them.
|
||||
@ -4910,10 +4910,12 @@ CodeTypedef parse_typedef()
|
||||
|| currtok.Type == TokType::Decl_Struct
|
||||
|| currtok.Type == TokType::Decl_Union;
|
||||
|
||||
|
||||
// This code is highly correlated with parse_complicated_definition
|
||||
if ( is_complicated )
|
||||
{
|
||||
TokArray tokens = Context.Tokens;
|
||||
TokType which = currtok.Type;
|
||||
|
||||
s32 idx = tokens.Idx;
|
||||
s32 level = 0;
|
||||
@ -4929,73 +4931,80 @@ CodeTypedef parse_typedef()
|
||||
break;
|
||||
}
|
||||
|
||||
if ( (idx - 2 ) == tokens.Idx )
|
||||
Token pre_foward_tok = currtok;
|
||||
if ( (idx - 3 ) == tokens.Idx )
|
||||
{
|
||||
log_fmt("Identified forward typedef\n");
|
||||
// Its a forward declaration only
|
||||
type = parse_forward_or_definition( currtok.Type, from_typedef );
|
||||
type = parse_forward_or_definition( which, from_typedef );
|
||||
// <ModuleFalgs> typedef <UnderlyingType: Forward Decl>
|
||||
}
|
||||
|
||||
Token tok = tokens[ idx - 1 ];
|
||||
if ( tok.Type == TokType::Identifier )
|
||||
else
|
||||
{
|
||||
tok = tokens[ idx - 2 ];
|
||||
|
||||
bool is_indirection = tok.Type == TokType::Ampersand
|
||||
|| tok.Type == TokType::Star;
|
||||
|
||||
bool ok_to_parse = false;
|
||||
|
||||
if ( tok.Type == TokType::BraceCurly_Close )
|
||||
Token tok = tokens.Arr[ idx - 1 ];
|
||||
if ( tok.Type == TokType::Identifier )
|
||||
{
|
||||
// Its an inplace definition
|
||||
// typdef <which> <type_identifier> { ... } <identifier>;
|
||||
ok_to_parse = true;
|
||||
}
|
||||
else if ( tok.Type == TokType::Identifier && tokens[ idx - 3 ].Type == TokType::Decl_Struct )
|
||||
{
|
||||
// Its a variable with type ID using struct namespace.
|
||||
// <which> <type_identifier> <identifier>;
|
||||
ok_to_parse = true;
|
||||
}
|
||||
else if ( is_indirection )
|
||||
{
|
||||
// Its a indirection type with type ID using struct namespace.
|
||||
// <which> <type_identifier>* <identifier>;
|
||||
ok_to_parse = true;
|
||||
}
|
||||
log_fmt("Found id\n");
|
||||
tok = tokens.Arr[ idx - 2 ];
|
||||
|
||||
if ( ! ok_to_parse )
|
||||
bool is_indirection = tok.Type == TokType::Ampersand
|
||||
|| tok.Type == TokType::Star;
|
||||
|
||||
bool ok_to_parse = false;
|
||||
|
||||
Token temp_3 = tokens.Arr[ idx - 3 ];
|
||||
|
||||
if ( tok.Type == TokType::BraceCurly_Close )
|
||||
{
|
||||
// Its an inplace definition
|
||||
// typedef <which> <type_identifier> { ... } <identifier>;
|
||||
ok_to_parse = true;
|
||||
}
|
||||
else if ( tok.Type == TokType::Identifier && tokens.Arr[ idx - 3 ].Type == which )
|
||||
{
|
||||
// Its a variable with type ID using which namespace.
|
||||
// typedef <which> <type_identifier> <identifier>;
|
||||
ok_to_parse = true;
|
||||
}
|
||||
else if ( is_indirection )
|
||||
{
|
||||
// Its a indirection type with type ID using struct namespace.
|
||||
// typedef <which> <type_identifier>* <identifier>;
|
||||
ok_to_parse = true;
|
||||
}
|
||||
|
||||
if ( ! ok_to_parse )
|
||||
{
|
||||
log_failure( "Unsupported or bad member definition after struct declaration\n%s", Context.to_string() );
|
||||
Context.pop();
|
||||
return CodeInvalid;
|
||||
}
|
||||
|
||||
// TODO(Ed) : I'm not sure if I have to use parse_type here, I'd rather not as that would complicate parse_type.
|
||||
// type = parse_type();
|
||||
type = parse_forward_or_definition( which, from_typedef );
|
||||
// <ModuleFalgs> typedef <UnderlyingType>
|
||||
}
|
||||
else if ( tok.Type == TokType::BraceCurly_Close )
|
||||
{
|
||||
// Its a definition
|
||||
// <which> { ... };
|
||||
type = parse_forward_or_definition( currtok.Type, from_typedef );
|
||||
// <ModuleFalgs> typedef <UnderlyingType>
|
||||
}
|
||||
else if ( tok.Type == TokType::BraceSquare_Close)
|
||||
{
|
||||
// Its an array definition
|
||||
// <which> <type_identifier> <identifier> [ ... ];
|
||||
type = parse_type();
|
||||
// <ModuleFalgs> typedef <UnderlyingType>
|
||||
}
|
||||
else
|
||||
{
|
||||
log_failure( "Unsupported or bad member definition after struct declaration\n%s", Context.to_string() );
|
||||
Context.pop();
|
||||
return CodeInvalid;
|
||||
}
|
||||
|
||||
// TODO(Ed) : I'm not sure if I have to use parse_type here, I'd rather not as that would complicate parse_type.
|
||||
// type = parse_type();
|
||||
type = parse_forward_or_definition( currtok.Type, from_typedef );
|
||||
// <ModuleFalgs> typedef <UnderlyingType>
|
||||
}
|
||||
else if ( tok.Type == TokType::BraceCurly_Close )
|
||||
{
|
||||
// Its a definition
|
||||
// <which> { ... };
|
||||
type = parse_forward_or_definition( currtok.Type, from_typedef );
|
||||
// <ModuleFalgs> typedef <UnderlyingType>
|
||||
}
|
||||
else if ( tok.Type == TokType::BraceSquare_Close)
|
||||
{
|
||||
// Its an array definition
|
||||
// <which> <type_identifier> <identifier> [ ... ];
|
||||
type = parse_type();
|
||||
// <ModuleFalgs> typedef <UnderlyingType>
|
||||
}
|
||||
else
|
||||
{
|
||||
log_failure( "Unsupported or bad member definition after struct declaration\n%s", Context.to_string() );
|
||||
Context.pop();
|
||||
return CodeInvalid;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -5057,7 +5066,7 @@ CodeTypedef parse_typedef()
|
||||
// Type needs to be aware of its parent so that it can be serialized properly.
|
||||
|
||||
if ( type->Type == Typename && array_expr && array_expr->Type != Invalid )
|
||||
type.cast<CodeType>()->ArrExpr = array_expr;
|
||||
type.code_cast<CodeType>()->ArrExpr = array_expr;
|
||||
|
||||
if ( inline_cmt )
|
||||
result->InlineCmt = inline_cmt;
|
||||
|
@ -25,7 +25,7 @@ enum AccessSpec enum_underlying(u32)
|
||||
|
||||
AccessSpec_SizeDef = GEN_U32_MAX,
|
||||
};
|
||||
static_assert( size_of(AccessSpec) == size_of(u32));
|
||||
static_assert( size_of(AccessSpec) == size_of(u32), "AccessSpec not u32 size" );
|
||||
|
||||
inline
|
||||
char const* to_str( AccessSpec type )
|
||||
@ -54,7 +54,7 @@ enum CodeFlag enum_underlying(u32)
|
||||
|
||||
CodeFlag_SizeDef = GEN_U32_MAX,
|
||||
};
|
||||
static_assert( size_of(CodeFlag) == size_of(u32));
|
||||
static_assert( size_of(CodeFlag) == size_of(u32), "CodeFlag not u32 size" );
|
||||
|
||||
// Used to indicate if enum definitoin is an enum class or regular enum.
|
||||
enum EnumDecl enum_underlying(u8)
|
||||
@ -77,7 +77,7 @@ enum ModuleFlag enum_underlying(u32)
|
||||
|
||||
ModuleFlag_SizeDef = GEN_U32_MAX,
|
||||
};
|
||||
static_assert( size_of(ModuleFlag) == size_of(u32));
|
||||
static_assert( size_of(ModuleFlag) == size_of(u32), "ModuleFlag not u32 size" );
|
||||
|
||||
inline
|
||||
StrC to_str( ModuleFlag flag )
|
||||
@ -110,4 +110,4 @@ enum EPreprocessCond enum_underlying(u32)
|
||||
|
||||
EPreprocessCond_SizeDef = GEN_U32_MAX,
|
||||
};
|
||||
static_assert( size_of(EPreprocessCond) == size_of(u32));
|
||||
static_assert( size_of(EPreprocessCond) == size_of(u32), "EPreprocessCond not u32 size" );
|
||||
|
Reference in New Issue
Block a user