Code::is_body reduction

This commit is contained in:
Edward R. Gonzalez 2024-12-02 00:18:54 -05:00
parent 007bfa0cb0
commit 5cd69e1742
4 changed files with 11 additions and 271 deletions

View File

@ -172,7 +172,7 @@ struct Code
char const* debug_str() { return GEN_NS debug_str(* this); } \
Code duplicate() { return GEN_NS duplicate(* this); } \
bool is_equal( Code other ); \
bool is_body(); \
bool is_body() { return GEN_NS is_body(* this); } \
bool is_valid(); \
void set_global(); \
String to_string(); \

View File

@ -7,15 +7,6 @@
#pragma region generated code inline implementation
inline bool Code::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool Code::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -56,15 +47,6 @@ inline Code::operator bool()
return ast != nullptr;
}
inline bool CodeBody::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeBody::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -105,15 +87,6 @@ inline CodeBody::operator bool()
return ast != nullptr;
}
inline bool CodeAttributes::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeAttributes::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -174,15 +147,6 @@ inline AST_Attributes* CodeAttributes::operator->()
return ast;
}
inline bool CodeComment::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeComment::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -243,15 +207,6 @@ inline AST_Comment* CodeComment::operator->()
return ast;
}
inline bool CodeConstructor::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeConstructor::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -312,15 +267,6 @@ inline AST_Constructor* CodeConstructor::operator->()
return ast;
}
inline bool CodeClass::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeClass::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -361,15 +307,6 @@ inline CodeClass::operator bool()
return ast != nullptr;
}
inline bool CodeDefine::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeDefine::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -430,15 +367,6 @@ inline AST_Define* CodeDefine::operator->()
return ast;
}
inline bool CodeDestructor::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeDestructor::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -499,15 +427,6 @@ inline AST_Destructor* CodeDestructor::operator->()
return ast;
}
inline bool CodeEnum::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeEnum::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -568,15 +487,6 @@ inline AST_Enum* CodeEnum::operator->()
return ast;
}
inline bool CodeExec::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeExec::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -637,15 +547,6 @@ inline AST_Exec* CodeExec::operator->()
return ast;
}
inline bool CodeExtern::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeExtern::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -706,15 +607,6 @@ inline AST_Extern* CodeExtern::operator->()
return ast;
}
inline bool CodeFriend::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeFriend::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -775,15 +667,6 @@ inline AST_Friend* CodeFriend::operator->()
return ast;
}
inline bool CodeFn::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeFn::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -844,15 +727,6 @@ inline AST_Fn* CodeFn::operator->()
return ast;
}
inline bool CodeInclude::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeInclude::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -913,15 +787,6 @@ inline AST_Include* CodeInclude::operator->()
return ast;
}
inline bool CodeModule::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeModule::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -982,15 +847,6 @@ inline AST_Module* CodeModule::operator->()
return ast;
}
inline bool CodeNS::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeNS::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1051,15 +907,6 @@ inline AST_NS* CodeNS::operator->()
return ast;
}
inline bool CodeOperator::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeOperator::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1120,15 +967,6 @@ inline AST_Operator* CodeOperator::operator->()
return ast;
}
inline bool CodeOpCast::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeOpCast::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1189,15 +1027,6 @@ inline AST_OpCast* CodeOpCast::operator->()
return ast;
}
inline bool CodeParam::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeParam::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1238,15 +1067,6 @@ inline CodeParam::operator bool()
return ast != nullptr;
}
inline bool CodePragma::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodePragma::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1307,15 +1127,6 @@ inline AST_Pragma* CodePragma::operator->()
return ast;
}
inline bool CodePreprocessCond::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodePreprocessCond::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1376,15 +1187,6 @@ inline AST_PreprocessCond* CodePreprocessCond::operator->()
return ast;
}
inline bool CodeSpecifiers::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeSpecifiers::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1425,15 +1227,6 @@ inline CodeSpecifiers::operator bool()
return ast != nullptr;
}
inline bool CodeStruct::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeStruct::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1474,15 +1267,6 @@ inline CodeStruct::operator bool()
return ast != nullptr;
}
inline bool CodeTemplate::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeTemplate::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1543,15 +1327,6 @@ inline AST_Template* CodeTemplate::operator->()
return ast;
}
inline bool CodeType::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeType::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1612,15 +1387,6 @@ inline AST_Type* CodeType::operator->()
return ast;
}
inline bool CodeTypedef::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeTypedef::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1681,15 +1447,6 @@ inline AST_Typedef* CodeTypedef::operator->()
return ast;
}
inline bool CodeUnion::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeUnion::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1750,15 +1507,6 @@ inline AST_Union* CodeUnion::operator->()
return ast;
}
inline bool CodeUsing::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeUsing::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1819,15 +1567,6 @@ inline AST_Using* CodeUsing::operator->()
return ast;
}
inline bool CodeVar::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeVar::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )

View File

@ -111,6 +111,16 @@ Code duplicate( Code code )
return { duplicate(code.ast) };
}
inline
bool is_body(Code code)
{
if ( code.ast == nullptr )
{
return is_body(code.ast);
}
return false;
}
inline
Code& Code::operator ++()
{

View File

@ -354,15 +354,6 @@ CodeBody gen_ast_inlines()
char const* code_impl_tmpl = stringize(
\n
inline
bool <typename>::is_body()
{
if ( ast == nullptr )
{
return rcast(AST*, ast)->is_body();
}
return false;
}
inline
bool <typename>::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )