mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
member proc usage reductions on CodeTypes complete (Typedef, Union, Using, Var)
proceeding to finalize the AST interface reductions...
This commit is contained in:
parent
05e65aa464
commit
defe42c15c
@ -557,7 +557,7 @@ void to_string( AST* self, String* result )
|
||||
break;
|
||||
|
||||
case Typedef:
|
||||
cast(CodeTypedef, {self}).to_string( * result );
|
||||
to_string(cast(CodeTypedef, {self}), result );
|
||||
break;
|
||||
|
||||
case Typename:
|
||||
@ -565,19 +565,19 @@ void to_string( AST* self, String* result )
|
||||
break;
|
||||
|
||||
case Union:
|
||||
cast(CodeUnion, {self}).to_string( * result );
|
||||
to_string( cast(CodeUnion, {self}), result );
|
||||
break;
|
||||
|
||||
case Using:
|
||||
cast(CodeUsing, {self}).to_string( * result );
|
||||
to_string(cast(CodeUsing, {self}), result );
|
||||
break;
|
||||
|
||||
case Using_Namespace:
|
||||
cast(CodeUsing, {self}).to_string_ns( * result );
|
||||
to_string_ns(cast(CodeUsing, {self}), result );
|
||||
break;
|
||||
|
||||
case Variable:
|
||||
cast(CodeVar, {self}).to_string( * result );
|
||||
to_string(cast(CodeVar, {self}), result );
|
||||
break;
|
||||
|
||||
case Enum_Body:
|
||||
|
@ -264,7 +264,6 @@ struct Code_POD
|
||||
{
|
||||
AST* ast;
|
||||
};
|
||||
|
||||
static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" );
|
||||
|
||||
// Desired width of the AST data structure.
|
||||
@ -421,73 +420,9 @@ struct AST
|
||||
};
|
||||
};
|
||||
|
||||
struct AST_POD
|
||||
{
|
||||
union {
|
||||
struct
|
||||
{
|
||||
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
||||
AST* Specs; // Destructor, Function, Operator, Typename, Variable
|
||||
union {
|
||||
AST* InitializerList; // Constructor
|
||||
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
||||
AST* ReturnType; // Function, Operator, Typename
|
||||
AST* UnderlyingType; // Enum, Typedef
|
||||
AST* ValueType; // Parameter, Variable
|
||||
};
|
||||
union {
|
||||
AST* Macro; // Parameter
|
||||
AST* BitfieldSize; // Variable (Class/Struct Data Member)
|
||||
AST* Params; // Constructor, Function, Operator, Template, Typename
|
||||
};
|
||||
union {
|
||||
AST* ArrExpr; // Typename
|
||||
AST* Body; // Class, Constructr, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
||||
AST* Declaration; // Friend, Template
|
||||
AST* Value; // Parameter, Variable
|
||||
};
|
||||
union {
|
||||
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
||||
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
||||
AST* PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
|
||||
};
|
||||
};
|
||||
StringCached Content; // Attributes, Comment, Execution, Include
|
||||
struct {
|
||||
SpecifierT ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers
|
||||
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
||||
};
|
||||
};
|
||||
union {
|
||||
AST* Prev;
|
||||
AST* Front;
|
||||
AST* Last;
|
||||
};
|
||||
union {
|
||||
AST* Next;
|
||||
AST* Back;
|
||||
};
|
||||
parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
||||
AST* Parent;
|
||||
StringCached Name;
|
||||
CodeT Type;
|
||||
CodeFlag CodeFlags;
|
||||
ModuleFlag ModuleFlags;
|
||||
union {
|
||||
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.
|
||||
OperatorT Op;
|
||||
AccessSpec ParentAccess;
|
||||
s32 NumEntries;
|
||||
s32 VarConstructorInit; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
|
||||
};
|
||||
};
|
||||
|
||||
// Its intended for the AST to have equivalent size to its POD.
|
||||
// All extra functionality within the AST namespace should just be syntatic sugar.
|
||||
static_assert( sizeof(AST) == sizeof(AST_POD), "ERROR: AST IS NOT POD" );
|
||||
static_assert( sizeof(AST_POD) == AST_POD_Size, "ERROR: AST POD is not size of AST_POD_Size" );
|
||||
static_assert( sizeof(AST) == AST_POD_Size, "ERROR: AST POD is not size of AST_POD_Size" );
|
||||
|
||||
// Used when the its desired when omission is allowed in a definition.
|
||||
#define NoCode { nullptr }
|
||||
|
@ -1093,46 +1093,46 @@ void to_string(CodeTemplate self, String* result )
|
||||
append_fmt( result, "template<>\n%S", GEN_NS to_string(self->Declaration) );
|
||||
}
|
||||
|
||||
String CodeTypedef::to_string()
|
||||
String to_string(CodeTypedef self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
to_string( result );
|
||||
to_string( self, & result );
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeTypedef::to_string( String& result )
|
||||
void to_string(CodeTypedef self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
append( & result, "typedef ");
|
||||
append( result, "typedef ");
|
||||
|
||||
// Determines if the typedef is a function typename
|
||||
if ( ast->UnderlyingType->ReturnType )
|
||||
append( & result, GEN_NS to_string(ast->UnderlyingType) );
|
||||
if ( self->UnderlyingType->ReturnType )
|
||||
append( result, GEN_NS to_string(self->UnderlyingType) );
|
||||
else
|
||||
append_fmt( & result, "%S %S", GEN_NS to_string(ast->UnderlyingType), ast->Name );
|
||||
append_fmt( result, "%S %S", GEN_NS to_string(self->UnderlyingType), self->Name );
|
||||
|
||||
if ( ast->UnderlyingType->Type == ECode::Typename && ast->UnderlyingType->ArrExpr )
|
||||
if ( self->UnderlyingType->Type == ECode::Typename && self->UnderlyingType->ArrExpr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ];", GEN_NS to_string(ast->UnderlyingType->ArrExpr) );
|
||||
append_fmt( result, "[ %S ];", GEN_NS to_string(self->UnderlyingType->ArrExpr) );
|
||||
|
||||
AST* next_arr_expr = ast->UnderlyingType->ArrExpr->Next;
|
||||
AST* next_arr_expr = self->UnderlyingType->ArrExpr->Next;
|
||||
while ( next_arr_expr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ];", GEN_NS to_string(next_arr_expr) );
|
||||
append_fmt( result, "[ %S ];", GEN_NS to_string(next_arr_expr) );
|
||||
next_arr_expr = next_arr_expr->Next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
append( & result, ";" );
|
||||
append( result, ";" );
|
||||
}
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, " %S", ast->InlineCmt->Content);
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, " %S", self->InlineCmt->Content);
|
||||
else
|
||||
append( & result, "\n");
|
||||
append( result, "\n");
|
||||
}
|
||||
|
||||
String to_string(CodeType self)
|
||||
@ -1188,235 +1188,235 @@ void to_string(CodeType self, String* result )
|
||||
append( result, "...");
|
||||
}
|
||||
|
||||
String CodeUnion::to_string()
|
||||
String to_string(CodeUnion self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
to_string( result );
|
||||
to_string( self, & result );
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeUnion::to_string( String& result )
|
||||
void to_string(CodeUnion self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
append( & result, "union " );
|
||||
append( result, "union " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
if ( self->Attributes )
|
||||
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
|
||||
|
||||
if ( ast->Name )
|
||||
if ( self->Name )
|
||||
{
|
||||
append_fmt( & result, "%S\n{\n%S\n}"
|
||||
, ast->Name
|
||||
, GEN_NS to_string(ast->Body)
|
||||
append_fmt( result, "%S\n{\n%S\n}"
|
||||
, self->Name
|
||||
, GEN_NS to_string(self->Body)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Anonymous union
|
||||
append_fmt( & result, "\n{\n%S\n}"
|
||||
, GEN_NS to_string(ast->Body)
|
||||
append_fmt( result, "\n{\n%S\n}"
|
||||
, GEN_NS to_string(self->Body)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
|
||||
append( & result, ";\n");
|
||||
if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) )
|
||||
append( result, ";\n");
|
||||
}
|
||||
|
||||
String CodeUsing::to_string()
|
||||
String to_string(CodeUsing self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
switch ( ast->Type )
|
||||
switch ( self->Type )
|
||||
{
|
||||
using namespace ECode;
|
||||
case Using:
|
||||
to_string( result );
|
||||
to_string( self, & result );
|
||||
break;
|
||||
case Using_Namespace:
|
||||
to_string_ns( result );
|
||||
to_string_ns( self, & result );
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeUsing::to_string( String& result )
|
||||
void to_string(CodeUsing self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
if ( self->Attributes )
|
||||
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
|
||||
|
||||
if ( ast->UnderlyingType )
|
||||
if ( self->UnderlyingType )
|
||||
{
|
||||
append_fmt( & result, "using %S = %S", ast->Name, GEN_NS to_string(ast->UnderlyingType) );
|
||||
append_fmt( result, "using %S = %S", self->Name, GEN_NS to_string(self->UnderlyingType) );
|
||||
|
||||
if ( ast->UnderlyingType->ArrExpr )
|
||||
if ( self->UnderlyingType->ArrExpr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ]", GEN_NS to_string(ast->UnderlyingType->ArrExpr) );
|
||||
append_fmt( result, "[ %S ]", GEN_NS to_string(self->UnderlyingType->ArrExpr) );
|
||||
|
||||
AST* next_arr_expr = ast->UnderlyingType->ArrExpr->Next;
|
||||
AST* next_arr_expr = self->UnderlyingType->ArrExpr->Next;
|
||||
while ( next_arr_expr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
|
||||
append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
|
||||
next_arr_expr = next_arr_expr->Next;
|
||||
}
|
||||
}
|
||||
|
||||
append( & result, ";" );
|
||||
append( result, ";" );
|
||||
}
|
||||
else
|
||||
append_fmt( & result, "using %S;", ast->Name );
|
||||
append_fmt( result, "using %S;", self->Name );
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, " %S\n", ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, " %S\n", self->InlineCmt->Content );
|
||||
else
|
||||
append( & result, "\n");
|
||||
append( result, "\n");
|
||||
}
|
||||
|
||||
void CodeUsing::to_string_ns( String& result )
|
||||
void to_string_ns(CodeUsing self, String* result )
|
||||
{
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, "using namespace $S; %S", ast->Name, ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, "using namespace $S; %S", self->Name, self->InlineCmt->Content );
|
||||
else
|
||||
append_fmt( & result, "using namespace %s;\n", ast->Name );
|
||||
append_fmt( result, "using namespace %s;\n", self->Name );
|
||||
}
|
||||
|
||||
String CodeVar::to_string()
|
||||
String to_string(CodeVar self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
to_string( result );
|
||||
to_string( self, & result );
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeVar::to_string( String& result )
|
||||
void to_string(CodeVar self, String* result )
|
||||
{
|
||||
if ( ast->Parent && ast->Parent->Type == ECode::Variable )
|
||||
if ( self->Parent && self->Parent->Type == ECode::Variable )
|
||||
{
|
||||
// Its a comma-separated variable ( a NextVar )
|
||||
|
||||
if ( ast->Specs )
|
||||
append_fmt( & result, "%S ", GEN_NS to_string(ast->Specs) );
|
||||
if ( self->Specs )
|
||||
append_fmt( result, "%S ", GEN_NS to_string(self->Specs) );
|
||||
|
||||
append( & result, ast->Name );
|
||||
append( result, self->Name );
|
||||
|
||||
if ( ast->ValueType->ArrExpr )
|
||||
if ( self->ValueType->ArrExpr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ]", GEN_NS to_string(ast->ValueType->ArrExpr) );
|
||||
append_fmt( result, "[ %S ]", GEN_NS to_string(self->ValueType->ArrExpr) );
|
||||
|
||||
AST* next_arr_expr = ast->ValueType->ArrExpr->Next;
|
||||
AST* next_arr_expr = self->ValueType->ArrExpr->Next;
|
||||
while ( next_arr_expr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
|
||||
append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
|
||||
next_arr_expr = next_arr_expr->Next;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ast->Value )
|
||||
if ( self->Value )
|
||||
{
|
||||
if ( ast->VarConstructorInit )
|
||||
append_fmt( & result, "( %S ", GEN_NS to_string(ast->Value) );
|
||||
if ( self->VarConstructorInit )
|
||||
append_fmt( result, "( %S ", GEN_NS to_string(self->Value) );
|
||||
else
|
||||
append_fmt( & result, " = %S", GEN_NS to_string(ast->Value) );
|
||||
append_fmt( result, " = %S", GEN_NS to_string(self->Value) );
|
||||
}
|
||||
|
||||
// Keep the chain going...
|
||||
if ( ast->NextVar )
|
||||
append_fmt( & result, ", %S", ast->NextVar.to_string() );
|
||||
if ( self->NextVar )
|
||||
append_fmt( result, ", %S", self->NextVar.to_string() );
|
||||
|
||||
if ( ast->VarConstructorInit )
|
||||
append( & result, " )");
|
||||
if ( self->VarConstructorInit )
|
||||
append( result, " )");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
if ( ast->Attributes || ast->Specs )
|
||||
if ( self->Attributes || self->Specs )
|
||||
{
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", GEN_NS to_string(ast->Specs) );
|
||||
if ( self->Attributes )
|
||||
append_fmt( result, "%S ", GEN_NS to_string(self->Specs) );
|
||||
|
||||
if ( ast->Specs )
|
||||
append_fmt( & result, "%S\n", GEN_NS to_string(ast->Specs) );
|
||||
if ( self->Specs )
|
||||
append_fmt( result, "%S\n", GEN_NS to_string(self->Specs) );
|
||||
|
||||
append_fmt( & result, "%S %S", GEN_NS to_string(ast->ValueType), ast->Name );
|
||||
append_fmt( result, "%S %S", GEN_NS to_string(self->ValueType), self->Name );
|
||||
|
||||
if ( ast->ValueType->ArrExpr )
|
||||
if ( self->ValueType->ArrExpr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ]", GEN_NS to_string(ast->ValueType->ArrExpr) );
|
||||
append_fmt( result, "[ %S ]", GEN_NS to_string(self->ValueType->ArrExpr) );
|
||||
|
||||
AST* next_arr_expr = ast->ValueType->ArrExpr->Next;
|
||||
AST* next_arr_expr = self->ValueType->ArrExpr->Next;
|
||||
while ( next_arr_expr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
|
||||
append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
|
||||
next_arr_expr = next_arr_expr->Next;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ast->BitfieldSize )
|
||||
append_fmt( & result, " : %S", GEN_NS to_string(ast->BitfieldSize) );
|
||||
if ( self->BitfieldSize )
|
||||
append_fmt( result, " : %S", GEN_NS to_string(self->BitfieldSize) );
|
||||
|
||||
if ( ast->Value )
|
||||
if ( self->Value )
|
||||
{
|
||||
if ( ast->VarConstructorInit )
|
||||
append_fmt( & result, "( %S ", GEN_NS to_string(ast->Value) );
|
||||
if ( self->VarConstructorInit )
|
||||
append_fmt( result, "( %S ", GEN_NS to_string(self->Value) );
|
||||
else
|
||||
append_fmt( & result, " = %S", GEN_NS to_string(ast->Value) );
|
||||
append_fmt( result, " = %S", GEN_NS to_string(self->Value) );
|
||||
}
|
||||
|
||||
if ( ast->NextVar )
|
||||
append_fmt( & result, ", %S", ast->NextVar.to_string() );
|
||||
if ( self->NextVar )
|
||||
append_fmt( result, ", %S", self->NextVar.to_string() );
|
||||
|
||||
if ( ast->VarConstructorInit )
|
||||
append( & result, " )");
|
||||
if ( self->VarConstructorInit )
|
||||
append( result, " )");
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, "; %S", ast->InlineCmt->Content);
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, "; %S", self->InlineCmt->Content);
|
||||
else
|
||||
append( & result, ";\n" );
|
||||
append( result, ";\n" );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ast->BitfieldSize )
|
||||
append_fmt( & result, "%S %S : %S", GEN_NS to_string(ast->ValueType), ast->Name, GEN_NS to_string(ast->BitfieldSize) );
|
||||
if ( self->BitfieldSize )
|
||||
append_fmt( result, "%S %S : %S", GEN_NS to_string(self->ValueType), self->Name, GEN_NS to_string(self->BitfieldSize) );
|
||||
|
||||
else if ( ast->ValueType->ArrExpr )
|
||||
else if ( self->ValueType->ArrExpr )
|
||||
{
|
||||
append_fmt( & result, "%S %S[ %S ]", GEN_NS to_string(ast->ValueType), ast->Name, GEN_NS to_string(ast->ValueType->ArrExpr) );
|
||||
append_fmt( result, "%S %S[ %S ]", GEN_NS to_string(self->ValueType), self->Name, GEN_NS to_string(self->ValueType->ArrExpr) );
|
||||
|
||||
AST* next_arr_expr = ast->ValueType->ArrExpr->Next;
|
||||
AST* next_arr_expr = self->ValueType->ArrExpr->Next;
|
||||
while ( next_arr_expr )
|
||||
{
|
||||
append_fmt( & result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
|
||||
append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
|
||||
next_arr_expr = next_arr_expr->Next;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
append_fmt( & result, "%S %S", GEN_NS to_string(ast->ValueType), ast->Name );
|
||||
append_fmt( result, "%S %S", GEN_NS to_string(self->ValueType), self->Name );
|
||||
|
||||
if ( ast->Value )
|
||||
if ( self->Value )
|
||||
{
|
||||
if ( ast->VarConstructorInit )
|
||||
append_fmt( & result, "( %S ", GEN_NS to_string(ast->Value) );
|
||||
if ( self->VarConstructorInit )
|
||||
append_fmt( result, "( %S ", GEN_NS to_string(self->Value) );
|
||||
else
|
||||
append_fmt( & result, " = %S", GEN_NS to_string(ast->Value) );
|
||||
append_fmt( result, " = %S", GEN_NS to_string(self->Value) );
|
||||
}
|
||||
|
||||
if ( ast->NextVar )
|
||||
append_fmt( & result, ", %S", ast->NextVar.to_string() );
|
||||
if ( self->NextVar )
|
||||
append_fmt( result, ", %S", self->NextVar.to_string() );
|
||||
|
||||
if ( ast->VarConstructorInit )
|
||||
append( & result, " )");
|
||||
if ( self->VarConstructorInit )
|
||||
append( result, " )");
|
||||
|
||||
append( & result, ";" );
|
||||
append( result, ";" );
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, " %S", ast->InlineCmt->Content);
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, " %S", self->InlineCmt->Content);
|
||||
else
|
||||
append( & result, "\n");
|
||||
append( result, "\n");
|
||||
}
|
||||
|
@ -105,11 +105,26 @@ void to_string(CodeTemplate self, String* result);
|
||||
String to_string(CodeType self);
|
||||
void to_string(CodeType self, String* result);
|
||||
|
||||
String to_string(CodeTypedef self);
|
||||
void to_string(CodeTypedef self, String* result);
|
||||
|
||||
String to_string(CodeUnion self);
|
||||
void to_string(CodeUnion self, String* result);
|
||||
|
||||
String to_string (CodeUsing op_cast );
|
||||
void to_string (CodeUsing op_cast, String* result );
|
||||
void to_string_ns(CodeUsing op_cast, String* result );
|
||||
|
||||
String to_string(CodeVar self);
|
||||
void to_string(CodeVar self, String* result);
|
||||
|
||||
#pragma region Code Types
|
||||
// These structs are not used at all by the C vairant.
|
||||
#if ! GEN_COMPILER_C
|
||||
// stati_assert( GEN_COMPILER_C, "This should not be compiled with the C-library" );
|
||||
|
||||
#define Verify_POD(Type) static_assert(size_of(Code##Type) == size_of(AST_##Type), "ERROR: Code##Type is not a POD")
|
||||
|
||||
struct CodeBody
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
@ -897,7 +912,7 @@ struct CodeStmt_While
|
||||
|
||||
struct CodeTemplate
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeTemplate );
|
||||
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
@ -927,11 +942,11 @@ struct CodeType
|
||||
|
||||
struct CodeTypedef
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeTypedef );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeTypedef );
|
||||
@ -945,8 +960,8 @@ struct CodeUnion
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
Using_Code( CodeUnion );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeUnion);
|
||||
@ -960,9 +975,9 @@ struct CodeUsing
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
Using_Code( CodeUsing );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
void to_string_ns( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
void to_string_ns( String& result ) { return GEN_NS to_string_ns(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeUsing);
|
||||
@ -976,8 +991,8 @@ struct CodeVar
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
Using_Code( CodeVar );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeVar);
|
||||
@ -994,6 +1009,8 @@ struct CodeVar
|
||||
void to_string_export( CodeBody body, String& result ) { return to_string_export(body, & result); };
|
||||
#endif
|
||||
|
||||
#undef Verify_POD
|
||||
|
||||
#endif //if ! GEN_COMPILER_C
|
||||
|
||||
#pragma endregion Code Types
|
||||
|
Loading…
Reference in New Issue
Block a user