mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
Compare commits
5 Commits
8f47f3b30f
...
f28ae57f16
Author | SHA1 | Date | |
---|---|---|---|
f28ae57f16 | |||
2fe708e4be | |||
69a9abcd59 | |||
defe42c15c | |||
05e65aa464 |
@ -157,7 +157,7 @@ int gen_main()
|
||||
CodeFn fn = cast(CodeFn, entry);
|
||||
s32 constexpr_found = fn->Specs.remove( ESpecifier::Constexpr );
|
||||
if (constexpr_found > -1) {
|
||||
log_fmt("Found constexpr: %S\n", entry->to_string());
|
||||
log_fmt("Found constexpr: %S\n", entry.to_string());
|
||||
fn->Specs.append(ESpecifier::Inline);
|
||||
}
|
||||
if ( fn->Name.is_equal(txt("free")) )
|
||||
@ -189,7 +189,7 @@ int gen_main()
|
||||
case ECode::Class:
|
||||
case ECode::Struct:
|
||||
{
|
||||
CodeBody body = entry->Body->operator CodeBody();
|
||||
CodeBody body = cast(CodeBody, entry->Body);
|
||||
CodeBody new_body = def_body( entry->Body->Type );
|
||||
for ( Code body_entry = body.begin(); body_entry != body.end(); ++ body_entry ) switch
|
||||
(body_entry->Type) {
|
||||
@ -204,7 +204,7 @@ int gen_main()
|
||||
break;
|
||||
}
|
||||
|
||||
entry->Body = rcast(AST*, new_body.ast);
|
||||
entry->Body = new_body;
|
||||
memory.append(entry);
|
||||
}
|
||||
break;
|
||||
@ -324,7 +324,7 @@ int gen_main()
|
||||
|
||||
case ECode::Struct:
|
||||
{
|
||||
CodeBody body = entry->Body->operator CodeBody();
|
||||
CodeBody body = cast(CodeBody, entry->Body);
|
||||
CodeBody new_body = def_body( entry->Body->Type );
|
||||
for ( Code body_entry = body.begin(); body_entry != body.end(); ++ body_entry ) switch
|
||||
(body_entry->Type) {
|
||||
@ -340,7 +340,7 @@ int gen_main()
|
||||
new_body.append(body_entry);
|
||||
break;
|
||||
}
|
||||
entry->Body = rcast(AST*, new_body.ast);
|
||||
entry->Body = new_body;
|
||||
strings.append(entry);
|
||||
}
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@ global Code Code_Global;
|
||||
global Code Code_Invalid;
|
||||
|
||||
// This serializes all the data-members in a "debug" format, where each member is printed with its associated value.
|
||||
char const* debug_str(AST* self)
|
||||
char const* debug_str(Code self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
String result_stack = string_make_reserve( GlobalAllocator, kilobytes(1) );
|
||||
@ -360,26 +360,26 @@ char const* debug_str(AST* self)
|
||||
return * result;
|
||||
}
|
||||
|
||||
AST* duplicate(AST* self)
|
||||
Code duplicate(Code self)
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
AST* result = make_code().ast;
|
||||
Code result = make_code();
|
||||
|
||||
mem_copy( result, self, sizeof( AST ) );
|
||||
mem_copy( result.ast, self.ast, sizeof( AST ) );
|
||||
|
||||
result->Parent = nullptr;
|
||||
result->Parent = { nullptr };
|
||||
return result;
|
||||
}
|
||||
|
||||
String to_string(AST* self)
|
||||
String to_string(Code self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
GEN_NS to_string( self, & result );
|
||||
return result;
|
||||
}
|
||||
|
||||
void to_string( AST* self, String* result )
|
||||
void to_string( Code self, String* result )
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
local_persist thread_local
|
||||
@ -415,169 +415,169 @@ void to_string( AST* self, String* result )
|
||||
break;
|
||||
|
||||
case Class:
|
||||
to_string_def(cast(CodeClass, {self}), result );
|
||||
to_string_def(cast(CodeClass, self), result );
|
||||
break;
|
||||
|
||||
case Class_Fwd:
|
||||
to_string_fwd(cast(CodeClass, {self}), result );
|
||||
to_string_fwd(cast(CodeClass, self), result );
|
||||
break;
|
||||
|
||||
case Constructor:
|
||||
to_string_def(cast(CodeConstructor, {self}), result );
|
||||
to_string_def(cast(CodeConstructor, self), result );
|
||||
break;
|
||||
|
||||
case Constructor_Fwd:
|
||||
to_string_fwd(cast(CodeConstructor, {self}), result );
|
||||
to_string_fwd(cast(CodeConstructor, self), result );
|
||||
break;
|
||||
|
||||
case Destructor:
|
||||
to_string_def(cast(CodeDestructor, {self}), result );
|
||||
to_string_def(cast(CodeDestructor, self), result );
|
||||
break;
|
||||
|
||||
case Destructor_Fwd:
|
||||
to_string_fwd(cast(CodeDestructor, {self}), result );
|
||||
to_string_fwd(cast(CodeDestructor, self), result );
|
||||
break;
|
||||
|
||||
case Enum:
|
||||
to_string_def(cast(CodeEnum, {self}), result );
|
||||
to_string_def(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case Enum_Fwd:
|
||||
to_string_fwd(cast(CodeEnum, {self}), result );
|
||||
to_string_fwd(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case Enum_Class:
|
||||
to_string_class_def(cast(CodeEnum, {self}), result );
|
||||
to_string_class_def(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case Enum_Class_Fwd:
|
||||
to_string_class_fwd(cast(CodeEnum, {self}), result );
|
||||
to_string_class_fwd(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case Export_Body:
|
||||
to_string_export(cast(CodeBody, {self}), result );
|
||||
to_string_export(cast(CodeBody, self), result );
|
||||
break;
|
||||
|
||||
case Extern_Linkage:
|
||||
to_string(cast(CodeExtern, {self}), result );
|
||||
to_string(cast(CodeExtern, self), result );
|
||||
break;
|
||||
|
||||
case Friend:
|
||||
to_string(cast(CodeFriend, {self}), result );
|
||||
to_string(cast(CodeFriend, self), result );
|
||||
break;
|
||||
|
||||
case Function:
|
||||
to_string_def(cast(CodeFn, {self}), result );
|
||||
to_string_def(cast(CodeFn, self), result );
|
||||
break;
|
||||
|
||||
case Function_Fwd:
|
||||
to_string_fwd(cast(CodeFn, {self}), result );
|
||||
to_string_fwd(cast(CodeFn, self), result );
|
||||
break;
|
||||
|
||||
case Module:
|
||||
cast(CodeModule, {self}).to_string( * result );
|
||||
to_string(cast(CodeModule, self), result );
|
||||
break;
|
||||
|
||||
case Namespace:
|
||||
cast(CodeNS, {self}).to_string( * result );
|
||||
to_string(cast(CodeNS, self), result );
|
||||
break;
|
||||
|
||||
case Operator:
|
||||
case Operator_Member:
|
||||
cast(CodeOperator, {self}).to_string_def( * result );
|
||||
to_string_def(cast(CodeOperator, self), result );
|
||||
break;
|
||||
|
||||
case Operator_Fwd:
|
||||
case Operator_Member_Fwd:
|
||||
cast(CodeOperator, {self}).to_string_fwd( * result );
|
||||
to_string_fwd(cast(CodeOperator, self), result );
|
||||
break;
|
||||
|
||||
case Operator_Cast:
|
||||
cast(CodeOpCast, {self}).to_string_def( * result );
|
||||
to_string_def(cast(CodeOpCast, self), result );
|
||||
break;
|
||||
|
||||
case Operator_Cast_Fwd:
|
||||
cast(CodeOpCast, {self}).to_string_fwd( * result );
|
||||
to_string_fwd(cast(CodeOpCast, self), result );
|
||||
break;
|
||||
|
||||
case Parameters:
|
||||
to_string(cast(CodeParam, {self}), result );
|
||||
to_string(cast(CodeParam, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_Define:
|
||||
to_string(cast(CodeDefine, {self}), result );
|
||||
to_string(cast(CodeDefine, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_If:
|
||||
cast(CodePreprocessCond, {self}).to_string_if( * result );
|
||||
to_string_if(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_IfDef:
|
||||
cast(CodePreprocessCond, {self}).to_string_ifdef( * result );
|
||||
to_string_ifdef(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_IfNotDef:
|
||||
cast(CodePreprocessCond, {self}).to_string_ifndef( * result );
|
||||
to_string_ifndef(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_Include:
|
||||
to_string(cast(CodeInclude, {self}), result );
|
||||
to_string(cast(CodeInclude, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_ElIf:
|
||||
cast(CodePreprocessCond, {self}).to_string_elif( * result );
|
||||
to_string_elif(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_Else:
|
||||
cast(CodePreprocessCond, {self}).to_string_else( * result );
|
||||
to_string_else(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_EndIf:
|
||||
cast(CodePreprocessCond, {self}).to_string_endif( * result );
|
||||
to_string_endif(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case Preprocess_Pragma:
|
||||
cast(CodePragma, {self}).to_string( * result );
|
||||
to_string(cast(CodePragma, self), result );
|
||||
break;
|
||||
|
||||
case Specifiers:
|
||||
to_string(cast(CodeSpecifiers, {self}), result );
|
||||
to_string(cast(CodeSpecifiers, self), result );
|
||||
break;
|
||||
|
||||
case Struct:
|
||||
to_string_def(cast(CodeStruct, {self}), result );
|
||||
to_string_def(cast(CodeStruct, self), result );
|
||||
break;
|
||||
|
||||
case Struct_Fwd:
|
||||
to_string_fwd(cast(CodeStruct, {self}), result );
|
||||
to_string_fwd(cast(CodeStruct, self), result );
|
||||
break;
|
||||
|
||||
case Template:
|
||||
cast(CodeTemplate, {self}).to_string( * result );
|
||||
to_string(cast(CodeTemplate, self), result );
|
||||
break;
|
||||
|
||||
case Typedef:
|
||||
cast(CodeTypedef, {self}).to_string( * result );
|
||||
to_string(cast(CodeTypedef, self), result );
|
||||
break;
|
||||
|
||||
case Typename:
|
||||
cast(CodeType, {self}).to_string( * result );
|
||||
to_string(cast(CodeType, self), result );
|
||||
break;
|
||||
|
||||
case Union:
|
||||
cast(CodeUnion, {self}).to_string( * result );
|
||||
to_string( cast(CodeUnion, self), result );
|
||||
break;
|
||||
|
||||
case Using:
|
||||
cast(CodeUsing, {self}).to_string( * result );
|
||||
to_string(cast(CodeUsing, self), result );
|
||||
break;
|
||||
|
||||
case Using_Namespace:
|
||||
cast(CodeUsing, {self}).to_string_ns( * result );
|
||||
to_string_ns(cast(CodeUsing, self), result );
|
||||
break;
|
||||
|
||||
case Variable:
|
||||
cast(CodeVar, {self}).to_string( * result );
|
||||
to_string(cast(CodeVar, self), result );
|
||||
break;
|
||||
|
||||
case Enum_Body:
|
||||
@ -588,12 +588,12 @@ void to_string( AST* self, String* result )
|
||||
case Namespace_Body:
|
||||
case Struct_Body:
|
||||
case Union_Body:
|
||||
to_string( cast(CodeBody, {self}), result );
|
||||
to_string( cast(CodeBody, self), result );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_equal( AST* self, AST* other )
|
||||
bool is_equal( Code self, Code other )
|
||||
{
|
||||
/*
|
||||
AST values are either some u32 value, a cached string, or a pointer to another AST.
|
||||
@ -910,8 +910,8 @@ bool is_equal( AST* self, AST* other )
|
||||
{
|
||||
if ( self->NumEntries > 1 )
|
||||
{
|
||||
AST* curr = self;
|
||||
AST* curr_other = other;
|
||||
Code curr = self;
|
||||
Code curr_other = other;
|
||||
while ( curr != nullptr )
|
||||
{
|
||||
if ( curr )
|
||||
@ -1104,8 +1104,8 @@ bool is_equal( AST* self, AST* other )
|
||||
check_member_ast( Front );
|
||||
check_member_ast( Back );
|
||||
|
||||
AST* curr = self->Front;
|
||||
AST* curr_other = other->Front;
|
||||
Code curr = self->Front;
|
||||
Code curr_other = other->Front;
|
||||
while ( curr != nullptr )
|
||||
{
|
||||
if ( curr_other == nullptr )
|
||||
@ -1153,14 +1153,14 @@ bool is_equal( AST* self, AST* other )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool validate_body(AST* self)
|
||||
bool validate_body(Code self)
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
#define CheckEntries( Unallowed_Types ) \
|
||||
do \
|
||||
{ \
|
||||
for ( Code entry : cast(CodeBody, {self}) ) \
|
||||
for ( Code entry : cast(CodeBody, self) ) \
|
||||
{ \
|
||||
switch ( entry->Type ) \
|
||||
{ \
|
||||
@ -1178,7 +1178,7 @@ bool validate_body(AST* self)
|
||||
CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES );
|
||||
break;
|
||||
case Enum_Body:
|
||||
for ( Code entry : cast(CodeBody, {self}) )
|
||||
for ( Code entry : cast(CodeBody, self) )
|
||||
{
|
||||
if ( entry->Type != Untyped )
|
||||
{
|
||||
@ -1197,7 +1197,7 @@ bool validate_body(AST* self)
|
||||
CheckEntries( GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES );
|
||||
break;
|
||||
case Global_Body:
|
||||
for (Code entry : cast(CodeBody, {self}))
|
||||
for (Code entry : cast(CodeBody, self))
|
||||
{
|
||||
switch (entry->Type)
|
||||
{
|
||||
|
@ -152,22 +152,29 @@ Define_Code(Using);
|
||||
Define_Code(Var);
|
||||
#undef Define_Code
|
||||
|
||||
namespace parser
|
||||
{
|
||||
struct Token;
|
||||
}
|
||||
GEN_NS_PARSER_BEGIN
|
||||
struct Token;
|
||||
GEN_NS_PARSER_END
|
||||
|
||||
#if ! GEN_COMPILER_C
|
||||
template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( Type*, & self ); }
|
||||
#endif
|
||||
|
||||
char const* debug_str (Code code);
|
||||
Code duplicate (Code code);
|
||||
bool is_equal (Code code, Code other);
|
||||
bool is_body (Code code);
|
||||
bool is_valid (Code code);
|
||||
void set_global(Code code);
|
||||
String to_string (Code code);
|
||||
#pragma region Code Interface
|
||||
void append (Code code, Code other );
|
||||
char const* debug_str (Code code);
|
||||
Code duplicate (Code code);
|
||||
Code* entry (Code code, u32 idx );
|
||||
bool has_entries (Code code);
|
||||
bool is_body (Code code);
|
||||
bool is_equal (Code code, Code other);
|
||||
bool is_valid (Code code);
|
||||
void set_global (Code code);
|
||||
String to_string (Code self );
|
||||
void to_string (Code self, String* result );
|
||||
char const* type_str (Code self );
|
||||
bool validate_body(Code self );
|
||||
#pragma endregion Code Interface
|
||||
|
||||
#if ! GEN_COMPILER_C
|
||||
/*
|
||||
@ -188,7 +195,6 @@ struct Code
|
||||
void set_global() { return GEN_NS set_global(* this); }
|
||||
|
||||
# define Using_CodeOps( Typename ) \
|
||||
Typename& operator = ( AST* other ); \
|
||||
Typename& operator = ( Code other ); \
|
||||
bool operator ==( Code other ) { return (AST*)ast == other.ast; } \
|
||||
bool operator !=( Code other ) { return (AST*)ast != other.ast; } \
|
||||
@ -196,7 +202,13 @@ struct Code
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( Code );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void append(Code other) { return GEN_NS append(* this, other); }
|
||||
Code* entry(u32 idx) { return GEN_NS entry(* this, idx); }
|
||||
bool has_entries() { return GEN_NS has_entries(* this); }
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string(String& result) { return GEN_NS to_string(* this, & result); }
|
||||
char const* type_str() { return GEN_NS type_str(* this); }
|
||||
bool validate_body() { return GEN_NS validate_body(*this); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( Code );
|
||||
@ -216,6 +228,11 @@ struct Code
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(std::nullptr_t) const { return ast == nullptr; }
|
||||
bool operator!=(std::nullptr_t) const { return ast != nullptr; }
|
||||
friend bool operator==(std::nullptr_t, const Code code) { return code.ast == nullptr; }
|
||||
friend bool operator!=(std::nullptr_t, const Code code) { return code.ast != nullptr; }
|
||||
|
||||
#ifdef GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
# define operator explicit operator
|
||||
#endif
|
||||
@ -264,33 +281,11 @@ struct Code_POD
|
||||
{
|
||||
AST* ast;
|
||||
};
|
||||
|
||||
static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" );
|
||||
|
||||
// Desired width of the AST data structure.
|
||||
constexpr int const AST_POD_Size = 128;
|
||||
|
||||
void append ( AST* self, AST* other );
|
||||
char const* debug_str ( AST* self );
|
||||
AST* duplicate ( AST* self );
|
||||
Code* entry ( AST* self, u32 idx );
|
||||
bool has_entries ( AST* self );
|
||||
bool is_body ( AST* self );
|
||||
bool is_equal ( AST* self, AST* other );
|
||||
String to_string ( AST* self );
|
||||
void to_string ( AST* self, String* result );
|
||||
char const* type_str ( AST* self );
|
||||
bool validate_body( AST* self );
|
||||
|
||||
#if GEN_CPP_SUPPORT_REFERENCES
|
||||
void append ( AST& self, AST& other ) { return append(& self, & other); }
|
||||
bool is_body ( AST& self ) { return is_body(& self); }
|
||||
bool is_equal ( AST& self, AST& other ) { return is_equal(& self, & other); }
|
||||
char const* debug_str( AST& self ) { return debug_str( & self ); }
|
||||
String to_string( AST& self ) { return to_string( & self ); }
|
||||
char const* type_str ( AST& self ) { return type_str( & self ); }
|
||||
#endif
|
||||
|
||||
constexpr static
|
||||
int AST_ArrSpecs_Cap =
|
||||
(
|
||||
@ -310,102 +305,53 @@ int AST_ArrSpecs_Cap =
|
||||
*/
|
||||
struct AST
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
# pragma region Member Functions
|
||||
void append ( AST* other ) { GEN_NS append(this, other); }
|
||||
char const* debug_str () { return GEN_NS debug_str(this); }
|
||||
AST* duplicate () { return GEN_NS duplicate(this); }
|
||||
Code* entry ( u32 idx ) { return GEN_NS entry(this, idx); }
|
||||
bool has_entries() { return GEN_NS has_entries(this); }
|
||||
bool is_equal ( AST* other ) { return GEN_NS is_equal(this, other); }
|
||||
bool is_body() { return GEN_NS is_body(this); }
|
||||
char const* type_str() { return GEN_NS type_str(this); }
|
||||
bool validate_body() { return GEN_NS validate_body(this); }
|
||||
|
||||
String to_string() { return GEN_NS to_string(this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(this, & result); }
|
||||
|
||||
# pragma endregion Member Functions
|
||||
#endif
|
||||
|
||||
operator Code();
|
||||
operator CodeBody();
|
||||
operator CodeAttributes();
|
||||
// operator CodeBaseClass();
|
||||
operator CodeComment();
|
||||
operator CodeConstructor();
|
||||
operator CodeDestructor();
|
||||
operator CodeClass();
|
||||
operator CodeDefine();
|
||||
operator CodeEnum();
|
||||
operator CodeExec();
|
||||
operator CodeExtern();
|
||||
operator CodeInclude();
|
||||
operator CodeFriend();
|
||||
operator CodeFn();
|
||||
operator CodeModule();
|
||||
operator CodeNS();
|
||||
operator CodeOperator();
|
||||
operator CodeOpCast();
|
||||
operator CodeParam();
|
||||
operator CodePragma();
|
||||
operator CodePreprocessCond();
|
||||
operator CodeSpecifiers();
|
||||
operator CodeStruct();
|
||||
operator CodeTemplate();
|
||||
operator CodeType();
|
||||
operator CodeTypedef();
|
||||
operator CodeUnion();
|
||||
operator CodeUsing();
|
||||
operator CodeVar();
|
||||
|
||||
union {
|
||||
struct
|
||||
{
|
||||
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
||||
AST* Specs; // Destructor, Function, Operator, Typename, Variable
|
||||
Code InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
Code Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
||||
Code Specs; // Destructor, Function, Operator, Typename, Variable
|
||||
union {
|
||||
AST* InitializerList; // Constructor
|
||||
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
||||
AST* ReturnType; // Function, Operator, Typename
|
||||
AST* UnderlyingType; // Enum, Typedef
|
||||
AST* ValueType; // Parameter, Variable
|
||||
Code InitializerList; // Constructor
|
||||
Code ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
||||
Code ReturnType; // Function, Operator, Typename
|
||||
Code UnderlyingType; // Enum, Typedef
|
||||
Code ValueType; // Parameter, Variable
|
||||
};
|
||||
union {
|
||||
AST* Macro; // Parameter
|
||||
AST* BitfieldSize; // Variable (Class/Struct Data Member)
|
||||
AST* Params; // Constructor, Function, Operator, Template, Typename
|
||||
Code Macro; // Parameter
|
||||
Code BitfieldSize; // Variable (Class/Struct Data Member)
|
||||
Code Params; // Constructor, Function, Operator, Template, Typename
|
||||
};
|
||||
union {
|
||||
AST* ArrExpr; // Typename
|
||||
AST* Body; // Class, Constructor, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
||||
AST* Declaration; // Friend, Template
|
||||
AST* Value; // Parameter, Variable
|
||||
Code ArrExpr; // Typename
|
||||
Code Body; // Class, Constructor, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
||||
Code Declaration; // Friend, Template
|
||||
Code Value; // Parameter, Variable
|
||||
};
|
||||
union {
|
||||
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
||||
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
||||
AST* PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
|
||||
Code NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
||||
Code SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
||||
Code PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
|
||||
};
|
||||
};
|
||||
StringCached Content; // Attributes, Comment, Execution, Include
|
||||
struct {
|
||||
SpecifierT ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers
|
||||
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
||||
Code NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
||||
};
|
||||
};
|
||||
union {
|
||||
AST* Prev;
|
||||
AST* Front;
|
||||
AST* Last;
|
||||
Code Prev;
|
||||
Code Front;
|
||||
Code Last;
|
||||
};
|
||||
union {
|
||||
AST* Next;
|
||||
AST* Back;
|
||||
Code Next;
|
||||
Code Back;
|
||||
};
|
||||
parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
||||
AST* Parent;
|
||||
Code Parent;
|
||||
StringCached Name;
|
||||
CodeT Type;
|
||||
// CodeFlag CodeFlags;
|
||||
@ -420,75 +366,16 @@ struct AST
|
||||
b32 EnumUnderlyingMacro; // Used by enums incase the user wants to wrap underlying type specification in a macro
|
||||
};
|
||||
};
|
||||
static_assert( sizeof(AST) == AST_POD_Size, "ERROR: AST POD is not size of AST_POD_Size" );
|
||||
|
||||
struct AST_POD
|
||||
{
|
||||
union {
|
||||
struct
|
||||
{
|
||||
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
||||
AST* Specs; // Destructor, Function, Operator, Typename, Variable
|
||||
union {
|
||||
AST* InitializerList; // Constructor
|
||||
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
||||
AST* ReturnType; // Function, Operator, Typename
|
||||
AST* UnderlyingType; // Enum, Typedef
|
||||
AST* ValueType; // Parameter, Variable
|
||||
};
|
||||
union {
|
||||
AST* Macro; // Parameter
|
||||
AST* BitfieldSize; // Variable (Class/Struct Data Member)
|
||||
AST* Params; // Constructor, Function, Operator, Template, Typename
|
||||
};
|
||||
union {
|
||||
AST* ArrExpr; // Typename
|
||||
AST* Body; // Class, Constructr, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
||||
AST* Declaration; // Friend, Template
|
||||
AST* Value; // Parameter, Variable
|
||||
};
|
||||
union {
|
||||
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
||||
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
||||
AST* PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
|
||||
};
|
||||
};
|
||||
StringCached Content; // Attributes, Comment, Execution, Include
|
||||
struct {
|
||||
SpecifierT ArrSpecs[AST_ArrSpecs_Cap]; // Specifiers
|
||||
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
||||
};
|
||||
};
|
||||
union {
|
||||
AST* Prev;
|
||||
AST* Front;
|
||||
AST* Last;
|
||||
};
|
||||
union {
|
||||
AST* Next;
|
||||
AST* Back;
|
||||
};
|
||||
parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
||||
AST* Parent;
|
||||
StringCached Name;
|
||||
CodeT Type;
|
||||
CodeFlag CodeFlags;
|
||||
ModuleFlag ModuleFlags;
|
||||
union {
|
||||
b32 IsFunction; // Used by typedef to not serialize the name field.
|
||||
b32 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
|
||||
OperatorT Op;
|
||||
AccessSpec ParentAccess;
|
||||
s32 NumEntries;
|
||||
s32 VarConstructorInit; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
|
||||
};
|
||||
};
|
||||
|
||||
// Its intended for the AST to have equivalent size to its POD.
|
||||
// All extra functionality within the AST namespace should just be syntatic sugar.
|
||||
static_assert( sizeof(AST) == sizeof(AST_POD), "ERROR: AST IS NOT POD" );
|
||||
static_assert( sizeof(AST_POD) == AST_POD_Size, "ERROR: AST POD is not size of AST_POD_Size" );
|
||||
#if ! GEN_COMPILER_C
|
||||
// Uses an implicitly overloaded cast from the AST to the desired code type.
|
||||
// Necessary if the user wants GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
struct InvalidCode_ImplictCaster;
|
||||
#define InvalidCode (InvalidCode_ImplictCaster{})
|
||||
#else
|
||||
#define InvalidCode Code_Invalid
|
||||
#endif
|
||||
|
||||
// Used when the its desired when omission is allowed in a definition.
|
||||
#define NoCode { nullptr }
|
||||
#define InvalidCode (* Code_Invalid.ast) // Uses an implicitly overloaded cast from the AST to the desired code type.
|
||||
#define NullCode { nullptr }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@
|
||||
#include "ast.hpp"
|
||||
#endif
|
||||
|
||||
#pragma region Code Type Interface
|
||||
void append ( CodeBody body, Code other );
|
||||
void append ( CodeBody body, CodeBody other );
|
||||
String to_string ( CodeBody body );
|
||||
@ -74,11 +75,58 @@ String to_string (CodeFn self);
|
||||
void to_string_def(CodeFn self, String* result);
|
||||
void to_string_fwd(CodeFn self, String* result);
|
||||
|
||||
String to_string(CodeModule self);
|
||||
void to_string(CodeModule self, String* result);
|
||||
|
||||
String to_string(CodeNS self);
|
||||
void to_string(CodeNS self, String* result);
|
||||
|
||||
String to_string (CodeOperator self);
|
||||
void to_string_fwd(CodeOperator self, String* result );
|
||||
void to_string_def(CodeOperator self, String* result );
|
||||
|
||||
String to_string (CodeOpCast op_cast );
|
||||
void to_string_def(CodeOpCast op_cast, String* result );
|
||||
void to_string_fwd(CodeOpCast op_cast, String* result );
|
||||
|
||||
String to_string(CodePragma self);
|
||||
void to_string(CodePragma self, String* result);
|
||||
|
||||
String to_string (CodePreprocessCond cond);
|
||||
void to_string_if (CodePreprocessCond cond, String* result );
|
||||
void to_string_ifdef (CodePreprocessCond cond, String* result );
|
||||
void to_string_ifndef(CodePreprocessCond cond, String* result );
|
||||
void to_string_elif (CodePreprocessCond cond, String* result );
|
||||
void to_string_else (CodePreprocessCond cond, String* result );
|
||||
void to_string_endif (CodePreprocessCond cond, String* result );
|
||||
|
||||
String to_string(CodeTemplate self);
|
||||
void to_string(CodeTemplate self, String* result);
|
||||
|
||||
String to_string(CodeType self);
|
||||
void to_string(CodeType self, String* result);
|
||||
|
||||
String to_string(CodeTypedef self);
|
||||
void to_string(CodeTypedef self, String* result);
|
||||
|
||||
String to_string(CodeUnion self);
|
||||
void to_string(CodeUnion self, String* result);
|
||||
|
||||
String to_string (CodeUsing op_cast );
|
||||
void to_string (CodeUsing op_cast, String* result );
|
||||
void to_string_ns(CodeUsing op_cast, String* result );
|
||||
|
||||
String to_string(CodeVar self);
|
||||
void to_string(CodeVar self, String* result);
|
||||
#pragma endregion Code Type Interface
|
||||
|
||||
#pragma region Code Types
|
||||
// These structs are not used at all by the C vairant.
|
||||
#if ! GEN_COMPILER_C
|
||||
// stati_assert( GEN_COMPILER_C, "This should not be compiled with the C-library" );
|
||||
|
||||
#define Verify_POD(Type) static_assert(size_of(Code##Type) == size_of(AST_##Type), "ERROR: Code##Type is not a POD")
|
||||
|
||||
struct CodeBody
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
@ -86,7 +134,7 @@ struct CodeBody
|
||||
|
||||
void append( Code other ) { return GEN_NS append( *this, other ); }
|
||||
void append( CodeBody body ) { return GEN_NS append(*this, body); }
|
||||
bool has_entries() { return GEN_NS has_entries(rcast( AST*, ast )); }
|
||||
bool has_entries() { return GEN_NS has_entries(* this); }
|
||||
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result ); }
|
||||
@ -292,10 +340,10 @@ struct CodeEnum
|
||||
Using_Code( CodeEnum );
|
||||
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this); }
|
||||
void to_string_class_def( String& result ) { return GEN_NS to_string_class_def(* this); }
|
||||
void to_string_class_fwd( String& result ) { return GEN_NS to_string_class_fwd(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); }
|
||||
void to_string_class_def( String& result ) { return GEN_NS to_string_class_def(* this, & result); }
|
||||
void to_string_class_fwd( String& result ) { return GEN_NS to_string_class_fwd(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeEnum);
|
||||
@ -573,8 +621,8 @@ struct CodeFn
|
||||
Using_Code( CodeFn );
|
||||
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeFn);
|
||||
@ -585,11 +633,11 @@ struct CodeFn
|
||||
|
||||
struct CodeModule
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeModule );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeModule);
|
||||
@ -600,11 +648,11 @@ struct CodeModule
|
||||
|
||||
struct CodeNS
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeNS );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeNS);
|
||||
@ -615,12 +663,12 @@ struct CodeNS
|
||||
|
||||
struct CodeOperator
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeOperator );
|
||||
|
||||
String to_string();
|
||||
void to_string_def( String& result );
|
||||
void to_string_fwd( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeOperator);
|
||||
@ -631,12 +679,12 @@ struct CodeOperator
|
||||
|
||||
struct CodeOpCast
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeOpCast );
|
||||
|
||||
String to_string();
|
||||
void to_string_def( String& result );
|
||||
void to_string_fwd( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeOpCast);
|
||||
@ -650,8 +698,8 @@ struct CodePragma
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
Using_Code( CodePragma );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodePragma );
|
||||
@ -662,16 +710,16 @@ struct CodePragma
|
||||
|
||||
struct CodePreprocessCond
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodePreprocessCond );
|
||||
|
||||
String to_string();
|
||||
void to_string_if( String& result );
|
||||
void to_string_ifdef( String& result );
|
||||
void to_string_ifndef( String& result );
|
||||
void to_string_elif( String& result );
|
||||
void to_string_else( String& result );
|
||||
void to_string_endif( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_if( String& result ) { return GEN_NS to_string_if(* this, & result); }
|
||||
void to_string_ifdef( String& result ) { return GEN_NS to_string_ifdef(* this, & result); }
|
||||
void to_string_ifndef( String& result ) { return GEN_NS to_string_ifndef(* this, & result); }
|
||||
void to_string_elif( String& result ) { return GEN_NS to_string_elif(* this, & result); }
|
||||
void to_string_else( String& result ) { return GEN_NS to_string_else(* this, & result); }
|
||||
void to_string_endif( String& result ) { return GEN_NS to_string_endif(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodePreprocessCond );
|
||||
@ -866,11 +914,11 @@ struct CodeStmt_While
|
||||
|
||||
struct CodeTemplate
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeTemplate );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeTemplate );
|
||||
@ -881,11 +929,11 @@ struct CodeTemplate
|
||||
|
||||
struct CodeType
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeType );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeType );
|
||||
@ -896,11 +944,11 @@ struct CodeType
|
||||
|
||||
struct CodeTypedef
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeTypedef );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeTypedef );
|
||||
@ -914,8 +962,8 @@ struct CodeUnion
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
Using_Code( CodeUnion );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeUnion);
|
||||
@ -929,9 +977,9 @@ struct CodeUsing
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
Using_Code( CodeUsing );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
void to_string_ns( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
void to_string_ns( String& result ) { return GEN_NS to_string_ns(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeUsing);
|
||||
@ -945,8 +993,8 @@ struct CodeVar
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
Using_Code( CodeVar );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeVar);
|
||||
@ -963,6 +1011,42 @@ struct CodeVar
|
||||
void to_string_export( CodeBody body, String& result ) { return to_string_export(body, & result); };
|
||||
#endif
|
||||
|
||||
#undef Verify_POD
|
||||
|
||||
struct InvalidCode_ImplictCaster
|
||||
{
|
||||
// operator CodeBaseClass() const;
|
||||
operator Code () const { return Code_Invalid; }
|
||||
operator CodeBody () const { return cast(CodeBody, Code_Invalid); }
|
||||
operator CodeAttributes () const { return cast(CodeAttributes, Code_Invalid); }
|
||||
operator CodeComment () const { return cast(CodeComment, Code_Invalid); }
|
||||
operator CodeClass () const { return cast(CodeClass, Code_Invalid); }
|
||||
operator CodeConstructor () const { return cast(CodeConstructor, Code_Invalid); }
|
||||
operator CodeDefine () const { return cast(CodeDefine, Code_Invalid); }
|
||||
operator CodeDestructor () const { return cast(CodeDestructor, Code_Invalid); }
|
||||
operator CodeExec () const { return cast(CodeExec, Code_Invalid); }
|
||||
operator CodeEnum () const { return cast(CodeEnum, Code_Invalid); }
|
||||
operator CodeExtern () const { return cast(CodeExtern, Code_Invalid); }
|
||||
operator CodeInclude () const { return cast(CodeInclude, Code_Invalid); }
|
||||
operator CodeFriend () const { return cast(CodeFriend, Code_Invalid); }
|
||||
operator CodeFn () const { return cast(CodeFn, Code_Invalid); }
|
||||
operator CodeModule () const { return cast(CodeModule, Code_Invalid); }
|
||||
operator CodeNS () const { return cast(CodeNS, Code_Invalid); }
|
||||
operator CodeOperator () const { return cast(CodeOperator, Code_Invalid); }
|
||||
operator CodeOpCast () const { return cast(CodeOpCast, Code_Invalid); }
|
||||
operator CodeParam () const { return cast(CodeParam, Code_Invalid); }
|
||||
operator CodePragma () const { return cast(CodePragma, Code_Invalid); }
|
||||
operator CodePreprocessCond() const { return cast(CodePreprocessCond, Code_Invalid); }
|
||||
operator CodeSpecifiers () const { return cast(CodeSpecifiers, Code_Invalid); }
|
||||
operator CodeStruct () const { return cast(CodeStruct, Code_Invalid); }
|
||||
operator CodeTemplate () const { return cast(CodeTemplate, Code_Invalid); }
|
||||
operator CodeType () const { return cast(CodeType, Code_Invalid); }
|
||||
operator CodeTypedef () const { return cast(CodeTypedef, Code_Invalid); }
|
||||
operator CodeUnion () const { return cast(CodeUnion, Code_Invalid); }
|
||||
operator CodeUsing () const { return cast(CodeUsing, Code_Invalid); }
|
||||
operator CodeVar () const { return cast(CodeVar, Code_Invalid); }
|
||||
};
|
||||
|
||||
#endif //if ! GEN_COMPILER_C
|
||||
|
||||
#pragma endregion Code Types
|
||||
|
@ -11,8 +11,8 @@ inline Code& Code::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -27,8 +27,8 @@ inline CodeBody& CodeBody::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -43,8 +43,8 @@ inline CodeAttributes& CodeAttributes::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -74,8 +74,8 @@ inline CodeComment& CodeComment::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -105,8 +105,8 @@ inline CodeConstructor& CodeConstructor::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -136,8 +136,8 @@ inline CodeClass& CodeClass::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -152,8 +152,8 @@ inline CodeDefine& CodeDefine::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -183,8 +183,8 @@ inline CodeDestructor& CodeDestructor::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -214,8 +214,8 @@ inline CodeEnum& CodeEnum::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -245,8 +245,8 @@ inline CodeExec& CodeExec::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -276,8 +276,8 @@ inline CodeExtern& CodeExtern::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -307,8 +307,8 @@ inline CodeFriend& CodeFriend::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -338,8 +338,8 @@ inline CodeFn& CodeFn::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -369,8 +369,8 @@ inline CodeInclude& CodeInclude::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -400,8 +400,8 @@ inline CodeModule& CodeModule::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -431,8 +431,8 @@ inline CodeNS& CodeNS::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -462,8 +462,8 @@ inline CodeOperator& CodeOperator::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -493,8 +493,8 @@ inline CodeOpCast& CodeOpCast::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -524,8 +524,8 @@ inline CodeParam& CodeParam::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -540,8 +540,8 @@ inline CodePragma& CodePragma::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -571,8 +571,8 @@ inline CodePreprocessCond& CodePreprocessCond::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -602,8 +602,8 @@ inline CodeSpecifiers& CodeSpecifiers::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -618,8 +618,8 @@ inline CodeStruct& CodeStruct::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -634,8 +634,8 @@ inline CodeTemplate& CodeTemplate::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -665,8 +665,8 @@ inline CodeType& CodeType::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -696,8 +696,8 @@ inline CodeTypedef& CodeTypedef::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -727,8 +727,8 @@ inline CodeUnion& CodeUnion::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -758,8 +758,8 @@ inline CodeUsing& CodeUsing::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -789,8 +789,8 @@ inline CodeVar& CodeVar::operator=( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other.ast ) );
|
||||
rcast( AST*, ast )->Parent = nullptr;
|
||||
ast = rcast( decltype( ast ), GEN_NS duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
@ -820,281 +820,141 @@ inline AST_Var* CodeVar::operator->()
|
||||
|
||||
#pragma region generated AST/Code cast implementation
|
||||
|
||||
inline AST::operator CodeBody()
|
||||
{
|
||||
return { rcast( AST_Body*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeBody() const
|
||||
{
|
||||
return { (AST_Body*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeAttributes()
|
||||
{
|
||||
return { rcast( AST_Attributes*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeAttributes() const
|
||||
{
|
||||
return { (AST_Attributes*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeComment()
|
||||
{
|
||||
return { rcast( AST_Comment*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeComment() const
|
||||
{
|
||||
return { (AST_Comment*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeConstructor()
|
||||
{
|
||||
return { rcast( AST_Constructor*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeConstructor() const
|
||||
{
|
||||
return { (AST_Constructor*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeClass()
|
||||
{
|
||||
return { rcast( AST_Class*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeClass() const
|
||||
{
|
||||
return { (AST_Class*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeDefine()
|
||||
{
|
||||
return { rcast( AST_Define*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeDefine() const
|
||||
{
|
||||
return { (AST_Define*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeDestructor()
|
||||
{
|
||||
return { rcast( AST_Destructor*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeDestructor() const
|
||||
{
|
||||
return { (AST_Destructor*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeEnum()
|
||||
{
|
||||
return { rcast( AST_Enum*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeEnum() const
|
||||
{
|
||||
return { (AST_Enum*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeExec()
|
||||
{
|
||||
return { rcast( AST_Exec*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeExec() const
|
||||
{
|
||||
return { (AST_Exec*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeExtern()
|
||||
{
|
||||
return { rcast( AST_Extern*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeExtern() const
|
||||
{
|
||||
return { (AST_Extern*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeFriend()
|
||||
{
|
||||
return { rcast( AST_Friend*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeFriend() const
|
||||
{
|
||||
return { (AST_Friend*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeFn()
|
||||
{
|
||||
return { rcast( AST_Fn*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeFn() const
|
||||
{
|
||||
return { (AST_Fn*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeInclude()
|
||||
{
|
||||
return { rcast( AST_Include*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeInclude() const
|
||||
{
|
||||
return { (AST_Include*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeModule()
|
||||
{
|
||||
return { rcast( AST_Module*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeModule() const
|
||||
{
|
||||
return { (AST_Module*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeNS()
|
||||
{
|
||||
return { rcast( AST_NS*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeNS() const
|
||||
{
|
||||
return { (AST_NS*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeOperator()
|
||||
{
|
||||
return { rcast( AST_Operator*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeOperator() const
|
||||
{
|
||||
return { (AST_Operator*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeOpCast()
|
||||
{
|
||||
return { rcast( AST_OpCast*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeOpCast() const
|
||||
{
|
||||
return { (AST_OpCast*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeParam()
|
||||
{
|
||||
return { rcast( AST_Param*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeParam() const
|
||||
{
|
||||
return { (AST_Param*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodePragma()
|
||||
{
|
||||
return { rcast( AST_Pragma*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodePragma() const
|
||||
{
|
||||
return { (AST_Pragma*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodePreprocessCond()
|
||||
{
|
||||
return { rcast( AST_PreprocessCond*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodePreprocessCond() const
|
||||
{
|
||||
return { (AST_PreprocessCond*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeSpecifiers()
|
||||
{
|
||||
return { rcast( AST_Specifiers*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeSpecifiers() const
|
||||
{
|
||||
return { (AST_Specifiers*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeStruct()
|
||||
{
|
||||
return { rcast( AST_Struct*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeStruct() const
|
||||
{
|
||||
return { (AST_Struct*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeTemplate()
|
||||
{
|
||||
return { rcast( AST_Template*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeTemplate() const
|
||||
{
|
||||
return { (AST_Template*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeType()
|
||||
{
|
||||
return { rcast( AST_Type*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeType() const
|
||||
{
|
||||
return { (AST_Type*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeTypedef()
|
||||
{
|
||||
return { rcast( AST_Typedef*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeTypedef() const
|
||||
{
|
||||
return { (AST_Typedef*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeUnion()
|
||||
{
|
||||
return { rcast( AST_Union*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeUnion() const
|
||||
{
|
||||
return { (AST_Union*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeUsing()
|
||||
{
|
||||
return { rcast( AST_Using*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeUsing() const
|
||||
{
|
||||
return { (AST_Using*)ast };
|
||||
}
|
||||
|
||||
inline AST::operator CodeVar()
|
||||
{
|
||||
return { rcast( AST_Var*, this ) };
|
||||
}
|
||||
|
||||
inline Code::operator CodeVar() const
|
||||
{
|
||||
return { (AST_Var*)ast };
|
||||
|
@ -136,7 +136,7 @@ extern CodeType t_typename;
|
||||
#ifndef token_fmt
|
||||
# define gen_main main
|
||||
|
||||
# define __ NoCode
|
||||
# define __ NullCode
|
||||
|
||||
// Convienence for defining any name used with the gen api.
|
||||
// Lets you provide the length and string literal to the functions without the need for the DSL.
|
||||
|
@ -17,15 +17,3 @@
|
||||
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
||||
# include "gen.dep.hpp"
|
||||
#endif
|
||||
|
||||
#ifndef GEN_NS_BEGIN
|
||||
# ifdef GEN_DONT_USE_NAMESPACE
|
||||
# define GEN_NS
|
||||
# define GEN_NS_BEGIN
|
||||
# define GEN_NS_END
|
||||
# else
|
||||
# define GEN_NS gen::
|
||||
# define GEN_NS_BEGIN namespace gen {
|
||||
# define GEN_NS_END }
|
||||
# endif
|
||||
#endif
|
||||
|
@ -3,11 +3,12 @@
|
||||
#include "interface.hpp"
|
||||
#endif
|
||||
|
||||
#pragma region Code
|
||||
inline
|
||||
void append( AST* self, AST* other )
|
||||
void append( Code self, Code other )
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
GEN_ASSERT(other != nullptr);
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(other.ast != nullptr);
|
||||
|
||||
if ( other->Parent )
|
||||
other = duplicate(other);
|
||||
@ -23,40 +24,15 @@ void append( AST* self, AST* other )
|
||||
return;
|
||||
}
|
||||
|
||||
AST*
|
||||
Code
|
||||
Current = self->Back;
|
||||
Current->Next = other;
|
||||
other->Prev = Current;
|
||||
self->Back = other;
|
||||
self->NumEntries++;
|
||||
}
|
||||
|
||||
inline
|
||||
Code* entry( AST* self, u32 idx )
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
AST** current = & self->Front;
|
||||
while ( idx >= 0 && current != nullptr )
|
||||
{
|
||||
if ( idx == 0 )
|
||||
return rcast( Code*, current);
|
||||
|
||||
current = & ( * current )->Next;
|
||||
idx--;
|
||||
}
|
||||
|
||||
return rcast( Code*, current);
|
||||
}
|
||||
|
||||
inline
|
||||
bool has_entries(AST* self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
return self->NumEntries > 0;
|
||||
}
|
||||
|
||||
inline
|
||||
bool is_body(AST* self)
|
||||
bool is_body(Code self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
switch (self->Type)
|
||||
@ -74,59 +50,21 @@ bool is_body(AST* self)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
char const* type_str(AST* self)
|
||||
Code* entry( Code self, u32 idx )
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
return ECode::to_str( self->Type );
|
||||
}
|
||||
|
||||
inline
|
||||
AST::operator Code()
|
||||
{
|
||||
return { this };
|
||||
}
|
||||
|
||||
#pragma region Code
|
||||
inline
|
||||
char const* debug_str( Code code )
|
||||
{
|
||||
if ( code.ast == nullptr )
|
||||
return "Code::debug_str: AST is null!";
|
||||
|
||||
return debug_str( code.ast );
|
||||
}
|
||||
inline
|
||||
Code duplicate( Code code )
|
||||
{
|
||||
if ( code.ast == nullptr )
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
Code* current = & self->Front;
|
||||
while ( idx >= 0 && current != nullptr )
|
||||
{
|
||||
log_failure("Code::duplicate: Cannot duplicate code, AST is null!");
|
||||
return Code_Invalid;
|
||||
if ( idx == 0 )
|
||||
return rcast( Code*, current);
|
||||
|
||||
current = & ( * current )->Next;
|
||||
idx--;
|
||||
}
|
||||
|
||||
return { duplicate(code.ast) };
|
||||
}
|
||||
inline
|
||||
bool is_body(Code code)
|
||||
{
|
||||
if ( code.ast == nullptr )
|
||||
{
|
||||
return is_body(code.ast);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
inline
|
||||
bool is_equal( Code self, Code other )
|
||||
{
|
||||
if ( self.ast == nullptr || other.ast == nullptr )
|
||||
{
|
||||
// Just check if they're both null.
|
||||
// log_failure( "Code::is_equal: Cannot compare code, AST is null!" );
|
||||
return self.ast == nullptr && other.ast == nullptr;
|
||||
}
|
||||
return is_equal( self.ast, other.ast );
|
||||
return rcast( Code*, current);
|
||||
}
|
||||
inline
|
||||
bool is_valid(Code self)
|
||||
@ -134,6 +72,12 @@ bool is_valid(Code self)
|
||||
return self.ast != nullptr && self.ast->Type != CodeT::Invalid;
|
||||
}
|
||||
inline
|
||||
bool has_entries(AST* self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
return self->NumEntries > 0;
|
||||
}
|
||||
inline
|
||||
void set_global(Code self)
|
||||
{
|
||||
if ( self.ast == nullptr )
|
||||
@ -142,15 +86,21 @@ void set_global(Code self)
|
||||
return;
|
||||
}
|
||||
|
||||
self->Parent = Code_Global.ast;
|
||||
self->Parent.ast = Code_Global.ast;
|
||||
}
|
||||
inline
|
||||
Code& Code::operator ++()
|
||||
{
|
||||
if ( ast )
|
||||
ast = ast->Next;
|
||||
ast = ast->Next.ast;
|
||||
|
||||
return *this;
|
||||
return * this;
|
||||
}
|
||||
inline
|
||||
char const* type_str(Code self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
return ECode::to_str( self->Type );
|
||||
}
|
||||
#pragma endregion Code
|
||||
|
||||
@ -165,7 +115,7 @@ void append( CodeBody self, Code other )
|
||||
return;
|
||||
}
|
||||
|
||||
append( rcast(AST*, self.ast), other.ast );
|
||||
append( cast(Code, self), other );
|
||||
}
|
||||
inline
|
||||
void append( CodeBody self, CodeBody body )
|
||||
@ -216,8 +166,8 @@ inline
|
||||
void append( CodeParam appendee, CodeParam other )
|
||||
{
|
||||
GEN_ASSERT(appendee.ast != nullptr);
|
||||
AST* self = cast(Code, appendee).ast;
|
||||
AST* entry = (AST*) other.ast;
|
||||
Code self = cast(Code, appendee);
|
||||
Code entry = cast(Code, other);
|
||||
|
||||
if ( entry->Parent )
|
||||
entry = GEN_NS duplicate( entry );
|
||||
@ -246,7 +196,7 @@ CodeParam get(CodeParam self, s32 idx )
|
||||
if ( ! ++ param )
|
||||
return { nullptr };
|
||||
|
||||
param = { (AST_Param*) cast(Code, param)->Next };
|
||||
param = cast(Code, param)->Next;
|
||||
}
|
||||
while ( --idx );
|
||||
|
||||
|
@ -145,7 +145,7 @@ void define_constants()
|
||||
|
||||
# define def_constant_code_type( Type_ ) \
|
||||
t_##Type_ = def_type( name(Type_) ); \
|
||||
t_##Type_.set_global();
|
||||
set_global(t_##Type_);
|
||||
|
||||
def_constant_code_type( auto );
|
||||
def_constant_code_type( void );
|
||||
|
@ -42,74 +42,126 @@ void set_allocator_type_table ( AllocatorInfo type_reg_allocator );
|
||||
CodeAttributes def_attributes( StrC content );
|
||||
CodeComment def_comment ( StrC content );
|
||||
|
||||
CodeClass def_class( StrC name
|
||||
, Code body = NoCode
|
||||
, CodeType parent = NoCode, AccessSpec access = AccessSpec_Default
|
||||
, CodeAttributes attributes = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag_None
|
||||
, CodeType* interfaces = nullptr, s32 num_interfaces = 0 );
|
||||
struct Opts_def_struct {
|
||||
Code body;
|
||||
CodeType parent;
|
||||
AccessSpec parent_access;
|
||||
CodeAttributes attributes;
|
||||
ModuleFlag mflags;
|
||||
CodeType* interfaces;
|
||||
s32 num_interfaces;
|
||||
};
|
||||
CodeClass def_class( StrC name, Opts_def_struct otps GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeConstructor def_constructor( CodeParam params = NoCode, Code initializer_list = NoCode, Code body = NoCode );
|
||||
struct Opts_def_constructor {
|
||||
CodeParam params;
|
||||
Code initializer_list;
|
||||
Code body;
|
||||
};
|
||||
CodeConstructor def_constructor( Opts_def_constructor opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeDefine def_define( StrC name, StrC content );
|
||||
|
||||
CodeDestructor def_destructor( Code body = NoCode, CodeSpecifiers specifiers = NoCode );
|
||||
struct Opts_def_destructor {
|
||||
Code body;
|
||||
CodeSpecifiers specifiers;
|
||||
};
|
||||
CodeDestructor def_destructor( Opts_def_destructor opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeEnum def_enum( StrC name
|
||||
, Code body = NoCode, CodeType type = NoCode
|
||||
, EnumT specifier = EnumDecl_Regular, CodeAttributes attributes = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_enum {
|
||||
Code body;
|
||||
CodeType type;
|
||||
EnumT specifier;
|
||||
CodeAttributes attributes;
|
||||
ModuleFlag mflags;
|
||||
};
|
||||
CodeEnum def_enum( StrC name, Opts_def_enum opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeExec def_execution ( StrC content );
|
||||
CodeExtern def_extern_link( StrC name, Code body );
|
||||
CodeFriend def_friend ( Code symbol );
|
||||
|
||||
CodeFn def_function( StrC name
|
||||
, CodeParam params = NoCode, CodeType ret_type = NoCode, Code body = NoCode
|
||||
, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_function {
|
||||
CodeParam params;
|
||||
CodeType ret_type;
|
||||
Code body;
|
||||
CodeSpecifiers specs;
|
||||
CodeAttributes attrs;
|
||||
ModuleFlag mflags;
|
||||
};
|
||||
CodeFn def_function( StrC name, Opts_def_function opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeInclude def_include ( StrC content, bool foreign = false );
|
||||
CodeModule def_module ( StrC name, ModuleFlag mflags = ModuleFlag_None );
|
||||
CodeNS def_namespace( StrC name, Code body, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_include { b32 foreign; };
|
||||
struct Opts_def_module { ModuleFlag mflags; };
|
||||
struct Opts_def_namespace { ModuleFlag mflags; };
|
||||
CodeInclude def_include ( StrC content, Opts_def_include opts GEN_PARAM_DEFAULT );
|
||||
CodeModule def_module ( StrC name, Opts_def_module opts GEN_PARAM_DEFAULT );
|
||||
CodeNS def_namespace( StrC name, Code body, Opts_def_namespace opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeOperator def_operator( OperatorT op, StrC nspace
|
||||
, CodeParam params = NoCode, CodeType ret_type = NoCode, Code body = NoCode
|
||||
, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_operator {
|
||||
CodeParam params;
|
||||
CodeType ret_type;
|
||||
Code body;
|
||||
CodeSpecifiers specifiers;
|
||||
CodeAttributes attributes;
|
||||
ModuleFlag mflags;
|
||||
};
|
||||
CodeOperator def_operator( OperatorT op, StrC nspace, Opts_def_operator opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeOpCast def_operator_cast( CodeType type, Code body = NoCode, CodeSpecifiers specs = NoCode );
|
||||
struct Opts_def_operator_cast {
|
||||
Code body;
|
||||
CodeSpecifiers specs;
|
||||
};
|
||||
CodeOpCast def_operator_cast( CodeType type, Opts_def_operator_cast opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeParam def_param ( CodeType type, StrC name, Code value = NoCode );
|
||||
struct Opts_def_param { Code value; };
|
||||
CodeParam def_param ( CodeType type, StrC name, Opts_def_param opts GEN_PARAM_DEFAULT );
|
||||
CodePragma def_pragma( StrC directive );
|
||||
|
||||
CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content );
|
||||
|
||||
CodeSpecifiers def_specifier( SpecifierT specifier );
|
||||
|
||||
CodeStruct def_struct( StrC name
|
||||
, Code body = NoCode
|
||||
, CodeType parent = NoCode, AccessSpec access = AccessSpec_Default
|
||||
, CodeAttributes attributes = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag_None
|
||||
, CodeType* interfaces = nullptr, s32 num_interfaces = 0 );
|
||||
CodeStruct def_struct( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeTemplate def_template( CodeParam params, Code definition, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_template { ModuleFlag mflags; };
|
||||
CodeTemplate def_template( CodeParam params, Code definition, Opts_def_template opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeType def_type ( StrC name, Code arrayexpr = NoCode, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode );
|
||||
CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes = NoCode, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_type {
|
||||
Code arrayexpr;
|
||||
CodeSpecifiers specifiers;
|
||||
CodeAttributes attributes;
|
||||
};
|
||||
CodeType def_type( StrC name, Opts_def_type opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeUnion def_union( StrC name, Code body, CodeAttributes attributes = NoCode, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_typedef {
|
||||
CodeAttributes attributes;
|
||||
ModuleFlag mflags;
|
||||
};
|
||||
CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeUsing def_using( StrC name, CodeType type = NoCode
|
||||
, CodeAttributes attributess = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_union {
|
||||
CodeAttributes attributes;
|
||||
ModuleFlag mflags;
|
||||
};
|
||||
CodeUnion def_union( StrC name, Code body, Opts_def_union opts GEN_PARAM_DEFAULT );
|
||||
|
||||
struct Opts_def_using {
|
||||
CodeAttributes attributes;
|
||||
ModuleFlag mflags;
|
||||
};
|
||||
CodeUsing def_using( StrC name, Code type, Opts_def_using opts GEN_PARAM_DEFAULT );
|
||||
|
||||
CodeUsing def_using_namespace( StrC name );
|
||||
|
||||
CodeVar def_variable( CodeType type, StrC name, Code value = NoCode
|
||||
, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag_None );
|
||||
struct Opts_def_variable
|
||||
{
|
||||
Code value;
|
||||
CodeSpecifiers specifiers;
|
||||
CodeAttributes attributes;
|
||||
ModuleFlag mflags;
|
||||
};
|
||||
CodeVar def_variable( CodeType type, StrC name, Opts_def_variable opts GEN_PARAM_DEFAULT );
|
||||
|
||||
// Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries.
|
||||
CodeBody def_body( CodeT type );
|
||||
|
@ -39,9 +39,9 @@ CodeConstructor parse_constructor( StrC def )
|
||||
SpecifierT specs_found[ 16 ] { ESpecifier::NumSpecifiers };
|
||||
s32 NumSpecifiers = 0;
|
||||
|
||||
while ( left && currtok.is_specifier() )
|
||||
while ( left && is_specifier(currtok) )
|
||||
{
|
||||
SpecifierT spec = ESpecifier::to_type( currtok );
|
||||
SpecifierT spec = ESpecifier::to_type( to_str(currtok) );
|
||||
|
||||
b32 ignore_spec = false;
|
||||
|
||||
|
@ -36,14 +36,14 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
}
|
||||
|
||||
# define check_param_eq_ret() \
|
||||
if ( ! is_member_symbol && ! params_code->ValueType.is_equal( ret_type) ) \
|
||||
if ( ! is_member_symbol && ! is_equal(params_code->ValueType, ret_type) ) \
|
||||
{ \
|
||||
log_failure("gen::def_operator: operator%s requires first parameter to equal return type\n" \
|
||||
"param types: %s\n" \
|
||||
"return type: %s", \
|
||||
to_str(op).Ptr, \
|
||||
debug_str(params_code), \
|
||||
ret_type.debug_str() \
|
||||
debug_str(ret_type) \
|
||||
); \
|
||||
return OpValidateResult::Fail; \
|
||||
}
|
||||
@ -56,7 +56,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
|
||||
if ( ret_type->Type != ECode::Typename )
|
||||
{
|
||||
log_failure("gen::def_operator: ret_type is not of typename type - %s", ret_type.debug_str());
|
||||
log_failure("gen::def_operator: ret_type is not of typename type - %s", debug_str(ret_type));
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
switch ( params_code->NumEntries )
|
||||
{
|
||||
case 1:
|
||||
if ( params_code->ValueType.is_equal( t_int ) )
|
||||
if ( is_equal(params_code->ValueType, t_int ) )
|
||||
is_member_symbol = true;
|
||||
|
||||
else
|
||||
@ -170,14 +170,14 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
|
||||
if ( params_code->ValueType.is_equal( ret_type ) )
|
||||
if ( is_equal(params_code->ValueType, ret_type ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %s\n"
|
||||
"return type: %s\n"
|
||||
, debug_str(params_code)
|
||||
, ret_type.debug_str()
|
||||
, debug_str(ret_type)
|
||||
);
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
@ -247,14 +247,14 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( ! params_code->ValueType.is_equal( ret_type ) )
|
||||
if ( ! is_equal(params_code->ValueType, ret_type ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %s\n"
|
||||
"return type: %s\n"
|
||||
, debug_str(params_code)
|
||||
, ret_type.debug_str()
|
||||
, debug_str(ret_type)
|
||||
);
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
@ -291,11 +291,11 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! ret_type.is_equal( t_bool ))
|
||||
if ( ! is_equal(ret_type, t_bool ))
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s return type must be of type bool - %s"
|
||||
, to_str(op)
|
||||
, ret_type.debug_str()
|
||||
, debug_str(ret_type)
|
||||
);
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
@ -495,11 +495,13 @@ CodeComment def_comment( StrC content )
|
||||
return (CodeComment) result;
|
||||
}
|
||||
|
||||
CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code body )
|
||||
CodeConstructor def_constructor( Opts_def_constructor p )
|
||||
{
|
||||
using namespace ECode;
|
||||
CodeParam params = p.params;
|
||||
Code initializer_list = p.initializer_list;
|
||||
Code body = p.body;
|
||||
|
||||
if ( params && params->Type != Parameters )
|
||||
if ( params && params->Type != ECode::Parameters )
|
||||
{
|
||||
log_failure("gen::def_constructor: params must be of Parameters type - %s", debug_str(params));
|
||||
return InvalidCode;
|
||||
@ -522,8 +524,8 @@ CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code b
|
||||
{
|
||||
switch ( body->Type )
|
||||
{
|
||||
case Function_Body:
|
||||
case Untyped:
|
||||
case ECode::Function_Body:
|
||||
case ECode::Untyped:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -531,37 +533,38 @@ CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code b
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
result->Type = Constructor;
|
||||
result->Type = ECode::Constructor;
|
||||
result->Body = body;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Type = Constructor_Fwd;
|
||||
result->Type = ECode::Constructor_Fwd;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeClass def_class( StrC name
|
||||
, Code body
|
||||
, CodeType parent, AccessSpec parent_access
|
||||
, CodeAttributes attributes
|
||||
, ModuleFlag mflags
|
||||
, CodeType* interfaces, s32 num_interfaces )
|
||||
CodeClass def_class( StrC name, Opts_def_struct p )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
name_check( def_class, name );
|
||||
|
||||
Code body = p.body;
|
||||
CodeType parent = p.parent;
|
||||
AccessSpec parent_access = p.parent_access;
|
||||
CodeAttributes attributes = p.attributes;
|
||||
ModuleFlag mflags = p.mflags;
|
||||
CodeType* interfaces = p.interfaces;
|
||||
s32 num_interfaces = p.num_interfaces;
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( parent && ( parent->Type != Class && parent->Type != Struct && parent->Type != Typename && parent->Type != Untyped ) )
|
||||
if ( parent && ( parent->Type != ECode::Class && parent->Type != ECode::Struct && parent->Type != ECode::Typename && parent->Type != ECode::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", debug_str(parent) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -574,8 +577,8 @@ CodeClass def_class( StrC name
|
||||
{
|
||||
switch ( body->Type )
|
||||
{
|
||||
case Class_Body:
|
||||
case Untyped:
|
||||
case ECode::Class_Body:
|
||||
case ECode::Untyped:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -583,13 +586,13 @@ CodeClass def_class( StrC name
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
result->Type = Class;
|
||||
result->Type = ECode::Class;
|
||||
result->Body = body;
|
||||
result->Body->Parent = result; // TODO(Ed): Review this?
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Type = Class_Fwd;
|
||||
result->Type = ECode::Class_Fwd;
|
||||
}
|
||||
|
||||
if ( attributes )
|
||||
@ -614,8 +617,6 @@ CodeClass def_class( StrC name
|
||||
|
||||
CodeDefine def_define( StrC name, StrC content )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
name_check( def_define, name );
|
||||
|
||||
// Defines can be empty definitions
|
||||
@ -629,7 +630,7 @@ CodeDefine def_define( StrC name, StrC content )
|
||||
|
||||
CodeDefine
|
||||
result = (CodeDefine) make_code();
|
||||
result->Type = Preprocess_Define;
|
||||
result->Type = ECode::Preprocess_Define;
|
||||
result->Name = get_cached_string( name );
|
||||
if ( content.Len <= 0 || content.Ptr == nullptr )
|
||||
{
|
||||
@ -641,16 +642,17 @@ CodeDefine def_define( StrC name, StrC content )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers )
|
||||
CodeDestructor def_destructor( Opts_def_destructor p )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
if ( specifiers && specifiers->Type != Specifiers )
|
||||
Code body = p.body;
|
||||
CodeSpecifiers specifiers = p.specifiers;
|
||||
|
||||
if ( specifiers && specifiers->Type != ECode::Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_destructor: specifiers was not a 'Specifiers' type: %s", debug_str(specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
|
||||
CodeDestructor result = (CodeDestructor) make_code();
|
||||
|
||||
if ( specifiers )
|
||||
@ -660,8 +662,8 @@ CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers )
|
||||
{
|
||||
switch ( body->Type )
|
||||
{
|
||||
case Function_Body:
|
||||
case Untyped:
|
||||
case ECode::Function_Body:
|
||||
case ECode::Untyped:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -669,33 +671,34 @@ CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
result->Type = Destructor;
|
||||
result->Type = ECode::Destructor;
|
||||
result->Body = body;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Type = Destructor_Fwd;
|
||||
result->Type = ECode::Destructor_Fwd;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeEnum def_enum( StrC name
|
||||
, Code body, CodeType type
|
||||
, EnumT specifier, CodeAttributes attributes
|
||||
, ModuleFlag mflags )
|
||||
CodeEnum def_enum( StrC name, Opts_def_enum p )
|
||||
{
|
||||
using namespace ECode;
|
||||
Code body = p.body;
|
||||
CodeType type = p.type;
|
||||
EnumT specifier = p.specifier;
|
||||
CodeAttributes attributes = p.attributes;
|
||||
ModuleFlag mflags = p.mflags;
|
||||
|
||||
name_check( def_enum, name );
|
||||
|
||||
if ( type && type->Type != Typename )
|
||||
if ( type && type->Type != ECode::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", debug_str(type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
@ -710,8 +713,8 @@ CodeEnum def_enum( StrC name
|
||||
{
|
||||
switch ( body->Type )
|
||||
{
|
||||
case Enum_Body:
|
||||
case Untyped:
|
||||
case ECode::Enum_Body:
|
||||
case ECode::Untyped:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -720,14 +723,14 @@ CodeEnum def_enum( StrC name
|
||||
}
|
||||
|
||||
result->Type = specifier == EnumDecl_Class ?
|
||||
Enum_Class : Enum;
|
||||
ECode::Enum_Class : ECode::Enum;
|
||||
|
||||
result->Body = body;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Type = specifier == EnumDecl_Class ?
|
||||
Enum_Class_Fwd : Enum_Fwd;
|
||||
ECode::Enum_Class_Fwd : ECode::Enum_Fwd;
|
||||
}
|
||||
|
||||
if ( attributes )
|
||||
@ -737,7 +740,7 @@ CodeEnum def_enum( StrC name
|
||||
{
|
||||
result->UnderlyingType = type;
|
||||
}
|
||||
else if ( result->Type != Enum_Class_Fwd && result->Type != Enum_Fwd )
|
||||
else if ( result->Type != ECode::Enum_Class_Fwd && result->Type != ECode::Enum_Fwd )
|
||||
{
|
||||
log_failure( "gen::def_enum: enum forward declaration must have an underlying type" );
|
||||
return InvalidCode;
|
||||
@ -765,12 +768,10 @@ CodeExec def_execution( StrC content )
|
||||
|
||||
CodeExtern def_extern_link( StrC name, Code body )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
name_check( def_extern_linkage, name );
|
||||
null_check( def_extern_linkage, body );
|
||||
|
||||
if ( body->Type != Extern_Linkage_Body && body->Type != Untyped )
|
||||
if ( body->Type != ECode::Extern_Linkage_Body && body->Type != ECode::Untyped )
|
||||
{
|
||||
log_failure("gen::def_extern_linkage: body is not of extern_linkage or untyped type %s", debug_str(body));
|
||||
return InvalidCode;
|
||||
@ -778,7 +779,7 @@ CodeExtern def_extern_link( StrC name, Code body )
|
||||
|
||||
CodeExtern
|
||||
result = (CodeExtern)make_code();
|
||||
result->Type = Extern_Linkage;
|
||||
result->Type = ECode::Extern_Linkage;
|
||||
result->Name = get_cached_string( name );
|
||||
result->Body = body;
|
||||
|
||||
@ -787,20 +788,18 @@ CodeExtern def_extern_link( StrC name, Code body )
|
||||
|
||||
CodeFriend def_friend( Code declaration )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
null_check( def_friend, declaration );
|
||||
|
||||
switch ( declaration->Type )
|
||||
{
|
||||
case Class_Fwd:
|
||||
case Function_Fwd:
|
||||
case Operator_Fwd:
|
||||
case Struct_Fwd:
|
||||
case Class:
|
||||
case Function:
|
||||
case Operator:
|
||||
case Struct:
|
||||
case ECode::Class_Fwd:
|
||||
case ECode::Function_Fwd:
|
||||
case ECode::Operator_Fwd:
|
||||
case ECode::Struct_Fwd:
|
||||
case ECode::Class:
|
||||
case ECode::Function:
|
||||
case ECode::Operator:
|
||||
case ECode::Struct:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -810,41 +809,43 @@ CodeFriend def_friend( Code declaration )
|
||||
|
||||
CodeFriend
|
||||
result = (CodeFriend) make_code();
|
||||
result->Type = Friend;
|
||||
result->Type = ECode::Friend;
|
||||
|
||||
result->Declaration = declaration;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeFn def_function( StrC name
|
||||
, CodeParam params , CodeType ret_type, Code body
|
||||
, CodeSpecifiers specifiers, CodeAttributes attributes
|
||||
, ModuleFlag mflags )
|
||||
CodeFn def_function( StrC name, Opts_def_function p )
|
||||
{
|
||||
using namespace ECode;
|
||||
CodeParam params = p.params;
|
||||
CodeType ret_type = p.ret_type;
|
||||
Code body = p.body;
|
||||
CodeSpecifiers specifiers = p.specs;
|
||||
CodeAttributes attributes = p.attrs;
|
||||
ModuleFlag mflags = p.mflags;
|
||||
|
||||
name_check( def_function, name );
|
||||
|
||||
if ( params && params->Type != Parameters )
|
||||
if ( params && params->Type != ECode::Parameters )
|
||||
{
|
||||
log_failure( "gen::def_function: params was not a `Parameters` type: %s", debug_str(params) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( ret_type && ret_type->Type != Typename )
|
||||
if ( ret_type && ret_type->Type != ECode::Typename )
|
||||
{
|
||||
log_failure( "gen::def_function: ret_type was not a Typename: %s", debug_str(ret_type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( specifiers && specifiers->Type != Specifiers )
|
||||
if ( specifiers && specifiers->Type != ECode::Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_function: specifiers was not a `Specifiers` type: %s", debug_str(specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
@ -859,9 +860,9 @@ CodeFn def_function( StrC name
|
||||
{
|
||||
switch ( body->Type )
|
||||
{
|
||||
case Function_Body:
|
||||
case Execution:
|
||||
case Untyped:
|
||||
case ECode::Function_Body:
|
||||
case ECode::Execution:
|
||||
case ECode::Untyped:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -871,12 +872,12 @@ CodeFn def_function( StrC name
|
||||
}
|
||||
}
|
||||
|
||||
result->Type = Function;
|
||||
result->Type = ECode::Function;
|
||||
result->Body = body;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Type = Function_Fwd;
|
||||
result->Type = ECode::Function_Fwd;
|
||||
}
|
||||
|
||||
if ( attributes )
|
||||
@ -900,7 +901,7 @@ CodeFn def_function( StrC name
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeInclude def_include( StrC path, bool foreign )
|
||||
CodeInclude def_include( StrC path, Opts_def_include p )
|
||||
{
|
||||
if ( path.Len <= 0 || path.Ptr == nullptr )
|
||||
{
|
||||
@ -908,7 +909,7 @@ CodeInclude def_include( StrC path, bool foreign )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
StrC content = foreign ?
|
||||
StrC content = p.foreign ?
|
||||
to_str( str_fmt_buf( "<%.*s>", path.Len, path.Ptr ))
|
||||
: to_str( str_fmt_buf( "\"%.*s\"", path.Len, path.Ptr ));
|
||||
|
||||
@ -921,7 +922,7 @@ CodeInclude def_include( StrC path, bool foreign )
|
||||
return (CodeInclude) result;
|
||||
}
|
||||
|
||||
CodeModule def_module( StrC name, ModuleFlag mflags )
|
||||
CodeModule def_module( StrC name, Opts_def_module p )
|
||||
{
|
||||
name_check( def_module, name );
|
||||
|
||||
@ -930,19 +931,17 @@ CodeModule def_module( StrC name, ModuleFlag mflags )
|
||||
result->Type = ECode::Module;
|
||||
result->Name = get_cached_string( name );
|
||||
result->Content = result->Name;
|
||||
result->ModuleFlags = mflags;
|
||||
result->ModuleFlags = p.mflags;
|
||||
|
||||
return (CodeModule) result;
|
||||
}
|
||||
|
||||
CodeNS def_namespace( StrC name, Code body, ModuleFlag mflags )
|
||||
CodeNS def_namespace( StrC name, Code body, Opts_def_namespace p )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
name_check( def_namespace, name );
|
||||
null_check( def_namespace, body );
|
||||
|
||||
if ( body->Type != Namespace_Body && body->Type != Untyped )
|
||||
null_check( def_namespace, body);
|
||||
|
||||
if ( body && body->Type != ECode::Namespace_Body && body->Type != ECode::Untyped )
|
||||
{
|
||||
log_failure("gen::def_namespace: body is not of namespace or untyped type %s", debug_str(body));
|
||||
return InvalidCode;
|
||||
@ -950,28 +949,29 @@ CodeNS def_namespace( StrC name, Code body, ModuleFlag mflags )
|
||||
|
||||
CodeNS
|
||||
result = (CodeNS) make_code();
|
||||
result->Type = Namespace;
|
||||
result->Type = ECode::Namespace;
|
||||
result->Name = get_cached_string( name );
|
||||
result->ModuleFlags = mflags;
|
||||
result->ModuleFlags = p.mflags;
|
||||
result->Body = body;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeOperator def_operator( OperatorT op, StrC nspace
|
||||
, CodeParam params_code, CodeType ret_type, Code body
|
||||
, CodeSpecifiers specifiers, CodeAttributes attributes
|
||||
, ModuleFlag mflags )
|
||||
CodeOperator def_operator( OperatorT op, StrC nspace, Opts_def_operator p )
|
||||
{
|
||||
using namespace ECode;
|
||||
CodeParam params_code = p.params;
|
||||
CodeType ret_type = p.ret_type;
|
||||
Code body = p.body;
|
||||
CodeSpecifiers specifiers = p.specifiers;
|
||||
CodeAttributes attributes = p.attributes;
|
||||
ModuleFlag mflags = p.mflags;
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( specifiers && specifiers->Type != Specifiers )
|
||||
if ( specifiers && specifiers->Type != ECode::Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_operator: Specifiers was provided but its not of specifiers type: %s", debug_str(specifiers) );
|
||||
return InvalidCode;
|
||||
@ -1001,9 +1001,9 @@ CodeOperator def_operator( OperatorT op, StrC nspace
|
||||
{
|
||||
switch ( body->Type )
|
||||
{
|
||||
case Function_Body:
|
||||
case Execution:
|
||||
case Untyped:
|
||||
case ECode::Function_Body:
|
||||
case ECode::Execution:
|
||||
case ECode::Untyped:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1014,14 +1014,14 @@ CodeOperator def_operator( OperatorT op, StrC nspace
|
||||
}
|
||||
|
||||
result->Type = check_result == OpValidateResult::Global ?
|
||||
Operator : Operator_Member;
|
||||
ECode::Operator : ECode::Operator_Member;
|
||||
|
||||
result->Body = body;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Type = check_result == OpValidateResult::Global ?
|
||||
Operator_Fwd : Operator_Member_Fwd;
|
||||
ECode::Operator_Fwd : ECode::Operator_Member_Fwd;
|
||||
}
|
||||
|
||||
if ( attributes )
|
||||
@ -1038,14 +1038,16 @@ CodeOperator def_operator( OperatorT op, StrC nspace
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeOpCast def_operator_cast( CodeType type, Code body, CodeSpecifiers const_spec )
|
||||
CodeOpCast def_operator_cast( CodeType type, Opts_def_operator_cast p )
|
||||
{
|
||||
using namespace ECode;
|
||||
Code body = p.body;
|
||||
CodeSpecifiers const_spec = p.specs;
|
||||
|
||||
null_check( def_operator_cast, type );
|
||||
|
||||
if ( type->Type != Typename )
|
||||
if ( type->Type != ECode::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", debug_str(type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1053,9 +1055,9 @@ CodeOpCast def_operator_cast( CodeType type, Code body, CodeSpecifiers const_spe
|
||||
|
||||
if (body)
|
||||
{
|
||||
result->Type = Operator_Cast;
|
||||
result->Type = ECode::Operator_Cast;
|
||||
|
||||
if ( body->Type != Function_Body && body->Type != Execution )
|
||||
if ( body->Type != ECode::Function_Body && body->Type != ECode::Execution )
|
||||
{
|
||||
log_failure( "gen::def_operator_cast: body is not of function body or execution type - %s", debug_str(body) );
|
||||
return InvalidCode;
|
||||
@ -1065,7 +1067,7 @@ CodeOpCast def_operator_cast( CodeType type, Code body, CodeSpecifiers const_spe
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Type = Operator_Cast_Fwd;
|
||||
result->Type = ECode::Operator_Cast_Fwd;
|
||||
}
|
||||
|
||||
if ( const_spec )
|
||||
@ -1077,34 +1079,32 @@ CodeOpCast def_operator_cast( CodeType type, Code body, CodeSpecifiers const_spe
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeParam def_param( CodeType type, StrC name, Code value )
|
||||
CodeParam def_param( CodeType type, StrC name, Opts_def_param p )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
name_check( def_param, name );
|
||||
null_check( def_param, type );
|
||||
|
||||
if ( type->Type != Typename )
|
||||
if ( type->Type != ECode::Typename )
|
||||
{
|
||||
log_failure( "gen::def_param: type is not a typename - %s", debug_str(type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( value && value->Type != Untyped )
|
||||
if ( p.value && p.value->Type != ECode::Untyped )
|
||||
{
|
||||
log_failure( "gen::def_param: value is not untyped - %s", debug_str(value) );
|
||||
log_failure( "gen::def_param: value is not untyped - %s", debug_str(p.value) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
CodeParam
|
||||
result = (CodeParam) make_code();
|
||||
result->Type = Parameters;
|
||||
result->Type = ECode::Parameters;
|
||||
result->Name = get_cached_string( name );
|
||||
|
||||
result->ValueType = type;
|
||||
|
||||
if ( value )
|
||||
result->Value = value;
|
||||
if ( p.value )
|
||||
result->Value = p.value;
|
||||
|
||||
result->NumEntries++;
|
||||
|
||||
@ -1113,8 +1113,6 @@ CodeParam def_param( CodeType type, StrC name, Code value )
|
||||
|
||||
CodePragma def_pragma( StrC directive )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
if ( directive.Len <= 0 || directive.Ptr == nullptr )
|
||||
{
|
||||
log_failure( "gen::def_comment: Invalid comment provided:" );
|
||||
@ -1123,7 +1121,7 @@ CodePragma def_pragma( StrC directive )
|
||||
|
||||
CodePragma
|
||||
result = (CodePragma) make_code();
|
||||
result->Type = Preprocess_Pragma;
|
||||
result->Type = ECode::Preprocess_Pragma;
|
||||
result->Content = get_cached_string( directive );
|
||||
|
||||
return result;
|
||||
@ -1131,8 +1129,6 @@ CodePragma def_pragma( StrC directive )
|
||||
|
||||
CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC expr )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
if ( expr.Len <= 0 || expr.Ptr == nullptr )
|
||||
{
|
||||
log_failure( "gen::def_comment: Invalid comment provided:" );
|
||||
@ -1146,16 +1142,16 @@ CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC expr )
|
||||
switch (type)
|
||||
{
|
||||
case PreprocessCond_If:
|
||||
result->Type = Preprocess_If;
|
||||
result->Type = ECode::Preprocess_If;
|
||||
break;
|
||||
case PreprocessCond_IfDef:
|
||||
result->Type = Preprocess_IfDef;
|
||||
result->Type = ECode::Preprocess_IfDef;
|
||||
break;
|
||||
case PreprocessCond_IfNotDef:
|
||||
result->Type = Preprocess_IfNotDef;
|
||||
result->Type = ECode::Preprocess_IfNotDef;
|
||||
break;
|
||||
case PreprocessCond_ElIf:
|
||||
result->Type = Preprocess_ElIf;
|
||||
result->Type = ECode::Preprocess_ElIf;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1172,28 +1168,29 @@ CodeSpecifiers def_specifier( SpecifierT spec )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeStruct def_struct( StrC name
|
||||
, Code body
|
||||
, CodeType parent, AccessSpec parent_access
|
||||
, CodeAttributes attributes
|
||||
, ModuleFlag mflags
|
||||
, CodeType* interfaces, s32 num_interfaces )
|
||||
CodeStruct def_struct( StrC name, Opts_def_struct p )
|
||||
{
|
||||
using namespace ECode;
|
||||
Code body = p.body;
|
||||
CodeType parent = p.parent;
|
||||
AccessSpec parent_access = p.parent_access;
|
||||
CodeAttributes attributes = p.attributes;
|
||||
ModuleFlag mflags = p.mflags;
|
||||
CodeType* interfaces = p.interfaces;
|
||||
s32 num_interfaces = p.num_interfaces;
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( parent && parent->Type != Typename )
|
||||
if ( parent && parent->Type != ECode::Typename )
|
||||
{
|
||||
log_failure( "gen::def_struct: parent was not a `Struct` type - %s", debug_str(parent) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( body && body->Type != Struct_Body )
|
||||
if ( body && body->Type != ECode::Struct_Body )
|
||||
{
|
||||
log_failure( "gen::def_struct: body was not a Struct_Body type - %s", debug_str(body) );
|
||||
return InvalidCode;
|
||||
@ -1208,12 +1205,12 @@ CodeStruct def_struct( StrC name
|
||||
|
||||
if ( body )
|
||||
{
|
||||
result->Type = Struct;
|
||||
result->Type = ECode::Struct;
|
||||
result->Body = body;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Type = Struct_Fwd;
|
||||
result->Type = ECode::Struct_Fwd;
|
||||
}
|
||||
|
||||
if ( attributes )
|
||||
@ -1236,7 +1233,7 @@ CodeStruct def_struct( StrC name
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeTemplate def_template( CodeParam params, Code declaration, ModuleFlag mflags )
|
||||
CodeTemplate def_template( CodeParam params, Code declaration, Opts_def_template p )
|
||||
{
|
||||
null_check( def_template, declaration );
|
||||
|
||||
@ -1262,16 +1259,19 @@ CodeTemplate def_template( CodeParam params, Code declaration, ModuleFlag mflags
|
||||
CodeTemplate
|
||||
result = (CodeTemplate) make_code();
|
||||
result->Type = ECode::Template;
|
||||
result->ModuleFlags = mflags;
|
||||
result->ModuleFlags = p.mflags;
|
||||
result->Params = params;
|
||||
result->Declaration = declaration;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeType def_type( StrC name, Code arrayexpr, CodeSpecifiers specifiers, CodeAttributes attributes )
|
||||
CodeType def_type( StrC name, Opts_def_type p )
|
||||
{
|
||||
name_check( def_type, name );
|
||||
|
||||
Code arrayexpr = p.arrayexpr;
|
||||
CodeSpecifiers specifiers = p.specifiers;
|
||||
CodeAttributes attributes = p.attributes;
|
||||
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
@ -1308,34 +1308,32 @@ CodeType def_type( StrC name, Code arrayexpr, CodeSpecifiers specifiers, CodeAtt
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, ModuleFlag mflags )
|
||||
CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef p )
|
||||
{
|
||||
using namespace ECode;
|
||||
|
||||
null_check( def_typedef, type );
|
||||
|
||||
switch ( type->Type )
|
||||
{
|
||||
case Class:
|
||||
case Class_Fwd:
|
||||
case Enum:
|
||||
case Enum_Fwd:
|
||||
case Enum_Class:
|
||||
case Enum_Class_Fwd:
|
||||
case Function_Fwd:
|
||||
case Struct:
|
||||
case Struct_Fwd:
|
||||
case Union:
|
||||
case Typename:
|
||||
case ECode::Class:
|
||||
case ECode::Class_Fwd:
|
||||
case ECode::Enum:
|
||||
case ECode::Enum_Fwd:
|
||||
case ECode::Enum_Class:
|
||||
case ECode::Enum_Class_Fwd:
|
||||
case ECode::Function_Fwd:
|
||||
case ECode::Struct:
|
||||
case ECode::Struct_Fwd:
|
||||
case ECode::Union:
|
||||
case ECode::Typename:
|
||||
break;
|
||||
default:
|
||||
log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", debug_str(type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
if ( p.attributes && p.attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", debug_str(attributes) );
|
||||
log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", debug_str(p.attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1351,13 +1349,13 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module
|
||||
CodeTypedef
|
||||
result = (CodeTypedef) make_code();
|
||||
result->Type = ECode::Typedef;
|
||||
result->ModuleFlags = mflags;
|
||||
result->ModuleFlags = p.mflags;
|
||||
|
||||
result->UnderlyingType = type;
|
||||
|
||||
if ( name.Len <= 0 )
|
||||
{
|
||||
if (type->Type != Untyped)
|
||||
if (type->Type != ECode::Untyped)
|
||||
{
|
||||
log_failure( "gen::def_typedef: name was empty and type was not untyped (indicating its a function typedef) - %s", debug_str(type) );
|
||||
return InvalidCode;
|
||||
@ -1375,7 +1373,7 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeUnion def_union( StrC name, Code body, CodeAttributes attributes, ModuleFlag mflags )
|
||||
CodeUnion def_union( StrC name, Code body, Opts_def_union p )
|
||||
{
|
||||
null_check( def_union, body );
|
||||
|
||||
@ -1385,15 +1383,15 @@ CodeUnion def_union( StrC name, Code body, CodeAttributes attributes, ModuleFlag
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
if ( p.attributes && p.attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", debug_str(attributes) );
|
||||
log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", debug_str(p.attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
CodeUnion
|
||||
result = (CodeUnion) make_code();
|
||||
result->ModuleFlags = mflags;
|
||||
result->ModuleFlags = p.mflags;
|
||||
result->Type = ECode::Union;
|
||||
|
||||
if ( name.Ptr )
|
||||
@ -1401,15 +1399,13 @@ CodeUnion def_union( StrC name, Code body, CodeAttributes attributes, ModuleFlag
|
||||
|
||||
result->Body = body;
|
||||
|
||||
if ( attributes )
|
||||
result->Attributes = attributes;
|
||||
if ( p.attributes )
|
||||
result->Attributes = p.attributes;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeUsing def_using( StrC name, CodeType type
|
||||
, CodeAttributes attributes
|
||||
, ModuleFlag mflags )
|
||||
CodeUsing def_using( StrC name, Code type, Opts_def_using p )
|
||||
{
|
||||
name_check( def_using, name );
|
||||
null_check( def_using, type );
|
||||
@ -1422,22 +1418,22 @@ CodeUsing def_using( StrC name, CodeType type
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
if ( p.attributes && p.attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", debug_str(attributes) );
|
||||
log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", debug_str(p.attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
CodeUsing
|
||||
result = (CodeUsing) make_code();
|
||||
result->Name = get_cached_string( name );
|
||||
result->ModuleFlags = mflags;
|
||||
result->Type = ECode::Using;
|
||||
result->ModuleFlags = p.mflags;
|
||||
result->Type = ECode::Using;
|
||||
|
||||
result->UnderlyingType = type;
|
||||
|
||||
if ( attributes )
|
||||
result->Attributes = attributes;
|
||||
if ( p.attributes )
|
||||
result->Attributes = p.attributes;
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1455,28 +1451,26 @@ CodeUsing def_using_namespace( StrC name )
|
||||
return (CodeUsing) result;
|
||||
}
|
||||
|
||||
CodeVar def_variable( CodeType type, StrC name, Code value
|
||||
, CodeSpecifiers specifiers, CodeAttributes attributes
|
||||
, ModuleFlag mflags )
|
||||
CodeVar def_variable( CodeType type, StrC name, Code value, Opts_def_variable p )
|
||||
{
|
||||
name_check( def_variable, name );
|
||||
null_check( def_variable, type );
|
||||
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
if ( p.attributes && p.attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", debug_str(attributes) );
|
||||
log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", debug_str(p.attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( specifiers && specifiers->Type != ECode::Specifiers )
|
||||
if ( p.specifiers && p.specifiers->Type != ECode::Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_variable: specifiers was not a `Specifiers` type - %s", debug_str(specifiers) );
|
||||
log_failure( "gen::def_variable: specifiers was not a `Specifiers` type - %s", debug_str(p.specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
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", debug_str(type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1490,15 +1484,15 @@ CodeVar def_variable( CodeType type, StrC name, Code value
|
||||
result = (CodeVar) make_code();
|
||||
result->Name = get_cached_string( name );
|
||||
result->Type = ECode::Variable;
|
||||
result->ModuleFlags = mflags;
|
||||
result->ModuleFlags = p.mflags;
|
||||
|
||||
result->ValueType = type;
|
||||
|
||||
if ( attributes )
|
||||
result->Attributes = attributes;
|
||||
if ( p.attributes )
|
||||
result->Attributes = p.attributes;
|
||||
|
||||
if ( specifiers )
|
||||
result->Specs = specifiers;
|
||||
if ( p.specifiers )
|
||||
result->Specs = p.specifiers;
|
||||
|
||||
if ( value )
|
||||
result->Value = value;
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "gen/etoktype.cpp"
|
||||
#endif
|
||||
|
||||
namespace parser {
|
||||
GEN_NS_PARSER_BEGIN
|
||||
|
||||
enum TokFlags : u32
|
||||
{
|
||||
@ -31,137 +31,132 @@ struct Token
|
||||
s32 Line;
|
||||
s32 Column;
|
||||
u32 Flags;
|
||||
|
||||
operator bool()
|
||||
{
|
||||
return Text && Length && Type != TokType::Invalid;
|
||||
}
|
||||
|
||||
operator StrC()
|
||||
{
|
||||
return { Length, Text };
|
||||
}
|
||||
|
||||
bool is_access_operator()
|
||||
{
|
||||
return bitfield_is_equal( u32, Flags, TF_AccessOperator );
|
||||
}
|
||||
|
||||
bool is_access_specifier()
|
||||
{
|
||||
return bitfield_is_equal( u32, Flags, TF_AccessSpecifier );
|
||||
}
|
||||
|
||||
bool is_attribute()
|
||||
{
|
||||
return bitfield_is_equal( u32, Flags, TF_Attribute );
|
||||
}
|
||||
|
||||
bool is_operator()
|
||||
{
|
||||
return bitfield_is_equal( u32, Flags, TF_Operator );
|
||||
}
|
||||
|
||||
bool is_preprocessor()
|
||||
{
|
||||
return bitfield_is_equal( u32, Flags, TF_Preprocess );
|
||||
}
|
||||
|
||||
bool is_preprocess_cond()
|
||||
{
|
||||
return bitfield_is_equal( u32, Flags, TF_Preprocess_Cond );
|
||||
}
|
||||
|
||||
bool is_specifier()
|
||||
{
|
||||
return bitfield_is_equal( u32, Flags, TF_Specifier );
|
||||
}
|
||||
|
||||
bool is_end_definition()
|
||||
{
|
||||
return bitfield_is_equal( u32, Flags, TF_EndDefinition );
|
||||
}
|
||||
|
||||
AccessSpec to_access_specifier()
|
||||
{
|
||||
return scast(AccessSpec, Type);
|
||||
}
|
||||
|
||||
String to_string()
|
||||
{
|
||||
String result = string_make_reserve( GlobalAllocator, kilobytes(4) );
|
||||
|
||||
StrC type_str = ETokType::to_str( Type );
|
||||
|
||||
append_fmt( & result, "Line: %d Column: %d, Type: %.*s Content: %.*s"
|
||||
, Line, Column
|
||||
, type_str.Len, type_str.Ptr
|
||||
, Length, Text
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr Token NullToken { nullptr, 0, TokType::Invalid, false, 0, TF_Null };
|
||||
|
||||
AccessSpec to_access_specifier(Token tok)
|
||||
{
|
||||
return scast(AccessSpec, tok.Type);
|
||||
}
|
||||
|
||||
StrC to_str(Token tok)
|
||||
{
|
||||
return { tok.Length, tok.Text };
|
||||
}
|
||||
|
||||
bool is_valid( Token tok )
|
||||
{
|
||||
return tok.Text && tok.Length && tok.Type != TokType::Invalid;
|
||||
}
|
||||
|
||||
bool is_access_operator(Token tok)
|
||||
{
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_AccessOperator );
|
||||
}
|
||||
|
||||
bool is_access_specifier(Token tok)
|
||||
{
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_AccessSpecifier );
|
||||
}
|
||||
|
||||
bool is_attribute(Token tok)
|
||||
{
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Attribute );
|
||||
}
|
||||
|
||||
bool is_operator(Token tok)
|
||||
{
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Operator );
|
||||
}
|
||||
|
||||
bool is_preprocessor(Token tok)
|
||||
{
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Preprocess );
|
||||
}
|
||||
|
||||
bool is_preprocess_cond(Token tok)
|
||||
{
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Preprocess_Cond );
|
||||
}
|
||||
|
||||
bool is_specifier(Token tok)
|
||||
{
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Specifier );
|
||||
}
|
||||
|
||||
bool is_end_definition(Token tok)
|
||||
{
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_EndDefinition );
|
||||
}
|
||||
|
||||
String to_string(Token tok)
|
||||
{
|
||||
String result = string_make_reserve( GlobalAllocator, kilobytes(4) );
|
||||
|
||||
StrC type_str = ETokType::to_str( tok.Type );
|
||||
|
||||
append_fmt( & result, "Line: %d Column: %d, Type: %.*s Content: %.*s"
|
||||
, tok.Line, tok.Column
|
||||
, type_str.Len, type_str.Ptr
|
||||
, tok.Length, tok.Text
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
struct TokArray
|
||||
{
|
||||
Array<Token> Arr;
|
||||
Array(Token) Arr;
|
||||
s32 Idx;
|
||||
|
||||
bool __eat( TokType type );
|
||||
|
||||
Token& current( bool skip_formatting = true )
|
||||
{
|
||||
if ( skip_formatting )
|
||||
{
|
||||
while ( Arr[Idx].Type == TokType::NewLine || Arr[Idx].Type == TokType::Comment )
|
||||
Idx++;
|
||||
}
|
||||
|
||||
return Arr[Idx];
|
||||
}
|
||||
|
||||
Token& previous( bool skip_formatting = false )
|
||||
{
|
||||
s32 idx = this->Idx;
|
||||
|
||||
if ( skip_formatting )
|
||||
{
|
||||
while ( Arr[idx].Type == TokType::NewLine )
|
||||
idx--;
|
||||
|
||||
return Arr[idx];
|
||||
}
|
||||
|
||||
return Arr[idx - 1];
|
||||
}
|
||||
|
||||
Token& next( bool skip_formatting = false )
|
||||
{
|
||||
s32 idx = this->Idx;
|
||||
|
||||
if ( skip_formatting )
|
||||
{
|
||||
while ( Arr[idx].Type == TokType::NewLine )
|
||||
idx++;
|
||||
|
||||
return Arr[idx + 1];
|
||||
}
|
||||
|
||||
return Arr[idx + 1];
|
||||
}
|
||||
|
||||
Token& operator []( s32 idx )
|
||||
{
|
||||
return Arr[idx];
|
||||
}
|
||||
};
|
||||
|
||||
bool __eat( TokType type );
|
||||
|
||||
Token* current(TokArray* self, bool skip_formatting )
|
||||
{
|
||||
if ( skip_formatting )
|
||||
{
|
||||
while ( self->Arr[self->Idx].Type == TokType::NewLine || self->Arr[self->Idx].Type == TokType::Comment )
|
||||
self->Idx++;
|
||||
}
|
||||
|
||||
return & self->Arr[self->Idx];
|
||||
}
|
||||
|
||||
Token* previous(TokArray self, bool skip_formatting)
|
||||
{
|
||||
s32 idx = self.Idx;
|
||||
|
||||
if ( skip_formatting )
|
||||
{
|
||||
while ( self.Arr[idx].Type == TokType::NewLine )
|
||||
idx --;
|
||||
|
||||
return & self.Arr[idx];
|
||||
}
|
||||
|
||||
return & self.Arr[idx - 1];
|
||||
}
|
||||
|
||||
Token* next(TokArray self, bool skip_formatting)
|
||||
{
|
||||
s32 idx = self.Idx;
|
||||
|
||||
if ( skip_formatting )
|
||||
{
|
||||
while ( self.Arr[idx].Type == TokType::NewLine )
|
||||
idx++;
|
||||
|
||||
return & self.Arr[idx + 1];
|
||||
}
|
||||
|
||||
return & self.Arr[idx + 1];
|
||||
}
|
||||
|
||||
global Arena_256KB defines_map_arena;
|
||||
global HashTable<StrC> defines;
|
||||
global Array<Token> Tokens;
|
||||
global HashTable(StrC) defines;
|
||||
global Array(Token) Tokens;
|
||||
|
||||
#define current ( * scanner )
|
||||
|
||||
@ -234,7 +229,7 @@ s32 lex_preprocessor_directive(
|
||||
token.Length++;
|
||||
}
|
||||
|
||||
token.Type = ETokType::to_type( token );
|
||||
token.Type = ETokType::to_type( to_str(token) );
|
||||
|
||||
bool is_preprocessor = token.Type >= TokType::Preprocess_Define && token.Type <= TokType::Preprocess_Pragma;
|
||||
if ( ! is_preprocessor )
|
||||
@ -341,7 +336,7 @@ s32 lex_preprocessor_directive(
|
||||
append( & Tokens, name );
|
||||
|
||||
u64 key = crc32( name.Text, name.Length );
|
||||
set<StrC>(& defines, key, name );
|
||||
set(& defines, key, to_str(name) );
|
||||
}
|
||||
|
||||
Token preprocess_content = { scanner, 0, TokType::Preprocess_Content, line, column, TF_Preprocess };
|
||||
@ -465,7 +460,7 @@ void lex_found_token( StrC& content
|
||||
return;
|
||||
}
|
||||
|
||||
TokType type = ETokType::to_type( token );
|
||||
TokType type = ETokType::to_type( to_str(token) );
|
||||
|
||||
if (type <= TokType::Access_Public && type >= TokType::Access_Private )
|
||||
{
|
||||
@ -1267,5 +1262,4 @@ TokArray lex( StrC content )
|
||||
#undef move_forward
|
||||
#undef SkipWhitespace
|
||||
|
||||
// namespace parser
|
||||
}
|
||||
GEN_NS_PARSER_END
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -385,6 +385,8 @@ bool set_capacity(Array<Type>* array, usize new_capacity)
|
||||
// TODO(Ed) : This thing needs ALOT of work.
|
||||
|
||||
#pragma region HashTable
|
||||
#define HashTable(Type) HashTable<Type>
|
||||
|
||||
template<class Type> struct HashTable;
|
||||
|
||||
struct HashTableFindResult {
|
||||
|
@ -234,4 +234,10 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ! defined(GEN_PARAM_DEFAULT) && ! GEN_COMPILER_C
|
||||
# define GEN_PARAM_DEFAULT = {}
|
||||
#else
|
||||
# define GEN_PARAM_DEFAULT
|
||||
#endif
|
||||
|
||||
#pragma endregion Macros
|
||||
|
@ -133,12 +133,16 @@
|
||||
|
||||
#if GEN_DONT_USE_NAMESPACE || GEN_COMPILER_C
|
||||
# if GEN_COMPILER_C
|
||||
# define GEN_NS_PARSER_BEGIN
|
||||
# define GEN_NS_PARSER_END
|
||||
# define GEN_NS_ENUM_BEGIN
|
||||
# define GEN_NS_ENUM_END
|
||||
# define GEN_NS
|
||||
# define GEN_NS_BEGIN
|
||||
# define GEN_NS_END
|
||||
# else
|
||||
# define GEN_NS_PARSER_BEGIN namespace parser {
|
||||
# define GEN_NS_PARSER_END }
|
||||
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
|
||||
# define GEN_NS_ENUM_END }
|
||||
# define GEN_NS ::
|
||||
@ -146,6 +150,8 @@
|
||||
# define GEN_NS_END
|
||||
# endif
|
||||
#else
|
||||
# define GEN_NS_PARSER_BEGIN namespace parser {
|
||||
# define GEN_NS_PARSER_END }
|
||||
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
|
||||
# define GEN_NS_ENUM_END }
|
||||
# define GEN_NS gen::
|
||||
|
@ -358,12 +358,12 @@ CodeBody gen_ast_inlines()
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
{
|
||||
ast = rcast( decltype(ast), GEN_NS duplicate(other.ast) );
|
||||
rcast( AST*, ast)->Parent = nullptr;
|
||||
ast = rcast( decltype(ast), GEN_NS duplicate(other).ast);
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
|
||||
ast = rcast( decltype(ast), other.ast );
|
||||
return *this;
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return * this;
|
||||
}
|
||||
inline
|
||||
<typename>::operator bool()
|
||||
@ -448,10 +448,6 @@ CodeBody gen_ast_inlines()
|
||||
append(impl_code_var, parse_global_body( token_fmt( "typename", StrC name(Var), codetype_impl_tmpl )));
|
||||
|
||||
char const* cast_tmpl = stringize(
|
||||
inline AST::operator Code<typename>()
|
||||
{
|
||||
return { rcast( AST_<typename>*, this ) };
|
||||
}
|
||||
inline Code::operator Code<typename>() const
|
||||
{
|
||||
return { (AST_<typename>*) ast };
|
||||
|
@ -253,7 +253,7 @@
|
||||
|
||||
// word log_failure, new_name
|
||||
|
||||
// word NoCode, new_name
|
||||
// word NullCode, new_name
|
||||
// word CodeInvalid, new_name
|
||||
|
||||
// ------------ gencpp common
|
||||
|
@ -50,7 +50,7 @@ u32 gen_sanity_upfront()
|
||||
|
||||
// Enum
|
||||
{
|
||||
CodeEnum fwd = def_enum( name(ETestEnum), NoCode, t_u8 );
|
||||
CodeEnum fwd = def_enum( name(ETestEnum), NullCode, t_u8 );
|
||||
CodeEnum def;
|
||||
{
|
||||
Code body = untyped_str( code(
|
||||
@ -62,7 +62,7 @@ u32 gen_sanity_upfront()
|
||||
def = def_enum( name(ETestEnum), body, t_u8 );
|
||||
}
|
||||
|
||||
CodeEnum fwd_enum_class = def_enum( name(ETestEnumClass), NoCode, t_u8, EnumClass );
|
||||
CodeEnum fwd_enum_class = def_enum( name(ETestEnumClass), NullCode, t_u8, EnumClass );
|
||||
|
||||
gen_sanity_file.print(fwd);
|
||||
gen_sanity_file.print(def);
|
||||
|
Loading…
Reference in New Issue
Block a user