reduction of Code struct member function usage in base lib

This commit is contained in:
Edward R. Gonzalez 2024-12-02 02:38:55 -05:00
parent 9b68791e38
commit 9321a04ebc
9 changed files with 95 additions and 98 deletions

View File

@ -136,7 +136,7 @@ int gen_main()
case ECode::Using: case ECode::Using:
{ {
log_fmt("REPLACE THIS MANUALLY: %S\n", entry->Name); log_fmt("REPLACE THIS MANUALLY: %S\n", entry->Name);
CodeUsing using_ver = entry.code_cast<CodeUsing>(); CodeUsing using_ver = cast(CodeUsing, entry);
CodeTypedef typedef_ver = def_typedef(using_ver->Name, using_ver->UnderlyingType); CodeTypedef typedef_ver = def_typedef(using_ver->Name, using_ver->UnderlyingType);
memory.append(typedef_ver); memory.append(typedef_ver);
@ -144,7 +144,7 @@ int gen_main()
break; break;
case ECode::Function_Fwd: case ECode::Function_Fwd:
{ {
CodeFn fn = entry.code_cast<CodeFn>(); CodeFn fn = cast(CodeFn, entry);
if ( fn->Name.is_equal(txt("free")) ) if ( fn->Name.is_equal(txt("free")) )
{ {
fn->Name = get_cached_string(txt("gen_free_ptr")); fn->Name = get_cached_string(txt("gen_free_ptr"));
@ -154,7 +154,7 @@ int gen_main()
break; break;
case ECode::Function: case ECode::Function:
{ {
CodeFn fn = entry.code_cast<CodeFn>(); CodeFn fn = cast(CodeFn, entry);
s32 constexpr_found = fn->Specs.remove( ESpecifier::Constexpr ); s32 constexpr_found = fn->Specs.remove( ESpecifier::Constexpr );
if (constexpr_found > -1) { if (constexpr_found > -1) {
log_fmt("Found constexpr: %S\n", entry->to_string()); log_fmt("Found constexpr: %S\n", entry->to_string());
@ -169,7 +169,7 @@ int gen_main()
break; break;
case ECode::Template: case ECode::Template:
{ {
CodeTemplate tmpl = entry.code_cast<CodeTemplate>(); CodeTemplate tmpl = cast(CodeTemplate, entry);
if ( tmpl->Declaration->Name.contains(txt("swap"))) if ( tmpl->Declaration->Name.contains(txt("swap")))
{ {
CodeBody macro_swap = parse_global_body( txt(R"( CodeBody macro_swap = parse_global_body( txt(R"(

View File

@ -8,7 +8,7 @@ using SwapContentProc = CodeBody(void);
b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& body ) b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& body )
{ {
b32 found = false; b32 found = false;
CodePreprocessCond cond = entry_iter.code_cast<CodePreprocessCond>(); CodePreprocessCond cond = cast(CodePreprocessCond, entry_iter);
if ( cond->Content.contains(cond_sig) ) if ( cond->Content.contains(cond_sig) )
{ {
log_fmt("Preprocess cond found: %S\n", cond->Content); log_fmt("Preprocess cond found: %S\n", cond->Content);
@ -44,7 +44,7 @@ b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& bod
bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_content, Code& entry_iter, CodeBody& body ) bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_content, Code& entry_iter, CodeBody& body )
{ {
bool found = false; bool found = false;
CodePragma possible_region = entry_iter.code_cast<CodePragma>(); CodePragma possible_region = cast(CodePragma, entry_iter);
String region_sig = string_fmt_buf(GlobalAllocator, "region %s", region_name.Ptr); String region_sig = string_fmt_buf(GlobalAllocator, "region %s", region_name.Ptr);
String endregion_sig = string_fmt_buf(GlobalAllocator, "endregion %s", region_name.Ptr); String endregion_sig = string_fmt_buf(GlobalAllocator, "endregion %s", region_name.Ptr);
@ -58,7 +58,7 @@ bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_
(entry_iter->Type) { (entry_iter->Type) {
case ECode::Preprocess_Pragma: case ECode::Preprocess_Pragma:
{ {
CodePragma possible_end_region = entry_iter.code_cast<CodePragma>(); CodePragma possible_end_region = cast(CodePragma, entry_iter);
if ( possible_end_region->Content.contains(endregion_sig) ) { if ( possible_end_region->Content.contains(endregion_sig) ) {
// body.append(possible_end_region); // body.append(possible_end_region);
continue_for = false; continue_for = false;

View File

@ -1159,12 +1159,12 @@ bool AST::validate_body()
#define CheckEntries( Unallowed_Types ) \ #define CheckEntries( Unallowed_Types ) \
do \ do \
{ \ { \
for ( Code entry : code_cast<CodeBody>() ) \ for ( Code entry : code_cast<CodeBody>() ) \
{ \ { \
switch ( entry->Type ) \ switch ( entry->Type ) \
{ \ { \
Unallowed_Types \ Unallowed_Types \
log_failure( "AST::validate_body: Invalid entry in body %s", entry.debug_str() ); \ log_failure( "AST::validate_body: Invalid entry in body %s", GEN_NS debug_str(entry) ); \
return false; \ return false; \
} \ } \
} \ } \
@ -1181,7 +1181,7 @@ bool AST::validate_body()
{ {
if ( entry->Type != Untyped ) if ( entry->Type != Untyped )
{ {
log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %s", entry.debug_str() ); log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %s", GEN_NS debug_str(entry) );
return false; return false;
} }
} }
@ -1217,7 +1217,7 @@ bool AST::validate_body()
case Specifiers: case Specifiers:
case Struct_Body: case Struct_Body:
case Typename: case Typename:
log_failure("AST::validate_body: Invalid entry in body %s", entry.debug_str()); log_failure("AST::validate_body: Invalid entry in body %s", GEN_NS debug_str(entry));
return false; return false;
} }
} }
@ -1233,7 +1233,7 @@ bool AST::validate_body()
{ {
if ( entry->Type != Untyped ) if ( entry->Type != Untyped )
{ {
log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %s", entry.debug_str() ); log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %s", GEN_NS debug_str(entry) );
return false; return false;
} }
} }

View File

@ -157,9 +157,8 @@ namespace parser
struct Token; struct Token;
} }
template< class Type> forceinline Type tmpl_cast( Code* self ) { return * rcast( Type*, self ); } #if ! GEN_COMPILER_C
#if ! GEN_COMPILER_C && 0 template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( Type*, & self ); }
template< class Type> forceinline Type tmpl_cast( Code& self ) { return * rcast( Type*, & self ); }
#endif #endif
char const* debug_str (Code code); char const* debug_str (Code code);
@ -195,16 +194,13 @@ struct Code
bool operator !=( Code other ) { return (AST*)ast != other.ast; } \ bool operator !=( Code other ) { return (AST*)ast != other.ast; } \
operator bool(); operator bool();
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 #if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code( Code ); Using_Code( Code );
String to_string() { return GEN_NS to_string(* this); } String to_string() { return GEN_NS to_string(* this); }
#endif #endif
Using_CodeOps( Code ); Using_CodeOps( Code );
template< class Type >
forceinline Type code_cast() { return * rcast( Type*, this ); }
AST* operator ->() { return ast; } AST* operator ->() { return ast; }
Code& operator ++(); Code& operator ++();

View File

@ -53,7 +53,7 @@ void CodeBody::to_string( String& result )
s32 left = ast->NumEntries; s32 left = ast->NumEntries;
while ( left -- ) while ( left -- )
{ {
append_fmt( & result, "%S", curr.to_string() ); append_fmt( & result, "%S", GEN_NS to_string(curr) );
++curr; ++curr;
} }
} }
@ -66,7 +66,7 @@ void CodeBody::to_string_export( String& result )
s32 left = ast->NumEntries; s32 left = ast->NumEntries;
while ( left-- ) while ( left-- )
{ {
append_fmt( & result, "%S", curr.to_string() ); append_fmt( & result, "%S", GEN_NS to_string(curr) );
++curr; ++curr;
} }
@ -110,12 +110,12 @@ void CodeConstructor::to_string_def( String& result )
append( & result, "()" ); append( & result, "()" );
if ( ast->InitializerList ) if ( ast->InitializerList )
append_fmt( & result, " : %S", ast->InitializerList.to_string() ); append_fmt( & result, " : %S", GEN_NS to_string(ast->InitializerList) );
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}\n", ast->Body.to_string() ); append_fmt( & result, "\n{\n%S\n}\n", GEN_NS to_string(ast->Body) );
} }
void CodeConstructor::to_string_fwd( String& result ) void CodeConstructor::to_string_fwd( String& result )
@ -134,7 +134,7 @@ void CodeConstructor::to_string_fwd( String& result )
append_fmt( & result, "()"); append_fmt( & result, "()");
if (ast->Body) if (ast->Body)
append_fmt( & result, " = %S", ast->Body.to_string() ); append_fmt( & result, " = %S", GEN_NS to_string(ast->Body) );
if ( ast->InlineCmt ) if ( ast->InlineCmt )
append_fmt( & result, "; // %S\n", ast->InlineCmt->Content ); append_fmt( & result, "; // %S\n", ast->InlineCmt->Content );
@ -264,7 +264,7 @@ void CodeDestructor::to_string_def( String& result )
else else
append_fmt( & result, "~%S()", ast->Parent->Name ); append_fmt( & result, "~%S()", ast->Parent->Name );
append_fmt( & result, "\n{\n%S\n}\n", ast->Body.to_string() ); append_fmt( & result, "\n{\n%S\n}\n", GEN_NS to_string(ast->Body) );
} }
void CodeDestructor::to_string_fwd( String& result ) void CodeDestructor::to_string_fwd( String& result )
@ -279,7 +279,7 @@ void CodeDestructor::to_string_fwd( String& result )
if ( ast->Specs.has( ESpecifier::Pure ) ) if ( ast->Specs.has( ESpecifier::Pure ) )
append( & result, " = 0;" ); append( & result, " = 0;" );
else if (ast->Body) else if (ast->Body)
append_fmt( & result, " = %S;", ast->Body.to_string() ); append_fmt( & result, " = %S;", GEN_NS to_string(ast->Body) );
} }
else else
append_fmt( & result, "~%S();", ast->Parent->Name ); append_fmt( & result, "~%S();", ast->Parent->Name );
@ -333,7 +333,7 @@ void CodeEnum::to_string_def( String& result )
else if ( ast->UnderlyingTypeMacro ) else if ( ast->UnderlyingTypeMacro )
append_fmt( & result, "%S : %S\n{\n%S\n}" append_fmt( & result, "%S : %S\n{\n%S\n}"
, ast->Name , ast->Name
, ast->UnderlyingTypeMacro.to_string() , GEN_NS to_string(ast->UnderlyingTypeMacro)
, ast->Body.to_string() , ast->Body.to_string()
); );
@ -872,11 +872,11 @@ void CodeParam::to_string( String& result )
if ( ast->PostNameMacro ) if ( ast->PostNameMacro )
{ {
append_fmt( & result, " %S", ast->PostNameMacro.to_string() ); append_fmt( & result, " %S", GEN_NS to_string(ast->PostNameMacro) );
} }
if ( ast->Value ) if ( ast->Value )
append_fmt( & result, " = %S", ast->Value.to_string() ); append_fmt( & result, " = %S", GEN_NS to_string(ast->Value) );
if ( ast->NumEntries - 1 > 0 ) if ( ast->NumEntries - 1 > 0 )
{ {
@ -1068,9 +1068,9 @@ void CodeTemplate::to_string( String& result )
append( & result, "export " ); append( & result, "export " );
if ( ast->Params ) if ( ast->Params )
append_fmt( & result, "template< %S >\n%S", ast->Params.to_string(), ast->Declaration.to_string() ); append_fmt( & result, "template< %S >\n%S", GEN_NS to_string(ast->Params), GEN_NS to_string(ast->Declaration) );
else else
append_fmt( & result, "template<>\n%S", ast->Declaration.to_string() ); append_fmt( & result, "template<>\n%S", GEN_NS to_string(ast->Declaration) );
} }
String CodeTypedef::to_string() String CodeTypedef::to_string()
@ -1089,9 +1089,9 @@ void CodeTypedef::to_string( String& result )
// Determines if the typedef is a function typename // Determines if the typedef is a function typename
if ( ast->UnderlyingType->ReturnType ) if ( ast->UnderlyingType->ReturnType )
append( & result, ast->UnderlyingType.to_string() ); append( & result, GEN_NS to_string(ast->UnderlyingType) );
else else
append_fmt( & result, "%S %S", ast->UnderlyingType.to_string(), ast->Name ); append_fmt( & result, "%S %S", GEN_NS to_string(ast->UnderlyingType), ast->Name );
if ( ast->UnderlyingType->Type == ECode::Typename && ast->UnderlyingType->ArrExpr ) if ( ast->UnderlyingType->Type == ECode::Typename && ast->UnderlyingType->ArrExpr )
{ {
@ -1234,7 +1234,7 @@ void CodeUsing::to_string( String& result )
if ( ast->UnderlyingType->ArrExpr ) if ( ast->UnderlyingType->ArrExpr )
{ {
append_fmt( & result, "[ %S ]", ast->UnderlyingType->ArrExpr.to_string() ); append_fmt( & result, "[ %S ]", GEN_NS to_string(ast->UnderlyingType->ArrExpr) );
AST* next_arr_expr = ast->UnderlyingType->ArrExpr->Next; AST* next_arr_expr = ast->UnderlyingType->ArrExpr->Next;
while ( next_arr_expr ) while ( next_arr_expr )
@ -1283,7 +1283,7 @@ void CodeVar::to_string( String& result )
if ( ast->ValueType->ArrExpr ) if ( ast->ValueType->ArrExpr )
{ {
append_fmt( & result, "[ %S ]", ast->ValueType->ArrExpr.to_string() ); append_fmt( & result, "[ %S ]", GEN_NS to_string(ast->ValueType->ArrExpr) );
AST* next_arr_expr = ast->ValueType->ArrExpr->Next; AST* next_arr_expr = ast->ValueType->ArrExpr->Next;
while ( next_arr_expr ) while ( next_arr_expr )
@ -1296,9 +1296,9 @@ void CodeVar::to_string( String& result )
if ( ast->Value ) if ( ast->Value )
{ {
if ( ast->VarConstructorInit ) if ( ast->VarConstructorInit )
append_fmt( & result, "( %S ", ast->Value.to_string() ); append_fmt( & result, "( %S ", GEN_NS to_string(ast->Value) );
else else
append_fmt( & result, " = %S", ast->Value.to_string() ); append_fmt( & result, " = %S", GEN_NS to_string(ast->Value) );
} }
// Keep the chain going... // Keep the chain going...
@ -1326,7 +1326,7 @@ void CodeVar::to_string( String& result )
if ( ast->ValueType->ArrExpr ) if ( ast->ValueType->ArrExpr )
{ {
append_fmt( & result, "[ %S ]", ast->ValueType->ArrExpr.to_string() ); append_fmt( & result, "[ %S ]", GEN_NS to_string(ast->ValueType->ArrExpr) );
AST* next_arr_expr = ast->ValueType->ArrExpr->Next; AST* next_arr_expr = ast->ValueType->ArrExpr->Next;
while ( next_arr_expr ) while ( next_arr_expr )
@ -1337,14 +1337,14 @@ void CodeVar::to_string( String& result )
} }
if ( ast->BitfieldSize ) if ( ast->BitfieldSize )
append_fmt( & result, " : %S", ast->BitfieldSize.to_string() ); append_fmt( & result, " : %S", GEN_NS to_string(ast->BitfieldSize) );
if ( ast->Value ) if ( ast->Value )
{ {
if ( ast->VarConstructorInit ) if ( ast->VarConstructorInit )
append_fmt( & result, "( %S ", ast->Value.to_string() ); append_fmt( & result, "( %S ", GEN_NS to_string(ast->Value) );
else else
append_fmt( & result, " = %S", ast->Value.to_string() ); append_fmt( & result, " = %S", GEN_NS to_string(ast->Value) );
} }
if ( ast->NextVar ) if ( ast->NextVar )
@ -1362,11 +1362,11 @@ void CodeVar::to_string( String& result )
} }
if ( ast->BitfieldSize ) if ( ast->BitfieldSize )
append_fmt( & result, "%S %S : %S", ast->ValueType.to_string(), ast->Name, ast->BitfieldSize.to_string() ); append_fmt( & result, "%S %S : %S", ast->ValueType.to_string(), ast->Name, GEN_NS to_string(ast->BitfieldSize) );
else if ( ast->ValueType->ArrExpr ) else if ( ast->ValueType->ArrExpr )
{ {
append_fmt( & result, "%S %S[ %S ]", ast->ValueType.to_string(), ast->Name, ast->ValueType->ArrExpr.to_string() ); append_fmt( & result, "%S %S[ %S ]", ast->ValueType.to_string(), ast->Name, GEN_NS to_string(ast->ValueType->ArrExpr) );
AST* next_arr_expr = ast->ValueType->ArrExpr->Next; AST* next_arr_expr = ast->ValueType->ArrExpr->Next;
while ( next_arr_expr ) while ( next_arr_expr )
@ -1382,9 +1382,9 @@ void CodeVar::to_string( String& result )
if ( ast->Value ) if ( ast->Value )
{ {
if ( ast->VarConstructorInit ) if ( ast->VarConstructorInit )
append_fmt( & result, "( %S ", ast->Value.to_string() ); append_fmt( & result, "( %S ", GEN_NS to_string(ast->Value) );
else else
append_fmt( & result, " = %S", ast->Value.to_string() ); append_fmt( & result, " = %S", GEN_NS to_string(ast->Value) );
} }
if ( ast->NextVar ) if ( ast->NextVar )

View File

@ -17,8 +17,8 @@ struct CodeBody
{ {
GEN_ASSERT(other.ast != nullptr); GEN_ASSERT(other.ast != nullptr);
if (other.is_body()) { if (GEN_NS is_body(other)) {
append( cast(CodeBody, & other) ); append( cast(CodeBody, other) );
} }
GEN_NS append( raw(), other.ast ); GEN_NS append( raw(), other.ast );

View File

@ -79,69 +79,69 @@ void define_constants()
scast(String, Code_Global->Content) = Code_Global->Name; scast(String, Code_Global->Content) = Code_Global->Name;
Code_Invalid = make_code(); Code_Invalid = make_code();
Code_Invalid.set_global(); set_global(Code_Invalid);
t_empty = (CodeType) make_code(); t_empty = (CodeType) make_code();
t_empty->Type = ECode::Typename; t_empty->Type = ECode::Typename;
t_empty->Name = get_cached_string( txt("") ); t_empty->Name = get_cached_string( txt("") );
t_empty.set_global(); set_global(t_empty);
access_private = make_code(); access_private = make_code();
access_private->Type = ECode::Access_Private; access_private->Type = ECode::Access_Private;
access_private->Name = get_cached_string( txt("private:\n") ); access_private->Name = get_cached_string( txt("private:\n") );
access_private.set_global(); set_global(access_private);
access_protected = make_code(); access_protected = make_code();
access_protected->Type = ECode::Access_Protected; access_protected->Type = ECode::Access_Protected;
access_protected->Name = get_cached_string( txt("protected:\n") ); access_protected->Name = get_cached_string( txt("protected:\n") );
access_protected.set_global(); set_global(access_protected);
access_public = make_code(); access_public = make_code();
access_public->Type = ECode::Access_Public; access_public->Type = ECode::Access_Public;
access_public->Name = get_cached_string( txt("public:\n") ); access_public->Name = get_cached_string( txt("public:\n") );
access_public.set_global(); set_global(access_public);
attrib_api_export = def_attributes( code(GEN_API_Export_Code)); attrib_api_export = def_attributes( code(GEN_API_Export_Code));
attrib_api_export.set_global(); set_global(attrib_api_export);
attrib_api_import = def_attributes( code(GEN_API_Import_Code)); attrib_api_import = def_attributes( code(GEN_API_Import_Code));
attrib_api_import.set_global(); set_global(attrib_api_import);
module_global_fragment = make_code(); module_global_fragment = make_code();
module_global_fragment->Type = ECode::Untyped; module_global_fragment->Type = ECode::Untyped;
module_global_fragment->Name = get_cached_string( txt("module;") ); module_global_fragment->Name = get_cached_string( txt("module;") );
module_global_fragment->Content = module_global_fragment->Name; module_global_fragment->Content = module_global_fragment->Name;
module_global_fragment.set_global(); set_global(module_global_fragment);
module_private_fragment = make_code(); module_private_fragment = make_code();
module_private_fragment->Type = ECode::Untyped; module_private_fragment->Type = ECode::Untyped;
module_private_fragment->Name = get_cached_string( txt("module : private;") ); module_private_fragment->Name = get_cached_string( txt("module : private;") );
module_private_fragment->Content = module_private_fragment->Name; module_private_fragment->Content = module_private_fragment->Name;
module_private_fragment.set_global(); set_global(module_private_fragment);
fmt_newline = make_code(); fmt_newline = make_code();
fmt_newline->Type = ECode::NewLine; fmt_newline->Type = ECode::NewLine;
fmt_newline.set_global(); set_global(fmt_newline);
pragma_once = (CodePragma) make_code(); pragma_once = (CodePragma) make_code();
pragma_once->Type = ECode::Preprocess_Pragma; pragma_once->Type = ECode::Preprocess_Pragma;
pragma_once->Name = get_cached_string( txt("once") ); pragma_once->Name = get_cached_string( txt("once") );
pragma_once->Content = pragma_once->Name; pragma_once->Content = pragma_once->Name;
pragma_once.set_global(); set_global(pragma_once);
param_varadic = (CodeType) make_code(); param_varadic = (CodeType) make_code();
param_varadic->Type = ECode::Parameters; param_varadic->Type = ECode::Parameters;
param_varadic->Name = get_cached_string( txt("...") ); param_varadic->Name = get_cached_string( txt("...") );
param_varadic->ValueType = t_empty; param_varadic->ValueType = t_empty;
param_varadic.set_global(); set_global(param_varadic);
preprocess_else = (CodePreprocessCond) make_code(); preprocess_else = (CodePreprocessCond) make_code();
preprocess_else->Type = ECode::Preprocess_Else; preprocess_else->Type = ECode::Preprocess_Else;
preprocess_else.set_global(); set_global(preprocess_else);
preprocess_endif = (CodePreprocessCond) make_code(); preprocess_endif = (CodePreprocessCond) make_code();
preprocess_endif->Type = ECode::Preprocess_EndIf; preprocess_endif->Type = ECode::Preprocess_EndIf;
preprocess_endif.set_global(); set_global(preprocess_endif);
# define def_constant_code_type( Type_ ) \ # define def_constant_code_type( Type_ ) \
t_##Type_ = def_type( name(Type_) ); \ t_##Type_ = def_type( name(Type_) ); \

View File

@ -527,7 +527,7 @@ CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code b
break; break;
default: default:
log_failure("gen::def_constructor: body must be either of Function_Body or Untyped type - %s", body.debug_str()); log_failure("gen::def_constructor: body must be either of Function_Body or Untyped type - %s", debug_str(body));
return InvalidCode; return InvalidCode;
} }
@ -579,7 +579,7 @@ CodeClass def_class( StrC name
break; break;
default: default:
log_failure("gen::def_class: body must be either of Class_Body or Untyped type - %s", body.debug_str()); log_failure("gen::def_class: body must be either of Class_Body or Untyped type - %s", debug_str(body));
return InvalidCode; return InvalidCode;
} }
@ -665,7 +665,7 @@ CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers )
break; break;
default: default:
log_failure("gen::def_destructor: body must be either of Function_Body or Untyped type - %s", body.debug_str()); log_failure("gen::def_destructor: body must be either of Function_Body or Untyped type - %s", debug_str(body));
return InvalidCode; return InvalidCode;
} }
@ -715,7 +715,7 @@ CodeEnum def_enum( StrC name
break; break;
default: default:
log_failure( "gen::def_enum: body must be of Enum_Body or Untyped type %s", body.debug_str()); log_failure( "gen::def_enum: body must be of Enum_Body or Untyped type %s", debug_str(body));
return InvalidCode; return InvalidCode;
} }
@ -944,7 +944,7 @@ CodeNS def_namespace( StrC name, Code body, ModuleFlag mflags )
if ( body->Type != Namespace_Body && body->Type != Untyped ) if ( body->Type != Namespace_Body && body->Type != Untyped )
{ {
log_failure("gen::def_namespace: body is not of namespace or untyped type %s", body.debug_str()); log_failure("gen::def_namespace: body is not of namespace or untyped type %s", debug_str(body));
return InvalidCode; return InvalidCode;
} }
@ -1057,7 +1057,7 @@ CodeOpCast def_operator_cast( CodeType type, Code body, CodeSpecifiers const_spe
if ( body->Type != Function_Body && body->Type != Execution ) if ( body->Type != Function_Body && body->Type != Execution )
{ {
log_failure( "gen::def_operator_cast: body is not of function body or execution type - %s", body.debug_str() ); log_failure( "gen::def_operator_cast: body is not of function body or execution type - %s", debug_str(body) );
return InvalidCode; return InvalidCode;
} }
@ -1086,13 +1086,13 @@ CodeParam def_param( CodeType type, StrC name, Code value )
if ( type->Type != Typename ) if ( type->Type != Typename )
{ {
log_failure( "gen::def_param: type is not a typename - %s", type.debug_str() ); log_failure( "gen::def_param: type is not a typename - %s", debug_str(type) );
return InvalidCode; return InvalidCode;
} }
if ( value && value->Type != Untyped ) if ( value && value->Type != Untyped )
{ {
log_failure( "gen::def_param: value is not untyped - %s", value.debug_str() ); log_failure( "gen::def_param: value is not untyped - %s", debug_str(value) );
return InvalidCode; return InvalidCode;
} }
@ -1189,13 +1189,13 @@ CodeStruct def_struct( StrC name
if ( parent && parent->Type != Typename ) if ( parent && parent->Type != Typename )
{ {
log_failure( "gen::def_struct: parent was not a `Struct` type - %s", parent.debug_str() ); log_failure( "gen::def_struct: parent was not a `Struct` type - %s", debug_str(parent) );
return InvalidCode; return InvalidCode;
} }
if ( body && body->Type != Struct_Body ) if ( body && body->Type != Struct_Body )
{ {
log_failure( "gen::def_struct: body was not a Struct_Body type - %s", body.debug_str() ); log_failure( "gen::def_struct: body was not a Struct_Body type - %s", debug_str(body) );
return InvalidCode; return InvalidCode;
} }
@ -1256,7 +1256,7 @@ CodeTemplate def_template( CodeParam params, Code declaration, ModuleFlag mflags
break; break;
default: default:
log_failure( "gen::def_template: declaration is not of class, function, struct, variable, or using type - %s", declaration.debug_str() ); log_failure( "gen::def_template: declaration is not of class, function, struct, variable, or using type - %s", debug_str(declaration) );
} }
CodeTemplate CodeTemplate
@ -1329,13 +1329,13 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module
case Typename: case Typename:
break; break;
default: default:
log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", type.debug_str() ); log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", debug_str(type) );
return InvalidCode; return InvalidCode;
} }
if ( attributes && attributes->Type != ECode::PlatformAttributes ) if ( attributes && attributes->Type != ECode::PlatformAttributes )
{ {
log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", attributes.debug_str() ); log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", debug_str(attributes) );
return InvalidCode; return InvalidCode;
} }
@ -1359,7 +1359,7 @@ CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, Module
{ {
if (type->Type != Untyped) if (type->Type != Untyped)
{ {
log_failure( "gen::def_typedef: name was empty and type was not untyped (indicating its a function typedef) - %s", type.debug_str() ); log_failure( "gen::def_typedef: name was empty and type was not untyped (indicating its a function typedef) - %s", debug_str(type) );
return InvalidCode; return InvalidCode;
} }
@ -1381,7 +1381,7 @@ CodeUnion def_union( StrC name, Code body, CodeAttributes attributes, ModuleFlag
if ( body->Type != ECode::Union_Body ) if ( body->Type != ECode::Union_Body )
{ {
log_failure( "gen::def_union: body was not a Union_Body type - %s", body.debug_str() ); log_failure( "gen::def_union: body was not a Union_Body type - %s", debug_str(body) );
return InvalidCode; return InvalidCode;
} }
@ -1482,7 +1482,7 @@ CodeVar def_variable( CodeType type, StrC name, Code value
if ( value && value->Type != ECode::Untyped ) if ( value && value->Type != ECode::Untyped )
{ {
log_failure( "gen::def_variable: value was not a `Untyped` type - %s", value.debug_str() ); log_failure( "gen::def_variable: value was not a `Untyped` type - %s", debug_str(value) );
return InvalidCode; return InvalidCode;
} }
@ -1558,7 +1558,7 @@ CodeBody def_class_body( s32 num, ... )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_CLASS_UNALLOWED_TYPES GEN_AST_BODY_CLASS_UNALLOWED_TYPES
log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1595,7 +1595,7 @@ CodeBody def_class_body( s32 num, Code* codes )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_CLASS_UNALLOWED_TYPES GEN_AST_BODY_CLASS_UNALLOWED_TYPES
log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1632,7 +1632,7 @@ CodeBody def_enum_body( s32 num, ... )
if ( entry->Type != Untyped && entry->Type != Comment ) if ( entry->Type != Untyped && entry->Type != Comment )
{ {
log_failure("gen::def_enum_body: Entry type is not allowed - %s. Must be of untyped or comment type.", entry.debug_str() ); log_failure("gen::def_enum_body: Entry type is not allowed - %s. Must be of untyped or comment type.", debug_str(entry) );
return InvalidCode; return InvalidCode;
} }
@ -1664,7 +1664,7 @@ CodeBody def_enum_body( s32 num, Code* codes )
if ( entry->Type != Untyped && entry->Type != Comment ) if ( entry->Type != Untyped && entry->Type != Comment )
{ {
log_failure("gen::def_enum_body: Entry type is not allowed: %s", entry.debug_str() ); log_failure("gen::def_enum_body: Entry type is not allowed: %s", debug_str(entry) );
return InvalidCode; return InvalidCode;
} }
@ -1699,7 +1699,7 @@ CodeBody def_export_body( s32 num, ... )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES GEN_AST_BODY_EXPORT_UNALLOWED_TYPES
log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1736,7 +1736,7 @@ CodeBody def_export_body( s32 num, Code* codes )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES GEN_AST_BODY_EXPORT_UNALLOWED_TYPES
log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1774,7 +1774,7 @@ CodeBody def_extern_link_body( s32 num, ... )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES
log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1811,7 +1811,7 @@ CodeBody def_extern_link_body( s32 num, Code* codes )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES
log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1851,7 +1851,7 @@ CodeBody def_function_body( s32 num, ... )
{ {
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES
log_failure("gen::" stringize(def_function_body) ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" stringize(def_function_body) ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1888,7 +1888,7 @@ CodeBody def_function_body( s32 num, Code* codes )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES
log_failure("gen::" "def_function_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_function_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1925,11 +1925,12 @@ CodeBody def_global_body( s32 num, ... )
switch (entry->Type) switch (entry->Type)
{ {
case Global_Body: case Global_Body:
result.append( entry.code_cast<CodeBody>() ) ; // result.append( entry.code_cast<CodeBody>() ) ;
result.append( cast(CodeBody, entry) ) ;
continue; continue;
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -1966,11 +1967,11 @@ CodeBody def_global_body( s32 num, Code* codes )
switch (entry->Type) switch (entry->Type)
{ {
case Global_Body: case Global_Body:
result.append( entry.code_cast<CodeBody>() ) ; result.append( cast(CodeBody, entry) );
continue; continue;
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -2008,7 +2009,7 @@ CodeBody def_namespace_body( s32 num, ... )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES
log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -2045,7 +2046,7 @@ CodeBody def_namespace_body( s32 num, Code* codes )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES
log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str() ); log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", debug_str(entry) );
return InvalidCode; return InvalidCode;
default: break; default: break;
@ -2217,7 +2218,7 @@ CodeBody def_struct_body( s32 num, ... )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES GEN_AST_BODY_STRUCT_UNALLOWED_TYPES
log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str()); log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", debug_str(entry));
return InvalidCode; return InvalidCode;
default: default:
@ -2254,7 +2255,7 @@ CodeBody def_struct_body( s32 num, Code* codes )
switch (entry->Type) switch (entry->Type)
{ {
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES GEN_AST_BODY_STRUCT_UNALLOWED_TYPES
log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str() ); log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", debug_str(entry) );
return InvalidCode; return InvalidCode;
default: default:
@ -2291,7 +2292,7 @@ CodeBody def_union_body( s32 num, ... )
if ( entry->Type != Untyped && entry->Type != Comment ) if ( entry->Type != Untyped && entry->Type != Comment )
{ {
log_failure("gen::def_union_body: Entry type is not allowed - %s. Must be of untyped or comment type.", entry.debug_str() ); log_failure("gen::def_union_body: Entry type is not allowed - %s. Must be of untyped or comment type.", debug_str(entry) );
return InvalidCode; return InvalidCode;
} }
@ -2323,7 +2324,7 @@ CodeBody def_union_body( s32 num, CodeUnion* codes )
if ( entry->Type != Untyped && entry->Type != Comment ) if ( entry->Type != Untyped && entry->Type != Comment )
{ {
log_failure("gen::def_union_body: Entry type is not allowed: %s", entry.debug_str() ); log_failure("gen::def_union_body: Entry type is not allowed: %s", debug_str(entry) );
return InvalidCode; return InvalidCode;
} }

View File

@ -5067,7 +5067,7 @@ CodeTypedef parse_typedef()
// Type needs to be aware of its parent so that it can be serialized properly. // Type needs to be aware of its parent so that it can be serialized properly.
if ( type->Type == Typename && array_expr && array_expr->Type != Invalid ) if ( type->Type == Typename && array_expr && array_expr->Type != Invalid )
type.code_cast<CodeType>()->ArrExpr = array_expr; cast(CodeType, type)->ArrExpr = array_expr;
if ( inline_cmt ) if ( inline_cmt )
result->InlineCmt = inline_cmt; result->InlineCmt = inline_cmt;