mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Code::is_equal reduction
This commit is contained in:
parent
5cd69e1742
commit
2b24511f7d
@ -592,7 +592,7 @@ void AST::to_string( String& result )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AST::is_equal( AST* other )
|
bool is_equal( AST* self, AST* other )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
AST values are either some u32 value, a cached string, or a pointer to another AST.
|
AST values are either some u32 value, a cached string, or a pointer to another AST.
|
||||||
@ -603,31 +603,31 @@ bool AST::is_equal( AST* other )
|
|||||||
*/
|
*/
|
||||||
if ( other == nullptr )
|
if ( other == nullptr )
|
||||||
{
|
{
|
||||||
log_fmt( "AST::is_equal: other is null\nAST: %S", debug_str() );
|
log_fmt( "AST::is_equal: other is null\nAST: %S", debug_str(self) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Type != other->Type )
|
if ( self->Type != other->Type )
|
||||||
{
|
{
|
||||||
log_fmt("AST::is_equal: Type check failure with other\nAST: %S\nOther: %S"
|
log_fmt("AST::is_equal: Type check failure with other\nAST: %S\nOther: %S"
|
||||||
, debug_str()
|
, debug_str(self)
|
||||||
, other->debug_str()
|
, other->debug_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( Type )
|
switch ( self->Type )
|
||||||
{
|
{
|
||||||
using namespace ECode;
|
using namespace ECode;
|
||||||
|
|
||||||
#define check_member_val( val ) \
|
#define check_member_val( val ) \
|
||||||
if ( val != other->val ) \
|
if ( self->val != other->val ) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt("\nAST::is_equal: Member - " #val " failed\n" \
|
log_fmt("\nAST::is_equal: Member - " #val " failed\n" \
|
||||||
"AST : %S\n" \
|
"AST : %S\n" \
|
||||||
"Other: %S\n" \
|
"Other: %S\n" \
|
||||||
, debug_str() \
|
, debug_str(self) \
|
||||||
, other->debug_str() \
|
, other->debug_str() \
|
||||||
); \
|
); \
|
||||||
\
|
\
|
||||||
@ -635,12 +635,12 @@ bool AST::is_equal( AST* other )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define check_member_str( str ) \
|
#define check_member_str( str ) \
|
||||||
if ( str != other->str ) \
|
if ( self->str != other->str ) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt("\nAST::is_equal: Member string - "#str " failed\n" \
|
log_fmt("\nAST::is_equal: Member string - "#str " failed\n" \
|
||||||
"AST : %S\n" \
|
"AST : %S\n" \
|
||||||
"Other: %S\n" \
|
"Other: %S\n" \
|
||||||
, debug_str() \
|
, debug_str(self) \
|
||||||
, other->debug_str() \
|
, other->debug_str() \
|
||||||
); \
|
); \
|
||||||
\
|
\
|
||||||
@ -648,12 +648,12 @@ bool AST::is_equal( AST* other )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define check_member_content( content ) \
|
#define check_member_content( content ) \
|
||||||
if ( content != other->content ) \
|
if ( self->content != other->content ) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt("\nAST::is_equal: Member content - "#content " failed\n" \
|
log_fmt("\nAST::is_equal: Member content - "#content " failed\n" \
|
||||||
"AST : %S\n" \
|
"AST : %S\n" \
|
||||||
"Other: %S\n" \
|
"Other: %S\n" \
|
||||||
, debug_str() \
|
, debug_str(self) \
|
||||||
, other->debug_str() \
|
, other->debug_str() \
|
||||||
); \
|
); \
|
||||||
\
|
\
|
||||||
@ -661,13 +661,13 @@ bool AST::is_equal( AST* other )
|
|||||||
"so it must be verified by eye for now\n" \
|
"so it must be verified by eye for now\n" \
|
||||||
"AST Content:\n%S\n" \
|
"AST Content:\n%S\n" \
|
||||||
"Other Content:\n%S\n" \
|
"Other Content:\n%S\n" \
|
||||||
, visualize_whitespace(content) \
|
, visualize_whitespace(self->content) \
|
||||||
, visualize_whitespace(other->content) \
|
, visualize_whitespace(other->content) \
|
||||||
); \
|
); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define check_member_ast( ast ) \
|
#define check_member_ast( ast ) \
|
||||||
if ( ast ) \
|
if ( self->ast ) \
|
||||||
{ \
|
{ \
|
||||||
if ( other->ast == nullptr ) \
|
if ( other->ast == nullptr ) \
|
||||||
{ \
|
{ \
|
||||||
@ -675,24 +675,24 @@ bool AST::is_equal( AST* other )
|
|||||||
"AST : %s\n" \
|
"AST : %s\n" \
|
||||||
"Other: %s\n" \
|
"Other: %s\n" \
|
||||||
"For ast member: %s\n" \
|
"For ast member: %s\n" \
|
||||||
, debug_str() \
|
, debug_str(self) \
|
||||||
, other->debug_str() \
|
, other->debug_str() \
|
||||||
, ast->debug_str() \
|
, self->ast->debug_str() \
|
||||||
); \
|
); \
|
||||||
\
|
\
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
if ( ! ast->is_equal( other->ast ) ) \
|
if ( ! self->ast->is_equal( other->ast ) ) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt( "\nAST::is_equal: Failed for " #ast"\n" \
|
log_fmt( "\nAST::is_equal: Failed for " #ast"\n" \
|
||||||
"AST : %S\n" \
|
"AST : %S\n" \
|
||||||
"Other: %S\n" \
|
"Other: %S\n" \
|
||||||
"For ast member: %S\n" \
|
"For ast member: %S\n" \
|
||||||
"other's ast member: %S\n" \
|
"other's ast member: %S\n" \
|
||||||
, debug_str() \
|
, debug_str(self) \
|
||||||
, other->debug_str() \
|
, other->debug_str() \
|
||||||
, ast->debug_str() \
|
, self->ast->debug_str() \
|
||||||
, other->ast->debug_str() \
|
, other->ast->debug_str() \
|
||||||
); \
|
); \
|
||||||
\
|
\
|
||||||
@ -907,9 +907,9 @@ bool AST::is_equal( AST* other )
|
|||||||
|
|
||||||
case Parameters:
|
case Parameters:
|
||||||
{
|
{
|
||||||
if ( NumEntries > 1 )
|
if ( self->NumEntries > 1 )
|
||||||
{
|
{
|
||||||
AST* curr = this;
|
AST* curr = self;
|
||||||
AST* curr_other = other;
|
AST* curr_other = other;
|
||||||
while ( curr != nullptr )
|
while ( curr != nullptr )
|
||||||
{
|
{
|
||||||
@ -934,7 +934,7 @@ bool AST::is_equal( AST* other )
|
|||||||
"Other: %S\n"
|
"Other: %S\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %S\n"
|
||||||
"other's ast member: %S\n"
|
"other's ast member: %S\n"
|
||||||
, debug_str()
|
, debug_str(self)
|
||||||
, other->debug_str()
|
, other->debug_str()
|
||||||
, curr->debug_str()
|
, curr->debug_str()
|
||||||
, curr_other->debug_str()
|
, curr_other->debug_str()
|
||||||
@ -949,7 +949,7 @@ bool AST::is_equal( AST* other )
|
|||||||
"Other: %S\n"
|
"Other: %S\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %S\n"
|
||||||
"other's ast member: %S\n"
|
"other's ast member: %S\n"
|
||||||
, debug_str()
|
, debug_str(self)
|
||||||
, other->debug_str()
|
, other->debug_str()
|
||||||
, curr->debug_str()
|
, curr->debug_str()
|
||||||
, curr_other->debug_str()
|
, curr_other->debug_str()
|
||||||
@ -964,7 +964,7 @@ bool AST::is_equal( AST* other )
|
|||||||
"Other: %S\n"
|
"Other: %S\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %S\n"
|
||||||
"other's ast member: %S\n"
|
"other's ast member: %S\n"
|
||||||
, debug_str()
|
, debug_str(self)
|
||||||
, other->debug_str()
|
, other->debug_str()
|
||||||
, curr->debug_str()
|
, curr->debug_str()
|
||||||
, curr_other->debug_str()
|
, curr_other->debug_str()
|
||||||
@ -1020,7 +1020,7 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
check_member_val( NumEntries );
|
check_member_val( NumEntries );
|
||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
for ( s32 idx = 0; idx < NumEntries; ++idx )
|
for ( s32 idx = 0; idx < self->NumEntries; ++idx )
|
||||||
{
|
{
|
||||||
check_member_val( ArrSpecs[ idx ] );
|
check_member_val( ArrSpecs[ idx ] );
|
||||||
}
|
}
|
||||||
@ -1103,7 +1103,7 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( Front );
|
check_member_ast( Front );
|
||||||
check_member_ast( Back );
|
check_member_ast( Back );
|
||||||
|
|
||||||
AST* curr = Front;
|
AST* curr = self->Front;
|
||||||
AST* curr_other = other->Front;
|
AST* curr_other = other->Front;
|
||||||
while ( curr != nullptr )
|
while ( curr != nullptr )
|
||||||
{
|
{
|
||||||
@ -1126,7 +1126,7 @@ bool AST::is_equal( AST* other )
|
|||||||
"Other: %S\n"
|
"Other: %S\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %S\n"
|
||||||
"other's ast member: %S\n"
|
"other's ast member: %S\n"
|
||||||
, debug_str()
|
, debug_str(self)
|
||||||
, other->debug_str()
|
, other->debug_str()
|
||||||
, curr->debug_str()
|
, curr->debug_str()
|
||||||
, curr_other->debug_str()
|
, curr_other->debug_str()
|
||||||
|
@ -171,7 +171,7 @@ struct Code
|
|||||||
# define Using_Code( Typename ) \
|
# define Using_Code( Typename ) \
|
||||||
char const* debug_str() { return GEN_NS debug_str(* this); } \
|
char const* debug_str() { return GEN_NS debug_str(* this); } \
|
||||||
Code duplicate() { return GEN_NS duplicate(* this); } \
|
Code duplicate() { return GEN_NS duplicate(* this); } \
|
||||||
bool is_equal( Code other ); \
|
bool is_equal( Code other ) { return GEN_NS is_equal(* this, other); } \
|
||||||
bool is_body() { return GEN_NS is_body(* this); } \
|
bool is_body() { return GEN_NS is_body(* this); } \
|
||||||
bool is_valid(); \
|
bool is_valid(); \
|
||||||
void set_global(); \
|
void set_global(); \
|
||||||
@ -267,12 +267,14 @@ AST* duplicate ( AST* self );
|
|||||||
Code* entry ( AST* self, u32 idx );
|
Code* entry ( AST* self, u32 idx );
|
||||||
bool has_entries( AST* self );
|
bool has_entries( AST* self );
|
||||||
bool is_body ( AST* self );
|
bool is_body ( AST* self );
|
||||||
|
bool is_equal ( AST* self, AST* other );
|
||||||
String to_string ( AST* self );
|
String to_string ( AST* self );
|
||||||
char const* type_str ( AST* self );
|
char const* type_str ( AST* self );
|
||||||
|
|
||||||
#if GEN_CPP_SUPPORT_REFERENCES
|
#if GEN_CPP_SUPPORT_REFERENCES
|
||||||
void append ( AST& self, AST& other ) { return append(& self, & other); }
|
void append ( AST& self, AST& other ) { return append(& self, & other); }
|
||||||
bool is_body ( AST& self ) { return is_body(& self); }
|
bool is_body ( AST& self ) { return is_body(& self); }
|
||||||
|
bool is_equal ( AST& self, AST& other ) { return is_equal(& self, & other); }
|
||||||
char const* debug_str( AST& self ) { return debug_str( & self ); }
|
char const* debug_str( AST& self ) { return debug_str( & self ); }
|
||||||
String to_string( AST& self ) { return to_string( & self ); }
|
String to_string( AST& self ) { return to_string( & self ); }
|
||||||
char const* type_str ( AST& self ) { return type_str( & self ); }
|
char const* type_str ( AST& self ) { return type_str( & self ); }
|
||||||
@ -290,7 +292,7 @@ struct AST
|
|||||||
AST* duplicate () { return GEN_NS duplicate(this); }
|
AST* duplicate () { return GEN_NS duplicate(this); }
|
||||||
Code* entry ( u32 idx ) { return GEN_NS entry(this, idx); }
|
Code* entry ( u32 idx ) { return GEN_NS entry(this, idx); }
|
||||||
bool has_entries();
|
bool has_entries();
|
||||||
bool is_equal ( AST* other );
|
bool is_equal ( AST* other ) { return GEN_NS is_equal(this, other); }
|
||||||
bool is_body() { return GEN_NS is_body(this); }
|
bool is_body() { return GEN_NS is_body(this); }
|
||||||
char const* type_str() { return GEN_NS type_str(this); }
|
char const* type_str() { return GEN_NS type_str(this); }
|
||||||
bool validate_body();
|
bool validate_body();
|
||||||
|
@ -7,15 +7,6 @@
|
|||||||
|
|
||||||
#pragma region generated code inline implementation
|
#pragma region generated code inline implementation
|
||||||
|
|
||||||
inline bool Code::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool Code::is_valid()
|
inline bool Code::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -47,15 +38,6 @@ inline Code::operator bool()
|
|||||||
return ast != nullptr;
|
return ast != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeBody::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeBody::is_valid()
|
inline bool CodeBody::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -87,15 +69,6 @@ inline CodeBody::operator bool()
|
|||||||
return ast != nullptr;
|
return ast != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeAttributes::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeAttributes::is_valid()
|
inline bool CodeAttributes::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -147,15 +120,6 @@ inline AST_Attributes* CodeAttributes::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeComment::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeComment::is_valid()
|
inline bool CodeComment::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -207,15 +171,6 @@ inline AST_Comment* CodeComment::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeConstructor::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeConstructor::is_valid()
|
inline bool CodeConstructor::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -267,15 +222,6 @@ inline AST_Constructor* CodeConstructor::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeClass::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeClass::is_valid()
|
inline bool CodeClass::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -307,15 +253,6 @@ inline CodeClass::operator bool()
|
|||||||
return ast != nullptr;
|
return ast != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeDefine::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeDefine::is_valid()
|
inline bool CodeDefine::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -367,15 +304,6 @@ inline AST_Define* CodeDefine::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeDestructor::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeDestructor::is_valid()
|
inline bool CodeDestructor::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -427,15 +355,6 @@ inline AST_Destructor* CodeDestructor::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeEnum::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeEnum::is_valid()
|
inline bool CodeEnum::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -487,15 +406,6 @@ inline AST_Enum* CodeEnum::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeExec::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeExec::is_valid()
|
inline bool CodeExec::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -547,15 +457,6 @@ inline AST_Exec* CodeExec::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeExtern::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeExtern::is_valid()
|
inline bool CodeExtern::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -607,15 +508,6 @@ inline AST_Extern* CodeExtern::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeFriend::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeFriend::is_valid()
|
inline bool CodeFriend::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -667,15 +559,6 @@ inline AST_Friend* CodeFriend::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeFn::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeFn::is_valid()
|
inline bool CodeFn::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -727,15 +610,6 @@ inline AST_Fn* CodeFn::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeInclude::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeInclude::is_valid()
|
inline bool CodeInclude::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -787,15 +661,6 @@ inline AST_Include* CodeInclude::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeModule::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeModule::is_valid()
|
inline bool CodeModule::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -847,15 +712,6 @@ inline AST_Module* CodeModule::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeNS::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeNS::is_valid()
|
inline bool CodeNS::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -907,15 +763,6 @@ inline AST_NS* CodeNS::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeOperator::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeOperator::is_valid()
|
inline bool CodeOperator::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -967,15 +814,6 @@ inline AST_Operator* CodeOperator::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeOpCast::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeOpCast::is_valid()
|
inline bool CodeOpCast::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1027,15 +865,6 @@ inline AST_OpCast* CodeOpCast::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeParam::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeParam::is_valid()
|
inline bool CodeParam::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1067,15 +896,6 @@ inline CodeParam::operator bool()
|
|||||||
return ast != nullptr;
|
return ast != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodePragma::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodePragma::is_valid()
|
inline bool CodePragma::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1127,15 +947,6 @@ inline AST_Pragma* CodePragma::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodePreprocessCond::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodePreprocessCond::is_valid()
|
inline bool CodePreprocessCond::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1187,15 +998,6 @@ inline AST_PreprocessCond* CodePreprocessCond::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeSpecifiers::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeSpecifiers::is_valid()
|
inline bool CodeSpecifiers::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1227,15 +1029,6 @@ inline CodeSpecifiers::operator bool()
|
|||||||
return ast != nullptr;
|
return ast != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeStruct::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeStruct::is_valid()
|
inline bool CodeStruct::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1267,15 +1060,6 @@ inline CodeStruct::operator bool()
|
|||||||
return ast != nullptr;
|
return ast != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeTemplate::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeTemplate::is_valid()
|
inline bool CodeTemplate::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1327,15 +1111,6 @@ inline AST_Template* CodeTemplate::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeType::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeType::is_valid()
|
inline bool CodeType::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1387,15 +1162,6 @@ inline AST_Type* CodeType::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeTypedef::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeTypedef::is_valid()
|
inline bool CodeTypedef::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1447,15 +1213,6 @@ inline AST_Typedef* CodeTypedef::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeUnion::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeUnion::is_valid()
|
inline bool CodeUnion::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1507,15 +1264,6 @@ inline AST_Union* CodeUnion::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeUsing::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeUsing::is_valid()
|
inline bool CodeUsing::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
@ -1567,15 +1315,6 @@ inline AST_Using* CodeUsing::operator->()
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool CodeVar::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast( AST*, ast )->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool CodeVar::is_valid()
|
inline bool CodeVar::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
||||||
|
@ -121,6 +121,18 @@ bool is_body(Code code)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool is_equal( Code self, Code other )
|
||||||
|
{
|
||||||
|
if ( self.ast == nullptr || other.ast == nullptr )
|
||||||
|
{
|
||||||
|
// Just check if they're both null.
|
||||||
|
// log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
|
||||||
|
return self.ast == nullptr && other.ast == nullptr;
|
||||||
|
}
|
||||||
|
return is_equal( self.ast, other.ast );
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
Code& Code::operator ++()
|
Code& Code::operator ++()
|
||||||
{
|
{
|
||||||
|
@ -354,17 +354,6 @@ CodeBody gen_ast_inlines()
|
|||||||
char const* code_impl_tmpl = stringize(
|
char const* code_impl_tmpl = stringize(
|
||||||
\n
|
\n
|
||||||
inline
|
inline
|
||||||
bool <typename>::is_equal( Code other )
|
|
||||||
{
|
|
||||||
if ( ast == nullptr || other.ast == nullptr )
|
|
||||||
{
|
|
||||||
// Just check if they're both null.
|
|
||||||
// log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
|
|
||||||
return ast == nullptr && other.ast == nullptr;
|
|
||||||
}
|
|
||||||
return rcast(AST*, ast)->is_equal( other.ast );
|
|
||||||
}
|
|
||||||
inline
|
|
||||||
bool <typename>::is_valid()
|
bool <typename>::is_valid()
|
||||||
{
|
{
|
||||||
return (AST*) ast != nullptr && rcast( AST*, ast)->Type != CodeT::Invalid;
|
return (AST*) ast != nullptr && rcast( AST*, ast)->Type != CodeT::Invalid;
|
||||||
|
Loading…
Reference in New Issue
Block a user