began to remove usage of code specific types member procs

This commit is contained in:
Edward R. Gonzalez 2024-12-02 04:12:09 -05:00
parent 5b0079fb0c
commit 16b8a3a164
7 changed files with 168 additions and 137 deletions

View File

@ -415,11 +415,11 @@ void to_string( AST* self, String* result )
break; break;
case Class: case Class:
cast(CodeClass, {self}).to_string_def( * result ); to_string_def(cast(CodeClass, {self}), result );
break; break;
case Class_Fwd: case Class_Fwd:
cast(CodeClass, {self}).to_string_fwd( * result ); to_string_fwd(cast(CodeClass, {self}), result );
break; break;
case Constructor: case Constructor:
@ -455,7 +455,7 @@ void to_string( AST* self, String* result )
break; break;
case Export_Body: case Export_Body:
cast(CodeBody, {self}).to_string_export( * result ); to_string_export(cast(CodeBody, {self}), result );
break; break;
case Extern_Linkage: case Extern_Linkage:
@ -588,7 +588,7 @@ void to_string( AST* self, String* result )
case Namespace_Body: case Namespace_Body:
case Struct_Body: case Struct_Body:
case Union_Body: case Union_Body:
cast(CodeBody, {self}).to_string( * result ); to_string( cast(CodeBody, {self}), result );
break; break;
} }
} }

View File

@ -18,15 +18,16 @@ String CodeAttributes::to_string()
return GEN_NS duplicate( ast->Content, GlobalAllocator ); return GEN_NS duplicate( ast->Content, GlobalAllocator );
} }
String CodeBody::to_string() String to_string(CodeBody body)
{ {
GEN_ASSERT(body.ast != nullptr);
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( ast->Type ) switch ( body.ast->Type )
{ {
using namespace ECode; using namespace ECode;
case Untyped: case Untyped:
case Execution: case Execution:
GEN_NS append( & result, raw()->Content ); append( & result, rcast(AST*, body.ast)->Content );
break; break;
case Enum_Body: case Enum_Body:
@ -37,40 +38,44 @@ String CodeBody::to_string()
case Namespace_Body: case Namespace_Body:
case Struct_Body: case Struct_Body:
case Union_Body: case Union_Body:
to_string( result ); to_string( body, & result );
break; break;
case Export_Body: case Export_Body:
to_string_export( result ); to_string_export( body, & result );
break; break;
} }
return result; return result;
} }
void CodeBody::to_string( String& result ) void to_string( CodeBody body, String* result )
{ {
Code curr = ast->Front; GEN_ASSERT(body.ast != nullptr);
s32 left = ast->NumEntries; GEN_ASSERT(result != nullptr);
Code curr = body.ast->Front;
s32 left = body.ast->NumEntries;
while ( left -- ) while ( left -- )
{ {
append_fmt( & result, "%S", GEN_NS to_string(curr) ); append_fmt( result, "%S", GEN_NS to_string(curr) );
++curr; ++curr;
} }
} }
void CodeBody::to_string_export( String& result ) void to_string_export( CodeBody body, String* result )
{ {
append_fmt( & result, "export\n{\n" ); GEN_ASSERT(body.ast != nullptr);
GEN_ASSERT(result != nullptr);
append_fmt( result, "export\n{\n" );
Code curr = *this; Code curr = body;
s32 left = ast->NumEntries; s32 left = body.ast->NumEntries;
while ( left-- ) while ( left-- )
{ {
append_fmt( & result, "%S", GEN_NS to_string(curr) ); append_fmt( result, "%S", to_string(curr) );
++curr; ++curr;
} }
append_fmt( & result, "};\n" ); append_fmt( result, "};\n" );
} }
String CodeComment::to_string() String CodeComment::to_string()
@ -142,83 +147,89 @@ void CodeConstructor::to_string_fwd( String& result )
append( & result, ";\n" ); append( & result, ";\n" );
} }
String CodeClass::to_string() String to_string( CodeClass self )
{ {
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( ast->Type ) switch ( self->Type )
{ {
using namespace ECode; using namespace ECode;
case Class: case Class:
to_string_def( result ); to_string_def(self, & result );
break; break;
case Class_Fwd: case Class_Fwd:
to_string_fwd( result ); to_string_fwd(self, & result );
break; break;
} }
return result; return result;
} }
void CodeClass::to_string_def( String& result ) void to_string_def( CodeClass self, String* result )
{ {
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) GEN_ASSERT(self.ast != nullptr);
append( & result, "export " ); AST_Class* ast = self.ast;
append( & result, "class " ); if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
append( result, "export " );
append( result, "class " );
if ( ast->Attributes ) if ( ast->Attributes )
{ {
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( result, "%S ", ast->Attributes.to_string() );
} }
if ( ast->ParentType ) if ( ast->ParentType )
{ {
char const* access_level = to_str( ast->ParentAccess ); char const* access_level = to_str( ast->ParentAccess );
append_fmt( & result, "%S : %s %S", ast->Name, access_level, ast->ParentType.to_string() ); append_fmt( result, "%S : %s %S", ast->Name, access_level, ast->ParentType.to_string() );
CodeType interface = cast(CodeType, ast->ParentType->Next); CodeType interface = cast(CodeType, ast->ParentType->Next);
if ( interface ) if ( interface )
append( & result, "\n" ); append( result, "\n" );
while ( interface ) while ( interface )
{ {
append_fmt( & result, ", %S", interface.to_string() ); append_fmt( result, ", %S", interface.to_string() );
interface = interface->Next ? cast(CodeType, interface->Next) : CodeType { nullptr }; interface = interface->Next ? cast(CodeType, interface->Next) : CodeType { nullptr };
} }
} }
else if ( ast->Name ) else if ( ast->Name )
{ {
append( & result, ast->Name ); append( result, ast->Name );
} }
if ( ast->InlineCmt ) if ( ast->InlineCmt )
{ {
append_fmt( & result, " // %S", ast->InlineCmt->Content ); append_fmt( result, " // %S", ast->InlineCmt->Content );
} }
append_fmt( & result, "\n{\n%S\n}", ast->Body.to_string() ); append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) );
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
append( & result, ";\n"); append( result, ";\n");
} }
void CodeClass::to_string_fwd( String& result ) void to_string_fwd( CodeClass self, String* result )
{ {
GEN_ASSERT(self.ast != nullptr);
AST_Class* ast = self.ast;
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
append( & result, "export " ); append( result, "export " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "class %S %S", ast->Attributes.to_string(), ast->Name ); append_fmt( result, "class %S %S", ast->Attributes.to_string(), ast->Name );
else append_fmt( & result, "class %S", ast->Name ); else append_fmt( result, "class %S", ast->Name );
// Check if it can have an end-statement // Check if it can have an end-statement
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
{ {
if ( ast->InlineCmt ) if ( ast->InlineCmt )
append_fmt( & result, "; // %S\n", ast->InlineCmt->Content ); append_fmt( result, "; // %S\n", ast->InlineCmt->Content );
else else
append( & result,";\n"); append( result,";\n");
} }
} }
@ -328,18 +339,18 @@ void CodeEnum::to_string_def( String& result )
append_fmt( & result, "%S : %S\n{\n%S\n}" append_fmt( & result, "%S : %S\n{\n%S\n}"
, ast->Name , ast->Name
, ast->UnderlyingType.to_string() , ast->UnderlyingType.to_string()
, ast->Body.to_string() , GEN_NS to_string(ast->Body)
); );
else if ( ast->UnderlyingTypeMacro ) else if ( ast->UnderlyingTypeMacro )
append_fmt( & result, "%S : %S\n{\n%S\n}" append_fmt( & result, "%S : %S\n{\n%S\n}"
, ast->Name , ast->Name
, GEN_NS to_string(ast->UnderlyingTypeMacro) , GEN_NS to_string(ast->UnderlyingTypeMacro)
, ast->Body.to_string() , GEN_NS to_string(ast->Body)
); );
else append_fmt( & result, "%S\n{\n%S\n}", ast->Name, ast->Body.to_string() ); else append_fmt( & result, "%S\n{\n%S\n}", ast->Name, GEN_NS to_string(ast->Body) );
} }
else append_fmt( & result, "enum %S\n{\n%S\n}", ast->Name, ast->Body.to_string() ); else append_fmt( & result, "enum %S\n{\n%S\n}", ast->Name, GEN_NS to_string(ast->Body) );
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
append( & result, ";\n"); append( & result, ";\n");
@ -383,16 +394,16 @@ void CodeEnum::to_string_class_def( String& result )
if ( ast->UnderlyingType ) if ( ast->UnderlyingType )
{ {
append_fmt( & result, "%S : %S\n{\n%S\n}", ast->Name, ast->UnderlyingType.to_string(), ast->Body.to_string() ); append_fmt( & result, "%S : %S\n{\n%S\n}", ast->Name, ast->UnderlyingType.to_string(), GEN_NS to_string(ast->Body) );
} }
else else
{ {
append_fmt( & result, "%S\n{\n%S\n}", ast->Name, ast->Body.to_string() ); append_fmt( & result, "%S\n{\n%S\n}", ast->Name, GEN_NS to_string(ast->Body) );
} }
} }
else else
{ {
append_fmt( & result, "enum class %S\n{\n%S\n}", ast->Body.to_string() ); append_fmt( & result, "enum class %S\n{\n%S\n}", GEN_NS to_string(ast->Body) );
} }
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
@ -428,7 +439,7 @@ String CodeExec::to_string()
void CodeExtern::to_string( String& result ) void CodeExtern::to_string( String& result )
{ {
if ( ast->Body ) if ( ast->Body )
append_fmt( & result, "extern \"%S\"\n{\n%S\n}\n", ast->Name, ast->Body.to_string() ); append_fmt( & result, "extern \"%S\"\n{\n%S\n}\n", ast->Name, GEN_NS to_string(ast->Body) );
else else
append_fmt( & result, "extern \"%S\"\n{}\n", ast->Name ); append_fmt( & result, "extern \"%S\"\n{}\n", ast->Name );
} }
@ -531,7 +542,7 @@ void CodeFn::to_string_def( String& result )
} }
} }
append_fmt( & result, "\n{\n%S\n}\n", ast->Body.to_string() ); append_fmt( & result, "\n{\n%S\n}\n", GEN_NS to_string(ast->Body) );
} }
void CodeFn::to_string_fwd( String& result ) void CodeFn::to_string_fwd( String& result )
@ -589,7 +600,7 @@ void CodeFn::to_string_fwd( String& result )
if ( ast->Specs && ast->Specs.has( ESpecifier::Pure ) >= 0 ) if ( ast->Specs && ast->Specs.has( ESpecifier::Pure ) >= 0 )
append( & result, " = 0;" ); append( & result, " = 0;" );
else if (ast->Body) else if (ast->Body)
append_fmt( & result, " = %S;", ast->Body.to_string() ); append_fmt( & result, " = %S;", GEN_NS to_string(ast->Body) );
if ( ast->InlineCmt ) if ( ast->InlineCmt )
append_fmt( & result, "; %S", ast->InlineCmt->Content ); append_fmt( & result, "; %S", ast->InlineCmt->Content );
@ -627,7 +638,7 @@ void CodeNS::to_string( String& result )
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
append( & result, "export " ); append( & result, "export " );
append_fmt( & result, "namespace %S\n{\n%S\n}\n", ast->Name , ast->Body.to_string() ); append_fmt( & result, "namespace %S\n{\n%S\n}\n", ast->Name , GEN_NS to_string(ast->Body) );
} }
String CodeOperator::to_string() String CodeOperator::to_string()
@ -698,7 +709,7 @@ void CodeOperator::to_string_def( String& result )
} }
append_fmt( & result, "\n{\n%S\n}\n" append_fmt( & result, "\n{\n%S\n}\n"
, ast->Body.to_string() , GEN_NS to_string(ast->Body)
); );
} }
@ -796,14 +807,14 @@ void CodeOpCast::to_string_def( String& result )
} }
} }
append_fmt( & result, "\n{\n%S\n}\n", ast->Body.to_string() ); append_fmt( & result, "\n{\n%S\n}\n", GEN_NS to_string(ast->Body) );
return; return;
} }
if ( ast->Name && length(ast->Name) ) if ( ast->Name && length(ast->Name) )
append_fmt( & result, "%Soperator %S()\n{\n%S\n}\n", ast->Name, ast->ValueType.to_string(), ast->Body.to_string() ); append_fmt( & result, "%Soperator %S()\n{\n%S\n}\n", ast->Name, ast->ValueType.to_string(), GEN_NS to_string(ast->Body) );
else else
append_fmt( & result, "operator %S()\n{\n%S\n}\n", ast->ValueType.to_string(), ast->Body.to_string() ); append_fmt( & result, "operator %S()\n{\n%S\n}\n", ast->ValueType.to_string(), GEN_NS to_string(ast->Body) );
} }
void CodeOpCast::to_string_fwd( String& result ) void CodeOpCast::to_string_fwd( String& result )
@ -1030,7 +1041,7 @@ void CodeStruct::to_string_def( String& result )
append_fmt( & result, " // %S", ast->InlineCmt->Content ); append_fmt( & result, " // %S", ast->InlineCmt->Content );
} }
append_fmt( & result, "\n{\n%S\n}", ast->Body.to_string() ); append_fmt( & result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) );
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
append( & result, ";\n"); append( & result, ";\n");
@ -1189,14 +1200,14 @@ void CodeUnion::to_string( String& result )
{ {
append_fmt( & result, "%S\n{\n%S\n}" append_fmt( & result, "%S\n{\n%S\n}"
, ast->Name , ast->Name
, ast->Body.to_string() , GEN_NS to_string(ast->Body)
); );
} }
else else
{ {
// Anonymous union // Anonymous union
append_fmt( & result, "\n{\n%S\n}" append_fmt( & result, "\n{\n%S\n}"
, ast->Body.to_string() , GEN_NS to_string(ast->Body)
); );
} }

View File

@ -3,6 +3,17 @@
#include "ast.hpp" #include "ast.hpp"
#endif #endif
void append ( CodeBody body, Code other );
void append ( CodeBody body, CodeBody other );
String to_string ( CodeBody body );
void to_string ( CodeBody body, String* result );
void to_string_export ( CodeBody body, String* result );
void add_interface( CodeClass self, CodeType interface );
String to_string ( CodeClass self );
void to_string_def( CodeClass self, String* result );
void to_string_fwd( CodeClass self, String* result );
#pragma region Code Types #pragma region Code Types
// These structs are not used at all by the C vairant. // These structs are not used at all by the C vairant.
#if ! GEN_COMPILER_C #if ! GEN_COMPILER_C
@ -10,31 +21,16 @@
struct CodeBody struct CodeBody
{ {
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 #if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code( CodeBody ); Using_Code( CodeBody );
void append( Code other ) void append( Code other ) { return GEN_NS append( *this, other ); }
{ void append( CodeBody body ) { return GEN_NS append(*this, body); }
GEN_ASSERT(other.ast != nullptr);
if (GEN_NS is_body(other)) {
append( cast(CodeBody, other) );
}
GEN_NS append( raw(), other.ast );
}
void append( CodeBody body )
{
for ( Code entry : body ) {
append( entry );
}
}
bool has_entries() { return GEN_NS has_entries(rcast( AST*, ast )); } bool has_entries() { return GEN_NS has_entries(rcast( AST*, ast )); }
AST* raw() { return rcast( AST*, ast ); }
String to_string(); String to_string() { return GEN_NS to_string(* this); }
void to_string( String& result ); void to_string( String& result ) { return GEN_NS to_string(* this, & result ); }
void to_string_export( String& result ); void to_string_export( String& result ) { return GEN_NS to_string_export(* this, & result); }
#endif #endif
Using_CodeOps( CodeBody ); Using_CodeOps( CodeBody );
@ -59,7 +55,7 @@ struct CodeBody
struct CodeClass struct CodeClass
{ {
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 #if GEN_SUPPORT_CPP_MEMBER_FEATURES || 0
Using_Code( CodeClass ); Using_Code( CodeClass );
void add_interface( CodeType interface ); void add_interface( CodeType interface );
@ -67,8 +63,6 @@ struct CodeClass
String to_string(); String to_string();
void to_string_def( String& result ); void to_string_def( String& result );
void to_string_fwd( String& result ); void to_string_fwd( String& result );
AST* raw() { return rcast( AST*, ast ); }
#endif #endif
Using_CodeOps( CodeClass ); Using_CodeOps( CodeClass );
@ -1054,5 +1048,9 @@ struct CodeVar
#undef Using_Code #undef Using_Code
#undef Using_CodeOps #undef Using_CodeOps
#if GEN_SUPPORT_CPP_REFERENCES
void to_string_export( CodeBody body, String& result ) { return to_string_export(body, & result); };
#endif
#endif //if ! GEN_COMPILER_C #endif //if ! GEN_COMPILER_C
#pragma endregion Code Types #pragma endregion Code Types

View File

@ -163,13 +163,35 @@ Code& Code::operator ++()
#pragma endregion Code #pragma endregion Code
inline inline
void CodeClass::add_interface( CodeType type ) void append( CodeBody self, Code other )
{ {
CodeType possible_slot = ast->ParentType; GEN_ASSERT(other.ast != nullptr);
if (is_body(other)) {
append( self, cast(CodeBody, other) );
return;
}
append( rcast(AST*, self.ast), other.ast );
}
inline
void append( CodeBody self, CodeBody body )
{
for ( Code entry : body ) {
append( self, entry );
}
}
inline
void add_interface( CodeClass self, CodeType type )
{
GEN_ASSERT(self.ast !=nullptr);
CodeType possible_slot = self->ParentType;
if ( possible_slot.ast ) if ( possible_slot.ast )
{ {
// Were adding an interface to parent type, so we need to make sure the parent type is public. // Were adding an interface to parent type, so we need to make sure the parent type is public.
ast->ParentAccess = AccessSpec_Public; self->ParentAccess = AccessSpec_Public;
// If your planning on adding a proper parent, // If your planning on adding a proper parent,
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. // then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
} }

View File

@ -605,7 +605,7 @@ CodeClass def_class( StrC name
{ {
for (s32 idx = 0; idx < num_interfaces; idx++ ) for (s32 idx = 0; idx < num_interfaces; idx++ )
{ {
result.add_interface( interfaces[idx] ); add_interface(result, interfaces[idx] );
} }
} }
@ -1565,7 +1565,7 @@ CodeBody def_class_body( s32 num, ... )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
va_end(va); va_end(va);
@ -1602,7 +1602,7 @@ CodeBody def_class_body( s32 num, Code* codes )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
@ -1636,7 +1636,7 @@ CodeBody def_enum_body( s32 num, ... )
return InvalidCode; return InvalidCode;
} }
result.append( entry ); append(result, entry );
} }
while ( num--, num > 0 ); while ( num--, num > 0 );
va_end(va); va_end(va);
@ -1668,7 +1668,7 @@ CodeBody def_enum_body( s32 num, Code* codes )
return InvalidCode; return InvalidCode;
} }
result.append( entry ); append(result, entry );
} }
while ( codes++, num--, num > 0 ); while ( codes++, num--, num > 0 );
@ -1706,7 +1706,7 @@ CodeBody def_export_body( s32 num, ... )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
va_end(va); va_end(va);
@ -1743,7 +1743,7 @@ CodeBody def_export_body( s32 num, Code* codes )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
@ -1781,7 +1781,7 @@ CodeBody def_extern_link_body( s32 num, ... )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
va_end(va); va_end(va);
@ -1818,7 +1818,7 @@ CodeBody def_extern_link_body( s32 num, Code* codes )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
@ -1858,7 +1858,7 @@ CodeBody def_function_body( s32 num, ... )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
va_end(va); va_end(va);
@ -1894,7 +1894,7 @@ CodeBody def_function_body( s32 num, Code* codes )
default: default:
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
@ -1926,7 +1926,7 @@ CodeBody def_global_body( s32 num, ... )
{ {
case Global_Body: case Global_Body:
// result.append( entry.code_cast<CodeBody>() ) ; // result.append( entry.code_cast<CodeBody>() ) ;
result.append( cast(CodeBody, entry) ) ; append( result, cast(CodeBody, entry) );
continue; continue;
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
@ -1937,7 +1937,7 @@ CodeBody def_global_body( s32 num, ... )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
va_end(va); va_end(va);
@ -1967,7 +1967,7 @@ CodeBody def_global_body( s32 num, Code* codes )
switch (entry->Type) switch (entry->Type)
{ {
case Global_Body: case Global_Body:
result.append( cast(CodeBody, entry) ); append(result, cast(CodeBody, entry) );
continue; continue;
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
@ -1978,7 +1978,7 @@ CodeBody def_global_body( s32 num, Code* codes )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
@ -2016,7 +2016,7 @@ CodeBody def_namespace_body( s32 num, ... )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
va_end(va); va_end(va);
@ -2052,7 +2052,7 @@ CodeBody def_namespace_body( s32 num, Code* codes )
default: break; default: break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
@ -2225,7 +2225,7 @@ CodeBody def_struct_body( s32 num, ... )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
va_end(va); va_end(va);
@ -2262,7 +2262,7 @@ CodeBody def_struct_body( s32 num, Code* codes )
break; break;
} }
result.append(entry); append(result, entry);
} }
while (num--, num > 0); while (num--, num > 0);
@ -2296,7 +2296,7 @@ CodeBody def_union_body( s32 num, ... )
return InvalidCode; return InvalidCode;
} }
result.append( entry ); append(result, entry );
} }
while ( num--, num > 0 ); while ( num--, num > 0 );
va_end(va); va_end(va);
@ -2328,7 +2328,7 @@ CodeBody def_union_body( s32 num, CodeUnion* codes )
return InvalidCode; return InvalidCode;
} }
result.append( entry ); append(result, entry );
} }
while ( codes++, num--, num > 0 ); while ( codes++, num--, num > 0 );

View File

@ -1115,7 +1115,7 @@ CodeBody parse_class_struct_body( TokType which, Token name )
return InvalidCode; return InvalidCode;
} }
result.append( member ); append(result, member );
} }
eat( TokType::BraceCurly_Close ); eat( TokType::BraceCurly_Close );
@ -1503,7 +1503,7 @@ CodeFn parse_function_after_name(
default: default:
{ {
log_failure("Body must be either of Function_Body or Untyped type, %s\n%s", body.debug_str(), Context.to_string()); log_failure("Body must be either of Function_Body or Untyped type, %s\n%s", debug_str(body), Context.to_string());
Context.pop(); Context.pop();
return InvalidCode; return InvalidCode;
} }
@ -1568,7 +1568,7 @@ Code parse_function_body()
if ( len > 0 ) if ( len > 0 )
{ {
result.append( def_execution( { len, start.Text } ) ); append( result, def_execution( { len, start.Text } ) );
} }
eat( TokType::BraceCurly_Close ); eat( TokType::BraceCurly_Close );
@ -1878,7 +1878,7 @@ CodeBody parse_global_nspace( CodeT which )
} }
// log_fmt("Global Body Member: %s", member->debug_str()); // log_fmt("Global Body Member: %s", member->debug_str());
result.append( member ); append(result, member );
} }
if ( which != Global_Body ) if ( which != Global_Body )
@ -3743,7 +3743,7 @@ CodeEnum parse_enum( bool inplace_def )
return InvalidCode; return InvalidCode;
} }
body.append( member ); append(body, member );
} }
eat( TokType::BraceCurly_Close ); eat( TokType::BraceCurly_Close );
@ -5187,7 +5187,7 @@ CodeUnion parse_union( bool inplace_def )
} }
if ( member ) if ( member )
body.append( member ); append(body, member );
} }
// <ModuleFlags> union <Attributes> <Name> { <Body> // <ModuleFlags> union <Attributes> <Name> { <Body>

View File

@ -428,29 +428,29 @@ CodeBody gen_ast_inlines()
CodeBody impl_code_using = parse_global_body( token_fmt( "typename", StrC name(CodeUsing), code_impl_tmpl )); CodeBody impl_code_using = parse_global_body( token_fmt( "typename", StrC name(CodeUsing), code_impl_tmpl ));
CodeBody impl_code_var = parse_global_body( token_fmt( "typename", StrC name(CodeVar), code_impl_tmpl )); CodeBody impl_code_var = parse_global_body( token_fmt( "typename", StrC name(CodeVar), code_impl_tmpl ));
impl_code_attr. append( parse_global_body( token_fmt( "typename", StrC name(Attributes), codetype_impl_tmpl ))); append(impl_code_attr, parse_global_body( token_fmt( "typename", StrC name(Attributes), codetype_impl_tmpl )));
impl_code_cmt. append( parse_global_body( token_fmt( "typename", StrC name(Comment), codetype_impl_tmpl ))); append(impl_code_cmt, parse_global_body( token_fmt( "typename", StrC name(Comment), codetype_impl_tmpl )));
impl_code_constr. append( parse_global_body( token_fmt( "typename", StrC name(Constructor), codetype_impl_tmpl ))); append(impl_code_constr, parse_global_body( token_fmt( "typename", StrC name(Constructor), codetype_impl_tmpl )));
impl_code_define. append( parse_global_body( token_fmt( "typename", StrC name(Define), codetype_impl_tmpl ))); append(impl_code_define, parse_global_body( token_fmt( "typename", StrC name(Define), codetype_impl_tmpl )));
impl_code_destruct.append( parse_global_body( token_fmt( "typename", StrC name(Destructor), codetype_impl_tmpl ))); append(impl_code_destruct, parse_global_body( token_fmt( "typename", StrC name(Destructor), codetype_impl_tmpl )));
impl_code_enum. append( parse_global_body( token_fmt( "typename", StrC name(Enum), codetype_impl_tmpl ))); append(impl_code_enum, parse_global_body( token_fmt( "typename", StrC name(Enum), codetype_impl_tmpl )));
impl_code_exec. append( parse_global_body( token_fmt( "typename", StrC name(Exec), codetype_impl_tmpl ))); append(impl_code_exec, parse_global_body( token_fmt( "typename", StrC name(Exec), codetype_impl_tmpl )));
impl_code_extern. append( parse_global_body( token_fmt( "typename", StrC name(Extern), codetype_impl_tmpl ))); append(impl_code_extern, parse_global_body( token_fmt( "typename", StrC name(Extern), codetype_impl_tmpl )));
impl_code_include. append( parse_global_body( token_fmt( "typename", StrC name(Include), codetype_impl_tmpl ))); append(impl_code_include, parse_global_body( token_fmt( "typename", StrC name(Include), codetype_impl_tmpl )));
impl_code_friend. append( parse_global_body( token_fmt( "typename", StrC name(Friend), codetype_impl_tmpl ))); append(impl_code_friend, parse_global_body( token_fmt( "typename", StrC name(Friend), codetype_impl_tmpl )));
impl_code_fn. append( parse_global_body( token_fmt( "typename", StrC name(Fn), codetype_impl_tmpl ))); append(impl_code_fn, parse_global_body( token_fmt( "typename", StrC name(Fn), codetype_impl_tmpl )));
impl_code_module. append( parse_global_body( token_fmt( "typename", StrC name(Module), codetype_impl_tmpl ))); append(impl_code_module, parse_global_body( token_fmt( "typename", StrC name(Module), codetype_impl_tmpl )));
impl_code_ns. append( parse_global_body( token_fmt( "typename", StrC name(NS), codetype_impl_tmpl ))); append(impl_code_ns, parse_global_body( token_fmt( "typename", StrC name(NS), codetype_impl_tmpl )));
impl_code_op. append( parse_global_body( token_fmt( "typename", StrC name(Operator), codetype_impl_tmpl ))); append(impl_code_op, parse_global_body( token_fmt( "typename", StrC name(Operator), codetype_impl_tmpl )));
impl_code_opcast. append( parse_global_body( token_fmt( "typename", StrC name(OpCast), codetype_impl_tmpl ))); append(impl_code_opcast, parse_global_body( token_fmt( "typename", StrC name(OpCast), codetype_impl_tmpl )));
impl_code_pragma . append( parse_global_body( token_fmt( "typename", StrC name(Pragma), codetype_impl_tmpl ))); append(impl_code_pragma, parse_global_body( token_fmt( "typename", StrC name(Pragma), codetype_impl_tmpl )));
impl_code_precond. append( parse_global_body( token_fmt( "typename", StrC name(PreprocessCond), codetype_impl_tmpl ))); append(impl_code_precond, parse_global_body( token_fmt( "typename", StrC name(PreprocessCond), codetype_impl_tmpl )));
impl_code_tmpl. append( parse_global_body( token_fmt( "typename", StrC name(Template), codetype_impl_tmpl ))); append(impl_code_tmpl, parse_global_body( token_fmt( "typename", StrC name(Template), codetype_impl_tmpl )));
impl_code_type. append( parse_global_body( token_fmt( "typename", StrC name(Type), codetype_impl_tmpl ))); append(impl_code_type, parse_global_body( token_fmt( "typename", StrC name(Type), codetype_impl_tmpl )));
impl_code_typedef. append( parse_global_body( token_fmt( "typename", StrC name(Typedef), codetype_impl_tmpl ))); append(impl_code_typedef, parse_global_body( token_fmt( "typename", StrC name(Typedef), codetype_impl_tmpl )));
impl_code_union. append( parse_global_body( token_fmt( "typename", StrC name(Union), codetype_impl_tmpl ))); append(impl_code_union, parse_global_body( token_fmt( "typename", StrC name(Union), codetype_impl_tmpl )));
impl_code_using. append( parse_global_body( token_fmt( "typename", StrC name(Using), codetype_impl_tmpl ))); append(impl_code_using, parse_global_body( token_fmt( "typename", StrC name(Using), codetype_impl_tmpl )));
impl_code_var. append( parse_global_body( token_fmt( "typename", StrC name(Var), codetype_impl_tmpl ))); append(impl_code_var, parse_global_body( token_fmt( "typename", StrC name(Var), codetype_impl_tmpl )));
char const* cast_tmpl = stringize( char const* cast_tmpl = stringize(
inline AST::operator Code<typename>() inline AST::operator Code<typename>()