Compare commits

..

No commits in common. "9e88cb8724807886f89ba7aeb408b9d38dafd1e8" and "ed0c0422ad91f708fa217c95f3353e082aa5f8ee" have entirely different histories.

14 changed files with 79 additions and 461 deletions

View File

@ -90,7 +90,6 @@ CodeBody parse_file( const char* path )
{
FileContents file = file_read_contents( GlobalAllocator, true, path );
CodeBody code = parse_global_body( { file.size, (char const*)file.data } );
log_fmt("\nParsed: %s\n", path);
return code;
}
@ -127,7 +126,7 @@ int gen_main()
header.print( debug );
CodeBody parsed_memory = parse_file( project_dir "dependencies/memory.hpp" );
CodeBody memory = def_body(ECode::Global_Body);
CodeBody memory = def_body(ECode::Struct_Body);
for ( Code entry = parsed_memory.begin(); entry != parsed_memory.end(); ++ entry )
{
switch (entry->Type)
@ -146,31 +145,12 @@ int gen_main()
CodeFn fn = entry.cast<CodeFn>();
s32 constexpr_found = fn->Specs.remove( ESpecifier::Constexpr );
if (constexpr_found > -1) {
log_fmt("Found constexpr: %S\n", entry->to_string());
log_fmt("Found constexpr proc\n");
fn->Specs.append(ESpecifier::Inline);
}
memory.append(entry);
}
break;
case ECode::Template:
{
CodeTemplate tmpl = entry.cast<CodeTemplate>();
if ( tmpl->Declaration->Name.contains(txt("swap")))
{
CodeBody macro_swap = parse_global_body( txt(R"(
#define swap( a, b ) \
do \
{ \
typeof( a ) temp = ( a ); \
( a ) = ( b ); \
( b ) = temp; \
} while ( 0 )
)"
));
memory.append(macro_swap);
}
}
break;
case ECode::Class:
case ECode::Struct:
{
@ -195,26 +175,17 @@ int gen_main()
break;
case ECode::Preprocess_If:
{
b32 found = ignore_preprocess_cond_block(txt("GEN_SUPPORT_CPP_MEMBER_FEATURES"), entry, parsed_memory );
if (found) break;
memory.append(entry);
ignore_preprocess_cond_block(txt("GEN_SUPPORT_CPP_MEMBER_FEATURES"), entry, parsed_memory );
}
break;
case ECode::Preprocess_IfDef:
{
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_memory );
if (found) break;
memory.append(entry);
ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_memory );
}
break;
case ECode::Preprocess_Pragma:
{
b32 found = swap_pragma_region_implementation( txt("FixedArena"), gen_fixed_arenas, entry, memory);
if (found) break;
memory.append(entry);
swap_pragma_region_implementation( txt("FixedArena"), gen_fixed_arenas, entry, memory);
}
break;
default: {
@ -223,134 +194,65 @@ int gen_main()
break;
}
}
header.print( dump_to_scratch_and_retireve(memory) );
header.print( memory );
Code string_ops = scan_file( project_dir "dependencies/string_ops.hpp" );
header.print( string_ops );
CodeBody printing_parsed = parse_file( project_dir "dependencies/printing.hpp" );
CodeBody printing = def_body(ECode::Global_Body);
CodeBody printing = def_body(ECode::Struct_Body);
for ( Code entry = printing_parsed.begin(); entry != printing_parsed.end(); ++ entry )
{
switch (entry->Type)
{
case ECode::Preprocess_IfDef:
{
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, printing_parsed );
ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, printing_parsed );
}
}
if (entry->Type == ECode::Variable &&
contains(entry->Name, txt("Msg_Invalid_Value")))
{
CodeDefine define = def_define(entry->Name, entry->Value->Content);
printing.append(define);
continue;
}
printing.append(entry);
}
header.print(printing);
CodeBody parsed_containers = parse_file( project_dir "dependencies/containers.hpp" );
CodeBody containers = def_body(ECode::Struct_Body);
for ( Code entry = parsed_containers.begin(); entry != parsed_containers.end(); ++ entry )
{
switch ( entry->Type )
{
case ECode::Preprocess_Pragma:
{
bool found = false;
found = swap_pragma_region_implementation( txt("Array"), gen_array_base, entry, containers);
if (found) break;
printing.append(entry);
found = swap_pragma_region_implementation( txt("Hashtable"), gen_hashtable_base, entry, containers);
if (found) break;
containers.append(entry);
}
break;
case ECode::Variable:
{
if (contains(entry->Name, txt("Msg_Invalid_Value")))
{
CodeDefine define = def_define(entry->Name, entry->Value->Content);
printing.append(define);
continue;
}
printing.append(entry);
}
break;
default:
printing.append(entry);
break;
}
}
header.print(dump_to_scratch_and_retireve(printing));
CodeBody containers = def_body(ECode::Global_Body);
{
containers.append( def_pragma(code(region Containers)));
containers.append( gen_array_base() );
containers.append( gen_hashtable_base() );
containers.append( def_pragma(code(endregion Containers)));
}
header.print(fmt_newline);
header.print(dump_to_scratch_and_retireve(containers));
Code hashing = scan_file( project_dir "dependencies/hashing.hpp" );
header.print( hashing );
CodeBody parsed_strings = parse_file( project_dir "dependencies/strings.hpp" );
CodeBody strings = def_body(ECode::Global_Body);
for ( Code entry = parsed_strings.begin(); entry != parsed_strings.end(); ++ entry )
{
switch (entry->Type)
{
case ECode::Preprocess_If:
{
ignore_preprocess_cond_block(txt("! GEN_COMPILER_C"), entry, parsed_strings);
}
break;
case ECode::Preprocess_IfDef:
{
ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_strings );
}
break;
case ECode::Struct_Fwd:
{
if ( entry->Name.is_equal(txt("String")) )
{
CodeTypedef c_def = parse_typedef(code( typedef Type* String; ));
strings.append(c_def);
strings.append(fmt_newline);
++ entry;
continue;
}
strings.append(entry);
}
break;
default:
strings.append(entry);
break;
}
}
header.print(dump_to_scratch_and_retireve(strings));
Code filesystem = scan_file( project_dir "dependencies/filesystem.hpp" );
Code timing = scan_file( project_dir "dependencies/timing.hpp" );
header.print( filesystem );
header.print( timing );
header.print_fmt( "\nGEN_NS_END\n" );
header.print_fmt( roll_own_dependencies_guard_end );
Code types = scan_file( project_dir "components/types.hpp" );
Code ast = scan_file( project_dir "components/ast.hpp" );
Code ast_types = scan_file( project_dir "components/ast_types.hpp" );
Code code_types = scan_file( project_dir "components/code_types.hpp" );
Code interface = scan_file( project_dir "components/interface.hpp" );
Code inlines = scan_file( project_dir "components/inlines.hpp" );
Code header_end = scan_file( project_dir "components/header_end.hpp" );
CodeBody ecode = gen_ecode ( project_dir "enums/ECode.csv" );
CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv" );
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" );
CodeBody ast_inlines = gen_ast_inlines();
header.print_fmt("#pragma region Types\n");
header.print( types );
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve( ecode ));
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve( eoperator ));
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve( especifier ));
header.print( fmt_newline );
header.print_fmt("#pragma endregion Types\n\n");
header.print(containers);
}
header.print( pop_ignores );
header.write();
// format_file( "gen/gen.h" );
format_file( "gen/gen.h" );
gen::deinit();
return 0;

View File

@ -19,7 +19,7 @@ CodeBody gen_array_base()
// Code grow_formula = untyped_str( txt( "#define gen_array_grow_formula( value ) ( 2 * value + 8 )\n" ));
Code get_header = untyped_str( txt( "#define array_get_header( Type, self ) ( (ArrayHeader*)( self ) - 1)\n" ));
return def_global_body( args( fmt_newline, td_header, header, get_header, fmt_newline ) );
return def_global_body( args( td_header, header, get_header ) );
};
CodeBody gen_array( StrC type, StrC array_name )

View File

@ -7,13 +7,9 @@ using SwapContentProc = CodeBody(void);
b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& body )
{
b32 found = false;
CodePreprocessCond cond = entry_iter.cast<CodePreprocessCond>();
if ( cond->Content.contains(cond_sig) )
{
log_fmt("Preprocess cond found: %S\n", cond->Content);
found = true;
s32 depth = 1;
++ entry_iter; for(b32 continue_for = true; continue_for && entry_iter != body.end(); ) switch
(entry_iter->Type) {
@ -38,7 +34,7 @@ b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& bod
}
}
return found;
return entry_iter != body.end();
}
bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_content, Code& entry_iter, CodeBody& body )

View File

@ -165,7 +165,6 @@ struct Code
char const* debug_str(); \
Code duplicate(); \
bool is_equal( Code other ); \
bool is_body(); \
bool is_valid(); \
void set_global(); \
String to_string(); \
@ -260,7 +259,6 @@ struct AST
Code& entry ( u32 idx );
bool has_entries();
bool is_equal ( AST* other );
bool is_body();
char const* type_str();
bool validate_body();

View File

@ -11,10 +11,6 @@ struct CodeBody
void append( Code other )
{
if (other.is_body())
{
append( other.cast<CodeBody>() );
}
raw()->append( other.ast );
}
void append( CodeBody body )

View File

@ -24,15 +24,6 @@ inline Code Code::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool Code::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool Code::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -100,15 +91,6 @@ inline Code CodeBody::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeBody::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeBody::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -176,15 +158,6 @@ inline Code CodeAttributes::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeAttributes::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeAttributes::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -272,15 +245,6 @@ inline Code CodeComment::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeComment::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeComment::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -368,15 +332,6 @@ inline Code CodeConstructor::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeConstructor::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeConstructor::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -464,15 +419,6 @@ inline Code CodeClass::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeClass::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeClass::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -540,15 +486,6 @@ inline Code CodeDefine::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeDefine::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeDefine::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -636,15 +573,6 @@ inline Code CodeDestructor::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeDestructor::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeDestructor::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -732,15 +660,6 @@ inline Code CodeEnum::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeEnum::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeEnum::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -828,15 +747,6 @@ inline Code CodeExec::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeExec::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeExec::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -924,15 +834,6 @@ inline Code CodeExtern::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeExtern::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeExtern::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1020,15 +921,6 @@ inline Code CodeFriend::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeFriend::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeFriend::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1116,15 +1008,6 @@ inline Code CodeFn::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeFn::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeFn::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1212,15 +1095,6 @@ inline Code CodeInclude::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeInclude::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeInclude::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1308,15 +1182,6 @@ inline Code CodeModule::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeModule::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeModule::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1404,15 +1269,6 @@ inline Code CodeNS::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeNS::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeNS::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1500,15 +1356,6 @@ inline Code CodeOperator::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeOperator::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeOperator::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1596,15 +1443,6 @@ inline Code CodeOpCast::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeOpCast::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeOpCast::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1692,15 +1530,6 @@ inline Code CodeParam::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeParam::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeParam::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1768,15 +1597,6 @@ inline Code CodePragma::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodePragma::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodePragma::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1864,15 +1684,6 @@ inline Code CodePreprocessCond::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodePreprocessCond::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodePreprocessCond::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -1960,15 +1771,6 @@ inline Code CodeSpecifiers::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeSpecifiers::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeSpecifiers::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -2036,15 +1838,6 @@ inline Code CodeStruct::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeStruct::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeStruct::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -2112,15 +1905,6 @@ inline Code CodeTemplate::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeTemplate::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeTemplate::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -2208,15 +1992,6 @@ inline Code CodeType::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeType::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeType::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -2304,15 +2079,6 @@ inline Code CodeTypedef::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeTypedef::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeTypedef::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -2400,15 +2166,6 @@ inline Code CodeUnion::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeUnion::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeUnion::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -2496,15 +2253,6 @@ inline Code CodeUsing::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeUsing::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeUsing::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )
@ -2592,15 +2340,6 @@ inline Code CodeVar::duplicate()
return { rcast( AST*, ast )->duplicate() };
}
inline bool CodeVar::is_body()
{
if ( ast == nullptr )
{
return rcast( AST*, ast )->is_body();
}
return false;
}
inline bool CodeVar::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )

View File

@ -21,7 +21,7 @@ void AST::append( AST* other )
}
AST*
Current = Back;
Current = Back;
Current->Next = other;
other->Prev = Current;
Back = other;
@ -50,25 +50,6 @@ bool AST::has_entries()
return NumEntries > 0;
}
inline
bool AST::is_body()
{
switch (Type)
{
case ECode::Enum_Body:
case ECode::Class_Body:
case ECode::Union_Body:
case ECode::Export_Body:
case ECode::Global_Body:
case ECode::Struct_Body:
case ECode::Function_Body:
case ECode::Namespace_Body:
case ECode::Extern_Linkage_Body:
return true;
}
return false;
}
inline
char const* AST::type_str()
{

View File

@ -4406,7 +4406,6 @@ CodeTemplate parse_template()
result->Params = params;
result->Declaration = definition;
result->ModuleFlags = mflags;
// result->Name = definition->Name;
Context.pop();
return result;

View File

@ -14,17 +14,20 @@ template<class TType>
using TRemoveConst = typename RemoveConst<TType>::Type;
#pragma region Array
#if ! GEN_COMPILER_C
#define Array(Type) Array<Type>
// #define array_init(Type, ...) array_init <Type>(__VA_ARGS__)
// #define array_init_reserve(Type, ...) array_init_reserve<Type>(__VA_ARGS__)
#endif
struct ArrayHeader;
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
template<class Type> struct Array;
template<class Type> struct Array;
#else
template<class Type> using Array = Type*;
template<class Type>
using Array = Type*;
#endif
usize array_grow_formula(ssize value);

View File

@ -205,7 +205,7 @@
# define foreach(Type, entry_id, iterable) for ( Type entry_id : iterable )
#endif
#if GEN_COMPILER_C
#if GENC_COMPILERC
# if __STDC_VERSION__ >= 202311L
# define enum_underlying(type) : type
# else

View File

@ -14,13 +14,23 @@
#define GEN__HIGHS ( GEN__ONES * ( GEN_U8_MAX / 2 + 1 ) )
#define GEN__HAS_ZERO( x ) ( ( ( x ) - GEN__ONES ) & ~( x ) & GEN__HIGHS )
template< class Type >
void swap( Type& a, Type& b )
{
Type tmp = a;
a = b;
b = tmp;
}
#if ! GEN_COMPILER_C
template< class Type >
void swap( Type& a, Type& b )
{
Type tmp = a;
a = b;
b = tmp;
}
#else
#define swap( a, b ) \
do { \
typeof(a) \
temp = (a); \
(a) = (b); \
(b) = temp; \
} while(0)
#endif
//! Checks if value is power of 2.
b32 is_power_of_two( ssize x );

View File

@ -106,7 +106,7 @@
# define GEN_GCC_VERSION_CHECK(major,minor,patch) (0)
#endif
#ifndef GEN_COMPILER_C
#ifndef GEN_COMPIELR_C
# if defined(__STDC_VERSION__)
# define GEN_COMPILER_C 1
# else

View File

@ -11,10 +11,8 @@ struct StrC
ssize Len;
char const* Ptr;
#if ! GEN_COMPILER_C
operator char const* () const { return Ptr; }
char const& operator[]( ssize index ) const { return Ptr[index]; }
#endif
};
#define cast_to_strc( str ) * rcast( StrC*, (str) - sizeof(ssize) )
@ -31,7 +29,12 @@ StrC to_str( char const* str ) {
// I kept it for simplicty of porting but its not necessary to keep it that way.
#pragma region String
struct StringHeader;
#if GEN_COMPILER_C
typedef char* String;
#else
struct String;
#endif
String string_make(AllocatorInfo allocator, char const* str);
String string_make(AllocatorInfo allocator, StrC str);
@ -41,8 +44,8 @@ String string_fmt(AllocatorInfo allocator, char* buf, ssize buf_size, cha
String string_fmt_buf(AllocatorInfo allocator, char const* fmt, ...);
String string_join(AllocatorInfo allocator, char const** parts, ssize num_parts, char const* glue);
usize string_grow_formula(usize value);
bool are_equal(String const& lhs, String const& rhs);
bool are_equal(String const& lhs, StrC rhs);
bool are_equal(String lhs, String rhs);
bool are_equal(String lhs, StrC rhs);
bool make_space_for(String& str, char const* to_append, ssize add_len);
bool append(String& str, char c);
bool append(String& str, char const* str_to_append);
@ -108,6 +111,8 @@ struct String
forceinline static String make_length(AllocatorInfo a, char const* s, ssize l) { return GEN_NS string_make_length(a, s, l); }
forceinline static String join(AllocatorInfo a, char const** p, ssize n, char const* g) { return GEN_NS string_join(a, p, n, g); }
forceinline static usize grow_formula(usize value) { return GEN_NS string_grow_formula(value); }
forceinline static bool are_equal(String lhs, String rhs) { return GEN_NS are_equal(lhs, rhs); }
forceinline static bool are_equal(String lhs, StrC rhs) { return GEN_NS are_equal(lhs, rhs); }
static
String fmt(AllocatorInfo allocator, char* buf, ssize buf_size, char const* fmt, ...) {
@ -143,8 +148,6 @@ struct String
forceinline void clear() { GEN_NS clear(*this); }
forceinline String duplicate(AllocatorInfo allocator) const { return GEN_NS duplicate(*this, allocator); }
forceinline void free() { GEN_NS free(*this); }
forceinline bool is_equal(String const& other) const { return GEN_NS are_equal(* this, other); }
forceinline bool is_equal(StrC other) const { return GEN_NS are_equal(* this, other); }
forceinline ssize length() const { return GEN_NS length(*this); }
forceinline b32 starts_with(StrC substring) const { return GEN_NS starts_with(*this, substring); }
forceinline b32 starts_with(String substring) const { return GEN_NS starts_with(*this, substring); }
@ -286,7 +289,7 @@ bool append_fmt(String& str, char const* fmt, ...) {
}
inline
bool are_equal(String const& lhs, String const& rhs)
bool are_equal(String lhs, String rhs)
{
if (length(lhs) != length(rhs))
return false;
@ -299,7 +302,7 @@ bool are_equal(String const& lhs, String const& rhs)
}
inline
bool are_equal(String const& lhs, StrC rhs)
bool are_equal(String lhs, StrC rhs)
{
if (length(lhs) != (rhs.Len))
return false;

View File

@ -368,15 +368,6 @@ CodeBody gen_ast_inlines()
return { rcast(AST*, ast)->duplicate() };
}
inline
bool <typename>::is_body()
{
if ( ast == nullptr )
{
return rcast(AST*, ast)->is_body();
}
return false;
}
inline
bool <typename>::is_equal( Code other )
{
if ( ast == nullptr || other.ast == nullptr )