From 5b0079fb0c8e7f9004649381fd1edc3b3aa66734 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 2 Dec 2024 03:18:52 -0500 Subject: [PATCH] ast interface uage reductions --- docs/AST_Types.md | 2 +- docs/Readme.md | 2 +- project/auxillary/builder.cpp | 2 +- project/components/ast.cpp | 171 +++++++++++----------- project/components/ast.hpp | 81 +++++----- project/components/ast_types.hpp | 122 +++++++-------- project/components/code_serialization.cpp | 24 +-- project/components/code_types.hpp | 8 +- project/components/gen/ast_inlines.hpp | 58 ++++---- project/components/interface.upfront.cpp | 18 +-- project/helpers/helper.hpp | 2 +- 11 files changed, 241 insertions(+), 249 deletions(-) diff --git a/docs/AST_Types.md b/docs/AST_Types.md index 3f96ceb..4fce55f 100644 --- a/docs/AST_Types.md +++ b/docs/AST_Types.md @@ -552,7 +552,7 @@ Serialization: Fields: ```cpp -SpecifierT ArrSpecs[ AST::ArrSpecs_Cap ]; +SpecifierT ArrSpecs[ AST_ArrSpecs_Cap ]; CodeSpecifiers NextSpecs; Code Prev; Code Next; diff --git a/docs/Readme.md b/docs/Readme.md index 4621d56..2ba612f 100644 --- a/docs/Readme.md +++ b/docs/Readme.md @@ -101,7 +101,7 @@ union { }; StringCached Content; // Attributes, Comment, Execution, Include struct { - SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers + SpecifierT ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers AST* NextSpecs; // Specifiers }; }; diff --git a/project/auxillary/builder.cpp b/project/auxillary/builder.cpp index b283e96..1960306 100644 --- a/project/auxillary/builder.cpp +++ b/project/auxillary/builder.cpp @@ -26,7 +26,7 @@ void Builder::pad_lines( s32 num ) void Builder::print( Code code ) { - String str = code->to_string(); + String str = to_string(code); // const ssize len = str.length(); // log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data ); append( & Buffer, str ); diff --git a/project/components/ast.cpp b/project/components/ast.cpp index 6948866..128c788 100644 --- a/project/components/ast.cpp +++ b/project/components/ast.cpp @@ -14,7 +14,7 @@ char const* debug_str(AST* self) String* result = & result_stack; if ( self->Parent ) - append_fmt( result, "\n\tParent : %S %S", self->Parent->type_str(), self->Name ? self->Name : "" ); + append_fmt( result, "\n\tParent : %S %S", type_str(self->Parent), self->Name ? self->Name : "" ); else append_fmt( result, "\n\tParent : %S", "Null" ); @@ -372,19 +372,20 @@ AST* duplicate(AST* self) return result; } -String AST::to_string() +String to_string(AST* self) { String result = string_make( GlobalAllocator, "" ); - to_string( result ); + GEN_NS to_string( self, & result ); return result; } -void AST::to_string( String& result ) +void to_string( AST* self, String* result ) { + GEN_ASSERT(self != nullptr); local_persist thread_local char SerializationLevel = 0; - switch ( Type ) + switch ( self->Type ) { using namespace ECode; @@ -392,191 +393,191 @@ void AST::to_string( String& result ) #ifdef GEN_DONT_ALLOW_INVALID_CODE log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name ); #else - GEN_NS append_fmt( & result, "Invalid Code!" ); + append_fmt( result, "Invalid Code!" ); #endif break; case NewLine: - GEN_NS append( & result,"\n"); + append( result,"\n"); break; case Untyped: case Execution: case Comment: case PlatformAttributes: - GEN_NS append( & result, Content ); + append( result, self->Content ); break; case Access_Private: case Access_Protected: case Access_Public: - GEN_NS append( & result, Name ); + append( result, self->Name ); break; case Class: - code_cast().to_string_def( result ); + cast(CodeClass, {self}).to_string_def( * result ); break; case Class_Fwd: - code_cast().to_string_fwd( result ); + cast(CodeClass, {self}).to_string_fwd( * result ); break; case Constructor: - code_cast().to_string_def( result ); + cast(CodeConstructor, {self}).to_string_def( * result ); break; case Constructor_Fwd: - code_cast().to_string_fwd( result ); + cast(CodeConstructor, {self}).to_string_fwd( * result ); break; case Destructor: - code_cast().to_string_def( result ); + cast(CodeDestructor, {self}).to_string_def( * result ); break; case Destructor_Fwd: - code_cast().to_string_fwd( result ); + cast(CodeDestructor, {self}).to_string_fwd( * result ); break; case Enum: - code_cast().to_string_def( result ); + cast(CodeEnum, {self}).to_string_def( * result ); break; case Enum_Fwd: - code_cast().to_string_fwd( result ); + cast(CodeEnum, {self}).to_string_fwd( * result ); break; case Enum_Class: - code_cast().to_string_class_def( result ); + cast(CodeEnum, {self}).to_string_class_def( * result ); break; case Enum_Class_Fwd: - code_cast().to_string_class_fwd( result ); + cast(CodeEnum, {self}).to_string_class_fwd( * result ); break; case Export_Body: - code_cast().to_string_export( result ); + cast(CodeBody, {self}).to_string_export( * result ); break; case Extern_Linkage: - code_cast().to_string( result ); + cast(CodeExtern, {self}).to_string( * result ); break; case Friend: - code_cast().to_string( result ); + cast(CodeFriend, {self}).to_string( * result ); break; case Function: - code_cast().to_string_def( result ); + cast(CodeFn, {self}).to_string_def( * result ); break; case Function_Fwd: - code_cast().to_string_fwd( result ); + cast(CodeFn, {self}).to_string_fwd( * result ); break; case Module: - code_cast().to_string( result ); + cast(CodeModule, {self}).to_string( * result ); break; case Namespace: - code_cast().to_string( result ); + cast(CodeNS, {self}).to_string( * result ); break; case Operator: case Operator_Member: - code_cast().to_string_def( result ); + cast(CodeOperator, {self}).to_string_def( * result ); break; case Operator_Fwd: case Operator_Member_Fwd: - code_cast().to_string_fwd( result ); + cast(CodeOperator, {self}).to_string_fwd( * result ); break; case Operator_Cast: - code_cast().to_string_def( result ); + cast(CodeOpCast, {self}).to_string_def( * result ); break; case Operator_Cast_Fwd: - code_cast().to_string_fwd( result ); + cast(CodeOpCast, {self}).to_string_fwd( * result ); break; case Parameters: - code_cast().to_string( result ); + cast(CodeParam, {self}).to_string( * result ); break; case Preprocess_Define: - code_cast().to_string( result ); + cast(CodeDefine, {self}).to_string( * result ); break; case Preprocess_If: - code_cast().to_string_if( result ); + cast(CodePreprocessCond, {self}).to_string_if( * result ); break; case Preprocess_IfDef: - code_cast().to_string_ifdef( result ); + cast(CodePreprocessCond, {self}).to_string_ifdef( * result ); break; case Preprocess_IfNotDef: - code_cast().to_string_ifndef( result ); + cast(CodePreprocessCond, {self}).to_string_ifndef( * result ); break; case Preprocess_Include: - code_cast().to_string( result ); + cast(CodeInclude, {self}).to_string( * result ); break; case Preprocess_ElIf: - code_cast().to_string_elif( result ); + cast(CodePreprocessCond, {self}).to_string_elif( * result ); break; case Preprocess_Else: - code_cast().to_string_else( result ); + cast(CodePreprocessCond, {self}).to_string_else( * result ); break; case Preprocess_EndIf: - code_cast().to_string_endif( result ); + cast(CodePreprocessCond, {self}).to_string_endif( * result ); break; case Preprocess_Pragma: - code_cast().to_string( result ); + cast(CodePragma, {self}).to_string( * result ); break; case Specifiers: - code_cast().to_string( result ); + cast(CodeSpecifiers, {self}).to_string( * result ); break; case Struct: - code_cast().to_string_def( result ); + cast(CodeStruct, {self}).to_string_def( * result ); break; case Struct_Fwd: - code_cast().to_string_fwd( result ); + cast(CodeStruct, {self}).to_string_fwd( * result ); break; case Template: - code_cast().to_string( result ); + cast(CodeTemplate, {self}).to_string( * result ); break; case Typedef: - code_cast().to_string( result ); + cast(CodeTypedef, {self}).to_string( * result ); break; case Typename: - code_cast().to_string( result ); + cast(CodeType, {self}).to_string( * result ); break; case Union: - code_cast().to_string( result ); + cast(CodeUnion, {self}).to_string( * result ); break; case Using: - code_cast().to_string( result ); + cast(CodeUsing, {self}).to_string( * result ); break; case Using_Namespace: - code_cast().to_string_ns( result ); + cast(CodeUsing, {self}).to_string_ns( * result ); break; case Variable: - code_cast().to_string( result ); + cast(CodeVar, {self}).to_string( * result ); break; case Enum_Body: @@ -587,7 +588,7 @@ void AST::to_string( String& result ) case Namespace_Body: case Struct_Body: case Union_Body: - code_cast().to_string( result ); + cast(CodeBody, {self}).to_string( * result ); break; } } @@ -611,7 +612,7 @@ bool is_equal( AST* self, AST* other ) { log_fmt("AST::is_equal: Type check failure with other\nAST: %S\nOther: %S" , debug_str(self) - , other->debug_str() + ,debug_str(other) ); return false; @@ -628,7 +629,7 @@ bool is_equal( AST* self, AST* other ) "AST : %S\n" \ "Other: %S\n" \ , debug_str(self) \ - , other->debug_str() \ + ,debug_str(other) \ ); \ \ return false; \ @@ -641,7 +642,7 @@ bool is_equal( AST* self, AST* other ) "AST : %S\n" \ "Other: %S\n" \ , debug_str(self) \ - , other->debug_str() \ + ,debug_str(other) \ ); \ \ return false; \ @@ -654,7 +655,7 @@ bool is_equal( AST* self, AST* other ) "AST : %S\n" \ "Other: %S\n" \ , debug_str(self) \ - , other->debug_str() \ + ,debug_str(other) \ ); \ \ log_fmt("Content cannot be trusted to be unique with this check " \ @@ -676,14 +677,14 @@ bool is_equal( AST* self, AST* other ) "Other: %s\n" \ "For ast member: %s\n" \ , debug_str(self) \ - , other->debug_str() \ - , self->ast->debug_str() \ + , debug_str(other) \ + , debug_str(self->ast) \ ); \ \ return false; \ } \ \ - if ( ! self->ast->is_equal( other->ast ) ) \ + if ( ! is_equal(self->ast, other->ast ) ) \ { \ log_fmt( "\nAST::is_equal: Failed for " #ast"\n" \ "AST : %S\n" \ @@ -691,9 +692,9 @@ bool is_equal( AST* self, AST* other ) "For ast member: %S\n" \ "other's ast member: %S\n" \ , debug_str(self) \ - , other->debug_str() \ - , self->ast->debug_str() \ - , other->ast->debug_str() \ + , debug_str(other) \ + , debug_str(self->ast) \ + , debug_str(other->ast) \ ); \ \ return false; \ @@ -921,7 +922,7 @@ bool is_equal( AST* self, AST* other ) "AST : %S\n" "Other: %S\n" "For ast member: %S\n" - , curr->debug_str() + , debug_str(curr) ); return false; @@ -935,14 +936,14 @@ bool is_equal( AST* self, AST* other ) "For ast member: %S\n" "other's ast member: %S\n" , debug_str(self) - , other->debug_str() - , curr->debug_str() - , curr_other->debug_str() + , debug_str(other) + , debug_str(curr) + , debug_str(curr_other) ); return false; } - if ( curr->ValueType && ! curr->ValueType->is_equal(curr_other->ValueType) ) + if ( curr->ValueType && ! is_equal(curr->ValueType, curr_other->ValueType) ) { log_fmt( "\nAST::is_equal: Failed for parameter value type check\n" "AST : %S\n" @@ -950,14 +951,14 @@ bool is_equal( AST* self, AST* other ) "For ast member: %S\n" "other's ast member: %S\n" , debug_str(self) - , other->debug_str() - , curr->debug_str() - , curr_other->debug_str() + , debug_str(other) + , debug_str(curr) + , debug_str(curr_other) ); return false; } - if ( curr->Value && ! curr->Value->is_equal(curr_other->Value) ) + if ( curr->Value && ! is_equal(curr->Value, curr_other->Value) ) { log_fmt( "\nAST::is_equal: Failed for parameter value check\n" "AST : %S\n" @@ -965,9 +966,9 @@ bool is_equal( AST* self, AST* other ) "For ast member: %S\n" "other's ast member: %S\n" , debug_str(self) - , other->debug_str() - , curr->debug_str() - , curr_other->debug_str() + , debug_str(other) + , debug_str(curr) + , debug_str(curr_other) ); return false; } @@ -1113,13 +1114,13 @@ bool is_equal( AST* self, AST* other ) "AST : %S\n" "Other: %S\n" "For ast member: %S\n" - , curr->debug_str() + , debug_str(curr) ); return false; } - if ( ! curr->is_equal( curr_other ) ) + if ( ! is_equal( curr, curr_other ) ) { log_fmt( "\nAST::is_equal: Failed for body\n" "AST : %S\n" @@ -1127,9 +1128,9 @@ bool is_equal( AST* self, AST* other ) "For ast member: %S\n" "other's ast member: %S\n" , debug_str(self) - , other->debug_str() - , curr->debug_str() - , curr_other->debug_str() + , debug_str(other) + , debug_str(curr) + , debug_str(curr_other) ); return false; @@ -1152,14 +1153,14 @@ bool is_equal( AST* self, AST* other ) return true; } -bool AST::validate_body() +bool validate_body(AST* self) { using namespace ECode; #define CheckEntries( Unallowed_Types ) \ do \ { \ - for ( Code entry : code_cast() ) \ + for ( Code entry : cast(CodeBody, {self}) ) \ { \ switch ( entry->Type ) \ { \ @@ -1171,13 +1172,13 @@ bool AST::validate_body() } \ while (0); - switch ( Type ) + switch ( self->Type ) { case Class_Body: CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES ); break; case Enum_Body: - for ( Code entry : code_cast() ) + for ( Code entry : cast(CodeBody, {self}) ) { if ( entry->Type != Untyped ) { @@ -1196,7 +1197,7 @@ bool AST::validate_body() CheckEntries( GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES ); break; case Global_Body: - for (Code entry : code_cast()) + for (Code entry : cast(CodeBody, {self})) { switch (entry->Type) { @@ -1229,7 +1230,7 @@ bool AST::validate_body() CheckEntries( GEN_AST_BODY_STRUCT_UNALLOWED_TYPES ); break; case Union_Body: - for ( Code entry : Body->code_cast() ) + for ( Code entry : cast(CodeBody, {self->Body}) ) { if ( entry->Type != Untyped ) { @@ -1240,7 +1241,7 @@ bool AST::validate_body() break; default: - log_failure( "AST::validate_body: Invalid this AST does not have a body %s", debug_str() ); + log_failure( "AST::validate_body: Invalid this AST does not have a body %s", debug_str(self) ); return false; } diff --git a/project/components/ast.hpp b/project/components/ast.hpp index 9e8f8d7..4923199 100644 --- a/project/components/ast.hpp +++ b/project/components/ast.hpp @@ -270,15 +270,17 @@ 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 ); -bool is_equal ( AST* self, AST* other ); -String to_string ( AST* self ); -char const* type_str ( AST* self ); +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 ); +bool is_equal ( AST* self, AST* other ); +String to_string ( AST* self ); +void to_string ( AST* self, String* result ); +char const* type_str ( AST* self ); +bool validate_body( AST* self ); #if GEN_CPP_SUPPORT_REFERENCES void append ( AST& self, AST& other ) { return append(& self, & other); } @@ -289,33 +291,40 @@ String to_string( AST& self ) { return to_string( & self ); } char const* type_str ( AST& self ) { return type_str( & self ); } #endif +constexpr static +int AST_ArrSpecs_Cap = +( + AST_POD_Size + - sizeof(AST*) * 3 + - sizeof(parser::Token*) + - sizeof(AST*) + - sizeof(StringCached) + - sizeof(CodeT) + - sizeof(ModuleFlag) + - sizeof(int) +) +/ sizeof(int) - 1; // -1 for 4 extra bytes + /* Simple AST POD with functionality to seralize into C++ syntax. */ struct AST { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 +#if GEN_SUPPORT_CPP_MEMBER_FEATURES # pragma region Member Functions - 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(); + 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() { return GEN_NS has_entries(this); } bool is_equal ( AST* other ) { return GEN_NS is_equal(this, other); } bool is_body() { return GEN_NS is_body(this); } char const* type_str() { return GEN_NS type_str(this); } - bool validate_body(); + bool validate_body() { return GEN_NS validate_body(this); } - String to_string(); //{ return GEN_NS to_string(this); } + String to_string() { return GEN_NS to_string(this); } + void to_string( String& result ) { return GEN_NS to_string(this, & result); } - template< class Type > - forceinline Type code_cast() - { - return * this; - } - - neverinline - void to_string( String& result ); # pragma endregion Member Functions #endif @@ -350,20 +359,6 @@ struct AST operator CodeUsing(); operator CodeVar(); - constexpr static - int ArrSpecs_Cap = - ( - AST_POD_Size - - sizeof(AST*) * 3 - - sizeof(parser::Token*) - - sizeof(AST*) - - sizeof(StringCached) - - sizeof(CodeT) - - sizeof(ModuleFlag) - - sizeof(int) - ) - / sizeof(int) - 1; // -1 for 4 extra bytes - union { struct { @@ -396,7 +391,7 @@ struct AST }; StringCached Content; // Attributes, Comment, Execution, Include struct { - SpecifierT ArrSpecs[ArrSpecs_Cap]; // Specifiers + SpecifierT ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used. }; }; @@ -460,7 +455,7 @@ struct AST_POD }; StringCached Content; // Attributes, Comment, Execution, Include struct { - SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers + SpecifierT ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used. }; }; @@ -489,10 +484,6 @@ struct AST_POD }; }; - -// 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. static_assert( sizeof(AST) == sizeof(AST_POD), "ERROR: AST IS NOT POD" ); diff --git a/project/components/ast_types.hpp b/project/components/ast_types.hpp index e4e5295..d91db61 100644 --- a/project/components/ast_types.hpp +++ b/project/components/ast_types.hpp @@ -12,7 +12,7 @@ struct AST_Body { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; Code Front; Code Back; parser::Token* Tok; @@ -27,7 +27,7 @@ static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same struct AST_Attributes { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; StringCached Content; }; Code Prev; @@ -44,7 +44,7 @@ static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is struct AST_BaseClass { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; Code Prev; Code Next; @@ -60,7 +60,7 @@ static_assert( sizeof(AST_BaseClass) == sizeof(AST), "ERROR: AST_BaseClass is no struct AST_Comment { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; StringCached Content; }; Code Prev; @@ -76,7 +76,7 @@ static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not th struct AST_Class { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; // Only supported by forward declarations @@ -102,7 +102,7 @@ static_assert( sizeof(AST_Class) == sizeof(AST), "ERROR: AST_Class is not the sa struct AST_Constructor { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; // Only supported by forward declarations @@ -127,7 +127,7 @@ static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor i struct AST_Define { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; StringCached Content; }; Code Prev; @@ -143,7 +143,7 @@ static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the struct AST_Destructor { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -167,7 +167,7 @@ static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is struct AST_Enum { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -193,7 +193,7 @@ static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same struct AST_Exec { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; StringCached Content; }; Code Prev; @@ -210,7 +210,7 @@ static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same struct AST_Expr { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -225,7 +225,7 @@ static_assert( sizeof(AST_Expr) == sizeof(AST), "ERROR: AST_Expr is not the same struct AST_Expr_Assign { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -240,7 +240,7 @@ static_assert( sizeof(AST_Expr_Assign) == sizeof(AST), "ERROR: AST_Expr_Assign i struct AST_Expr_Alignof { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -255,7 +255,7 @@ static_assert( sizeof(AST_Expr_Alignof) == sizeof(AST), "ERROR: AST_Expr_Alignof struct AST_Expr_Binary { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -270,7 +270,7 @@ static_assert( sizeof(AST_Expr_Binary) == sizeof(AST), "ERROR: AST_Expr_Binary i struct AST_Expr_CStyleCast { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -285,7 +285,7 @@ static_assert( sizeof(AST_Expr_CStyleCast) == sizeof(AST), "ERROR: AST_Expr_CSty struct AST_Expr_FunctionalCast { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -300,7 +300,7 @@ static_assert( sizeof(AST_Expr_FunctionalCast) == sizeof(AST), "ERROR: AST_Expr_ struct AST_Expr_CppCast { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -315,7 +315,7 @@ static_assert( sizeof(AST_Expr_CppCast) == sizeof(AST), "ERROR: AST_Expr_CppCast struct AST_Expr_ProcCall { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -330,7 +330,7 @@ static_assert( sizeof(AST_Expr_ProcCall) == sizeof(AST), "ERROR: AST_Expr_Identi struct AST_Expr_Decltype { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -345,7 +345,7 @@ static_assert( sizeof(AST_Expr_Decltype) == sizeof(AST), "ERROR: AST_Expr_Declty struct AST_Expr_Comma { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -360,7 +360,7 @@ static_assert( sizeof(AST_Expr_Comma) == sizeof(AST), "ERROR: AST_Expr_Comma is struct AST_Expr_AMS { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -375,7 +375,7 @@ static_assert( sizeof(AST_Expr_AMS) == sizeof(AST), "ERROR: AST_Expr_AMS is not struct AST_Expr_Sizeof { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -390,7 +390,7 @@ static_assert( sizeof(AST_Expr_Sizeof) == sizeof(AST), "ERROR: AST_Expr_Sizeof i struct AST_Expr_Subscript { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -405,7 +405,7 @@ static_assert( sizeof(AST_Expr_Subscript) == sizeof(AST), "ERROR: AST_Expr_Subsc struct AST_Expr_Ternary { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -420,7 +420,7 @@ static_assert( sizeof(AST_Expr_Ternary) == sizeof(AST), "ERROR: AST_Expr_Ternary struct AST_Expr_UnaryPrefix { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -435,7 +435,7 @@ static_assert( sizeof(AST_Expr_UnaryPrefix) == sizeof(AST), "ERROR: AST_Expr_Una struct AST_Expr_UnaryPostfix { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -450,7 +450,7 @@ static_assert( sizeof(AST_Expr_UnaryPostfix) == sizeof(AST), "ERROR: AST_Expr_Un struct AST_Expr_Element { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -466,7 +466,7 @@ static_assert( sizeof(AST_Expr_Element) == sizeof(AST), "ERROR: AST_Expr_Element struct AST_Extern { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; @@ -487,7 +487,7 @@ static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the struct AST_Include { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; StringCached Content; }; Code Prev; @@ -503,7 +503,7 @@ static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not th struct AST_Friend { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -525,7 +525,7 @@ static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the struct AST_Fn { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -550,7 +550,7 @@ static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same siz struct AST_Module { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; Code Prev; Code Next; parser::Token* Tok; @@ -565,7 +565,7 @@ static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the struct AST_NS { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; CodeBody Body; @@ -586,7 +586,7 @@ static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same siz struct AST_Operator { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -612,7 +612,7 @@ static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not struct AST_OpCast { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -637,7 +637,7 @@ static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the struct AST_Param { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; @@ -662,7 +662,7 @@ static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the sa struct AST_Pragma { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; StringCached Content; }; Code Prev; @@ -678,7 +678,7 @@ static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the struct AST_PreprocessCond { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; StringCached Content; }; Code Prev; @@ -693,7 +693,7 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess struct AST_Specifiers { - SpecifierT ArrSpecs[ AST::ArrSpecs_Cap ]; + SpecifierT ArrSpecs[ AST_ArrSpecs_Cap ]; CodeSpecifiers NextSpecs; Code Prev; Code Next; @@ -710,7 +710,7 @@ static_assert( sizeof(AST_Specifiers) == sizeof(AST), "ERROR: AST_Specifier is n struct AST_Stmt { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -725,7 +725,7 @@ static_assert( sizeof(AST_Stmt) == sizeof(AST), "ERROR: AST_Stmt is not the same struct AST_Stmt_Break { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -740,7 +740,7 @@ static_assert( sizeof(AST_Stmt_Break) == sizeof(AST), "ERROR: AST_Stmt_Break is struct AST_Stmt_Case { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -755,7 +755,7 @@ static_assert( sizeof(AST_Stmt_Case) == sizeof(AST), "ERROR: AST_Stmt_Case is no struct AST_Stmt_Continue { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -770,7 +770,7 @@ static_assert( sizeof(AST_Stmt_Continue) == sizeof(AST), "ERROR: AST_Stmt_Contin struct AST_Stmt_Decl { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -785,7 +785,7 @@ static_assert( sizeof(AST_Stmt_Decl) == sizeof(AST), "ERROR: AST_Stmt_Decl is no struct AST_Stmt_Do { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -800,7 +800,7 @@ static_assert( sizeof(AST_Stmt_Do) == sizeof(AST), "ERROR: AST_Stmt_Do is not th struct AST_Stmt_Expr { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -815,7 +815,7 @@ static_assert( sizeof(AST_Stmt_Expr) == sizeof(AST), "ERROR: AST_Stmt_Expr is no struct AST_Stmt_Else { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -830,7 +830,7 @@ static_assert( sizeof(AST_Stmt_Else) == sizeof(AST), "ERROR: AST_Stmt_Else is no struct AST_Stmt_If { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -845,7 +845,7 @@ static_assert( sizeof(AST_Stmt_If) == sizeof(AST), "ERROR: AST_Stmt_If is not th struct AST_Stmt_For { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -860,7 +860,7 @@ static_assert( sizeof(AST_Stmt_For) == sizeof(AST), "ERROR: AST_Stmt_For is not struct AST_Stmt_Goto { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -875,7 +875,7 @@ static_assert( sizeof(AST_Stmt_Goto) == sizeof(AST), "ERROR: AST_Stmt_Goto is no struct AST_Stmt_Label { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -890,7 +890,7 @@ static_assert( sizeof(AST_Stmt_Label) == sizeof(AST), "ERROR: AST_Stmt_Label is struct AST_Stmt_Switch { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -905,7 +905,7 @@ static_assert( sizeof(AST_Stmt_Switch) == sizeof(AST), "ERROR: AST_Stmt_Switch i struct AST_Stmt_While { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; }; CodeExpr Prev; CodeExpr Next; @@ -921,7 +921,7 @@ static_assert( sizeof(AST_Stmt_While) == sizeof(AST), "ERROR: AST_Stmt_While is struct AST_Struct { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -947,7 +947,7 @@ static_assert( sizeof(AST_Struct) == sizeof(AST), "ERROR: AST_Struct is not the struct AST_Template { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; @@ -972,7 +972,7 @@ static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not struct AST_Type { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { char _PAD_INLINE_CMT_[ sizeof(AST*) ]; @@ -1000,7 +1000,7 @@ static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same struct AST_Type { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { char _PAD_INLINE_CMT_[ sizeof(AST*) ]; @@ -1026,7 +1026,7 @@ static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same struct AST_Typedef { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -1049,7 +1049,7 @@ static_assert( sizeof(AST_Typedef) == sizeof(AST), "ERROR: AST_Typedef is not th struct AST_Union { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { char _PAD_INLINE_CMT_[ sizeof(AST*) ]; @@ -1073,7 +1073,7 @@ static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the sa struct AST_Using { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; @@ -1097,7 +1097,7 @@ static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the sa struct AST_Var { union { - char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; + char _PAD_[ sizeof(SpecifierT) * AST_ArrSpecs_Cap + sizeof(AST*) ]; struct { CodeComment InlineCmt; diff --git a/project/components/code_serialization.cpp b/project/components/code_serialization.cpp index 734fd24..08323d9 100644 --- a/project/components/code_serialization.cpp +++ b/project/components/code_serialization.cpp @@ -10,7 +10,7 @@ String to_string(Code self) log_failure( "Code::to_string: Cannot convert code to string, AST is null!" ); return { nullptr }; } - return rcast( AST*, self.ast )->to_string(); + return to_string( self.ast ); } String CodeAttributes::to_string() @@ -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->code_cast< CodeType >(); + CodeType interface = cast(CodeType, ast->ParentType->Next); if ( interface ) append( & result, "\n" ); while ( interface ) { append_fmt( & result, ", %S", interface.to_string() ); - interface = interface->Next ? interface->Next->code_cast< CodeType >() : CodeType { nullptr }; + interface = interface->Next ? cast(CodeType, interface->Next) : CodeType { nullptr }; } } else if ( ast->Name ) @@ -452,7 +452,7 @@ String CodeFriend::to_string() void CodeFriend::to_string( String& result ) { - append_fmt( & result, "friend %S", ast->Declaration->to_string() ); + append_fmt( & result, "friend %S", GEN_NS to_string(ast->Declaration) ); if ( ast->Declaration->Type != ECode::Function && result[ length(result) - 1 ] != ';' ) { @@ -1010,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->code_cast< CodeType >(); + CodeType interface = cast(CodeType, ast->ParentType->Next); if ( interface ) append( & result, "\n" ); while ( interface ) { append_fmt( & result, ", %S", interface.to_string() ); - interface = interface->Next ? interface->Next->code_cast< CodeType >() : CodeType { nullptr }; + interface = interface->Next ? cast( CodeType, interface->Next) : CodeType { nullptr }; } } else if ( ast->Name ) @@ -1095,12 +1095,12 @@ void CodeTypedef::to_string( String& result ) if ( ast->UnderlyingType->Type == ECode::Typename && ast->UnderlyingType->ArrExpr ) { - append_fmt( & result, "[ %S ];", ast->UnderlyingType->ArrExpr->to_string() ); + append_fmt( & result, "[ %S ];", GEN_NS to_string(ast->UnderlyingType->ArrExpr) ); AST* next_arr_expr = ast->UnderlyingType->ArrExpr->Next; while ( next_arr_expr ) { - append_fmt( & result, "[ %S ];", next_arr_expr->to_string() ); + append_fmt( & result, "[ %S ];", GEN_NS to_string(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } @@ -1239,7 +1239,7 @@ void CodeUsing::to_string( String& result ) AST* next_arr_expr = ast->UnderlyingType->ArrExpr->Next; while ( next_arr_expr ) { - append_fmt( & result, "[ %S ]", next_arr_expr->to_string() ); + append_fmt( & result, "[ %S ]", GEN_NS to_string(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } @@ -1288,7 +1288,7 @@ void CodeVar::to_string( String& result ) AST* next_arr_expr = ast->ValueType->ArrExpr->Next; while ( next_arr_expr ) { - append_fmt( & result, "[ %S ]", next_arr_expr->to_string() ); + append_fmt( & result, "[ %S ]", GEN_NS to_string(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } @@ -1331,7 +1331,7 @@ void CodeVar::to_string( String& result ) AST* next_arr_expr = ast->ValueType->ArrExpr->Next; while ( next_arr_expr ) { - append_fmt( & result, "[ %S ]", next_arr_expr->to_string() ); + append_fmt( & result, "[ %S ]", GEN_NS to_string(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } @@ -1371,7 +1371,7 @@ void CodeVar::to_string( String& result ) AST* next_arr_expr = ast->ValueType->ArrExpr->Next; while ( next_arr_expr ) { - append_fmt( & result, "[ %S ]", next_arr_expr->to_string() ); + append_fmt( & result, "[ %S ]", GEN_NS to_string(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } diff --git a/project/components/code_types.hpp b/project/components/code_types.hpp index 997ec07..a582b62 100644 --- a/project/components/code_types.hpp +++ b/project/components/code_types.hpp @@ -151,9 +151,9 @@ struct CodeSpecifiers return false; } - if ( raw()->NumEntries == AST::ArrSpecs_Cap ) + if ( raw()->NumEntries == AST_ArrSpecs_Cap ) { - log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST::ArrSpecs_Cap ); + log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST_ArrSpecs_Cap ); return false; } @@ -179,9 +179,9 @@ struct CodeSpecifiers return -1; } - if ( raw()->NumEntries == AST::ArrSpecs_Cap ) + if ( raw()->NumEntries == AST_ArrSpecs_Cap ) { - log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST::ArrSpecs_Cap ); + log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST_ArrSpecs_Cap ); return -1; } diff --git a/project/components/gen/ast_inlines.hpp b/project/components/gen/ast_inlines.hpp index 3224148..0f840a9 100644 --- a/project/components/gen/ast_inlines.hpp +++ b/project/components/gen/ast_inlines.hpp @@ -11,7 +11,7 @@ inline Code& Code::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -27,7 +27,7 @@ inline CodeBody& CodeBody::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -43,7 +43,7 @@ inline CodeAttributes& CodeAttributes::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -79,7 +79,7 @@ inline CodeComment& CodeComment::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -115,7 +115,7 @@ inline CodeConstructor& CodeConstructor::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -151,7 +151,7 @@ inline CodeClass& CodeClass::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -167,7 +167,7 @@ inline CodeDefine& CodeDefine::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -203,7 +203,7 @@ inline CodeDestructor& CodeDestructor::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -239,7 +239,7 @@ inline CodeEnum& CodeEnum::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -275,7 +275,7 @@ inline CodeExec& CodeExec::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -311,7 +311,7 @@ inline CodeExtern& CodeExtern::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -347,7 +347,7 @@ inline CodeFriend& CodeFriend::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -383,7 +383,7 @@ inline CodeFn& CodeFn::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -419,7 +419,7 @@ inline CodeInclude& CodeInclude::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -455,7 +455,7 @@ inline CodeModule& CodeModule::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -491,7 +491,7 @@ inline CodeNS& CodeNS::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -527,7 +527,7 @@ inline CodeOperator& CodeOperator::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -563,7 +563,7 @@ inline CodeOpCast& CodeOpCast::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -599,7 +599,7 @@ inline CodeParam& CodeParam::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -615,7 +615,7 @@ inline CodePragma& CodePragma::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -651,7 +651,7 @@ inline CodePreprocessCond& CodePreprocessCond::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -687,7 +687,7 @@ inline CodeSpecifiers& CodeSpecifiers::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -703,7 +703,7 @@ inline CodeStruct& CodeStruct::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -719,7 +719,7 @@ inline CodeTemplate& CodeTemplate::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -755,7 +755,7 @@ inline CodeType& CodeType::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -791,7 +791,7 @@ inline CodeTypedef& CodeTypedef::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -827,7 +827,7 @@ inline CodeUnion& CodeUnion::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -863,7 +863,7 @@ inline CodeUsing& CodeUsing::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); @@ -899,7 +899,7 @@ inline CodeVar& CodeVar::operator=( Code other ) { if ( other.ast && other->Parent ) { - ast = rcast( decltype( ast ), other.ast->duplicate() ); + ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) ); rcast( AST*, ast )->Parent = nullptr; } ast = rcast( decltype( ast ), other.ast ); diff --git a/project/components/interface.upfront.cpp b/project/components/interface.upfront.cpp index 9a19a6b..5f9ce5e 100644 --- a/project/components/interface.upfront.cpp +++ b/project/components/interface.upfront.cpp @@ -772,7 +772,7 @@ CodeExtern def_extern_link( StrC name, Code body ) if ( body->Type != Extern_Linkage_Body && body->Type != Untyped ) { - log_failure("gen::def_extern_linkage: body is not of extern_linkage or untyped type %s", body->debug_str()); + log_failure("gen::def_extern_linkage: body is not of extern_linkage or untyped type %s", debug_str(body)); return InvalidCode; } @@ -804,7 +804,7 @@ CodeFriend def_friend( Code declaration ) break; default: - log_failure("gen::def_friend: requires declartion to have class, function, operator, or struct - %s", declaration->debug_str()); + log_failure("gen::def_friend: requires declartion to have class, function, operator, or struct - %s", debug_str(declaration)); return InvalidCode; } @@ -866,7 +866,7 @@ CodeFn def_function( StrC name default: { - log_failure("gen::def_function: body must be either of Function_Body, Execution, or Untyped type. %s", body->debug_str()); + log_failure("gen::def_function: body must be either of Function_Body, Execution, or Untyped type. %s", debug_str(body)); return InvalidCode; } } @@ -1008,7 +1008,7 @@ CodeOperator def_operator( OperatorT op, StrC nspace default: { - log_failure("gen::def_operator: body must be either of Function_Body, Execution, or Untyped type. %s", body->debug_str()); + log_failure("gen::def_operator: body must be either of Function_Body, Execution, or Untyped type. %s", debug_str(body)); return InvalidCode; } } @@ -1275,19 +1275,19 @@ CodeType def_type( StrC name, Code arrayexpr, CodeSpecifiers specifiers, CodeAtt if ( attributes && attributes->Type != ECode::PlatformAttributes ) { - log_failure( "gen::def_type: attributes is not of attributes type - %s", attributes.debug_str() ); + log_failure( "gen::def_type: attributes is not of attributes type - %s", debug_str(attributes) ); return InvalidCode; } if ( specifiers && specifiers->Type != ECode::Specifiers ) { - log_failure( "gen::def_type: specifiers is not of specifiers type - %s", specifiers.debug_str() ); + log_failure( "gen::def_type: specifiers is not of specifiers type - %s", debug_str(specifiers) ); return InvalidCode; } if ( arrayexpr && arrayexpr->Type != ECode::Untyped ) { - log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", arrayexpr->debug_str() ); + log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", debug_str(arrayexpr) ); return InvalidCode; } @@ -2141,7 +2141,7 @@ CodeSpecifiers def_specifiers( s32 num, ... ) return InvalidCode; } - if ( num > AST::ArrSpecs_Cap ) + if ( num > AST_ArrSpecs_Cap ) { log_failure("gen::def_specifiers: num of speciifers to define AST larger than AST specicifier capacity - %d", num); return InvalidCode; @@ -2173,7 +2173,7 @@ CodeSpecifiers def_specifiers( s32 num, SpecifierT* specs ) return InvalidCode; } - if ( num > AST::ArrSpecs_Cap ) + if ( num > AST_ArrSpecs_Cap ) { log_failure("gen::def_specifiers: num of speciifers to define AST larger than AST specicifier capacity - %d", num); return InvalidCode; diff --git a/project/helpers/helper.hpp b/project/helpers/helper.hpp index 4d874be..5baa9e8 100644 --- a/project/helpers/helper.hpp +++ b/project/helpers/helper.hpp @@ -358,7 +358,7 @@ CodeBody gen_ast_inlines() { if ( other.ast && other->Parent ) { - ast = rcast( decltype(ast), other.ast->duplicate() ); + ast = rcast( decltype(ast), GEN_NS duplicate(other.ast) ); rcast( AST*, ast)->Parent = nullptr; }