formatting, fixes from testing latest in Odin fork

This commit is contained in:
Edward R. Gonzalez 2024-12-13 11:56:07 -05:00
parent e3172057d3
commit 6ffdca8595
7 changed files with 57 additions and 57 deletions

View File

@ -263,7 +263,7 @@ void code_set_global (Code code);
StrBuilder code_to_string (Code self ); StrBuilder code_to_string (Code self );
void code_to_strbuilder_ptr(Code self, StrBuilder* result ); void code_to_strbuilder_ptr(Code self, StrBuilder* result );
Str code_type_str (Code self ); Str code_type_str (Code self );
bool code_validate_body(Code self ); bool code_validate_body (Code self );
#pragma endregion Code C-Interface #pragma endregion Code C-Interface
@ -305,6 +305,7 @@ struct Code
#endif #endif
Using_CodeOps( Code ); Using_CodeOps( Code );
forceinline Code operator *() { return * this; } // Required for for-range iteration.
forceinline AST* operator ->() { return ast; } forceinline AST* operator ->() { return ast; }
Code& operator ++(); Code& operator ++();

View File

@ -1414,7 +1414,7 @@ void var_to_strbuilder_ref(CodeVar self, StrBuilder* result )
strbuilder_append_fmt( result, "%SB %S", typename_to_string(self->ValueType), self->Name ); strbuilder_append_fmt( result, "%SB %S", typename_to_string(self->ValueType), self->Name );
if ( self->ValueType->ArrExpr ) if ( self->ValueType && self->ValueType->ArrExpr )
{ {
strbuilder_append_fmt( result, "[ %SB ]", code_to_string(self->ValueType->ArrExpr) ); strbuilder_append_fmt( result, "[ %SB ]", code_to_string(self->ValueType->ArrExpr) );

View File

@ -161,9 +161,9 @@ struct CodeBody
forceinline void to_string( StrBuilder& result ) { return body_to_strbuilder_ref(* this, & result ); } forceinline void to_string( StrBuilder& result ) { return body_to_strbuilder_ref(* this, & result ); }
forceinline void to_strbuilder_export( StrBuilder& result ) { return body_to_strbuilder_export(* this, & result); } forceinline void to_strbuilder_export( StrBuilder& result ) { return body_to_strbuilder_export(* this, & result); }
#endif
forceinline Code begin() { return begin_CodeBody(* this); } forceinline Code begin() { return begin_CodeBody(* this); }
forceinline Code end() { return end_CodeBody(* this); } forceinline Code end() { return end_CodeBody(* this); }
#endif
Using_CodeOps( CodeBody ); Using_CodeOps( CodeBody );
forceinline operator Code() { return * rcast( Code*, this ); } forceinline operator Code() { return * rcast( Code*, this ); }
forceinline AST_Body* operator->() { return ast; } forceinline AST_Body* operator->() { return ast; }

View File

@ -64,7 +64,7 @@ inline AST_Attributes* CodeAttributes::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -95,7 +95,7 @@ inline AST_Comment* CodeComment::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -126,7 +126,7 @@ inline AST_Constructor* CodeConstructor::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -173,7 +173,7 @@ inline AST_Define* CodeDefine::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -204,7 +204,7 @@ inline AST_Destructor* CodeDestructor::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -235,7 +235,7 @@ inline AST_Enum* CodeEnum::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -266,7 +266,7 @@ inline AST_Exec* CodeExec::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -297,7 +297,7 @@ inline AST_Extern* CodeExtern::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -328,7 +328,7 @@ inline AST_Friend* CodeFriend::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -359,7 +359,7 @@ inline AST_Fn* CodeFn::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -390,7 +390,7 @@ inline AST_Include* CodeInclude::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -421,7 +421,7 @@ inline AST_Module* CodeModule::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -452,7 +452,7 @@ inline AST_NS* CodeNS::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -483,7 +483,7 @@ inline AST_Operator* CodeOperator::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -514,7 +514,7 @@ inline AST_OpCast* CodeOpCast::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -561,7 +561,7 @@ inline AST_Pragma* CodePragma::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -592,7 +592,7 @@ inline AST_PreprocessCond* CodePreprocessCond::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -655,7 +655,7 @@ inline AST_Template* CodeTemplate::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -686,7 +686,7 @@ inline AST_Typename* CodeTypename::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -717,7 +717,7 @@ inline AST_Typedef* CodeTypedef::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -748,7 +748,7 @@ inline AST_Union* CodeUnion::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -779,7 +779,7 @@ inline AST_Using* CodeUsing::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;
@ -810,7 +810,7 @@ inline AST_Var* CodeVar::operator->()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;

View File

@ -124,7 +124,7 @@ bool lex__eat(TokArray* self, TokType type )
, tok.Column , tok.Column
, parser_to_string(Context) , parser_to_string(Context)
); );
GEN_DEBUG_TRAP();
return false; return false;
} }
@ -515,7 +515,7 @@ Code parse_array_decl()
if ( check( Tok_Operator ) && currtok.Text[0] == '[' && currtok.Text[1] == ']' ) if ( check( Tok_Operator ) && currtok.Text[0] == '[' && currtok.Text[1] == ']' )
{ {
Code array_expr = untyped_str( tok_to_str(currtok) ); Code array_expr = untyped_str( txt(" ") );
eat( Tok_Operator ); eat( Tok_Operator );
// [] // []
@ -2391,7 +2391,7 @@ CodeOperator parse_operator_after_ret_type(
case '<': case '<':
{ {
if ( currtok.Text[1] == '=' ) if ( currtok.Text[1] == '=' )
op = Op_LEqual; op = Op_LesserEqual;
else if ( currtok.Text[1] == '<' ) else if ( currtok.Text[1] == '<' )
{ {
@ -3428,12 +3428,12 @@ CodeVar parse_variable_declaration_list()
break; break;
} }
// eat(currtok.Type);
if ( specifiers ) if ( specifiers )
specifiers_append(specifiers, spec ); specifiers_append(specifiers, spec );
else else
specifiers = def_specifier( spec ); specifiers = def_specifier( spec );
eat(currtok.Type);
} }
// , <Specifiers> // , <Specifiers>

View File

@ -505,7 +505,7 @@ CodeBody gen_ast_inlines()
{ {
if ( ast == nullptr ) if ( ast == nullptr )
{ {
log_failure( "Attempt to dereference a nullptr!" ); log_failure( "Attempt to dereference a nullptr!\n" );
return nullptr; return nullptr;
} }
return ast; return ast;

View File

@ -176,9 +176,9 @@ int gen_main()
Code timing = scan_file( path_base "dependencies/timing.cpp" ); Code timing = scan_file( path_base "dependencies/timing.cpp" );
header.print_fmt( roll_own_dependencies_guard_start ); header.print_fmt( roll_own_dependencies_guard_start );
header.print( impl_start );
header.print_fmt( "GEN_NS_BEGIN\n\n"); header.print_fmt( "GEN_NS_BEGIN\n\n");
header.print( impl_start );
header.print( debug ); header.print( debug );
header.print( string_ops ); header.print( string_ops );
header.print( printing ); header.print( printing );
@ -210,7 +210,6 @@ int gen_main()
Code untyped = scan_file( path_base "components/interface.untyped.cpp" ); Code untyped = scan_file( path_base "components/interface.untyped.cpp" );
CodeBody etoktype = gen_etoktype( path_base "enums/ETokType.csv", path_base "enums/AttributeTokens.csv" ); CodeBody etoktype = gen_etoktype( path_base "enums/ETokType.csv", path_base "enums/AttributeTokens.csv" );
CodeNS parser_nspace = def_namespace( name(parser), def_namespace_body( args(etoktype)) );
header.print_fmt( "\nGEN_NS_BEGIN\n"); header.print_fmt( "\nGEN_NS_BEGIN\n");
header.print( static_data ); header.print( static_data );
@ -225,7 +224,7 @@ int gen_main()
header.print( interface ); header.print( interface );
header.print( upfront ); header.print( upfront );
header.print_fmt( "\n#pragma region Parsing\n\n" ); header.print_fmt( "\n#pragma region Parsing\n\n" );
header.print( format(parser_nspace) ); header.print( format(etoktype) );
header.print( lexer ); header.print( lexer );
header.print( parser ); header.print( parser );
header.print( parsing_interface ); header.print( parsing_interface );