diff --git a/project/components/ast.hpp b/project/components/ast.hpp index 6cec65d..16645a9 100644 --- a/project/components/ast.hpp +++ b/project/components/ast.hpp @@ -173,7 +173,7 @@ struct Code Code duplicate() { return GEN_NS duplicate(* this); } \ bool is_equal( Code other ) { return GEN_NS is_equal(* this, other); } \ bool is_body() { return GEN_NS is_body(* this); } \ - bool is_valid(); \ + bool is_valid() { return GEN_NS is_valid(* this); } \ void set_global(); \ String to_string(); \ Typename& operator = ( AST* other ); \ diff --git a/project/components/gen/ast_inlines.hpp b/project/components/gen/ast_inlines.hpp index b336234..c787fa4 100644 --- a/project/components/gen/ast_inlines.hpp +++ b/project/components/gen/ast_inlines.hpp @@ -7,11 +7,6 @@ #pragma region generated code inline implementation -inline bool Code::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void Code::set_global() { if ( ast == nullptr ) @@ -38,11 +33,6 @@ inline Code::operator bool() return ast != nullptr; } -inline bool CodeBody::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeBody::set_global() { if ( ast == nullptr ) @@ -69,11 +59,6 @@ inline CodeBody::operator bool() return ast != nullptr; } -inline bool CodeAttributes::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeAttributes::set_global() { if ( ast == nullptr ) @@ -120,11 +105,6 @@ inline AST_Attributes* CodeAttributes::operator->() return ast; } -inline bool CodeComment::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeComment::set_global() { if ( ast == nullptr ) @@ -171,11 +151,6 @@ inline AST_Comment* CodeComment::operator->() return ast; } -inline bool CodeConstructor::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeConstructor::set_global() { if ( ast == nullptr ) @@ -222,11 +197,6 @@ inline AST_Constructor* CodeConstructor::operator->() return ast; } -inline bool CodeClass::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeClass::set_global() { if ( ast == nullptr ) @@ -253,11 +223,6 @@ inline CodeClass::operator bool() return ast != nullptr; } -inline bool CodeDefine::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeDefine::set_global() { if ( ast == nullptr ) @@ -304,11 +269,6 @@ inline AST_Define* CodeDefine::operator->() return ast; } -inline bool CodeDestructor::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeDestructor::set_global() { if ( ast == nullptr ) @@ -355,11 +315,6 @@ inline AST_Destructor* CodeDestructor::operator->() return ast; } -inline bool CodeEnum::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeEnum::set_global() { if ( ast == nullptr ) @@ -406,11 +361,6 @@ inline AST_Enum* CodeEnum::operator->() return ast; } -inline bool CodeExec::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeExec::set_global() { if ( ast == nullptr ) @@ -457,11 +407,6 @@ inline AST_Exec* CodeExec::operator->() return ast; } -inline bool CodeExtern::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeExtern::set_global() { if ( ast == nullptr ) @@ -508,11 +453,6 @@ inline AST_Extern* CodeExtern::operator->() return ast; } -inline bool CodeFriend::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeFriend::set_global() { if ( ast == nullptr ) @@ -559,11 +499,6 @@ inline AST_Friend* CodeFriend::operator->() return ast; } -inline bool CodeFn::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeFn::set_global() { if ( ast == nullptr ) @@ -610,11 +545,6 @@ inline AST_Fn* CodeFn::operator->() return ast; } -inline bool CodeInclude::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeInclude::set_global() { if ( ast == nullptr ) @@ -661,11 +591,6 @@ inline AST_Include* CodeInclude::operator->() return ast; } -inline bool CodeModule::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeModule::set_global() { if ( ast == nullptr ) @@ -712,11 +637,6 @@ inline AST_Module* CodeModule::operator->() return ast; } -inline bool CodeNS::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeNS::set_global() { if ( ast == nullptr ) @@ -763,11 +683,6 @@ inline AST_NS* CodeNS::operator->() return ast; } -inline bool CodeOperator::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeOperator::set_global() { if ( ast == nullptr ) @@ -814,11 +729,6 @@ inline AST_Operator* CodeOperator::operator->() return ast; } -inline bool CodeOpCast::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeOpCast::set_global() { if ( ast == nullptr ) @@ -865,11 +775,6 @@ inline AST_OpCast* CodeOpCast::operator->() return ast; } -inline bool CodeParam::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeParam::set_global() { if ( ast == nullptr ) @@ -896,11 +801,6 @@ inline CodeParam::operator bool() return ast != nullptr; } -inline bool CodePragma::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodePragma::set_global() { if ( ast == nullptr ) @@ -947,11 +847,6 @@ inline AST_Pragma* CodePragma::operator->() return ast; } -inline bool CodePreprocessCond::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodePreprocessCond::set_global() { if ( ast == nullptr ) @@ -998,11 +893,6 @@ inline AST_PreprocessCond* CodePreprocessCond::operator->() return ast; } -inline bool CodeSpecifiers::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeSpecifiers::set_global() { if ( ast == nullptr ) @@ -1029,11 +919,6 @@ inline CodeSpecifiers::operator bool() return ast != nullptr; } -inline bool CodeStruct::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeStruct::set_global() { if ( ast == nullptr ) @@ -1060,11 +945,6 @@ inline CodeStruct::operator bool() return ast != nullptr; } -inline bool CodeTemplate::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeTemplate::set_global() { if ( ast == nullptr ) @@ -1111,11 +991,6 @@ inline AST_Template* CodeTemplate::operator->() return ast; } -inline bool CodeType::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeType::set_global() { if ( ast == nullptr ) @@ -1162,11 +1037,6 @@ inline AST_Type* CodeType::operator->() return ast; } -inline bool CodeTypedef::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeTypedef::set_global() { if ( ast == nullptr ) @@ -1213,11 +1083,6 @@ inline AST_Typedef* CodeTypedef::operator->() return ast; } -inline bool CodeUnion::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeUnion::set_global() { if ( ast == nullptr ) @@ -1264,11 +1129,6 @@ inline AST_Union* CodeUnion::operator->() return ast; } -inline bool CodeUsing::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeUsing::set_global() { if ( ast == nullptr ) @@ -1315,11 +1175,6 @@ inline AST_Using* CodeUsing::operator->() return ast; } -inline bool CodeVar::is_valid() -{ - return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid; -} - inline void CodeVar::set_global() { if ( ast == nullptr ) diff --git a/project/components/inlines.hpp b/project/components/inlines.hpp index e80c567..48e6f77 100644 --- a/project/components/inlines.hpp +++ b/project/components/inlines.hpp @@ -133,6 +133,12 @@ bool is_equal( Code self, Code other ) return is_equal( self.ast, other.ast ); } +inline +bool is_valid(Code self) +{ + return self.ast != nullptr && self.ast->Type != CodeT::Invalid; +} + inline Code& Code::operator ++() { diff --git a/project/helpers/helper.hpp b/project/helpers/helper.hpp index fc91e95..03ca48c 100644 --- a/project/helpers/helper.hpp +++ b/project/helpers/helper.hpp @@ -354,11 +354,6 @@ CodeBody gen_ast_inlines() char const* code_impl_tmpl = stringize( \n inline - bool ::is_valid() - { - return (AST*) ast != nullptr && rcast( AST*, ast)->Type != CodeT::Invalid; - } - inline void ::set_global() { if ( ast == nullptr )