remove raw member def from code types, reduction on CodeAttributes

This commit is contained in:
Edward R. Gonzalez 2024-12-02 11:20:31 -05:00
parent ea18792373
commit 0bad61fda6
7 changed files with 72 additions and 209 deletions

View File

@ -545,11 +545,11 @@ void to_string( AST* self, String* result )
break; break;
case Struct: case Struct:
cast(CodeStruct, {self}).to_string_def( * result ); to_string_def(cast(CodeStruct, {self}), result );
break; break;
case Struct_Fwd: case Struct_Fwd:
cast(CodeStruct, {self}).to_string_fwd( * result ); to_string_fwd(cast(CodeStruct, {self}), result );
break; break;
case Template: case Template:

View File

@ -13,9 +13,8 @@ String to_string(Code self)
return to_string( self.ast ); return to_string( self.ast );
} }
String CodeAttributes::to_string() String to_string(CodeAttributes attributes) {
{ return GEN_NS duplicate( attributes->Content, GlobalAllocator );
return GEN_NS duplicate( ast->Content, GlobalAllocator );
} }
String to_string(CodeBody body) String to_string(CodeBody body)
@ -175,7 +174,7 @@ void to_string_def( CodeClass self, String* result )
if ( ast->Attributes ) if ( ast->Attributes )
{ {
append_fmt( result, "%S ", ast->Attributes.to_string() ); append_fmt( result, "%S ", GEN_NS to_string(ast->Attributes) );
} }
if ( ast->ParentType ) if ( ast->ParentType )
@ -219,7 +218,7 @@ void to_string_fwd( CodeClass self, String* result )
append( result, "export " ); append( result, "export " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( result, "class %S %S", ast->Attributes.to_string(), ast->Name ); append_fmt( result, "class %S %S", to_string(ast->Attributes), ast->Name );
else append_fmt( result, "class %S", ast->Name ); else append_fmt( result, "class %S", ast->Name );
@ -333,7 +332,7 @@ void CodeEnum::to_string_def( String& result )
append( & result, "enum " ); append( & result, "enum " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ", GEN_NS to_string(ast->Attributes) );
if ( ast->UnderlyingType ) if ( ast->UnderlyingType )
append_fmt( & result, "%S : %S\n{\n%S\n}" append_fmt( & result, "%S : %S\n{\n%S\n}"
@ -362,7 +361,7 @@ void CodeEnum::to_string_fwd( String& result )
append( & result, "export " ); append( & result, "export " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
if ( ast->UnderlyingType ) if ( ast->UnderlyingType )
append_fmt( & result, "enum %S : %S", ast->Name, ast->UnderlyingType.to_string() ); append_fmt( & result, "enum %S : %S", ast->Name, ast->UnderlyingType.to_string() );
@ -389,7 +388,7 @@ void CodeEnum::to_string_class_def( String& result )
if ( ast->Attributes ) if ( ast->Attributes )
{ {
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
} }
if ( ast->UnderlyingType ) if ( ast->UnderlyingType )
@ -418,7 +417,7 @@ void CodeEnum::to_string_class_fwd( String& result )
append( & result, "enum class " ); append( & result, "enum class " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
append_fmt( & result, "%S : %S", ast->Name, ast->UnderlyingType.to_string() ); append_fmt( & result, "%S : %S", ast->Name, ast->UnderlyingType.to_string() );
@ -498,7 +497,7 @@ void CodeFn::to_string_def( String& result )
append( & result, "export" ); append( & result, "export" );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, " %S ", ast->Attributes.to_string() ); append_fmt( & result, " %S ",GEN_NS to_string(ast->Attributes) );
bool prefix_specs = false; bool prefix_specs = false;
if ( ast->Specs ) if ( ast->Specs )
@ -551,7 +550,7 @@ void CodeFn::to_string_fwd( String& result )
append( & result, "export " ); append( & result, "export " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
b32 prefix_specs = false; b32 prefix_specs = false;
if ( ast->Specs ) if ( ast->Specs )
@ -665,10 +664,10 @@ void CodeOperator::to_string_def( String& result )
append( & result, "export " ); append( & result, "export " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
if ( ast->Specs ) if ( ast->Specs )
{ {
@ -719,7 +718,7 @@ void CodeOperator::to_string_fwd( String& result )
append( & result, "export " ); append( & result, "export " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S\n", ast->Attributes.to_string() ); append_fmt( & result, "%S\n",GEN_NS to_string(ast->Attributes) );
if ( ast->Specs ) if ( ast->Specs )
{ {
@ -990,82 +989,89 @@ void to_string( CodeSpecifiers self, String* result )
} }
} }
String CodeStruct::to_string() String to_string(CodeStruct self)
{ {
GEN_ASSERT(self.ast != nullptr);
String result = string_make( GlobalAllocator, "" ); String result = string_make( GlobalAllocator, "" );
switch ( ast->Type ) switch ( self->Type )
{ {
using namespace ECode; using namespace ECode;
case Struct: case Struct:
to_string_def( result ); to_string_def( self, & result );
break; break;
case Struct_Fwd: case Struct_Fwd:
to_string_fwd( result ); to_string_fwd( self, & result );
break; break;
} }
return result; return result;
} }
void CodeStruct::to_string_def( String& result ) void to_string_def( CodeStruct self, String* result )
{ {
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) GEN_ASSERT(self.ast != nullptr);
append( & result, "export " ); AST_Struct* ast = self.ast;
append( & result, "struct " ); if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
append( result, "export " );
append( result, "struct " );
if ( ast->Attributes ) if ( ast->Attributes )
{ {
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( result, "%S ",GEN_NS to_string(ast->Attributes) );
} }
if ( ast->ParentType ) if ( ast->ParentType )
{ {
char const* access_level = to_str( ast->ParentAccess ); char const* access_level = to_str( ast->ParentAccess );
append_fmt( & result, "%S : %s %S", ast->Name, access_level, ast->ParentType.to_string() ); append_fmt( result, "%S : %s %S", ast->Name, access_level, ast->ParentType.to_string() );
CodeType interface = cast(CodeType, ast->ParentType->Next); CodeType interface = cast(CodeType, ast->ParentType->Next);
if ( interface ) if ( interface )
append( & result, "\n" ); append( result, "\n" );
while ( interface ) while ( interface )
{ {
append_fmt( & result, ", %S", interface.to_string() ); append_fmt( result, ", %S", interface.to_string() );
interface = interface->Next ? cast( CodeType, interface->Next) : CodeType { nullptr }; interface = interface->Next ? cast( CodeType, interface->Next) : CodeType { nullptr };
} }
} }
else if ( ast->Name ) else if ( ast->Name )
{ {
append( & result, ast->Name ); append( result, ast->Name );
} }
if ( ast->InlineCmt ) if ( ast->InlineCmt )
{ {
append_fmt( & result, " // %S", ast->InlineCmt->Content ); append_fmt( result, " // %S", ast->InlineCmt->Content );
} }
append_fmt( & result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) ); append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) );
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
append( & result, ";\n"); append( result, ";\n");
} }
void CodeStruct::to_string_fwd( String& result ) void to_string_fwd( CodeStruct self, String* result )
{ {
GEN_ASSERT(self.ast != nullptr);
AST_Struct* ast = self.ast;
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
append( & result, "export " ); append( result, "export " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "struct %S %S", ast->Attributes.to_string(), ast->Name ); append_fmt( result, "struct %S %S",GEN_NS to_string(ast->Attributes), ast->Name );
else append_fmt( & result, "struct %S", ast->Name ); else append_fmt( result, "struct %S", ast->Name );
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) ) if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
{ {
if ( ast->InlineCmt ) if ( ast->InlineCmt )
append_fmt( & result, "; %S", ast->InlineCmt->Content ); append_fmt( result, "; %S", ast->InlineCmt->Content );
else else
append( & result, ";\n"); append( result, ";\n");
} }
} }
@ -1142,7 +1148,7 @@ void CodeType::to_string( String& result )
if ( ast->ReturnType && ast->Params ) if ( ast->ReturnType && ast->Params )
{ {
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( result, "%S ", ast->Attributes.to_string() ); append_fmt( result, "%S ",GEN_NS to_string(ast->Attributes) );
else else
{ {
if ( ast->Specs ) if ( ast->Specs )
@ -1157,7 +1163,7 @@ void CodeType::to_string( String& result )
if ( ast->ReturnType && ast->Params ) if ( ast->ReturnType && ast->Params )
{ {
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
else else
{ {
if ( ast->Specs ) if ( ast->Specs )
@ -1171,7 +1177,7 @@ void CodeType::to_string( String& result )
#endif #endif
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
if ( ast->Specs ) if ( ast->Specs )
append_fmt( & result, "%S %S", ast->Name, GEN_NS to_string(ast->Specs) ); append_fmt( & result, "%S %S", ast->Name, GEN_NS to_string(ast->Specs) );
@ -1197,7 +1203,7 @@ void CodeUnion::to_string( String& result )
append( & result, "union " ); append( & result, "union " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
if ( ast->Name ) if ( ast->Name )
{ {
@ -1240,7 +1246,7 @@ void CodeUsing::to_string( String& result )
append( & result, "export " ); append( & result, "export " );
if ( ast->Attributes ) if ( ast->Attributes )
append_fmt( & result, "%S ", ast->Attributes.to_string() ); append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
if ( ast->UnderlyingType ) if ( ast->UnderlyingType )
{ {

View File

@ -35,6 +35,13 @@ void to_string(CodeSpecifiers specifiers, String* result);
SpecifierT* begin(CodeSpecifiers specifiers ); SpecifierT* begin(CodeSpecifiers specifiers );
SpecifierT* end (CodeSpecifiers specifiers); SpecifierT* end (CodeSpecifiers specifiers);
void add_interface(CodeStruct self, CodeType interface);
String to_string (CodeStruct self);
void to_string_fwd(CodeStruct self, String* result);
void to_string_def(CodeStruct self, String* result);
String to_string(CodeAttributes attributes);
#pragma region Code Types #pragma region Code Types
// These structs are not used at all by the C vairant. // These structs are not used at all by the C vairant.
#if ! GEN_COMPILER_C #if ! GEN_COMPILER_C
@ -148,7 +155,7 @@ struct CodeSpecifiers
struct CodeStruct struct CodeStruct
{ {
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 #if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code( CodeStruct ); Using_Code( CodeStruct );
void add_interface( CodeType interface ); void add_interface( CodeType interface );
@ -159,14 +166,7 @@ struct CodeStruct
#endif #endif
Using_CodeOps( CodeStruct ); Using_CodeOps( CodeStruct );
AST* raw() operator Code() { return * rcast( Code*, this ); }
{
return rcast( AST*, ast );
}
operator Code()
{
return * rcast( Code*, this );
}
AST_Struct* operator->() AST_Struct* operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
@ -181,13 +181,12 @@ struct CodeStruct
struct CodeAttributes struct CodeAttributes
{ {
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 #if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code(CodeAttributes); Using_Code(CodeAttributes);
String to_string(); String to_string();
#endif #endif
Using_CodeOps(CodeAttributes); Using_CodeOps(CodeAttributes);
AST *raw();
operator Code(); operator Code();
AST_Attributes *operator->(); AST_Attributes *operator->();
AST_Attributes *ast; AST_Attributes *ast;
@ -203,7 +202,6 @@ struct CodeComment
#endif #endif
Using_CodeOps(CodeComment); Using_CodeOps(CodeComment);
AST *raw();
operator Code(); operator Code();
AST_Comment *operator->(); AST_Comment *operator->();
AST_Comment *ast; AST_Comment *ast;
@ -220,7 +218,6 @@ struct CodeConstructor
#endif #endif
Using_CodeOps(CodeConstructor); Using_CodeOps(CodeConstructor);
AST* raw();
operator Code(); operator Code();
AST_Constructor* operator->(); AST_Constructor* operator->();
AST_Constructor* ast; AST_Constructor* ast;
@ -236,7 +233,6 @@ struct CodeDefine
#endif #endif
Using_CodeOps(CodeDefine); Using_CodeOps(CodeDefine);
AST* raw();
operator Code(); operator Code();
AST_Define* operator->(); AST_Define* operator->();
AST_Define* ast; AST_Define* ast;
@ -253,7 +249,6 @@ struct CodeDestructor
#endif #endif
Using_CodeOps(CodeDestructor); Using_CodeOps(CodeDestructor);
AST* raw();
operator Code(); operator Code();
AST_Destructor* operator->(); AST_Destructor* operator->();
AST_Destructor* ast; AST_Destructor* ast;
@ -272,7 +267,6 @@ struct CodeEnum
#endif #endif
Using_CodeOps(CodeEnum); Using_CodeOps(CodeEnum);
AST* raw();
operator Code(); operator Code();
AST_Enum* operator->(); AST_Enum* operator->();
AST_Enum* ast; AST_Enum* ast;
@ -286,7 +280,6 @@ struct CodeExec
#endif #endif
Using_CodeOps(CodeExec); Using_CodeOps(CodeExec);
AST *raw();
operator Code(); operator Code();
AST_Exec *operator->(); AST_Exec *operator->();
AST_Exec *ast; AST_Exec *ast;
@ -507,7 +500,6 @@ struct CodeExtern
#endif #endif
Using_CodeOps(CodeExtern); Using_CodeOps(CodeExtern);
AST* raw();
operator Code(); operator Code();
AST_Extern* operator->(); AST_Extern* operator->();
AST_Extern* ast; AST_Extern* ast;
@ -523,7 +515,6 @@ struct CodeInclude
#endif #endif
Using_CodeOps(CodeInclude); Using_CodeOps(CodeInclude);
AST* raw();
operator Code(); operator Code();
AST_Include* operator->(); AST_Include* operator->();
AST_Include* ast; AST_Include* ast;
@ -539,7 +530,6 @@ struct CodeFriend
#endif #endif
Using_CodeOps(CodeFriend); Using_CodeOps(CodeFriend);
AST* raw();
operator Code(); operator Code();
AST_Friend* operator->(); AST_Friend* operator->();
AST_Friend* ast; AST_Friend* ast;
@ -556,7 +546,6 @@ struct CodeFn
#endif #endif
Using_CodeOps(CodeFn); Using_CodeOps(CodeFn);
AST* raw();
operator Code(); operator Code();
AST_Fn* operator->(); AST_Fn* operator->();
AST_Fn* ast; AST_Fn* ast;
@ -572,7 +561,6 @@ struct CodeModule
#endif #endif
Using_CodeOps(CodeModule); Using_CodeOps(CodeModule);
AST* raw();
operator Code(); operator Code();
AST_Module* operator->(); AST_Module* operator->();
AST_Module* ast; AST_Module* ast;
@ -588,7 +576,6 @@ struct CodeNS
#endif #endif
Using_CodeOps(CodeNS); Using_CodeOps(CodeNS);
AST* raw();
operator Code(); operator Code();
AST_NS* operator->(); AST_NS* operator->();
AST_NS* ast; AST_NS* ast;
@ -605,7 +592,6 @@ struct CodeOperator
#endif #endif
Using_CodeOps(CodeOperator); Using_CodeOps(CodeOperator);
AST* raw();
operator Code(); operator Code();
AST_Operator* operator->(); AST_Operator* operator->();
AST_Operator* ast; AST_Operator* ast;
@ -622,7 +608,6 @@ struct CodeOpCast
#endif #endif
Using_CodeOps(CodeOpCast); Using_CodeOps(CodeOpCast);
AST* raw();
operator Code(); operator Code();
AST_OpCast* operator->(); AST_OpCast* operator->();
AST_OpCast* ast; AST_OpCast* ast;
@ -638,7 +623,6 @@ struct CodePragma
#endif #endif
Using_CodeOps( CodePragma ); Using_CodeOps( CodePragma );
AST* raw();
operator Code(); operator Code();
AST_Pragma* operator->(); AST_Pragma* operator->();
AST_Pragma* ast; AST_Pragma* ast;
@ -659,7 +643,6 @@ struct CodePreprocessCond
#endif #endif
Using_CodeOps( CodePreprocessCond ); Using_CodeOps( CodePreprocessCond );
AST* raw();
operator Code(); operator Code();
AST_PreprocessCond* operator->(); AST_PreprocessCond* operator->();
AST_PreprocessCond* ast; AST_PreprocessCond* ast;
@ -859,7 +842,6 @@ struct CodeTemplate
#endif #endif
Using_CodeOps( CodeTemplate ); Using_CodeOps( CodeTemplate );
AST* raw();
operator Code(); operator Code();
AST_Template* operator->(); AST_Template* operator->();
AST_Template* ast; AST_Template* ast;
@ -875,7 +857,6 @@ struct CodeType
#endif #endif
Using_CodeOps( CodeType ); Using_CodeOps( CodeType );
AST* raw();
operator Code(); operator Code();
AST_Type* operator->(); AST_Type* operator->();
AST_Type* ast; AST_Type* ast;
@ -891,7 +872,6 @@ struct CodeTypedef
#endif #endif
Using_CodeOps( CodeTypedef ); Using_CodeOps( CodeTypedef );
AST* raw();
operator Code(); operator Code();
AST_Typedef* operator->(); AST_Typedef* operator->();
AST_Typedef* ast; AST_Typedef* ast;
@ -907,7 +887,6 @@ struct CodeUnion
#endif #endif
Using_CodeOps(CodeUnion); Using_CodeOps(CodeUnion);
AST* raw();
operator Code(); operator Code();
AST_Union* operator->(); AST_Union* operator->();
AST_Union* ast; AST_Union* ast;
@ -924,7 +903,6 @@ struct CodeUsing
#endif #endif
Using_CodeOps(CodeUsing); Using_CodeOps(CodeUsing);
AST* raw();
operator Code(); operator Code();
AST_Using* operator->(); AST_Using* operator->();
AST_Using* ast; AST_Using* ast;
@ -940,7 +918,6 @@ struct CodeVar
#endif #endif
Using_CodeOps(CodeVar); Using_CodeOps(CodeVar);
AST* raw();
operator Code(); operator Code();
AST_Var* operator->(); AST_Var* operator->();
AST_Var* ast; AST_Var* ast;

View File

@ -55,11 +55,6 @@ inline CodeAttributes::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeAttributes::raw()
{
return rcast( AST*, ast );
}
inline CodeAttributes::operator Code() inline CodeAttributes::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -91,11 +86,6 @@ inline CodeComment::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeComment::raw()
{
return rcast( AST*, ast );
}
inline CodeComment::operator Code() inline CodeComment::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -127,11 +117,6 @@ inline CodeConstructor::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeConstructor::raw()
{
return rcast( AST*, ast );
}
inline CodeConstructor::operator Code() inline CodeConstructor::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -179,11 +164,6 @@ inline CodeDefine::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeDefine::raw()
{
return rcast( AST*, ast );
}
inline CodeDefine::operator Code() inline CodeDefine::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -215,11 +195,6 @@ inline CodeDestructor::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeDestructor::raw()
{
return rcast( AST*, ast );
}
inline CodeDestructor::operator Code() inline CodeDestructor::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -251,11 +226,6 @@ inline CodeEnum::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeEnum::raw()
{
return rcast( AST*, ast );
}
inline CodeEnum::operator Code() inline CodeEnum::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -287,11 +257,6 @@ inline CodeExec::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeExec::raw()
{
return rcast( AST*, ast );
}
inline CodeExec::operator Code() inline CodeExec::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -323,11 +288,6 @@ inline CodeExtern::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeExtern::raw()
{
return rcast( AST*, ast );
}
inline CodeExtern::operator Code() inline CodeExtern::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -359,11 +319,6 @@ inline CodeFriend::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeFriend::raw()
{
return rcast( AST*, ast );
}
inline CodeFriend::operator Code() inline CodeFriend::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -395,11 +350,6 @@ inline CodeFn::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeFn::raw()
{
return rcast( AST*, ast );
}
inline CodeFn::operator Code() inline CodeFn::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -431,11 +381,6 @@ inline CodeInclude::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeInclude::raw()
{
return rcast( AST*, ast );
}
inline CodeInclude::operator Code() inline CodeInclude::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -467,11 +412,6 @@ inline CodeModule::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeModule::raw()
{
return rcast( AST*, ast );
}
inline CodeModule::operator Code() inline CodeModule::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -503,11 +443,6 @@ inline CodeNS::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeNS::raw()
{
return rcast( AST*, ast );
}
inline CodeNS::operator Code() inline CodeNS::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -539,11 +474,6 @@ inline CodeOperator::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeOperator::raw()
{
return rcast( AST*, ast );
}
inline CodeOperator::operator Code() inline CodeOperator::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -575,11 +505,6 @@ inline CodeOpCast::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeOpCast::raw()
{
return rcast( AST*, ast );
}
inline CodeOpCast::operator Code() inline CodeOpCast::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -627,11 +552,6 @@ inline CodePragma::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodePragma::raw()
{
return rcast( AST*, ast );
}
inline CodePragma::operator Code() inline CodePragma::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -663,11 +583,6 @@ inline CodePreprocessCond::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodePreprocessCond::raw()
{
return rcast( AST*, ast );
}
inline CodePreprocessCond::operator Code() inline CodePreprocessCond::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -731,11 +646,6 @@ inline CodeTemplate::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeTemplate::raw()
{
return rcast( AST*, ast );
}
inline CodeTemplate::operator Code() inline CodeTemplate::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -767,11 +677,6 @@ inline CodeType::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeType::raw()
{
return rcast( AST*, ast );
}
inline CodeType::operator Code() inline CodeType::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -803,11 +708,6 @@ inline CodeTypedef::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeTypedef::raw()
{
return rcast( AST*, ast );
}
inline CodeTypedef::operator Code() inline CodeTypedef::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -839,11 +739,6 @@ inline CodeUnion::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeUnion::raw()
{
return rcast( AST*, ast );
}
inline CodeUnion::operator Code() inline CodeUnion::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -875,11 +770,6 @@ inline CodeUsing::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeUsing::raw()
{
return rcast( AST*, ast );
}
inline CodeUsing::operator Code() inline CodeUsing::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );
@ -911,11 +801,6 @@ inline CodeVar::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline AST* CodeVar::raw()
{
return rcast( AST*, ast );
}
inline CodeVar::operator Code() inline CodeVar::operator Code()
{ {
return *rcast( Code*, this ); return *rcast( Code*, this );

View File

@ -353,13 +353,13 @@ SpecifierT* end(CodeSpecifiers self)
#pragma region CodeStruct #pragma region CodeStruct
inline inline
void CodeStruct::add_interface( CodeType type ) void add_interface(CodeStruct self, CodeType type )
{ {
CodeType possible_slot = ast->ParentType; CodeType possible_slot = self->ParentType;
if ( possible_slot.ast ) if ( possible_slot.ast )
{ {
// Were adding an interface to parent type, so we need to make sure the parent type is public. // Were adding an interface to parent type, so we need to make sure the parent type is public.
ast->ParentAccess = AccessSpec_Public; self->ParentAccess = AccessSpec_Public;
// If your planning on adding a proper parent, // If your planning on adding a proper parent,
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. // then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
} }

View File

@ -555,7 +555,7 @@ CodeClass def_class( StrC name
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() ); log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }
@ -697,7 +697,7 @@ CodeEnum def_enum( StrC name
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() ); log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }
@ -846,7 +846,7 @@ CodeFn def_function( StrC name
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", attributes.debug_str() ); log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }
@ -967,7 +967,7 @@ CodeOperator def_operator( OperatorT op, StrC nspace
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", attributes.debug_str() ); log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }
@ -1183,7 +1183,7 @@ CodeStruct def_struct( StrC name
if ( attributes && attributes->Type != PlatformAttributes ) if ( attributes && attributes->Type != PlatformAttributes )
{ {
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() ); log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }
@ -1229,7 +1229,7 @@ CodeStruct def_struct( StrC name
{ {
for (s32 idx = 0; idx < num_interfaces; idx++ ) for (s32 idx = 0; idx < num_interfaces; idx++ )
{ {
result.add_interface( interfaces[idx] ); add_interface(result, interfaces[idx] );
} }
} }
@ -1387,7 +1387,7 @@ CodeUnion def_union( StrC name, Code body, CodeAttributes attributes, ModuleFlag
if ( attributes && attributes->Type != ECode::PlatformAttributes ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", attributes.debug_str() ); log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }
@ -1424,7 +1424,7 @@ CodeUsing def_using( StrC name, CodeType type
if ( attributes && attributes->Type != ECode::PlatformAttributes ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", attributes.debug_str() ); log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }
@ -1464,7 +1464,7 @@ CodeVar def_variable( CodeType type, StrC name, Code value
if ( attributes && attributes->Type != ECode::PlatformAttributes ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() ); log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }

View File

@ -373,11 +373,6 @@ CodeBody gen_ast_inlines()
); );
char const* codetype_impl_tmpl = stringize( char const* codetype_impl_tmpl = stringize(
inline
AST* Code<typename>::raw()
{
return rcast( AST*, ast );
}
inline inline
Code<typename>::operator Code() Code<typename>::operator Code()
{ {