mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Work on AST::is_equal.
The NumEntries checks need to be deferred until the end as a final unresolved check on valdiation. As if there really is a discrepancy of entires it should be revealed by the specific entry failing. Right now the latest failure with the single header check involves a define directive specifically the define does omit whitespace properly and so the check interprets the different cached content to be non-equivalent. This will happen with all unvalidated aspects of the AST ( expressions, function bodies, etc ) There are two ways to resolve, either make an AST that can tokenize all items (not realistic), or I need to strip non-syntax important whitespace and then cache the string. This would mean removing everything but a single whitespace for all content within a content string. Otherwise, I would have to somehow make sure the content of the string has the exact formatting between both files for the definitions that matter. AST types with this issue: * Define Directive * Pragma Directive * Comment * Execution * Platform Attributes * Untyped Comments can technically be left unverified as they do not matter semantically. When the serialization is first emitted, the content these strings should for the most part be equivalent. However I do see some possible failures for that if a different style of bracket placment is used (between the serialization). At that point what I could do is just leave those unverified and just emit the content to the user as warning that the ast and the other compared could not be verified. Those technically can be handled on a per-eye basis, and worst case the tests with the compiler will in the determine if any critical defintions are missing for the user.
This commit is contained in:
parent
9edcbad907
commit
9b6dc3cbd8
@ -1028,17 +1028,23 @@ 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" \
|
||||||
"other ast member: %S\n" \
|
"other's ast member: %S\n" \
|
||||||
, debug_str() \
|
, debug_str() \
|
||||||
, other->debug_str() \
|
, other->debug_str() \
|
||||||
, ast->debug_str() \
|
, ast->debug_str() \
|
||||||
, other->ast->debug_str() \
|
, other->ast->debug_str() \
|
||||||
); \
|
); \
|
||||||
} \
|
|
||||||
\
|
\
|
||||||
return false; \
|
return false; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need to check to make sure the prev->is_equal wont lead to a recursion.
|
||||||
|
// #define check_member_prev() \
|
||||||
|
// if ( Prev ) \
|
||||||
|
// { \
|
||||||
|
|
||||||
|
|
||||||
case NewLine:
|
case NewLine:
|
||||||
case Access_Public:
|
case Access_Public:
|
||||||
case Access_Protected:
|
case Access_Protected:
|
||||||
@ -1053,8 +1059,8 @@ bool AST::is_equal( AST* other )
|
|||||||
case Untyped:
|
case Untyped:
|
||||||
{
|
{
|
||||||
check_member_str( Content );
|
check_member_str( Content );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
}
|
}
|
||||||
|
|
||||||
case Class_Fwd:
|
case Class_Fwd:
|
||||||
@ -1064,8 +1070,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( ParentType );
|
check_member_ast( ParentType );
|
||||||
check_member_val( ParentAccess );
|
check_member_val( ParentAccess );
|
||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1079,8 +1085,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_val( ParentAccess );
|
check_member_val( ParentAccess );
|
||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1090,8 +1096,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( InitializerList );
|
check_member_ast( InitializerList );
|
||||||
check_member_ast( Params );
|
check_member_ast( Params );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1100,8 +1106,8 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
check_member_ast( InitializerList );
|
check_member_ast( InitializerList );
|
||||||
check_member_ast( Params );
|
check_member_ast( Params );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1110,8 +1116,8 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1119,8 +1125,8 @@ bool AST::is_equal( AST* other )
|
|||||||
case Destructor_Fwd:
|
case Destructor_Fwd:
|
||||||
{
|
{
|
||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1133,8 +1139,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( UnderlyingType );
|
check_member_ast( UnderlyingType );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1146,8 +1152,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( UnderlyingType );
|
check_member_ast( UnderlyingType );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1156,8 +1162,8 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1166,8 +1172,8 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Declaration );
|
check_member_ast( Declaration );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1181,8 +1187,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( Params );
|
check_member_ast( Params );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1195,8 +1201,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( Params );
|
check_member_ast( Params );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1205,8 +1211,8 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
check_member_val( ModuleFlags );
|
check_member_val( ModuleFlags );
|
||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1216,8 +1222,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_val( ModuleFlags );
|
check_member_val( ModuleFlags );
|
||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1232,8 +1238,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( Params );
|
check_member_ast( Params );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1247,8 +1253,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( Params );
|
check_member_ast( Params );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1259,8 +1265,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( ValueType );
|
check_member_ast( ValueType );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1270,8 +1276,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( ValueType );
|
check_member_ast( ValueType );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1280,8 +1286,6 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
if ( NumEntries > 1 )
|
if ( NumEntries > 1 )
|
||||||
{
|
{
|
||||||
check_member_val( NumEntries );
|
|
||||||
|
|
||||||
AST* curr = this;
|
AST* curr = this;
|
||||||
AST* curr_other = other;
|
AST* curr_other = other;
|
||||||
while ( curr != nullptr )
|
while ( curr != nullptr )
|
||||||
@ -1312,15 +1316,16 @@ bool AST::is_equal( AST* other )
|
|||||||
, curr->debug_str()
|
, curr->debug_str()
|
||||||
, curr_other->debug_str()
|
, curr_other->debug_str()
|
||||||
);
|
);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curr = curr->Next;
|
curr = curr->Next;
|
||||||
curr_other = curr_other->Next;
|
curr_other = curr_other->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_member_val( NumEntries );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1336,8 +1341,8 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_str( Content );
|
check_member_str( Content );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1348,8 +1353,8 @@ bool AST::is_equal( AST* other )
|
|||||||
case Preprocess_ElIf:
|
case Preprocess_ElIf:
|
||||||
{
|
{
|
||||||
check_member_str( Content );
|
check_member_str( Content );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1358,8 +1363,8 @@ bool AST::is_equal( AST* other )
|
|||||||
case Preprocess_Pragma:
|
case Preprocess_Pragma:
|
||||||
{
|
{
|
||||||
check_member_str( Content );
|
check_member_str( Content );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1372,8 +1377,8 @@ bool AST::is_equal( AST* other )
|
|||||||
{
|
{
|
||||||
check_member_val( ArrSpecs[ idx ] );
|
check_member_val( ArrSpecs[ idx ] );
|
||||||
}
|
}
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1383,8 +1388,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Params );
|
check_member_ast( Params );
|
||||||
check_member_ast( Declaration );
|
check_member_ast( Declaration );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1396,8 +1401,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( UnderlyingType );
|
check_member_ast( UnderlyingType );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1407,8 +1412,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( ArrExpr );
|
check_member_ast( ArrExpr );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1419,8 +1424,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( Body );
|
check_member_ast( Body );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1432,8 +1437,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_str( Name );
|
check_member_str( Name );
|
||||||
check_member_ast( UnderlyingType );
|
check_member_ast( UnderlyingType );
|
||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1447,8 +1452,8 @@ bool AST::is_equal( AST* other )
|
|||||||
check_member_ast( Value );
|
check_member_ast( Value );
|
||||||
check_member_ast( Attributes );
|
check_member_ast( Attributes );
|
||||||
check_member_ast( Specs );
|
check_member_ast( Specs );
|
||||||
check_member_ast( Prev );
|
// check_member_ast( Prev );
|
||||||
check_member_ast( Next );
|
// check_member_ast( Next );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1461,7 +1466,6 @@ bool AST::is_equal( AST* other )
|
|||||||
case Struct_Body:
|
case Struct_Body:
|
||||||
case Union_Body:
|
case Union_Body:
|
||||||
{
|
{
|
||||||
check_member_val( NumEntries );
|
|
||||||
check_member_ast( Front );
|
check_member_ast( Front );
|
||||||
check_member_ast( Back );
|
check_member_ast( Back );
|
||||||
|
|
||||||
@ -1501,6 +1505,8 @@ bool AST::is_equal( AST* other )
|
|||||||
curr_other = curr_other->Next;
|
curr_other = curr_other->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_member_val( NumEntries );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user