diff --git a/.vscode/bookmarks.json b/.vscode/bookmarks.json deleted file mode 100644 index e69de29..0000000 diff --git a/base/Readme.md b/base/Readme.md index 5bbe56c..1175e1e 100644 --- a/base/Readme.md +++ b/base/Readme.md @@ -148,7 +148,7 @@ The convention you'll see used throughout the upfront interface of the library i 1. Check name or parameters to make sure they are valid for the construction requested 2. Create a code object using `make_code`. 3. Populate immediate fields (Name, Type, ModuleFlags, etc) -4. Populate sub-entires using `add_entry`. If using the default serialization function `to_string`, follow the order at which entires are expected to appear (there is a strong ordering expected). +4. Populate sub-entires using `add_entry`. If using the default serialization function `to_strbuilder`, follow the order at which entires are expected to appear (there is a strong ordering expected). Names or Content fields are interned strings and thus showed be cached using `get_cached_string` if its desired to preserve that behavior. diff --git a/base/auxillary/builder.cpp b/base/auxillary/builder.cpp index eb5e931..d7797f2 100644 --- a/base/auxillary/builder.cpp +++ b/base/auxillary/builder.cpp @@ -15,7 +15,7 @@ Builder builder_open( char const* path ) return result; } - result.Buffer = string_make_reserve( GlobalAllocator, Builder_StrBufferReserve ); + result.Buffer = strbuilder_make_reserve( GlobalAllocator, Builder_StrBufferReserve ); // log_fmt("$Builder - Opened file: %s\n", result.File.filename ); return result; @@ -23,15 +23,15 @@ Builder builder_open( char const* path ) void builder_pad_lines( Builder* builder, s32 num ) { - string_append_strc( & builder->Buffer, txt("\n") ); + strbuilder_append_str( & builder->Buffer, txt("\n") ); } void builder_print( Builder* builder, Code code ) { - String str = code_to_string(code); + StrBuilder str = code_to_strbuilder(code); // const ssize len = str.length(); // log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data ); - string_append_string( & builder->Buffer, str ); + strbuilder_append_string( & builder->Buffer, str ); } void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va ) @@ -39,21 +39,21 @@ void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va ) ssize res; char buf[ GEN_PRINTF_MAXLEN ] = { 0 }; - res = str_fmt_va( buf, count_of( buf ) - 1, fmt, va ) - 1; + res = c_str_fmt_va( buf, count_of( buf ) - 1, fmt, va ) - 1; - string_append_c_str_len( (String*) & (builder->Buffer), (char const*)buf, res); + strbuilder_append_c_str_len( (StrBuilder*) & (builder->Buffer), (char const*)buf, res); } void builder_write(Builder* builder) { - b32 result = file_write( & builder->File, builder->Buffer, string_length(builder->Buffer) ); + b32 result = file_write( & builder->File, builder->Buffer, strbuilder_length(builder->Buffer) ); if ( result == false ) log_failure("gen::File::write - Failed to write to file: %s\n", file_name( & builder->File ) ); log_fmt( "Generated: %s\n", builder->File.filename ); file_close( & builder->File ); - string_free(& builder->Buffer); + strbuilder_free(& builder->Buffer); } #pragma endregion Builder diff --git a/base/auxillary/builder.hpp b/base/auxillary/builder.hpp index 3c37fba..1de05c3 100644 --- a/base/auxillary/builder.hpp +++ b/base/auxillary/builder.hpp @@ -36,7 +36,7 @@ void builder_write( Builder* builder ); struct Builder { FileInfo File; - String Buffer; + StrBuilder Buffer; #if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP forceinline static Builder open( char const* path ) { return builder_open(path); } diff --git a/base/auxillary/gen_template.hpp b/base/auxillary/gen_template.hpp index 101f7de..d64dcc2 100644 --- a/base/auxillary/gen_template.hpp +++ b/base/auxillary/gen_template.hpp @@ -32,4 +32,4 @@ CodeFn gen_func_template( CodeTemplate template, ... ); Code gen_class_struct_template( CodeTemplate template, ... ); Code gen_template( CodeTemplate template, ... ); -Code gen_template( StrC template, StrC instantiation ); +Code gen_template( Str template, Str instantiation ); diff --git a/base/auxillary/scanner.cpp b/base/auxillary/scanner.cpp index 70b12f3..0ac23a3 100644 --- a/base/auxillary/scanner.cpp +++ b/base/auxillary/scanner.cpp @@ -20,9 +20,9 @@ Code scan_file( char const* path ) GEN_FATAL("scan_file: %s is empty", path ); } - String str = string_make_reserve( GlobalAllocator, fsize ); + StrBuilder str = strbuilder_make_reserve( GlobalAllocator, fsize ); file_read( & file, str, fsize ); - string_get_header(str)->Length = fsize; + strbuilder_get_header(str)->Length = fsize; // Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks // Its designed so that the directive should be the first thing in the file. @@ -31,9 +31,9 @@ Code scan_file( char const* path ) #define current (*scanner) #define matched 0 #define move_fwd() do { ++ scanner; -- left; } while (0) - const StrC directive_start = txt( "ifdef" ); - const StrC directive_end = txt( "endif" ); - const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); + const Str directive_start = txt( "ifdef" ); + const Str directive_end = txt( "endif" ); + const Str def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); bool found_directive = false; char const* scanner = (char const*)str; @@ -49,7 +49,7 @@ Code scan_file( char const* path ) if ( ! found_directive ) { - if ( left && str_compare_len( scanner, directive_start.Ptr, directive_start.Len ) == matched ) + if ( left && c_str_compare_len( scanner, directive_start.Ptr, directive_start.Len ) == matched ) { scanner += directive_start.Len; left -= directive_start.Len; @@ -57,7 +57,7 @@ Code scan_file( char const* path ) while ( left && char_is_space( current ) ) move_fwd(); - if ( left && str_compare_len( scanner, def_intellisense.Ptr, def_intellisense.Len ) == matched ) + if ( left && c_str_compare_len( scanner, def_intellisense.Ptr, def_intellisense.Len ) == matched ) { scanner += def_intellisense.Len; left -= def_intellisense.Len; @@ -77,7 +77,7 @@ Code scan_file( char const* path ) continue; } - if ( left && str_compare_len( scanner, directive_end.Ptr, directive_end.Len ) == matched ) + if ( left && c_str_compare_len( scanner, directive_end.Ptr, directive_end.Len ) == matched ) { scanner += directive_end.Len; left -= directive_end.Len; @@ -94,12 +94,12 @@ Code scan_file( char const* path ) if ( (scanner + 2) >= ( (char const*) str + fsize ) ) { mem_move( str, scanner, left ); - string_get_header(str)->Length = left; + strbuilder_get_header(str)->Length = left; break; } mem_move( str, scanner, left ); - string_get_header(str)->Length = left; + strbuilder_get_header(str)->Length = left; break; } @@ -113,12 +113,12 @@ Code scan_file( char const* path ) } file_close( & file ); - return untyped_str( string_to_strc(str) ); + return untyped_str( strbuilder_to_str(str) ); } CodeBody parse_file( const char* path ) { FileContents file = file_read_contents( GlobalAllocator, true, path ); - StrC content = { file.size, (char const*)file.data }; + Str content = { (char const*)file.data, file.size }; CodeBody code = parse_global_body( content ); log_fmt("\nParsed: %s\n", path); return code; diff --git a/base/base.cpp b/base/base.cpp index e1d5c1a..8701ad4 100644 --- a/base/base.cpp +++ b/base/base.cpp @@ -35,12 +35,13 @@ int gen_main() def_include(txt("components/types.hpp")), preprocess_endif, fmt_newline, - untyped_str( to_strc_from_c_str(generation_notice) ) + untyped_str( to_str_from_c_str(generation_notice) ) )); CodeBody ecode = gen_ecode ( "enums/ECodeTypes.csv" ); CodeBody eoperator = gen_eoperator ( "enums/EOperator.csv" ); CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" ); + CodeBody etoktype = gen_etoktype ( "enums/ETokType.csv", "enums/AttributeTokens.csv" ); CodeBody ast_inlines = gen_ast_inlines(); Builder header_ecode = builder_open( "components/gen/ecodetypes.hpp" ); @@ -57,6 +58,11 @@ int gen_main() builder_print( & header_especifier, gen_component_header ); builder_print( & header_especifier, format(especifier) ); builder_write( & header_especifier); + + Builder header_etoktype = builder_open( "components/gen/etoktype.cpp" ); + builder_print( & header_etoktype, gen_component_header ); + builder_print( & header_etoktype, format(etoktype) ); + builder_write( & header_etoktype); Builder header_ast_inlines = builder_open( "components/gen/ast_inlines.hpp" ); builder_print( & header_ast_inlines, gen_component_header ); diff --git a/base/components/ast.cpp b/base/components/ast.cpp index 1d83489..75bd779 100644 --- a/base/components/ast.cpp +++ b/base/components/ast.cpp @@ -7,20 +7,20 @@ 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. -StrC code_debug_str(Code self) +Str code_debug_str(Code self) { GEN_ASSERT(self != nullptr); - String result_stack = string_make_reserve( GlobalAllocator, kilobytes(1) ); - String* result = & result_stack; + StrBuilder result_stack = strbuilder_make_reserve( GlobalAllocator, kilobytes(1) ); + StrBuilder* result = & result_stack; if ( self->Parent ) - string_append_fmt( result, "\n\tParent : %SC %SC", code_type_str(self->Parent), self->Name.Len ? self->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParent : %S %S", code_type_str(self->Parent), self->Name.Len ? self->Name : txt("Null") ); else - string_append_fmt( result, "\n\tParent : %SC", txt("Null") ); + strbuilder_append_fmt( result, "\n\tParent : %S", txt("Null") ); - string_append_fmt( result, "\n\tName : %SC", self->Name.Len ? self->Name : txt("Null") ); - string_append_fmt( result, "\n\tType : %SC", code_type_str(self) ); - string_append_fmt( result, "\n\tModule Flags : %SC", module_flag_to_str( self->ModuleFlags ) ); + strbuilder_append_fmt( result, "\n\tName : %S", self->Name.Len ? self->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tType : %S", code_type_str(self) ); + strbuilder_append_fmt( result, "\n\tModule Flags : %S", module_flag_to_str( self->ModuleFlags ) ); switch ( self->Type ) { @@ -30,9 +30,9 @@ StrC code_debug_str(Code self) case CT_Access_Protected: case CT_Access_Public: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); break; case CT_Untyped: @@ -48,74 +48,74 @@ StrC code_debug_str(Code self) case CT_Preprocess_IfDef: case CT_Preprocess_IfNotDef: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tContent: %SC", self->Content ); + strbuilder_append_fmt( result, "\n\tContent: %S", self->Content ); break; case CT_Class: case CT_Struct: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes : %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tParentAccess: %SC", self->ParentType ? access_spec_to_str( self->ParentAccess ) : txt("No Parent") ); - string_append_fmt( result, "\n\tParentType : %SC", self->ParentType ? code_type_str(self->ParentType) : txt("Null") ); - string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParentAccess: %S", self->ParentType ? access_spec_to_str( self->ParentAccess ) : txt("No Parent") ); + strbuilder_append_fmt( result, "\n\tParentType : %S", self->ParentType ? code_type_str(self->ParentType) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); break; case CT_Class_Fwd: case CT_Struct_Fwd: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes : %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tParentAccess: %SC", self->ParentType ? access_spec_to_str( self->ParentAccess ) : txt("No Parent") ); - string_append_fmt( result, "\n\tParentType : %SC", self->ParentType ? code_type_str(self->ParentType) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParentAccess: %S", self->ParentType ? access_spec_to_str( self->ParentAccess ) : txt("No Parent") ); + strbuilder_append_fmt( result, "\n\tParentType : %S", self->ParentType ? code_type_str(self->ParentType) : txt("Null") ); break; case CT_Constructor: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs) ) : txt("Null") ); - string_append_fmt( result, "\n\tInitializerList: %SC", self->InitializerList ? string_to_strc( code_to_string(self->InitializerList) ) : txt("Null") ); - string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params) ) : txt("Null") ); - string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInitializerList: %S", self->InitializerList ? strbuilder_to_str( code_to_strbuilder(self->InitializerList) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); break; case CT_Constructor_Fwd: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs) ) : txt("Null") ); - string_append_fmt( result, "\n\tInitializerList: %SC", self->InitializerList ? string_to_strc( code_to_string(self->InitializerList) ) : txt("Null") ); - string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInitializerList: %S", self->InitializerList ? strbuilder_to_str( code_to_strbuilder(self->InitializerList) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params) ) : txt("Null") ); break; case CT_Destructor: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs) ) : txt("Null") ); - string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); break; case CT_Destructor_Fwd: @@ -124,208 +124,208 @@ StrC code_debug_str(Code self) case CT_Enum: case CT_Enum_Class: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes : %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tUnderlying Type : %SC", self->UnderlyingType ? string_to_strc( code_to_string(self->UnderlyingType)) : txt("Null") ); - string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tUnderlying Type : %S", self->UnderlyingType ? strbuilder_to_str( code_to_strbuilder(self->UnderlyingType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); break; case CT_Enum_Fwd: case CT_Enum_Class_Fwd: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes : %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tUnderlying Type : %SC", self->UnderlyingType ? string_to_strc( code_to_string(self->UnderlyingType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tUnderlying Type : %S", self->UnderlyingType ? strbuilder_to_str( code_to_strbuilder(self->UnderlyingType)) : txt("Null") ); break; case CT_Extern_Linkage: case CT_Namespace: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tBody: %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody: %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); break; case CT_Friend: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tDeclaration: %SC", self->Declaration ? string_to_strc( code_to_string(self->Declaration)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? strbuilder_to_str( code_to_strbuilder(self->Declaration)) : txt("Null") ); break; case CT_Function: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes: %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs)) : txt("Null") ); - string_append_fmt( result, "\n\tReturnType: %SC", self->ReturnType ? string_to_strc( code_to_string(self->ReturnType)) : txt("Null") ); - string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params)) : txt("Null") ); - string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tReturnType: %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); break; case CT_Function_Fwd: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes: %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs)) : txt("Null") ); - string_append_fmt( result, "\n\tReturnType: %SC", self->ReturnType ? string_to_strc( code_to_string(self->ReturnType)) : txt("Null") ); - string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tReturnType: %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") ); break; case CT_Module: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); break; case CT_Operator: case CT_Operator_Member: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes: %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs)) : txt("Null") ); - string_append_fmt( result, "\n\tReturnType: %SC", self->ReturnType ? string_to_strc( code_to_string(self->ReturnType)) : txt("Null") ); - string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params)) : txt("Null") ); - string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); - string_append_fmt( result, "\n\tOp : %SC", operator_to_str( self->Op ) ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tReturnType: %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tOp : %S", operator_to_str( self->Op ) ); break; case CT_Operator_Fwd: case CT_Operator_Member_Fwd: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes: %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs) ) : txt("Null") ); - string_append_fmt( result, "\n\tReturnType: %SC", self->ReturnType ? string_to_strc( code_to_string(self->ReturnType) ) : txt("Null") ); - string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params) ) : txt("Null") ); - string_append_fmt( result, "\n\tOp : %SC", operator_to_str( self->Op ) ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tReturnType: %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tOp : %S", operator_to_str( self->Op ) ); break; case CT_Operator_Cast: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs)) : txt("Null") ); - string_append_fmt( result, "\n\tValueType : %SC", self->ValueType ? string_to_strc( code_to_string(self->ValueType)) : txt("Null") ); - string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tValueType : %S", self->ValueType ? strbuilder_to_str( code_to_strbuilder(self->ValueType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); break; case CT_Operator_Cast_Fwd: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs)) : txt("Null") ); - string_append_fmt( result, "\n\tValueType : %SC", self->ValueType ? string_to_strc( code_to_string(self->ValueType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tValueType : %S", self->ValueType ? strbuilder_to_str( code_to_strbuilder(self->ValueType)) : txt("Null") ); break; case CT_Parameters: - string_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries ); - string_append_fmt( result, "\n\tLast : %SC", self->Last->Name ); - string_append_fmt( result, "\n\tNext : %SC", self->Next->Name ); - string_append_fmt( result, "\n\tValueType : %SC", self->ValueType ? string_to_strc( code_to_string(self->ValueType)) : txt("Null") ); - string_append_fmt( result, "\n\tValue : %SC", self->Value ? string_to_strc( code_to_string(self->Value)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries ); + strbuilder_append_fmt( result, "\n\tLast : %S", self->Last->Name ); + strbuilder_append_fmt( result, "\n\tNext : %S", self->Next->Name ); + strbuilder_append_fmt( result, "\n\tValueType : %S", self->ValueType ? strbuilder_to_str( code_to_strbuilder(self->ValueType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tValue : %S", self->Value ? strbuilder_to_str( code_to_strbuilder(self->Value)) : txt("Null") ); break; case CT_Specifiers: { - string_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries ); - string_append_strc( result, txt("\n\tArrSpecs: ") ); + strbuilder_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries ); + strbuilder_append_str( result, txt("\n\tArrSpecs: ") ); s32 idx = 0; s32 left = self->NumEntries; while ( left-- ) { - StrC spec = spec_to_str( self->ArrSpecs[idx] ); - string_append_fmt( result, "%.*s, ", spec.Len, spec.Ptr ); + Str spec = spec_to_str( self->ArrSpecs[idx] ); + strbuilder_append_fmt( result, "%.*s, ", spec.Len, spec.Ptr ); idx++; } - string_append_fmt( result, "\n\tNextSpecs: %SC", self->NextSpecs ? code_debug_str(self->NextSpecs) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNextSpecs: %S", self->NextSpecs ? code_debug_str(self->NextSpecs) : txt("Null") ); } break; case CT_Template: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params)) : txt("Null") ); - string_append_fmt( result, "\n\tDeclaration: %SC", self->Declaration ? string_to_strc( code_to_string(self->Declaration)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? strbuilder_to_str( code_to_strbuilder(self->Declaration)) : txt("Null") ); break; case CT_Typedef: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tUnderlyingType: %SC", self->UnderlyingType ? string_to_strc( code_to_string(self->UnderlyingType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? strbuilder_to_str( code_to_strbuilder(self->UnderlyingType)) : txt("Null") ); break; case CT_Typename: - string_append_fmt( result, "\n\tAttributes : %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs)) : txt("Null") ); - string_append_fmt( result, "\n\tReturnType : %SC", self->ReturnType ? string_to_strc( code_to_string(self->ReturnType)) : txt("Null") ); - string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params)) : txt("Null") ); - string_append_fmt( result, "\n\tArrExpr : %SC", self->ArrExpr ? string_to_strc( code_to_string(self->ArrExpr)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tReturnType : %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tArrExpr : %S", self->ArrExpr ? strbuilder_to_str( code_to_strbuilder(self->ArrExpr)) : txt("Null") ); break; case CT_Union: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tAttributes: %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") ); break; case CT_Using: if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes : %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tUnderlyingType: %SC", self->UnderlyingType ? string_to_strc( code_to_string(self->UnderlyingType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? strbuilder_to_str( code_to_strbuilder(self->UnderlyingType)) : txt("Null") ); break; case CT_Variable: @@ -333,29 +333,29 @@ StrC code_debug_str(Code self) if ( self->Parent && self->Parent->Type == CT_Variable ) { // Its a NextVar - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs)) : txt("Null") ); - string_append_fmt( result, "\n\tValue : %SC", self->Value ? string_to_strc( code_to_string(self->Value)) : txt("Null") ); - string_append_fmt( result, "\n\tBitfieldSize: %SC", self->BitfieldSize ? string_to_strc( code_to_string(self->BitfieldSize)) : txt("Null") ); - string_append_fmt( result, "\n\tNextVar : %SC", self->NextVar ? code_debug_str(self->NextVar) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tValue : %S", self->Value ? strbuilder_to_str( code_to_strbuilder(self->Value)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBitfieldSize: %S", self->BitfieldSize ? strbuilder_to_str( code_to_strbuilder(self->BitfieldSize)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNextVar : %S", self->NextVar ? code_debug_str(self->NextVar) : txt("Null") ); break; } if ( self->Prev ) - string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); if ( self->Next ) - string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") ); - string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); - string_append_fmt( result, "\n\tAttributes : %SC", self->Attributes ? string_to_strc( code_to_string(self->Attributes) ) : txt("Null") ); - string_append_fmt( result, "\n\tSpecs : %SC", self->Specs ? string_to_strc( code_to_string(self->Specs)) : txt("Null") ); - string_append_fmt( result, "\n\tValueType : %SC", self->ValueType ? string_to_strc( code_to_string(self->ValueType)) : txt("Null") ); - string_append_fmt( result, "\n\tBitfieldSize: %SC", self->BitfieldSize ? string_to_strc( code_to_string(self->BitfieldSize)) : txt("Null") ); - string_append_fmt( result, "\n\tValue : %SC", self->Value ? string_to_strc( code_to_string(self->Value)) : txt("Null") ); - string_append_fmt( result, "\n\tNextVar : %SC", self->NextVar ? code_debug_str(self->NextVar) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") ); + strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tValueType : %S", self->ValueType ? strbuilder_to_str( code_to_strbuilder(self->ValueType)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tBitfieldSize: %S", self->BitfieldSize ? strbuilder_to_str( code_to_strbuilder(self->BitfieldSize)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tValue : %S", self->Value ? strbuilder_to_str( code_to_strbuilder(self->Value)) : txt("Null") ); + strbuilder_append_fmt( result, "\n\tNextVar : %S", self->NextVar ? code_debug_str(self->NextVar) : txt("Null") ); break; } - return string_to_strc( * result ); + return strbuilder_to_str( * result ); } Code code_duplicate(Code self) @@ -370,14 +370,14 @@ Code code_duplicate(Code self) return result; } -String code_to_string(Code self) +StrBuilder code_to_strbuilder(Code self) { - String result = string_make_strc( GlobalAllocator, txt("") ); - code_to_string_ptr( self, & result ); + StrBuilder result = strbuilder_make_str( GlobalAllocator, txt("") ); + code_to_strbuilder_ptr( self, & result ); return result; } -void code_to_string_ptr( Code self, String* result ) +void code_to_strbuilder_ptr( Code self, StrBuilder* result ) { GEN_ASSERT(self != nullptr); local_persist thread_local @@ -387,197 +387,197 @@ void code_to_string_ptr( Code self, String* result ) { case CT_Invalid: #ifdef GEN_DONT_ALLOW_INVALID_CODE - log_failure("Attempted to serialize invalid code! - %SC", Parent ? Parent->code_debug_str() : Name ); + log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->code_debug_str() : Name ); #else - string_append_fmt( result, "Invalid Code!" ); + strbuilder_append_fmt( result, "Invalid Code!" ); #endif break; case CT_NewLine: - string_append_strc( result, txt("\n")); + strbuilder_append_str( result, txt("\n")); break; case CT_Untyped: case CT_Execution: case CT_Comment: case CT_PlatformAttributes: - string_append_strc( result, self->Content ); + strbuilder_append_str( result, self->Content ); break; case CT_Access_Private: case CT_Access_Protected: case CT_Access_Public: - string_append_strc( result, self->Name ); + strbuilder_append_str( result, self->Name ); break; case CT_Class: - class_to_string_def(cast(CodeClass, self), result ); + class_to_strbuilder_def(cast(CodeClass, self), result ); break; case CT_Class_Fwd: - class_to_string_fwd(cast(CodeClass, self), result ); + class_to_strbuilder_fwd(cast(CodeClass, self), result ); break; case CT_Constructor: - constructor_to_string_def(cast(CodeConstructor, self), result ); + constructor_to_strbuilder_def(cast(CodeConstructor, self), result ); break; case CT_Constructor_Fwd: - constructor_to_string_fwd(cast(CodeConstructor, self), result ); + constructor_to_strbuilder_fwd(cast(CodeConstructor, self), result ); break; case CT_Destructor: - destructor_to_string_def(cast(CodeDestructor, self), result ); + destructor_to_strbuilder_def(cast(CodeDestructor, self), result ); break; case CT_Destructor_Fwd: - destructor_to_string_fwd(cast(CodeDestructor, self), result ); + destructor_to_strbuilder_fwd(cast(CodeDestructor, self), result ); break; case CT_Enum: - enum_to_string_def(cast(CodeEnum, self), result ); + enum_to_strbuilder_def(cast(CodeEnum, self), result ); break; case CT_Enum_Fwd: - enum_to_string_fwd(cast(CodeEnum, self), result ); + enum_to_strbuilder_fwd(cast(CodeEnum, self), result ); break; case CT_Enum_Class: - enum_to_string_class_def(cast(CodeEnum, self), result ); + enum_to_strbuilder_class_def(cast(CodeEnum, self), result ); break; case CT_Enum_Class_Fwd: - enum_to_string_class_fwd(cast(CodeEnum, self), result ); + enum_to_strbuilder_class_fwd(cast(CodeEnum, self), result ); break; case CT_Export_Body: - body_to_string_export(cast(CodeBody, self), result ); + body_to_strbuilder_export(cast(CodeBody, self), result ); break; case CT_Extern_Linkage: - extern_to_string(cast(CodeExtern, self), result ); + extern_to_strbuilder(cast(CodeExtern, self), result ); break; case CT_Friend: - friend_to_string_ref(cast(CodeFriend, self), result ); + friend_to_strbuilder_ref(cast(CodeFriend, self), result ); break; case CT_Function: - fn_to_string_def(cast(CodeFn, self), result ); + fn_to_strbuilder_def(cast(CodeFn, self), result ); break; case CT_Function_Fwd: - fn_to_string_fwd(cast(CodeFn, self), result ); + fn_to_strbuilder_fwd(cast(CodeFn, self), result ); break; case CT_Module: - module_to_string_ref(cast(CodeModule, self), result ); + module_to_strbuilder_ref(cast(CodeModule, self), result ); break; case CT_Namespace: - namespace_to_string_ref(cast(CodeNS, self), result ); + namespace_to_strbuilder_ref(cast(CodeNS, self), result ); break; case CT_Operator: case CT_Operator_Member: - code_op_to_string_def(cast(CodeOperator, self), result ); + code_op_to_strbuilder_def(cast(CodeOperator, self), result ); break; case CT_Operator_Fwd: case CT_Operator_Member_Fwd: - code_op_to_string_fwd(cast(CodeOperator, self), result ); + code_op_to_strbuilder_fwd(cast(CodeOperator, self), result ); break; case CT_Operator_Cast: - opcast_to_string_def(cast(CodeOpCast, self), result ); + opcast_to_strbuilder_def(cast(CodeOpCast, self), result ); break; case CT_Operator_Cast_Fwd: - opcast_to_string_fwd(cast(CodeOpCast, self), result ); + opcast_to_strbuilder_fwd(cast(CodeOpCast, self), result ); break; case CT_Parameters: - params_to_string_ref(cast(CodeParams, self), result ); + params_to_strbuilder_ref(cast(CodeParams, self), result ); break; case CT_Preprocess_Define: - define_to_string_ref(cast(CodeDefine, self), result ); + define_to_strbuilder_ref(cast(CodeDefine, self), result ); break; case CT_Preprocess_If: - preprocess_to_string_if(cast(CodePreprocessCond, self), result ); + preprocess_to_strbuilder_if(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_IfDef: - preprocess_to_string_ifdef(cast(CodePreprocessCond, self), result ); + preprocess_to_strbuilder_ifdef(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_IfNotDef: - preprocess_to_string_ifndef(cast(CodePreprocessCond, self), result ); + preprocess_to_strbuilder_ifndef(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_Include: - include_to_string_ref(cast(CodeInclude, self), result ); + include_to_strbuilder_ref(cast(CodeInclude, self), result ); break; case CT_Preprocess_ElIf: - preprocess_to_string_elif(cast(CodePreprocessCond, self), result ); + preprocess_to_strbuilder_elif(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_Else: - preprocess_to_string_else(cast(CodePreprocessCond, self), result ); + preprocess_to_strbuilder_else(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_EndIf: - preprocess_to_string_endif(cast(CodePreprocessCond, self), result ); + preprocess_to_strbuilder_endif(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_Pragma: - pragma_to_string_ref(cast(CodePragma, self), result ); + pragma_to_strbuilder_ref(cast(CodePragma, self), result ); break; case CT_Specifiers: - specifiers_to_string_ref(cast(CodeSpecifiers, self), result ); + specifiers_to_strbuilder_ref(cast(CodeSpecifiers, self), result ); break; case CT_Struct: - struct_to_string_def(cast(CodeStruct, self), result ); + struct_to_strbuilder_def(cast(CodeStruct, self), result ); break; case CT_Struct_Fwd: - struct_to_string_fwd(cast(CodeStruct, self), result ); + struct_to_strbuilder_fwd(cast(CodeStruct, self), result ); break; case CT_Template: - template_to_string_ref(cast(CodeTemplate, self), result ); + template_to_strbuilder_ref(cast(CodeTemplate, self), result ); break; case CT_Typedef: - typedef_to_string_ref(cast(CodeTypedef, self), result ); + typedef_to_strbuilder_ref(cast(CodeTypedef, self), result ); break; case CT_Typename: - typename_to_string_ref(cast(CodeTypename, self), result ); + typename_to_strbuilder_ref(cast(CodeTypename, self), result ); break; case CT_Union: - union_to_string_def( cast(CodeUnion, self), result ); + union_to_strbuilder_def( cast(CodeUnion, self), result ); break; case CT_Union_Fwd: - union_to_string_fwd( cast(CodeUnion, self), result ); + union_to_strbuilder_fwd( cast(CodeUnion, self), result ); break; case CT_Using: - using_to_string_ref(cast(CodeUsing, self), result ); + using_to_strbuilder_ref(cast(CodeUsing, self), result ); break; case CT_Using_Namespace: - using_to_string_ns(cast(CodeUsing, self), result ); + using_to_strbuilder_ns(cast(CodeUsing, self), result ); break; case CT_Variable: - var_to_string_ref(cast(CodeVar, self), result ); + var_to_strbuilder_ref(cast(CodeVar, self), result ); break; case CT_Enum_Body: @@ -588,7 +588,7 @@ void code_to_string_ptr( Code self, String* result ) case CT_Namespace_Body: case CT_Struct_Body: case CT_Union_Body: - body_to_string_ref( cast(CodeBody, self), result ); + body_to_strbuilder_ref( cast(CodeBody, self), result ); break; } } @@ -604,13 +604,13 @@ bool code_is_equal( Code self, Code other ) */ if ( other == nullptr ) { - log_fmt( "AST::is_equal: other is null\nAST: %SC", code_debug_str(self) ); + log_fmt( "AST::is_equal: other is null\nAST: %S", code_debug_str(self) ); return false; } if ( self->Type != other->Type ) { - log_fmt("AST::is_equal: Type check failure with other\nAST: %SC\nOther: %SC" + log_fmt("AST::is_equal: Type check failure with other\nAST: %S\nOther: %S" , code_debug_str(self) ,code_debug_str(other) ); @@ -624,8 +624,8 @@ bool code_is_equal( Code self, Code other ) if ( self->val != other->val ) \ { \ log_fmt("\nAST::is_equal: Member - " #val " failed\n" \ - "AST : %SC\n" \ - "Other: %SC\n" \ + "AST : %S\n" \ + "Other: %S\n" \ , code_debug_str(self) \ ,code_debug_str(other) \ ); \ @@ -634,11 +634,11 @@ bool code_is_equal( Code self, Code other ) } #define check_member_str( str ) \ - if ( ! strc_are_equal( self->str, other->str ) ) \ + if ( ! str_are_equal( self->str, other->str ) ) \ { \ log_fmt("\nAST::is_equal: Member string - "#str " failed\n" \ - "AST : %SC\n" \ - "Other: %SC\n" \ + "AST : %S\n" \ + "Other: %S\n" \ , code_debug_str(self) \ ,code_debug_str(other) \ ); \ @@ -647,21 +647,21 @@ bool code_is_equal( Code self, Code other ) } #define check_member_content( content ) \ - if ( ! strc_are_equal( self->content, other->content )) \ + if ( ! str_are_equal( self->content, other->content )) \ { \ log_fmt("\nAST::is_equal: Member content - "#content " failed\n" \ - "AST : %SC\n" \ - "Other: %SC\n" \ + "AST : %S\n" \ + "Other: %S\n" \ , code_debug_str(self) \ , code_debug_str(other) \ ); \ \ log_fmt("Content cannot be trusted to be unique with this check " \ "so it must be verified by eye for now\n" \ - "AST Content:\n%SC\n" \ - "Other Content:\n%SC\n" \ - , strc_visualize_whitespace(self->content, GlobalAllocator) \ - , strc_visualize_whitespace(other->content, GlobalAllocator) \ + "AST Content:\n%S\n" \ + "Other Content:\n%S\n" \ + , str_visualize_whitespace(self->content, GlobalAllocator) \ + , str_visualize_whitespace(other->content, GlobalAllocator) \ ); \ } @@ -671,9 +671,9 @@ bool code_is_equal( Code self, Code other ) if ( other->ast == nullptr ) \ { \ log_fmt("\nAST::is_equal: Failed for member " #ast " other equivalent param is null\n" \ - "AST : %SC\n" \ - "Other: %SC\n" \ - "For ast member: %SC\n" \ + "AST : %S\n" \ + "Other: %S\n" \ + "For ast member: %S\n" \ , code_debug_str(self) \ , code_debug_str(other) \ , code_debug_str(self->ast) \ @@ -685,10 +685,10 @@ bool code_is_equal( Code self, Code other ) if ( ! code_is_equal(self->ast, other->ast ) ) \ { \ log_fmt( "\nAST::is_equal: Failed for " #ast"\n" \ - "AST : %SC\n" \ - "Other: %SC\n" \ - "For ast member: %SC\n" \ - "other's ast member: %SC\n" \ + "AST : %S\n" \ + "Other: %S\n" \ + "For ast member: %S\n" \ + "other's ast member: %S\n" \ , code_debug_str(self) \ , code_debug_str(other) \ , code_debug_str(self->ast) \ @@ -918,22 +918,22 @@ bool code_is_equal( Code self, Code other ) if ( curr_other == nullptr ) { log_fmt("\nAST::is_equal: Failed for parameter, other equivalent param is null\n" - "AST : %SC\n" - "Other: %SC\n" - "For ast member: %SC\n" + "AST : %S\n" + "Other: %S\n" + "For ast member: %S\n" , code_debug_str(curr) ); return false; } - if ( strc_are_equal(curr->Name, curr_other->Name) ) + if ( str_are_equal(curr->Name, curr_other->Name) ) { log_fmt( "\nAST::is_equal: Failed for parameter name check\n" - "AST : %SC\n" - "Other: %SC\n" - "For ast member: %SC\n" - "other's ast member: %SC\n" + "AST : %S\n" + "Other: %S\n" + "For ast member: %S\n" + "other's ast member: %S\n" , code_debug_str(self) , code_debug_str(other) , code_debug_str(curr) @@ -945,10 +945,10 @@ bool code_is_equal( Code self, Code other ) if ( curr->ValueType && ! code_is_equal(curr->ValueType, curr_other->ValueType) ) { log_fmt( "\nAST::is_equal: Failed for parameter value type check\n" - "AST : %SC\n" - "Other: %SC\n" - "For ast member: %SC\n" - "other's ast member: %SC\n" + "AST : %S\n" + "Other: %S\n" + "For ast member: %S\n" + "other's ast member: %S\n" , code_debug_str(self) , code_debug_str(other) , code_debug_str(curr) @@ -960,10 +960,10 @@ bool code_is_equal( Code self, Code other ) if ( curr->Value && ! code_is_equal(curr->Value, curr_other->Value) ) { log_fmt( "\nAST::is_equal: Failed for parameter value check\n" - "AST : %SC\n" - "Other: %SC\n" - "For ast member: %SC\n" - "other's ast member: %SC\n" + "AST : %S\n" + "Other: %S\n" + "For ast member: %S\n" + "other's ast member: %S\n" , code_debug_str(self) , code_debug_str(other) , code_debug_str(curr) @@ -1117,8 +1117,8 @@ bool code_is_equal( Code self, Code other ) if ( curr_other == nullptr ) { log_fmt("\nAST::is_equal: Failed for body, other equivalent param is null\n" - "AST : %SC\n" - "Other: %SC\n" + "AST : %S\n" + "Other: %S\n" , code_debug_str(curr) , code_debug_str(other) ); @@ -1129,10 +1129,10 @@ bool code_is_equal( Code self, Code other ) if ( ! code_is_equal( curr, curr_other ) ) { log_fmt( "\nAST::is_equal: Failed for body\n" - "AST : %SC\n" - "Other: %SC\n" - "For ast member: %SC\n" - "other's ast member: %SC\n" + "AST : %S\n" + "Other: %S\n" + "For ast member: %S\n" + "other's ast member: %S\n" , code_debug_str(self) , code_debug_str(other) , code_debug_str(curr) @@ -1169,7 +1169,7 @@ bool code_validate_body(Code self) for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type) { GEN_AST_BODY_CLASS_UNALLOWED_TYPES: - log_failure("AST::validate_body: Invalid entry in body %SC", code_debug_str(code_entry)); + log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry)); return false; default: @@ -1184,7 +1184,7 @@ bool code_validate_body(Code self) { if ( entry->Type != CT_Untyped ) { - log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %SC", code_debug_str(entry) ); + log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %S", code_debug_str(entry) ); return false; } } @@ -1196,7 +1196,7 @@ bool code_validate_body(Code self) for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type) { GEN_AST_BODY_EXPORT_UNALLOWED_TYPES: - log_failure("AST::validate_body: Invalid entry in body %SC", code_debug_str(code_entry)); + log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry)); return false; default: @@ -1210,7 +1210,7 @@ bool code_validate_body(Code self) for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type) { GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES: - log_failure("AST::validate_body: Invalid entry in body %SC", code_debug_str(code_entry)); + log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry)); return false; default: @@ -1224,7 +1224,7 @@ bool code_validate_body(Code self) for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type) { GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES: - log_failure("AST::validate_body: Invalid entry in body %SC", code_debug_str(code_entry)); + log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry)); return false; default: @@ -1238,7 +1238,7 @@ bool code_validate_body(Code self) for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )switch (entry->Type) { GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES: - log_failure("AST::validate_body: Invalid entry in body %SC", code_debug_str(entry)); + log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry)); return false; } } @@ -1249,7 +1249,7 @@ bool code_validate_body(Code self) for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) switch (entry->Type) { GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES: - log_failure("AST::validate_body: Invalid entry in body %SC", code_debug_str(entry)); + log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry)); return false; } } @@ -1260,7 +1260,7 @@ bool code_validate_body(Code self) for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) switch (entry->Type) { GEN_AST_BODY_STRUCT_UNALLOWED_TYPES: - log_failure("AST::validate_body: Invalid entry in body %SC", code_debug_str(entry)); + log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry)); return false; } } @@ -1272,7 +1272,7 @@ bool code_validate_body(Code self) { if ( entry->Type != CT_Untyped ) { - log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %SC", code_debug_str(entry) ); + log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %S", code_debug_str(entry) ); return false; } } @@ -1280,7 +1280,7 @@ bool code_validate_body(Code self) break; default: - log_failure( "AST::validate_body: Invalid this AST does not have a body %SC", code_debug_str(self) ); + log_failure( "AST::validate_body: Invalid this AST does not have a body %S", code_debug_str(self) ); return false; } diff --git a/base/components/ast.hpp b/base/components/ast.hpp index 052d8b6..03f94bc 100644 --- a/base/components/ast.hpp +++ b/base/components/ast.hpp @@ -242,7 +242,7 @@ GEN_NS_PARSER_END // I have ideas for ways to pack that into the typedef/using ast, but for now just keeping it like this #define ParserTokenType GEN_NS_PARSER Token typedef ParserTokenType Token; -#undef ParserTokenType +#undef ParserTokenType #endif #if GEN_COMPILER_CPP @@ -251,19 +251,19 @@ template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( #pragma region Code C-Interface -void code_append (Code code, Code other ); -StrC code_debug_str (Code code); -Code code_duplicate (Code code); -Code* code_entry (Code code, u32 idx ); -bool code_has_entries (Code code); -bool code_is_body (Code code); -bool code_is_equal (Code code, Code other); -bool code_is_valid (Code code); -void code_set_global (Code code); -String code_to_string (Code self ); -void code_to_string_ptr(Code self, String* result ); -StrC code_type_str (Code self ); -bool code_validate_body(Code self ); +void code_append (Code code, Code other ); +Str code_debug_str (Code code); +Code code_duplicate (Code code); +Code* code_entry (Code code, u32 idx ); +bool code_has_entries (Code code); +bool code_is_body (Code code); +bool code_is_equal (Code code, Code other); +bool code_is_valid (Code code); +void code_set_global (Code code); +StrBuilder code_to_strbuilder (Code self ); +void code_to_strbuilder_ptr(Code self, StrBuilder* result ); +Str code_type_str (Code self ); +bool code_validate_body (Code self ); #pragma endregion Code C-Interface @@ -278,7 +278,7 @@ struct Code AST* ast; # define Using_Code( Typename ) \ - forceinline StrC debug_str() { return code_debug_str(* this); } \ + forceinline Str debug_str() { return code_debug_str(* this); } \ forceinline Code duplicate() { return code_duplicate(* this); } \ forceinline bool is_equal( Code other ) { return code_is_equal(* this, other); } \ forceinline bool is_body() { return code_is_body(* this); } \ @@ -295,16 +295,17 @@ struct Code #if ! GEN_C_LIKE_CPP Using_Code( Code ); - forceinline void append(Code other) { return code_append(* this, other); } - forceinline Code* entry(u32 idx) { return code_entry(* this, idx); } - forceinline bool has_entries() { return code_has_entries(* this); } - forceinline String to_string() { return code_to_string(* this); } - forceinline void to_string(String& result) { return code_to_string_ptr(* this, & result); } - forceinline StrC type_str() { return code_type_str(* this); } - forceinline bool validate_body() { return code_validate_body(*this); } + forceinline void append(Code other) { return code_append(* this, other); } + forceinline Code* entry(u32 idx) { return code_entry(* this, idx); } + forceinline bool has_entries() { return code_has_entries(* this); } + forceinline StrBuilder to_strbuilder() { return code_to_strbuilder(* this); } + forceinline void to_strbuilder(StrBuilder& result) { return code_to_strbuilder_ptr(* this, & result); } + forceinline Str type_str() { return code_type_str(* this); } + forceinline bool validate_body() { return code_validate_body(*this); } #endif Using_CodeOps( Code ); + forceinline Code operator *() { return * this; } // Required to support for-range iteration. forceinline AST* operator ->() { return ast; } Code& operator ++(); diff --git a/base/components/code_serialization.cpp b/base/components/code_serialization.cpp index 5e0a4f4..2e8794d 100644 --- a/base/components/code_serialization.cpp +++ b/base/components/code_serialization.cpp @@ -4,29 +4,29 @@ #endif inline -String attributes_to_string(CodeAttributes attributes) { +StrBuilder attributes_to_strbuilder(CodeAttributes attributes) { GEN_ASSERT(attributes); - char* raw = ccast(char*, strc_duplicate( attributes->Content, GlobalAllocator ).Ptr); - String result = { raw }; + char* raw = ccast(char*, str_duplicate( attributes->Content, GlobalAllocator ).Ptr); + StrBuilder result = { raw }; return result; } inline -void attributes_to_string_ref(CodeAttributes attributes, String* result) { +void attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result) { GEN_ASSERT(attributes); GEN_ASSERT(result); - string_append_strc(result, attributes->Content); + strbuilder_append_str(result, attributes->Content); } -String body_to_string(CodeBody body) +StrBuilder body_to_strbuilder(CodeBody body) { GEN_ASSERT(body); - String result = string_make_reserve( GlobalAllocator, 128 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 128 ); switch ( body->Type ) { case CT_Untyped: case CT_Execution: - string_append_strc( & result, cast(Code, body)->Content ); + strbuilder_append_str( & result, cast(Code, body)->Content ); break; case CT_Enum_Body: @@ -37,17 +37,17 @@ String body_to_string(CodeBody body) case CT_Namespace_Body: case CT_Struct_Body: case CT_Union_Body: - body_to_string_ref( body, & result ); + body_to_strbuilder_ref( body, & result ); break; case CT_Export_Body: - body_to_string_export( body, & result ); + body_to_strbuilder_export( body, & result ); break; } return result; } -void body_to_string_ref( CodeBody body, String* result ) +void body_to_strbuilder_ref( CodeBody body, StrBuilder* result ) { GEN_ASSERT(body != nullptr); GEN_ASSERT(result != nullptr); @@ -55,461 +55,461 @@ void body_to_string_ref( CodeBody body, String* result ) s32 left = body->NumEntries; while ( left -- ) { - code_to_string_ptr(curr, result); - // string_append_fmt( result, "%S", code_to_string(curr) ); + code_to_strbuilder_ptr(curr, result); + // strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) ); ++curr; } } -void body_to_string_export( CodeBody body, String* result ) +void body_to_strbuilder_export( CodeBody body, StrBuilder* result ) { GEN_ASSERT(body != nullptr); GEN_ASSERT(result != nullptr); - string_append_fmt( result, "export\n{\n" ); + strbuilder_append_fmt( result, "export\n{\n" ); Code curr = cast(Code, body); s32 left = body->NumEntries; while ( left-- ) { - code_to_string_ptr(curr, result); - // string_append_fmt( result, "%S", code_to_string(curr) ); + code_to_strbuilder_ptr(curr, result); + // strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) ); ++curr; } - string_append_fmt( result, "};\n" ); + strbuilder_append_fmt( result, "};\n" ); } inline -String comment_to_string(CodeComment comment) { +StrBuilder comment_to_strbuilder(CodeComment comment) { GEN_ASSERT(comment); - char* raw = ccast(char*, strc_duplicate( comment->Content, GlobalAllocator ).Ptr); - String result = { raw }; + char* raw = ccast(char*, str_duplicate( comment->Content, GlobalAllocator ).Ptr); + StrBuilder result = { raw }; return result; } inline -void comment_to_string_ref(CodeComment comment, String* result) { +void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result) { GEN_ASSERT(comment); GEN_ASSERT(result); - string_append_strc(result, comment->Content); + strbuilder_append_str(result, comment->Content); } -String constructor_to_string(CodeConstructor self) +StrBuilder constructor_to_strbuilder(CodeConstructor self) { - String result = string_make_reserve( GlobalAllocator, 128 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 128 ); switch (self->Type) { case CT_Constructor: - constructor_to_string_def( self, & result ); + constructor_to_strbuilder_def( self, & result ); break; case CT_Constructor_Fwd: - constructor_to_string_fwd( self, & result ); + constructor_to_strbuilder_fwd( self, & result ); break; } return result; } -void constructor_to_string_def(CodeConstructor self, String* result ) +void constructor_to_strbuilder_def(CodeConstructor self, StrBuilder* result ) { Code ClassStructParent = self->Parent->Parent; if (ClassStructParent) { - string_append_strc( result, ClassStructParent->Name ); + strbuilder_append_str( result, ClassStructParent->Name ); } else { - string_append_strc( result, self->Name ); + strbuilder_append_str( result, self->Name ); } if ( self->Params ) - string_append_fmt( result, "( %S )", params_to_string(self->Params) ); + strbuilder_append_fmt( result, "( %SB )", params_to_strbuilder(self->Params) ); else - string_append_strc( result, txt("()") ); + strbuilder_append_str( result, txt("()") ); if ( self->InitializerList ) - string_append_fmt( result, " : %S", code_to_string(self->InitializerList) ); + strbuilder_append_fmt( result, " : %SB", code_to_strbuilder(self->InitializerList) ); if ( self->InlineCmt ) - string_append_fmt( result, " // %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, " // %S", self->InlineCmt->Content ); - string_append_fmt( result, "\n{\n%S\n}\n", code_to_string(self->Body) ); + strbuilder_append_fmt( result, "\n{\n%SB\n}\n", code_to_strbuilder(self->Body) ); } -void constructor_to_string_fwd(CodeConstructor self, String* result ) +void constructor_to_strbuilder_fwd(CodeConstructor self, StrBuilder* result ) { Code ClassStructParent = self->Parent->Parent; if (ClassStructParent) { - string_append_strc( result, ClassStructParent->Name ); + strbuilder_append_str( result, ClassStructParent->Name ); } else { - string_append_strc( result, self->Name ); + strbuilder_append_str( result, self->Name ); } if ( self->Params ) - string_append_fmt( result, "( %S )", params_to_string(self->Params) ); + strbuilder_append_fmt( result, "( %SB )", params_to_strbuilder(self->Params) ); else - string_append_fmt( result, "()"); + strbuilder_append_fmt( result, "()"); if (self->Body) - string_append_fmt( result, " = %S", code_to_string(self->Body) ); + strbuilder_append_fmt( result, " = %SB", code_to_strbuilder(self->Body) ); if ( self->InlineCmt ) - string_append_fmt( result, "; // %SC\n", self->InlineCmt->Content ); + strbuilder_append_fmt( result, "; // %S\n", self->InlineCmt->Content ); else - string_append_strc( result, txt(";\n") ); + strbuilder_append_str( result, txt(";\n") ); } -String class_to_string( CodeClass self ) +StrBuilder class_to_strbuilder( CodeClass self ) { - String result = string_make_reserve( GlobalAllocator, 512 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Class: - class_to_string_def(self, & result ); + class_to_strbuilder_def(self, & result ); break; case CT_Class_Fwd: - class_to_string_fwd(self, & result ); + class_to_strbuilder_fwd(self, & result ); break; } return result; } -void class_to_string_def( CodeClass self, String* result ) +void class_to_strbuilder_def( CodeClass self, StrBuilder* result ) { GEN_ASSERT(self); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); - string_append_strc( result, txt("class ") ); + strbuilder_append_str( result, txt("class ") ); if ( self->Attributes ) { - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); } if ( self->ParentType ) { - StrC access_level = access_spec_to_str( self->ParentAccess ); - string_append_fmt( result, "%SC : %SC %S", self->Name, access_level, typename_to_string(self->ParentType) ); + Str access_level = access_spec_to_str( self->ParentAccess ); + strbuilder_append_fmt( result, "%S : %S %SB", self->Name, access_level, typename_to_strbuilder(self->ParentType) ); CodeTypename interface = cast(CodeTypename, self->ParentType->Next); if ( interface ) - string_append_strc( result, txt("\n") ); + strbuilder_append_str( result, txt("\n") ); while ( interface ) { - string_append_fmt( result, ", public %S", typename_to_string(interface) ); + strbuilder_append_fmt( result, ", public %SB", typename_to_strbuilder(interface) ); interface = interface->Next ? cast(CodeTypename, interface->Next) : NullCode; } } else if ( self->Name.Len ) { - string_append_strc( result, self->Name ); + strbuilder_append_str( result, self->Name ); } if ( self->InlineCmt ) { - string_append_fmt( result, " // %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, " // %S", self->InlineCmt->Content ); } - string_append_fmt( result, "\n{\n%S\n}", body_to_string(self->Body) ); + strbuilder_append_fmt( result, "\n{\n%SB\n}", body_to_strbuilder(self->Body) ); if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) - string_append_strc( result, txt(";\n") ); + strbuilder_append_str( result, txt(";\n") ); } -void class_to_string_fwd( CodeClass self, String* result ) +void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result ) { GEN_ASSERT(self); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "class %S %SC", attributes_to_string(self->Attributes), self->Name ); + strbuilder_append_fmt( result, "class %SB %S", attributes_to_strbuilder(self->Attributes), self->Name ); - else string_append_fmt( result, "class %SC", self->Name ); + else strbuilder_append_fmt( result, "class %S", self->Name ); // Check if it can have an end-statement if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { if ( self->InlineCmt ) - string_append_fmt( result, "; // %SC\n", self->InlineCmt->Content ); + strbuilder_append_fmt( result, "; // %S\n", self->InlineCmt->Content ); else - string_append_strc( result, txt(";\n") ); + strbuilder_append_str( result, txt(";\n") ); } } -String define_to_string(CodeDefine define) +StrBuilder define_to_strbuilder(CodeDefine define) { - return string_fmt_buf( GlobalAllocator, "#define %SC %SC", define->Name, define->Content ); + return strbuilder_fmt_buf( GlobalAllocator, "#define %S %S", define->Name, define->Content ); } -void define_to_string_ref(CodeDefine define, String* result ) +void define_to_strbuilder_ref(CodeDefine define, StrBuilder* result ) { - string_append_fmt( result, "#define %SC %SC", define->Name, define->Content ); + strbuilder_append_fmt( result, "#define %S %S", define->Name, define->Content ); } -String destructor_to_string(CodeDestructor self) +StrBuilder destructor_to_strbuilder(CodeDestructor self) { - String result = string_make_reserve( GlobalAllocator, 128 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 128 ); switch ( self->Type ) { case CT_Destructor: - destructor_to_string_def( self, & result ); + destructor_to_strbuilder_def( self, & result ); break; case CT_Destructor_Fwd: - destructor_to_string_fwd( self, & result ); + destructor_to_strbuilder_fwd( self, & result ); break; } return result; } -void destructor_to_string_def(CodeDestructor self, String* result ) +void destructor_to_strbuilder_def(CodeDestructor self, StrBuilder* result ) { if ( self->Name.Len ) { - string_append_fmt( result, "%SC()", self->Name ); + strbuilder_append_fmt( result, "%S()", self->Name ); } else if ( self->Specs ) { if ( specifiers_has(self->Specs, Spec_Virtual ) ) - string_append_fmt( result, "virtual ~%SC()", self->Parent->Name ); + strbuilder_append_fmt( result, "virtual ~%S()", self->Parent->Name ); else - string_append_fmt( result, "~%SC()", self->Parent->Name ); + strbuilder_append_fmt( result, "~%S()", self->Parent->Name ); } else - string_append_fmt( result, "~%SC()", self->Parent->Name ); + strbuilder_append_fmt( result, "~%S()", self->Parent->Name ); - string_append_fmt( result, "\n{\n%S\n}\n", code_to_string(self->Body) ); + strbuilder_append_fmt( result, "\n{\n%SB\n}\n", code_to_strbuilder(self->Body) ); } -void destructor_to_string_fwd(CodeDestructor self, String* result ) +void destructor_to_strbuilder_fwd(CodeDestructor self, StrBuilder* result ) { if ( self->Specs ) { if ( specifiers_has(self->Specs, Spec_Virtual ) ) - string_append_fmt( result, "virtual ~%SC();\n", self->Parent->Name ); + strbuilder_append_fmt( result, "virtual ~%S();\n", self->Parent->Name ); else - string_append_fmt( result, "~%SC()", self->Parent->Name ); + strbuilder_append_fmt( result, "~%S()", self->Parent->Name ); if ( specifiers_has(self->Specs, Spec_Pure ) ) - string_append_strc( result, txt(" = 0;") ); + strbuilder_append_str( result, txt(" = 0;") ); else if (self->Body) - string_append_fmt( result, " = %S;", code_to_string(self->Body) ); + strbuilder_append_fmt( result, " = %SB;", code_to_strbuilder(self->Body) ); } else - string_append_fmt( result, "~%SC();", self->Parent->Name ); + strbuilder_append_fmt( result, "~%S();", self->Parent->Name ); if ( self->InlineCmt ) - string_append_fmt( result, " %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, " %S", self->InlineCmt->Content ); else - string_append_strc( result, txt("\n")); + strbuilder_append_str( result, txt("\n")); } -String enum_to_string(CodeEnum self) +StrBuilder enum_to_strbuilder(CodeEnum self) { - String result = string_make_reserve( GlobalAllocator, 512 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Enum: - enum_to_string_def(self, & result ); + enum_to_strbuilder_def(self, & result ); break; case CT_Enum_Fwd: - enum_to_string_fwd(self, & result ); + enum_to_strbuilder_fwd(self, & result ); break; case CT_Enum_Class: - enum_to_string_class_def(self, & result ); + enum_to_strbuilder_class_def(self, & result ); break; case CT_Enum_Class_Fwd: - enum_to_string_class_fwd(self, & result ); + enum_to_strbuilder_class_fwd(self, & result ); break; } return result; } -void enum_to_string_def(CodeEnum self, String* result ) +void enum_to_strbuilder_def(CodeEnum self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes || self->UnderlyingType || self->UnderlyingTypeMacro ) { - string_append_strc( result, txt("enum ") ); + strbuilder_append_str( result, txt("enum ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); if ( self->UnderlyingType ) - string_append_fmt( result, "%SC : %S\n{\n%S\n}" + strbuilder_append_fmt( result, "%S : %SB\n{\n%SB\n}" , self->Name - , typename_to_string(self->UnderlyingType) - , body_to_string(self->Body) + , typename_to_strbuilder(self->UnderlyingType) + , body_to_strbuilder(self->Body) ); else if ( self->UnderlyingTypeMacro ) - string_append_fmt( result, "%SC %S\n{\n%S\n}" + strbuilder_append_fmt( result, "%S %SB\n{\n%SB\n}" , self->Name - , code_to_string(self->UnderlyingTypeMacro) - , body_to_string(self->Body) + , code_to_strbuilder(self->UnderlyingTypeMacro) + , body_to_strbuilder(self->Body) ); - else string_append_fmt( result, "%SC\n{\n%S\n}", self->Name, body_to_string(self->Body) ); + else strbuilder_append_fmt( result, "%S\n{\n%SB\n}", self->Name, body_to_strbuilder(self->Body) ); } - else string_append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, body_to_string(self->Body) ); + else strbuilder_append_fmt( result, "enum %S\n{\n%SB\n}", self->Name, body_to_strbuilder(self->Body) ); if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) - string_append_strc( result, txt(";\n")); + strbuilder_append_str( result, txt(";\n")); } -void enum_to_string_fwd(CodeEnum self, String* result ) +void enum_to_strbuilder_fwd(CodeEnum self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); if ( self->UnderlyingType ) - string_append_fmt( result, "enum %SC : %S", self->Name, typename_to_string(self->UnderlyingType) ); + strbuilder_append_fmt( result, "enum %S : %SB", self->Name, typename_to_strbuilder(self->UnderlyingType) ); else if (self->UnderlyingTypeMacro) { log_fmt("IDENTIFIED A UNDERLYING ENUM MACRO"); - string_append_fmt( result, "enum %SC %S", self->Name, code_to_string(self->UnderlyingTypeMacro) ); + strbuilder_append_fmt( result, "enum %S %SB", self->Name, code_to_strbuilder(self->UnderlyingTypeMacro) ); } else - string_append_fmt( result, "enum %SC", self->Name ); + strbuilder_append_fmt( result, "enum %S", self->Name ); if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { if ( self->InlineCmt ) - string_append_fmt( result, "; %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, "; %S", self->InlineCmt->Content ); else - string_append_strc( result, txt(";\n")); + strbuilder_append_str( result, txt(";\n")); } } -void enum_to_string_class_def(CodeEnum self, String* result ) +void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes || self->UnderlyingType ) { - string_append_strc( result, txt("enum class ") ); + strbuilder_append_str( result, txt("enum class ") ); if ( self->Attributes ) { - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); } if ( self->UnderlyingType ) { - string_append_fmt( result, "%SC : %S\n{\n%S\n}", self->Name, typename_to_string(self->UnderlyingType), body_to_string(self->Body) ); + strbuilder_append_fmt( result, "%S : %SB\n{\n%SB\n}", self->Name, typename_to_strbuilder(self->UnderlyingType), body_to_strbuilder(self->Body) ); } else { - string_append_fmt( result, "%SC\n{\n%S\n}", self->Name, body_to_string(self->Body) ); + strbuilder_append_fmt( result, "%S\n{\n%SB\n}", self->Name, body_to_strbuilder(self->Body) ); } } else { - string_append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, body_to_string(self->Body) ); + strbuilder_append_fmt( result, "enum %S\n{\n%SB\n}", self->Name, body_to_strbuilder(self->Body) ); } if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) - string_append_strc( result, txt(";\n")); + strbuilder_append_str( result, txt(";\n")); } -void enum_to_string_class_fwd(CodeEnum self, String* result ) +void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); - string_append_strc( result, txt("enum class ") ); + strbuilder_append_str( result, txt("enum class ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); - string_append_fmt( result, "%SC : %S", self->Name, typename_to_string(self->UnderlyingType) ); + strbuilder_append_fmt( result, "%S : %SB", self->Name, typename_to_strbuilder(self->UnderlyingType) ); if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { if ( self->InlineCmt ) - string_append_fmt( result, "; %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, "; %S", self->InlineCmt->Content ); else - string_append_strc( result, txt(";\n")); + strbuilder_append_str( result, txt(";\n")); } } -String exec_to_string(CodeExec exec) +StrBuilder exec_to_strbuilder(CodeExec exec) { GEN_ASSERT(exec); - char* raw = ccast(char*, strc_duplicate( exec->Content, GlobalAllocator ).Ptr); - String result = { raw }; + char* raw = ccast(char*, str_duplicate( exec->Content, GlobalAllocator ).Ptr); + StrBuilder result = { raw }; return result; } -void extern_to_string(CodeExtern self, String* result ) +void extern_to_strbuilder(CodeExtern self, StrBuilder* result ) { if ( self->Body ) - string_append_fmt( result, "extern \"%SC\"\n{\n%S\n}\n", self->Name, body_to_string(self->Body) ); + strbuilder_append_fmt( result, "extern \"%S\"\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) ); else - string_append_fmt( result, "extern \"%SC\"\n{}\n", self->Name ); + strbuilder_append_fmt( result, "extern \"%S\"\n{}\n", self->Name ); } -String include_to_string(CodeInclude include) +StrBuilder include_to_strbuilder(CodeInclude include) { - return string_fmt_buf( GlobalAllocator, "#include %SC\n", include->Content ); + return strbuilder_fmt_buf( GlobalAllocator, "#include %S\n", include->Content ); } -void include_to_string_ref( CodeInclude include, String* result ) +void include_to_strbuilder_ref( CodeInclude include, StrBuilder* result ) { - string_append_fmt( result, "#include %SC\n", include->Content ); + strbuilder_append_fmt( result, "#include %S\n", include->Content ); } -String friend_to_string(CodeFriend self) +StrBuilder friend_to_strbuilder(CodeFriend self) { - String result = string_make_reserve( GlobalAllocator, 256 ); - friend_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 256 ); + friend_to_strbuilder_ref( self, & result ); return result; } -void friend_to_string_ref(CodeFriend self, String* result ) +void friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result ) { - string_append_fmt( result, "friend %S", code_to_string(self->Declaration) ); + strbuilder_append_fmt( result, "friend %SB", code_to_strbuilder(self->Declaration) ); - if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ string_length(* result) - 1 ] != ';' ) + if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ strbuilder_length(* result) - 1 ] != ';' ) { - string_append_strc( result, txt(";") ); + strbuilder_append_str( result, txt(";") ); } if ( self->InlineCmt ) - string_append_fmt( result, " %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, " %S", self->InlineCmt->Content ); else - string_append_strc( result, txt("\n")); + strbuilder_append_str( result, txt("\n")); } -String fn_to_string(CodeFn self) +StrBuilder fn_to_strbuilder(CodeFn self) { - String result = string_make_reserve( GlobalAllocator, 512 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Function: - fn_to_string_def(self, & result ); + fn_to_strbuilder_def(self, & result ); break; case CT_Function_Fwd: - fn_to_string_fwd(self, & result ); + fn_to_strbuilder_fwd(self, & result ); break; } return result; } -void fn_to_string_def(CodeFn self, String* result ) +void fn_to_strbuilder_def(CodeFn self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export") ); + strbuilder_append_str( result, txt("export") ); if ( self->Attributes ) - string_append_fmt( result, " %S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, " %SB ", attributes_to_strbuilder(self->Attributes) ); bool prefix_specs = false; if ( self->Specs ) @@ -518,8 +518,8 @@ void fn_to_string_def(CodeFn self, String* result ) { if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); prefix_specs = true; } @@ -527,19 +527,19 @@ void fn_to_string_def(CodeFn self, String* result ) } if ( self->Attributes || prefix_specs ) - string_append_strc( result, txt("\n") ); + strbuilder_append_str( result, txt("\n") ); if ( self->ReturnType ) - string_append_fmt( result, "%S %SC(", typename_to_string(self->ReturnType), self->Name ); + strbuilder_append_fmt( result, "%SB %S(", typename_to_strbuilder(self->ReturnType), self->Name ); else - string_append_fmt( result, "%SC(", self->Name ); + strbuilder_append_fmt( result, "%S(", self->Name ); if ( self->Params ) - string_append_fmt( result, "%S)", params_to_string(self->Params) ); + strbuilder_append_fmt( result, "%SB)", params_to_strbuilder(self->Params) ); else - string_append_strc( result, txt(")") ); + strbuilder_append_str( result, txt(")") ); if ( self->Specs ) { @@ -547,22 +547,22 @@ void fn_to_string_def(CodeFn self, String* result ) { if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } - string_append_fmt( result, "\n{\n%S\n}\n", body_to_string(self->Body) ); + strbuilder_append_fmt( result, "\n{\n%SB\n}\n", body_to_strbuilder(self->Body) ); } -void fn_to_string_fwd(CodeFn self, String* result ) +void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); b32 prefix_specs = false; if ( self->Specs ) @@ -571,8 +571,8 @@ void fn_to_string_fwd(CodeFn self, String* result ) { if ( ! spec_is_trailing( * spec ) || ! ( * spec != Spec_Pure) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); prefix_specs = true; } @@ -581,20 +581,20 @@ void fn_to_string_fwd(CodeFn self, String* result ) if ( self->Attributes || prefix_specs ) { - string_append_strc( result, txt("\n") ); + strbuilder_append_str( result, txt("\n") ); } if ( self->ReturnType ) - string_append_fmt( result, "%S %SC(", typename_to_string(self->ReturnType), self->Name ); + strbuilder_append_fmt( result, "%SB %S(", typename_to_strbuilder(self->ReturnType), self->Name ); else - string_append_fmt( result, "%SC(", self->Name ); + strbuilder_append_fmt( result, "%S(", self->Name ); if ( self->Params ) - string_append_fmt( result, "%S)", params_to_string(self->Params) ); + strbuilder_append_fmt( result, "%SB)", params_to_strbuilder(self->Params) ); else - string_append_strc( result, txt(")") ); + strbuilder_append_str( result, txt(")") ); if ( self->Specs ) { @@ -602,83 +602,83 @@ void fn_to_string_fwd(CodeFn self, String* result ) { if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } if ( self->Specs && specifiers_has(self->Specs, Spec_Pure ) >= 0 ) - string_append_strc( result, txt(" = 0;") ); + strbuilder_append_str( result, txt(" = 0;") ); else if (self->Body) - string_append_fmt( result, " = %S;", body_to_string(self->Body) ); + strbuilder_append_fmt( result, " = %SB;", body_to_strbuilder(self->Body) ); if ( self->InlineCmt ) - string_append_fmt( result, "; %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, "; %S", self->InlineCmt->Content ); else - string_append_strc( result, txt(";\n") ); + strbuilder_append_str( result, txt(";\n") ); } -String module_to_string(CodeModule self) +StrBuilder module_to_strbuilder(CodeModule self) { - String result = string_make_reserve( GlobalAllocator, 64 ); - module_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 64 ); + module_to_strbuilder_ref( self, & result ); return result; } -void module_to_string_ref(CodeModule self, String* result ) +void module_to_strbuilder_ref(CodeModule self, StrBuilder* result ) { if (((scast(u32, ModuleFlag_Export) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Export))) - string_append_strc( result, txt("export ")); + strbuilder_append_str( result, txt("export ")); if (((scast(u32, ModuleFlag_Import) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Import))) - string_append_strc( result, txt("import ")); + strbuilder_append_str( result, txt("import ")); - string_append_fmt( result, "%SC;\n", self->Name ); + strbuilder_append_fmt( result, "%S;\n", self->Name ); } -String namespace_to_string(CodeNS self) +StrBuilder namespace_to_strbuilder(CodeNS self) { - String result = string_make_reserve( GlobalAllocator, 512 ); - namespace_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 512 ); + namespace_to_strbuilder_ref( self, & result ); return result; } -void namespace_to_string_ref(CodeNS self, String* result ) +void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); - string_append_fmt( result, "namespace %SC\n{\n%S\n}\n", self->Name, body_to_string(self->Body) ); + strbuilder_append_fmt( result, "namespace %S\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) ); } -String code_op_to_string(CodeOperator self) +StrBuilder code_op_to_strbuilder(CodeOperator self) { - String result = string_make_reserve( GlobalAllocator, 512 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Operator: case CT_Operator_Member: - code_op_to_string_def( self, & result ); + code_op_to_strbuilder_def( self, & result ); break; case CT_Operator_Fwd: case CT_Operator_Member_Fwd: - code_op_to_string_fwd( self, & result ); + code_op_to_strbuilder_fwd( self, & result ); break; } return result; } -void code_op_to_string_def(CodeOperator self, String* result ) +void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); if ( self->Specs ) { @@ -686,25 +686,25 @@ void code_op_to_string_def(CodeOperator self, String* result ) { if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } if ( self->Attributes || self->Specs ) { - string_append_strc( result, txt("\n") ); + strbuilder_append_str( result, txt("\n") ); } if ( self->ReturnType ) - string_append_fmt( result, "%S %SC (", typename_to_string(self->ReturnType), self->Name ); + strbuilder_append_fmt( result, "%SB %S (", typename_to_strbuilder(self->ReturnType), self->Name ); if ( self->Params ) - string_append_fmt( result, "%S)", params_to_string(self->Params) ); + strbuilder_append_fmt( result, "%SB)", params_to_strbuilder(self->Params) ); else - string_append_strc( result, txt(")") ); + strbuilder_append_str( result, txt(")") ); if ( self->Specs ) { @@ -712,24 +712,24 @@ void code_op_to_string_def(CodeOperator self, String* result ) { if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } - string_append_fmt( result, "\n{\n%S\n}\n" - , body_to_string(self->Body) + strbuilder_append_fmt( result, "\n{\n%SB\n}\n" + , body_to_strbuilder(self->Body) ); } -void code_op_to_string_fwd(CodeOperator self, String* result ) +void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S\n", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB\n", attributes_to_strbuilder(self->Attributes) ); if ( self->Specs ) { @@ -737,24 +737,24 @@ void code_op_to_string_fwd(CodeOperator self, String* result ) { if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } if ( self->Attributes || self->Specs ) { - string_append_strc( result, txt("\n") ); + strbuilder_append_str( result, txt("\n") ); } - string_append_fmt( result, "%S %SC (", typename_to_string(self->ReturnType), self->Name ); + strbuilder_append_fmt( result, "%SB %S (", typename_to_strbuilder(self->ReturnType), self->Name ); if ( self->Params ) - string_append_fmt( result, "%S)", params_to_string(self->Params) ); + strbuilder_append_fmt( result, "%SB)", params_to_strbuilder(self->Params) ); else - string_append_fmt( result, ")" ); + strbuilder_append_fmt( result, ")" ); if ( self->Specs ) { @@ -762,34 +762,34 @@ void code_op_to_string_fwd(CodeOperator self, String* result ) { if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } if ( self->InlineCmt ) - string_append_fmt( result, "; %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, "; %S", self->InlineCmt->Content ); else - string_append_strc( result, txt(";\n") ); + strbuilder_append_str( result, txt(";\n") ); } -String opcast_to_string(CodeOpCast self) +StrBuilder opcast_to_strbuilder(CodeOpCast self) { - String result = string_make_reserve( GlobalAllocator, 128 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 128 ); switch ( self->Type ) { case CT_Operator_Cast: - opcast_to_string_def(self, & result ); + opcast_to_strbuilder_def(self, & result ); break; case CT_Operator_Cast_Fwd: - opcast_to_string_fwd(self, & result ); + opcast_to_strbuilder_fwd(self, & result ); break; } return result; } -void opcast_to_string_def(CodeOpCast self, String* result ) +void opcast_to_strbuilder_def(CodeOpCast self, StrBuilder* result ) { if ( self->Specs ) { @@ -797,36 +797,36 @@ void opcast_to_string_def(CodeOpCast self, String* result ) { if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr ); } } if ( self->Name.Ptr && self->Name.Len ) - string_append_fmt( result, "%SC operator %S()", self->Name, typename_to_string(self->ValueType) ); + strbuilder_append_fmt( result, "%S operator %SB()", self->Name, typename_to_strbuilder(self->ValueType) ); else - string_append_fmt( result, "operator %S()", typename_to_string(self->ValueType) ); + strbuilder_append_fmt( result, "operator %SB()", typename_to_strbuilder(self->ValueType) ); for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } - string_append_fmt( result, "\n{\n%S\n}\n", body_to_string(self->Body) ); + strbuilder_append_fmt( result, "\n{\n%SB\n}\n", body_to_strbuilder(self->Body) ); return; } if ( self->Name.Ptr && self->Name.Len ) - string_append_fmt( result, "%SC operator %S()\n{\n%S\n}\n", self->Name, typename_to_string(self->ValueType), body_to_string(self->Body) ); + strbuilder_append_fmt( result, "%S operator %SB()\n{\n%SB\n}\n", self->Name, typename_to_strbuilder(self->ValueType), body_to_strbuilder(self->Body) ); else - string_append_fmt( result, "operator %S()\n{\n%S\n}\n", typename_to_string(self->ValueType), body_to_string(self->Body) ); + strbuilder_append_fmt( result, "operator %SB()\n{\n%SB\n}\n", typename_to_strbuilder(self->ValueType), body_to_strbuilder(self->Body) ); } -void opcast_to_string_fwd(CodeOpCast self, String* result ) +void opcast_to_strbuilder_fwd(CodeOpCast self, StrBuilder* result ) { if ( self->Specs ) { @@ -834,168 +834,168 @@ void opcast_to_string_fwd(CodeOpCast self, String* result ) { if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr ); } } - string_append_fmt( result, "operator %S()", typename_to_string(self->ValueType) ); + strbuilder_append_fmt( result, "operator %SB()", typename_to_strbuilder(self->ValueType) ); for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( * spec ); - string_append_fmt( result, " %*s", spec_str.Len, spec_str.Ptr ); + Str spec_str = spec_to_str( * spec ); + strbuilder_append_fmt( result, " %*s", spec_str.Len, spec_str.Ptr ); } } if ( self->InlineCmt ) - string_append_fmt( result, "; %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, "; %S", self->InlineCmt->Content ); else - string_append_strc( result, txt(";\n") ); + strbuilder_append_str( result, txt(";\n") ); return; } if ( self->InlineCmt ) - string_append_fmt( result, "operator %S(); %S", typename_to_string(self->ValueType) ); + strbuilder_append_fmt( result, "operator %SB(); %SB", typename_to_strbuilder(self->ValueType) ); else - string_append_fmt( result, "operator %S();\n", typename_to_string(self->ValueType) ); + strbuilder_append_fmt( result, "operator %SB();\n", typename_to_strbuilder(self->ValueType) ); } -String params_to_string(CodeParams self) +StrBuilder params_to_strbuilder(CodeParams self) { GEN_ASSERT(self); GEN_ASSERT(self); - String result = string_make_reserve( GlobalAllocator, 128 ); - params_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 128 ); + params_to_strbuilder_ref( self, & result ); return result; } -void params_to_string_ref( CodeParams self, String* result ) +void params_to_strbuilder_ref( CodeParams self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); if ( self->Macro ) { // Related to parsing: ( , ... ) - string_append_strc( result, self->Macro->Content ); + strbuilder_append_str( result, self->Macro->Content ); // Could also be: ( , ... ) } if ( self->Name.Ptr && self->Name.Len ) { if ( self->ValueType == nullptr ) - string_append_fmt( result, " %SC", self->Name ); + strbuilder_append_fmt( result, " %S", self->Name ); else - string_append_fmt( result, " %S %SC", typename_to_string(self->ValueType), self->Name ); + strbuilder_append_fmt( result, " %SB %S", typename_to_strbuilder(self->ValueType), self->Name ); } else if ( self->ValueType ) - string_append_fmt( result, " %S", typename_to_string(self->ValueType) ); + strbuilder_append_fmt( result, " %SB", typename_to_strbuilder(self->ValueType) ); if ( self->PostNameMacro ) { - string_append_fmt( result, " %S", code_to_string(self->PostNameMacro) ); + strbuilder_append_fmt( result, " %SB", code_to_strbuilder(self->PostNameMacro) ); } if ( self->Value ) - string_append_fmt( result, " = %S", code_to_string(self->Value) ); + strbuilder_append_fmt( result, " = %SB", code_to_strbuilder(self->Value) ); if ( self->NumEntries - 1 > 0 ) { for ( CodeParams param = begin_CodeParams(self->Next); param != end_CodeParams(self->Next); param = next_CodeParams(self->Next, param) ) { - string_append_fmt( result, ", %S", params_to_string(param) ); + strbuilder_append_fmt( result, ", %SB", params_to_strbuilder(param) ); } } } -String preprocess_to_string(CodePreprocessCond self) +StrBuilder preprocess_to_strbuilder(CodePreprocessCond self) { GEN_ASSERT(self); - String result = string_make_reserve( GlobalAllocator, 256 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 256 ); switch ( self->Type ) { case CT_Preprocess_If: - preprocess_to_string_if( self, & result ); + preprocess_to_strbuilder_if( self, & result ); break; case CT_Preprocess_IfDef: - preprocess_to_string_ifdef( self, & result ); + preprocess_to_strbuilder_ifdef( self, & result ); break; case CT_Preprocess_IfNotDef: - preprocess_to_string_ifndef( self, & result ); + preprocess_to_strbuilder_ifndef( self, & result ); break; case CT_Preprocess_ElIf: - preprocess_to_string_elif( self, & result ); + preprocess_to_strbuilder_elif( self, & result ); break; case CT_Preprocess_Else: - preprocess_to_string_else( self, & result ); + preprocess_to_strbuilder_else( self, & result ); break; case CT_Preprocess_EndIf: - preprocess_to_string_endif( self, & result ); + preprocess_to_strbuilder_endif( self, & result ); break; } return result; } -void preprocess_to_string_if(CodePreprocessCond cond, String* result ) +void preprocess_to_strbuilder_if(CodePreprocessCond cond, StrBuilder* result ) { GEN_ASSERT(cond); - string_append_fmt( result, "#if %SC", cond->Content ); + strbuilder_append_fmt( result, "#if %S", cond->Content ); } -void preprocess_to_string_ifdef(CodePreprocessCond cond, String* result ) +void preprocess_to_strbuilder_ifdef(CodePreprocessCond cond, StrBuilder* result ) { GEN_ASSERT(cond); - string_append_fmt( result, "#ifdef %SC\n", cond->Content ); + strbuilder_append_fmt( result, "#ifdef %S\n", cond->Content ); } -void preprocess_to_string_ifndef(CodePreprocessCond cond, String* result ) +void preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result ) { GEN_ASSERT(cond); - string_append_fmt( result, "#ifndef %SC", cond->Content ); + strbuilder_append_fmt( result, "#ifndef %S", cond->Content ); } -void preprocess_to_string_elif(CodePreprocessCond cond, String* result ) +void preprocess_to_strbuilder_elif(CodePreprocessCond cond, StrBuilder* result ) { GEN_ASSERT(cond); - string_append_fmt( result, "#elif %SC\n", cond->Content ); + strbuilder_append_fmt( result, "#elif %S\n", cond->Content ); } -void preprocess_to_string_else(CodePreprocessCond cond, String* result ) +void preprocess_to_strbuilder_else(CodePreprocessCond cond, StrBuilder* result ) { GEN_ASSERT(cond); - string_append_strc( result, txt("#else\n") ); + strbuilder_append_str( result, txt("#else\n") ); } -void preprocess_to_string_endif(CodePreprocessCond cond, String* result ) +void preprocess_to_strbuilder_endif(CodePreprocessCond cond, StrBuilder* result ) { GEN_ASSERT(cond); - string_append_strc( result, txt("#endif\n") ); + strbuilder_append_str( result, txt("#endif\n") ); } -String pragma_to_string(CodePragma self) +StrBuilder pragma_to_strbuilder(CodePragma self) { GEN_ASSERT(self); - String result = string_make_reserve( GlobalAllocator, 256 ); - pragma_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 256 ); + pragma_to_strbuilder_ref( self, & result ); return result; } -void pragma_to_string_ref(CodePragma self, String* result ) +void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result ) { - string_append_fmt( result, "#pragma %SC\n", self->Content ); + strbuilder_append_fmt( result, "#pragma %S\n", self->Content ); } -String specifiers_to_string(CodeSpecifiers self) +StrBuilder specifiers_to_strbuilder(CodeSpecifiers self) { - String result = string_make_reserve( GlobalAllocator, 64 ); - specifiers_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 64 ); + specifiers_to_strbuilder_ref( self, & result ); return result; } -void specifiers_to_string_ref( CodeSpecifiers self, String* result ) +void specifiers_to_strbuilder_ref( CodeSpecifiers self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); @@ -1003,179 +1003,179 @@ void specifiers_to_string_ref( CodeSpecifiers self, String* result ) s32 left = self->NumEntries; while ( left-- ) { - StrC spec = spec_to_str( self->ArrSpecs[idx] ); - string_append_fmt( result, "%.*s ", spec.Len, spec.Ptr ); + Str spec = spec_to_str( self->ArrSpecs[idx] ); + strbuilder_append_fmt( result, "%.*s ", spec.Len, spec.Ptr ); idx++; } } -String struct_to_string(CodeStruct self) +StrBuilder struct_to_strbuilder(CodeStruct self) { GEN_ASSERT(self); GEN_ASSERT(self); - String result = string_make_reserve( GlobalAllocator, 512 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Struct: - struct_to_string_def( self, & result ); + struct_to_strbuilder_def( self, & result ); break; case CT_Struct_Fwd: - struct_to_string_fwd( self, & result ); + struct_to_strbuilder_fwd( self, & result ); break; } return result; } -void struct_to_string_def( CodeStruct self, String* result ) +void struct_to_strbuilder_def( CodeStruct self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); - string_append_strc( result, txt("struct ") ); + strbuilder_append_str( result, txt("struct ") ); if ( self->Attributes ) { - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); } if ( self->ParentType ) { - StrC access_level = access_spec_to_str( self->ParentAccess ); + Str access_level = access_spec_to_str( self->ParentAccess ); - string_append_fmt( result, "%SC : %SC %S", self->Name, access_level, typename_to_string(self->ParentType) ); + strbuilder_append_fmt( result, "%S : %S %SB", self->Name, access_level, typename_to_strbuilder(self->ParentType) ); CodeTypename interface = cast(CodeTypename, self->ParentType->Next); if ( interface ) - string_append_strc( result, txt("\n") ); + strbuilder_append_str( result, txt("\n") ); while ( interface ) { - string_append_fmt( result, ", %S", typename_to_string(interface) ); + strbuilder_append_fmt( result, ", %SB", typename_to_strbuilder(interface) ); interface = interface->Next ? cast( CodeTypename, interface->Next) : NullCode; } } else if ( self->Name.Len ) { - string_append_strc( result, self->Name ); + strbuilder_append_str( result, self->Name ); } if ( self->InlineCmt ) { - string_append_fmt( result, " // %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, " // %S", self->InlineCmt->Content ); } - string_append_fmt( result, "\n{\n%S\n}", body_to_string(self->Body) ); + strbuilder_append_fmt( result, "\n{\n%SB\n}", body_to_strbuilder(self->Body) ); if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) - string_append_strc( result, txt(";\n")); + strbuilder_append_str( result, txt(";\n")); } -void struct_to_string_fwd( CodeStruct self, String* result ) +void struct_to_strbuilder_fwd( CodeStruct self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "struct %S %SC", attributes_to_string(self->Attributes), self->Name ); + strbuilder_append_fmt( result, "struct %SB %S", attributes_to_strbuilder(self->Attributes), self->Name ); - else string_append_fmt( result, "struct %SC", self->Name ); + else strbuilder_append_fmt( result, "struct %S", self->Name ); if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { if ( self->InlineCmt ) - string_append_fmt( result, "; %SC", self->InlineCmt->Content ); + strbuilder_append_fmt( result, "; %S", self->InlineCmt->Content ); else - string_append_strc( result, txt( ";\n") ); + strbuilder_append_str( result, txt( ";\n") ); } } -String template_to_string(CodeTemplate self) +StrBuilder template_to_strbuilder(CodeTemplate self) { GEN_ASSERT(self); - String result = string_make_reserve( GlobalAllocator, 1024 ); - template_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 1024 ); + template_to_strbuilder_ref( self, & result ); return result; } -void template_to_string_ref(CodeTemplate self, String* result ) +void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Params ) - string_append_fmt( result, "template< %S >\n%S", params_to_string(self->Params), code_to_string(self->Declaration) ); + strbuilder_append_fmt( result, "template< %SB >\n%SB", params_to_strbuilder(self->Params), code_to_strbuilder(self->Declaration) ); else - string_append_fmt( result, "template<>\n%S", code_to_string(self->Declaration) ); + strbuilder_append_fmt( result, "template<>\n%SB", code_to_strbuilder(self->Declaration) ); } -String typedef_to_string(CodeTypedef self) +StrBuilder typedef_to_strbuilder(CodeTypedef self) { - String result = string_make_reserve( GlobalAllocator, 128 ); - typedef_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 128 ); + typedef_to_strbuilder_ref( self, & result ); return result; } -void typedef_to_string_ref(CodeTypedef self, String* result ) +void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); - string_append_strc( result, txt("typedef ")); + strbuilder_append_str( result, txt("typedef ")); // Determines if the typedef is a function typename if ( self->UnderlyingType->ReturnType ) - string_append_string( result, code_to_string(self->UnderlyingType) ); + strbuilder_append_string( result, code_to_strbuilder(self->UnderlyingType) ); else - string_append_fmt( result, "%S %SC", code_to_string(self->UnderlyingType), self->Name ); + strbuilder_append_fmt( result, "%SB %S", code_to_strbuilder(self->UnderlyingType), self->Name ); if ( self->UnderlyingType->Type == CT_Typename && self->UnderlyingType->ArrExpr ) { - string_append_fmt( result, "[ %S ];", code_to_string(self->UnderlyingType->ArrExpr) ); + strbuilder_append_fmt( result, "[ %SB ];", code_to_strbuilder(self->UnderlyingType->ArrExpr) ); Code next_arr_expr = self->UnderlyingType->ArrExpr->Next; while ( next_arr_expr ) { - string_append_fmt( result, "[ %S ];", code_to_string(next_arr_expr) ); + strbuilder_append_fmt( result, "[ %SB ];", code_to_strbuilder(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } else { - string_append_strc( result, txt(";") ); + strbuilder_append_str( result, txt(";") ); } if ( self->InlineCmt ) - string_append_fmt( result, " %SC", self->InlineCmt->Content); + strbuilder_append_fmt( result, " %S", self->InlineCmt->Content); else - string_append_strc( result, txt("\n")); + strbuilder_append_str( result, txt("\n")); } -String typename_to_string(CodeTypename self) +StrBuilder typename_to_strbuilder(CodeTypename self) { - String result = string_make_strc( GlobalAllocator, txt("") ); - typename_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_str( GlobalAllocator, txt("") ); + typename_to_strbuilder_ref( self, & result ); return result; } -void typename_to_string_ref(CodeTypename self, String* result ) +void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result ) { #if defined(GEN_USE_NEW_TYPENAME_PARSING) if ( self->ReturnType && self->Params ) { if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); else { if ( self->Specs ) - string_append_fmt( result, "%S ( %SC ) ( %S ) %S", typename_to_string(self->ReturnType), self->Name, params_to_string(self->Params), specifiers_to_string(self->Specs) ); + strbuilder_append_fmt( result, "%SB ( %S ) ( %SB ) %SB", typename_to_strbuilder(self->ReturnType), self->Name, params_to_strbuilder(self->Params), specifiers_to_strbuilder(self->Specs) ); else - string_append_fmt( result, "%S ( %SC ) ( %S )", typename_to_string(self->ReturnType), self->Name, params_to_string(self->Params) ); + strbuilder_append_fmt( result, "%SB ( %S ) ( %SB )", typename_to_strbuilder(self->ReturnType), self->Name, params_to_strbuilder(self->Params) ); } break; @@ -1184,13 +1184,13 @@ void typename_to_string_ref(CodeTypename self, String* result ) if ( self->ReturnType && self->Params ) { if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); else { if ( self->Specs ) - string_append_fmt( result, "%S %SC ( %S ) %S", typename_to_string(self->ReturnType), self->Name, params_to_string(self->Params), specifiers_to_string(self->Specs) ); + strbuilder_append_fmt( result, "%SB %S ( %SB ) %SB", typename_to_strbuilder(self->ReturnType), self->Name, params_to_strbuilder(self->Params), specifiers_to_strbuilder(self->Specs) ); else - string_append_fmt( result, "%S %SC ( %S )", typename_to_string(self->ReturnType), self->Name, params_to_string(self->Params) ); + strbuilder_append_fmt( result, "%SB %S ( %SB )", typename_to_strbuilder(self->ReturnType), self->Name, params_to_strbuilder(self->Params) ); } return; @@ -1198,167 +1198,167 @@ void typename_to_string_ref(CodeTypename self, String* result ) #endif if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); switch ( self->TypeTag ) { - case Tag_Class : string_append_strc( result, txt("class ")); break; - case Tag_Enum : string_append_strc( result, txt("enum ")); break; - case Tag_Struct : string_append_strc( result, txt("struct ")); break; - case Tag_Union : string_append_strc( result, txt("union ")); break; + case Tag_Class : strbuilder_append_str( result, txt("class ")); break; + case Tag_Enum : strbuilder_append_str( result, txt("enum ")); break; + case Tag_Struct : strbuilder_append_str( result, txt("struct ")); break; + case Tag_Union : strbuilder_append_str( result, txt("union ")); break; default: break; } if ( self->Specs ) - string_append_fmt( result, "%SC %S", self->Name, specifiers_to_string(self->Specs) ); + strbuilder_append_fmt( result, "%S %SB", self->Name, specifiers_to_strbuilder(self->Specs) ); else - string_append_fmt( result, "%SC", self->Name ); + strbuilder_append_fmt( result, "%S", self->Name ); if ( self->IsParamPack ) - string_append_strc( result, txt("...")); + strbuilder_append_str( result, txt("...")); } -String union_to_string(CodeUnion self) +StrBuilder union_to_strbuilder(CodeUnion self) { - String result = string_make_reserve( GlobalAllocator, 512 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Union: - union_to_string_def( self, & result ); + union_to_strbuilder_def( self, & result ); break; case CT_Union_Fwd: - union_to_string_fwd( self, & result ); + union_to_strbuilder_fwd( self, & result ); break; } return result; } -void union_to_string_def(CodeUnion self, String* result ) +void union_to_strbuilder_def(CodeUnion self, StrBuilder* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); - string_append_strc( result, txt("union ") ); + strbuilder_append_str( result, txt("union ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); if ( self->Name.Len ) { - string_append_fmt( result, "%SC\n{\n%S\n}" + strbuilder_append_fmt( result, "%S\n{\n%SB\n}" , self->Name - , body_to_string(self->Body) + , body_to_strbuilder(self->Body) ); } else { // Anonymous union - string_append_fmt( result, "\n{\n%S\n}" - , body_to_string(self->Body) + strbuilder_append_fmt( result, "\n{\n%SB\n}" + , body_to_strbuilder(self->Body) ); } if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) - string_append_strc( result, txt(";\n")); + strbuilder_append_str( result, txt(";\n")); } -void union_to_string_fwd(CodeUnion self, String* result ) +void union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); - string_append_strc( result, txt("union ") ); + strbuilder_append_str( result, txt("union ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); if ( self->Name.Len ) { - string_append_fmt( result, "%SC", self->Name); + strbuilder_append_fmt( result, "%S", self->Name); } if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) - string_append_strc( result, txt(";\n")); + strbuilder_append_str( result, txt(";\n")); } -String using_to_string(CodeUsing self) +StrBuilder using_to_strbuilder(CodeUsing self) { GEN_ASSERT(self); - String result = string_make_reserve( GlobalAllocator, 128 ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 128 ); switch ( self->Type ) { case CT_Using: - using_to_string_ref( self, & result ); + using_to_strbuilder_ref( self, & result ); break; case CT_Using_Namespace: - using_to_string_ns( self, & result ); + using_to_strbuilder_ns( self, & result ); break; } return result; } -void using_to_string_ref(CodeUsing self, String* result ) +void using_to_strbuilder_ref(CodeUsing self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); + strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); if ( self->UnderlyingType ) { - string_append_fmt( result, "using %SC = %S", self->Name, typename_to_string(self->UnderlyingType) ); + strbuilder_append_fmt( result, "using %S = %SB", self->Name, typename_to_strbuilder(self->UnderlyingType) ); if ( self->UnderlyingType->ArrExpr ) { - string_append_fmt( result, "[ %S ]", code_to_string(self->UnderlyingType->ArrExpr) ); + strbuilder_append_fmt( result, "[ %SB ]", code_to_strbuilder(self->UnderlyingType->ArrExpr) ); Code next_arr_expr = self->UnderlyingType->ArrExpr->Next; while ( next_arr_expr ) { - string_append_fmt( result, "[ %S ]", code_to_string(next_arr_expr) ); + strbuilder_append_fmt( result, "[ %SB ]", code_to_strbuilder(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } - string_append_strc( result, txt(";") ); + strbuilder_append_str( result, txt(";") ); } else - string_append_fmt( result, "using %SC;", self->Name ); + strbuilder_append_fmt( result, "using %S;", self->Name ); if ( self->InlineCmt ) - string_append_fmt( result, " %SC\n", self->InlineCmt->Content ); + strbuilder_append_fmt( result, " %S\n", self->InlineCmt->Content ); else - string_append_strc( result, txt("\n")); + strbuilder_append_str( result, txt("\n")); } inline -void using_to_string_ns(CodeUsing self, String* result ) +void using_to_strbuilder_ns(CodeUsing self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); if ( self->InlineCmt ) - string_append_fmt( result, "using namespace $SC; %SC", self->Name, self->InlineCmt->Content ); + strbuilder_append_fmt( result, "using namespace $SC; %S", self->Name, self->InlineCmt->Content ); else - string_append_fmt( result, "using namespace %SC;\n", self->Name ); + strbuilder_append_fmt( result, "using namespace %S;\n", self->Name ); } inline -String var_to_string(CodeVar self) +StrBuilder var_to_strbuilder(CodeVar self) { GEN_ASSERT(self); - String result = string_make_reserve( GlobalAllocator, 256 ); - var_to_string_ref( self, & result ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, 256 ); + var_to_strbuilder_ref( self, & result ); return result; } neverinline -void var_to_string_ref(CodeVar self, String* result ) +void var_to_strbuilder_ref(CodeVar self, StrBuilder* result ) { GEN_ASSERT(self); GEN_ASSERT(result); @@ -1367,18 +1367,18 @@ void var_to_string_ref(CodeVar self, String* result ) // Its a comma-separated variable ( a NextVar ) if ( self->Specs ) - string_append_fmt( result, "%S ", specifiers_to_string(self->Specs) ); + strbuilder_append_fmt( result, "%SB ", specifiers_to_strbuilder(self->Specs) ); - string_append_strc( result, self->Name ); + strbuilder_append_str( result, self->Name ); if ( self->ValueType->ArrExpr ) { - string_append_fmt( result, "[ %S ]", code_to_string(self->ValueType->ArrExpr) ); + strbuilder_append_fmt( result, "[ %SB ]", code_to_strbuilder(self->ValueType->ArrExpr) ); Code next_arr_expr = self->ValueType->ArrExpr->Next; while ( next_arr_expr ) { - string_append_fmt( result, "[ %S ]", code_to_string(next_arr_expr) ); + strbuilder_append_fmt( result, "[ %SB ]", code_to_strbuilder(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } @@ -1386,107 +1386,107 @@ void var_to_string_ref(CodeVar self, String* result ) if ( self->Value ) { if ( self->VarParenthesizedInit ) - string_append_fmt( result, "( %S ", code_to_string(self->Value) ); + strbuilder_append_fmt( result, "( %SB ", code_to_strbuilder(self->Value) ); else - string_append_fmt( result, " = %S", code_to_string(self->Value) ); + strbuilder_append_fmt( result, " = %SB", code_to_strbuilder(self->Value) ); } // Keep the chain going... if ( self->NextVar ) - string_append_fmt( result, ", %S", var_to_string(self->NextVar) ); + strbuilder_append_fmt( result, ", %SB", var_to_strbuilder(self->NextVar) ); if ( self->VarParenthesizedInit ) - string_append_strc( result, txt(" )")); + strbuilder_append_str( result, txt(" )")); return; } if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) - string_append_strc( result, txt("export ") ); + strbuilder_append_str( result, txt("export ") ); if ( self->Attributes || self->Specs ) { if ( self->Attributes ) - string_append_fmt( result, "%S ", specifiers_to_string(self->Specs) ); + strbuilder_append_fmt( result, "%SB ", specifiers_to_strbuilder(self->Specs) ); if ( self->Specs ) - string_append_fmt( result, "%S\n", specifiers_to_string(self->Specs) ); + strbuilder_append_fmt( result, "%SB\n", specifiers_to_strbuilder(self->Specs) ); - string_append_fmt( result, "%S %SC", typename_to_string(self->ValueType), self->Name ); + strbuilder_append_fmt( result, "%SB %S", typename_to_strbuilder(self->ValueType), self->Name ); - if ( self->ValueType->ArrExpr ) + if ( self->ValueType && self->ValueType->ArrExpr ) { - string_append_fmt( result, "[ %S ]", code_to_string(self->ValueType->ArrExpr) ); + strbuilder_append_fmt( result, "[ %SB ]", code_to_strbuilder(self->ValueType->ArrExpr) ); Code next_arr_expr = self->ValueType->ArrExpr->Next; while ( next_arr_expr ) { - string_append_fmt( result, "[ %S ]", code_to_string(next_arr_expr) ); + strbuilder_append_fmt( result, "[ %SB ]", code_to_strbuilder(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } if ( self->BitfieldSize ) - string_append_fmt( result, " : %S", code_to_string(self->BitfieldSize) ); + strbuilder_append_fmt( result, " : %SB", code_to_strbuilder(self->BitfieldSize) ); if ( self->Value ) { if ( self->VarParenthesizedInit ) - string_append_fmt( result, "( %S ", code_to_string(self->Value) ); + strbuilder_append_fmt( result, "( %SB ", code_to_strbuilder(self->Value) ); else - string_append_fmt( result, " = %S", code_to_string(self->Value) ); + strbuilder_append_fmt( result, " = %SB", code_to_strbuilder(self->Value) ); } if ( self->NextVar ) - string_append_fmt( result, ", %S", var_to_string(self->NextVar) ); + strbuilder_append_fmt( result, ", %SB", var_to_strbuilder(self->NextVar) ); if ( self->VarParenthesizedInit ) - string_append_strc( result, txt(" )")); + strbuilder_append_str( result, txt(" )")); if ( self->InlineCmt ) - string_append_fmt( result, "; %SC", self->InlineCmt->Content); + strbuilder_append_fmt( result, "; %S", self->InlineCmt->Content); else - string_append_strc( result, txt(";\n") ); + strbuilder_append_str( result, txt(";\n") ); return; } if ( self->BitfieldSize ) - string_append_fmt( result, "%S %SC : %S", typename_to_string(self->ValueType), self->Name, code_to_string(self->BitfieldSize) ); + strbuilder_append_fmt( result, "%SB %S : %SB", typename_to_strbuilder(self->ValueType), self->Name, code_to_strbuilder(self->BitfieldSize) ); else if ( self->ValueType->ArrExpr ) { - string_append_fmt( result, "%S %SC[ %S ]", typename_to_string(self->ValueType), self->Name, code_to_string(self->ValueType->ArrExpr) ); + strbuilder_append_fmt( result, "%SB %S[ %SB ]", typename_to_strbuilder(self->ValueType), self->Name, code_to_strbuilder(self->ValueType->ArrExpr) ); Code next_arr_expr = self->ValueType->ArrExpr->Next; while ( next_arr_expr ) { - string_append_fmt( result, "[ %S ]", code_to_string(next_arr_expr) ); + strbuilder_append_fmt( result, "[ %SB ]", code_to_strbuilder(next_arr_expr) ); next_arr_expr = next_arr_expr->Next; } } else - string_append_fmt( result, "%S %SC", typename_to_string(self->ValueType), self->Name ); + strbuilder_append_fmt( result, "%SB %S", typename_to_strbuilder(self->ValueType), self->Name ); if ( self->Value ) { if ( self->VarParenthesizedInit ) - string_append_fmt( result, "( %S ", code_to_string(self->Value) ); + strbuilder_append_fmt( result, "( %SB ", code_to_strbuilder(self->Value) ); else - string_append_fmt( result, " = %S", code_to_string(self->Value) ); + strbuilder_append_fmt( result, " = %SB", code_to_strbuilder(self->Value) ); } if ( self->NextVar ) - string_append_fmt( result, ", %S", var_to_string( self->NextVar) ); + strbuilder_append_fmt( result, ", %SB", var_to_strbuilder( self->NextVar) ); if ( self->VarParenthesizedInit ) - string_append_strc( result, txt(" )")); + strbuilder_append_str( result, txt(" )")); - string_append_strc( result, txt(";") ); + strbuilder_append_str( result, txt(";") ); if ( self->InlineCmt ) - string_append_fmt( result, " %SC", self->InlineCmt->Content); + strbuilder_append_fmt( result, " %S", self->InlineCmt->Content); else - string_append_strc( result, txt("\n")); + strbuilder_append_str( result, txt("\n")); } diff --git a/base/components/code_types.hpp b/base/components/code_types.hpp index 22ae89e..0611e0b 100644 --- a/base/components/code_types.hpp +++ b/base/components/code_types.hpp @@ -17,128 +17,128 @@ #pragma region Code Type C-Interface -void body_append ( CodeBody body, Code other ); -void body_append_body ( CodeBody body, CodeBody other ); -String body_to_string ( CodeBody body ); -void body_to_string_ref ( CodeBody body, String* result ); -void body_to_string_export( CodeBody body, String* result ); +void body_append ( CodeBody body, Code other ); +void body_append_body ( CodeBody body, CodeBody other ); +StrBuilder body_to_strbuilder ( CodeBody body ); +void body_to_strbuilder_ref ( CodeBody body, StrBuilder* result ); +void body_to_strbuilder_export( CodeBody body, StrBuilder* result ); Code begin_CodeBody( CodeBody body); Code end_CodeBody ( CodeBody body ); Code next_CodeBody ( CodeBody body, Code entry_iter ); -void class_add_interface( CodeClass self, CodeTypename interface ); -String class_to_string ( CodeClass self ); -void class_to_string_def( CodeClass self, String* result ); -void class_to_string_fwd( CodeClass self, String* result ); +void class_add_interface ( CodeClass self, CodeTypename interface ); +StrBuilder class_to_strbuilder ( CodeClass self ); +void class_to_strbuilder_def( CodeClass self, StrBuilder* result ); +void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result ); -void params_append (CodeParams params, CodeParams param ); -CodeParams params_get (CodeParams params, s32 idx); -bool params_has_entries (CodeParams params ); -String params_to_string (CodeParams params ); -void params_to_string_ref(CodeParams params, String* result ); +void params_append (CodeParams params, CodeParams param ); +CodeParams params_get (CodeParams params, s32 idx); +bool params_has_entries (CodeParams params ); +StrBuilder params_to_strbuilder (CodeParams params ); +void params_to_strbuilder_ref(CodeParams params, StrBuilder* result ); CodeParams begin_CodeParams(CodeParams params); CodeParams end_CodeParams (CodeParams params); CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter); -bool specifiers_append (CodeSpecifiers specifiers, Specifier spec); -s32 specifiers_has (CodeSpecifiers specifiers, Specifier spec); -s32 specifiers_remove (CodeSpecifiers specifiers, Specifier to_remove ); -String specifiers_to_string (CodeSpecifiers specifiers); -void specifiers_to_string_ref(CodeSpecifiers specifiers, String* result); +bool specifiers_append (CodeSpecifiers specifiers, Specifier spec); +s32 specifiers_has (CodeSpecifiers specifiers, Specifier spec); +s32 specifiers_remove (CodeSpecifiers specifiers, Specifier to_remove ); +StrBuilder specifiers_to_strbuilder (CodeSpecifiers specifiers); +void specifiers_to_strbuilder_ref(CodeSpecifiers specifiers, StrBuilder* result); Specifier* begin_CodeSpecifiers(CodeSpecifiers specifiers); Specifier* end_CodeSpecifiers (CodeSpecifiers specifiers); Specifier* next_CodeSpecifiers (CodeSpecifiers specifiers, Specifier* spec_iter); -void struct_add_interface(CodeStruct self, CodeTypename interface); -String struct_to_string (CodeStruct self); -void struct_to_string_fwd(CodeStruct self, String* result); -void struct_to_string_def(CodeStruct self, String* result); +void struct_add_interface (CodeStruct self, CodeTypename interface); +StrBuilder struct_to_strbuilder (CodeStruct self); +void struct_to_strbuilder_fwd(CodeStruct self, StrBuilder* result); +void struct_to_strbuilder_def(CodeStruct self, StrBuilder* result); -String attributes_to_string (CodeAttributes attributes); -void attributes_to_string_ref(CodeAttributes attributes, String* result); +StrBuilder attributes_to_strbuilder (CodeAttributes attributes); +void attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result); -String comment_to_string (CodeComment comment ); -void comment_to_string_ref(CodeComment comment, String* result ); +StrBuilder comment_to_strbuilder (CodeComment comment ); +void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result ); -String constructor_to_string (CodeConstructor constructor); -void constructor_to_string_def(CodeConstructor constructor, String* result ); -void constructor_to_string_fwd(CodeConstructor constructor, String* result ); +StrBuilder constructor_to_strbuilder (CodeConstructor constructor); +void constructor_to_strbuilder_def(CodeConstructor constructor, StrBuilder* result ); +void constructor_to_strbuilder_fwd(CodeConstructor constructor, StrBuilder* result ); -String define_to_string (CodeDefine self); -void define_to_string_ref(CodeDefine self, String* result); +StrBuilder define_to_strbuilder (CodeDefine self); +void define_to_strbuilder_ref(CodeDefine self, StrBuilder* result); -String destructor_to_string (CodeDestructor destructor); -void destructor_to_string_def(CodeDestructor destructor, String* result ); -void destructor_to_string_fwd(CodeDestructor destructor, String* result ); +StrBuilder destructor_to_strbuilder (CodeDestructor destructor); +void destructor_to_strbuilder_fwd(CodeDestructor destructor, StrBuilder* result ); +void destructor_to_strbuilder_def(CodeDestructor destructor, StrBuilder* result ); -String enum_to_string (CodeEnum self); -void enum_to_string_def (CodeEnum self, String* result ); -void enum_to_string_fwd (CodeEnum self, String* result ); -void enum_to_string_class_def(CodeEnum self, String* result ); -void enum_to_string_class_fwd(CodeEnum self, String* result ); +StrBuilder enum_to_strbuilder (CodeEnum self); +void enum_to_strbuilder_def (CodeEnum self, StrBuilder* result ); +void enum_to_strbuilder_fwd (CodeEnum self, StrBuilder* result ); +void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result ); +void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result ); -String exec_to_string (CodeExec exec); -void exec_to_string_ref(CodeExec exec, String* result); +StrBuilder exec_to_strbuilder (CodeExec exec); +void exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result); -void extern_to_string(CodeExtern self, String* result); +void extern_to_strbuilder(CodeExtern self, StrBuilder* result); -String include_to_string (CodeInclude self); -void include_to_string_ref(CodeInclude self, String* result); +StrBuilder include_to_strbuilder (CodeInclude self); +void include_to_strbuilder_ref(CodeInclude self, StrBuilder* result); -String friend_to_string (CodeFriend self); -void friend_to_string_ref(CodeFriend self, String* result); +StrBuilder friend_to_strbuilder (CodeFriend self); +void friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result); -String fn_to_string (CodeFn self); -void fn_to_string_def(CodeFn self, String* result); -void fn_to_string_fwd(CodeFn self, String* result); +StrBuilder fn_to_strbuilder (CodeFn self); +void fn_to_strbuilder_def(CodeFn self, StrBuilder* result); +void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result); -String module_to_string (CodeModule self); -void module_to_string_ref(CodeModule self, String* result); +StrBuilder module_to_strbuilder (CodeModule self); +void module_to_strbuilder_ref(CodeModule self, StrBuilder* result); -String namespace_to_string (CodeNS self); -void namespace_to_string_ref(CodeNS self, String* result); +StrBuilder namespace_to_strbuilder (CodeNS self); +void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result); -String code_op_to_string (CodeOperator self); -void code_op_to_string_fwd(CodeOperator self, String* result ); -void code_op_to_string_def(CodeOperator self, String* result ); +StrBuilder code_op_to_strbuilder (CodeOperator self); +void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result ); +void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result ); -String opcast_to_string (CodeOpCast op_cast ); -void opcast_to_string_def(CodeOpCast op_cast, String* result ); -void opcast_to_string_fwd(CodeOpCast op_cast, String* result ); +StrBuilder opcast_to_strbuilder (CodeOpCast op_cast ); +void opcast_to_strbuilder_def(CodeOpCast op_cast, StrBuilder* result ); +void opcast_to_strbuilder_fwd(CodeOpCast op_cast, StrBuilder* result ); -String pragma_to_string (CodePragma self); -void pragma_to_string_ref(CodePragma self, String* result); +StrBuilder pragma_to_strbuilder (CodePragma self); +void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result); -String preprocess_to_string (CodePreprocessCond cond); -void preprocess_to_string_if (CodePreprocessCond cond, String* result ); -void preprocess_to_string_ifdef (CodePreprocessCond cond, String* result ); -void preprocess_to_string_ifndef(CodePreprocessCond cond, String* result ); -void preprocess_to_string_elif (CodePreprocessCond cond, String* result ); -void preprocess_to_string_else (CodePreprocessCond cond, String* result ); -void preprocess_to_string_endif (CodePreprocessCond cond, String* result ); +StrBuilder preprocess_to_strbuilder (CodePreprocessCond cond); +void preprocess_to_strbuilder_if (CodePreprocessCond cond, StrBuilder* result ); +void preprocess_to_strbuilder_ifdef (CodePreprocessCond cond, StrBuilder* result ); +void preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result ); +void preprocess_to_strbuilder_elif (CodePreprocessCond cond, StrBuilder* result ); +void preprocess_to_strbuilder_else (CodePreprocessCond cond, StrBuilder* result ); +void preprocess_to_strbuilder_endif (CodePreprocessCond cond, StrBuilder* result ); -String template_to_string (CodeTemplate self); -void template_to_string_ref(CodeTemplate self, String* result); +StrBuilder template_to_strbuilder (CodeTemplate self); +void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result); -String typename_to_string (CodeTypename self); -void typename_to_string_ref(CodeTypename self, String* result); +StrBuilder typename_to_strbuilder (CodeTypename self); +void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result); -String typedef_to_string (CodeTypedef self); -void typedef_to_string_ref(CodeTypedef self, String* result ); +StrBuilder typedef_to_strbuilder (CodeTypedef self); +void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result ); -String union_to_string (CodeUnion self); -void union_to_string_def(CodeUnion self, String* result); -void union_to_string_fwd(CodeUnion self, String* result); +StrBuilder union_to_strbuilder (CodeUnion self); +void union_to_strbuilder_def(CodeUnion self, StrBuilder* result); +void union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result); -String using_to_string (CodeUsing op_cast ); -void using_to_string_ref(CodeUsing op_cast, String* result ); -void using_to_string_ns (CodeUsing op_cast, String* result ); +StrBuilder using_to_strbuilder (CodeUsing op_cast ); +void using_to_strbuilder_ref(CodeUsing op_cast, StrBuilder* result ); +void using_to_strbuilder_ns (CodeUsing op_cast, StrBuilder* result ); -String var_to_string (CodeVar self); -void var_to_string_ref(CodeVar self, String* result); +StrBuilder var_to_strbuilder (CodeVar self); +void var_to_strbuilder_ref(CodeVar self, StrBuilder* result); #pragma endregion Code Type C-Interface @@ -154,16 +154,16 @@ struct CodeBody { #if ! GEN_C_LIKE_CPP Using_Code( CodeBody ); - forceinline void append( Code other ) { return body_append( *this, other ); } - forceinline void append( CodeBody body ) { return body_append(*this, body); } - forceinline bool has_entries() { return code_has_entries(* this); } - forceinline String to_string() { return body_to_string(* this); } - forceinline void to_string( String& result ) { return body_to_string_ref(* this, & result ); } - forceinline void to_string_export( String& result ) { return body_to_string_export(* this, & result); } + forceinline void append( Code other ) { return body_append( *this, other ); } + forceinline void append( CodeBody body ) { return body_append(*this, body); } + forceinline bool has_entries() { return code_has_entries(* this); } + forceinline StrBuilder to_strbuilder() { return body_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return body_to_strbuilder_ref(* 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 end() { return end_CodeBody(* this); } -#endif Using_CodeOps( CodeBody ); forceinline operator Code() { return * rcast( Code*, this ); } forceinline AST_Body* operator->() { return ast; } @@ -174,10 +174,10 @@ struct CodeClass { #if ! GEN_C_LIKE_CPP Using_Code( CodeClass ); - forceinline void add_interface( CodeType interface ); - forceinline String to_string(); - forceinline void to_string_def( String& result ); - forceinline void to_string_fwd( String& result ); + forceinline void add_interface( CodeType interface ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder_def( StrBuilder& result ); + forceinline void to_strbuilder_fwd( StrBuilder& result ); #endif Using_CodeOps( CodeClass ); forceinline operator Code() { return * rcast( Code*, this ); } @@ -192,18 +192,18 @@ struct CodeParams { #if ! GEN_C_LIKE_CPP Using_Code( CodeParams ); - forceinline void append( CodeParams other ); - forceinline CodeParams get( s32 idx ); - forceinline bool has_entries(); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline void append( CodeParams other ); + forceinline CodeParams get( s32 idx ); + forceinline bool has_entries(); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); - forceinline CodeParams begin() { return begin_CodeParams(* this); } - forceinline CodeParams end() { return end_CodeParams(* this); } #endif Using_CodeOps( CodeParams ); - forceinline operator Code() { return { (AST*)ast }; } - forceinline CodeParams operator*() { return * this; } + forceinline CodeParams begin() { return begin_CodeParams(* this); } + forceinline CodeParams end() { return end_CodeParams(* this); } + forceinline operator Code() { return { (AST*)ast }; } + forceinline CodeParams operator *() { return * this; } // Required to support for-range iteration. forceinline AST_Params* operator->() { GEN_ASSERT(ast); return ast; @@ -216,14 +216,15 @@ struct CodeSpecifiers { #if ! GEN_C_LIKE_CPP Using_Code( CodeSpecifiers ); - bool append( Specifier spec ) { return specifiers_append(* this, spec); } - s32 has( Specifier spec ) { return specifiers_has(* this, spec); } - s32 remove( Specifier to_remove ) { return specifiers_remove(* this, to_remove); } - String to_string() { return specifiers_to_string(* this ); } - void to_string( String& result ) { return specifiers_to_string_ref(* this, & result); } + bool append( Specifier spec ) { return specifiers_append(* this, spec); } + s32 has( Specifier spec ) { return specifiers_has(* this, spec); } + s32 remove( Specifier to_remove ) { return specifiers_remove(* this, to_remove); } + StrBuilder to_strbuilder() { return specifiers_to_strbuilder(* this ); } + void to_strbuilder( StrBuilder& result ) { return specifiers_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeSpecifiers); forceinline operator Code() { return { (AST*) ast }; } + forceinline Code operator *() { return * this; } // Required to support for-range iteration. forceinline AST_Specifiers* operator->() { GEN_ASSERT(ast); return ast; @@ -235,8 +236,8 @@ struct CodeAttributes { #if ! GEN_C_LIKE_CPP Using_Code(CodeAttributes); - forceinline String to_string() { return attributes_to_string(* this); } - forceinline void to_string(String& result) { return attributes_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return attributes_to_strbuilder(* this); } + forceinline void to_strbuilder(StrBuilder& result) { return attributes_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeAttributes); operator Code(); @@ -250,8 +251,8 @@ struct CodeComment { #if ! GEN_C_LIKE_CPP Using_Code(CodeComment); - forceinline String to_string() { return comment_to_string (* this); } - forceinline void to_string(String& result) { return comment_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return comment_to_strbuilder (* this); } + forceinline void to_strbuilder(StrBuilder& result) { return comment_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeComment); operator Code(); @@ -263,9 +264,9 @@ struct CodeConstructor { #if ! GEN_C_LIKE_CPP Using_Code( CodeConstructor ); - forceinline String to_string() { return constructor_to_string(* this); } - forceinline void to_string_def( String& result ) { return constructor_to_string_def(* this, & result); } - forceinline void to_string_fwd( String& result ) { return constructor_to_string_fwd(* this, & result); } + forceinline StrBuilder to_strbuilder() { return constructor_to_strbuilder(* this); } + forceinline void to_strbuilder_def( StrBuilder& result ) { return constructor_to_strbuilder_def(* this, & result); } + forceinline void to_strbuilder_fwd( StrBuilder& result ) { return constructor_to_strbuilder_fwd(* this, & result); } #endif Using_CodeOps(CodeConstructor); operator Code(); @@ -277,8 +278,8 @@ struct CodeDefine { #if ! GEN_C_LIKE_CPP Using_Code( CodeDefine ); - forceinline String to_string() { return define_to_string(* this); } - forceinline void to_string( String& result ) { return define_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return define_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return define_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeDefine); operator Code(); @@ -290,9 +291,9 @@ struct CodeDestructor { #if ! GEN_C_LIKE_CPP Using_Code( CodeDestructor ); - forceinline String to_string() { return destructor_to_string(* this); } - forceinline void to_string_def( String& result ) { return destructor_to_string_def(* this, & result); } - forceinline void to_string_fwd( String& result ) { return destructor_to_string_fwd(* this, & result); } + forceinline StrBuilder to_strbuilder() { return destructor_to_strbuilder(* this); } + forceinline void to_strbuilder_def( StrBuilder& result ) { return destructor_to_strbuilder_def(* this, & result); } + forceinline void to_strbuilder_fwd( StrBuilder& result ) { return destructor_to_strbuilder_fwd(* this, & result); } #endif Using_CodeOps(CodeDestructor); operator Code(); @@ -304,11 +305,11 @@ struct CodeEnum { #if ! GEN_C_LIKE_CPP Using_Code( CodeEnum ); - forceinline String to_string() { return enum_to_string(* this); } - forceinline void to_string_def( String& result ) { return enum_to_string_def(* this, & result); } - forceinline void to_string_fwd( String& result ) { return enum_to_string_fwd(* this, & result); } - forceinline void to_string_class_def( String& result ) { return enum_to_string_class_def(* this, & result); } - forceinline void to_string_class_fwd( String& result ) { return enum_to_string_class_fwd(* this, & result); } + forceinline StrBuilder to_strbuilder() { return enum_to_strbuilder(* this); } + forceinline void to_strbuilder_def( StrBuilder& result ) { return enum_to_strbuilder_def(* this, & result); } + forceinline void to_strbuilder_fwd( StrBuilder& result ) { return enum_to_strbuilder_fwd(* this, & result); } + forceinline void to_strbuilder_class_def( StrBuilder& result ) { return enum_to_strbuilder_class_def(* this, & result); } + forceinline void to_strbuilder_class_fwd( StrBuilder& result ) { return enum_to_strbuilder_class_fwd(* this, & result); } #endif Using_CodeOps(CodeEnum); operator Code(); @@ -320,8 +321,8 @@ struct CodeExec { #if ! GEN_C_LIKE_CPP Using_Code(CodeExec); - forceinline String to_string() { return exec_to_string(* this); } - forceinline void to_string(String& result) { return exec_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return exec_to_strbuilder(* this); } + forceinline void to_strbuilder(StrBuilder& result) { return exec_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeExec); operator Code(); @@ -334,7 +335,7 @@ struct CodeExpr { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr* operator->(); @@ -345,7 +346,7 @@ struct CodeExpr_Assign { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Assign ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Assign* operator->(); @@ -356,7 +357,7 @@ struct CodeExpr_Alignof { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Alignof ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Alignof* operator->(); @@ -367,7 +368,7 @@ struct CodeExpr_Binary { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Binary ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Binary* operator->(); @@ -378,7 +379,7 @@ struct CodeExpr_CStyleCast { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_CStyleCast ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_CStyleCast* operator->(); @@ -389,7 +390,7 @@ struct CodeExpr_FunctionalCast { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_FunctionalCast ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_FunctionalCast* operator->(); @@ -400,7 +401,7 @@ struct CodeExpr_CppCast { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_CppCast ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_CppCast* operator->(); @@ -411,7 +412,7 @@ struct CodeExpr_Element { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Element ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Element* operator->(); @@ -422,7 +423,7 @@ struct CodeExpr_ProcCall { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_ProcCall ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_ProcCall* operator->(); @@ -433,7 +434,7 @@ struct CodeExpr_Decltype { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Decltype ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Decltype* operator->(); @@ -444,7 +445,7 @@ struct CodeExpr_Comma { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Comma ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Comma* operator->(); @@ -455,7 +456,7 @@ struct CodeExpr_AMS { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_AMS ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_AMS* operator->(); @@ -466,7 +467,7 @@ struct CodeExpr_Sizeof { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Sizeof ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Sizeof* operator->(); @@ -477,7 +478,7 @@ struct CodeExpr_Subscript { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Subscript ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Subscript* operator->(); @@ -488,7 +489,7 @@ struct CodeExpr_Ternary { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Ternary ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_Ternary* operator->(); @@ -499,7 +500,7 @@ struct CodeExpr_UnaryPrefix { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_UnaryPrefix ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Expr_UnaryPrefix* operator->(); @@ -510,7 +511,7 @@ struct CodeExpr_UnaryPostfix { #if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_UnaryPostfix ); - forceinline void to_string( String& result ); + forceinline void to_strbuilder( StrBuilder& result ); #endif AST* raw(); operator Code(); @@ -523,7 +524,7 @@ struct CodeExtern { #if ! GEN_C_LIKE_CPP Using_Code( CodeExtern ); - forceinline void to_string( String& result ) { return extern_to_string(* this, & result); } + forceinline void to_strbuilder( StrBuilder& result ) { return extern_to_strbuilder(* this, & result); } #endif Using_CodeOps(CodeExtern); operator Code(); @@ -535,8 +536,8 @@ struct CodeInclude { #if ! GEN_C_LIKE_CPP Using_Code( CodeInclude ); - String to_string() { return include_to_string(* this); } - forceinline void to_string( String& result ) { return include_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return include_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return include_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeInclude); operator Code(); @@ -548,8 +549,8 @@ struct CodeFriend { #if ! GEN_C_LIKE_CPP Using_Code( CodeFriend ); - forceinline String to_string() { return friend_to_string(* this); } - forceinline void to_string( String& result ) { return friend_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return friend_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return friend_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeFriend); operator Code(); @@ -561,9 +562,9 @@ struct CodeFn { #if ! GEN_C_LIKE_CPP Using_Code( CodeFn ); - forceinline String to_string() { return fn_to_string(* this); } - forceinline void to_string_def( String& result ) { return fn_to_string_def(* this, & result); } - forceinline void to_string_fwd( String& result ) { return fn_to_string_fwd(* this, & result); } + forceinline StrBuilder to_strbuilder() { return fn_to_strbuilder(* this); } + forceinline void to_strbuilder_def( StrBuilder& result ) { return fn_to_strbuilder_def(* this, & result); } + forceinline void to_strbuilder_fwd( StrBuilder& result ) { return fn_to_strbuilder_fwd(* this, & result); } #endif Using_CodeOps(CodeFn); operator Code(); @@ -575,8 +576,8 @@ struct CodeModule { #if ! GEN_C_LIKE_CPP Using_Code( CodeModule ); - forceinline String to_string() { return module_to_string(* this); } - forceinline void to_string( String& result ) { return module_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return module_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return module_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeModule); operator Code(); @@ -588,8 +589,8 @@ struct CodeNS { #if ! GEN_C_LIKE_CPP Using_Code( CodeNS ); - forceinline String to_string() { return namespace_to_string(* this); } - forceinline void to_string( String& result ) { return namespace_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return namespace_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return namespace_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeNS); operator Code(); @@ -601,9 +602,9 @@ struct CodeOperator { #if ! GEN_C_LIKE_CPP Using_Code( CodeOperator ); - forceinline String to_string() { return code_op_to_string(* this); } - forceinline void to_string_def( String& result ) { return code_op_to_string_def(* this, & result); } - forceinline void to_string_fwd( String& result ) { return code_op_to_string_fwd(* this, & result); } + forceinline StrBuilder to_strbuilder() { return code_op_to_strbuilder(* this); } + forceinline void to_strbuilder_def( StrBuilder& result ) { return code_op_to_strbuilder_def(* this, & result); } + forceinline void to_strbuilder_fwd( StrBuilder& result ) { return code_op_to_strbuilder_fwd(* this, & result); } #endif Using_CodeOps(CodeOperator); operator Code(); @@ -615,9 +616,9 @@ struct CodeOpCast { #if ! GEN_C_LIKE_CPP Using_Code( CodeOpCast ); - forceinline String to_string() { return opcast_to_string(* this); } - forceinline void to_string_def( String& result ) { return opcast_to_string_def(* this, & result); } - forceinline void to_string_fwd( String& result ) { return opcast_to_string_fwd(* this, & result); } + forceinline StrBuilder to_strbuilder() { return opcast_to_strbuilder(* this); } + forceinline void to_strbuilder_def( StrBuilder& result ) { return opcast_to_strbuilder_def(* this, & result); } + forceinline void to_strbuilder_fwd( StrBuilder& result ) { return opcast_to_strbuilder_fwd(* this, & result); } #endif Using_CodeOps(CodeOpCast); operator Code(); @@ -629,8 +630,8 @@ struct CodePragma { #if ! GEN_C_LIKE_CPP Using_Code( CodePragma ); - forceinline String to_string() { return pragma_to_string(* this); } - forceinline void to_string( String& result ) { return pragma_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return pragma_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return pragma_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps( CodePragma ); operator Code(); @@ -642,13 +643,13 @@ struct CodePreprocessCond { #if ! GEN_C_LIKE_CPP Using_Code( CodePreprocessCond ); - forceinline String to_string() { return preprocess_to_string(* this); } - forceinline void to_string_if( String& result ) { return preprocess_to_string_if(* this, & result); } - forceinline void to_string_ifdef( String& result ) { return preprocess_to_string_ifdef(* this, & result); } - forceinline void to_string_ifndef( String& result ) { return preprocess_to_string_ifndef(* this, & result); } - forceinline void to_string_elif( String& result ) { return preprocess_to_string_elif(* this, & result); } - forceinline void to_string_else( String& result ) { return preprocess_to_string_else(* this, & result); } - forceinline void to_string_endif( String& result ) { return preprocess_to_string_endif(* this, & result); } + forceinline StrBuilder to_strbuilder() { return preprocess_to_strbuilder(* this); } + forceinline void to_strbuilder_if( StrBuilder& result ) { return preprocess_to_strbuilder_if(* this, & result); } + forceinline void to_strbuilder_ifdef( StrBuilder& result ) { return preprocess_to_strbuilder_ifdef(* this, & result); } + forceinline void to_strbuilder_ifndef( StrBuilder& result ) { return preprocess_to_strbuilder_ifndef(* this, & result); } + forceinline void to_strbuilder_elif( StrBuilder& result ) { return preprocess_to_strbuilder_elif(* this, & result); } + forceinline void to_strbuilder_else( StrBuilder& result ) { return preprocess_to_strbuilder_else(* this, & result); } + forceinline void to_strbuilder_endif( StrBuilder& result ) { return preprocess_to_strbuilder_endif(* this, & result); } #endif Using_CodeOps( CodePreprocessCond ); operator Code(); @@ -661,8 +662,8 @@ struct CodeStmt { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt* operator->(); @@ -673,8 +674,8 @@ struct CodeStmt_Break { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Break ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Break* operator->(); @@ -685,8 +686,8 @@ struct CodeStmt_Case { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Case ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Case* operator->(); @@ -697,8 +698,8 @@ struct CodeStmt_Continue { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Continue ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Continue* operator->(); @@ -709,8 +710,8 @@ struct CodeStmt_Decl { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Decl ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Decl* operator->(); @@ -721,8 +722,8 @@ struct CodeStmt_Do { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Do ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Do* operator->(); @@ -733,8 +734,8 @@ struct CodeStmt_Expr { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Expr ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Expr* operator->(); @@ -745,8 +746,8 @@ struct CodeStmt_Else { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Else ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Else* operator->(); @@ -757,8 +758,8 @@ struct CodeStmt_If { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_If ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_If* operator->(); @@ -769,8 +770,8 @@ struct CodeStmt_For { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_For ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_For* operator->(); @@ -781,8 +782,8 @@ struct CodeStmt_Goto { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Goto ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Goto* operator->(); @@ -793,8 +794,8 @@ struct CodeStmt_Label { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Label ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Label* operator->(); @@ -805,8 +806,8 @@ struct CodeStmt_Switch { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Switch ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_Switch* operator->(); @@ -817,8 +818,8 @@ struct CodeStmt_While { #if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_While ); - forceinline String to_string(); - forceinline void to_string( String& result ); + forceinline StrBuilder to_strbuilder(); + forceinline void to_strbuilder( StrBuilder& result ); #endif operator Code(); AST_Stmt_While* operator->(); @@ -830,8 +831,8 @@ struct CodeTemplate { #if ! GEN_C_LIKE_CPP Using_Code( CodeTemplate ); - forceinline String to_string() { return template_to_string(* this); } - forceinline void to_string( String& result ) { return template_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return template_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return template_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps( CodeTemplate ); operator Code(); @@ -843,8 +844,8 @@ struct CodeTypename { #if ! GEN_C_LIKE_CPP Using_Code( CodeTypename ); - forceinline String to_string() { return typename_to_string(* this); } - forceinline void to_string( String& result ) { return typename_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return typename_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return typename_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps( CodeTypename ); operator Code(); @@ -856,8 +857,8 @@ struct CodeTypedef { #if ! GEN_C_LIKE_CPP Using_Code( CodeTypedef ); - forceinline String to_string() { return typedef_to_string(* this); } - forceinline void to_string( String& result ) { return typedef_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return typedef_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return typedef_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps( CodeTypedef ); operator Code(); @@ -869,9 +870,9 @@ struct CodeUnion { #if ! GEN_C_LIKE_CPP Using_Code( CodeUnion ); - forceinline String to_string() { return union_to_string(* this); } - forceinline void to_string_def( String& result ) { return union_to_string_def(* this, & result); } - forceinline void to_string_fwd( String& result ) { return union_to_string_fwd(* this, & result); } + forceinline StrBuilder to_strbuilder() { return union_to_strbuilder(* this); } + forceinline void to_strbuilder_def( StrBuilder& result ) { return union_to_strbuilder_def(* this, & result); } + forceinline void to_strbuilder_fwd( StrBuilder& result ) { return union_to_strbuilder_fwd(* this, & result); } #endif Using_CodeOps(CodeUnion); operator Code(); @@ -883,9 +884,9 @@ struct CodeUsing { #if ! GEN_C_LIKE_CPP Using_Code( CodeUsing ); - forceinline String to_string() { return using_to_string(* this); } - forceinline void to_string( String& result ) { return using_to_string_ref(* this, & result); } - forceinline void to_string_ns( String& result ) { return using_to_string_ns(* this, & result); } + forceinline StrBuilder to_strbuilder() { return using_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return using_to_strbuilder_ref(* this, & result); } + forceinline void to_strbuilder_ns( StrBuilder& result ) { return using_to_strbuilder_ns(* this, & result); } #endif Using_CodeOps(CodeUsing); operator Code(); @@ -897,8 +898,8 @@ struct CodeVar { #if ! GEN_C_LIKE_CPP Using_Code( CodeVar ); - forceinline String to_string() { return var_to_string(* this); } - forceinline void to_string( String& result ) { return var_to_string_ref(* this, & result); } + forceinline StrBuilder to_strbuilder() { return var_to_strbuilder(* this); } + forceinline void to_strbuilder( StrBuilder& result ) { return var_to_strbuilder_ref(* this, & result); } #endif Using_CodeOps(CodeVar); operator Code(); @@ -910,10 +911,10 @@ struct CodeStruct { #if ! GEN_C_LIKE_CPP Using_Code( CodeStruct ); - forceinline void add_interface( CodeTypename interface ) { return struct_add_interface(* this, interface); } - forceinline String to_string() { return struct_to_string(* this); } - forceinline void to_string_fwd( String& result ) { return struct_to_string_fwd(* this, & result); } - forceinline void to_string_def( String& result ) { return struct_to_string_def(* this, & result); } + forceinline void add_interface( CodeTypename interface ) { return struct_add_interface(* this, interface); } + forceinline StrBuilder to_strbuilder() { return struct_to_strbuilder(* this); } + forceinline void to_strbuilder_fwd( StrBuilder& result ) { return struct_to_strbuilder_fwd(* this, & result); } + forceinline void to_strbuilder_def( StrBuilder& result ) { return struct_to_strbuilder_def(* this, & result); } #endif Using_CodeOps( CodeStruct ); forceinline operator Code() { return * rcast( Code*, this ); } @@ -951,7 +952,7 @@ struct InvalidCode_ImplictCaster 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 CodeParams () const { return cast(CodeParams, Code_Invalid); } + operator CodeParams () const { return cast(CodeParams, 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); } @@ -997,131 +998,131 @@ struct NullCode_ImplicitCaster operator CodeVar () const { return {nullptr}; } }; -#if ! GEN_C_LIKE_CPP -GEN_OPTIMIZE_MAPPINGS_BEGIN - -forceinline void append ( CodeBody body, Code other ) { return body_append(body, other); } -forceinline void append ( CodeBody body, CodeBody other ) { return body_append_body(body, other); } -forceinline String to_string ( CodeBody body ) { return body_to_string(body); } -forceinline void to_string ( CodeBody body, String& result ) { return body_to_string_ref(body, & result); } -forceinline void to_string_export( CodeBody body, String& result ) { return body_to_string_export(body, & result); } - forceinline Code begin( CodeBody body) { return begin_CodeBody(body); } forceinline Code end ( CodeBody body ) { return end_CodeBody(body); } forceinline Code next ( CodeBody body, Code entry_iter ) { return next_CodeBody(body, entry_iter); } -forceinline void add_interface( CodeClass self, CodeTypename interface ) { return class_add_interface(self, interface); } -forceinline String to_string ( CodeClass self ) { return class_to_string(self); } -forceinline void to_string_def( CodeClass self, String& result ) { return class_to_string_def(self, & result); } -forceinline void to_string_fwd( CodeClass self, String& result ) { return class_to_string_fwd(self, & result); } - -forceinline void append (CodeParams params, CodeParams param ) { return params_append(params, param); } -forceinline CodeParams get (CodeParams params, s32 idx) { return params_get(params, idx); } -forceinline bool has_entries(CodeParams params ) { return params_has_entries(params); } -forceinline String to_string (CodeParams params ) { return params_to_string(params); } -forceinline void to_string (CodeParams params, String& result ) { return params_to_string_ref(params, & result); } - forceinline CodeParams begin(CodeParams params) { return begin_CodeParams(params); } forceinline CodeParams end (CodeParams params) { return end_CodeParams(params); } forceinline CodeParams next (CodeParams params, CodeParams entry_iter) { return next_CodeParams(params, entry_iter); } -forceinline bool append (CodeSpecifiers specifiers, Specifier spec) { return specifiers_append(specifiers, spec); } -forceinline s32 has (CodeSpecifiers specifiers, Specifier spec) { return specifiers_has(specifiers, spec); } -forceinline s32 remove (CodeSpecifiers specifiers, Specifier to_remove ) { return specifiers_remove(specifiers, to_remove); } -forceinline String to_string(CodeSpecifiers specifiers) { return specifiers_to_string(specifiers); } -forceinline void to_string(CodeSpecifiers specifiers, String& result) { return specifiers_to_string_ref(specifiers, & result); } - forceinline Specifier* begin(CodeSpecifiers specifiers) { return begin_CodeSpecifiers(specifiers); } forceinline Specifier* end (CodeSpecifiers specifiers) { return end_CodeSpecifiers(specifiers); } forceinline Specifier* next (CodeSpecifiers specifiers, Specifier& spec_iter) { return next_CodeSpecifiers(specifiers, & spec_iter); } -forceinline void add_interface(CodeStruct self, CodeTypename interface) { return struct_add_interface(self, interface); } -forceinline String to_string (CodeStruct self) { return struct_to_string(self); } -forceinline void to_string_fwd(CodeStruct self, String& result) { return struct_to_string_fwd(self, & result); } -forceinline void to_string_def(CodeStruct self, String& result) { return struct_to_string_def(self, & result); } +#if ! GEN_C_LIKE_CPP +GEN_OPTIMIZE_MAPPINGS_BEGIN -forceinline String to_string(CodeAttributes attributes) { return attributes_to_string(attributes); } -forceinline void to_string(CodeAttributes attributes, String& result) { return attributes_to_string_ref(attributes, & result); } +forceinline void append ( CodeBody body, Code other ) { return body_append(body, other); } +forceinline void append ( CodeBody body, CodeBody other ) { return body_append_body(body, other); } +forceinline StrBuilder to_strbuilder ( CodeBody body ) { return body_to_strbuilder(body); } +forceinline void to_strbuilder ( CodeBody body, StrBuilder& result ) { return body_to_strbuilder_ref(body, & result); } +forceinline void to_strbuilder_export( CodeBody body, StrBuilder& result ) { return body_to_strbuilder_export(body, & result); } -forceinline String to_string(CodeComment comment ) { return comment_to_string(comment); } -forceinline void to_string(CodeComment comment, String& result ) { return comment_to_string_ref(comment, & result); } +forceinline void add_interface ( CodeClass self, CodeTypename interface ) { return class_add_interface(self, interface); } +forceinline StrBuilder to_strbuilder ( CodeClass self ) { return class_to_strbuilder(self); } +forceinline void to_strbuilder_def( CodeClass self, StrBuilder& result ) { return class_to_strbuilder_def(self, & result); } +forceinline void to_strbuilder_fwd( CodeClass self, StrBuilder& result ) { return class_to_strbuilder_fwd(self, & result); } -forceinline String to_string (CodeConstructor constructor) { return constructor_to_string(constructor); } -forceinline void to_string_def(CodeConstructor constructor, String& result ) { return constructor_to_string_def(constructor, & result); } -forceinline void to_string_fwd(CodeConstructor constructor, String& result ) { return constructor_to_string_fwd(constructor, & result); } +forceinline void append (CodeParams params, CodeParams param ) { return params_append(params, param); } +forceinline CodeParams get (CodeParams params, s32 idx) { return params_get(params, idx); } +forceinline bool has_entries (CodeParams params ) { return params_has_entries(params); } +forceinline StrBuilder to_strbuilder(CodeParams params ) { return params_to_strbuilder(params); } +forceinline void to_strbuilder(CodeParams params, StrBuilder& result ) { return params_to_strbuilder_ref(params, & result); } + +forceinline bool append (CodeSpecifiers specifiers, Specifier spec) { return specifiers_append(specifiers, spec); } +forceinline s32 has (CodeSpecifiers specifiers, Specifier spec) { return specifiers_has(specifiers, spec); } +forceinline s32 remove (CodeSpecifiers specifiers, Specifier to_remove ) { return specifiers_remove(specifiers, to_remove); } +forceinline StrBuilder to_strbuilder(CodeSpecifiers specifiers) { return specifiers_to_strbuilder(specifiers); } +forceinline void to_strbuilder(CodeSpecifiers specifiers, StrBuilder& result) { return specifiers_to_strbuilder_ref(specifiers, & result); } -forceinline String to_string(CodeDefine self) { return define_to_string(self); } -forceinline void to_string(CodeDefine self, String& result) { return define_to_string_ref(self, & result); } +forceinline void add_interface (CodeStruct self, CodeTypename interface) { return struct_add_interface(self, interface); } +forceinline StrBuilder to_strbuilder (CodeStruct self) { return struct_to_strbuilder(self); } +forceinline void to_strbuilder_fwd(CodeStruct self, StrBuilder& result) { return struct_to_strbuilder_fwd(self, & result); } +forceinline void to_strbuilder_def(CodeStruct self, StrBuilder& result) { return struct_to_strbuilder_def(self, & result); } -forceinline String to_string (CodeDestructor destructor) { return destructor_to_string(destructor); } -forceinline void to_string_def(CodeDestructor destructor, String& result ) { return destructor_to_string_def(destructor, & result); } -forceinline void to_string_fwd(CodeDestructor destructor, String& result ) { return destructor_to_string_fwd(destructor, & result); } +forceinline StrBuilder to_strbuilder(CodeAttributes attributes) { return attributes_to_strbuilder(attributes); } +forceinline void to_strbuilder(CodeAttributes attributes, StrBuilder& result) { return attributes_to_strbuilder_ref(attributes, & result); } -forceinline String to_string (CodeEnum self) { return enum_to_string(self); } -forceinline void to_string_def (CodeEnum self, String& result ) { return enum_to_string_def(self, & result); } -forceinline void to_string_fwd (CodeEnum self, String& result ) { return enum_to_string_fwd(self, & result); } -forceinline void to_string_class_def(CodeEnum self, String& result ) { return enum_to_string_class_def(self, & result); } -forceinline void to_string_class_fwd(CodeEnum self, String& result ) { return enum_to_string_class_fwd(self, & result); } +forceinline StrBuilder to_strbuilder(CodeComment comment ) { return comment_to_strbuilder(comment); } +forceinline void to_strbuilder(CodeComment comment, StrBuilder& result ) { return comment_to_strbuilder_ref(comment, & result); } -forceinline String to_string(CodeExec exec) { return exec_to_string(exec); } -forceinline void to_string(CodeExec exec, String& result) { return exec_to_string_ref(exec, & result); } +forceinline StrBuilder to_strbuilder (CodeConstructor constructor) { return constructor_to_strbuilder(constructor); } +forceinline void to_strbuilder_def(CodeConstructor constructor, StrBuilder& result ) { return constructor_to_strbuilder_def(constructor, & result); } +forceinline void to_strbuilder_fwd(CodeConstructor constructor, StrBuilder& result ) { return constructor_to_strbuilder_fwd(constructor, & result); } -forceinline void to_string(CodeExtern self, String& result) { return extern_to_string(self, & result); } +forceinline StrBuilder to_strbuilder(CodeDefine self) { return define_to_strbuilder(self); } +forceinline void to_strbuilder(CodeDefine self, StrBuilder& result) { return define_to_strbuilder_ref(self, & result); } -forceinline String to_string(CodeInclude self) { return include_to_string(self); } -forceinline void to_string(CodeInclude self, String& result) { return include_to_string_ref(self, & result); } +forceinline StrBuilder to_strbuilder (CodeDestructor destructor) { return destructor_to_strbuilder(destructor); } +forceinline void to_strbuilder_def(CodeDestructor destructor, StrBuilder& result ) { return destructor_to_strbuilder_def(destructor, & result); } +forceinline void to_strbuilder_fwd(CodeDestructor destructor, StrBuilder& result ) { return destructor_to_strbuilder_fwd(destructor, & result); } -forceinline String to_string(CodeFriend self) { return friend_to_string(self); } -forceinline void to_string(CodeFriend self, String& result) { return friend_to_string_ref(self, & result); } +forceinline StrBuilder to_strbuilder (CodeEnum self) { return enum_to_strbuilder(self); } +forceinline void to_strbuilder_def (CodeEnum self, StrBuilder& result ) { return enum_to_strbuilder_def(self, & result); } +forceinline void to_strbuilder_fwd (CodeEnum self, StrBuilder& result ) { return enum_to_strbuilder_fwd(self, & result); } +forceinline void to_strbuilder_class_def(CodeEnum self, StrBuilder& result ) { return enum_to_strbuilder_class_def(self, & result); } +forceinline void to_strbuilder_class_fwd(CodeEnum self, StrBuilder& result ) { return enum_to_strbuilder_class_fwd(self, & result); } -forceinline String to_string (CodeFn self) { return fn_to_string(self); } -forceinline void to_string_def(CodeFn self, String& result) { return fn_to_string_def(self, & result); } -forceinline void to_string_fwd(CodeFn self, String& result) { return fn_to_string_fwd(self, & result); } +forceinline StrBuilder to_strbuilder(CodeExec exec) { return exec_to_strbuilder(exec); } +forceinline void to_strbuilder(CodeExec exec, StrBuilder& result) { return exec_to_strbuilder_ref(exec, & result); } -forceinline String to_string(CodeModule self) { return module_to_string(self); } -forceinline void to_string(CodeModule self, String& result) { return module_to_string_ref(self, & result); } +forceinline void to_strbuilder(CodeExtern self, StrBuilder& result) { return extern_to_strbuilder(self, & result); } -forceinline String to_string(CodeNS self) { return namespace_to_string(self); } -forceinline void to_string(CodeNS self, String& result) { return namespace_to_string_ref(self, & result); } +forceinline StrBuilder to_strbuilder(CodeInclude self) { return include_to_strbuilder(self); } +forceinline void to_strbuilder(CodeInclude self, StrBuilder& result) { return include_to_strbuilder_ref(self, & result); } -forceinline String to_string (CodeOperator self) { return code_op_to_string(self); } -forceinline void to_string_fwd(CodeOperator self, String& result ) { return code_op_to_string_fwd(self, & result); } -forceinline void to_string_def(CodeOperator self, String& result ) { return code_op_to_string_def(self, & result); } +forceinline StrBuilder to_strbuilder(CodeFriend self) { return friend_to_strbuilder(self); } +forceinline void to_strbuilder(CodeFriend self, StrBuilder& result) { return friend_to_strbuilder_ref(self, & result); } -forceinline String to_string (CodeOpCast op_cast ) { return opcast_to_string(op_cast); } -forceinline void to_string_def(CodeOpCast op_cast, String& result ) { return opcast_to_string_def(op_cast, & result); } -forceinline void to_string_fwd(CodeOpCast op_cast, String& result ) { return opcast_to_string_fwd(op_cast, & result); } +forceinline StrBuilder to_strbuilder (CodeFn self) { return fn_to_strbuilder(self); } +forceinline void to_strbuilder_def(CodeFn self, StrBuilder& result) { return fn_to_strbuilder_def(self, & result); } +forceinline void to_strbuilder_fwd(CodeFn self, StrBuilder& result) { return fn_to_strbuilder_fwd(self, & result); } -forceinline String to_string(CodePragma self) { return pragma_to_string(self); } -forceinline void to_string(CodePragma self, String& result) { return pragma_to_string_ref(self, & result); } +forceinline StrBuilder to_strbuilder(CodeModule self) { return module_to_strbuilder(self); } +forceinline void to_strbuilder(CodeModule self, StrBuilder& result) { return module_to_strbuilder_ref(self, & result); } -forceinline String to_string (CodePreprocessCond cond) { return preprocess_to_string(cond); } -forceinline void to_string_if (CodePreprocessCond cond, String& result ) { return preprocess_to_string_if(cond, & result); } -forceinline void to_string_ifdef (CodePreprocessCond cond, String& result ) { return preprocess_to_string_ifdef(cond, & result); } -forceinline void to_string_ifndef(CodePreprocessCond cond, String& result ) { return preprocess_to_string_ifndef(cond, & result); } -forceinline void to_string_elif (CodePreprocessCond cond, String& result ) { return preprocess_to_string_elif(cond, & result); } -forceinline void to_string_else (CodePreprocessCond cond, String& result ) { return preprocess_to_string_else(cond, & result); } -forceinline void to_string_endif (CodePreprocessCond cond, String& result ) { return preprocess_to_string_endif(cond, & result); } +forceinline StrBuilder to_strbuilder(CodeNS self) { return namespace_to_strbuilder(self); } +forceinline void to_strbuilder(CodeNS self, StrBuilder& result) { return namespace_to_strbuilder_ref(self, & result); } -forceinline String to_string(CodeTemplate self) { return template_to_string(self); } -forceinline void to_string(CodeTemplate self, String& result) { return template_to_string_ref(self, & result); } +forceinline StrBuilder to_strbuilder (CodeOperator self) { return code_op_to_strbuilder(self); } +forceinline void to_strbuilder_fwd(CodeOperator self, StrBuilder& result ) { return code_op_to_strbuilder_fwd(self, & result); } +forceinline void to_strbuilder_def(CodeOperator self, StrBuilder& result ) { return code_op_to_strbuilder_def(self, & result); } -forceinline String to_string(CodeTypename self) { return typename_to_string(self); } -forceinline void to_string(CodeTypename self, String& result) { return typename_to_string_ref(self, & result); } +forceinline StrBuilder to_strbuilder (CodeOpCast op_cast ) { return opcast_to_strbuilder(op_cast); } +forceinline void to_strbuilder_def(CodeOpCast op_cast, StrBuilder& result ) { return opcast_to_strbuilder_def(op_cast, & result); } +forceinline void to_strbuilder_fwd(CodeOpCast op_cast, StrBuilder& result ) { return opcast_to_strbuilder_fwd(op_cast, & result); } -forceinline String to_string(CodeTypedef self) { return typedef_to_string(self); } -forceinline void to_string(CodeTypedef self, String& result ) { return typedef_to_string_ref(self, & result); } +forceinline StrBuilder to_strbuilder(CodePragma self) { return pragma_to_strbuilder(self); } +forceinline void to_strbuilder(CodePragma self, StrBuilder& result) { return pragma_to_strbuilder_ref(self, & result); } -forceinline String to_string (CodeUnion self) { return union_to_string(self); } -forceinline void to_string_def(CodeUnion self, String& result) { return union_to_string_def(self, & result); } -forceinline void to_string_fwd(CodeUnion self, String& result) { return union_to_string_fwd(self, & result); } +forceinline StrBuilder to_strbuilder (CodePreprocessCond cond) { return preprocess_to_strbuilder(cond); } +forceinline void to_strbuilder_if (CodePreprocessCond cond, StrBuilder& result ) { return preprocess_to_strbuilder_if(cond, & result); } +forceinline void to_strbuilder_ifdef (CodePreprocessCond cond, StrBuilder& result ) { return preprocess_to_strbuilder_ifdef(cond, & result); } +forceinline void to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder& result ) { return preprocess_to_strbuilder_ifndef(cond, & result); } +forceinline void to_strbuilder_elif (CodePreprocessCond cond, StrBuilder& result ) { return preprocess_to_strbuilder_elif(cond, & result); } +forceinline void to_strbuilder_else (CodePreprocessCond cond, StrBuilder& result ) { return preprocess_to_strbuilder_else(cond, & result); } +forceinline void to_strbuilder_endif (CodePreprocessCond cond, StrBuilder& result ) { return preprocess_to_strbuilder_endif(cond, & result); } -forceinline String to_string (CodeUsing op_cast ) { return using_to_string(op_cast); } -forceinline void to_string (CodeUsing op_cast, String& result ) { return using_to_string_ref(op_cast, & result); } -forceinline void to_string_ns(CodeUsing op_cast, String& result ) { return using_to_string_ns(op_cast, & result); } +forceinline StrBuilder to_strbuilder(CodeTemplate self) { return template_to_strbuilder(self); } +forceinline void to_strbuilder(CodeTemplate self, StrBuilder& result) { return template_to_strbuilder_ref(self, & result); } -forceinline String to_string(CodeVar self) { return var_to_string(self); } -forceinline void to_string(CodeVar self, String& result) { return var_to_string_ref(self, & result); } +forceinline StrBuilder to_strbuilder(CodeTypename self) { return typename_to_strbuilder(self); } +forceinline void to_strbuilder(CodeTypename self, StrBuilder& result) { return typename_to_strbuilder_ref(self, & result); } + +forceinline StrBuilder to_strbuilder(CodeTypedef self) { return typedef_to_strbuilder(self); } +forceinline void to_strbuilder(CodeTypedef self, StrBuilder& result ) { return typedef_to_strbuilder_ref(self, & result); } + +forceinline StrBuilder to_strbuilder (CodeUnion self) { return union_to_strbuilder(self); } +forceinline void to_strbuilder_def(CodeUnion self, StrBuilder& result) { return union_to_strbuilder_def(self, & result); } +forceinline void to_strbuilder_fwd(CodeUnion self, StrBuilder& result) { return union_to_strbuilder_fwd(self, & result); } + +forceinline StrBuilder to_strbuilder (CodeUsing op_cast ) { return using_to_strbuilder(op_cast); } +forceinline void to_strbuilder (CodeUsing op_cast, StrBuilder& result ) { return using_to_strbuilder_ref(op_cast, & result); } +forceinline void to_strbuilder_ns(CodeUsing op_cast, StrBuilder& result ) { return using_to_strbuilder_ns(op_cast, & result); } + +forceinline StrBuilder to_strbuilder(CodeVar self) { return var_to_strbuilder(self); } +forceinline void to_strbuilder(CodeVar self, StrBuilder& result) { return var_to_strbuilder_ref(self, & result); } GEN_OPITMIZE_MAPPINGS_END #endif //if GEN_C_LIKE_CPP diff --git a/base/components/gen/ast_inlines.hpp b/base/components/gen/ast_inlines.hpp index 148e477..46e80ed 100644 --- a/base/components/gen/ast_inlines.hpp +++ b/base/components/gen/ast_inlines.hpp @@ -64,7 +64,7 @@ inline AST_Attributes* CodeAttributes::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -95,7 +95,7 @@ inline AST_Comment* CodeComment::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -126,7 +126,7 @@ inline AST_Constructor* CodeConstructor::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -173,7 +173,7 @@ inline AST_Define* CodeDefine::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -204,7 +204,7 @@ inline AST_Destructor* CodeDestructor::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -235,7 +235,7 @@ inline AST_Enum* CodeEnum::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -266,7 +266,7 @@ inline AST_Exec* CodeExec::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -297,7 +297,7 @@ inline AST_Extern* CodeExtern::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -328,7 +328,7 @@ inline AST_Friend* CodeFriend::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -359,7 +359,7 @@ inline AST_Fn* CodeFn::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -390,7 +390,7 @@ inline AST_Include* CodeInclude::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -421,7 +421,7 @@ inline AST_Module* CodeModule::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -452,7 +452,7 @@ inline AST_NS* CodeNS::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -483,7 +483,7 @@ inline AST_Operator* CodeOperator::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -514,7 +514,7 @@ inline AST_OpCast* CodeOpCast::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -561,7 +561,7 @@ inline AST_Pragma* CodePragma::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -592,7 +592,7 @@ inline AST_PreprocessCond* CodePreprocessCond::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -655,7 +655,7 @@ inline AST_Template* CodeTemplate::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -686,7 +686,7 @@ inline AST_Typename* CodeTypename::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -717,7 +717,7 @@ inline AST_Typedef* CodeTypedef::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -748,7 +748,7 @@ inline AST_Union* CodeUnion::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -779,7 +779,7 @@ inline AST_Using* CodeUsing::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; @@ -810,7 +810,7 @@ inline AST_Var* CodeVar::operator->() { if ( ast == nullptr ) { - log_failure( "Attempt to dereference a nullptr!" ); + log_failure( "Attempt to dereference a nullptr!\n" ); return nullptr; } return ast; diff --git a/base/components/gen/ecodetypes.hpp b/base/components/gen/ecodetypes.hpp index 7321695..aaf6d0d 100644 --- a/base/components/gen/ecodetypes.hpp +++ b/base/components/gen/ecodetypes.hpp @@ -72,148 +72,148 @@ enum CodeType : u32 CT_UnderlyingType = GEN_U32_MAX }; -inline StrC codetype_to_str( CodeType type ) +inline Str codetype_to_str( CodeType type ) { - local_persist StrC lookup[61] = { - { sizeof( "Invalid" ), "Invalid" }, - { sizeof( "Untyped" ), "Untyped" }, - { sizeof( "NewLine" ), "NewLine" }, - { sizeof( "Comment" ), "Comment" }, - { sizeof( "Access_Private" ), "Access_Private" }, - { sizeof( "Access_Protected" ), "Access_Protected" }, - { sizeof( "Access_Public" ), "Access_Public" }, - { sizeof( "PlatformAttributes" ), "PlatformAttributes" }, - { sizeof( "Class" ), "Class" }, - { sizeof( "Class_Fwd" ), "Class_Fwd" }, - { sizeof( "Class_Body" ), "Class_Body" }, - { sizeof( "Constructor" ), "Constructor" }, - { sizeof( "Constructor_Fwd" ), "Constructor_Fwd" }, - { sizeof( "Destructor" ), "Destructor" }, - { sizeof( "Destructor_Fwd" ), "Destructor_Fwd" }, - { sizeof( "Enum" ), "Enum" }, - { sizeof( "Enum_Fwd" ), "Enum_Fwd" }, - { sizeof( "Enum_Body" ), "Enum_Body" }, - { sizeof( "Enum_Class" ), "Enum_Class" }, - { sizeof( "Enum_Class_Fwd" ), "Enum_Class_Fwd" }, - { sizeof( "Execution" ), "Execution" }, - { sizeof( "Export_Body" ), "Export_Body" }, - { sizeof( "Extern_Linkage" ), "Extern_Linkage" }, - { sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" }, - { sizeof( "Friend" ), "Friend" }, - { sizeof( "Function" ), "Function" }, - { sizeof( "Function_Fwd" ), "Function_Fwd" }, - { sizeof( "Function_Body" ), "Function_Body" }, - { sizeof( "Global_Body" ), "Global_Body" }, - { sizeof( "Module" ), "Module" }, - { sizeof( "Namespace" ), "Namespace" }, - { sizeof( "Namespace_Body" ), "Namespace_Body" }, - { sizeof( "Operator" ), "Operator" }, - { sizeof( "Operator_Fwd" ), "Operator_Fwd" }, - { sizeof( "Operator_Member" ), "Operator_Member" }, - { sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" }, - { sizeof( "Operator_Cast" ), "Operator_Cast" }, - { sizeof( "Operator_Cast_Fwd" ), "Operator_Cast_Fwd" }, - { sizeof( "Parameters" ), "Parameters" }, - { sizeof( "Preprocess_Define" ), "Preprocess_Define" }, - { sizeof( "Preprocess_Include" ), "Preprocess_Include" }, - { sizeof( "Preprocess_If" ), "Preprocess_If" }, - { sizeof( "Preprocess_IfDef" ), "Preprocess_IfDef" }, - { sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" }, - { sizeof( "Preprocess_ElIf" ), "Preprocess_ElIf" }, - { sizeof( "Preprocess_Else" ), "Preprocess_Else" }, - { sizeof( "Preprocess_EndIf" ), "Preprocess_EndIf" }, - { sizeof( "Preprocess_Pragma" ), "Preprocess_Pragma" }, - { sizeof( "Specifiers" ), "Specifiers" }, - { sizeof( "Struct" ), "Struct" }, - { sizeof( "Struct_Fwd" ), "Struct_Fwd" }, - { sizeof( "Struct_Body" ), "Struct_Body" }, - { sizeof( "Template" ), "Template" }, - { sizeof( "Typedef" ), "Typedef" }, - { sizeof( "Typename" ), "Typename" }, - { sizeof( "Union" ), "Union" }, - { sizeof( "Union_Fwd" ), "Union_Fwd" }, - { sizeof( "Union_Body" ), "Union_Body" }, - { sizeof( "Using" ), "Using" }, - { sizeof( "Using_Namespace" ), "Using_Namespace" }, - { sizeof( "Variable" ), "Variable" }, + local_persist Str lookup[61] = { + { "Invalid", sizeof( "Invalid" ) - 1 }, + { "Untyped", sizeof( "Untyped" ) - 1 }, + { "NewLine", sizeof( "NewLine" ) - 1 }, + { "Comment", sizeof( "Comment" ) - 1 }, + { "Access_Private", sizeof( "Access_Private" ) - 1 }, + { "Access_Protected", sizeof( "Access_Protected" ) - 1 }, + { "Access_Public", sizeof( "Access_Public" ) - 1 }, + { "PlatformAttributes", sizeof( "PlatformAttributes" ) - 1 }, + { "Class", sizeof( "Class" ) - 1 }, + { "Class_Fwd", sizeof( "Class_Fwd" ) - 1 }, + { "Class_Body", sizeof( "Class_Body" ) - 1 }, + { "Constructor", sizeof( "Constructor" ) - 1 }, + { "Constructor_Fwd", sizeof( "Constructor_Fwd" ) - 1 }, + { "Destructor", sizeof( "Destructor" ) - 1 }, + { "Destructor_Fwd", sizeof( "Destructor_Fwd" ) - 1 }, + { "Enum", sizeof( "Enum" ) - 1 }, + { "Enum_Fwd", sizeof( "Enum_Fwd" ) - 1 }, + { "Enum_Body", sizeof( "Enum_Body" ) - 1 }, + { "Enum_Class", sizeof( "Enum_Class" ) - 1 }, + { "Enum_Class_Fwd", sizeof( "Enum_Class_Fwd" ) - 1 }, + { "Execution", sizeof( "Execution" ) - 1 }, + { "Export_Body", sizeof( "Export_Body" ) - 1 }, + { "Extern_Linkage", sizeof( "Extern_Linkage" ) - 1 }, + { "Extern_Linkage_Body", sizeof( "Extern_Linkage_Body" ) - 1 }, + { "Friend", sizeof( "Friend" ) - 1 }, + { "Function", sizeof( "Function" ) - 1 }, + { "Function_Fwd", sizeof( "Function_Fwd" ) - 1 }, + { "Function_Body", sizeof( "Function_Body" ) - 1 }, + { "Global_Body", sizeof( "Global_Body" ) - 1 }, + { "Module", sizeof( "Module" ) - 1 }, + { "Namespace", sizeof( "Namespace" ) - 1 }, + { "Namespace_Body", sizeof( "Namespace_Body" ) - 1 }, + { "Operator", sizeof( "Operator" ) - 1 }, + { "Operator_Fwd", sizeof( "Operator_Fwd" ) - 1 }, + { "Operator_Member", sizeof( "Operator_Member" ) - 1 }, + { "Operator_Member_Fwd", sizeof( "Operator_Member_Fwd" ) - 1 }, + { "Operator_Cast", sizeof( "Operator_Cast" ) - 1 }, + { "Operator_Cast_Fwd", sizeof( "Operator_Cast_Fwd" ) - 1 }, + { "Parameters", sizeof( "Parameters" ) - 1 }, + { "Preprocess_Define", sizeof( "Preprocess_Define" ) - 1 }, + { "Preprocess_Include", sizeof( "Preprocess_Include" ) - 1 }, + { "Preprocess_If", sizeof( "Preprocess_If" ) - 1 }, + { "Preprocess_IfDef", sizeof( "Preprocess_IfDef" ) - 1 }, + { "Preprocess_IfNotDef", sizeof( "Preprocess_IfNotDef" ) - 1 }, + { "Preprocess_ElIf", sizeof( "Preprocess_ElIf" ) - 1 }, + { "Preprocess_Else", sizeof( "Preprocess_Else" ) - 1 }, + { "Preprocess_EndIf", sizeof( "Preprocess_EndIf" ) - 1 }, + { "Preprocess_Pragma", sizeof( "Preprocess_Pragma" ) - 1 }, + { "Specifiers", sizeof( "Specifiers" ) - 1 }, + { "Struct", sizeof( "Struct" ) - 1 }, + { "Struct_Fwd", sizeof( "Struct_Fwd" ) - 1 }, + { "Struct_Body", sizeof( "Struct_Body" ) - 1 }, + { "Template", sizeof( "Template" ) - 1 }, + { "Typedef", sizeof( "Typedef" ) - 1 }, + { "Typename", sizeof( "Typename" ) - 1 }, + { "Union", sizeof( "Union" ) - 1 }, + { "Union_Fwd", sizeof( "Union_Fwd" ) - 1 }, + { "Union_Body", sizeof( "Union_Body" ) - 1 }, + { "Using", sizeof( "Using" ) - 1 }, + { "Using_Namespace", sizeof( "Using_Namespace" ) - 1 }, + { "Variable", sizeof( "Variable" ) - 1 }, }; return lookup[type]; } -inline StrC codetype_to_keyword_str( CodeType type ) +inline Str codetype_to_keyword_str( CodeType type ) { - local_persist StrC lookup[61] = { - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "//" ) - 1, "//" }, - { sizeof( "private" ) - 1, "private" }, - { sizeof( "protected" ) - 1, "protected" }, - { sizeof( "public" ) - 1, "public" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "class" ) - 1, "class" }, - { sizeof( "clsss" ) - 1, "clsss" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "enum" ) - 1, "enum" }, - { sizeof( "enum" ) - 1, "enum" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "enum class" ) - 1, "enum class" }, - { sizeof( "enum class" ) - 1, "enum class" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "extern" ) - 1, "extern" }, - { sizeof( "extern" ) - 1, "extern" }, - { sizeof( "friend" ) - 1, "friend" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "module" ) - 1, "module" }, - { sizeof( "namespace" ) - 1, "namespace" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "operator" ) - 1, "operator" }, - { sizeof( "operator" ) - 1, "operator" }, - { sizeof( "operator" ) - 1, "operator" }, - { sizeof( "operator" ) - 1, "operator" }, - { sizeof( "operator" ) - 1, "operator" }, - { sizeof( "operator" ) - 1, "operator" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "define" ) - 1, "define" }, - { sizeof( "include" ) - 1, "include" }, - { sizeof( "if" ) - 1, "if" }, - { sizeof( "ifdef" ) - 1, "ifdef" }, - { sizeof( "ifndef" ) - 1, "ifndef" }, - { sizeof( "elif" ) - 1, "elif" }, - { sizeof( "else" ) - 1, "else" }, - { sizeof( "endif" ) - 1, "endif" }, - { sizeof( "pragma" ) - 1, "pragma" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "struct" ) - 1, "struct" }, - { sizeof( "struct" ) - 1, "struct" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "template" ) - 1, "template" }, - { sizeof( "typedef" ) - 1, "typedef" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "union" ) - 1, "union" }, - { sizeof( "union" ) - 1, "union" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, - { sizeof( "using" ) - 1, "using" }, - { sizeof( "using namespace" ) - 1, "using namespace" }, - { sizeof( "__NA__" ) - 1, "__NA__" }, + local_persist Str lookup[61] = { + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "//", sizeof( "//" ) - 1 }, + { "private", sizeof( "private" ) - 1 }, + { "protected", sizeof( "protected" ) - 1 }, + { "public", sizeof( "public" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "class", sizeof( "class" ) - 1 }, + { "clsss", sizeof( "clsss" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "enum", sizeof( "enum" ) - 1 }, + { "enum", sizeof( "enum" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "enum class", sizeof( "enum class" ) - 1 }, + { "enum class", sizeof( "enum class" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "extern", sizeof( "extern" ) - 1 }, + { "extern", sizeof( "extern" ) - 1 }, + { "friend", sizeof( "friend" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "module", sizeof( "module" ) - 1 }, + { "namespace", sizeof( "namespace" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "operator", sizeof( "operator" ) - 1 }, + { "operator", sizeof( "operator" ) - 1 }, + { "operator", sizeof( "operator" ) - 1 }, + { "operator", sizeof( "operator" ) - 1 }, + { "operator", sizeof( "operator" ) - 1 }, + { "operator", sizeof( "operator" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "define", sizeof( "define" ) - 1 }, + { "include", sizeof( "include" ) - 1 }, + { "if", sizeof( "if" ) - 1 }, + { "ifdef", sizeof( "ifdef" ) - 1 }, + { "ifndef", sizeof( "ifndef" ) - 1 }, + { "elif", sizeof( "elif" ) - 1 }, + { "else", sizeof( "else" ) - 1 }, + { "endif", sizeof( "endif" ) - 1 }, + { "pragma", sizeof( "pragma" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "struct", sizeof( "struct" ) - 1 }, + { "struct", sizeof( "struct" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "template", sizeof( "template" ) - 1 }, + { "typedef", sizeof( "typedef" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "union", sizeof( "union" ) - 1 }, + { "union", sizeof( "union" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, + { "using", sizeof( "using" ) - 1 }, + { "using namespace", sizeof( "using namespace" ) - 1 }, + { "__NA__", sizeof( "__NA__" ) - 1 }, }; return lookup[type]; } -forceinline StrC to_str( CodeType type ) +forceinline Str to_str( CodeType type ) { return codetype_to_str( type ); } -forceinline StrC to_keyword_str( CodeType type ) +forceinline Str to_keyword_str( CodeType type ) { return codetype_to_keyword_str( type ); } diff --git a/base/components/gen/eoperator.hpp b/base/components/gen/eoperator.hpp index f45e441..b447d7a 100644 --- a/base/components/gen/eoperator.hpp +++ b/base/components/gen/eoperator.hpp @@ -58,61 +58,61 @@ enum Operator : u32 Op_UnderlyingType = 0xffffffffu }; -inline StrC operator_to_str( Operator op ) +inline Str operator_to_str( Operator op ) { - local_persist StrC lookup[47] = { - { sizeof( "INVALID" ), "INVALID" }, - { sizeof( "=" ), "=" }, - { sizeof( "+=" ), "+=" }, - { sizeof( "-=" ), "-=" }, - { sizeof( "*=" ), "*=" }, - { sizeof( "/=" ), "/=" }, - { sizeof( "%=" ), "%=" }, - { sizeof( "&=" ), "&=" }, - { sizeof( "|=" ), "|=" }, - { sizeof( "^=" ), "^=" }, - { sizeof( "<<=" ), "<<=" }, - { sizeof( ">>=" ), ">>=" }, - { sizeof( "++" ), "++" }, - { sizeof( "--" ), "--" }, - { sizeof( "+" ), "+" }, - { sizeof( "-" ), "-" }, - { sizeof( "!" ), "!" }, - { sizeof( "+" ), "+" }, - { sizeof( "-" ), "-" }, - { sizeof( "*" ), "*" }, - { sizeof( "/" ), "/" }, - { sizeof( "%" ), "%" }, - { sizeof( "~" ), "~" }, - { sizeof( "&" ), "&" }, - { sizeof( "|" ), "|" }, - { sizeof( "^" ), "^" }, - { sizeof( "<<" ), "<<" }, - { sizeof( ">>" ), ">>" }, - { sizeof( "&&" ), "&&" }, - { sizeof( "||" ), "||" }, - { sizeof( "==" ), "==" }, - { sizeof( "!=" ), "!=" }, - { sizeof( "<" ), "<" }, - { sizeof( ">" ), ">" }, - { sizeof( "<=" ), "<=" }, - { sizeof( ">=" ), ">=" }, - { sizeof( "[]" ), "[]" }, - { sizeof( "*" ), "*" }, - { sizeof( "&" ), "&" }, - { sizeof( "->" ), "->" }, - { sizeof( "->*" ), "->*" }, - { sizeof( "()" ), "()" }, - { sizeof( "," ), "," }, - { sizeof( "new" ), "new" }, - { sizeof( "new[]" ), "new[]" }, - { sizeof( "delete" ), "delete" }, - { sizeof( "delete[]" ), "delete[]" }, + local_persist Str lookup[47] = { + { "INVALID", sizeof( "INVALID" ) - 1 }, + { "=", sizeof( "=" ) - 1 }, + { "+=", sizeof( "+=" ) - 1 }, + { "-=", sizeof( "-=" ) - 1 }, + { "*=", sizeof( "*=" ) - 1 }, + { "/=", sizeof( "/=" ) - 1 }, + { "%=", sizeof( "%=" ) - 1 }, + { "&=", sizeof( "&=" ) - 1 }, + { "|=", sizeof( "|=" ) - 1 }, + { "^=", sizeof( "^=" ) - 1 }, + { "<<=", sizeof( "<<=" ) - 1 }, + { ">>=", sizeof( ">>=" ) - 1 }, + { "++", sizeof( "++" ) - 1 }, + { "--", sizeof( "--" ) - 1 }, + { "+", sizeof( "+" ) - 1 }, + { "-", sizeof( "-" ) - 1 }, + { "!", sizeof( "!" ) - 1 }, + { "+", sizeof( "+" ) - 1 }, + { "-", sizeof( "-" ) - 1 }, + { "*", sizeof( "*" ) - 1 }, + { "/", sizeof( "/" ) - 1 }, + { "%", sizeof( "%" ) - 1 }, + { "~", sizeof( "~" ) - 1 }, + { "&", sizeof( "&" ) - 1 }, + { "|", sizeof( "|" ) - 1 }, + { "^", sizeof( "^" ) - 1 }, + { "<<", sizeof( "<<" ) - 1 }, + { ">>", sizeof( ">>" ) - 1 }, + { "&&", sizeof( "&&" ) - 1 }, + { "||", sizeof( "||" ) - 1 }, + { "==", sizeof( "==" ) - 1 }, + { "!=", sizeof( "!=" ) - 1 }, + { "<", sizeof( "<" ) - 1 }, + { ">", sizeof( ">" ) - 1 }, + { "<=", sizeof( "<=" ) - 1 }, + { ">=", sizeof( ">=" ) - 1 }, + { "[]", sizeof( "[]" ) - 1 }, + { "*", sizeof( "*" ) - 1 }, + { "&", sizeof( "&" ) - 1 }, + { "->", sizeof( "->" ) - 1 }, + { "->*", sizeof( "->*" ) - 1 }, + { "()", sizeof( "()" ) - 1 }, + { ",", sizeof( "," ) - 1 }, + { "new", sizeof( "new" ) - 1 }, + { "new[]", sizeof( "new[]" ) - 1 }, + { "delete", sizeof( "delete" ) - 1 }, + { "delete[]", sizeof( "delete[]" ) - 1 }, }; return lookup[op]; } -forceinline StrC to_str( Operator op ) +forceinline Str to_str( Operator op ) { return operator_to_str( op ); } diff --git a/base/components/gen/especifier.hpp b/base/components/gen/especifier.hpp index 6298888..f75f94d 100644 --- a/base/components/gen/especifier.hpp +++ b/base/components/gen/especifier.hpp @@ -37,35 +37,35 @@ enum Specifier : u32 Spec_UnderlyingType = 0xffffffffu }; -inline StrC spec_to_str( Specifier type ) +inline Str spec_to_str( Specifier type ) { - local_persist StrC lookup[26] = { - { sizeof( "INVALID" ), "INVALID" }, - { sizeof( "consteval" ), "consteval" }, - { sizeof( "constexpr" ), "constexpr" }, - { sizeof( "constinit" ), "constinit" }, - { sizeof( "explicit" ), "explicit" }, - { sizeof( "extern" ), "extern" }, - { sizeof( "forceinline" ), "forceinline" }, - { sizeof( "global" ), "global" }, - { sizeof( "inline" ), "inline" }, - { sizeof( "internal" ), "internal" }, - { sizeof( "local_persist" ), "local_persist" }, - { sizeof( "mutable" ), "mutable" }, - { sizeof( "neverinline" ), "neverinline" }, - { sizeof( "*" ), "*" }, - { sizeof( "&" ), "&" }, - { sizeof( "register" ), "register" }, - { sizeof( "&&" ), "&&" }, - { sizeof( "static" ), "static" }, - { sizeof( "thread_local" ), "thread_local" }, - { sizeof( "virtual" ), "virtual" }, - { sizeof( "const" ), "const" }, - { sizeof( "final" ), "final" }, - { sizeof( "noexcept" ), "noexcept" }, - { sizeof( "override" ), "override" }, - { sizeof( "= 0" ), "= 0" }, - { sizeof( "volatile" ), "volatile" }, + local_persist Str lookup[26] = { + { "INVALID", sizeof( "INVALID" ) - 1 }, + { "consteval", sizeof( "consteval" ) - 1 }, + { "constexpr", sizeof( "constexpr" ) - 1 }, + { "constinit", sizeof( "constinit" ) - 1 }, + { "explicit", sizeof( "explicit" ) - 1 }, + { "extern", sizeof( "extern" ) - 1 }, + { "forceinline", sizeof( "forceinline" ) - 1 }, + { "global", sizeof( "global" ) - 1 }, + { "inline", sizeof( "inline" ) - 1 }, + { "internal", sizeof( "internal" ) - 1 }, + { "local_persist", sizeof( "local_persist" ) - 1 }, + { "mutable", sizeof( "mutable" ) - 1 }, + { "neverinline", sizeof( "neverinline" ) - 1 }, + { "*", sizeof( "*" ) - 1 }, + { "&", sizeof( "&" ) - 1 }, + { "register", sizeof( "register" ) - 1 }, + { "&&", sizeof( "&&" ) - 1 }, + { "static", sizeof( "static" ) - 1 }, + { "thread_local", sizeof( "thread_local" ) - 1 }, + { "virtual", sizeof( "virtual" ) - 1 }, + { "const", sizeof( "const" ) - 1 }, + { "final", sizeof( "final" ) - 1 }, + { "noexcept", sizeof( "noexcept" ) - 1 }, + { "override", sizeof( "override" ) - 1 }, + { "= 0", sizeof( "= 0" ) - 1 }, + { "volatile", sizeof( "volatile" ) - 1 }, }; return lookup[type]; } @@ -75,13 +75,13 @@ inline bool spec_is_trailing( Specifier specifier ) return specifier > Spec_Virtual; } -inline Specifier strc_to_specifier( StrC str ) +inline Specifier str_to_specifier( Str str ) { local_persist u32 keymap[Spec_NumSpecifiers]; do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) { - StrC enum_str = spec_to_str( (Specifier)index ); - keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 ); + Str enum_str = spec_to_str( (Specifier)index ); + keymap[index] = crc32( enum_str.Ptr, enum_str.Len ); } do_once_end u32 hash = crc32( str.Ptr, str.Len ); for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) @@ -92,14 +92,14 @@ inline Specifier strc_to_specifier( StrC str ) return Spec_Invalid; } -forceinline StrC to_str( Specifier spec ) +forceinline Str to_str( Specifier spec ) { return spec_to_str( spec ); } -forceinline Specifier to_type( StrC str ) +forceinline Specifier to_type( Str str ) { - return strc_to_specifier( str ); + return str_to_specifier( str ); } forceinline bool is_trailing( Specifier specifier ) diff --git a/base/components/gen/etoktype.cpp b/base/components/gen/etoktype.cpp index 574f516..e5b4c68 100644 --- a/base/components/gen/etoktype.cpp +++ b/base/components/gen/etoktype.cpp @@ -111,117 +111,117 @@ enum TokType : u32 Tok_NumTokens }; -inline StrC toktype_to_str( TokType type ) +inline Str toktype_to_str( TokType type ) { - local_persist StrC lookup[] = { - { sizeof( "__invalid__" ), "__invalid__" }, - { sizeof( "private" ), "private" }, - { sizeof( "protected" ), "protected" }, - { sizeof( "public" ), "public" }, - { sizeof( "." ), "." }, - { sizeof( "::" ), "::" }, - { sizeof( "&" ), "&" }, - { sizeof( "&&" ), "&&" }, - { sizeof( ":" ), ":" }, - { sizeof( "[[" ), "[[" }, - { sizeof( "]]" ), "]]" }, - { sizeof( "{" ), "{" }, - { sizeof( "}" ), "}" }, - { sizeof( "[" ), "[" }, - { sizeof( "]" ), "]" }, - { sizeof( "(" ), "(" }, - { sizeof( ")" ), ")" }, - { sizeof( "__comment__" ), "__comment__" }, - { sizeof( "__comment_end__" ), "__comment_end__" }, - { sizeof( "__comment_start__" ), "__comment_start__" }, - { sizeof( "__character__" ), "__character__" }, - { sizeof( "," ), "," }, - { sizeof( "class" ), "class" }, - { sizeof( "__attribute__" ), "__attribute__" }, - { sizeof( "__declspec" ), "__declspec" }, - { sizeof( "enum" ), "enum" }, - { sizeof( "extern" ), "extern" }, - { sizeof( "friend" ), "friend" }, - { sizeof( "module" ), "module" }, - { sizeof( "namespace" ), "namespace" }, - { sizeof( "operator" ), "operator" }, - { sizeof( "struct" ), "struct" }, - { sizeof( "template" ), "template" }, - { sizeof( "typedef" ), "typedef" }, - { sizeof( "using" ), "using" }, - { sizeof( "union" ), "union" }, - { sizeof( "__identifier__" ), "__identifier__" }, - { sizeof( "import" ), "import" }, - { sizeof( "export" ), "export" }, - { sizeof( "__new_line__" ), "__new_line__" }, - { sizeof( "__number__" ), "__number__" }, - { sizeof( "__operator__" ), "__operator__" }, - { sizeof( "#" ), "#" }, - { sizeof( "define" ), "define" }, - { sizeof( "if" ), "if" }, - { sizeof( "ifdef" ), "ifdef" }, - { sizeof( "ifndef" ), "ifndef" }, - { sizeof( "elif" ), "elif" }, - { sizeof( "else" ), "else" }, - { sizeof( "endif" ), "endif" }, - { sizeof( "include" ), "include" }, - { sizeof( "pragma" ), "pragma" }, - { sizeof( "__macro_content__" ), "__macro_content__" }, - { sizeof( "__macro__" ), "__macro__" }, - { sizeof( "__unsupported__" ), "__unsupported__" }, - { sizeof( "alignas" ), "alignas" }, - { sizeof( "const" ), "const" }, - { sizeof( "consteval" ), "consteval" }, - { sizeof( "constexpr" ), "constexpr" }, - { sizeof( "constinit" ), "constinit" }, - { sizeof( "explicit" ), "explicit" }, - { sizeof( "extern" ), "extern" }, - { sizeof( "final" ), "final" }, - { sizeof( "forceinline" ), "forceinline" }, - { sizeof( "global" ), "global" }, - { sizeof( "inline" ), "inline" }, - { sizeof( "internal" ), "internal" }, - { sizeof( "local_persist" ), "local_persist" }, - { sizeof( "mutable" ), "mutable" }, - { sizeof( "neverinline" ), "neverinline" }, - { sizeof( "override" ), "override" }, - { sizeof( "static" ), "static" }, - { sizeof( "thread_local" ), "thread_local" }, - { sizeof( "volatile" ), "volatile" }, - { sizeof( "virtual" ), "virtual" }, - { sizeof( "*" ), "*" }, - { sizeof( ";" ), ";" }, - { sizeof( "static_assert" ), "static_assert" }, - { sizeof( "__string__" ), "__string__" }, - { sizeof( "typename" ), "typename" }, - { sizeof( "unsigned" ), "unsigned" }, - { sizeof( "signed" ), "signed" }, - { sizeof( "short" ), "short" }, - { sizeof( "long" ), "long" }, - { sizeof( "bool" ), "bool" }, - { sizeof( "char" ), "char" }, - { sizeof( "int" ), "int" }, - { sizeof( "double" ), "double" }, - { sizeof( "__int8" ), "__int8" }, - { sizeof( "__int16" ), "__int16" }, - { sizeof( "__int32" ), "__int32" }, - { sizeof( "__int64" ), "__int64" }, - { sizeof( "_W64" ), "_W64" }, - { sizeof( "..." ), "..." }, - { sizeof( "__attrib_start__" ), "__attrib_start__" }, - { sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" }, - { sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" }, + local_persist Str lookup[] = { + { "__invalid__", sizeof( "__invalid__" ) - 1 }, + { "private", sizeof( "private" ) - 1 }, + { "protected", sizeof( "protected" ) - 1 }, + { "public", sizeof( "public" ) - 1 }, + { ".", sizeof( "." ) - 1 }, + { "::", sizeof( "::" ) - 1 }, + { "&", sizeof( "&" ) - 1 }, + { "&&", sizeof( "&&" ) - 1 }, + { ":", sizeof( ":" ) - 1 }, + { "[[", sizeof( "[[" ) - 1 }, + { "]]", sizeof( "]]" ) - 1 }, + { "{", sizeof( "{" ) - 1 }, + { "}", sizeof( "}" ) - 1 }, + { "[", sizeof( "[" ) - 1 }, + { "]", sizeof( "]" ) - 1 }, + { "(", sizeof( "(" ) - 1 }, + { ")", sizeof( ")" ) - 1 }, + { "__comment__", sizeof( "__comment__" ) - 1 }, + { "__comment_end__", sizeof( "__comment_end__" ) - 1 }, + { "__comment_start__", sizeof( "__comment_start__" ) - 1 }, + { "__character__", sizeof( "__character__" ) - 1 }, + { ",", sizeof( "," ) - 1 }, + { "class", sizeof( "class" ) - 1 }, + { "__attribute__", sizeof( "__attribute__" ) - 1 }, + { "__declspec", sizeof( "__declspec" ) - 1 }, + { "enum", sizeof( "enum" ) - 1 }, + { "extern", sizeof( "extern" ) - 1 }, + { "friend", sizeof( "friend" ) - 1 }, + { "module", sizeof( "module" ) - 1 }, + { "namespace", sizeof( "namespace" ) - 1 }, + { "operator", sizeof( "operator" ) - 1 }, + { "struct", sizeof( "struct" ) - 1 }, + { "template", sizeof( "template" ) - 1 }, + { "typedef", sizeof( "typedef" ) - 1 }, + { "using", sizeof( "using" ) - 1 }, + { "union", sizeof( "union" ) - 1 }, + { "__identifier__", sizeof( "__identifier__" ) - 1 }, + { "import", sizeof( "import" ) - 1 }, + { "export", sizeof( "export" ) - 1 }, + { "__new_line__", sizeof( "__new_line__" ) - 1 }, + { "__number__", sizeof( "__number__" ) - 1 }, + { "__operator__", sizeof( "__operator__" ) - 1 }, + { "#", sizeof( "#" ) - 1 }, + { "define", sizeof( "define" ) - 1 }, + { "if", sizeof( "if" ) - 1 }, + { "ifdef", sizeof( "ifdef" ) - 1 }, + { "ifndef", sizeof( "ifndef" ) - 1 }, + { "elif", sizeof( "elif" ) - 1 }, + { "else", sizeof( "else" ) - 1 }, + { "endif", sizeof( "endif" ) - 1 }, + { "include", sizeof( "include" ) - 1 }, + { "pragma", sizeof( "pragma" ) - 1 }, + { "__macro_content__", sizeof( "__macro_content__" ) - 1 }, + { "__macro__", sizeof( "__macro__" ) - 1 }, + { "__unsupported__", sizeof( "__unsupported__" ) - 1 }, + { "alignas", sizeof( "alignas" ) - 1 }, + { "const", sizeof( "const" ) - 1 }, + { "consteval", sizeof( "consteval" ) - 1 }, + { "constexpr", sizeof( "constexpr" ) - 1 }, + { "constinit", sizeof( "constinit" ) - 1 }, + { "explicit", sizeof( "explicit" ) - 1 }, + { "extern", sizeof( "extern" ) - 1 }, + { "final", sizeof( "final" ) - 1 }, + { "forceinline", sizeof( "forceinline" ) - 1 }, + { "global", sizeof( "global" ) - 1 }, + { "inline", sizeof( "inline" ) - 1 }, + { "internal", sizeof( "internal" ) - 1 }, + { "local_persist", sizeof( "local_persist" ) - 1 }, + { "mutable", sizeof( "mutable" ) - 1 }, + { "neverinline", sizeof( "neverinline" ) - 1 }, + { "override", sizeof( "override" ) - 1 }, + { "static", sizeof( "static" ) - 1 }, + { "thread_local", sizeof( "thread_local" ) - 1 }, + { "volatile", sizeof( "volatile" ) - 1 }, + { "virtual", sizeof( "virtual" ) - 1 }, + { "*", sizeof( "*" ) - 1 }, + { ";", sizeof( ";" ) - 1 }, + { "static_assert", sizeof( "static_assert" ) - 1 }, + { "__string__", sizeof( "__string__" ) - 1 }, + { "typename", sizeof( "typename" ) - 1 }, + { "unsigned", sizeof( "unsigned" ) - 1 }, + { "signed", sizeof( "signed" ) - 1 }, + { "short", sizeof( "short" ) - 1 }, + { "long", sizeof( "long" ) - 1 }, + { "bool", sizeof( "bool" ) - 1 }, + { "char", sizeof( "char" ) - 1 }, + { "int", sizeof( "int" ) - 1 }, + { "double", sizeof( "double" ) - 1 }, + { "__int8", sizeof( "__int8" ) - 1 }, + { "__int16", sizeof( "__int16" ) - 1 }, + { "__int32", sizeof( "__int32" ) - 1 }, + { "__int64", sizeof( "__int64" ) - 1 }, + { "_W64", sizeof( "_W64" ) - 1 }, + { "...", sizeof( "..." ) - 1 }, + { "__attrib_start__", sizeof( "__attrib_start__" ) - 1 }, + { "GEN_API_Export_Code", sizeof( "GEN_API_Export_Code" ) - 1 }, + { "GEN_API_Import_Code", sizeof( "GEN_API_Import_Code" ) - 1 }, }; return lookup[type]; } -inline TokType strc_to_toktype( StrC str ) +inline TokType str_to_toktype( Str str ) { local_persist u32 keymap[Tok_NumTokens]; do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ ) { - StrC enum_str = toktype_to_str( (TokType)index ); - keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 ); + Str enum_str = toktype_to_str( (TokType)index ); + keymap[index] = crc32( enum_str.Ptr, enum_str.Len ); } do_once_end u32 hash = crc32( str.Ptr, str.Len ); for ( u32 index = 0; index < Tok_NumTokens; index++ ) diff --git a/base/components/header_end.hpp b/base/components/header_end.hpp index 2cbc306..c20b910 100644 --- a/base/components/header_end.hpp +++ b/base/components/header_end.hpp @@ -53,7 +53,7 @@ constexpr s32 MaxUntypedStrLength = GEN_MAX_UNTYPED_STR_LENGTH; constexpr s32 LexAllocator_Size = GEN_LEX_ALLOCATOR_SIZE; constexpr s32 Builder_StrBufferReserve = GEN_BUILDER_STR_BUFFER_RESERVE; -extern StrC enum_underlying_sig; +extern Str enum_underlying_sig; extern Code access_public; extern Code access_protected; diff --git a/base/components/inlines.hpp b/base/components/inlines.hpp index 70bc45d..7a74511 100644 --- a/base/components/inlines.hpp +++ b/base/components/inlines.hpp @@ -101,7 +101,7 @@ Code& Code::operator ++() } #endif forceinline -StrC code_type_str(Code self) +Str code_type_str(Code self) { GEN_ASSERT(self != nullptr); return codetype_to_str( self->Type ); @@ -397,7 +397,7 @@ CodeBody def_body( CodeType type ) } inline -StrC token_fmt_impl( ssize num, ... ) +Str token_fmt_impl( ssize num, ... ) { local_persist thread_local char buf[GEN_PRINTF_MAXLEN] = { 0 }; @@ -408,7 +408,7 @@ StrC token_fmt_impl( ssize num, ... ) ssize result = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num, va); va_end(va); - StrC str = { result, buf }; + Str str = { buf, result }; return str; } #pragma endregion Interface diff --git a/base/components/interface.cpp b/base/components/interface.cpp index cc09014..960e1c7 100644 --- a/base/components/interface.cpp +++ b/base/components/interface.cpp @@ -101,11 +101,11 @@ void define_constants() access_public->Name = get_cached_string( txt("public:\n") ); code_set_global(access_public); - StrC api_export_str = code(GEN_API_Export_Code); + Str api_export_str = code(GEN_API_Export_Code); attrib_api_export = def_attributes( api_export_str ); code_set_global(cast(Code, attrib_api_export)); - StrC api_import_str = code(GEN_API_Import_Code); + Str api_import_str = code(GEN_API_Import_Code); attrib_api_import = def_attributes( api_import_str ); code_set_global(cast(Code, attrib_api_import)); @@ -145,33 +145,33 @@ void define_constants() preprocess_endif->Type = CT_Preprocess_EndIf; code_set_global((Code)preprocess_endif); - StrC auto_str = txt("auto"); t_auto = def_type( auto_str ); code_set_global( t_auto ); - StrC void_str = txt("void"); t_void = def_type( void_str ); code_set_global( t_void ); - StrC int_str = txt("int"); t_int = def_type( int_str ); code_set_global( t_int ); - StrC bool_str = txt("bool"); t_bool = def_type( bool_str ); code_set_global( t_bool ); - StrC char_str = txt("char"); t_char = def_type( char_str ); code_set_global( t_char ); - StrC wchar_str = txt("wchar_t"); t_wchar_t = def_type( wchar_str ); code_set_global( t_wchar_t ); - StrC class_str = txt("class"); t_class = def_type( class_str ); code_set_global( t_class ); - StrC typename_str = txt("typename"); t_typename = def_type( typename_str ); code_set_global( t_typename ); + Str auto_str = txt("auto"); t_auto = def_type( auto_str ); code_set_global( t_auto ); + Str void_str = txt("void"); t_void = def_type( void_str ); code_set_global( t_void ); + Str int_str = txt("int"); t_int = def_type( int_str ); code_set_global( t_int ); + Str bool_str = txt("bool"); t_bool = def_type( bool_str ); code_set_global( t_bool ); + Str char_str = txt("char"); t_char = def_type( char_str ); code_set_global( t_char ); + Str wchar_str = txt("wchar_t"); t_wchar_t = def_type( wchar_str ); code_set_global( t_wchar_t ); + Str class_str = txt("class"); t_class = def_type( class_str ); code_set_global( t_class ); + Str typename_str = txt("typename"); t_typename = def_type( typename_str ); code_set_global( t_typename ); #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS t_b32 = def_type( name(b32) ); code_set_global( t_b32 ); - StrC s8_str = txt("s8"); t_s8 = def_type( s8_str ); code_set_global( t_s8 ); - StrC s16_str = txt("s16"); t_s16 = def_type( s16_str ); code_set_global( t_s16 ); - StrC s32_str = txt("s32"); t_s32 = def_type( s32_str ); code_set_global( t_s32 ); - StrC s64_str = txt("s64"); t_s64 = def_type( s64_str ); code_set_global( t_s64 ); + Str s8_str = txt("s8"); t_s8 = def_type( s8_str ); code_set_global( t_s8 ); + Str s16_str = txt("s16"); t_s16 = def_type( s16_str ); code_set_global( t_s16 ); + Str s32_str = txt("s32"); t_s32 = def_type( s32_str ); code_set_global( t_s32 ); + Str s64_str = txt("s64"); t_s64 = def_type( s64_str ); code_set_global( t_s64 ); - StrC u8_str = txt("u8"); t_u8 = def_type( u8_str ); code_set_global( t_u8 ); - StrC u16_str = txt("u16"); t_u16 = def_type( u16_str ); code_set_global( t_u16 ); - StrC u32_str = txt("u32"); t_u32 = def_type( u32_str ); code_set_global( t_u32 ); - StrC u64_str = txt("u64"); t_u64 = def_type( u64_str ); code_set_global( t_u64 ); + Str u8_str = txt("u8"); t_u8 = def_type( u8_str ); code_set_global( t_u8 ); + Str u16_str = txt("u16"); t_u16 = def_type( u16_str ); code_set_global( t_u16 ); + Str u32_str = txt("u32"); t_u32 = def_type( u32_str ); code_set_global( t_u32 ); + Str u64_str = txt("u64"); t_u64 = def_type( u64_str ); code_set_global( t_u64 ); - StrC ssize_str = txt("ssize"); t_ssize = def_type( ssize_str ); code_set_global( t_ssize ); - StrC usize_str = txt("usize"); t_usize = def_type( usize_str ); code_set_global( t_usize ); + Str ssize_str = txt("ssize"); t_ssize = def_type( ssize_str ); code_set_global( t_ssize ); + Str usize_str = txt("usize"); t_usize = def_type( usize_str ); code_set_global( t_usize ); - StrC f32_str = txt("f32"); t_f32 = def_type( f32_str ); code_set_global( t_f32 ); - StrC f64_str = txt("f64"); t_f64 = def_type( f64_str ); code_set_global( t_f64 ); + Str f32_str = txt("f32"); t_f32 = def_type( f32_str ); code_set_global( t_f32 ); + Str f64_str = txt("f64"); t_f64 = def_type( f64_str ); code_set_global( t_f64 ); #endif spec_const = def_specifier( Spec_Const); code_set_global( cast(Code, spec_const )); @@ -273,12 +273,12 @@ void init() LexArena = arena_init_from_allocator( Allocator_Lexer, LexAllocator_Size ); - Arena string_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena ); + Arena strbuilder_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena ); - if ( string_arena.PhysicalStart == nullptr ) + if ( strbuilder_arena.PhysicalStart == nullptr ) GEN_FATAL( "gen::init: Failed to initialize the string arena" ); - array_append( StringArenas, string_arena ); + array_append( StringArenas, strbuilder_arena ); } // Setup the hash tables @@ -312,8 +312,8 @@ void deinit() left = array_num(StringArenas); do { - Arena* string_arena = & StringArenas[index]; - arena_free(string_arena); + Arena* strbuilder_arena = & StringArenas[index]; + arena_free(strbuilder_arena); index++; } while ( left--, left ); @@ -357,8 +357,8 @@ void reset() left = array_num(StringArenas); do { - Arena* string_arena = & StringArenas[index]; - string_arena->TotalUsed = 0;; + Arena* strbuilder_arena = & StringArenas[index]; + strbuilder_arena->TotalUsed = 0;; index++; } while ( left--, left ); @@ -368,18 +368,18 @@ void reset() define_constants(); } -AllocatorInfo get_string_allocator( s32 str_length ) +AllocatorInfo get_strbuilder_allocator( s32 c_str_length ) { Arena* last = array_back(StringArenas); - usize size_req = str_length + sizeof(StringHeader) + sizeof(char*); + usize size_req = c_str_length + sizeof(StrBuilderHeader) + sizeof(char*); if ( last->TotalUsed + scast(ssize, size_req) > last->TotalSize ) { Arena new_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena ); if ( ! array_append( StringArenas, new_arena ) ) - GEN_FATAL( "gen::get_string_allocator: Failed to allocate a new string arena" ); + GEN_FATAL( "gen::get_strbuilder_allocator: Failed to allocate a new string arena" ); last = array_back(StringArenas); } @@ -388,7 +388,7 @@ AllocatorInfo get_string_allocator( s32 str_length ) } // Will either make or retrive a code string. -StringCached get_cached_string( StrC str ) +StringCached get_cached_string( Str str ) { s32 hash_length = str.Len > kilobytes(1) ? kilobytes(1) : str.Len; u64 key = crc32( str.Ptr, hash_length ); @@ -399,7 +399,7 @@ StringCached get_cached_string( StrC str ) return * result; } - StrC result = string_to_strc( string_make_strc( get_string_allocator( str.Len ), str )); + Str result = strbuilder_to_str( strbuilder_make_str( get_strbuilder_allocator( str.Len ), str )); hashtable_set(StringCache, key, result ); return result; @@ -442,12 +442,12 @@ void set_allocator_lexer( AllocatorInfo allocator ) Allocator_Lexer = allocator; } -void set_allocator_string_arena( AllocatorInfo allocator ) +void set_allocator_strbuilder_arena( AllocatorInfo allocator ) { Allocator_StringArena = allocator; } -void set_allocator_string_table( AllocatorInfo allocator ) +void set_allocator_strbuilder_table( AllocatorInfo allocator ) { Allocator_StringArena = allocator; } diff --git a/base/components/interface.hpp b/base/components/interface.hpp index 2b08281..5f7b590 100644 --- a/base/components/interface.hpp +++ b/base/components/interface.hpp @@ -28,7 +28,7 @@ void reset(); // Used internally to retrive or make string allocations. // Strings are stored in a series of string arenas of fixed size (SizePer_StringArena) -StringCached get_cached_string( StrC str ); +StringCached get_cached_string( Str str ); /* This provides a fresh Code AST. @@ -42,14 +42,14 @@ Code make_code(); void set_allocator_data_arrays ( AllocatorInfo data_array_allocator ); void set_allocator_code_pool ( AllocatorInfo pool_allocator ); void set_allocator_lexer ( AllocatorInfo lex_allocator ); -void set_allocator_string_arena( AllocatorInfo string_allocator ); -void set_allocator_string_table( AllocatorInfo string_allocator ); +void set_allocator_strbuilder_arena( AllocatorInfo strbuilder_allocator ); +void set_allocator_strbuilder_table( AllocatorInfo strbuilder_allocator ); void set_allocator_type_table ( AllocatorInfo type_reg_allocator ); #pragma region Upfront -CodeAttributes def_attributes( StrC content ); -CodeComment def_comment ( StrC content ); +CodeAttributes def_attributes( Str content ); +CodeComment def_comment ( Str content ); struct Opts_def_struct { CodeBody body; @@ -60,7 +60,7 @@ struct Opts_def_struct { s32 num_interfaces; ModuleFlag mflags; }; -CodeClass def_class( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT ); +CodeClass def_class( Str name, Opts_def_struct opts GEN_PARAM_DEFAULT ); struct Opts_def_constructor { CodeParams params; @@ -72,7 +72,7 @@ CodeConstructor def_constructor( Opts_def_constructor opts GEN_PARAM_DEFAULT ); struct Opts_def_define { b32 dont_append_preprocess_defines; }; -CodeDefine def_define( StrC name, StrC content, Opts_def_define opts GEN_PARAM_DEFAULT ); +CodeDefine def_define( Str name, Str content, Opts_def_define opts GEN_PARAM_DEFAULT ); struct Opts_def_destructor { Code body; @@ -88,10 +88,10 @@ struct Opts_def_enum { ModuleFlag mflags; Code type_macro; }; -CodeEnum def_enum( StrC name, Opts_def_enum opts GEN_PARAM_DEFAULT ); +CodeEnum def_enum( Str name, Opts_def_enum opts GEN_PARAM_DEFAULT ); -CodeExec def_execution ( StrC content ); -CodeExtern def_extern_link( StrC name, CodeBody body ); +CodeExec def_execution ( Str content ); +CodeExtern def_extern_link( Str name, CodeBody body ); CodeFriend def_friend ( Code symbol ); struct Opts_def_function { @@ -102,14 +102,14 @@ struct Opts_def_function { CodeAttributes attrs; ModuleFlag mflags; }; -CodeFn def_function( StrC name, Opts_def_function opts GEN_PARAM_DEFAULT ); +CodeFn def_function( Str name, Opts_def_function opts GEN_PARAM_DEFAULT ); 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, CodeBody body, Opts_def_namespace opts GEN_PARAM_DEFAULT ); +CodeInclude def_include ( Str content, Opts_def_include opts GEN_PARAM_DEFAULT ); +CodeModule def_module ( Str name, Opts_def_module opts GEN_PARAM_DEFAULT ); +CodeNS def_namespace( Str name, CodeBody body, Opts_def_namespace opts GEN_PARAM_DEFAULT ); struct Opts_def_operator { CodeParams params; @@ -119,7 +119,7 @@ struct Opts_def_operator { CodeAttributes attributes; ModuleFlag mflags; }; -CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator opts GEN_PARAM_DEFAULT ); +CodeOperator def_operator( Operator op, Str nspace, Opts_def_operator opts GEN_PARAM_DEFAULT ); struct Opts_def_operator_cast { CodeBody body; @@ -128,14 +128,14 @@ struct Opts_def_operator_cast { CodeOpCast def_operator_cast( CodeTypename type, Opts_def_operator_cast opts GEN_PARAM_DEFAULT ); struct Opts_def_param { Code value; }; -CodeParams def_param ( CodeTypename type, StrC name, Opts_def_param opts GEN_PARAM_DEFAULT ); -CodePragma def_pragma( StrC directive ); +CodeParams def_param ( CodeTypename type, Str name, Opts_def_param opts GEN_PARAM_DEFAULT ); +CodePragma def_pragma( Str directive ); -CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content ); +CodePreprocessCond def_preprocess_cond( EPreprocessCond type, Str content ); CodeSpecifiers def_specifier( Specifier specifier ); -CodeStruct def_struct( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT ); +CodeStruct def_struct( Str name, Opts_def_struct opts GEN_PARAM_DEFAULT ); struct Opts_def_template { ModuleFlag mflags; }; CodeTemplate def_template( CodeParams params, Code definition, Opts_def_template opts GEN_PARAM_DEFAULT ); @@ -146,27 +146,27 @@ struct Opts_def_type { CodeSpecifiers specifiers; CodeAttributes attributes; }; -CodeTypename def_type( StrC name, Opts_def_type opts GEN_PARAM_DEFAULT ); +CodeTypename def_type( Str name, Opts_def_type opts GEN_PARAM_DEFAULT ); struct Opts_def_typedef { CodeAttributes attributes; ModuleFlag mflags; }; -CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef opts GEN_PARAM_DEFAULT ); +CodeTypedef def_typedef( Str name, Code type, Opts_def_typedef opts GEN_PARAM_DEFAULT ); struct Opts_def_union { CodeAttributes attributes; ModuleFlag mflags; }; -CodeUnion def_union( StrC name, CodeBody body, Opts_def_union opts GEN_PARAM_DEFAULT ); +CodeUnion def_union( Str name, CodeBody body, Opts_def_union opts GEN_PARAM_DEFAULT ); struct Opts_def_using { CodeAttributes attributes; ModuleFlag mflags; }; -CodeUsing def_using( StrC name, CodeTypename type, Opts_def_using opts GEN_PARAM_DEFAULT ); +CodeUsing def_using( Str name, CodeTypename type, Opts_def_using opts GEN_PARAM_DEFAULT ); -CodeUsing def_using_namespace( StrC name ); +CodeUsing def_using_namespace( Str name ); struct Opts_def_variable { @@ -175,7 +175,7 @@ struct Opts_def_variable CodeAttributes attributes; ModuleFlag mflags; }; -CodeVar def_variable( CodeTypename type, StrC name, Opts_def_variable opts GEN_PARAM_DEFAULT ); +CodeVar def_variable( CodeTypename type, Str 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( CodeType type ); @@ -220,13 +220,13 @@ struct StackNode Token Start; Token Name; // The name of the AST node (if parsed) - StrC FailedProc; // The name of the procedure that failed + Str FailedProc; // The name of the procedure that failed }; // Stack nodes are allocated the error's allocator struct Error { - String message; + StrBuilder message; StackNode* context_stack; }; GEN_NS_PARSER_END @@ -243,28 +243,28 @@ struct ParseInfo // Errors are allocated to a dedicated general arena. }; -CodeBody parse_file( StrC path ); +CodeBody parse_file( Str path ); #endif -CodeClass parse_class ( StrC class_def ); -CodeConstructor parse_constructor ( StrC constructor_def ); -CodeDestructor parse_destructor ( StrC destructor_def ); -CodeEnum parse_enum ( StrC enum_def ); -CodeBody parse_export_body ( StrC export_def ); -CodeExtern parse_extern_link ( StrC exten_link_def ); -CodeFriend parse_friend ( StrC friend_def ); -CodeFn parse_function ( StrC fn_def ); -CodeBody parse_global_body ( StrC body_def ); -CodeNS parse_namespace ( StrC namespace_def ); -CodeOperator parse_operator ( StrC operator_def ); -CodeOpCast parse_operator_cast( StrC operator_def ); -CodeStruct parse_struct ( StrC struct_def ); -CodeTemplate parse_template ( StrC template_def ); -CodeTypename parse_type ( StrC type_def ); -CodeTypedef parse_typedef ( StrC typedef_def ); -CodeUnion parse_union ( StrC union_def ); -CodeUsing parse_using ( StrC using_def ); -CodeVar parse_variable ( StrC var_def ); +CodeClass parse_class ( Str class_def ); +CodeConstructor parse_constructor ( Str constructor_def ); +CodeDestructor parse_destructor ( Str destructor_def ); +CodeEnum parse_enum ( Str enum_def ); +CodeBody parse_export_body ( Str export_def ); +CodeExtern parse_extern_link ( Str exten_link_def ); +CodeFriend parse_friend ( Str friend_def ); +CodeFn parse_function ( Str fn_def ); +CodeBody parse_global_body ( Str body_def ); +CodeNS parse_namespace ( Str namespace_def ); +CodeOperator parse_operator ( Str operator_def ); +CodeOpCast parse_operator_cast( Str operator_def ); +CodeStruct parse_struct ( Str struct_def ); +CodeTemplate parse_template ( Str template_def ); +CodeTypename parse_type ( Str type_def ); +CodeTypedef parse_typedef ( Str typedef_def ); +CodeUnion parse_union ( Str union_def ); +CodeUsing parse_using ( Str using_def ); +CodeVar parse_variable ( Str var_def ); #pragma endregion Parsing @@ -272,9 +272,9 @@ CodeVar parse_variable ( StrC var_def ); ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va ); //! Do not use directly. Use the token_fmt macro instead. -StrC token_fmt_impl( ssize, ... ); +Str token_fmt_impl( ssize, ... ); -Code untyped_str ( StrC content); +Code untyped_str ( Str content); Code untyped_fmt ( char const* fmt, ... ); Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... ); @@ -289,12 +289,12 @@ Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... ); #ifndef name // 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. -#define name( Id_ ) { sizeof(stringize( Id_ )) - 1, stringize(Id_) } +#define name( Id_ ) { stringize(Id_), sizeof(stringize( Id_ )) - 1 } #endif #ifndef code // Same as name just used to indicate intention of literal for code instead of names. -#define code( ... ) { sizeof(stringize(__VA_ARGS__)) - 1, stringize( __VA_ARGS__ ) } +#define code( ... ) { stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 } #endif #ifndef args @@ -317,21 +317,21 @@ Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... ); #ifndef token_fmt /* -Takes a format string (char const*) and a list of tokens (StrC) and returns a StrC of the formatted string. +Takes a format string (char const*) and a list of tokens (Str) and returns a Str of the formatted string. Tokens are provided in '<'identifier'>' format where '<' '>' are just angle brackets (you can change it in token_fmt_va) --------------------------------------------------------- Example - A string with: typedef ; Will have a token_fmt arguments populated with: - "type", strc_for_type, - "name", strc_for_name, + "type", str_for_type, + "name", str_for_name, and: stringize( typedef ; ) ----------------------------------------------------------- So the full call for this example would be: token_fmt( - "type", strc_for_type - , "name", strc_for_name + "type", str_for_type + , "name", str_for_name , stringize( typedef )); diff --git a/base/components/interface.parsing.cpp b/base/components/interface.parsing.cpp index d983e07..e8fc53e 100644 --- a/base/components/interface.parsing.cpp +++ b/base/components/interface.parsing.cpp @@ -8,7 +8,7 @@ // Publically Exposed Interface -CodeClass parse_class( StrC def ) +CodeClass parse_class( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -24,7 +24,7 @@ CodeClass parse_class( StrC def ) return result; } -CodeConstructor parse_constructor( StrC def ) +CodeConstructor parse_constructor( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -41,7 +41,7 @@ CodeConstructor parse_constructor( StrC def ) while ( left && tok_is_specifier(currtok) ) { - Specifier spec = strc_to_specifier( tok_to_str(currtok) ); + Specifier spec = str_to_specifier( tok_to_str(currtok) ); b32 ignore_spec = false; @@ -59,7 +59,7 @@ CodeConstructor parse_constructor( StrC def ) break; default : - log_failure( "Invalid specifier %s for variable\n%s", spec_to_str( spec ), parser_to_string(Context) ); + log_failure( "Invalid specifier %s for variable\n%S", spec_to_str( spec ), parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -84,7 +84,7 @@ CodeConstructor parse_constructor( StrC def ) return result; } -CodeDestructor parse_destructor( StrC def ) +CodeDestructor parse_destructor( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -101,7 +101,7 @@ CodeDestructor parse_destructor( StrC def ) return result; } -CodeEnum parse_enum( StrC def ) +CodeEnum parse_enum( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -117,7 +117,7 @@ CodeEnum parse_enum( StrC def ) return parser_parse_enum( parser_not_inplace_def); } -CodeBody parse_export_body( StrC def ) +CodeBody parse_export_body( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -130,7 +130,7 @@ CodeBody parse_export_body( StrC def ) return parser_parse_export_body(); } -CodeExtern parse_extern_link( StrC def ) +CodeExtern parse_extern_link( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -143,7 +143,7 @@ CodeExtern parse_extern_link( StrC def ) return parser_parse_extern_link(); } -CodeFriend parse_friend( StrC def ) +CodeFriend parse_friend( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -156,7 +156,7 @@ CodeFriend parse_friend( StrC def ) return parser_parse_friend(); } -CodeFn parse_function( StrC def ) +CodeFn parse_function( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -169,7 +169,7 @@ CodeFn parse_function( StrC def ) return (CodeFn) parser_parse_function(); } -CodeBody parse_global_body( StrC def ) +CodeBody parse_global_body( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -185,7 +185,7 @@ CodeBody parse_global_body( StrC def ) return result; } -CodeNS parse_namespace( StrC def ) +CodeNS parse_namespace( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -198,7 +198,7 @@ CodeNS parse_namespace( StrC def ) return parser_parse_namespace(); } -CodeOperator parse_operator( StrC def ) +CodeOperator parse_operator( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -211,7 +211,7 @@ CodeOperator parse_operator( StrC def ) return (CodeOperator) parser_parse_operator(); } -CodeOpCast parse_operator_cast( StrC def ) +CodeOpCast parse_operator_cast( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -224,7 +224,7 @@ CodeOpCast parse_operator_cast( StrC def ) return parser_parse_operator_cast(NullCode); } -CodeStruct parse_struct( StrC def ) +CodeStruct parse_struct( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -240,7 +240,7 @@ CodeStruct parse_struct( StrC def ) return result; } -CodeTemplate parse_template( StrC def ) +CodeTemplate parse_template( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -253,7 +253,7 @@ CodeTemplate parse_template( StrC def ) return parser_parse_template(); } -CodeTypename parse_type( StrC def ) +CodeTypename parse_type( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -266,7 +266,7 @@ CodeTypename parse_type( StrC def ) return parser_parse_type( parser_not_from_template, nullptr); } -CodeTypedef parse_typedef( StrC def ) +CodeTypedef parse_typedef( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -279,7 +279,7 @@ CodeTypedef parse_typedef( StrC def ) return parser_parse_typedef(); } -CodeUnion parse_union( StrC def ) +CodeUnion parse_union( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -292,7 +292,7 @@ CodeUnion parse_union( StrC def ) return parser_parse_union( parser_not_inplace_def); } -CodeUsing parse_using( StrC def ) +CodeUsing parse_using( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); @@ -305,7 +305,7 @@ CodeUsing parse_using( StrC def ) return parser_parse_using(); } -CodeVar parse_variable( StrC def ) +CodeVar parse_variable( Str def ) { GEN_USING_NS_PARSER; check_parse_args( def ); diff --git a/base/components/interface.untyped.cpp b/base/components/interface.untyped.cpp index d430656..e8eb297 100644 --- a/base/components/interface.untyped.cpp +++ b/base/components/interface.untyped.cpp @@ -15,16 +15,16 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va ) local_persist StringTable tok_map; { - tok_map = hashtable_init(StrC, fixed_arena_allocator_info(& tok_map_arena) ); + tok_map = hashtable_init(Str, fixed_arena_allocator_info(& tok_map_arena) ); s32 left = num_tokens - 1; while ( left-- ) { char const* token = va_arg( va, char const* ); - StrC value = va_arg( va, StrC ); + Str value = va_arg( va, Str ); - u32 key = crc32( token, str_len(token) ); + u32 key = crc32( token, c_str_len(token) ); hashtable_set( tok_map, key, value ); } } @@ -61,7 +61,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va ) char const* token = fmt + 1; u32 key = crc32( token, tok_len ); - StrC* value = hashtable_get(tok_map, key ); + Str* value = hashtable_get(tok_map, key ); if ( value ) { @@ -99,7 +99,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va ) return result; } -Code untyped_str( StrC content ) +Code untyped_str( Str content ) { if ( content.Len == 0 ) { @@ -135,11 +135,11 @@ Code untyped_fmt( char const* fmt, ...) va_list va; va_start(va, fmt); - ssize length = str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va); + ssize length = c_str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va); va_end(va); - StrC buf_str = { str_len_capped(fmt, MaxNameLength), fmt }; - StrC uncapped_str = { length, buf }; + Str buf_str = { fmt, c_str_len_capped(fmt, MaxNameLength) }; + Str uncapped_str = { buf, length }; Code result = make_code(); @@ -172,7 +172,7 @@ Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... ) ssize length = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num_tokens, va); va_end(va); - StrC buf_str = { length, buf }; + Str buf_str = { buf, length }; Code result = make_code(); diff --git a/base/components/interface.upfront.cpp b/base/components/interface.upfront.cpp index 04782db..d7025f6 100644 --- a/base/components/interface.upfront.cpp +++ b/base/components/interface.upfront.cpp @@ -373,7 +373,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy } forceinline -bool name__check( char const* context, StrC name ) +bool name__check( char const* context, Str name ) { if ( name.Len <= 0 ) { log_failure( "gen::%s: Invalid name length provided - %d", name.Len ); @@ -409,7 +409,7 @@ identify the issue without having to debug too much (at least they can debug tho The largest of the functions is related to operator overload definitions. The library validates a good protion of their form and thus the argument processing for is quite a bit. */ -CodeAttributes def_attributes( StrC content ) +CodeAttributes def_attributes( Str content ) { if ( content.Len <= 0 || content.Ptr == nullptr ) { log_failure( "gen::def_attributes: Invalid attributes provided" ); @@ -424,7 +424,7 @@ CodeAttributes def_attributes( StrC content ) return (CodeAttributes) result; } -CodeComment def_comment( StrC content ) +CodeComment def_comment( Str content ) { if ( content.Len <= 0 || content.Ptr == nullptr ) { @@ -435,7 +435,7 @@ CodeComment def_comment( StrC content ) static char line[ MaxCommentLineLength ]; - String cmt_formatted = string_make_reserve( GlobalAllocator, kilobytes(1) ); + StrBuilder cmt_formatted = strbuilder_make_reserve( GlobalAllocator, kilobytes(1) ); char const* end = content.Ptr + content.Len; char const* scanner = content.Ptr; s32 curr = 0; @@ -450,18 +450,18 @@ CodeComment def_comment( StrC content ) } length++; - str_copy( line, scanner, length ); - string_append_fmt(& cmt_formatted, "//%.*s", length, line ); + c_str_copy( line, scanner, length ); + strbuilder_append_fmt(& cmt_formatted, "//%.*s", length, line ); mem_set( line, 0, MaxCommentLineLength ); scanner += length; } while ( scanner <= end ); - if ( * string_back(cmt_formatted) != '\n' ) - string_append_strc( & cmt_formatted, txt("\n") ); + if ( * strbuilder_back(cmt_formatted) != '\n' ) + strbuilder_append_str( & cmt_formatted, txt("\n") ); - StrC name = { string_length(cmt_formatted), cmt_formatted }; + Str name = strbuilder_to_str(cmt_formatted); Code result = make_code(); @@ -469,7 +469,7 @@ CodeComment def_comment( StrC content ) result->Name = get_cached_string( name ); result->Content = result->Name; - string_free(& cmt_formatted); + strbuilder_free(& cmt_formatted); return (CodeComment) result; } @@ -511,7 +511,7 @@ CodeConstructor def_constructor( Opts_def_constructor p ) return result; } -CodeClass def_class( StrC name, Opts_def_struct p ) +CodeClass def_class( Str name, Opts_def_struct p ) { if ( ! name_check( def_class, name ) ) { GEN_DEBUG_TRAP(); @@ -564,7 +564,7 @@ CodeClass def_class( StrC name, Opts_def_struct p ) return result; } -CodeDefine def_define( StrC name, StrC content, Opts_def_define p ) +CodeDefine def_define( Str name, Str content, Opts_def_define p ) { if ( ! name_check( def_define, name ) ) { GEN_DEBUG_TRAP(); @@ -579,7 +579,7 @@ CodeDefine def_define( StrC name, StrC content, Opts_def_define p ) if ( content.Len <= 0 || content.Ptr == nullptr ) result->Content = get_cached_string( txt("") ); else - result->Content = get_cached_string( string_to_strc(string_fmt_buf(GlobalAllocator, "%SC\n", content)) ); + result->Content = get_cached_string( strbuilder_to_str(strbuilder_fmt_buf(GlobalAllocator, "%S\n", content)) ); b32 append_preprocess_defines = ! p.dont_append_preprocess_defines; if ( append_preprocess_defines ) { @@ -589,7 +589,7 @@ CodeDefine def_define( StrC name, StrC content, Opts_def_define p ) if ( result->Name.Ptr[lex_id_len] == '(' ) break; } - StrC lex_id = { lex_id_len, result->Name.Ptr }; + Str lex_id = { result->Name.Ptr, lex_id_len }; array_append(PreprocessorDefines, lex_id ); } return result; @@ -629,7 +629,7 @@ CodeDestructor def_destructor( Opts_def_destructor p ) return result; } -CodeEnum def_enum( StrC name, Opts_def_enum p ) +CodeEnum def_enum( Str name, Opts_def_enum p ) { if ( ! name_check( def_enum, name ) ) { GEN_DEBUG_TRAP(); @@ -690,7 +690,7 @@ CodeEnum def_enum( StrC name, Opts_def_enum p ) return result; } -CodeExec def_execution( StrC content ) +CodeExec def_execution( Str content ) { if ( content.Len <= 0 || content.Ptr == nullptr ) { log_failure( "gen::def_execution: Invalid execution provided" ); @@ -704,7 +704,7 @@ CodeExec def_execution( StrC content ) return result; } -CodeExtern def_extern_link( StrC name, CodeBody body ) +CodeExtern def_extern_link( Str name, CodeBody body ) { if ( ! name_check(def_extern_link, name) || ! null_check(def_extern_link, body) ) { GEN_DEBUG_TRAP(); @@ -752,7 +752,7 @@ CodeFriend def_friend( Code declaration ) return result; } -CodeFn def_function( StrC name, Opts_def_function p ) +CodeFn def_function( Str name, Opts_def_function p ) { if ( ! name_check( def_function, name )) { GEN_DEBUG_TRAP(); @@ -812,26 +812,26 @@ CodeFn def_function( StrC name, Opts_def_function p ) return result; } -CodeInclude def_include( StrC path, Opts_def_include p ) +CodeInclude def_include( Str path, Opts_def_include p ) { if ( path.Len <= 0 || path.Ptr == nullptr ) { log_failure( "gen::def_include: Invalid path provided - %d" ); GEN_DEBUG_TRAP(); return InvalidCode; } - String content = p.foreign ? - string_fmt_buf( GlobalAllocator, "<%.*s>", path.Len, path.Ptr ) - : string_fmt_buf( GlobalAllocator, "\"%.*s\"", path.Len, path.Ptr ); + StrBuilder content = p.foreign ? + strbuilder_fmt_buf( GlobalAllocator, "<%.*s>", path.Len, path.Ptr ) + : strbuilder_fmt_buf( GlobalAllocator, "\"%.*s\"", path.Len, path.Ptr ); CodeInclude result = (CodeInclude) make_code(); result->Type = CT_Preprocess_Include; - result->Name = get_cached_string( string_to_strc(content) ); + result->Name = get_cached_string( strbuilder_to_str(content) ); result->Content = result->Name; return result; } -CodeModule def_module( StrC name, Opts_def_module p ) +CodeModule def_module( Str name, Opts_def_module p ) { if ( ! name_check( def_module, name )) { GEN_DEBUG_TRAP(); @@ -845,7 +845,7 @@ CodeModule def_module( StrC name, Opts_def_module p ) return result; } -CodeNS def_namespace( StrC name, CodeBody body, Opts_def_namespace p ) +CodeNS def_namespace( Str name, CodeBody body, Opts_def_namespace p ) { if ( ! name_check( def_namespace, name )) { GEN_DEBUG_TRAP(); @@ -869,7 +869,7 @@ CodeNS def_namespace( StrC name, CodeBody body, Opts_def_namespace p ) return result; } -CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator p ) +CodeOperator def_operator( Operator op, Str nspace, Opts_def_operator p ) { if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", code_debug_str(p.attributes) ); @@ -889,13 +889,13 @@ CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator p ) char const* name = nullptr; - StrC op_str = operator_to_str( op ); + Str op_str = operator_to_str( op ); if ( nspace.Len > 0 ) - name = str_fmt_buf( "%.*soperator %.*s", nspace.Len, nspace.Ptr, op_str.Len, op_str.Ptr ); + name = c_str_fmt_buf( "%.*soperator %.*s", nspace.Len, nspace.Ptr, op_str.Len, op_str.Ptr ); else - name = str_fmt_buf( "operator %.*s", op_str.Len, op_str.Ptr ); + name = c_str_fmt_buf( "operator %.*s", op_str.Len, op_str.Ptr ); - StrC name_resolved = { str_len(name), name }; + Str name_resolved = { name, c_str_len(name) }; CodeOperator result = (CodeOperator) make_code(); @@ -969,7 +969,7 @@ CodeOpCast def_operator_cast( CodeTypename type, Opts_def_operator_cast p ) return result; } -CodeParams def_param( CodeTypename type, StrC name, Opts_def_param p ) +CodeParams def_param( CodeTypename type, Str name, Opts_def_param p ) { if ( ! name_check( def_param, name ) || ! null_check( def_param, type ) ) { GEN_DEBUG_TRAP(); @@ -993,7 +993,7 @@ CodeParams def_param( CodeTypename type, StrC name, Opts_def_param p ) return result; } -CodePragma def_pragma( StrC directive ) +CodePragma def_pragma( Str directive ) { if ( directive.Len <= 0 || directive.Ptr == nullptr ) { log_failure( "gen::def_comment: Invalid comment provided:" ); @@ -1007,7 +1007,7 @@ CodePragma def_pragma( StrC directive ) return result; } -CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC expr ) +CodePreprocessCond def_preprocess_cond( EPreprocessCond type, Str expr ) { if ( expr.Len <= 0 || expr.Ptr == nullptr ) { log_failure( "gen::def_comment: Invalid comment provided:" ); @@ -1044,7 +1044,7 @@ CodeSpecifiers def_specifier( Specifier spec ) return result; } -CodeStruct def_struct( StrC name, Opts_def_struct p ) +CodeStruct def_struct( Str name, Opts_def_struct p ) { if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", code_debug_str(cast(Code, p.attributes)) ); @@ -1117,7 +1117,7 @@ CodeTemplate def_template( CodeParams params, Code declaration, Opts_def_templat return result; } -CodeTypename def_type( StrC name, Opts_def_type p ) +CodeTypename def_type( Str name, Opts_def_type p ) { if ( ! name_check( def_type, name )) { GEN_DEBUG_TRAP(); @@ -1152,7 +1152,7 @@ CodeTypename def_type( StrC name, Opts_def_type p ) return result; } -CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef p ) +CodeTypedef def_typedef( Str name, Code type, Opts_def_typedef p ) { if ( ! null_check( def_typedef, type ) ) { GEN_DEBUG_TRAP(); @@ -1215,7 +1215,7 @@ CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef p ) return result; } -CodeUnion def_union( StrC name, CodeBody body, Opts_def_union p ) +CodeUnion def_union( Str name, CodeBody body, Opts_def_union p ) { if ( ! null_check( def_union, body ) ) { GEN_DEBUG_TRAP(); @@ -1242,7 +1242,7 @@ CodeUnion def_union( StrC name, CodeBody body, Opts_def_union p ) return result; } -CodeUsing def_using( StrC name, CodeTypename type, Opts_def_using p ) +CodeUsing def_using( Str name, CodeTypename type, Opts_def_using p ) { if ( ! name_check( def_using, name ) || null_check( def_using, type ) ) { GEN_DEBUG_TRAP(); @@ -1270,7 +1270,7 @@ CodeUsing def_using( StrC name, CodeTypename type, Opts_def_using p ) return result; } -CodeUsing def_using_namespace( StrC name ) +CodeUsing def_using_namespace( Str name ) { if ( ! name_check( def_using_namespace, name ) ) { GEN_DEBUG_TRAP(); @@ -1283,7 +1283,7 @@ CodeUsing def_using_namespace( StrC name ) return result; } -CodeVar def_variable( CodeTypename type, StrC name, Opts_def_variable p ) +CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable p ) { if ( ! name_check( def_variable, name ) || null_check( def_variable, type ) ) { GEN_DEBUG_TRAP(); diff --git a/base/components/lexer.cpp b/base/components/lexer.cpp index 4fd1429..4009ec0 100644 --- a/base/components/lexer.cpp +++ b/base/components/lexer.cpp @@ -26,88 +26,84 @@ enum TokFlags : u32 struct Token { - char const* Text; - sptr Length; - TokType Type; - s32 Line; - s32 Column; - u32 Flags; + Str Text; + TokType Type; + s32 Line; + s32 Column; + u32 Flags; }; constexpr Token NullToken { nullptr, 0, Tok_Invalid, false, 0, TF_Null }; -AccessSpec tok_to_access_specifier(Token tok) -{ +forceinline +AccessSpec tok_to_access_specifier(Token tok) { return scast(AccessSpec, tok.Type); } -StrC tok_to_str(Token tok) -{ - StrC str = { tok.Length, tok.Text }; - return str; +forceinline +Str tok_to_str(Token tok) { + return tok.Text; } -bool tok_is_valid( Token tok ) -{ - return tok.Text && tok.Length && tok.Type != Tok_Invalid; +forceinline +bool tok_is_valid( Token tok ) { + return tok.Text.Ptr && tok.Text.Len && tok.Type != Tok_Invalid; } -bool tok_is_access_operator(Token tok) -{ +forceinline +bool tok_is_access_operator(Token tok) { return bitfield_is_equal( u32, tok.Flags, TF_AccessOperator ); } -bool tok_is_access_specifier(Token tok) -{ +forceinline +bool tok_is_access_specifier(Token tok) { return bitfield_is_equal( u32, tok.Flags, TF_AccessSpecifier ); } -bool tok_is_attribute(Token tok) -{ +forceinline +bool tok_is_attribute(Token tok) { return bitfield_is_equal( u32, tok.Flags, TF_Attribute ); } -bool tok_is_operator(Token tok) -{ +forceinline +bool tok_is_operator(Token tok) { return bitfield_is_equal( u32, tok.Flags, TF_Operator ); } -bool tok_is_preprocessor(Token tok) -{ +forceinline +bool tok_is_preprocessor(Token tok) { return bitfield_is_equal( u32, tok.Flags, TF_Preprocess ); } -bool tok_is_preprocess_cond(Token tok) -{ +forceinline +bool tok_is_preprocess_cond(Token tok) { return bitfield_is_equal( u32, tok.Flags, TF_Preprocess_Cond ); } -bool tok_is_specifier(Token tok) -{ +forceinline +bool tok_is_specifier(Token tok) { return bitfield_is_equal( u32, tok.Flags, TF_Specifier ); } -bool tok_is_end_definition(Token tok) -{ +forceinline +bool tok_is_end_definition(Token tok) { return bitfield_is_equal( u32, tok.Flags, TF_EndDefinition ); } -String tok_to_string(Token tok) +StrBuilder tok_to_strbuilder(Token tok) { - String result = string_make_reserve( GlobalAllocator, kilobytes(4) ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, kilobytes(4) ); + Str type_str = toktype_to_str( tok.Type ); - StrC type_str = toktype_to_str( tok.Type ); - - string_append_fmt( & result, "Line: %d Column: %d, Type: %.*s Content: %.*s" + strbuilder_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 + , tok.Text.Len, tok.Text.Ptr ); - return result; } -struct TokArray +struct TokArray { Array(Token) Arr; s32 Idx; @@ -122,14 +118,12 @@ Token* lex_current(TokArray* self, bool skip_formatting ) while ( self->Arr[self->Idx].Type == Tok_NewLine || self->Arr[self->Idx].Type == Tok_Comment ) self->Idx++; } - return & self->Arr[self->Idx]; } Token* lex_peek(TokArray self, bool skip_formatting) { s32 idx = self.Idx; - if ( skip_formatting ) { while ( self.Arr[idx].Type == Tok_NewLine ) @@ -137,14 +131,12 @@ Token* lex_peek(TokArray self, bool skip_formatting) return & self.Arr[idx]; } - return & self.Arr[idx]; } Token* lex_previous(TokArray self, bool skip_formatting) { s32 idx = self.Idx; - if ( skip_formatting ) { while ( self.Arr[idx].Type == Tok_NewLine ) @@ -152,14 +144,12 @@ Token* lex_previous(TokArray self, bool skip_formatting) return & self.Arr[idx]; } - return & self.Arr[idx - 1]; } Token* lex_next(TokArray self, bool skip_formatting) { s32 idx = self.Idx; - if ( skip_formatting ) { while ( self.Arr[idx].Type == Tok_NewLine ) @@ -167,7 +157,6 @@ Token* lex_next(TokArray self, bool skip_formatting) return & self.Arr[idx + 1]; } - return & self.Arr[idx + 1]; } @@ -183,7 +172,7 @@ enum struct LexContext { - StrC content; + Str content; s32 left; char const* scanner; s32 line; @@ -234,20 +223,20 @@ forceinline s32 lex_preprocessor_directive( LexContext* ctx ) { char const* hash = ctx->scanner; - Token hash_tok = { hash, 1, Tok_Preprocess_Hash, ctx->line, ctx->column, TF_Preprocess }; + Token hash_tok = { { hash, 1 }, Tok_Preprocess_Hash, ctx->line, ctx->column, TF_Preprocess }; array_append( Lexer_Tokens, hash_tok ); move_forward(); skip_whitespace(); - ctx->token.Text = ctx->scanner; + ctx->token.Text.Ptr = ctx->scanner; while (ctx->left && ! char_is_space((* ctx->scanner)) ) { move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; } - ctx->token.Type = strc_to_toktype( tok_to_str(ctx->token) ); + ctx->token.Type = str_to_toktype( tok_to_str(ctx->token) ); bool is_preprocessor = ctx->token.Type >= Tok_Preprocess_Define && ctx->token.Type <= Tok_Preprocess_Pragma; if ( ! is_preprocessor ) @@ -268,18 +257,18 @@ s32 lex_preprocessor_directive( LexContext* ctx ) if ( * ctx->scanner == '\\' && ! within_string && ! within_char ) { move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; if ( (* ctx->scanner) == '\r' ) { move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; } if ( (* ctx->scanner) == '\n' ) { move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; continue; } else @@ -295,22 +284,22 @@ s32 lex_preprocessor_directive( LexContext* ctx ) if ( (* ctx->scanner) == '\r' ) { move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; } if ( (* ctx->scanner) == '\n' ) { move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; break; } move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; } - ctx->token.Length = ctx->token.Length + ctx->token.Text - hash; - ctx->token.Text = hash; + ctx->token.Text.Len = ctx->token.Text.Len + ctx->token.Text.Ptr - hash; + ctx->token.Text.Ptr = hash; array_append( Lexer_Tokens, ctx->token ); return Lex_Continue; // Skip found token, its all handled here. } @@ -333,31 +322,31 @@ s32 lex_preprocessor_directive( LexContext* ctx ) if ( ctx->token.Type == Tok_Preprocess_Define ) { - Token name = { ctx->scanner, 0, Tok_Identifier, ctx->line, ctx->column, TF_Preprocess }; + Token name = { { ctx->scanner, 0 }, Tok_Identifier, ctx->line, ctx->column, TF_Preprocess }; - name.Text = ctx->scanner; - name.Length = 1; + name.Text.Ptr = ctx->scanner; + name.Text.Len = 1; move_forward(); while ( ctx->left && ( char_is_alphanumeric((* ctx->scanner)) || (* ctx->scanner) == '_' ) ) { move_forward(); - name.Length++; + name.Text.Len++; } if ( ctx->left && (* ctx->scanner) == '(' ) { move_forward(); - name.Length++; + name.Text.Len++; } array_append( Lexer_Tokens, name ); - u64 key = crc32( name.Text, name.Length ); + u64 key = crc32( name.Text.Ptr, name.Text.Len ); hashtable_set(ctx->defines, key, tok_to_str(name) ); } - Token preprocess_content = { ctx->scanner, 0, Tok_Preprocess_Content, ctx->line, ctx->column, TF_Preprocess }; + Token preprocess_content = { { ctx->scanner, 0 }, Tok_Preprocess_Content, ctx->line, ctx->column, TF_Preprocess }; if ( ctx->token.Type == Tok_Preprocess_Include ) { @@ -365,7 +354,7 @@ s32 lex_preprocessor_directive( LexContext* ctx ) if ( (* ctx->scanner) != '"' && (* ctx->scanner) != '<' ) { - String directive_str = string_fmt_buf( GlobalAllocator, "%.*s", min( 80, ctx->left + preprocess_content.Length ), ctx->token.Text ); + StrBuilder directive_str = strbuilder_fmt_buf( GlobalAllocator, "%.*s", min( 80, ctx->left + preprocess_content.Text.Len ), ctx->token.Text.Ptr ); log_failure( "gen::Parser::lex: Expected '\"' or '<' after #include, not '%c' (%d, %d)\n%s" , (* ctx->scanner) @@ -376,16 +365,16 @@ s32 lex_preprocessor_directive( LexContext* ctx ) return Lex_ReturnNull; } move_forward(); - preprocess_content.Length++; + preprocess_content.Text.Len++; while ( ctx->left && (* ctx->scanner) != '"' && (* ctx->scanner) != '>' ) { move_forward(); - preprocess_content.Length++; + preprocess_content.Text.Len++; } move_forward(); - preprocess_content.Length++; + preprocess_content.Text.Len++; if ( (* ctx->scanner) == '\r' && ctx->scanner[1] == '\n' ) { @@ -416,24 +405,24 @@ s32 lex_preprocessor_directive( LexContext* ctx ) if ( (* ctx->scanner) == '\\' && ! within_string && ! within_char ) { move_forward(); - preprocess_content.Length++; + preprocess_content.Text.Len++; if ( (* ctx->scanner) == '\r' ) { move_forward(); - preprocess_content.Length++; + preprocess_content.Text.Len++; } if ( (* ctx->scanner) == '\n' ) { move_forward(); - preprocess_content.Length++; + preprocess_content.Text.Len++; continue; } else { - String directive_str = string_make_length( GlobalAllocator, ctx->token.Text, ctx->token.Length ); - String content_str = string_fmt_buf( GlobalAllocator, "%.*s", min( 400, ctx->left + preprocess_content.Length ), preprocess_content.Text ); + StrBuilder directive_str = strbuilder_make_length( GlobalAllocator, ctx->token.Text.Ptr, ctx->token.Text.Len ); + StrBuilder content_str = strbuilder_fmt_buf( GlobalAllocator, "%.*s", min( 400, ctx->left + preprocess_content.Text.Len ), preprocess_content.Text.Ptr ); log_failure( "gen::Parser::lex: Invalid escape sequence '\\%c' (%d, %d)" " in preprocessor directive '%s' (%d, %d)\n%s" @@ -457,7 +446,7 @@ s32 lex_preprocessor_directive( LexContext* ctx ) } move_forward(); - preprocess_content.Length++; + preprocess_content.Text.Len++; } array_append( Lexer_Tokens, preprocess_content ); @@ -473,7 +462,7 @@ void lex_found_token( LexContext* ctx ) return; } - TokType type = strc_to_toktype( tok_to_str(ctx->token) ); + TokType type = str_to_toktype( tok_to_str(ctx->token) ); if (type <= Tok_Access_Public && type >= Tok_Access_Private ) { @@ -520,11 +509,11 @@ void lex_found_token( LexContext* ctx ) u64 key = 0; if ( (* ctx->scanner) == '(') - key = crc32( ctx->token.Text, ctx->token.Length + 1 ); + key = crc32( ctx->token.Text.Ptr, ctx->token.Text.Len + 1 ); else - key = crc32( ctx->token.Text, ctx->token.Length ); + key = crc32( ctx->token.Text.Ptr, ctx->token.Text.Len ); - StrC* define = hashtable_get(ctx->defines, key ); + Str* define = hashtable_get(ctx->defines, key ); if ( define ) { ctx->token.Type = Tok_Preprocess_Macro; @@ -533,7 +522,7 @@ void lex_found_token( LexContext* ctx ) if ( ctx->left && (* ctx->scanner) == '(' ) { move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; s32 level = 0; while ( ctx->left && ((* ctx->scanner) != ')' || level > 0) ) @@ -545,22 +534,22 @@ void lex_found_token( LexContext* ctx ) level--; move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; } move_forward(); - ctx->token.Length++; + ctx->token.Text.Len++; } //if ( (* ctx->scanner) == '\r' && ctx->scanner[1] == '\n' ) //{ // move_forward(); - // ctx->token.Length++; + // ctx->token..Text.Length++; //} //else if ( (* ctx->scanner) == '\n' ) //{ // move_forward(); - // ctx->token.Length++; + // ctx->token..Text.Length++; //} } else @@ -572,8 +561,8 @@ void lex_found_token( LexContext* ctx ) } neverinline -// TokArray lex( Array tokens, StrC content ) -TokArray lex( StrC content ) +// TokArray lex( Array tokens, Str content ) +TokArray lex( Str content ) { LexContext c; LexContext* ctx = & c; c.content = content; @@ -620,12 +609,12 @@ TokArray lex( StrC content ) #if 0 if (Tokens.num()) { - log_fmt("\nLastTok: %S", Tokens.back().to_string()); + log_fmt("\nLastTok: %SB", Tokens.back().to_strbuilder()); } #endif { - Token thanks_c = { c.scanner, 0, Tok_Invalid, c.line, c.column, TF_Null }; + Token thanks_c = { { c.scanner, 0 }, Tok_Invalid, c.line, c.column, TF_Null }; c.token = thanks_c; } @@ -636,7 +625,7 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == '\r') { move_forward(); - c.token.Length = 1; + c.token.Text.Len = 1; } if ( (* ctx->scanner) == '\n' ) @@ -644,14 +633,14 @@ TokArray lex( StrC content ) move_forward(); c.token.Type = Tok_NewLine; - c.token.Length++; + c.token.Text.Len++; array_append( Lexer_Tokens, c.token ); continue; } } - c.token.Length = 0; + c.token.Text.Len = 0; skip_whitespace(); if ( c.left <= 0 ) @@ -670,19 +659,19 @@ TokArray lex( StrC content ) //if ( last_type == Tok_Preprocess_Pragma ) { { - Token thanks_c = { c.scanner, 0, Tok_Invalid, c.line, c.column, TF_Null }; + Token thanks_c = { { c.scanner, 0 }, Tok_Invalid, c.line, c.column, TF_Null }; c.token = thanks_c; } if ( (* ctx->scanner) == '\r') { move_forward(); - c.token.Length = 1; + c.token.Text.Len = 1; } if ( (* ctx->scanner) == '\n' ) { c.token.Type = Tok_NewLine; - c.token.Length++; + c.token.Text.Len++; move_forward(); array_append( Lexer_Tokens, c.token ); @@ -700,8 +689,8 @@ TokArray lex( StrC content ) } case '.': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Access_MemberSymbol; c.token.Flags = TF_AccessOperator; @@ -714,14 +703,14 @@ TokArray lex( StrC content ) move_forward(); if( (* ctx->scanner) == '.' ) { - c.token.Length = 3; - c.token.Type = Tok_Varadic_Argument; - c.token.Flags = TF_Null; + c.token.Text.Len = 3; + c.token.Type = Tok_Varadic_Argument; + c.token.Flags = TF_Null; move_forward(); } else { - String context_str = string_fmt_buf( GlobalAllocator, "%s", c.scanner, min( 100, c.left ) ); + StrBuilder context_str = strbuilder_fmt_buf( GlobalAllocator, "%s", c.scanner, min( 100, c.left ) ); log_failure( "gen::lex: invalid varadic argument, expected '...' got '..%c' (%d, %d)\n%s", (* ctx->scanner), c.line, c.column, context_str ); } @@ -731,8 +720,8 @@ TokArray lex( StrC content ) } case '&' : { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Ampersand; c.token.Flags |= TF_Operator; c.token.Flags |= TF_Specifier; @@ -742,8 +731,8 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == '&' ) // && { - c.token.Length = 2; - c.token.Type = Tok_Ampersand_DBL; + c.token.Text.Len = 2; + c.token.Type = Tok_Ampersand_DBL; if (c.left) move_forward(); @@ -753,9 +742,9 @@ TokArray lex( StrC content ) } case ':': { - c.token.Text = c.scanner; - c.token.Length = 1; - c.token.Type = Tok_Assign_Classifer; + Str text = { c.scanner, 1 }; + c.token.Text = text; + c.token.Type = Tok_Assign_Classifer; // Can be either a classifier (ParentType, Bitfield width), or ternary else // token.Type = Tok_Colon; @@ -765,15 +754,15 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == ':' ) { move_forward(); - c.token.Type = Tok_Access_StaticSymbol; - c.token.Length++; + c.token.Type = Tok_Access_StaticSymbol; + c.token.Text.Len++; } goto FoundToken; } case '{': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_BraceCurly_Open; if (c.left) @@ -782,8 +771,8 @@ TokArray lex( StrC content ) } case '}': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_BraceCurly_Close; c.token.Flags = TF_EndDefinition; @@ -795,8 +784,8 @@ TokArray lex( StrC content ) } case '[': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_BraceSquare_Open; if ( c.left ) { @@ -804,8 +793,8 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == ']' ) { - c.token.Length = 2; - c.token.Type = Tok_Operator; + c.token.Text.Len = 2; + c.token.Type = Tok_Operator; move_forward(); } } @@ -813,8 +802,8 @@ TokArray lex( StrC content ) } case ']': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_BraceSquare_Close; if (c.left) @@ -823,8 +812,8 @@ TokArray lex( StrC content ) } case '(': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Capture_Start; if (c.left) @@ -833,8 +822,8 @@ TokArray lex( StrC content ) } case ')': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Capture_End; if (c.left) @@ -843,8 +832,8 @@ TokArray lex( StrC content ) } case '\'': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Char; c.token.Flags = TF_Literal; @@ -853,32 +842,32 @@ TokArray lex( StrC content ) if ( c.left && (* ctx->scanner) == '\\' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; if ( (* ctx->scanner) == '\'' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } } while ( c.left && (* ctx->scanner) != '\'' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } if ( c.left ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } goto FoundToken; } case ',': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Comma; c.token.Flags = TF_Operator; @@ -888,8 +877,8 @@ TokArray lex( StrC content ) } case '*': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Star; c.token.Flags |= TF_Specifier; c.token.Flags |= TF_Operator; @@ -899,7 +888,7 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == '=' ) { - c.token.Length++; + c.token.Text.Len++; c.token.Flags |= TF_Assign; // c.token.Type = Tok_Assign_Multiply; @@ -911,8 +900,8 @@ TokArray lex( StrC content ) } case ';': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Statement_End; c.token.Flags = TF_EndDefinition; @@ -924,8 +913,8 @@ TokArray lex( StrC content ) } case '"': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_String; c.token.Flags |= TF_Literal; @@ -941,25 +930,25 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == '\\' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; if ( c.left ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } continue; } move_forward(); - c.token.Length++; + c.token.Text.Len++; } goto FoundToken; } case '?': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Operator; // c.token.Type = Tok_Ternary; c.token.Flags = TF_Operator; @@ -971,8 +960,8 @@ TokArray lex( StrC content ) } case '=': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Operator; // c.token.Type = Tok_Assign; c.token.Flags = TF_Operator; @@ -983,7 +972,7 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == '=' ) { - c.token.Length++; + c.token.Text.Len++; c.token.Flags = TF_Operator; if (c.left) @@ -1027,8 +1016,8 @@ TokArray lex( StrC content ) } case '|': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Operator; c.token.Flags = TF_Operator; // token.Type = Tok_L_Or; @@ -1038,7 +1027,7 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == '=' ) { - c.token.Length++; + c.token.Text.Len++; c.token.Flags |= TF_Assign; // token.Flags |= TokFlags::Assignment; // token.Type = Tok_Assign_L_Or; @@ -1046,9 +1035,9 @@ TokArray lex( StrC content ) if (c.left) move_forward(); } - else while ( c.left && (* ctx->scanner) == *(c.scanner - 1) && c.token.Length < 3 ) + else while ( c.left && (* ctx->scanner) == *(c.scanner - 1) && c.token.Text.Len < 3 ) { - c.token.Length++; + c.token.Text.Len++; if (c.left) move_forward(); @@ -1059,8 +1048,8 @@ TokArray lex( StrC content ) // Dash is unfortunatlly a bit more complicated... case '-': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Operator; // token.Type = Tok_Subtract; c.token.Flags = TF_Operator; @@ -1070,7 +1059,7 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == '>' ) { - c.token.Length++; + c.token.Text.Len++; // token.Type = Tok_Access_PointerToMemberSymbol; c.token.Flags |= TF_AccessOperator; move_forward(); @@ -1078,22 +1067,22 @@ TokArray lex( StrC content ) if ( (* ctx->scanner) == '*' ) { // token.Type = Tok_Access_PointerToMemberOfPointerSymbol; - c.token.Length++; + c.token.Text.Len++; move_forward(); } } else if ( (* ctx->scanner) == '=' ) { - c.token.Length++; + c.token.Text.Len++; // token.Type = Tok_Assign_Subtract; c.token.Flags |= TF_Assign; if (c.left) move_forward(); } - else while ( c.left && (* ctx->scanner) == *(c.scanner - 1) && c.token.Length < 3 ) + else while ( c.left && (* ctx->scanner) == *(c.scanner - 1) && c.token.Text.Len < 3 ) { - c.token.Length++; + c.token.Text.Len++; if (c.left) move_forward(); @@ -1103,8 +1092,8 @@ TokArray lex( StrC content ) } case '/': { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Operator; // token.Type = Tok_Divide; c.token.Flags = TF_Operator; @@ -1116,40 +1105,40 @@ TokArray lex( StrC content ) { // token.Type = TokeType::Assign_Divide; move_forward(); - c.token.Length++; + c.token.Text.Len++; c.token.Flags = TF_Assign; } else if ( (* ctx->scanner) == '/' ) { - c.token.Type = Tok_Comment; - c.token.Length = 2; - c.token.Flags = TF_Null; + c.token.Type = Tok_Comment; + c.token.Text.Len = 2; + c.token.Flags = TF_Null; move_forward(); while ( c.left && (* ctx->scanner) != '\n' && (* ctx->scanner) != '\r' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } if ( (* ctx->scanner) == '\r' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } if ( (* ctx->scanner) == '\n' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } array_append( Lexer_Tokens, c.token ); continue; } else if ( (* ctx->scanner) == '*' ) { - c.token.Type = Tok_Comment; - c.token.Length = 2; - c.token.Flags = TF_Null; + c.token.Type = Tok_Comment; + c.token.Text.Len = 2; + c.token.Flags = TF_Null; move_forward(); bool star = (* ctx->scanner) == '*'; @@ -1158,25 +1147,25 @@ TokArray lex( StrC content ) while ( c.left && ! at_end ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; star = (* ctx->scanner) == '*'; slash = c.scanner[1] == '/'; at_end = star && slash; } - c.token.Length += 2; + c.token.Text.Len += 2; move_forward(); move_forward(); if ( (* ctx->scanner) == '\r' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } if ( (* ctx->scanner) == '\n' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } array_append( Lexer_Tokens, c.token ); // end_line(); @@ -1189,14 +1178,14 @@ TokArray lex( StrC content ) if ( char_is_alpha( (* ctx->scanner) ) || (* ctx->scanner) == '_' ) { - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; move_forward(); while ( c.left && ( char_is_alphanumeric((* ctx->scanner)) || (* ctx->scanner) == '_' ) ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } goto FoundToken; @@ -1205,8 +1194,8 @@ TokArray lex( StrC content ) { // This is a very brute force lex, no checks are done for validity of literal. - c.token.Text = c.scanner; - c.token.Length = 1; + Str text = { c.scanner, 1 }; + c.token.Text = text; c.token.Type = Tok_Number; c.token.Flags = TF_Literal; move_forward(); @@ -1218,12 +1207,12 @@ TokArray lex( StrC content ) ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; while ( c.left && char_is_hex_digit((* ctx->scanner)) ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } goto FoundToken; @@ -1232,18 +1221,18 @@ TokArray lex( StrC content ) while ( c.left && char_is_digit((* ctx->scanner)) ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } if ( c.left && (* ctx->scanner) == '.' ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; while ( c.left && char_is_digit((* ctx->scanner)) ) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } // Handle number literal suffixes in a botched way @@ -1256,13 +1245,13 @@ TokArray lex( StrC content ) { char prev = (* ctx->scanner); move_forward(); - c.token.Length++; + c.token.Text.Len++; // Handle 'll'/'LL' as a special case when we just processed an 'l'/'L' if (c.left && (prev == 'l' || prev == 'L') && ((* ctx->scanner) == 'l' || (* ctx->scanner) == 'L')) { move_forward(); - c.token.Length++; + c.token.Text.Len++; } } } @@ -1278,11 +1267,11 @@ TokArray lex( StrC content ) log_fmt( "Token %d Type: %s : %.*s\n" , idx , toktype_to_str( Lexer_Tokens[ idx ].Type ).Ptr - , Lexer_Tokens[ idx ].Length, Lexer_Tokens[ idx ].Text + , Lexer_Tokens[ idx ].Text.Len, Lexer_Tokens[ idx ].Text.Ptr ); } - String context_str = string_fmt_buf( GlobalAllocator, "%.*s", min( 100, c.left ), c.scanner ); + StrBuilder context_str = strbuilder_fmt_buf( GlobalAllocator, "%.*s", min( 100, c.left ), c.scanner ); log_failure( "Failed to lex token '%c' (%d, %d)\n%s", (* ctx->scanner), c.line, c.column, context_str ); // Skip to next whitespace since we can't know if anything else is valid until then. @@ -1298,18 +1287,18 @@ TokArray lex( StrC content ) TokType last_type = array_back(Lexer_Tokens)->Type; if ( last_type == Tok_Preprocess_Macro ) { - Token thanks_c = { c.scanner, 0, Tok_Invalid, c.line, c.column, TF_Null }; + Token thanks_c = { { c.scanner, 0 }, Tok_Invalid, c.line, c.column, TF_Null }; c.token = thanks_c; if ( (* ctx->scanner) == '\r') { move_forward(); - c.token.Length = 1; + c.token.Text.Len = 1; } if ( (* ctx->scanner) == '\n' ) { c.token.Type = Tok_NewLine; - c.token.Length++; + c.token.Text.Len++; move_forward(); array_append( Lexer_Tokens, c.token ); diff --git a/base/components/parser.cpp b/base/components/parser.cpp index c746c6c..aad9116 100644 --- a/base/components/parser.cpp +++ b/base/components/parser.cpp @@ -18,7 +18,7 @@ struct StackNode Token Start; Token Name; // The name of the AST node (if parsed) - StrC ProcName; // The name of the procedure + Str ProcName; // The name of the procedure }; struct ParseContext @@ -45,36 +45,36 @@ void parser_pop(ParseContext* ctx) ctx->Scope = ctx->Scope->Prev; } -String parser_to_string(ParseContext ctx) +StrBuilder parser_to_strbuilder(ParseContext ctx) { - String result = string_make_reserve( GlobalAllocator, kilobytes(4) ); + StrBuilder result = strbuilder_make_reserve( GlobalAllocator, kilobytes(4) ); Token scope_start = ctx.Scope->Start; Token last_valid = ctx.Tokens.Idx >= array_num(ctx.Tokens.Arr) ? ctx.Tokens.Arr[array_num(ctx.Tokens.Arr) -1] : (* lex_current(& ctx.Tokens, true)); - sptr length = scope_start.Length; - char const* current = scope_start.Text + length; - while ( current <= array_back( ctx.Tokens.Arr)->Text && *current != '\n' && length < 74 ) + sptr length = scope_start.Text.Len; + char const* current = scope_start.Text.Ptr + length; + while ( current <= array_back( ctx.Tokens.Arr)->Text.Ptr && (* current) != '\n' && length < 74 ) { current++; length++; } - StrC scope_strc = { length, scope_start.Text }; - String line = string_make_strc( GlobalAllocator, scope_strc ); - string_append_fmt( & result, "\tScope : %s\n", line ); - string_free(& line); + Str scope_str = { scope_start.Text.Ptr, length }; + StrBuilder line = strbuilder_make_str( GlobalAllocator, scope_str ); + strbuilder_append_fmt( & result, "\tScope : %s\n", line ); + strbuilder_free(& line); - sptr dist = (sptr)last_valid.Text - (sptr)scope_start.Text + 2; + sptr dist = (sptr)last_valid.Text.Ptr - (sptr)scope_start.Text.Ptr + 2; sptr length_from_err = dist; - StrC err_strc = { length_from_err, last_valid.Text }; - String line_from_err = string_make_strc( GlobalAllocator, err_strc ); + Str err_str = { last_valid.Text.Ptr, length_from_err }; + StrBuilder line_from_err = strbuilder_make_str( GlobalAllocator, err_str ); if ( length_from_err < 100 ) - string_append_fmt(& result, "\t(%d, %d):%*c\n", last_valid.Line, last_valid.Column, length_from_err, '^' ); + strbuilder_append_fmt(& result, "\t(%d, %d):%*c\n", last_valid.Line, last_valid.Column, length_from_err, '^' ); else - string_append_fmt(& result, "\t(%d, %d)\n", last_valid.Line, last_valid.Column ); + strbuilder_append_fmt(& result, "\t(%d, %d)\n", last_valid.Line, last_valid.Column ); StackNode* curr_scope = ctx.Scope; s32 level = 0; @@ -82,11 +82,11 @@ String parser_to_string(ParseContext ctx) { if ( tok_is_valid(curr_scope->Name) ) { - string_append_fmt(& result, "\t%d: %s, AST Name: %.*s\n", level, curr_scope->ProcName.Ptr, curr_scope->Name.Length, curr_scope->Name.Text ); + strbuilder_append_fmt(& result, "\t%d: %s, AST Name: %.*s\n", level, curr_scope->ProcName.Ptr, curr_scope->Name.Text.Len, curr_scope->Name.Text.Ptr ); } else { - string_append_fmt(& result, "\t%d: %s\n", level, curr_scope->ProcName.Ptr ); + strbuilder_append_fmt(& result, "\t%d: %s\n", level, curr_scope->ProcName.Ptr ); } curr_scope = curr_scope->Prev; @@ -102,7 +102,7 @@ bool lex__eat(TokArray* self, TokType type ) { if ( array_num(self->Arr) - self->Idx <= 0 ) { - log_failure( "No tokens left.\n%s", parser_to_string(Context) ); + log_failure( "No tokens left.\n%s", parser_to_strbuilder(Context) ); return false; } @@ -119,17 +119,17 @@ bool lex__eat(TokArray* self, TokType type ) Token tok = * lex_current( self, lex_skip_formatting ); log_failure( "Parse Error, TokArray::eat, Expected: ' %s ' not ' %.*s ' (%d, %d)`\n%s" , toktype_to_str(type).Ptr - , at_idx.Length, at_idx.Text + , at_idx.Text.Len, at_idx.Text.Ptr , tok.Line , tok.Column - , parser_to_string(Context) + , parser_to_strbuilder(Context) ); - + GEN_DEBUG_TRAP(); return false; } #if 0 && GEN_BUILD_DEBUG - log_fmt("Ate: %S\n", self->Arr[Idx].to_string() ); + log_fmt("Ate: %SB\n", self->Arr[Idx].to_strbuilder() ); #endif self->Idx ++; @@ -144,7 +144,7 @@ void parser_init() ); fixed_arena_init(& Lexer_defines_map_arena); - Lexer_defines = hashtable_init_reserve(StrC, fixed_arena_allocator_info( & Lexer_defines_map_arena), 256 ); + Lexer_defines = hashtable_init_reserve(Str, fixed_arena_allocator_info( & Lexer_defines_map_arena), 256 ); } internal @@ -157,17 +157,17 @@ void parser_deinit() #pragma region Helper Macros #define check_parse_args( def ) _check_parse_args(def, stringize(_func_) ) -bool _check_parse_args( StrC def, char const* func_name ) +bool _check_parse_args( Str def, char const* func_name ) { if ( def.Len <= 0 ) { - log_failure( str_fmt_buf("gen::%s: length must greater than 0", func_name) ); + log_failure( c_str_fmt_buf("gen::%s: length must greater than 0", func_name) ); parser_pop(& Context); return false; } if ( def.Ptr == nullptr ) { - log_failure( str_fmt_buf("gen::%s: def was null", func_name) ); + log_failure( c_str_fmt_buf("gen::%s: def was null", func_name) ); parser_pop(& Context); return false; } @@ -230,7 +230,7 @@ internal CodePreprocessCond parse_preprocess_cond (); internal Code parse_simple_preprocess ( TokType which, bool dont_consume_braces ); internal Code parse_static_assert (); internal void parse_template_args ( Token* token ); -internal CodeVar parse_variable_after_name ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename type, StrC name ); +internal CodeVar parse_variable_after_name ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename type, Str name ); internal CodeVar parse_variable_declaration_list (); internal CodeClass parser_parse_class ( bool inplace_def ); @@ -268,9 +268,9 @@ constexpr bool parser_strip_formatting_dont_preserve_newlines = false; It has edge case failures that prevent it from being used in function bodies. */ internal -String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) +StrBuilder parser_strip_formatting( Str raw_text, bool preserve_newlines ) { - String content = string_make_reserve( GlobalAllocator, raw_text.Len ); + StrBuilder content = strbuilder_make_reserve( GlobalAllocator, raw_text.Len ); if ( raw_text.Len == 0 ) return content; @@ -317,7 +317,7 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) if ( tokleft ) move_fwd(); - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); last_cut = rcast(sptr, scanner ) - rcast( sptr, raw_text.Ptr ); continue; } @@ -339,7 +339,7 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) if ( tokleft ) move_fwd(); - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); last_cut = rcast( sptr, scanner ) - rcast( sptr, raw_text.Ptr ); continue; } @@ -353,7 +353,7 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) scanner += 2; tokleft -= 2; - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); last_cut = rcast( sptr, scanner ) - rcast( sptr, raw_text.Ptr ); continue; } @@ -372,7 +372,7 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) if (tokleft) move_fwd(); - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); last_cut = rcast( sptr, scanner ) - rcast( sptr, raw_text.Ptr ); continue; } @@ -381,10 +381,10 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) if (scanner[0] == '\t') { if (pos > last_cut) - string_append_c_str_len( & content, cut_ptr, cut_length); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length); - if ( * string_back( content ) != ' ' ) - string_append_char( & content, ' ' ); + if ( * strbuilder_back( content ) != ' ' ) + strbuilder_append_char( & content, ' ' ); move_fwd(); last_cut = rcast( sptr, scanner) - rcast( sptr, raw_text.Ptr); @@ -400,17 +400,17 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) scanner += 2; tokleft -= 2; - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); last_cut = rcast( sptr, scanner ) - rcast( sptr, raw_text.Ptr ); continue; } if ( pos > last_cut ) - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); // Replace with a space - if ( * string_back( content ) != ' ' ) - string_append_char( & content, ' ' ); + if ( * strbuilder_back( content ) != ' ' ) + strbuilder_append_char( & content, ' ' ); scanner += 2; tokleft -= 2; @@ -427,17 +427,17 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) move_fwd(); - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); last_cut = rcast( sptr, scanner ) - rcast( sptr, raw_text.Ptr ); continue; } if ( pos > last_cut ) - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); // Replace with a space - if ( * string_back( content ) != ' ' ) - string_append_char( & content, ' ' ); + if ( * strbuilder_back( content ) != ' ' ) + strbuilder_append_char( & content, ' ' ); move_fwd(); @@ -448,7 +448,7 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) // Escaped newlines if ( scanner[0] == '\\' ) { - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); s32 amount_to_skip = 1; if ( tokleft > 1 && scanner[1] == '\n' ) @@ -475,7 +475,7 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) // Consectuive spaces if ( tokleft > 1 && char_is_space( scanner[0] ) && char_is_space( scanner[ 1 ] ) ) { - string_append_c_str_len( & content, cut_ptr, cut_length ); + strbuilder_append_c_str_len( & content, cut_ptr, cut_length ); do { move_fwd(); @@ -485,9 +485,9 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) last_cut = rcast( sptr, scanner ) - rcast( sptr, raw_text.Ptr ); // Preserve only 1 space of formattting - char* last = string_back(content); + char* last = strbuilder_back(content); if ( last == nullptr || * last != ' ' ) - string_append_char( & content, ' ' ); + strbuilder_append_char( & content, ' ' ); continue; } @@ -497,7 +497,7 @@ String parser_strip_formatting( StrC raw_text, bool preserve_newlines ) if ( last_cut < raw_text.Len ) { - string_append_c_str_len( & content, cut_ptr, raw_text.Len - last_cut ); + strbuilder_append_c_str_len( & content, cut_ptr, raw_text.Len - last_cut ); } #undef cut_ptr @@ -513,9 +513,9 @@ Code parse_array_decl() { push_scope(); - if ( check( Tok_Operator ) && currtok.Text[0] == '[' && currtok.Text[1] == ']' ) + if ( check( Tok_Operator ) && currtok.Text.Ptr[0] == '[' && currtok.Text.Ptr[1] == ']' ) { - Code array_expr = untyped_str( tok_to_str(currtok) ); + Code array_expr = untyped_str( txt(" ") ); eat( Tok_Operator ); // [] @@ -530,14 +530,14 @@ Code parse_array_decl() if ( left == 0 ) { - log_failure( "Error, unexpected end of array declaration ( '[]' scope started )\n%s", parser_to_string(Context) ); + log_failure( "Error, unexpected end of array declaration ( '[]' scope started )\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } if ( currtok.Type == Tok_BraceSquare_Close ) { - log_failure( "Error, empty array expression in definition\n%s", parser_to_string(Context) ); + log_failure( "Error, empty array expression in definition\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -549,21 +549,21 @@ Code parse_array_decl() eat( currtok.Type ); } - untyped_tok.Length = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)untyped_tok.Text; + untyped_tok.Text.Len = ( (sptr)prevtok.Text.Ptr + prevtok.Text.Len ) - (sptr)untyped_tok.Text.Ptr; Code array_expr = untyped_str( tok_to_str(untyped_tok) ); // [ if ( left == 0 ) { - log_failure( "Error, unexpected end of array declaration, expected ]\n%s", parser_to_string(Context) ); + log_failure( "Error, unexpected end of array declaration, expected ]\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } if ( currtok.Type != Tok_BraceSquare_Close ) { - log_failure( "%s: Error, expected ] in array declaration, not %s\n%s", toktype_to_str( currtok.Type ), parser_to_string(Context) ); + log_failure( "%s: Error, expected ] in array declaration, not %s\n%s", toktype_to_str( currtok.Type ), parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -614,7 +614,7 @@ CodeAttributes parse_attributes() eat( Tok_Attribute_Close ); // [[ ]] - len = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )start.Text; + len = ( ( sptr )prevtok.Text.Ptr + prevtok.Text.Len ) - ( sptr )start.Text.Ptr; } else if ( check( Tok_Decl_GNU_Attribute ) ) { @@ -633,7 +633,7 @@ CodeAttributes parse_attributes() eat( Tok_Capture_End ); // __attribute__(( )) - len = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )start.Text; + len = ( ( sptr )prevtok.Text.Ptr + prevtok.Text.Len ) - ( sptr )start.Text.Ptr; } else if ( check( Tok_Decl_MSVC_Attribute ) ) { @@ -650,7 +650,7 @@ CodeAttributes parse_attributes() eat( Tok_Capture_End ); // __declspec( ) - len = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )start.Text; + len = ( ( sptr )prevtok.Text.Ptr + prevtok.Text.Len ) - ( sptr )start.Text.Ptr; } else if ( tok_is_attribute(currtok) ) { @@ -674,21 +674,21 @@ CodeAttributes parse_attributes() eat(Tok_Capture_End); } - len = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )start.Text; + len = ( ( sptr )prevtok.Text.Ptr + prevtok.Text.Len ) - ( sptr )start.Text.Ptr; // ( ... ) } } if ( len > 0 ) { - StrC attribute_txt = { len, start.Text }; + Str attribute_txt = { start.Text.Ptr, len }; parser_pop(& Context); - String name_stripped = parser_strip_formatting( attribute_txt, parser_strip_formatting_dont_preserve_newlines ); + StrBuilder name_stripped = parser_strip_formatting( attribute_txt, parser_strip_formatting_dont_preserve_newlines ); Code result = make_code(); result->Type = CT_PlatformAttributes; - result->Name = get_cached_string( string_to_strc(name_stripped) ); + result->Name = get_cached_string( strbuilder_to_str(name_stripped) ); result->Content = result->Name; // result->Token = @@ -704,7 +704,7 @@ Code parse_class_struct( TokType which, bool inplace_def ) { if ( which != Tok_Decl_Class && which != Tok_Decl_Struct ) { - log_failure( "Error, expected class or struct, not %s\n%s", toktype_to_str( which ), parser_to_string(Context) ); + log_failure( "Error, expected class or struct, not %s\n%s", toktype_to_str( which ), parser_to_strbuilder(Context) ); return InvalidCode; } @@ -846,7 +846,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) case Tok_Statement_End: { // TODO(Ed): Convert this to a general warning procedure - log_fmt("Dangling end statement found %S\n", tok_to_string(currtok_noskip)); + log_fmt("Dangling end statement found %SB\n", tok_to_strbuilder(currtok_noskip)); eat( Tok_Statement_End ); continue; } @@ -928,7 +928,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) case Tok_Operator: //if ( currtok.Text[0] != '~' ) //{ - // log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_string(Context) ); + // log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_strbuilder(Context) ); // return InvalidCode; //} @@ -1015,7 +1015,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) while ( left && tok_is_specifier(currtok) ) { - Specifier spec = strc_to_specifier( tok_to_str(currtok) ); + Specifier spec = str_to_specifier( tok_to_str(currtok) ); b32 ignore_spec = false; @@ -1042,7 +1042,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) break; default: - log_failure( "Invalid specifier %s for variable\n%s", spec_to_str(spec), parser_to_string(Context) ); + log_failure( "Invalid specifier %S for variable\n%S", spec_to_str(spec), strbuilder_to_str( parser_to_strbuilder(Context)) ); parser_pop(& Context); return InvalidCode; } @@ -1069,10 +1069,10 @@ CodeBody parse_class_struct_body( TokType which, Token name ) if ( attributes ) { - String fused = string_make_reserve( GlobalAllocator, attributes->Content.Len + more_attributes->Content.Len ); - string_append_fmt( & fused, "%S %S", attributes->Content, more_attributes->Content ); + StrBuilder fused = strbuilder_make_reserve( GlobalAllocator, attributes->Content.Len + more_attributes->Content.Len ); + strbuilder_append_fmt( & fused, "%SB %SB", attributes->Content, more_attributes->Content ); - StrC attrib_name = { string_length(fused), fused }; + Str attrib_name = strbuilder_to_str(fused); attributes->Name = get_cached_string( attrib_name ); attributes->Content = attributes->Name; // @@ -1081,7 +1081,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) attributes = more_attributes; } - if ( currtok.Type == Tok_Operator && currtok.Text[0] == '~' ) + if ( currtok.Type == Tok_Operator && currtok.Text.Ptr[0] == '~' ) { member = cast(Code, parser_parse_destructor( specifiers )); // ~() @@ -1107,9 +1107,9 @@ CodeBody parse_class_struct_body( TokType which, Token name ) case Tok_Type_int: case Tok_Type_double: { - if ( nexttok.Type == Tok_Capture_Start && name.Length && currtok.Type == Tok_Identifier ) + if ( nexttok.Type == Tok_Capture_Start && name.Text.Len && currtok.Type == Tok_Identifier ) { - if ( str_compare_len( name.Text, currtok.Text, name.Length ) == 0 ) + if ( c_str_compare_len( name.Text.Ptr, currtok.Text.Ptr, name.Text.Len ) == 0 ) { member = cast(Code, parser_parse_constructor( specifiers )); // () @@ -1128,7 +1128,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) if ( member == Code_Invalid ) { - log_failure( "Failed to parse member\n%s", parser_to_string(Context) ); + log_failure( "Failed to parse member\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1151,7 +1151,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) while ( left && currtok.Type != Tok_BraceCurly_Close ) { - untyped_tok.Length = ( (sptr)currtok.Text + currtok.Length ) - (sptr)untyped_tok.Text; + untyped_tok.Text.Len = ( (sptr)currtok.Text.Ptr + currtok.Text.Len ) - (sptr)untyped_tok.Text.Ptr; eat( currtok.Type ); } @@ -1162,7 +1162,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) if ( member == Code_Invalid ) { - log_failure( "Failed to parse member\n%s", parser_to_string(Context) ); + log_failure( "Failed to parse member\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1226,13 +1226,13 @@ Code parse_complicated_definition( TokType which ) } Token tok = tokens.Arr[ idx - 1 ]; - if ( tok_is_specifier(tok) && spec_is_trailing( strc_to_specifier( tok_to_str(tok))) ) + if ( tok_is_specifier(tok) && spec_is_trailing( str_to_specifier( tok_to_str(tok))) ) { // (...) ...; s32 spec_idx = idx - 1; Token spec = tokens.Arr[spec_idx]; - while ( tok_is_specifier(spec) && spec_is_trailing( strc_to_specifier( tok_to_str(spec))) ) + while ( tok_is_specifier(spec) && spec_is_trailing( str_to_specifier( tok_to_str(spec))) ) { -- spec_idx; spec = tokens.Arr[spec_idx]; @@ -1249,7 +1249,7 @@ Code parse_complicated_definition( TokType which ) return result; } - log_failure( "Unsupported or bad member definition after %s declaration\n%s", toktype_to_str(which), parser_to_string(Context) ); + log_failure( "Unsupported or bad member definition after %s declaration\n%s", toktype_to_str(which), parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1294,7 +1294,7 @@ Code parse_complicated_definition( TokType which ) if ( ! ok_to_parse ) { - log_failure( "Unsupported or bad member definition after %s declaration\n%s", toktype_to_str(which), parser_to_string(Context) ); + log_failure( "Unsupported or bad member definition after %s declaration\n%s", toktype_to_str(which), parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1313,7 +1313,7 @@ Code parse_complicated_definition( TokType which ) && ( tokens.Arr[idx - 4].Type != which)) ) { - log_failure( "Unsupported or bad member definition after %s declaration\n%s", toktype_to_str(which), parser_to_string(Context) ); + log_failure( "Unsupported or bad member definition after %s declaration\n%s", toktype_to_str(which), parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1343,7 +1343,7 @@ Code parse_complicated_definition( TokType which ) } else { - log_failure( "Unsupported or bad member definition after %s declaration\n%S", toktype_to_str(which).Ptr, parser_to_string(Context) ); + log_failure( "Unsupported or bad member definition after %s declaration\n%SB", toktype_to_str(which).Ptr, parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1362,7 +1362,7 @@ CodeDefine parse_define() if ( ! check( Tok_Identifier ) ) { - log_failure( "Error, expected identifier after #define\n%s", parser_to_string(Context) ); + log_failure( "Error, expected identifier after #define\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1374,12 +1374,12 @@ CodeDefine parse_define() if ( ! check( Tok_Preprocess_Content )) { - log_failure( "Error, expected content after #define %s\n%s", define->Name, parser_to_string(Context) ); + log_failure( "Error, expected content after #define %s\n%s", define->Name, parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } - if ( currtok.Length == 0 ) + if ( currtok.Text.Len == 0 ) { define->Content = get_cached_string( tok_to_str(currtok) ); eat( Tok_Preprocess_Content ); @@ -1389,7 +1389,7 @@ CodeDefine parse_define() return define; } - define->Content = get_cached_string( string_to_strc( parser_strip_formatting( tok_to_str(currtok), parser_strip_formatting_dont_preserve_newlines )) ); + define->Content = get_cached_string( strbuilder_to_str( parser_strip_formatting( tok_to_str(currtok), parser_strip_formatting_dont_preserve_newlines )) ); eat( Tok_Preprocess_Content ); // #define @@ -1409,7 +1409,7 @@ Code parse_assignment_expression() if ( currtok.Type == Tok_Statement_End && currtok.Type != Tok_Comma ) { - log_failure( "Expected expression after assignment operator\n%s", parser_to_string(Context) ); + log_failure( "Expected expression after assignment operator\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1429,8 +1429,8 @@ Code parse_assignment_expression() eat( currtok.Type ); } - expr_tok.Length = ( ( sptr )currtok.Text + currtok.Length ) - ( sptr )expr_tok.Text - 1; - expr = untyped_str( tok_to_str(expr_tok) ); + expr_tok.Text.Len = ( ( sptr )currtok.Text.Ptr + currtok.Text.Len ) - ( sptr )expr_tok.Text.Ptr - 1; + expr = untyped_str( tok_to_str(expr_tok) ); // = return expr; } @@ -1461,7 +1461,7 @@ Code parse_forward_or_definition( TokType which, bool is_inplace ) default: log_failure( "Error, wrong token type given to parse_complicated_definition " "(only supports class, enum, struct, union) \n%s" - , parser_to_string(Context) ); + , parser_to_strbuilder(Context) ); return InvalidCode; } @@ -1486,12 +1486,12 @@ CodeFn parse_function_after_name( { if ( specifiers == nullptr ) { - specifiers = def_specifier( strc_to_specifier( tok_to_str(currtok)) ); + specifiers = def_specifier( str_to_specifier( tok_to_str(currtok)) ); eat( currtok.Type ); continue; } - specifiers_append(specifiers, strc_to_specifier( tok_to_str(currtok)) ); + specifiers_append(specifiers, str_to_specifier( tok_to_str(currtok)) ); eat( currtok.Type ); } // ( ) @@ -1508,7 +1508,7 @@ CodeFn parse_function_after_name( } // ( ) { } } - else if ( check(Tok_Operator) && currtok.Text[0] == '=' ) + else if ( check(Tok_Operator) && currtok.Text.Ptr[0] == '=' ) { eat(Tok_Operator); specifiers_append(specifiers, Spec_Pure ); @@ -1533,13 +1533,13 @@ CodeFn parse_function_after_name( // ( ) ; } - String - name_stripped = string_make_strc( GlobalAllocator, tok_to_str(name) ); + StrBuilder + name_stripped = strbuilder_make_str( GlobalAllocator, tok_to_str(name) ); strip_space(name_stripped); CodeFn result = (CodeFn) make_code(); - result->Name = get_cached_string( string_to_strc(name_stripped) ); + result->Name = get_cached_string( strbuilder_to_str(name_stripped) ); result->ModuleFlags = mflags; if ( body ) @@ -1552,7 +1552,7 @@ CodeFn parse_function_after_name( default: { - log_failure("Body must be either of Function_Body or Untyped type, %s\n%s", code_debug_str(body), parser_to_string(Context)); + log_failure("Body must be either of Function_Body or Untyped type, %s\n%s", code_debug_str(body), parser_to_strbuilder(Context)); parser_pop(& Context); return InvalidCode; } @@ -1612,11 +1612,11 @@ Code parse_function_body() Token past = prevtok; - s32 len = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)start.Text; + s32 len = ( (sptr)prevtok.Text.Ptr + prevtok.Text.Len ) - (sptr)start.Text.Ptr; if ( len > 0 ) { - StrC str = { len, start.Text }; + Str str = { start.Text.Ptr, len }; body_append( result, cast(Code, def_execution( str )) ); } @@ -1661,7 +1661,7 @@ CodeBody parse_global_nspace( CodeType which ) { case Tok_Comma: { - log_failure("Dangling comma found: %S\nContext:\n%S", tok_to_string(currtok), parser_to_string(Context)); + log_failure("Dangling comma found: %SB\nContext:\n%SB", tok_to_strbuilder(currtok), parser_to_strbuilder(Context)); parser_pop( & Context); return InvalidCode; } @@ -1669,7 +1669,7 @@ CodeBody parse_global_nspace( CodeType which ) case Tok_Statement_End: { // TODO(Ed): Convert this to a general warning procedure - log_fmt("Dangling end statement found %S\n", tok_to_string(currtok_noskip)); + log_fmt("Dangling end statement found %SB\n", tok_to_strbuilder(currtok_noskip)); eat( Tok_Statement_End ); continue; } @@ -1695,7 +1695,7 @@ CodeBody parse_global_nspace( CodeType which ) case Tok_Decl_Extern_Linkage: if ( which == CT_Extern_Linkage_Body ) - log_failure( "Nested extern linkage\n%s", parser_to_string(Context) ); + log_failure( "Nested extern linkage\n%s", parser_to_strbuilder(Context) ); member = cast(Code, parser_parse_extern_link()); // extern "..." { ... } @@ -1788,7 +1788,7 @@ CodeBody parse_global_nspace( CodeType which ) case Tok_Module_Export: { if ( which == CT_Export_Body ) - log_failure( "Nested export declaration\n%s", parser_to_string(Context) ); + log_failure( "Nested export declaration\n%s", parser_to_strbuilder(Context) ); member = cast(Code, parser_parse_export_body()); // export { ... } @@ -1828,7 +1828,7 @@ CodeBody parse_global_nspace( CodeType which ) while ( left && tok_is_specifier(currtok) ) { - Specifier spec = strc_to_specifier( tok_to_str(currtok) ); + Specifier spec = str_to_specifier( tok_to_str(currtok) ); bool ignore_spec = false; @@ -1856,9 +1856,9 @@ CodeBody parse_global_nspace( CodeType which ) break; default: - StrC spec_str = spec_to_str(spec); + Str spec_str = spec_to_str(spec); - log_failure( "Invalid specifier %.*s for variable\n%s", spec_str.Len, spec_str, parser_to_string(Context) ); + log_failure( "Invalid specifier %S for variable\n%S", spec_str, strbuilder_to_str( parser_to_strbuilder(Context)) ); parser_pop(& Context); return InvalidCode; } @@ -1941,7 +1941,7 @@ CodeBody parse_global_nspace( CodeType which ) if ( member == Code_Invalid ) { - log_failure( "Failed to parse member\n%s", parser_to_string(Context) ); + log_failure( "Failed to parse member\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -1960,7 +1960,7 @@ CodeBody parse_global_nspace( CodeType which ) Member_Resolved_To_Lone_Macro: if ( member == Code_Invalid ) { - log_failure( "Failed to parse member\nToken: %S\nContext:\n%S", tok_to_string(currtok_noskip), parser_to_string(Context) ); + log_failure( "Failed to parse member\nToken: %SB\nContext:\n%SB", tok_to_strbuilder(currtok_noskip), parser_to_strbuilder(Context) ); parser_pop(& Context); return InvalidCode; } @@ -2000,19 +2000,19 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) Token nav = tokens.Arr[ idx ]; for ( ; idx < array_num(tokens.Arr); idx++, nav = tokens.Arr[ idx ] ) { - if ( nav.Text[0] == '<' ) + if ( nav.Text.Ptr[0] == '<' ) { // Skip templated expressions as they mey have expressions with the () operators s32 capture_level = 0; s32 template_level = 0; for ( ; idx < array_num(tokens.Arr); idx++, nav = tokens.Arr[idx] ) { - if (nav.Text[ 0 ] == '<') + if (nav.Text.Ptr[ 0 ] == '<') ++ template_level; - if (nav.Text[ 0 ] == '>') + if (nav.Text.Ptr[ 0 ] == '>') -- template_level; - if (nav.Type == Tok_Operator && nav.Text[1] == '>') + if (nav.Type == Tok_Operator && nav.Text.Ptr[1] == '>') -- template_level; if ( nav.Type == Tok_Capture_Start) @@ -2047,7 +2047,7 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) // ... bool possible_destructor = false; - if ( tok_left.Type == Tok_Operator && tok_left.Text[0] == '~') + if ( tok_left.Type == Tok_Operator && tok_left.Text.Ptr[0] == '~') { possible_destructor = true; -- idx; @@ -2066,12 +2066,12 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) s32 template_level = 0; while ( idx != tokens.Idx ) { - if (tok_left.Text[ 0 ] == '<') + if (tok_left.Text.Ptr[ 0 ] == '<') ++ template_level; - if (tok_left.Text[ 0 ] == '>') + if (tok_left.Text.Ptr[ 0 ] == '>') -- template_level; - if (tok_left.Type == Tok_Operator && tok_left.Text[1] == '>') + if (tok_left.Type == Tok_Operator && tok_left.Text.Ptr[1] == '>') -- template_level; if ( template_level != 0 && tok_left.Type == Tok_Capture_Start) @@ -2087,7 +2087,7 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) tok_left = tokens.Arr[idx]; } - bool is_same = str_compare_len( tok_right.Text, tok_left.Text, tok_right.Length ) == 0; + bool is_same = c_str_compare_len( tok_right.Text.Ptr, tok_left.Text.Ptr, tok_right.Text.Len ) == 0; if (tok_left.Type == Tok_Identifier && is_same) { // We have found the pattern we desired @@ -2129,34 +2129,34 @@ Token parse_identifier( bool* possible_member_function ) Token invalid = { nullptr, 0, Tok_Invalid }; if ( left == 0 ) { - log_failure( "Error, unexpected end of static symbol identifier\n%s", parser_to_string(Context) ); + log_failure( "Error, unexpected end of static symbol identifier\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return invalid; } - if ( currtok.Type == Tok_Operator && currtok.Text[0] == '~' ) + if ( currtok.Type == Tok_Operator && currtok.Text.Ptr[0] == '~' ) { - bool is_destructor = strc_are_equal( Context.Scope->Prev->ProcName, txt("parser_parse_destructor")); + bool is_destructor = str_are_equal( Context.Scope->Prev->ProcName, txt("parser_parse_destructor")); if (is_destructor) { - name.Length = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )name.Text; + name.Text.Len = ( ( sptr )prevtok.Text.Ptr + prevtok.Text.Len ) - ( sptr )name.Text.Ptr; parser_pop(& Context); return name; } - log_failure( "Error, had a ~ operator after %S but not a destructor\n%s", toktype_to_str( prevtok.Type ), parser_to_string(Context) ); + log_failure( "Error, had a ~ operator after %SB but not a destructor\n%s", toktype_to_str( prevtok.Type ), parser_to_strbuilder(Context) ); parser_pop(& Context); return invalid; } - if ( currtok.Type == Tok_Operator && currtok.Text[0] == '*' && currtok.Length == 1 ) + if ( currtok.Type == Tok_Operator && currtok.Text.Ptr[0] == '*' && currtok.Text.Len == 1 ) { if ( possible_member_function ) *possible_member_function = true; else { - log_failure( "Found a member function pointer identifier but the parsing context did not expect it\n%s", parser_to_string(Context) ); + log_failure( "Found a member function pointer identifier but the parsing context did not expect it\n%s", parser_to_strbuilder(Context) ); parser_pop(& Context); return invalid; } @@ -2164,12 +2164,12 @@ Token parse_identifier( bool* possible_member_function ) if ( currtok.Type != Tok_Identifier ) { - log_failure( "Error, expected static symbol identifier, not %s\n%s", toktype_to_str( currtok.Type ), parser_to_string(Context) ); + log_failure( "Error, expected static symbol identifier, not %s\n%s", toktype_to_str( currtok.Type ), parser_to_strbuilder(Context) ); parser_pop(& Context); return invalid; } - name.Length = ( (sptr)currtok.Text + currtok.Length ) - (sptr)name.Text; + name.Text.Len = ( (sptr)currtok.Text.Ptr + currtok.Text.Len ) - (sptr)name.Text.Ptr; eat( Tok_Identifier ); //