From 937235b776cbadeaa00c8fa35ece86246c1d20d8 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 2 Dec 2024 00:03:38 -0500 Subject: [PATCH] progress (Code) --- project/components/ast.cpp | 4 +- project/components/ast.hpp | 29 +- project/components/gen/ast_inlines.hpp | 406 ++++------------------- project/components/inlines.hpp | 2 +- project/components/interface.cpp | 10 +- project/components/interface.parsing.cpp | 40 +-- project/components/interface.untyped.cpp | 12 +- project/components/interface.upfront.cpp | 212 ++++++------ project/components/parser.cpp | 168 +++++----- project/helpers/helper.hpp | 17 +- 10 files changed, 306 insertions(+), 594 deletions(-) diff --git a/project/components/ast.cpp b/project/components/ast.cpp index 792333f..acc572f 100644 --- a/project/components/ast.cpp +++ b/project/components/ast.cpp @@ -3,8 +3,8 @@ #include "static_data.cpp" #endif -Code Code::Global; -Code Code::Invalid; +global Code Code_Global; +global Code Code_Invalid; // This serializes all the data-members in a "debug" format, where each member is printed with its associated value. char const* debug_str(AST* self) diff --git a/project/components/ast.hpp b/project/components/ast.hpp index 533e705..0f327db 100644 --- a/project/components/ast.hpp +++ b/project/components/ast.hpp @@ -151,6 +151,14 @@ template< class Type> forceinline Type tmpl_cast( Code* self ) { return * rcast( template< class Type> forceinline Type tmpl_cast( Code& self ) { return * rcast( Type*, & self ); } #endif +char const* debug_str (Code code); +Code duplicate (Code code); +bool is_equal (Code code, Code other); +bool is_body (Code code); +bool is_valid (Code code); +void set_global(Code code); +String to_string (Code code); + /* AST* wrapper - Not constantly have to append the '*' as this is written often.. @@ -158,13 +166,6 @@ template< class Type> forceinline Type tmpl_cast( Code& self ) { return * rcast( */ struct Code { -# pragma region Statics - // Used to identify ASTs that should always be duplicated. (Global constant ASTs) - static Code Global; - - // Used to identify invalid generated code. - static Code Invalid; -# pragma endregion Statics # define Using_Code( Typename ) \ char const* debug_str(); \ @@ -176,8 +177,8 @@ struct Code String to_string(); \ Typename& operator = ( AST* other ); \ Typename& operator = ( Code other ); \ - bool operator ==( Code other ); \ - bool operator !=( Code other ); \ + bool operator ==( Code other ) { return (AST*)ast == other.ast; } \ + bool operator !=( Code other ) { return (AST*)ast != other.ast; } \ operator bool(); Using_Code( Code ); @@ -243,6 +244,14 @@ struct Code #undef operator }; +#pragma region Statics +// Used to identify ASTs that should always be duplicated. (Global constant ASTs) +extern Code Code_Global; + +// Used to identify invalid generated code. +extern Code Code_Invalid; +#pragma endregion Statics + struct Code_POD { AST* ast; @@ -481,4 +490,4 @@ static_assert( sizeof(AST_POD) == AST_POD_Size, "ERROR: AST POD is not size o // Used when the its desired when omission is allowed in a definition. #define NoCode { nullptr } -#define CodeInvalid (* Code::Invalid.ast) // Uses an implicitly overloaded cast from the AST to the desired code type. +#define InvalidCode (* Code_Invalid.ast) // Uses an implicitly overloaded cast from the AST to the desired code type. diff --git a/project/components/gen/ast_inlines.hpp b/project/components/gen/ast_inlines.hpp index ec26f08..0df47a5 100644 --- a/project/components/gen/ast_inlines.hpp +++ b/project/components/gen/ast_inlines.hpp @@ -19,7 +19,7 @@ inline Code Code::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -54,7 +54,7 @@ inline void Code::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline Code& Code::operator=( Code other ) @@ -68,16 +68,6 @@ inline Code& Code::operator=( Code other ) return *this; } -inline bool Code::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool Code::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline Code::operator bool() { return ast != nullptr; @@ -95,7 +85,7 @@ inline Code CodeBody::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -130,7 +120,7 @@ inline void CodeBody::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeBody& CodeBody::operator=( Code other ) @@ -144,16 +134,6 @@ inline CodeBody& CodeBody::operator=( Code other ) return *this; } -inline bool CodeBody::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeBody::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeBody::operator bool() { return ast != nullptr; @@ -171,7 +151,7 @@ inline Code CodeAttributes::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -206,7 +186,7 @@ inline void CodeAttributes::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeAttributes& CodeAttributes::operator=( Code other ) @@ -220,16 +200,6 @@ inline CodeAttributes& CodeAttributes::operator=( Code other ) return *this; } -inline bool CodeAttributes::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeAttributes::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeAttributes::operator bool() { return ast != nullptr; @@ -267,7 +237,7 @@ inline Code CodeComment::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -302,7 +272,7 @@ inline void CodeComment::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeComment& CodeComment::operator=( Code other ) @@ -316,16 +286,6 @@ inline CodeComment& CodeComment::operator=( Code other ) return *this; } -inline bool CodeComment::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeComment::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeComment::operator bool() { return ast != nullptr; @@ -363,7 +323,7 @@ inline Code CodeConstructor::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -398,7 +358,7 @@ inline void CodeConstructor::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeConstructor& CodeConstructor::operator=( Code other ) @@ -412,16 +372,6 @@ inline CodeConstructor& CodeConstructor::operator=( Code other ) return *this; } -inline bool CodeConstructor::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeConstructor::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeConstructor::operator bool() { return ast != nullptr; @@ -459,7 +409,7 @@ inline Code CodeClass::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -494,7 +444,7 @@ inline void CodeClass::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeClass& CodeClass::operator=( Code other ) @@ -508,16 +458,6 @@ inline CodeClass& CodeClass::operator=( Code other ) return *this; } -inline bool CodeClass::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeClass::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeClass::operator bool() { return ast != nullptr; @@ -535,7 +475,7 @@ inline Code CodeDefine::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -570,7 +510,7 @@ inline void CodeDefine::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeDefine& CodeDefine::operator=( Code other ) @@ -584,16 +524,6 @@ inline CodeDefine& CodeDefine::operator=( Code other ) return *this; } -inline bool CodeDefine::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeDefine::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeDefine::operator bool() { return ast != nullptr; @@ -631,7 +561,7 @@ inline Code CodeDestructor::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -666,7 +596,7 @@ inline void CodeDestructor::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeDestructor& CodeDestructor::operator=( Code other ) @@ -680,16 +610,6 @@ inline CodeDestructor& CodeDestructor::operator=( Code other ) return *this; } -inline bool CodeDestructor::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeDestructor::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeDestructor::operator bool() { return ast != nullptr; @@ -727,7 +647,7 @@ inline Code CodeEnum::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -762,7 +682,7 @@ inline void CodeEnum::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeEnum& CodeEnum::operator=( Code other ) @@ -776,16 +696,6 @@ inline CodeEnum& CodeEnum::operator=( Code other ) return *this; } -inline bool CodeEnum::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeEnum::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeEnum::operator bool() { return ast != nullptr; @@ -823,7 +733,7 @@ inline Code CodeExec::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -858,7 +768,7 @@ inline void CodeExec::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeExec& CodeExec::operator=( Code other ) @@ -872,16 +782,6 @@ inline CodeExec& CodeExec::operator=( Code other ) return *this; } -inline bool CodeExec::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeExec::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeExec::operator bool() { return ast != nullptr; @@ -919,7 +819,7 @@ inline Code CodeExtern::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -954,7 +854,7 @@ inline void CodeExtern::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeExtern& CodeExtern::operator=( Code other ) @@ -968,16 +868,6 @@ inline CodeExtern& CodeExtern::operator=( Code other ) return *this; } -inline bool CodeExtern::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeExtern::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeExtern::operator bool() { return ast != nullptr; @@ -1015,7 +905,7 @@ inline Code CodeFriend::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1050,7 +940,7 @@ inline void CodeFriend::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeFriend& CodeFriend::operator=( Code other ) @@ -1064,16 +954,6 @@ inline CodeFriend& CodeFriend::operator=( Code other ) return *this; } -inline bool CodeFriend::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeFriend::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeFriend::operator bool() { return ast != nullptr; @@ -1111,7 +991,7 @@ inline Code CodeFn::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1146,7 +1026,7 @@ inline void CodeFn::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeFn& CodeFn::operator=( Code other ) @@ -1160,16 +1040,6 @@ inline CodeFn& CodeFn::operator=( Code other ) return *this; } -inline bool CodeFn::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeFn::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeFn::operator bool() { return ast != nullptr; @@ -1207,7 +1077,7 @@ inline Code CodeInclude::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1242,7 +1112,7 @@ inline void CodeInclude::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeInclude& CodeInclude::operator=( Code other ) @@ -1256,16 +1126,6 @@ inline CodeInclude& CodeInclude::operator=( Code other ) return *this; } -inline bool CodeInclude::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeInclude::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeInclude::operator bool() { return ast != nullptr; @@ -1303,7 +1163,7 @@ inline Code CodeModule::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1338,7 +1198,7 @@ inline void CodeModule::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeModule& CodeModule::operator=( Code other ) @@ -1352,16 +1212,6 @@ inline CodeModule& CodeModule::operator=( Code other ) return *this; } -inline bool CodeModule::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeModule::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeModule::operator bool() { return ast != nullptr; @@ -1399,7 +1249,7 @@ inline Code CodeNS::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1434,7 +1284,7 @@ inline void CodeNS::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeNS& CodeNS::operator=( Code other ) @@ -1448,16 +1298,6 @@ inline CodeNS& CodeNS::operator=( Code other ) return *this; } -inline bool CodeNS::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeNS::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeNS::operator bool() { return ast != nullptr; @@ -1495,7 +1335,7 @@ inline Code CodeOperator::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1530,7 +1370,7 @@ inline void CodeOperator::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeOperator& CodeOperator::operator=( Code other ) @@ -1544,16 +1384,6 @@ inline CodeOperator& CodeOperator::operator=( Code other ) return *this; } -inline bool CodeOperator::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeOperator::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeOperator::operator bool() { return ast != nullptr; @@ -1591,7 +1421,7 @@ inline Code CodeOpCast::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1626,7 +1456,7 @@ inline void CodeOpCast::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeOpCast& CodeOpCast::operator=( Code other ) @@ -1640,16 +1470,6 @@ inline CodeOpCast& CodeOpCast::operator=( Code other ) return *this; } -inline bool CodeOpCast::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeOpCast::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeOpCast::operator bool() { return ast != nullptr; @@ -1687,7 +1507,7 @@ inline Code CodeParam::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1722,7 +1542,7 @@ inline void CodeParam::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeParam& CodeParam::operator=( Code other ) @@ -1736,16 +1556,6 @@ inline CodeParam& CodeParam::operator=( Code other ) return *this; } -inline bool CodeParam::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeParam::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeParam::operator bool() { return ast != nullptr; @@ -1763,7 +1573,7 @@ inline Code CodePragma::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1798,7 +1608,7 @@ inline void CodePragma::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodePragma& CodePragma::operator=( Code other ) @@ -1812,16 +1622,6 @@ inline CodePragma& CodePragma::operator=( Code other ) return *this; } -inline bool CodePragma::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodePragma::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodePragma::operator bool() { return ast != nullptr; @@ -1859,7 +1659,7 @@ inline Code CodePreprocessCond::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1894,7 +1694,7 @@ inline void CodePreprocessCond::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodePreprocessCond& CodePreprocessCond::operator=( Code other ) @@ -1908,16 +1708,6 @@ inline CodePreprocessCond& CodePreprocessCond::operator=( Code other ) return *this; } -inline bool CodePreprocessCond::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodePreprocessCond::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodePreprocessCond::operator bool() { return ast != nullptr; @@ -1955,7 +1745,7 @@ inline Code CodeSpecifiers::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -1990,7 +1780,7 @@ inline void CodeSpecifiers::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeSpecifiers& CodeSpecifiers::operator=( Code other ) @@ -2004,16 +1794,6 @@ inline CodeSpecifiers& CodeSpecifiers::operator=( Code other ) return *this; } -inline bool CodeSpecifiers::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeSpecifiers::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeSpecifiers::operator bool() { return ast != nullptr; @@ -2031,7 +1811,7 @@ inline Code CodeStruct::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -2066,7 +1846,7 @@ inline void CodeStruct::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeStruct& CodeStruct::operator=( Code other ) @@ -2080,16 +1860,6 @@ inline CodeStruct& CodeStruct::operator=( Code other ) return *this; } -inline bool CodeStruct::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeStruct::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeStruct::operator bool() { return ast != nullptr; @@ -2107,7 +1877,7 @@ inline Code CodeTemplate::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -2142,7 +1912,7 @@ inline void CodeTemplate::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeTemplate& CodeTemplate::operator=( Code other ) @@ -2156,16 +1926,6 @@ inline CodeTemplate& CodeTemplate::operator=( Code other ) return *this; } -inline bool CodeTemplate::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeTemplate::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeTemplate::operator bool() { return ast != nullptr; @@ -2203,7 +1963,7 @@ inline Code CodeType::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -2238,7 +1998,7 @@ inline void CodeType::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeType& CodeType::operator=( Code other ) @@ -2252,16 +2012,6 @@ inline CodeType& CodeType::operator=( Code other ) return *this; } -inline bool CodeType::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeType::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeType::operator bool() { return ast != nullptr; @@ -2299,7 +2049,7 @@ inline Code CodeTypedef::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -2334,7 +2084,7 @@ inline void CodeTypedef::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeTypedef& CodeTypedef::operator=( Code other ) @@ -2348,16 +2098,6 @@ inline CodeTypedef& CodeTypedef::operator=( Code other ) return *this; } -inline bool CodeTypedef::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeTypedef::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeTypedef::operator bool() { return ast != nullptr; @@ -2395,7 +2135,7 @@ inline Code CodeUnion::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -2430,7 +2170,7 @@ inline void CodeUnion::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeUnion& CodeUnion::operator=( Code other ) @@ -2444,16 +2184,6 @@ inline CodeUnion& CodeUnion::operator=( Code other ) return *this; } -inline bool CodeUnion::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeUnion::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeUnion::operator bool() { return ast != nullptr; @@ -2491,7 +2221,7 @@ inline Code CodeUsing::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -2526,7 +2256,7 @@ inline void CodeUsing::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeUsing& CodeUsing::operator=( Code other ) @@ -2540,16 +2270,6 @@ inline CodeUsing& CodeUsing::operator=( Code other ) return *this; } -inline bool CodeUsing::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeUsing::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeUsing::operator bool() { return ast != nullptr; @@ -2587,7 +2307,7 @@ inline Code CodeVar::duplicate() if ( ast == nullptr ) { log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); - return Code::Invalid; + return Code_Invalid; } return { rcast( AST*, ast )->duplicate() }; } @@ -2622,7 +2342,7 @@ inline void CodeVar::set_global() log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); return; } - rcast( AST*, ast )->Parent = Code::Global.ast; + rcast( AST*, ast )->Parent = Code_Global.ast; } inline CodeVar& CodeVar::operator=( Code other ) @@ -2636,16 +2356,6 @@ inline CodeVar& CodeVar::operator=( Code other ) return *this; } -inline bool CodeVar::operator==( Code other ) -{ - return (AST*)ast == other.ast; -} - -inline bool CodeVar::operator!=( Code other ) -{ - return (AST*)ast != other.ast; -} - inline CodeVar::operator bool() { return ast != nullptr; diff --git a/project/components/inlines.hpp b/project/components/inlines.hpp index 8178ab2..613a8f8 100644 --- a/project/components/inlines.hpp +++ b/project/components/inlines.hpp @@ -209,7 +209,7 @@ CodeBody def_body( CodeT type ) default: log_failure( "def_body: Invalid type %s", (char const*)ECode::to_str(type) ); - return (CodeBody)Code::Invalid; + return (CodeBody)Code_Invalid; } Code diff --git a/project/components/interface.cpp b/project/components/interface.cpp index b455259..425b921 100644 --- a/project/components/interface.cpp +++ b/project/components/interface.cpp @@ -74,12 +74,12 @@ void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, s internal void define_constants() { - Code::Global = make_code(); - scast(String, Code::Global->Name) = get_cached_string( txt("Global Code") ); - scast(String, Code::Global->Content) = Code::Global->Name; + Code_Global = make_code(); + scast(String, Code_Global->Name) = get_cached_string( txt("Global Code") ); + scast(String, Code_Global->Content) = Code_Global->Name; - Code::Invalid = make_code(); - Code::Invalid.set_global(); + Code_Invalid = make_code(); + Code_Invalid.set_global(); t_empty = (CodeType) make_code(); t_empty->Type = ECode::Typename; diff --git a/project/components/interface.parsing.cpp b/project/components/interface.parsing.cpp index 726f9e4..d1161aa 100644 --- a/project/components/interface.parsing.cpp +++ b/project/components/interface.parsing.cpp @@ -15,7 +15,7 @@ CodeClass parse_class( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; push_scope(); @@ -31,7 +31,7 @@ CodeConstructor parse_constructor( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; // TODO(Ed): Constructors can have prefix attributes @@ -61,7 +61,7 @@ CodeConstructor parse_constructor( StrC def ) default : log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // Every specifier after would be considered part of the type type signature @@ -91,7 +91,7 @@ CodeDestructor parse_destructor( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; // TODO(Ed): Destructors can have prefix attributes // TODO(Ed): Destructors can have virtual @@ -110,7 +110,7 @@ CodeEnum parse_enum( StrC def ) if ( toks.Arr == nullptr ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } Context.Tokens = toks; @@ -124,7 +124,7 @@ CodeBody parse_export_body( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_export_body(); @@ -137,7 +137,7 @@ CodeExtern parse_extern_link( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_extern_link(); @@ -150,7 +150,7 @@ CodeFriend parse_friend( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_friend(); @@ -163,7 +163,7 @@ CodeFn parse_function( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return (CodeFn) parse_function(); @@ -176,7 +176,7 @@ CodeBody parse_global_body( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; push_scope(); @@ -192,7 +192,7 @@ CodeNS parse_namespace( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_namespace(); @@ -205,7 +205,7 @@ CodeOperator parse_operator( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return (CodeOperator) parse_operator(); @@ -218,7 +218,7 @@ CodeOpCast parse_operator_cast( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_operator_cast(); @@ -231,7 +231,7 @@ CodeStruct parse_struct( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; push_scope(); @@ -247,7 +247,7 @@ CodeTemplate parse_template( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_template(); @@ -260,7 +260,7 @@ CodeType parse_type( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_type(); @@ -273,7 +273,7 @@ CodeTypedef parse_typedef( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_typedef(); @@ -286,7 +286,7 @@ CodeUnion parse_union( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_union(); @@ -299,7 +299,7 @@ CodeUsing parse_using( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_using(); @@ -312,7 +312,7 @@ CodeVar parse_variable( StrC def ) TokArray toks = lex( def ); if ( toks.Arr == nullptr ) - return CodeInvalid; + return InvalidCode; Context.Tokens = toks; return parse_variable(); diff --git a/project/components/interface.untyped.cpp b/project/components/interface.untyped.cpp index 4f49d5f..f8beb4c 100644 --- a/project/components/interface.untyped.cpp +++ b/project/components/interface.untyped.cpp @@ -106,7 +106,7 @@ Code untyped_str( StrC content ) if ( content.Len == 0 ) { log_failure( "untyped_str: empty string" ); - return CodeInvalid; + return InvalidCode; } Code @@ -118,7 +118,7 @@ Code untyped_str( StrC content ) if ( result->Name == nullptr ) { log_failure( "untyped_str: could not cache string" ); - return CodeInvalid; + return InvalidCode; } return result; @@ -129,7 +129,7 @@ Code untyped_fmt( char const* fmt, ...) if ( fmt == nullptr ) { log_failure( "untyped_fmt: null format string" ); - return CodeInvalid; + return InvalidCode; } local_persist thread_local @@ -149,7 +149,7 @@ Code untyped_fmt( char const* fmt, ...) if ( result->Name == nullptr ) { log_failure( "untyped_fmt: could not cache string" ); - return CodeInvalid; + return InvalidCode; } return result; @@ -160,7 +160,7 @@ Code untyped_token_fmt( s32 num_tokens, ... ) if ( num_tokens == 0 ) { log_failure( "untyped_token_fmt: zero tokens" ); - return CodeInvalid; + return InvalidCode; } local_persist thread_local @@ -180,7 +180,7 @@ Code untyped_token_fmt( s32 num_tokens, ... ) if ( result->Name == nullptr ) { log_failure( "untyped_fmt: could not cache string" ); - return CodeInvalid; + return InvalidCode; } return result; diff --git a/project/components/interface.upfront.cpp b/project/components/interface.upfront.cpp index fab42a1..af72be6 100644 --- a/project/components/interface.upfront.cpp +++ b/project/components/interface.upfront.cpp @@ -381,13 +381,13 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy if ( Name_.Len <= 0 ) \ { \ log_failure( "gen::" stringize(Context_) ": Invalid name length provided - %d", Name_.Len ); \ - return CodeInvalid; \ + return InvalidCode; \ } \ \ if ( Name_.Ptr == nullptr ) \ { \ log_failure( "gen::" stringize(Context_) ": name is null" ); \ - return CodeInvalid; \ + return InvalidCode; \ } \ } @@ -395,7 +395,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy if ( ! Code_ ) \ { \ log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \ - return CodeInvalid; \ + return InvalidCode; \ } #define null_or_invalid_check( Context_, Code_ ) \ @@ -403,19 +403,19 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy if ( ! Code_ ) \ { \ log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \ - return CodeInvalid; \ + return InvalidCode; \ } \ \ if ( Code_->is_invalid() ) \ { \ log_failure("gen::" stringize(Context_) ": " stringize(Code_) " provided is invalid" ); \ - return CodeInvalid; \ + return InvalidCode; \ } \ } #define not_implemented( Context_ ) \ log_failure( "gen::%s: This function is not implemented" ); \ - return CodeInvalid; + return InvalidCode; #pragma endregion Helper Marcos @@ -436,7 +436,7 @@ CodeAttributes def_attributes( StrC content ) if ( content.Len <= 0 || content.Ptr == nullptr ) { log_failure( "gen::def_attributes: Invalid attributes provided" ); - return CodeInvalid; + return InvalidCode; } Code @@ -453,7 +453,7 @@ CodeComment def_comment( StrC content ) if ( content.Len <= 0 || content.Ptr == nullptr ) { log_failure( "gen::def_comment: Invalid comment provided:" ); - return CodeInvalid; + return InvalidCode; } static char line[ MaxCommentLineLength ]; @@ -502,7 +502,7 @@ CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code b if ( params && params->Type != Parameters ) { log_failure("gen::def_constructor: params must be of Parameters type - %s", params.debug_str()); - return CodeInvalid; + return InvalidCode; } CodeConstructor @@ -528,7 +528,7 @@ CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code b default: log_failure("gen::def_constructor: body must be either of Function_Body or Untyped type - %s", body.debug_str()); - return CodeInvalid; + return InvalidCode; } result->Type = Constructor; @@ -556,13 +556,13 @@ CodeClass def_class( StrC name if ( attributes && attributes->Type != PlatformAttributes ) { log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( parent && ( parent->Type != Class && parent->Type != Struct && parent->Type != Typename && parent->Type != Untyped ) ) { log_failure( "gen::def_class: parent provided is not type 'Class', 'Struct', 'Typeanme', or 'Untyped': %s", parent.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeClass @@ -580,7 +580,7 @@ CodeClass def_class( StrC name default: log_failure("gen::def_class: body must be either of Class_Body or Untyped type - %s", body.debug_str()); - return CodeInvalid; + return InvalidCode; } result->Type = Class; @@ -623,7 +623,7 @@ CodeDefine def_define( StrC name, StrC content ) if ( content.Len <= 0 || content.Ptr == nullptr ) { log_failure( "gen::def_define: Invalid value provided" ); - return CodeInvalid; + return InvalidCode; } #endif @@ -648,7 +648,7 @@ CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers ) if ( specifiers && specifiers->Type != Specifiers ) { log_failure( "gen::def_destructor: specifiers was not a 'Specifiers' type: %s", specifiers.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeDestructor result = (CodeDestructor) make_code(); @@ -666,7 +666,7 @@ CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers ) default: log_failure("gen::def_destructor: body must be either of Function_Body or Untyped type - %s", body.debug_str()); - return CodeInvalid; + return InvalidCode; } result->Type = Destructor; @@ -692,13 +692,13 @@ CodeEnum def_enum( StrC name if ( type && type->Type != Typename ) { log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", type.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( attributes && attributes->Type != PlatformAttributes ) { log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeEnum @@ -716,7 +716,7 @@ CodeEnum def_enum( StrC name default: log_failure( "gen::def_enum: body must be of Enum_Body or Untyped type %s", body.debug_str()); - return CodeInvalid; + return InvalidCode; } result->Type = specifier == EnumDecl_Class ? @@ -740,7 +740,7 @@ CodeEnum def_enum( StrC name else if ( result->Type != Enum_Class_Fwd && result->Type != Enum_Fwd ) { log_failure( "gen::def_enum: enum forward declaration must have an underlying type" ); - return CodeInvalid; + return InvalidCode; } return result; @@ -751,7 +751,7 @@ CodeExec def_execution( StrC content ) if ( content.Len <= 0 || content.Ptr == nullptr ) { log_failure( "gen::def_execution: Invalid execution provided" ); - return CodeInvalid; + return InvalidCode; } Code @@ -773,7 +773,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()); - return CodeInvalid; + return InvalidCode; } CodeExtern @@ -805,7 +805,7 @@ CodeFriend def_friend( Code declaration ) default: log_failure("gen::def_friend: requires declartion to have class, function, operator, or struct - %s", declaration->debug_str()); - return CodeInvalid; + return InvalidCode; } CodeFriend @@ -829,25 +829,25 @@ CodeFn def_function( StrC name if ( params && params->Type != Parameters ) { log_failure( "gen::def_function: params was not a `Parameters` type: %s", params.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( ret_type && ret_type->Type != Typename ) { log_failure( "gen::def_function: ret_type was not a Typename: %s", ret_type.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( specifiers && specifiers->Type != Specifiers ) { log_failure( "gen::def_function: specifiers was not a `Specifiers` type: %s", specifiers.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( attributes && attributes->Type != PlatformAttributes ) { log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeFn @@ -867,7 +867,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()); - return CodeInvalid; + return InvalidCode; } } @@ -905,7 +905,7 @@ CodeInclude def_include( StrC path, bool foreign ) if ( path.Len <= 0 || path.Ptr == nullptr ) { log_failure( "gen::def_include: Invalid path provided - %d" ); - return CodeInvalid; + return InvalidCode; } StrC content = foreign ? @@ -945,7 +945,7 @@ CodeNS def_namespace( StrC name, Code body, ModuleFlag mflags ) if ( body->Type != Namespace_Body && body->Type != Untyped ) { log_failure("gen::def_namespace: body is not of namespace or untyped type %s", body.debug_str()); - return CodeInvalid; + return InvalidCode; } CodeNS @@ -968,20 +968,20 @@ CodeOperator def_operator( OperatorT op, StrC nspace if ( attributes && attributes->Type != PlatformAttributes ) { log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( specifiers && specifiers->Type != Specifiers ) { log_failure( "gen::def_operator: Specifiers was provided but its not of specifiers type: %s", specifiers.debug_str() ); - return CodeInvalid; + return InvalidCode; } OpValidateResult check_result = operator__validate( op, params_code, ret_type, specifiers ); if ( check_result == OpValidateResult::Fail ) { - return CodeInvalid; + return InvalidCode; } char const* name = nullptr; @@ -1009,7 +1009,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()); - return CodeInvalid; + return InvalidCode; } } @@ -1046,7 +1046,7 @@ CodeOpCast def_operator_cast( CodeType type, Code body, CodeSpecifiers const_spe if ( type->Type != Typename ) { log_failure( "gen::def_operator_cast: type is not a typename - %s", type.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeOpCast result = (CodeOpCast) make_code(); @@ -1058,7 +1058,7 @@ CodeOpCast def_operator_cast( CodeType type, Code body, CodeSpecifiers const_spe if ( body->Type != Function_Body && body->Type != Execution ) { log_failure( "gen::def_operator_cast: body is not of function body or execution type - %s", body.debug_str() ); - return CodeInvalid; + return InvalidCode; } result->Body = body; @@ -1087,13 +1087,13 @@ CodeParam def_param( CodeType type, StrC name, Code value ) if ( type->Type != Typename ) { log_failure( "gen::def_param: type is not a typename - %s", type.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( value && value->Type != Untyped ) { log_failure( "gen::def_param: value is not untyped - %s", value.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeParam @@ -1118,7 +1118,7 @@ CodePragma def_pragma( StrC directive ) if ( directive.Len <= 0 || directive.Ptr == nullptr ) { log_failure( "gen::def_comment: Invalid comment provided:" ); - return CodeInvalid; + return InvalidCode; } CodePragma @@ -1136,7 +1136,7 @@ CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC expr ) if ( expr.Len <= 0 || expr.Ptr == nullptr ) { log_failure( "gen::def_comment: Invalid comment provided:" ); - return CodeInvalid; + return InvalidCode; } CodePreprocessCond @@ -1184,19 +1184,19 @@ CodeStruct def_struct( StrC name if ( attributes && attributes->Type != PlatformAttributes ) { log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( parent && parent->Type != Typename ) { log_failure( "gen::def_struct: parent was not a `Struct` type - %s", parent.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( body && body->Type != Struct_Body ) { log_failure( "gen::def_struct: body was not a Struct_Body type - %s", body.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeStruct @@ -1243,7 +1243,7 @@ CodeTemplate def_template( CodeParam params, Code declaration, ModuleFlag mflags if ( params && params->Type != ECode::Parameters ) { log_failure( "gen::def_template: params is not of parameters type - %s", params.debug_str() ); - return CodeInvalid; + return InvalidCode; } switch (declaration->Type ) @@ -1276,19 +1276,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() ); - return CodeInvalid; + return InvalidCode; } if ( specifiers && specifiers->Type != ECode::Specifiers ) { log_failure( "gen::def_type: specifiers is not of specifiers type - %s", specifiers.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( arrayexpr && arrayexpr->Type != ECode::Untyped ) { log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", arrayexpr->debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeType @@ -1330,13 +1330,13 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module break; default: log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", type.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( attributes && attributes->Type != ECode::PlatformAttributes ) { log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } // Registering the type. @@ -1345,7 +1345,7 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module if ( ! registered_type ) { log_failure( "gen::def_typedef: failed to register type" ); - return CodeInvalid; + return InvalidCode; } CodeTypedef @@ -1360,7 +1360,7 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module if (type->Type != Untyped) { log_failure( "gen::def_typedef: name was empty and type was not untyped (indicating its a function typedef) - %s", type.debug_str() ); - return CodeInvalid; + return InvalidCode; } result->Name = get_cached_string( type->Name ); @@ -1382,13 +1382,13 @@ CodeUnion def_union( StrC name, Code body, CodeAttributes attributes, ModuleFlag if ( body->Type != ECode::Union_Body ) { log_failure( "gen::def_union: body was not a Union_Body type - %s", body.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( attributes && attributes->Type != ECode::PlatformAttributes ) { log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeUnion @@ -1419,13 +1419,13 @@ CodeUsing def_using( StrC name, CodeType type if ( ! register_type ) { log_failure( "gen::def_using: failed to register type" ); - return CodeInvalid; + return InvalidCode; } if ( attributes && attributes->Type != ECode::PlatformAttributes ) { log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeUsing @@ -1465,25 +1465,25 @@ CodeVar def_variable( CodeType type, StrC name, Code value if ( attributes && attributes->Type != ECode::PlatformAttributes ) { log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( specifiers && specifiers->Type != ECode::Specifiers ) { log_failure( "gen::def_variable: specifiers was not a `Specifiers` type - %s", specifiers.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( type->Type != ECode::Typename ) { log_failure( "gen::def_variable: type was not a Typename - %s", type.debug_str() ); - return CodeInvalid; + return InvalidCode; } if ( value && value->Type != ECode::Untyped ) { log_failure( "gen::def_variable: value was not a `Untyped` type - %s", value.debug_str() ); - return CodeInvalid; + return InvalidCode; } CodeVar @@ -1513,7 +1513,7 @@ using namespace ECode; \ if ( num <= 0 ) \ { \ log_failure("gen::" stringize(Name_) ": num cannot be zero or negative"); \ - return CodeInvalid; \ + return InvalidCode; \ } #define def_body_code_array_start( Name_ ) \ @@ -1522,13 +1522,13 @@ using namespace ECode; \ if ( num <= 0 ) \ { \ log_failure("gen::" stringize(Name_) ": num cannot be zero or negative"); \ - return CodeInvalid; \ + return InvalidCode; \ } \ \ if ( codes == nullptr ) \ { \ log_failure("gen::" stringize(Name_)" : Provided a null array of codes"); \ - return CodeInvalid; \ + return InvalidCode; \ } #pragma endregion Helper Macros for def_**_body functions @@ -1552,14 +1552,14 @@ CodeBody def_class_body( s32 num, ... ) log_failure("gen::" "def_class_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_CLASS_UNALLOWED_TYPES log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -1589,14 +1589,14 @@ CodeBody def_class_body( s32 num, Code* codes ) if (!entry) { log_failure("gen::" "def_class_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_CLASS_UNALLOWED_TYPES log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -1627,13 +1627,13 @@ CodeBody def_enum_body( s32 num, ... ) if ( ! entry ) { log_failure("gen::def_enum_body: Provided a null entry"); - return CodeInvalid; + return InvalidCode; } if ( entry->Type != Untyped && entry->Type != Comment ) { log_failure("gen::def_enum_body: Entry type is not allowed - %s. Must be of untyped or comment type.", entry.debug_str() ); - return CodeInvalid; + return InvalidCode; } result.append( entry ); @@ -1659,13 +1659,13 @@ CodeBody def_enum_body( s32 num, Code* codes ) if ( ! entry ) { log_failure("gen::def_enum_body: Provided a null entry"); - return CodeInvalid; + return InvalidCode; } if ( entry->Type != Untyped && entry->Type != Comment ) { log_failure("gen::def_enum_body: Entry type is not allowed: %s", entry.debug_str() ); - return CodeInvalid; + return InvalidCode; } result.append( entry ); @@ -1693,14 +1693,14 @@ CodeBody def_export_body( s32 num, ... ) if (!entry) { log_failure("gen::" "def_export_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_EXPORT_UNALLOWED_TYPES log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -1730,14 +1730,14 @@ CodeBody def_export_body( s32 num, Code* codes ) if (!entry) { log_failure("gen::" "def_export_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_EXPORT_UNALLOWED_TYPES log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -1768,14 +1768,14 @@ CodeBody def_extern_link_body( s32 num, ... ) if (!entry) { log_failure("gen::" "def_extern_linkage_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -1805,14 +1805,14 @@ CodeBody def_extern_link_body( s32 num, Code* codes ) if (!entry) { log_failure("gen::" "def_extern_linkage_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -1844,7 +1844,7 @@ CodeBody def_function_body( s32 num, ... ) if (!entry) { log_failure("gen::" stringize(def_function_body) ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) @@ -1852,7 +1852,7 @@ CodeBody def_function_body( s32 num, ... ) GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES log_failure("gen::" stringize(def_function_body) ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -1882,14 +1882,14 @@ CodeBody def_function_body( s32 num, Code* codes ) if (!entry) { log_failure("gen::" "def_function_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES log_failure("gen::" "def_function_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -1919,7 +1919,7 @@ CodeBody def_global_body( s32 num, ... ) if (!entry) { log_failure("gen::" "def_global_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) @@ -1930,7 +1930,7 @@ CodeBody def_global_body( s32 num, ... ) GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", entry.debug_str()); - return (*Code::Invalid.ast); + return InvalidCode; default: break; @@ -1960,7 +1960,7 @@ CodeBody def_global_body( s32 num, Code* codes ) if (!entry) { log_failure("gen::" "def_global_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) @@ -1971,7 +1971,7 @@ CodeBody def_global_body( s32 num, Code* codes ) GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -2002,14 +2002,14 @@ CodeBody def_namespace_body( s32 num, ... ) if (!entry) { log_failure("gen::" "def_namespace_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -2039,14 +2039,14 @@ CodeBody def_namespace_body( s32 num, Code* codes ) if (!entry) { log_failure("gen::" "def_namespace_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str() ); - return CodeInvalid; + return InvalidCode; default: break; } @@ -2073,7 +2073,7 @@ CodeParam def_params( s32 num, ... ) if ( param->Type != Parameters ) { log_failure( "gen::def_params: param %d is not a Parameters", num - num + 1 ); - return CodeInvalid; + return InvalidCode; } CodeParam result = (CodeParam) param.duplicate(); @@ -2086,7 +2086,7 @@ CodeParam def_params( s32 num, ... ) if ( param->Type != Parameters ) { log_failure( "gen::def_params: param %d is not a Parameters", num - num + 1 ); - return CodeInvalid; + return InvalidCode; } result.append( param ); @@ -2104,13 +2104,13 @@ CodeParam def_params( s32 num, CodeParam* codes ) if ( current.ast == nullptr ) \ { \ log_failure("gen::def_params: Provide a null code in codes array"); \ - return CodeInvalid; \ + return InvalidCode; \ } \ \ if (current->Type != Parameters ) \ { \ log_failure("gen::def_params: Code in coes array is not of paramter type - %s", current.debug_str() ); \ - return CodeInvalid; \ + return InvalidCode; \ } CodeParam current = (CodeParam) codes->duplicate(); @@ -2137,13 +2137,13 @@ CodeSpecifiers def_specifiers( s32 num, ... ) if ( num <= 0 ) { log_failure("gen::def_specifiers: num cannot be zero or less"); - return CodeInvalid; + return InvalidCode; } if ( num > AST::ArrSpecs_Cap ) { log_failure("gen::def_specifiers: num of speciifers to define AST larger than AST specicifier capacity - %d", num); - return CodeInvalid; + return InvalidCode; } CodeSpecifiers @@ -2169,13 +2169,13 @@ CodeSpecifiers def_specifiers( s32 num, SpecifierT* specs ) if ( num <= 0 ) { log_failure("gen::def_specifiers: num cannot be zero or less"); - return CodeInvalid; + return InvalidCode; } if ( num > AST::ArrSpecs_Cap ) { log_failure("gen::def_specifiers: num of speciifers to define AST larger than AST specicifier capacity - %d", num); - return CodeInvalid; + return InvalidCode; } CodeSpecifiers @@ -2211,14 +2211,14 @@ CodeBody def_struct_body( s32 num, ... ) if (!entry) { log_failure("gen::" "def_struct_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_STRUCT_UNALLOWED_TYPES log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str()); - return CodeInvalid; + return InvalidCode; default: break; @@ -2248,14 +2248,14 @@ CodeBody def_struct_body( s32 num, Code* codes ) if (!entry) { log_failure("gen::" "def_struct_body" ": Provided an null entry"); - return CodeInvalid; + return InvalidCode; } switch (entry->Type) { GEN_AST_BODY_STRUCT_UNALLOWED_TYPES log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str() ); - return CodeInvalid; + return InvalidCode; default: break; @@ -2286,13 +2286,13 @@ CodeBody def_union_body( s32 num, ... ) if ( ! entry ) { log_failure("gen::def_union_body: Provided a null entry"); - return CodeInvalid; + return InvalidCode; } if ( entry->Type != Untyped && entry->Type != Comment ) { log_failure("gen::def_union_body: Entry type is not allowed - %s. Must be of untyped or comment type.", entry.debug_str() ); - return CodeInvalid; + return InvalidCode; } result.append( entry ); @@ -2318,13 +2318,13 @@ CodeBody def_union_body( s32 num, CodeUnion* codes ) if ( ! entry ) { log_failure("gen::def_union_body: Provided a null entry"); - return CodeInvalid; + return InvalidCode; } if ( entry->Type != Untyped && entry->Type != Comment ) { log_failure("gen::def_union_body: Entry type is not allowed: %s", entry.debug_str() ); - return CodeInvalid; + return InvalidCode; } result.append( entry ); diff --git a/project/components/parser.cpp b/project/components/parser.cpp index 7055811..196a3d1 100644 --- a/project/components/parser.cpp +++ b/project/components/parser.cpp @@ -153,13 +153,13 @@ if ( def.Len <= 0 ) \ { \ log_failure( "gen::" stringize(__func__) ": length must greater than 0" ); \ parser::Context.pop(); \ - return CodeInvalid; \ + return InvalidCode; \ } \ if ( def.Ptr == nullptr ) \ { \ log_failure( "gen::" stringize(__func__) ": def was null" ); \ parser::Context.pop(); \ - return CodeInvalid; \ + return InvalidCode; \ } # define currtok_noskip Context.Tokens.current( dont_skip_formatting ) @@ -505,14 +505,14 @@ Code parse_array_decl() { log_failure( "Error, unexpected end of array declaration ( '[]' scope started )\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if ( currtok.Type == TokType::BraceSquare_Close ) { log_failure( "Error, empty array expression in definition\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } Token untyped_tok = currtok; @@ -531,14 +531,14 @@ Code parse_array_decl() { log_failure( "Error, unexpected end of array declaration, expected ]\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if ( currtok.Type != TokType::BraceSquare_Close ) { log_failure( "%s: Error, expected ] in array declaration, not %s\n%s", ETokType::to_str( currtok.Type ), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } eat( TokType::BraceSquare_Close ); @@ -678,7 +678,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) if ( which != TokType::Decl_Class && which != TokType::Decl_Struct ) { log_failure( "Error, expected class or struct, not %s\n%s", ETokType::to_str( which ), Context.to_string() ); - return CodeInvalid; + return InvalidCode; } Token name { nullptr, 0, TokType::Invalid }; @@ -689,7 +689,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) CodeAttributes attributes = { nullptr }; ModuleFlag mflags = ModuleFlag_None; - CodeClass result = CodeInvalid; + CodeClass result = InvalidCode; if ( check(TokType::Module_Export) ) { @@ -802,7 +802,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) while ( left && currtok_noskip.Type != TokType::BraceCurly_Close ) { - Code member = Code::Invalid; + Code member = Code_Invalid; CodeAttributes attributes = { nullptr }; CodeSpecifiers specifiers = { nullptr }; @@ -901,7 +901,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) if ( currtok.Text[0] != '~' ) { log_failure( "Operator token found in global body but not destructor unary negation\n%s", Context.to_string() ); - return CodeInvalid; + return InvalidCode; } member = parse_destructor(); @@ -1015,7 +1015,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) default: log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str(spec), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // Every specifier after would be considered part of the type type signature @@ -1108,11 +1108,11 @@ CodeBody parse_class_struct_body( TokType which, Token name ) break; } - if ( member == Code::Invalid ) + if ( member == Code_Invalid ) { log_failure( "Failed to parse member\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } result.append( member ); @@ -1200,7 +1200,7 @@ Code parse_complicated_definition( TokType which ) log_failure( "Unsupported or bad member definition after %s declaration\n%s", to_str(which), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if ( tok.Type == TokType::Identifier ) { @@ -1245,7 +1245,7 @@ Code parse_complicated_definition( TokType which ) { log_failure( "Unsupported or bad member definition after %s declaration\n%s", to_str(which), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } Code result = parse_operator_function_or_variable( false, { nullptr }, { nullptr } ); @@ -1264,7 +1264,7 @@ Code parse_complicated_definition( TokType which ) { log_failure( "Unsupported or bad member definition after %s declaration\n%s", to_str(which), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // Its a forward declaration of an enum class @@ -1294,7 +1294,7 @@ Code parse_complicated_definition( TokType which ) { log_failure( "Unsupported or bad member definition after %s declaration\n%S", to_str(which).Ptr, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } } @@ -1313,7 +1313,7 @@ CodeDefine parse_define() { log_failure( "Error, expected identifier after #define\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } Context.Scope->Name = currtok; @@ -1325,7 +1325,7 @@ CodeDefine parse_define() { log_failure( "Error, expected content after #define %s\n%s", define->Name, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if ( currtok.Length == 0 ) @@ -1360,7 +1360,7 @@ Code parse_assignment_expression() { log_failure( "Expected expression after assignment operator\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } s32 level = 0; @@ -1387,7 +1387,7 @@ Code parse_assignment_expression() internal inline Code parse_forward_or_definition( TokType which, bool is_inplace ) { - Code result = CodeInvalid; + Code result = InvalidCode; switch ( which ) { @@ -1412,7 +1412,7 @@ Code parse_forward_or_definition( TokType which, bool is_inplace ) "(only supports class, enum, struct, union) \n%s" , Context.to_string() ); - return CodeInvalid; + return InvalidCode; } } @@ -1450,10 +1450,10 @@ CodeFn parse_function_after_name( if ( check( TokType::BraceCurly_Open ) ) { body = parse_function_body(); - if ( body == Code::Invalid ) + if ( body == Code_Invalid ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // ( ) { } } @@ -1505,7 +1505,7 @@ CodeFn parse_function_after_name( { log_failure("Body must be either of Function_Body or Untyped type, %s\n%s", body.debug_str(), Context.to_string()); Context.pop(); - return CodeInvalid; + return InvalidCode; } } @@ -1585,7 +1585,7 @@ CodeBody parse_global_nspace( CodeT which ) push_scope(); if ( which != Namespace_Body && which != Global_Body && which != Export_Body && which != Extern_Linkage_Body ) - return CodeInvalid; + return InvalidCode; if ( which != Global_Body ) eat( TokType::BraceCurly_Open ); @@ -1597,7 +1597,7 @@ CodeBody parse_global_nspace( CodeT which ) while ( left && currtok_noskip.Type != TokType::BraceCurly_Close ) { - Code member = Code::Invalid; + Code member = Code_Invalid; CodeAttributes attributes = { nullptr }; CodeSpecifiers specifiers = { nullptr }; @@ -1798,7 +1798,7 @@ CodeBody parse_global_nspace( CodeT which ) log_failure( "Invalid specifier %.*s for variable\n%s", spec_str.Len, spec_str, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if (ignore_spec) @@ -1870,11 +1870,11 @@ CodeBody parse_global_nspace( CodeT which ) } } - if ( member == Code::Invalid ) + if ( member == Code_Invalid ) { log_failure( "Failed to parse member\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // log_fmt("Global Body Member: %s", member->debug_str()); @@ -2108,7 +2108,7 @@ CodeInclude parse_include() { log_failure( "Error, expected include string after #include\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } Context.Scope->Name = currtok; @@ -2157,7 +2157,7 @@ CodeOperator parse_operator_after_ret_type( { log_failure( "Expected operator after 'operator' keyword\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } Context.Scope->Name = currtok; @@ -2410,7 +2410,7 @@ CodeOperator parse_operator_after_ret_type( { log_failure( "Invalid operator '%s'\n%s", prevtok.Text, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } } } @@ -2420,7 +2420,7 @@ CodeOperator parse_operator_after_ret_type( { log_failure( "Invalid operator '%s'\n%s", currtok.Text, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if ( ! was_new_or_delete) @@ -2454,10 +2454,10 @@ CodeOperator parse_operator_after_ret_type( if ( check( TokType::BraceCurly_Open ) ) { body = parse_function_body(); - if ( body == Code::Invalid ) + if ( body == Code_Invalid ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // operator ( ) { ... } } @@ -2487,7 +2487,7 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes { push_scope(); - Code result = CodeInvalid; + Code result = InvalidCode; #ifndef GEN_PARSER_DISABLE_MACRO_FUNCTION_SIGNATURES if ( currtok.Type == TokType::Preprocess_Macro ) @@ -2503,10 +2503,10 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes CodeType type = parse_type(); // - if ( type == CodeInvalid ) + if ( type == InvalidCode ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } bool found_operator = false; @@ -2562,7 +2562,7 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes { log_failure( "Expected function declaration (consteval was used)\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // Dealing with a variable @@ -2590,7 +2590,7 @@ CodePragma parse_pragma() { log_failure( "Error, expected content after #pragma\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } Context.Scope->Name = currtok; @@ -2667,10 +2667,10 @@ CodeParam parse_params( bool use_template_capture ) if ( currtok.Type != TokType::Comma ) { type = parse_type( use_template_capture ); - if ( type == Code::Invalid ) + if ( type == Code_Invalid ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // ( @@ -2704,7 +2704,7 @@ CodeParam parse_params( bool use_template_capture ) { log_failure( "Expected value after assignment operator\n%s.", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } s32 capture_level = 0; @@ -2777,10 +2777,10 @@ CodeParam parse_params( bool use_template_capture ) if ( currtok.Type != TokType::Comma ) { type = parse_type( use_template_capture ); - if ( type == Code::Invalid ) + if ( type == Code_Invalid ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // ( = , @@ -2816,7 +2816,7 @@ CodeParam parse_params( bool use_template_capture ) { log_failure( "Expected value after assignment operator\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } s32 capture_level = 0; @@ -2877,7 +2877,7 @@ CodeParam parse_params( bool use_template_capture ) { log_failure( "Expected '<' after 'template' keyword\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } eat( TokType::Operator ); // < = , = , .. > @@ -2897,7 +2897,7 @@ CodePreprocessCond parse_preprocess_cond() { log_failure( "Error, expected preprocess conditional\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } CodePreprocessCond @@ -2910,7 +2910,7 @@ CodePreprocessCond parse_preprocess_cond() { log_failure( "Error, expected content after #define\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } Context.Scope->Name = currtok; @@ -3168,7 +3168,7 @@ CodeVar parse_variable_after_name( { log_failure( "Expected expression after bitfield \n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } while ( left && currtok.Type != TokType::Statement_End ) @@ -3466,7 +3466,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers ) else { log_failure( "Expected destructor '~' token\n%s", Context.to_string() ); - return CodeInvalid; + return InvalidCode; } // ~ @@ -3503,7 +3503,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers ) else { log_failure( "Pure or default specifier expected due to '=' token\n%s", Context.to_string() ); - return CodeInvalid; + return InvalidCode; } pure_virtual = true; @@ -3598,11 +3598,11 @@ CodeEnum parse_enum( bool inplace_def ) // enum : type = parse_type(); - if ( type == Code::Invalid ) + if ( type == Code_Invalid ) { log_failure( "Failed to parse enum classifier\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // enum : } @@ -3628,7 +3628,7 @@ CodeEnum parse_enum( bool inplace_def ) eat( TokType::BraceCurly_Open ); // enum : { - Code member = CodeInvalid; + Code member = InvalidCode; bool expects_entry = true; while ( left && currtok_noskip.Type != TokType::BraceCurly_Close ) @@ -3736,11 +3736,11 @@ CodeEnum parse_enum( bool inplace_def ) break; } - if ( member == Code::Invalid ) + if ( member == Code_Invalid ) { log_failure( "Failed to parse member\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } body.append( member ); @@ -3839,7 +3839,7 @@ CodeExtern parse_extern_link() result->Name = get_cached_string( name ); Code entry = parse_extern_link_body(); - if ( entry == Code::Invalid ) + if ( entry == Code_Invalid ) { log_failure( "Failed to parse body\n%s", Context.to_string() ); Context.pop(); @@ -3866,10 +3866,10 @@ CodeFriend parse_friend() // Type declaration or return type CodeType type = parse_type(); - if ( type == Code::Invalid ) + if ( type == Code_Invalid ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // friend @@ -3966,7 +3966,7 @@ CodeFn parse_function() default: log_failure( "Invalid specifier %s for functon\n%s", ESpecifier::to_str(spec), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if ( spec == ESpecifier::Const ) @@ -3984,10 +3984,10 @@ CodeFn parse_function() // CodeType ret_type = parse_type(); - if ( ret_type == Code::Invalid ) + if ( ret_type == Code_Invalid ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // @@ -3996,7 +3996,7 @@ CodeFn parse_function() if ( ! name ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // @@ -4020,10 +4020,10 @@ CodeNS parse_namespace() // namespace CodeBody body = parse_global_nspace( ECode::Namespace_Body ); - if ( body == Code::Invalid ) + if ( body == Code_Invalid ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // namespace { } @@ -4077,7 +4077,7 @@ CodeOperator parse_operator() default: log_failure( "Invalid specifier " "%s" " for operator\n%s", ESpecifier::to_str(spec), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if ( spec == ESpecifier::Const ) @@ -4246,10 +4246,10 @@ CodeTemplate parse_template() // template Code params = parse_params( UseTemplateCapture ); - if ( params == Code::Invalid ) + if ( params == Code_Invalid ) { Context.pop(); - return CodeInvalid; + return InvalidCode; } // template< > @@ -4328,7 +4328,7 @@ CodeTemplate parse_template() default : log_failure( "Invalid specifier %s for variable or function\n%s", ESpecifier::to_str( spec ), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // Ignore const it will be handled by the type @@ -4451,7 +4451,7 @@ CodeType parse_type( bool from_template, bool* typedef_is_function ) { log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } specs_found[ NumSpecifiers ] = spec; @@ -4464,7 +4464,7 @@ CodeType parse_type( bool from_template, bool* typedef_is_function ) { log_failure( "Error, unexpected end of type definition\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } if ( from_template && currtok.Type == TokType::Decl_Class ) @@ -4548,7 +4548,7 @@ else if ( currtok.Type == TokType::DeclType ) { log_failure( "Error, failed to type signature\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } } } @@ -4562,7 +4562,7 @@ else if ( currtok.Type == TokType::DeclType ) { log_failure( "Error, failed to type signature\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // // @@ -4577,7 +4577,7 @@ else if ( currtok.Type == TokType::DeclType ) { log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } specs_found[ NumSpecifiers ] = spec; @@ -4710,7 +4710,7 @@ else if ( currtok.Type == TokType::DeclType ) { log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } specs_found[ NumSpecifiers ] = spec; @@ -4780,7 +4780,7 @@ else if ( currtok.Type == TokType::DeclType ) { log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } specs_found[ NumSpecifiers ] = spec; @@ -4978,7 +4978,7 @@ CodeTypedef parse_typedef() { log_failure( "Unsupported or bad member definition after struct declaration\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // TODO(Ed) : I'm not sure if I have to use parse_type here, I'd rather not as that would complicate parse_type. @@ -5004,7 +5004,7 @@ CodeTypedef parse_typedef() { log_failure( "Unsupported or bad member definition after struct declaration\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } } } @@ -5025,7 +5025,7 @@ CodeTypedef parse_typedef() { log_failure( "Error, expected identifier for typedef\n%s", Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } array_expr = parse_array_decl(); @@ -5360,7 +5360,7 @@ CodeVar parse_variable() default: log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), Context.to_string() ); Context.pop(); - return CodeInvalid; + return InvalidCode; } // Ignore const specifiers, they're handled by the type @@ -5381,8 +5381,8 @@ CodeVar parse_variable() CodeType type = parse_type(); // - if ( type == Code::Invalid ) - return CodeInvalid; + if ( type == Code_Invalid ) + return InvalidCode; Context.Scope->Name = parse_identifier(); // diff --git a/project/helpers/helper.hpp b/project/helpers/helper.hpp index 388c0e9..0cc6673 100644 --- a/project/helpers/helper.hpp +++ b/project/helpers/helper.hpp @@ -346,9 +346,11 @@ CodeBody gen_ast_inlines() #pragma push_macro("GEN_NS") #pragma push_macro("rcast") #pragma push_macro("log_failure") +#pragma push_macro("CodeInvalid") #undef GEN_NS #undef rcast #undef log_failure +#undef CodeInvalid char const* code_impl_tmpl = stringize( \n inline @@ -365,7 +367,7 @@ CodeBody gen_ast_inlines() if ( ast == nullptr ) { log_failure("Code::duplicate: Cannot duplicate code, AST is null!"); - return Code::Invalid; + return Code_Invalid; } return { rcast(AST*, ast)->duplicate() }; @@ -404,7 +406,7 @@ CodeBody gen_ast_inlines() return; } - rcast(AST*, ast)->Parent = Code::Global.ast; + rcast(AST*, ast)->Parent = Code_Global.ast; } inline & ::operator =( Code other ) @@ -419,16 +421,6 @@ CodeBody gen_ast_inlines() return *this; } inline - bool ::operator ==( Code other ) - { - return (AST*) ast == other.ast; - } - inline - bool ::operator !=( Code other ) - { - return (AST*) ast != other.ast; - } - inline ::operator bool() { return ast != nullptr; @@ -459,6 +451,7 @@ CodeBody gen_ast_inlines() \n ); #pragma pop_macro("GEN_NS") +#pragma pop_macro("CodeInvalid") CodeBody impl_code = parse_global_body( token_fmt( "typename", StrC name(Code), code_impl_tmpl )); CodeBody impl_code_body = parse_global_body( token_fmt( "typename", StrC name(CodeBody), code_impl_tmpl ));