progress (Code)

This commit is contained in:
Edward R. Gonzalez 2024-12-02 00:03:38 -05:00
parent f9c21ebc04
commit 937235b776
10 changed files with 306 additions and 594 deletions

View File

@ -3,8 +3,8 @@
#include "static_data.cpp" #include "static_data.cpp"
#endif #endif
Code Code::Global; global Code Code_Global;
Code Code::Invalid; global Code Code_Invalid;
// This serializes all the data-members in a "debug" format, where each member is printed with its associated value. // 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) char const* debug_str(AST* self)

View File

@ -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 ); } template< class Type> forceinline Type tmpl_cast( Code& self ) { return * rcast( Type*, & self ); }
#endif #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 AST* wrapper
- Not constantly have to append the '*' as this is written often.. - 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 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 ) \ # define Using_Code( Typename ) \
char const* debug_str(); \ char const* debug_str(); \
@ -176,8 +177,8 @@ struct Code
String to_string(); \ String to_string(); \
Typename& operator = ( AST* other ); \ Typename& operator = ( AST* other ); \
Typename& operator = ( Code other ); \ Typename& operator = ( Code other ); \
bool operator ==( Code other ); \ bool operator ==( Code other ) { return (AST*)ast == other.ast; } \
bool operator !=( Code other ); \ bool operator !=( Code other ) { return (AST*)ast != other.ast; } \
operator bool(); operator bool();
Using_Code( Code ); Using_Code( Code );
@ -243,6 +244,14 @@ struct Code
#undef operator #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 struct Code_POD
{ {
AST* ast; 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. // Used when the its desired when omission is allowed in a definition.
#define NoCode { nullptr } #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.

View File

@ -19,7 +19,7 @@ inline Code Code::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline Code& Code::operator=( Code other ) inline Code& Code::operator=( Code other )
@ -68,16 +68,6 @@ inline Code& Code::operator=( Code other )
return *this; 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() inline Code::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -95,7 +85,7 @@ inline Code CodeBody::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeBody& CodeBody::operator=( Code other ) inline CodeBody& CodeBody::operator=( Code other )
@ -144,16 +134,6 @@ inline CodeBody& CodeBody::operator=( Code other )
return *this; 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() inline CodeBody::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -171,7 +151,7 @@ inline Code CodeAttributes::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeAttributes& CodeAttributes::operator=( Code other ) inline CodeAttributes& CodeAttributes::operator=( Code other )
@ -220,16 +200,6 @@ inline CodeAttributes& CodeAttributes::operator=( Code other )
return *this; 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() inline CodeAttributes::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -267,7 +237,7 @@ inline Code CodeComment::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeComment& CodeComment::operator=( Code other ) inline CodeComment& CodeComment::operator=( Code other )
@ -316,16 +286,6 @@ inline CodeComment& CodeComment::operator=( Code other )
return *this; 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() inline CodeComment::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -363,7 +323,7 @@ inline Code CodeConstructor::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeConstructor& CodeConstructor::operator=( Code other ) inline CodeConstructor& CodeConstructor::operator=( Code other )
@ -412,16 +372,6 @@ inline CodeConstructor& CodeConstructor::operator=( Code other )
return *this; 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() inline CodeConstructor::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -459,7 +409,7 @@ inline Code CodeClass::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeClass& CodeClass::operator=( Code other ) inline CodeClass& CodeClass::operator=( Code other )
@ -508,16 +458,6 @@ inline CodeClass& CodeClass::operator=( Code other )
return *this; 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() inline CodeClass::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -535,7 +475,7 @@ inline Code CodeDefine::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeDefine& CodeDefine::operator=( Code other ) inline CodeDefine& CodeDefine::operator=( Code other )
@ -584,16 +524,6 @@ inline CodeDefine& CodeDefine::operator=( Code other )
return *this; 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() inline CodeDefine::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -631,7 +561,7 @@ inline Code CodeDestructor::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeDestructor& CodeDestructor::operator=( Code other ) inline CodeDestructor& CodeDestructor::operator=( Code other )
@ -680,16 +610,6 @@ inline CodeDestructor& CodeDestructor::operator=( Code other )
return *this; 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() inline CodeDestructor::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -727,7 +647,7 @@ inline Code CodeEnum::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeEnum& CodeEnum::operator=( Code other ) inline CodeEnum& CodeEnum::operator=( Code other )
@ -776,16 +696,6 @@ inline CodeEnum& CodeEnum::operator=( Code other )
return *this; 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() inline CodeEnum::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -823,7 +733,7 @@ inline Code CodeExec::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeExec& CodeExec::operator=( Code other ) inline CodeExec& CodeExec::operator=( Code other )
@ -872,16 +782,6 @@ inline CodeExec& CodeExec::operator=( Code other )
return *this; 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() inline CodeExec::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -919,7 +819,7 @@ inline Code CodeExtern::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeExtern& CodeExtern::operator=( Code other ) inline CodeExtern& CodeExtern::operator=( Code other )
@ -968,16 +868,6 @@ inline CodeExtern& CodeExtern::operator=( Code other )
return *this; 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() inline CodeExtern::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1015,7 +905,7 @@ inline Code CodeFriend::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeFriend& CodeFriend::operator=( Code other ) inline CodeFriend& CodeFriend::operator=( Code other )
@ -1064,16 +954,6 @@ inline CodeFriend& CodeFriend::operator=( Code other )
return *this; 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() inline CodeFriend::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1111,7 +991,7 @@ inline Code CodeFn::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeFn& CodeFn::operator=( Code other ) inline CodeFn& CodeFn::operator=( Code other )
@ -1160,16 +1040,6 @@ inline CodeFn& CodeFn::operator=( Code other )
return *this; 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() inline CodeFn::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1207,7 +1077,7 @@ inline Code CodeInclude::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeInclude& CodeInclude::operator=( Code other ) inline CodeInclude& CodeInclude::operator=( Code other )
@ -1256,16 +1126,6 @@ inline CodeInclude& CodeInclude::operator=( Code other )
return *this; 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() inline CodeInclude::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1303,7 +1163,7 @@ inline Code CodeModule::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeModule& CodeModule::operator=( Code other ) inline CodeModule& CodeModule::operator=( Code other )
@ -1352,16 +1212,6 @@ inline CodeModule& CodeModule::operator=( Code other )
return *this; 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() inline CodeModule::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1399,7 +1249,7 @@ inline Code CodeNS::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeNS& CodeNS::operator=( Code other ) inline CodeNS& CodeNS::operator=( Code other )
@ -1448,16 +1298,6 @@ inline CodeNS& CodeNS::operator=( Code other )
return *this; 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() inline CodeNS::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1495,7 +1335,7 @@ inline Code CodeOperator::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeOperator& CodeOperator::operator=( Code other ) inline CodeOperator& CodeOperator::operator=( Code other )
@ -1544,16 +1384,6 @@ inline CodeOperator& CodeOperator::operator=( Code other )
return *this; 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() inline CodeOperator::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1591,7 +1421,7 @@ inline Code CodeOpCast::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeOpCast& CodeOpCast::operator=( Code other ) inline CodeOpCast& CodeOpCast::operator=( Code other )
@ -1640,16 +1470,6 @@ inline CodeOpCast& CodeOpCast::operator=( Code other )
return *this; 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() inline CodeOpCast::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1687,7 +1507,7 @@ inline Code CodeParam::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeParam& CodeParam::operator=( Code other ) inline CodeParam& CodeParam::operator=( Code other )
@ -1736,16 +1556,6 @@ inline CodeParam& CodeParam::operator=( Code other )
return *this; 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() inline CodeParam::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1763,7 +1573,7 @@ inline Code CodePragma::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodePragma& CodePragma::operator=( Code other ) inline CodePragma& CodePragma::operator=( Code other )
@ -1812,16 +1622,6 @@ inline CodePragma& CodePragma::operator=( Code other )
return *this; 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() inline CodePragma::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1859,7 +1659,7 @@ inline Code CodePreprocessCond::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodePreprocessCond& CodePreprocessCond::operator=( Code other ) inline CodePreprocessCond& CodePreprocessCond::operator=( Code other )
@ -1908,16 +1708,6 @@ inline CodePreprocessCond& CodePreprocessCond::operator=( Code other )
return *this; 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() inline CodePreprocessCond::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -1955,7 +1745,7 @@ inline Code CodeSpecifiers::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeSpecifiers& CodeSpecifiers::operator=( Code other ) inline CodeSpecifiers& CodeSpecifiers::operator=( Code other )
@ -2004,16 +1794,6 @@ inline CodeSpecifiers& CodeSpecifiers::operator=( Code other )
return *this; 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() inline CodeSpecifiers::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -2031,7 +1811,7 @@ inline Code CodeStruct::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeStruct& CodeStruct::operator=( Code other ) inline CodeStruct& CodeStruct::operator=( Code other )
@ -2080,16 +1860,6 @@ inline CodeStruct& CodeStruct::operator=( Code other )
return *this; 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() inline CodeStruct::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -2107,7 +1877,7 @@ inline Code CodeTemplate::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeTemplate& CodeTemplate::operator=( Code other ) inline CodeTemplate& CodeTemplate::operator=( Code other )
@ -2156,16 +1926,6 @@ inline CodeTemplate& CodeTemplate::operator=( Code other )
return *this; 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() inline CodeTemplate::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -2203,7 +1963,7 @@ inline Code CodeType::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeType& CodeType::operator=( Code other ) inline CodeType& CodeType::operator=( Code other )
@ -2252,16 +2012,6 @@ inline CodeType& CodeType::operator=( Code other )
return *this; 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() inline CodeType::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -2299,7 +2049,7 @@ inline Code CodeTypedef::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeTypedef& CodeTypedef::operator=( Code other ) inline CodeTypedef& CodeTypedef::operator=( Code other )
@ -2348,16 +2098,6 @@ inline CodeTypedef& CodeTypedef::operator=( Code other )
return *this; 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() inline CodeTypedef::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -2395,7 +2135,7 @@ inline Code CodeUnion::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeUnion& CodeUnion::operator=( Code other ) inline CodeUnion& CodeUnion::operator=( Code other )
@ -2444,16 +2184,6 @@ inline CodeUnion& CodeUnion::operator=( Code other )
return *this; 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() inline CodeUnion::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -2491,7 +2221,7 @@ inline Code CodeUsing::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeUsing& CodeUsing::operator=( Code other ) inline CodeUsing& CodeUsing::operator=( Code other )
@ -2540,16 +2270,6 @@ inline CodeUsing& CodeUsing::operator=( Code other )
return *this; 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() inline CodeUsing::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -2587,7 +2307,7 @@ inline Code CodeVar::duplicate()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" ); log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
return Code::Invalid; return Code_Invalid;
} }
return { rcast( AST*, ast )->duplicate() }; 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!" ); log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
return; return;
} }
rcast( AST*, ast )->Parent = Code::Global.ast; rcast( AST*, ast )->Parent = Code_Global.ast;
} }
inline CodeVar& CodeVar::operator=( Code other ) inline CodeVar& CodeVar::operator=( Code other )
@ -2636,16 +2356,6 @@ inline CodeVar& CodeVar::operator=( Code other )
return *this; 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() inline CodeVar::operator bool()
{ {
return ast != nullptr; return ast != nullptr;

View File

@ -209,7 +209,7 @@ CodeBody def_body( CodeT type )
default: default:
log_failure( "def_body: Invalid type %s", (char const*)ECode::to_str(type) ); log_failure( "def_body: Invalid type %s", (char const*)ECode::to_str(type) );
return (CodeBody)Code::Invalid; return (CodeBody)Code_Invalid;
} }
Code Code

View File

@ -74,12 +74,12 @@ void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, s
internal internal
void define_constants() void define_constants()
{ {
Code::Global = make_code(); Code_Global = make_code();
scast(String, Code::Global->Name) = get_cached_string( txt("Global Code") ); scast(String, Code_Global->Name) = get_cached_string( txt("Global Code") );
scast(String, Code::Global->Content) = Code::Global->Name; scast(String, Code_Global->Content) = Code_Global->Name;
Code::Invalid = make_code(); Code_Invalid = make_code();
Code::Invalid.set_global(); Code_Invalid.set_global();
t_empty = (CodeType) make_code(); t_empty = (CodeType) make_code();
t_empty->Type = ECode::Typename; t_empty->Type = ECode::Typename;

View File

@ -15,7 +15,7 @@ CodeClass parse_class( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
push_scope(); push_scope();
@ -31,7 +31,7 @@ CodeConstructor parse_constructor( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
// TODO(Ed): Constructors can have prefix attributes // TODO(Ed): Constructors can have prefix attributes
@ -61,7 +61,7 @@ CodeConstructor parse_constructor( StrC def )
default : default :
log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), Context.to_string() ); log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// Every specifier after would be considered part of the type type signature // 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 ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
// TODO(Ed): Destructors can have prefix attributes // TODO(Ed): Destructors can have prefix attributes
// TODO(Ed): Destructors can have virtual // TODO(Ed): Destructors can have virtual
@ -110,7 +110,7 @@ CodeEnum parse_enum( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
Context.Tokens = toks; Context.Tokens = toks;
@ -124,7 +124,7 @@ CodeBody parse_export_body( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_export_body(); return parse_export_body();
@ -137,7 +137,7 @@ CodeExtern parse_extern_link( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_extern_link(); return parse_extern_link();
@ -150,7 +150,7 @@ CodeFriend parse_friend( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_friend(); return parse_friend();
@ -163,7 +163,7 @@ CodeFn parse_function( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return (CodeFn) parse_function(); return (CodeFn) parse_function();
@ -176,7 +176,7 @@ CodeBody parse_global_body( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
push_scope(); push_scope();
@ -192,7 +192,7 @@ CodeNS parse_namespace( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_namespace(); return parse_namespace();
@ -205,7 +205,7 @@ CodeOperator parse_operator( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return (CodeOperator) parse_operator(); return (CodeOperator) parse_operator();
@ -218,7 +218,7 @@ CodeOpCast parse_operator_cast( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_operator_cast(); return parse_operator_cast();
@ -231,7 +231,7 @@ CodeStruct parse_struct( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
push_scope(); push_scope();
@ -247,7 +247,7 @@ CodeTemplate parse_template( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_template(); return parse_template();
@ -260,7 +260,7 @@ CodeType parse_type( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_type(); return parse_type();
@ -273,7 +273,7 @@ CodeTypedef parse_typedef( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_typedef(); return parse_typedef();
@ -286,7 +286,7 @@ CodeUnion parse_union( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_union(); return parse_union();
@ -299,7 +299,7 @@ CodeUsing parse_using( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_using(); return parse_using();
@ -312,7 +312,7 @@ CodeVar parse_variable( StrC def )
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return InvalidCode;
Context.Tokens = toks; Context.Tokens = toks;
return parse_variable(); return parse_variable();

View File

@ -106,7 +106,7 @@ Code untyped_str( StrC content )
if ( content.Len == 0 ) if ( content.Len == 0 )
{ {
log_failure( "untyped_str: empty string" ); log_failure( "untyped_str: empty string" );
return CodeInvalid; return InvalidCode;
} }
Code Code
@ -118,7 +118,7 @@ Code untyped_str( StrC content )
if ( result->Name == nullptr ) if ( result->Name == nullptr )
{ {
log_failure( "untyped_str: could not cache string" ); log_failure( "untyped_str: could not cache string" );
return CodeInvalid; return InvalidCode;
} }
return result; return result;
@ -129,7 +129,7 @@ Code untyped_fmt( char const* fmt, ...)
if ( fmt == nullptr ) if ( fmt == nullptr )
{ {
log_failure( "untyped_fmt: null format string" ); log_failure( "untyped_fmt: null format string" );
return CodeInvalid; return InvalidCode;
} }
local_persist thread_local local_persist thread_local
@ -149,7 +149,7 @@ Code untyped_fmt( char const* fmt, ...)
if ( result->Name == nullptr ) if ( result->Name == nullptr )
{ {
log_failure( "untyped_fmt: could not cache string" ); log_failure( "untyped_fmt: could not cache string" );
return CodeInvalid; return InvalidCode;
} }
return result; return result;
@ -160,7 +160,7 @@ Code untyped_token_fmt( s32 num_tokens, ... )
if ( num_tokens == 0 ) if ( num_tokens == 0 )
{ {
log_failure( "untyped_token_fmt: zero tokens" ); log_failure( "untyped_token_fmt: zero tokens" );
return CodeInvalid; return InvalidCode;
} }
local_persist thread_local local_persist thread_local
@ -180,7 +180,7 @@ Code untyped_token_fmt( s32 num_tokens, ... )
if ( result->Name == nullptr ) if ( result->Name == nullptr )
{ {
log_failure( "untyped_fmt: could not cache string" ); log_failure( "untyped_fmt: could not cache string" );
return CodeInvalid; return InvalidCode;
} }
return result; return result;

View File

@ -381,13 +381,13 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
if ( Name_.Len <= 0 ) \ if ( Name_.Len <= 0 ) \
{ \ { \
log_failure( "gen::" stringize(Context_) ": Invalid name length provided - %d", Name_.Len ); \ log_failure( "gen::" stringize(Context_) ": Invalid name length provided - %d", Name_.Len ); \
return CodeInvalid; \ return InvalidCode; \
} \ } \
\ \
if ( Name_.Ptr == nullptr ) \ if ( Name_.Ptr == nullptr ) \
{ \ { \
log_failure( "gen::" stringize(Context_) ": name is null" ); \ 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_ ) \ if ( ! Code_ ) \
{ \ { \
log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \ log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \
return CodeInvalid; \ return InvalidCode; \
} }
#define null_or_invalid_check( Context_, Code_ ) \ #define null_or_invalid_check( Context_, Code_ ) \
@ -403,19 +403,19 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
if ( ! Code_ ) \ if ( ! Code_ ) \
{ \ { \
log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \ log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \
return CodeInvalid; \ return InvalidCode; \
} \ } \
\ \
if ( Code_->is_invalid() ) \ if ( Code_->is_invalid() ) \
{ \ { \
log_failure("gen::" stringize(Context_) ": " stringize(Code_) " provided is invalid" ); \ log_failure("gen::" stringize(Context_) ": " stringize(Code_) " provided is invalid" ); \
return CodeInvalid; \ return InvalidCode; \
} \ } \
} }
#define not_implemented( Context_ ) \ #define not_implemented( Context_ ) \
log_failure( "gen::%s: This function is not implemented" ); \ log_failure( "gen::%s: This function is not implemented" ); \
return CodeInvalid; return InvalidCode;
#pragma endregion Helper Marcos #pragma endregion Helper Marcos
@ -436,7 +436,7 @@ CodeAttributes def_attributes( StrC content )
if ( content.Len <= 0 || content.Ptr == nullptr ) if ( content.Len <= 0 || content.Ptr == nullptr )
{ {
log_failure( "gen::def_attributes: Invalid attributes provided" ); log_failure( "gen::def_attributes: Invalid attributes provided" );
return CodeInvalid; return InvalidCode;
} }
Code Code
@ -453,7 +453,7 @@ CodeComment def_comment( StrC content )
if ( content.Len <= 0 || content.Ptr == nullptr ) if ( content.Len <= 0 || content.Ptr == nullptr )
{ {
log_failure( "gen::def_comment: Invalid comment provided:" ); log_failure( "gen::def_comment: Invalid comment provided:" );
return CodeInvalid; return InvalidCode;
} }
static char line[ MaxCommentLineLength ]; static char line[ MaxCommentLineLength ];
@ -502,7 +502,7 @@ CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code b
if ( params && params->Type != Parameters ) if ( params && params->Type != Parameters )
{ {
log_failure("gen::def_constructor: params must be of Parameters type - %s", params.debug_str()); log_failure("gen::def_constructor: params must be of Parameters type - %s", params.debug_str());
return CodeInvalid; return InvalidCode;
} }
CodeConstructor CodeConstructor
@ -528,7 +528,7 @@ CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code b
default: default:
log_failure("gen::def_constructor: body must be either of Function_Body or Untyped type - %s", body.debug_str()); 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; result->Type = Constructor;
@ -556,13 +556,13 @@ CodeClass def_class( StrC name
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() ); 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 ) ) 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() ); log_failure( "gen::def_class: parent provided is not type 'Class', 'Struct', 'Typeanme', or 'Untyped': %s", parent.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeClass CodeClass
@ -580,7 +580,7 @@ CodeClass def_class( StrC name
default: default:
log_failure("gen::def_class: body must be either of Class_Body or Untyped type - %s", body.debug_str()); 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; result->Type = Class;
@ -623,7 +623,7 @@ CodeDefine def_define( StrC name, StrC content )
if ( content.Len <= 0 || content.Ptr == nullptr ) if ( content.Len <= 0 || content.Ptr == nullptr )
{ {
log_failure( "gen::def_define: Invalid value provided" ); log_failure( "gen::def_define: Invalid value provided" );
return CodeInvalid; return InvalidCode;
} }
#endif #endif
@ -648,7 +648,7 @@ CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers )
if ( specifiers && specifiers->Type != Specifiers ) if ( specifiers && specifiers->Type != Specifiers )
{ {
log_failure( "gen::def_destructor: specifiers was not a 'Specifiers' type: %s", specifiers.debug_str() ); log_failure( "gen::def_destructor: specifiers was not a 'Specifiers' type: %s", specifiers.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeDestructor result = (CodeDestructor) make_code(); CodeDestructor result = (CodeDestructor) make_code();
@ -666,7 +666,7 @@ CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers )
default: default:
log_failure("gen::def_destructor: body must be either of Function_Body or Untyped type - %s", body.debug_str()); 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; result->Type = Destructor;
@ -692,13 +692,13 @@ CodeEnum def_enum( StrC name
if ( type && type->Type != Typename ) if ( type && type->Type != Typename )
{ {
log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", type.debug_str() ); 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 ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() ); log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeEnum CodeEnum
@ -716,7 +716,7 @@ CodeEnum def_enum( StrC name
default: default:
log_failure( "gen::def_enum: body must be of Enum_Body or Untyped type %s", body.debug_str()); 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 ? 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 ) else if ( result->Type != Enum_Class_Fwd && result->Type != Enum_Fwd )
{ {
log_failure( "gen::def_enum: enum forward declaration must have an underlying type" ); log_failure( "gen::def_enum: enum forward declaration must have an underlying type" );
return CodeInvalid; return InvalidCode;
} }
return result; return result;
@ -751,7 +751,7 @@ CodeExec def_execution( StrC content )
if ( content.Len <= 0 || content.Ptr == nullptr ) if ( content.Len <= 0 || content.Ptr == nullptr )
{ {
log_failure( "gen::def_execution: Invalid execution provided" ); log_failure( "gen::def_execution: Invalid execution provided" );
return CodeInvalid; return InvalidCode;
} }
Code Code
@ -773,7 +773,7 @@ CodeExtern def_extern_link( StrC name, Code body )
if ( body->Type != Extern_Linkage_Body && body->Type != Untyped ) 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()); log_failure("gen::def_extern_linkage: body is not of extern_linkage or untyped type %s", body->debug_str());
return CodeInvalid; return InvalidCode;
} }
CodeExtern CodeExtern
@ -805,7 +805,7 @@ CodeFriend def_friend( Code declaration )
default: default:
log_failure("gen::def_friend: requires declartion to have class, function, operator, or struct - %s", declaration->debug_str()); log_failure("gen::def_friend: requires declartion to have class, function, operator, or struct - %s", declaration->debug_str());
return CodeInvalid; return InvalidCode;
} }
CodeFriend CodeFriend
@ -829,25 +829,25 @@ CodeFn def_function( StrC name
if ( params && params->Type != Parameters ) if ( params && params->Type != Parameters )
{ {
log_failure( "gen::def_function: params was not a `Parameters` type: %s", params.debug_str() ); 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 ) if ( ret_type && ret_type->Type != Typename )
{ {
log_failure( "gen::def_function: ret_type was not a Typename: %s", ret_type.debug_str() ); 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 ) if ( specifiers && specifiers->Type != Specifiers )
{ {
log_failure( "gen::def_function: specifiers was not a `Specifiers` type: %s", specifiers.debug_str() ); log_failure( "gen::def_function: specifiers was not a `Specifiers` type: %s", specifiers.debug_str() );
return CodeInvalid; return InvalidCode;
} }
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", attributes.debug_str() ); log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", attributes.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeFn CodeFn
@ -867,7 +867,7 @@ CodeFn def_function( StrC name
default: default:
{ {
log_failure("gen::def_function: body must be either of Function_Body, Execution, or Untyped type. %s", body->debug_str()); 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 ) if ( path.Len <= 0 || path.Ptr == nullptr )
{ {
log_failure( "gen::def_include: Invalid path provided - %d" ); log_failure( "gen::def_include: Invalid path provided - %d" );
return CodeInvalid; return InvalidCode;
} }
StrC content = foreign ? StrC content = foreign ?
@ -945,7 +945,7 @@ CodeNS def_namespace( StrC name, Code body, ModuleFlag mflags )
if ( body->Type != Namespace_Body && body->Type != Untyped ) 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()); log_failure("gen::def_namespace: body is not of namespace or untyped type %s", body.debug_str());
return CodeInvalid; return InvalidCode;
} }
CodeNS CodeNS
@ -968,20 +968,20 @@ CodeOperator def_operator( OperatorT op, StrC nspace
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", attributes.debug_str() ); 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 ) if ( specifiers && specifiers->Type != Specifiers )
{ {
log_failure( "gen::def_operator: Specifiers was provided but its not of specifiers type: %s", specifiers.debug_str() ); 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 ); OpValidateResult check_result = operator__validate( op, params_code, ret_type, specifiers );
if ( check_result == OpValidateResult::Fail ) if ( check_result == OpValidateResult::Fail )
{ {
return CodeInvalid; return InvalidCode;
} }
char const* name = nullptr; char const* name = nullptr;
@ -1009,7 +1009,7 @@ CodeOperator def_operator( OperatorT op, StrC nspace
default: default:
{ {
log_failure("gen::def_operator: body must be either of Function_Body, Execution, or Untyped type. %s", body->debug_str()); 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 ) if ( type->Type != Typename )
{ {
log_failure( "gen::def_operator_cast: type is not a typename - %s", type.debug_str() ); log_failure( "gen::def_operator_cast: type is not a typename - %s", type.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeOpCast result = (CodeOpCast) make_code(); 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 ) 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() ); 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; result->Body = body;
@ -1087,13 +1087,13 @@ CodeParam def_param( CodeType type, StrC name, Code value )
if ( type->Type != Typename ) if ( type->Type != Typename )
{ {
log_failure( "gen::def_param: type is not a typename - %s", type.debug_str() ); log_failure( "gen::def_param: type is not a typename - %s", type.debug_str() );
return CodeInvalid; return InvalidCode;
} }
if ( value && value->Type != Untyped ) if ( value && value->Type != Untyped )
{ {
log_failure( "gen::def_param: value is not untyped - %s", value.debug_str() ); log_failure( "gen::def_param: value is not untyped - %s", value.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeParam CodeParam
@ -1118,7 +1118,7 @@ CodePragma def_pragma( StrC directive )
if ( directive.Len <= 0 || directive.Ptr == nullptr ) if ( directive.Len <= 0 || directive.Ptr == nullptr )
{ {
log_failure( "gen::def_comment: Invalid comment provided:" ); log_failure( "gen::def_comment: Invalid comment provided:" );
return CodeInvalid; return InvalidCode;
} }
CodePragma CodePragma
@ -1136,7 +1136,7 @@ CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC expr )
if ( expr.Len <= 0 || expr.Ptr == nullptr ) if ( expr.Len <= 0 || expr.Ptr == nullptr )
{ {
log_failure( "gen::def_comment: Invalid comment provided:" ); log_failure( "gen::def_comment: Invalid comment provided:" );
return CodeInvalid; return InvalidCode;
} }
CodePreprocessCond CodePreprocessCond
@ -1184,19 +1184,19 @@ CodeStruct def_struct( StrC name
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() ); log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() );
return CodeInvalid; return InvalidCode;
} }
if ( parent && parent->Type != Typename ) if ( parent && parent->Type != Typename )
{ {
log_failure( "gen::def_struct: parent was not a `Struct` type - %s", parent.debug_str() ); 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 ) if ( body && body->Type != Struct_Body )
{ {
log_failure( "gen::def_struct: body was not a Struct_Body type - %s", body.debug_str() ); log_failure( "gen::def_struct: body was not a Struct_Body type - %s", body.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeStruct CodeStruct
@ -1243,7 +1243,7 @@ CodeTemplate def_template( CodeParam params, Code declaration, ModuleFlag mflags
if ( params && params->Type != ECode::Parameters ) if ( params && params->Type != ECode::Parameters )
{ {
log_failure( "gen::def_template: params is not of parameters type - %s", params.debug_str() ); log_failure( "gen::def_template: params is not of parameters type - %s", params.debug_str() );
return CodeInvalid; return InvalidCode;
} }
switch (declaration->Type ) switch (declaration->Type )
@ -1276,19 +1276,19 @@ CodeType def_type( StrC name, Code arrayexpr, CodeSpecifiers specifiers, CodeAtt
if ( attributes && attributes->Type != ECode::PlatformAttributes ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_type: attributes is not of attributes type - %s", attributes.debug_str() ); 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 ) if ( specifiers && specifiers->Type != ECode::Specifiers )
{ {
log_failure( "gen::def_type: specifiers is not of specifiers type - %s", specifiers.debug_str() ); 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 ) if ( arrayexpr && arrayexpr->Type != ECode::Untyped )
{ {
log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", arrayexpr->debug_str() ); log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", arrayexpr->debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeType CodeType
@ -1330,13 +1330,13 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module
break; break;
default: default:
log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", type.debug_str() ); 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 ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", attributes.debug_str() ); log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", attributes.debug_str() );
return CodeInvalid; return InvalidCode;
} }
// Registering the type. // Registering the type.
@ -1345,7 +1345,7 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module
if ( ! registered_type ) if ( ! registered_type )
{ {
log_failure( "gen::def_typedef: failed to register type" ); log_failure( "gen::def_typedef: failed to register type" );
return CodeInvalid; return InvalidCode;
} }
CodeTypedef CodeTypedef
@ -1360,7 +1360,7 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module
if (type->Type != Untyped) 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() ); 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 ); 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 ) if ( body->Type != ECode::Union_Body )
{ {
log_failure( "gen::def_union: body was not a Union_Body type - %s", body.debug_str() ); 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 ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", attributes.debug_str() ); log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", attributes.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeUnion CodeUnion
@ -1419,13 +1419,13 @@ CodeUsing def_using( StrC name, CodeType type
if ( ! register_type ) if ( ! register_type )
{ {
log_failure( "gen::def_using: failed to register type" ); log_failure( "gen::def_using: failed to register type" );
return CodeInvalid; return InvalidCode;
} }
if ( attributes && attributes->Type != ECode::PlatformAttributes ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", attributes.debug_str() ); log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", attributes.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeUsing CodeUsing
@ -1465,25 +1465,25 @@ CodeVar def_variable( CodeType type, StrC name, Code value
if ( attributes && attributes->Type != ECode::PlatformAttributes ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() ); 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 ) if ( specifiers && specifiers->Type != ECode::Specifiers )
{ {
log_failure( "gen::def_variable: specifiers was not a `Specifiers` type - %s", specifiers.debug_str() ); log_failure( "gen::def_variable: specifiers was not a `Specifiers` type - %s", specifiers.debug_str() );
return CodeInvalid; return InvalidCode;
} }
if ( type->Type != ECode::Typename ) if ( type->Type != ECode::Typename )
{ {
log_failure( "gen::def_variable: type was not a Typename - %s", type.debug_str() ); log_failure( "gen::def_variable: type was not a Typename - %s", type.debug_str() );
return CodeInvalid; return InvalidCode;
} }
if ( value && value->Type != ECode::Untyped ) if ( value && value->Type != ECode::Untyped )
{ {
log_failure( "gen::def_variable: value was not a `Untyped` type - %s", value.debug_str() ); log_failure( "gen::def_variable: value was not a `Untyped` type - %s", value.debug_str() );
return CodeInvalid; return InvalidCode;
} }
CodeVar CodeVar
@ -1513,7 +1513,7 @@ using namespace ECode; \
if ( num <= 0 ) \ if ( num <= 0 ) \
{ \ { \
log_failure("gen::" stringize(Name_) ": num cannot be zero or negative"); \ log_failure("gen::" stringize(Name_) ": num cannot be zero or negative"); \
return CodeInvalid; \ return InvalidCode; \
} }
#define def_body_code_array_start( Name_ ) \ #define def_body_code_array_start( Name_ ) \
@ -1522,13 +1522,13 @@ using namespace ECode; \
if ( num <= 0 ) \ if ( num <= 0 ) \
{ \ { \
log_failure("gen::" stringize(Name_) ": num cannot be zero or negative"); \ log_failure("gen::" stringize(Name_) ": num cannot be zero or negative"); \
return CodeInvalid; \ return InvalidCode; \
} \ } \
\ \
if ( codes == nullptr ) \ if ( codes == nullptr ) \
{ \ { \
log_failure("gen::" stringize(Name_)" : Provided a null array of codes"); \ log_failure("gen::" stringize(Name_)" : Provided a null array of codes"); \
return CodeInvalid; \ return InvalidCode; \
} }
#pragma endregion Helper Macros for def_**_body functions #pragma endregion Helper Macros for def_**_body functions
@ -1552,14 +1552,14 @@ CodeBody def_class_body( s32 num, ... )
log_failure("gen::" log_failure("gen::"
"def_class_body" "def_class_body"
": Provided an null entry"); ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_CLASS_UNALLOWED_TYPES GEN_AST_BODY_CLASS_UNALLOWED_TYPES
log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -1589,14 +1589,14 @@ CodeBody def_class_body( s32 num, Code* codes )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_class_body" ": Provided an null entry"); log_failure("gen::" "def_class_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_CLASS_UNALLOWED_TYPES GEN_AST_BODY_CLASS_UNALLOWED_TYPES
log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -1627,13 +1627,13 @@ CodeBody def_enum_body( s32 num, ... )
if ( ! entry ) if ( ! entry )
{ {
log_failure("gen::def_enum_body: Provided a null entry"); log_failure("gen::def_enum_body: Provided a null entry");
return CodeInvalid; return InvalidCode;
} }
if ( entry->Type != Untyped && entry->Type != Comment ) 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() ); 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 ); result.append( entry );
@ -1659,13 +1659,13 @@ CodeBody def_enum_body( s32 num, Code* codes )
if ( ! entry ) if ( ! entry )
{ {
log_failure("gen::def_enum_body: Provided a null entry"); log_failure("gen::def_enum_body: Provided a null entry");
return CodeInvalid; return InvalidCode;
} }
if ( entry->Type != Untyped && entry->Type != Comment ) if ( entry->Type != Untyped && entry->Type != Comment )
{ {
log_failure("gen::def_enum_body: Entry type is not allowed: %s", entry.debug_str() ); log_failure("gen::def_enum_body: Entry type is not allowed: %s", entry.debug_str() );
return CodeInvalid; return InvalidCode;
} }
result.append( entry ); result.append( entry );
@ -1693,14 +1693,14 @@ CodeBody def_export_body( s32 num, ... )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_export_body" ": Provided an null entry"); log_failure("gen::" "def_export_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES GEN_AST_BODY_EXPORT_UNALLOWED_TYPES
log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -1730,14 +1730,14 @@ CodeBody def_export_body( s32 num, Code* codes )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_export_body" ": Provided an null entry"); log_failure("gen::" "def_export_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES GEN_AST_BODY_EXPORT_UNALLOWED_TYPES
log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -1768,14 +1768,14 @@ CodeBody def_extern_link_body( s32 num, ... )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_extern_linkage_body" ": Provided an null entry"); log_failure("gen::" "def_extern_linkage_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES
log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -1805,14 +1805,14 @@ CodeBody def_extern_link_body( s32 num, Code* codes )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_extern_linkage_body" ": Provided an null entry"); log_failure("gen::" "def_extern_linkage_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES
log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -1844,7 +1844,7 @@ CodeBody def_function_body( s32 num, ... )
if (!entry) if (!entry)
{ {
log_failure("gen::" stringize(def_function_body) ": Provided an null entry"); log_failure("gen::" stringize(def_function_body) ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
@ -1852,7 +1852,7 @@ CodeBody def_function_body( s32 num, ... )
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES
log_failure("gen::" stringize(def_function_body) ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" stringize(def_function_body) ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -1882,14 +1882,14 @@ CodeBody def_function_body( s32 num, Code* codes )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_function_body" ": Provided an null entry"); log_failure("gen::" "def_function_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES
log_failure("gen::" "def_function_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_function_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -1919,7 +1919,7 @@ CodeBody def_global_body( s32 num, ... )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_global_body" ": Provided an null entry"); log_failure("gen::" "def_global_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
@ -1930,7 +1930,7 @@ CodeBody def_global_body( s32 num, ... )
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", entry.debug_str());
return (*Code::Invalid.ast); return InvalidCode;
default: default:
break; break;
@ -1960,7 +1960,7 @@ CodeBody def_global_body( s32 num, Code* codes )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_global_body" ": Provided an null entry"); log_failure("gen::" "def_global_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
@ -1971,7 +1971,7 @@ CodeBody def_global_body( s32 num, Code* codes )
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -2002,14 +2002,14 @@ CodeBody def_namespace_body( s32 num, ... )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_namespace_body" ": Provided an null entry"); log_failure("gen::" "def_namespace_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES
log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -2039,14 +2039,14 @@ CodeBody def_namespace_body( s32 num, Code* codes )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_namespace_body" ": Provided an null entry"); log_failure("gen::" "def_namespace_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES
log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str() ); log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str() );
return CodeInvalid; return InvalidCode;
default: break; default: break;
} }
@ -2073,7 +2073,7 @@ CodeParam def_params( s32 num, ... )
if ( param->Type != Parameters ) if ( param->Type != Parameters )
{ {
log_failure( "gen::def_params: param %d is not a Parameters", num - num + 1 ); log_failure( "gen::def_params: param %d is not a Parameters", num - num + 1 );
return CodeInvalid; return InvalidCode;
} }
CodeParam result = (CodeParam) param.duplicate(); CodeParam result = (CodeParam) param.duplicate();
@ -2086,7 +2086,7 @@ CodeParam def_params( s32 num, ... )
if ( param->Type != Parameters ) if ( param->Type != Parameters )
{ {
log_failure( "gen::def_params: param %d is not a Parameters", num - num + 1 ); log_failure( "gen::def_params: param %d is not a Parameters", num - num + 1 );
return CodeInvalid; return InvalidCode;
} }
result.append( param ); result.append( param );
@ -2104,13 +2104,13 @@ CodeParam def_params( s32 num, CodeParam* codes )
if ( current.ast == nullptr ) \ if ( current.ast == nullptr ) \
{ \ { \
log_failure("gen::def_params: Provide a null code in codes array"); \ log_failure("gen::def_params: Provide a null code in codes array"); \
return CodeInvalid; \ return InvalidCode; \
} \ } \
\ \
if (current->Type != Parameters ) \ if (current->Type != Parameters ) \
{ \ { \
log_failure("gen::def_params: Code in coes array is not of paramter type - %s", current.debug_str() ); \ 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(); CodeParam current = (CodeParam) codes->duplicate();
@ -2137,13 +2137,13 @@ CodeSpecifiers def_specifiers( s32 num, ... )
if ( num <= 0 ) if ( num <= 0 )
{ {
log_failure("gen::def_specifiers: num cannot be zero or less"); log_failure("gen::def_specifiers: num cannot be zero or less");
return CodeInvalid; return InvalidCode;
} }
if ( num > AST::ArrSpecs_Cap ) if ( num > AST::ArrSpecs_Cap )
{ {
log_failure("gen::def_specifiers: num of speciifers to define AST larger than AST specicifier capacity - %d", num); log_failure("gen::def_specifiers: num of speciifers to define AST larger than AST specicifier capacity - %d", num);
return CodeInvalid; return InvalidCode;
} }
CodeSpecifiers CodeSpecifiers
@ -2169,13 +2169,13 @@ CodeSpecifiers def_specifiers( s32 num, SpecifierT* specs )
if ( num <= 0 ) if ( num <= 0 )
{ {
log_failure("gen::def_specifiers: num cannot be zero or less"); log_failure("gen::def_specifiers: num cannot be zero or less");
return CodeInvalid; return InvalidCode;
} }
if ( num > AST::ArrSpecs_Cap ) if ( num > AST::ArrSpecs_Cap )
{ {
log_failure("gen::def_specifiers: num of speciifers to define AST larger than AST specicifier capacity - %d", num); log_failure("gen::def_specifiers: num of speciifers to define AST larger than AST specicifier capacity - %d", num);
return CodeInvalid; return InvalidCode;
} }
CodeSpecifiers CodeSpecifiers
@ -2211,14 +2211,14 @@ CodeBody def_struct_body( s32 num, ... )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_struct_body" ": Provided an null entry"); log_failure("gen::" "def_struct_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES GEN_AST_BODY_STRUCT_UNALLOWED_TYPES
log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str());
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -2248,14 +2248,14 @@ CodeBody def_struct_body( s32 num, Code* codes )
if (!entry) if (!entry)
{ {
log_failure("gen::" "def_struct_body" ": Provided an null entry"); log_failure("gen::" "def_struct_body" ": Provided an null entry");
return CodeInvalid; return InvalidCode;
} }
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES GEN_AST_BODY_STRUCT_UNALLOWED_TYPES
log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str() ); log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str() );
return CodeInvalid; return InvalidCode;
default: default:
break; break;
@ -2286,13 +2286,13 @@ CodeBody def_union_body( s32 num, ... )
if ( ! entry ) if ( ! entry )
{ {
log_failure("gen::def_union_body: Provided a null entry"); log_failure("gen::def_union_body: Provided a null entry");
return CodeInvalid; return InvalidCode;
} }
if ( entry->Type != Untyped && entry->Type != Comment ) 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() ); 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 ); result.append( entry );
@ -2318,13 +2318,13 @@ CodeBody def_union_body( s32 num, CodeUnion* codes )
if ( ! entry ) if ( ! entry )
{ {
log_failure("gen::def_union_body: Provided a null entry"); log_failure("gen::def_union_body: Provided a null entry");
return CodeInvalid; return InvalidCode;
} }
if ( entry->Type != Untyped && entry->Type != Comment ) if ( entry->Type != Untyped && entry->Type != Comment )
{ {
log_failure("gen::def_union_body: Entry type is not allowed: %s", entry.debug_str() ); log_failure("gen::def_union_body: Entry type is not allowed: %s", entry.debug_str() );
return CodeInvalid; return InvalidCode;
} }
result.append( entry ); result.append( entry );

View File

@ -153,13 +153,13 @@ if ( def.Len <= 0 ) \
{ \ { \
log_failure( "gen::" stringize(__func__) ": length must greater than 0" ); \ log_failure( "gen::" stringize(__func__) ": length must greater than 0" ); \
parser::Context.pop(); \ parser::Context.pop(); \
return CodeInvalid; \ return InvalidCode; \
} \ } \
if ( def.Ptr == nullptr ) \ if ( def.Ptr == nullptr ) \
{ \ { \
log_failure( "gen::" stringize(__func__) ": def was null" ); \ log_failure( "gen::" stringize(__func__) ": def was null" ); \
parser::Context.pop(); \ parser::Context.pop(); \
return CodeInvalid; \ return InvalidCode; \
} }
# define currtok_noskip Context.Tokens.current( dont_skip_formatting ) # 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() ); log_failure( "Error, unexpected end of array declaration ( '[]' scope started )\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if ( currtok.Type == TokType::BraceSquare_Close ) if ( currtok.Type == TokType::BraceSquare_Close )
{ {
log_failure( "Error, empty array expression in definition\n%s", Context.to_string() ); log_failure( "Error, empty array expression in definition\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
Token untyped_tok = currtok; 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() ); log_failure( "Error, unexpected end of array declaration, expected ]\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if ( currtok.Type != TokType::BraceSquare_Close ) 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() ); log_failure( "%s: Error, expected ] in array declaration, not %s\n%s", ETokType::to_str( currtok.Type ), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
eat( TokType::BraceSquare_Close ); 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 ) 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() ); 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 }; Token name { nullptr, 0, TokType::Invalid };
@ -689,7 +689,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
CodeAttributes attributes = { nullptr }; CodeAttributes attributes = { nullptr };
ModuleFlag mflags = ModuleFlag_None; ModuleFlag mflags = ModuleFlag_None;
CodeClass result = CodeInvalid; CodeClass result = InvalidCode;
if ( check(TokType::Module_Export) ) 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 ) while ( left && currtok_noskip.Type != TokType::BraceCurly_Close )
{ {
Code member = Code::Invalid; Code member = Code_Invalid;
CodeAttributes attributes = { nullptr }; CodeAttributes attributes = { nullptr };
CodeSpecifiers specifiers = { nullptr }; CodeSpecifiers specifiers = { nullptr };
@ -901,7 +901,7 @@ CodeBody parse_class_struct_body( TokType which, Token name )
if ( currtok.Text[0] != '~' ) if ( currtok.Text[0] != '~' )
{ {
log_failure( "Operator token found in global body but not destructor unary negation\n%s", Context.to_string() ); 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(); member = parse_destructor();
@ -1015,7 +1015,7 @@ CodeBody parse_class_struct_body( TokType which, Token name )
default: default:
log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str(spec), Context.to_string() ); log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str(spec), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// Every specifier after would be considered part of the type type signature // 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; break;
} }
if ( member == Code::Invalid ) if ( member == Code_Invalid )
{ {
log_failure( "Failed to parse member\n%s", Context.to_string() ); log_failure( "Failed to parse member\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
result.append( member ); 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() ); log_failure( "Unsupported or bad member definition after %s declaration\n%s", to_str(which), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if ( tok.Type == TokType::Identifier ) 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() ); log_failure( "Unsupported or bad member definition after %s declaration\n%s", to_str(which), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
Code result = parse_operator_function_or_variable( false, { nullptr }, { nullptr } ); 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() ); log_failure( "Unsupported or bad member definition after %s declaration\n%s", to_str(which), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// Its a forward declaration of an enum class // 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() ); log_failure( "Unsupported or bad member definition after %s declaration\n%S", to_str(which).Ptr, Context.to_string() );
Context.pop(); 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() ); log_failure( "Error, expected identifier after #define\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
Context.Scope->Name = currtok; 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() ); log_failure( "Error, expected content after #define %s\n%s", define->Name, Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if ( currtok.Length == 0 ) if ( currtok.Length == 0 )
@ -1360,7 +1360,7 @@ Code parse_assignment_expression()
{ {
log_failure( "Expected expression after assignment operator\n%s", Context.to_string() ); log_failure( "Expected expression after assignment operator\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
s32 level = 0; s32 level = 0;
@ -1387,7 +1387,7 @@ Code parse_assignment_expression()
internal inline internal inline
Code parse_forward_or_definition( TokType which, bool is_inplace ) Code parse_forward_or_definition( TokType which, bool is_inplace )
{ {
Code result = CodeInvalid; Code result = InvalidCode;
switch ( which ) switch ( which )
{ {
@ -1412,7 +1412,7 @@ Code parse_forward_or_definition( TokType which, bool is_inplace )
"(only supports class, enum, struct, union) \n%s" "(only supports class, enum, struct, union) \n%s"
, Context.to_string() ); , Context.to_string() );
return CodeInvalid; return InvalidCode;
} }
} }
@ -1450,10 +1450,10 @@ CodeFn parse_function_after_name(
if ( check( TokType::BraceCurly_Open ) ) if ( check( TokType::BraceCurly_Open ) )
{ {
body = parse_function_body(); body = parse_function_body();
if ( body == Code::Invalid ) if ( body == Code_Invalid )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers> { <Body> } // <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers> { <Body> }
} }
@ -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()); log_failure("Body must be either of Function_Body or Untyped type, %s\n%s", body.debug_str(), Context.to_string());
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
} }
@ -1585,7 +1585,7 @@ CodeBody parse_global_nspace( CodeT which )
push_scope(); push_scope();
if ( which != Namespace_Body && which != Global_Body && which != Export_Body && which != Extern_Linkage_Body ) if ( which != Namespace_Body && which != Global_Body && which != Export_Body && which != Extern_Linkage_Body )
return CodeInvalid; return InvalidCode;
if ( which != Global_Body ) if ( which != Global_Body )
eat( TokType::BraceCurly_Open ); eat( TokType::BraceCurly_Open );
@ -1597,7 +1597,7 @@ CodeBody parse_global_nspace( CodeT which )
while ( left && currtok_noskip.Type != TokType::BraceCurly_Close ) while ( left && currtok_noskip.Type != TokType::BraceCurly_Close )
{ {
Code member = Code::Invalid; Code member = Code_Invalid;
CodeAttributes attributes = { nullptr }; CodeAttributes attributes = { nullptr };
CodeSpecifiers specifiers = { 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() ); log_failure( "Invalid specifier %.*s for variable\n%s", spec_str.Len, spec_str, Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if (ignore_spec) 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() ); log_failure( "Failed to parse member\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// log_fmt("Global Body Member: %s", member->debug_str()); // 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() ); log_failure( "Error, expected include string after #include\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
Context.Scope->Name = currtok; 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() ); log_failure( "Expected operator after 'operator' keyword\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
Context.Scope->Name = currtok; 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() ); log_failure( "Invalid operator '%s'\n%s", prevtok.Text, Context.to_string() );
Context.pop(); 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() ); log_failure( "Invalid operator '%s'\n%s", currtok.Text, Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if ( ! was_new_or_delete) if ( ! was_new_or_delete)
@ -2454,10 +2454,10 @@ CodeOperator parse_operator_after_ret_type(
if ( check( TokType::BraceCurly_Open ) ) if ( check( TokType::BraceCurly_Open ) )
{ {
body = parse_function_body(); body = parse_function_body();
if ( body == Code::Invalid ) if ( body == Code_Invalid )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers> { ... } // <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers> { ... }
} }
@ -2487,7 +2487,7 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
{ {
push_scope(); push_scope();
Code result = CodeInvalid; Code result = InvalidCode;
#ifndef GEN_PARSER_DISABLE_MACRO_FUNCTION_SIGNATURES #ifndef GEN_PARSER_DISABLE_MACRO_FUNCTION_SIGNATURES
if ( currtok.Type == TokType::Preprocess_Macro ) if ( currtok.Type == TokType::Preprocess_Macro )
@ -2503,10 +2503,10 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
CodeType type = parse_type(); CodeType type = parse_type();
// <Attributes> <Specifiers> <ReturnType/ValueType> // <Attributes> <Specifiers> <ReturnType/ValueType>
if ( type == CodeInvalid ) if ( type == InvalidCode )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
bool found_operator = false; 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() ); log_failure( "Expected function declaration (consteval was used)\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// Dealing with a variable // Dealing with a variable
@ -2590,7 +2590,7 @@ CodePragma parse_pragma()
{ {
log_failure( "Error, expected content after #pragma\n%s", Context.to_string() ); log_failure( "Error, expected content after #pragma\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
Context.Scope->Name = currtok; Context.Scope->Name = currtok;
@ -2667,10 +2667,10 @@ CodeParam parse_params( bool use_template_capture )
if ( currtok.Type != TokType::Comma ) if ( currtok.Type != TokType::Comma )
{ {
type = parse_type( use_template_capture ); type = parse_type( use_template_capture );
if ( type == Code::Invalid ) if ( type == Code_Invalid )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// ( <Macro> <ValueType> // ( <Macro> <ValueType>
@ -2704,7 +2704,7 @@ CodeParam parse_params( bool use_template_capture )
{ {
log_failure( "Expected value after assignment operator\n%s.", Context.to_string() ); log_failure( "Expected value after assignment operator\n%s.", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
s32 capture_level = 0; s32 capture_level = 0;
@ -2777,10 +2777,10 @@ CodeParam parse_params( bool use_template_capture )
if ( currtok.Type != TokType::Comma ) if ( currtok.Type != TokType::Comma )
{ {
type = parse_type( use_template_capture ); type = parse_type( use_template_capture );
if ( type == Code::Invalid ) if ( type == Code_Invalid )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> // ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType>
@ -2816,7 +2816,7 @@ CodeParam parse_params( bool use_template_capture )
{ {
log_failure( "Expected value after assignment operator\n%s", Context.to_string() ); log_failure( "Expected value after assignment operator\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
s32 capture_level = 0; 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() ); log_failure( "Expected '<' after 'template' keyword\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
eat( TokType::Operator ); eat( TokType::Operator );
// < <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression>, .. > // < <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression>, .. >
@ -2897,7 +2897,7 @@ CodePreprocessCond parse_preprocess_cond()
{ {
log_failure( "Error, expected preprocess conditional\n%s", Context.to_string() ); log_failure( "Error, expected preprocess conditional\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
CodePreprocessCond CodePreprocessCond
@ -2910,7 +2910,7 @@ CodePreprocessCond parse_preprocess_cond()
{ {
log_failure( "Error, expected content after #define\n%s", Context.to_string() ); log_failure( "Error, expected content after #define\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
Context.Scope->Name = currtok; Context.Scope->Name = currtok;
@ -3168,7 +3168,7 @@ CodeVar parse_variable_after_name(
{ {
log_failure( "Expected expression after bitfield \n%s", Context.to_string() ); log_failure( "Expected expression after bitfield \n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
while ( left && currtok.Type != TokType::Statement_End ) while ( left && currtok.Type != TokType::Statement_End )
@ -3466,7 +3466,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
else else
{ {
log_failure( "Expected destructor '~' token\n%s", Context.to_string() ); log_failure( "Expected destructor '~' token\n%s", Context.to_string() );
return CodeInvalid; return InvalidCode;
} }
// <Virtual Specifier> ~ // <Virtual Specifier> ~
@ -3503,7 +3503,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
else else
{ {
log_failure( "Pure or default specifier expected due to '=' token\n%s", Context.to_string() ); log_failure( "Pure or default specifier expected due to '=' token\n%s", Context.to_string() );
return CodeInvalid; return InvalidCode;
} }
pure_virtual = true; pure_virtual = true;
@ -3598,11 +3598,11 @@ CodeEnum parse_enum( bool inplace_def )
// enum <class> <Attributes> <Name> : // enum <class> <Attributes> <Name> :
type = parse_type(); type = parse_type();
if ( type == Code::Invalid ) if ( type == Code_Invalid )
{ {
log_failure( "Failed to parse enum classifier\n%s", Context.to_string() ); log_failure( "Failed to parse enum classifier\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// enum <class> <Attributes> <Name> : <UnderlyingType> // enum <class> <Attributes> <Name> : <UnderlyingType>
} }
@ -3628,7 +3628,7 @@ CodeEnum parse_enum( bool inplace_def )
eat( TokType::BraceCurly_Open ); eat( TokType::BraceCurly_Open );
// enum <class> <Attributes> <Name> : <UnderlyingType> { // enum <class> <Attributes> <Name> : <UnderlyingType> {
Code member = CodeInvalid; Code member = InvalidCode;
bool expects_entry = true; bool expects_entry = true;
while ( left && currtok_noskip.Type != TokType::BraceCurly_Close ) while ( left && currtok_noskip.Type != TokType::BraceCurly_Close )
@ -3736,11 +3736,11 @@ CodeEnum parse_enum( bool inplace_def )
break; break;
} }
if ( member == Code::Invalid ) if ( member == Code_Invalid )
{ {
log_failure( "Failed to parse member\n%s", Context.to_string() ); log_failure( "Failed to parse member\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
body.append( member ); body.append( member );
@ -3839,7 +3839,7 @@ CodeExtern parse_extern_link()
result->Name = get_cached_string( name ); result->Name = get_cached_string( name );
Code entry = parse_extern_link_body(); 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() ); log_failure( "Failed to parse body\n%s", Context.to_string() );
Context.pop(); Context.pop();
@ -3866,10 +3866,10 @@ CodeFriend parse_friend()
// Type declaration or return type // Type declaration or return type
CodeType type = parse_type(); CodeType type = parse_type();
if ( type == Code::Invalid ) if ( type == Code_Invalid )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// friend <Type> // friend <Type>
@ -3966,7 +3966,7 @@ CodeFn parse_function()
default: default:
log_failure( "Invalid specifier %s for functon\n%s", ESpecifier::to_str(spec), Context.to_string() ); log_failure( "Invalid specifier %s for functon\n%s", ESpecifier::to_str(spec), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if ( spec == ESpecifier::Const ) if ( spec == ESpecifier::Const )
@ -3984,10 +3984,10 @@ CodeFn parse_function()
// <export> <Attributes> <Specifiers> // <export> <Attributes> <Specifiers>
CodeType ret_type = parse_type(); CodeType ret_type = parse_type();
if ( ret_type == Code::Invalid ) if ( ret_type == Code_Invalid )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// <export> <Attributes> <Specifiers> <ReturnType> // <export> <Attributes> <Specifiers> <ReturnType>
@ -3996,7 +3996,7 @@ CodeFn parse_function()
if ( ! name ) if ( ! name )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// <export> <Attributes> <Specifiers> <ReturnType> <Name> // <export> <Attributes> <Specifiers> <ReturnType> <Name>
@ -4020,10 +4020,10 @@ CodeNS parse_namespace()
// namespace <Name> // namespace <Name>
CodeBody body = parse_global_nspace( ECode::Namespace_Body ); CodeBody body = parse_global_nspace( ECode::Namespace_Body );
if ( body == Code::Invalid ) if ( body == Code_Invalid )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// namespace <Name> { <Body> } // namespace <Name> { <Body> }
@ -4077,7 +4077,7 @@ CodeOperator parse_operator()
default: default:
log_failure( "Invalid specifier " "%s" " for operator\n%s", ESpecifier::to_str(spec), Context.to_string() ); log_failure( "Invalid specifier " "%s" " for operator\n%s", ESpecifier::to_str(spec), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if ( spec == ESpecifier::Const ) if ( spec == ESpecifier::Const )
@ -4246,10 +4246,10 @@ CodeTemplate parse_template()
// <export> template // <export> template
Code params = parse_params( UseTemplateCapture ); Code params = parse_params( UseTemplateCapture );
if ( params == Code::Invalid ) if ( params == Code_Invalid )
{ {
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// <export> template< <Parameters> > // <export> template< <Parameters> >
@ -4328,7 +4328,7 @@ CodeTemplate parse_template()
default : default :
log_failure( "Invalid specifier %s for variable or function\n%s", ESpecifier::to_str( spec ), Context.to_string() ); log_failure( "Invalid specifier %s for variable or function\n%s", ESpecifier::to_str( spec ), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// Ignore const it will be handled by the type // 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() ); log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
specs_found[ NumSpecifiers ] = spec; 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() ); log_failure( "Error, unexpected end of type definition\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
if ( from_template && currtok.Type == TokType::Decl_Class ) 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() ); log_failure( "Error, failed to type signature\n%s", Context.to_string() );
Context.pop(); 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() ); log_failure( "Error, failed to type signature\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// <Attributes> <Specifiers> <Qualifier ::> <Identifier> // <Attributes> <Specifiers> <Qualifier ::> <Identifier>
// <Attributes> <Specifiers> <Identifier> // <Attributes> <Specifiers> <Identifier>
@ -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() ); log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
specs_found[ NumSpecifiers ] = spec; 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() ); log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
specs_found[ NumSpecifiers ] = spec; 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() ); log_failure( "Error, invalid specifier used in type definition: %s\n%s", currtok.Text, Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
specs_found[ NumSpecifiers ] = spec; 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() ); log_failure( "Unsupported or bad member definition after struct declaration\n%s", Context.to_string() );
Context.pop(); 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. // 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() ); log_failure( "Unsupported or bad member definition after struct declaration\n%s", Context.to_string() );
Context.pop(); 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() ); log_failure( "Error, expected identifier for typedef\n%s", Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
array_expr = parse_array_decl(); array_expr = parse_array_decl();
@ -5360,7 +5360,7 @@ CodeVar parse_variable()
default: default:
log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), Context.to_string() ); log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), Context.to_string() );
Context.pop(); Context.pop();
return CodeInvalid; return InvalidCode;
} }
// Ignore const specifiers, they're handled by the type // Ignore const specifiers, they're handled by the type
@ -5381,8 +5381,8 @@ CodeVar parse_variable()
CodeType type = parse_type(); CodeType type = parse_type();
// <ModuleFlags> <Attributes> <Specifiers> <ValueType> // <ModuleFlags> <Attributes> <Specifiers> <ValueType>
if ( type == Code::Invalid ) if ( type == Code_Invalid )
return CodeInvalid; return InvalidCode;
Context.Scope->Name = parse_identifier(); Context.Scope->Name = parse_identifier();
// <ModuleFlags> <Attributes> <Specifiers> <ValueType> <Name> // <ModuleFlags> <Attributes> <Specifiers> <ValueType> <Name>

View File

@ -346,9 +346,11 @@ CodeBody gen_ast_inlines()
#pragma push_macro("GEN_NS") #pragma push_macro("GEN_NS")
#pragma push_macro("rcast") #pragma push_macro("rcast")
#pragma push_macro("log_failure") #pragma push_macro("log_failure")
#pragma push_macro("CodeInvalid")
#undef GEN_NS #undef GEN_NS
#undef rcast #undef rcast
#undef log_failure #undef log_failure
#undef CodeInvalid
char const* code_impl_tmpl = stringize( char const* code_impl_tmpl = stringize(
\n \n
inline inline
@ -365,7 +367,7 @@ CodeBody gen_ast_inlines()
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure("Code::duplicate: Cannot duplicate code, AST is null!"); log_failure("Code::duplicate: Cannot duplicate code, AST is null!");
return Code::Invalid; return Code_Invalid;
} }
return { rcast(AST*, ast)->duplicate() }; return { rcast(AST*, ast)->duplicate() };
@ -404,7 +406,7 @@ CodeBody gen_ast_inlines()
return; return;
} }
rcast(AST*, ast)->Parent = Code::Global.ast; rcast(AST*, ast)->Parent = Code_Global.ast;
} }
inline inline
<typename>& <typename>::operator =( Code other ) <typename>& <typename>::operator =( Code other )
@ -419,16 +421,6 @@ CodeBody gen_ast_inlines()
return *this; return *this;
} }
inline inline
bool <typename>::operator ==( Code other )
{
return (AST*) ast == other.ast;
}
inline
bool <typename>::operator !=( Code other )
{
return (AST*) ast != other.ast;
}
inline
<typename>::operator bool() <typename>::operator bool()
{ {
return ast != nullptr; return ast != nullptr;
@ -459,6 +451,7 @@ CodeBody gen_ast_inlines()
\n \n
); );
#pragma pop_macro("GEN_NS") #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 = 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 )); CodeBody impl_code_body = parse_global_body( token_fmt( "typename", StrC name(CodeBody), code_impl_tmpl ));