mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Compare commits
2 Commits
12e31276eb
...
ed9f719a07
Author | SHA1 | Date | |
---|---|---|---|
ed9f719a07 | |||
500f216da2 |
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -72,5 +72,5 @@
|
|||||||
},
|
},
|
||||||
"autoHide.autoHidePanel": false,
|
"autoHide.autoHidePanel": false,
|
||||||
"autoHide.autoHideSideBar": false,
|
"autoHide.autoHideSideBar": false,
|
||||||
"dimmer.enabled": true
|
"dimmer.enabled": false
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -107,7 +107,7 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
|||||||
HT_FindResult <fn>__find ( <tbl_type> self, u64 key );
|
HT_FindResult <fn>__find ( <tbl_type> self, u64 key );
|
||||||
b32 <fn>__full ( <tbl_type> self );
|
b32 <fn>__full ( <tbl_type> self );
|
||||||
|
|
||||||
<tbl_type> <fn>init( AllocatorInfo allocator )
|
<tbl_type> <fn>_init( AllocatorInfo allocator )
|
||||||
{
|
{
|
||||||
<tbl_type> result = hashtable_init_reserve(<type>, allocator, 8);
|
<tbl_type> result = hashtable_init_reserve(<type>, allocator, 8);
|
||||||
return result;
|
return result;
|
||||||
@ -373,13 +373,13 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
|||||||
#pragma pop_macro( "forceinline" )
|
#pragma pop_macro( "forceinline" )
|
||||||
|
|
||||||
++ HashTable_DefinitionCounter;
|
++ HashTable_DefinitionCounter;
|
||||||
StrC slot_str = String::fmt_buf(GlobalAllocator, "%d", Array_DefinitionCounter).to_strc();
|
StrC slot_str = String::fmt_buf(GlobalAllocator, "%d", HashTable_DefinitionCounter).to_strc();
|
||||||
|
|
||||||
Code generic_interface_slot = untyped_str(token_fmt( "type", type, "tbl_type", (StrC)tbl_type, "slot", (StrC)slot_str,
|
Code generic_interface_slot = untyped_str(token_fmt( "type", type, "tbl_type", (StrC)tbl_type, "slot", (StrC)slot_str,
|
||||||
R"(#define GENERIC_SLOT_<slot>__hashtable_init <type>, <tbl_type>_init
|
R"(#define GENERIC_SLOT_<slot>__hashtable_init <type>, <tbl_type>_init
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_init_reserve <type>, <tbl_type>_init_reserve
|
#define GENERIC_SLOT_<slot>__hashtable_init_reserve <type>, <tbl_type>_init_reserve
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_clear <tbl_type>, <tbl_type>_clear
|
#define GENERIC_SLOT_<slot>__hashtable_clear <tbl_type>, <tbl_type>_clear
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_destroy <tbl_type>*, <tbl_type>_destroy
|
#define GENERIC_SLOT_<slot>__hashtable_destroy <tbl_type>, <tbl_type>_destroy
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_get <tbl_type>, <tbl_type>_get
|
#define GENERIC_SLOT_<slot>__hashtable_get <tbl_type>, <tbl_type>_get
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_map <tbl_type>, <tbl_type>_map
|
#define GENERIC_SLOT_<slot>__hashtable_map <tbl_type>, <tbl_type>_map
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_map_mut <tbl_type>, <tbl_type>_map_mut
|
#define GENERIC_SLOT_<slot>__hashtable_map_mut <tbl_type>, <tbl_type>_map_mut
|
||||||
@ -387,7 +387,7 @@ R"(#define GENERIC_SLOT_<slot>__hashtable_init <type>, <tbl_type>_
|
|||||||
#define GENERIC_SLOT_<slot>__hashtable_rehash <tbl_type>*, <tbl_type>_rehash
|
#define GENERIC_SLOT_<slot>__hashtable_rehash <tbl_type>*, <tbl_type>_rehash
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_rehash_fast <tbl_type>, <tbl_type>_rehash_fast
|
#define GENERIC_SLOT_<slot>__hashtable_rehash_fast <tbl_type>, <tbl_type>_rehash_fast
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_remove_entry <tbl_type>, <tbl_type>_remove_entry
|
#define GENERIC_SLOT_<slot>__hashtable_remove_entry <tbl_type>, <tbl_type>_remove_entry
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_set <tbl_type>*, <tbl_type>_set
|
#define GENERIC_SLOT_<slot>__hashtable_set <tbl_type>, <tbl_type>_set
|
||||||
#define GENERIC_SLOT_<slot>__hashtable_slot <tbl_type>, <tbl_type>_slot
|
#define GENERIC_SLOT_<slot>__hashtable_slot <tbl_type>, <tbl_type>_slot
|
||||||
|
|
||||||
#define GENERIC_SLOT_<slot>__hashtable__add_entry <tbl_type>*, <tbl_type>__add_entry
|
#define GENERIC_SLOT_<slot>__hashtable__add_entry <tbl_type>*, <tbl_type>__add_entry
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
<Define>GEN_EXECUTION_EXPRESSION_SUPPORT</Define>
|
<Define>GEN_EXECUTION_EXPRESSION_SUPPORT</Define>
|
||||||
<Define>GEN_BENCHMARK</Define>
|
<Define>GEN_BENCHMARK</Define>
|
||||||
<Define>GEN_COMPILER_MSVC</Define>
|
<Define>GEN_COMPILER_MSVC</Define>
|
||||||
|
<Define>GEN_IMPLEMENTATION</Define>
|
||||||
</Defines>
|
</Defines>
|
||||||
<ConfigProperties>
|
<ConfigProperties>
|
||||||
<ConfigAndPlatform>
|
<ConfigAndPlatform>
|
||||||
|
@ -7,20 +7,20 @@ global Code Code_Global;
|
|||||||
global Code Code_Invalid;
|
global Code Code_Invalid;
|
||||||
|
|
||||||
// This serializes all the data-members in a "debug" format, where each member is printed with its associated value.
|
// This serializes all the data-members in a "debug" format, where each member is printed with its associated value.
|
||||||
char const* code_debug_str(Code self)
|
StrC code_debug_str(Code self)
|
||||||
{
|
{
|
||||||
GEN_ASSERT(self != nullptr);
|
GEN_ASSERT(self != nullptr);
|
||||||
String result_stack = string_make_reserve( GlobalAllocator, kilobytes(1) );
|
String result_stack = string_make_reserve( GlobalAllocator, kilobytes(1) );
|
||||||
String* result = & result_stack;
|
String* result = & result_stack;
|
||||||
|
|
||||||
if ( self->Parent )
|
if ( self->Parent )
|
||||||
string_append_fmt( result, "\n\tParent : %S %S", code_type_str(self->Parent), self->Name ? self->Name : "" );
|
string_append_fmt( result, "\n\tParent : %SC %SC", code_type_str(self->Parent), self->Name.Len ? self->Name : txt("Null") );
|
||||||
else
|
else
|
||||||
string_append_fmt( result, "\n\tParent : %S", "Null" );
|
string_append_fmt( result, "\n\tParent : %SC", txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tName : %S", self->Name ? self->Name : "Null" );
|
string_append_fmt( result, "\n\tName : %SC", self->Name.Len ? self->Name : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tType : %S", code_type_str(self) );
|
string_append_fmt( result, "\n\tType : %SC", code_type_str(self) );
|
||||||
string_append_fmt( result, "\n\tModule Flags : %S", module_flag_to_str( self->ModuleFlags ) );
|
string_append_fmt( result, "\n\tModule Flags : %SC", module_flag_to_str( self->ModuleFlags ) );
|
||||||
|
|
||||||
switch ( self->Type )
|
switch ( self->Type )
|
||||||
{
|
{
|
||||||
@ -30,9 +30,9 @@ char const* code_debug_str(Code self)
|
|||||||
case CT_Access_Protected:
|
case CT_Access_Protected:
|
||||||
case CT_Access_Public:
|
case CT_Access_Public:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Untyped:
|
case CT_Untyped:
|
||||||
@ -48,74 +48,74 @@ char const* code_debug_str(Code self)
|
|||||||
case CT_Preprocess_IfDef:
|
case CT_Preprocess_IfDef:
|
||||||
case CT_Preprocess_IfNotDef:
|
case CT_Preprocess_IfNotDef:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tContent: %S", self->Content );
|
string_append_fmt( result, "\n\tContent: %SC", self->Content );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Class:
|
case CT_Class:
|
||||||
case CT_Struct:
|
case CT_Struct:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? code_to_string(self->Attributes) : "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: %s", self->ParentType ? access_spec_to_str( self->ParentAccess ) : "No Parent" );
|
string_append_fmt( result, "\n\tParentAccess: %SC", self->ParentType ? access_spec_to_str( self->ParentAccess ) : txt("No Parent") );
|
||||||
string_append_fmt( result, "\n\tParentType : %s", self->ParentType ? code_type_str(self->ParentType) : "Null" );
|
string_append_fmt( result, "\n\tParentType : %SC", self->ParentType ? code_type_str(self->ParentType) : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Class_Fwd:
|
case CT_Class_Fwd:
|
||||||
case CT_Struct_Fwd:
|
case CT_Struct_Fwd:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? code_to_string(self->Attributes) : "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: %s", self->ParentType ? access_spec_to_str( self->ParentAccess ) : "No Parent" );
|
string_append_fmt( result, "\n\tParentAccess: %SC", self->ParentType ? access_spec_to_str( self->ParentAccess ) : txt("No Parent") );
|
||||||
string_append_fmt( result, "\n\tParentType : %s", self->ParentType ? code_type_str(self->ParentType) : "Null" );
|
string_append_fmt( result, "\n\tParentType : %SC", self->ParentType ? code_type_str(self->ParentType) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Constructor:
|
case CT_Constructor:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tSpecs : %S", self->Specs ? code_to_string(self->Specs) : "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: %S", self->InitializerList ? code_to_string(self->InitializerList) : "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 : %S", self->Params ? code_to_string(self->Params) : "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 : %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Constructor_Fwd:
|
case CT_Constructor_Fwd:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tSpecs : %S", self->Specs ? code_to_string(self->Specs) : "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: %S", self->InitializerList ? code_to_string(self->InitializerList) : "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 : %S", self->Params ? code_to_string(self->Params) : "Null" );
|
string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params) ) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Destructor:
|
case CT_Destructor:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tSpecs : %S", self->Specs ? code_to_string(self->Specs) : "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 : %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Destructor_Fwd:
|
case CT_Destructor_Fwd:
|
||||||
@ -124,142 +124,142 @@ char const* code_debug_str(Code self)
|
|||||||
case CT_Enum:
|
case CT_Enum:
|
||||||
case CT_Enum_Class:
|
case CT_Enum_Class:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->UnderlyingType ? code_to_string(self->UnderlyingType) : "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 : %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Enum_Fwd:
|
case CT_Enum_Fwd:
|
||||||
case CT_Enum_Class_Fwd:
|
case CT_Enum_Class_Fwd:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->UnderlyingType ? code_to_string(self->UnderlyingType) : "Null" );
|
string_append_fmt( result, "\n\tUnderlying Type : %SC", self->UnderlyingType ? string_to_strc( code_to_string(self->UnderlyingType)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Extern_Linkage:
|
case CT_Extern_Linkage:
|
||||||
case CT_Namespace:
|
case CT_Namespace:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tBody: %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody: %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Friend:
|
case CT_Friend:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? code_to_string(self->Declaration) : "Null" );
|
string_append_fmt( result, "\n\tDeclaration: %SC", self->Declaration ? string_to_strc( code_to_string(self->Declaration)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Function:
|
case CT_Function:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->Specs ? code_to_string(self->Specs) : "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: %S", self->ReturnType ? code_to_string(self->ReturnType) : "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 : %S", self->Params ? code_to_string(self->Params) : "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 : %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Function_Fwd:
|
case CT_Function_Fwd:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->Specs ? code_to_string(self->Specs) : "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: %S", self->ReturnType ? code_to_string(self->ReturnType) : "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 : %S", self->Params ? code_to_string(self->Params) : "Null" );
|
string_append_fmt( result, "\n\tParams : %SC", self->Params ? string_to_strc( code_to_string(self->Params)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Module:
|
case CT_Module:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Operator:
|
case CT_Operator:
|
||||||
case CT_Operator_Member:
|
case CT_Operator_Member:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->Specs ? code_to_string(self->Specs) : "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: %S", self->ReturnType ? code_to_string(self->ReturnType) : "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 : %S", self->Params ? code_to_string(self->Params) : "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 : %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tOp : %S", operator_to_str( self->Op ) );
|
string_append_fmt( result, "\n\tOp : %SC", operator_to_str( self->Op ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Operator_Fwd:
|
case CT_Operator_Fwd:
|
||||||
case CT_Operator_Member_Fwd:
|
case CT_Operator_Member_Fwd:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->Specs ? code_to_string(self->Specs) : "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: %S", self->ReturnType ? code_to_string(self->ReturnType) : "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 : %S", self->Params ? code_to_string(self->Params) : "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 : %S", operator_to_str( self->Op ) );
|
string_append_fmt( result, "\n\tOp : %SC", operator_to_str( self->Op ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Operator_Cast:
|
case CT_Operator_Cast:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tSpecs : %S", self->Specs ? code_to_string(self->Specs) : "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 : %S", self->ValueType ? code_to_string(self->ValueType) : "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 : %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Operator_Cast_Fwd:
|
case CT_Operator_Cast_Fwd:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tSpecs : %S", self->Specs ? code_to_string(self->Specs) : "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 : %S", self->ValueType ? code_to_string(self->ValueType) : "Null" );
|
string_append_fmt( result, "\n\tValueType : %SC", self->ValueType ? string_to_strc( code_to_string(self->ValueType)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Parameters:
|
case CT_Parameters:
|
||||||
string_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
string_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
||||||
string_append_fmt( result, "\n\tLast : %S", self->Last->Name );
|
string_append_fmt( result, "\n\tLast : %SC", self->Last->Name );
|
||||||
string_append_fmt( result, "\n\tNext : %S", self->Next->Name );
|
string_append_fmt( result, "\n\tNext : %SC", self->Next->Name );
|
||||||
string_append_fmt( result, "\n\tValueType : %S", self->ValueType ? code_to_string(self->ValueType) : "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\tValue : %S", self->Value ? code_to_string(self->Value) : "Null" );
|
string_append_fmt( result, "\n\tValue : %SC", self->Value ? string_to_strc( code_to_string(self->Value)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Specifiers:
|
case CT_Specifiers:
|
||||||
@ -275,57 +275,57 @@ char const* code_debug_str(Code self)
|
|||||||
string_append_fmt( result, "%.*s, ", spec.Len, spec.Ptr );
|
string_append_fmt( result, "%.*s, ", spec.Len, spec.Ptr );
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
string_append_fmt( result, "\n\tNextSpecs: %S", self->NextSpecs ? code_debug_str(self->NextSpecs) : "Null" );
|
string_append_fmt( result, "\n\tNextSpecs: %SC", self->NextSpecs ? code_debug_str(self->NextSpecs) : txt("Null") );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Template:
|
case CT_Template:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tParams : %S", self->Params ? code_to_string(self->Params) : "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: %S", self->Declaration ? code_to_string(self->Declaration) : "Null" );
|
string_append_fmt( result, "\n\tDeclaration: %SC", self->Declaration ? string_to_strc( code_to_string(self->Declaration)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Typedef:
|
case CT_Typedef:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? code_to_string(self->UnderlyingType) : "Null" );
|
string_append_fmt( result, "\n\tUnderlyingType: %SC", self->UnderlyingType ? string_to_strc( code_to_string(self->UnderlyingType)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Typename:
|
case CT_Typename:
|
||||||
string_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->Specs ? code_to_string(self->Specs) : "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 : %S", self->ReturnType ? code_to_string(self->ReturnType) : "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 : %S", self->Params ? code_to_string(self->Params) : "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 : %S", self->ArrExpr ? code_to_string(self->ArrExpr) : "Null" );
|
string_append_fmt( result, "\n\tArrExpr : %SC", self->ArrExpr ? string_to_strc( code_to_string(self->ArrExpr)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Union:
|
case CT_Union:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->Body ? code_debug_str(self->Body) : "Null" );
|
string_append_fmt( result, "\n\tBody : %SC", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Using:
|
case CT_Using:
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? code_to_string(self->Attributes) : "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: %S", self->UnderlyingType ? code_to_string(self->UnderlyingType) : "Null" );
|
string_append_fmt( result, "\n\tUnderlyingType: %SC", self->UnderlyingType ? string_to_strc( code_to_string(self->UnderlyingType)) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CT_Variable:
|
case CT_Variable:
|
||||||
@ -333,29 +333,29 @@ char const* code_debug_str(Code self)
|
|||||||
if ( self->Parent && self->Parent->Type == CT_Variable )
|
if ( self->Parent && self->Parent->Type == CT_Variable )
|
||||||
{
|
{
|
||||||
// Its a NextVar
|
// Its a NextVar
|
||||||
string_append_fmt( result, "\n\tSpecs : %S", self->Specs ? code_to_string(self->Specs) : "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\tValue : %S", self->Value ? code_to_string(self->Value) : "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: %S", self->BitfieldSize ? code_to_string(self->BitfieldSize) : "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 : %S", self->NextVar ? code_debug_str(self->NextVar) : "Null" );
|
string_append_fmt( result, "\n\tNextVar : %SC", self->NextVar ? code_debug_str(self->NextVar) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( self->Prev )
|
if ( self->Prev )
|
||||||
string_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tPrev: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
if ( self->Next )
|
if ( self->Next )
|
||||||
string_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name ? self->Prev->Name : "Null" );
|
string_append_fmt( result, "\n\tNext: %SC %SC", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
||||||
|
|
||||||
string_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : "Null" );
|
string_append_fmt( result, "\n\tInlineCmt : %SC", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
||||||
string_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? code_to_string(self->Attributes) : "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 : %S", self->Specs ? code_to_string(self->Specs) : "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 : %S", self->ValueType ? code_to_string(self->ValueType) : "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: %S", self->BitfieldSize ? code_to_string(self->BitfieldSize) : "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 : %S", self->Value ? code_to_string(self->Value) : "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 : %S", self->NextVar ? code_debug_str(self->NextVar) : "Null" );
|
string_append_fmt( result, "\n\tNextVar : %SC", self->NextVar ? code_debug_str(self->NextVar) : txt("Null") );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return * result;
|
return string_to_strc( * result );
|
||||||
}
|
}
|
||||||
|
|
||||||
Code code_duplicate(Code self)
|
Code code_duplicate(Code self)
|
||||||
@ -366,7 +366,7 @@ Code code_duplicate(Code self)
|
|||||||
void* mem_self = rcast(void*, cast(AST*, self));
|
void* mem_self = rcast(void*, cast(AST*, self));
|
||||||
mem_copy( mem_result, mem_self, sizeof( AST ) );
|
mem_copy( mem_result, mem_self, sizeof( AST ) );
|
||||||
|
|
||||||
result->Parent = { nullptr };
|
result->Parent = NullCode;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ void code_to_string_ptr( Code self, String* result )
|
|||||||
{
|
{
|
||||||
case CT_Invalid:
|
case CT_Invalid:
|
||||||
#ifdef GEN_DONT_ALLOW_INVALID_CODE
|
#ifdef GEN_DONT_ALLOW_INVALID_CODE
|
||||||
log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->code_debug_str() : Name );
|
log_failure("Attempted to serialize invalid code! - %SC", Parent ? Parent->code_debug_str() : Name );
|
||||||
#else
|
#else
|
||||||
string_append_fmt( result, "Invalid Code!" );
|
string_append_fmt( result, "Invalid Code!" );
|
||||||
#endif
|
#endif
|
||||||
@ -604,13 +604,13 @@ bool code_is_equal( Code self, Code other )
|
|||||||
*/
|
*/
|
||||||
if ( other == nullptr )
|
if ( other == nullptr )
|
||||||
{
|
{
|
||||||
log_fmt( "AST::is_equal: other is null\nAST: %S", code_debug_str(self) );
|
log_fmt( "AST::is_equal: other is null\nAST: %SC", code_debug_str(self) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( self->Type != other->Type )
|
if ( self->Type != other->Type )
|
||||||
{
|
{
|
||||||
log_fmt("AST::is_equal: Type check failure with other\nAST: %S\nOther: %S"
|
log_fmt("AST::is_equal: Type check failure with other\nAST: %SC\nOther: %SC"
|
||||||
, code_debug_str(self)
|
, code_debug_str(self)
|
||||||
,code_debug_str(other)
|
,code_debug_str(other)
|
||||||
);
|
);
|
||||||
@ -624,8 +624,8 @@ bool code_is_equal( Code self, Code other )
|
|||||||
if ( self->val != other->val ) \
|
if ( self->val != other->val ) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt("\nAST::is_equal: Member - " #val " failed\n" \
|
log_fmt("\nAST::is_equal: Member - " #val " failed\n" \
|
||||||
"AST : %S\n" \
|
"AST : %SC\n" \
|
||||||
"Other: %S\n" \
|
"Other: %SC\n" \
|
||||||
, code_debug_str(self) \
|
, code_debug_str(self) \
|
||||||
,code_debug_str(other) \
|
,code_debug_str(other) \
|
||||||
); \
|
); \
|
||||||
@ -634,11 +634,11 @@ bool code_is_equal( Code self, Code other )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define check_member_str( str ) \
|
#define check_member_str( str ) \
|
||||||
if ( self->str != other->str ) \
|
if ( ! strc_are_equal( self->str, other->str ) ) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt("\nAST::is_equal: Member string - "#str " failed\n" \
|
log_fmt("\nAST::is_equal: Member string - "#str " failed\n" \
|
||||||
"AST : %S\n" \
|
"AST : %SC\n" \
|
||||||
"Other: %S\n" \
|
"Other: %SC\n" \
|
||||||
, code_debug_str(self) \
|
, code_debug_str(self) \
|
||||||
,code_debug_str(other) \
|
,code_debug_str(other) \
|
||||||
); \
|
); \
|
||||||
@ -647,19 +647,19 @@ bool code_is_equal( Code self, Code other )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define check_member_content( content ) \
|
#define check_member_content( content ) \
|
||||||
if ( self->content != other->content ) \
|
if ( ! strc_are_equal( self->content, other->content )) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt("\nAST::is_equal: Member content - "#content " failed\n" \
|
log_fmt("\nAST::is_equal: Member content - "#content " failed\n" \
|
||||||
"AST : %S\n" \
|
"AST : %SC\n" \
|
||||||
"Other: %S\n" \
|
"Other: %SC\n" \
|
||||||
, code_debug_str(self) \
|
, code_debug_str(self) \
|
||||||
, code_debug_str(other) \
|
, code_debug_str(other) \
|
||||||
); \
|
); \
|
||||||
\
|
\
|
||||||
log_fmt("Content cannot be trusted to be unique with this check " \
|
log_fmt("Content cannot be trusted to be unique with this check " \
|
||||||
"so it must be verified by eye for now\n" \
|
"so it must be verified by eye for now\n" \
|
||||||
"AST Content:\n%S\n" \
|
"AST Content:\n%SC\n" \
|
||||||
"Other Content:\n%S\n" \
|
"Other Content:\n%SC\n" \
|
||||||
, strc_visualize_whitespace(self->content, GlobalAllocator) \
|
, strc_visualize_whitespace(self->content, GlobalAllocator) \
|
||||||
, strc_visualize_whitespace(other->content, GlobalAllocator) \
|
, strc_visualize_whitespace(other->content, GlobalAllocator) \
|
||||||
); \
|
); \
|
||||||
@ -671,9 +671,9 @@ bool code_is_equal( Code self, Code other )
|
|||||||
if ( other->ast == nullptr ) \
|
if ( other->ast == nullptr ) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt("\nAST::is_equal: Failed for member " #ast " other equivalent param is null\n" \
|
log_fmt("\nAST::is_equal: Failed for member " #ast " other equivalent param is null\n" \
|
||||||
"AST : %s\n" \
|
"AST : %SC\n" \
|
||||||
"Other: %s\n" \
|
"Other: %SC\n" \
|
||||||
"For ast member: %s\n" \
|
"For ast member: %SC\n" \
|
||||||
, code_debug_str(self) \
|
, code_debug_str(self) \
|
||||||
, code_debug_str(other) \
|
, code_debug_str(other) \
|
||||||
, code_debug_str(self->ast) \
|
, 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 ) ) \
|
if ( ! code_is_equal(self->ast, other->ast ) ) \
|
||||||
{ \
|
{ \
|
||||||
log_fmt( "\nAST::is_equal: Failed for " #ast"\n" \
|
log_fmt( "\nAST::is_equal: Failed for " #ast"\n" \
|
||||||
"AST : %S\n" \
|
"AST : %SC\n" \
|
||||||
"Other: %S\n" \
|
"Other: %SC\n" \
|
||||||
"For ast member: %S\n" \
|
"For ast member: %SC\n" \
|
||||||
"other's ast member: %S\n" \
|
"other's ast member: %SC\n" \
|
||||||
, code_debug_str(self) \
|
, code_debug_str(self) \
|
||||||
, code_debug_str(other) \
|
, code_debug_str(other) \
|
||||||
, code_debug_str(self->ast) \
|
, code_debug_str(self->ast) \
|
||||||
@ -918,22 +918,22 @@ bool code_is_equal( Code self, Code other )
|
|||||||
if ( curr_other == nullptr )
|
if ( curr_other == nullptr )
|
||||||
{
|
{
|
||||||
log_fmt("\nAST::is_equal: Failed for parameter, other equivalent param is null\n"
|
log_fmt("\nAST::is_equal: Failed for parameter, other equivalent param is null\n"
|
||||||
"AST : %S\n"
|
"AST : %SC\n"
|
||||||
"Other: %S\n"
|
"Other: %SC\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %SC\n"
|
||||||
, code_debug_str(curr)
|
, code_debug_str(curr)
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( curr->Name != curr_other->Name )
|
if ( strc_are_equal(curr->Name, curr_other->Name) )
|
||||||
{
|
{
|
||||||
log_fmt( "\nAST::is_equal: Failed for parameter name check\n"
|
log_fmt( "\nAST::is_equal: Failed for parameter name check\n"
|
||||||
"AST : %S\n"
|
"AST : %SC\n"
|
||||||
"Other: %S\n"
|
"Other: %SC\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %SC\n"
|
||||||
"other's ast member: %S\n"
|
"other's ast member: %SC\n"
|
||||||
, code_debug_str(self)
|
, code_debug_str(self)
|
||||||
, code_debug_str(other)
|
, code_debug_str(other)
|
||||||
, code_debug_str(curr)
|
, 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) )
|
if ( curr->ValueType && ! code_is_equal(curr->ValueType, curr_other->ValueType) )
|
||||||
{
|
{
|
||||||
log_fmt( "\nAST::is_equal: Failed for parameter value type check\n"
|
log_fmt( "\nAST::is_equal: Failed for parameter value type check\n"
|
||||||
"AST : %S\n"
|
"AST : %SC\n"
|
||||||
"Other: %S\n"
|
"Other: %SC\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %SC\n"
|
||||||
"other's ast member: %S\n"
|
"other's ast member: %SC\n"
|
||||||
, code_debug_str(self)
|
, code_debug_str(self)
|
||||||
, code_debug_str(other)
|
, code_debug_str(other)
|
||||||
, code_debug_str(curr)
|
, 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) )
|
if ( curr->Value && ! code_is_equal(curr->Value, curr_other->Value) )
|
||||||
{
|
{
|
||||||
log_fmt( "\nAST::is_equal: Failed for parameter value check\n"
|
log_fmt( "\nAST::is_equal: Failed for parameter value check\n"
|
||||||
"AST : %S\n"
|
"AST : %SC\n"
|
||||||
"Other: %S\n"
|
"Other: %SC\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %SC\n"
|
||||||
"other's ast member: %S\n"
|
"other's ast member: %SC\n"
|
||||||
, code_debug_str(self)
|
, code_debug_str(self)
|
||||||
, code_debug_str(other)
|
, code_debug_str(other)
|
||||||
, code_debug_str(curr)
|
, code_debug_str(curr)
|
||||||
@ -1117,10 +1117,10 @@ bool code_is_equal( Code self, Code other )
|
|||||||
if ( curr_other == nullptr )
|
if ( curr_other == nullptr )
|
||||||
{
|
{
|
||||||
log_fmt("\nAST::is_equal: Failed for body, other equivalent param is null\n"
|
log_fmt("\nAST::is_equal: Failed for body, other equivalent param is null\n"
|
||||||
"AST : %S\n"
|
"AST : %SC\n"
|
||||||
"Other: %S\n"
|
"Other: %SC\n"
|
||||||
"For ast member: %S\n"
|
|
||||||
, code_debug_str(curr)
|
, code_debug_str(curr)
|
||||||
|
, code_debug_str(other)
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -1129,10 +1129,10 @@ bool code_is_equal( Code self, Code other )
|
|||||||
if ( ! code_is_equal( curr, curr_other ) )
|
if ( ! code_is_equal( curr, curr_other ) )
|
||||||
{
|
{
|
||||||
log_fmt( "\nAST::is_equal: Failed for body\n"
|
log_fmt( "\nAST::is_equal: Failed for body\n"
|
||||||
"AST : %S\n"
|
"AST : %SC\n"
|
||||||
"Other: %S\n"
|
"Other: %SC\n"
|
||||||
"For ast member: %S\n"
|
"For ast member: %SC\n"
|
||||||
"other's ast member: %S\n"
|
"other's ast member: %SC\n"
|
||||||
, code_debug_str(self)
|
, code_debug_str(self)
|
||||||
, code_debug_str(other)
|
, code_debug_str(other)
|
||||||
, code_debug_str(curr)
|
, code_debug_str(curr)
|
||||||
@ -1170,7 +1170,7 @@ bool code_validate_body(Code self)
|
|||||||
switch ( code_entry->Type ) \
|
switch ( code_entry->Type ) \
|
||||||
{ \
|
{ \
|
||||||
Unallowed_Types \
|
Unallowed_Types \
|
||||||
log_failure( "AST::validate_body: Invalid entry in body %s", code_debug_str(code_entry) ); \
|
log_failure( "AST::validate_body: Invalid entry in body %SC", code_debug_str(code_entry) ); \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -1191,7 +1191,7 @@ bool code_validate_body(Code self)
|
|||||||
{
|
{
|
||||||
if ( entry->Type != CT_Untyped )
|
if ( entry->Type != CT_Untyped )
|
||||||
{
|
{
|
||||||
log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %s", GEN_NS code_debug_str(entry) );
|
log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %SC", code_debug_str(entry) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1236,7 +1236,7 @@ bool code_validate_body(Code self)
|
|||||||
case CT_Specifiers:
|
case CT_Specifiers:
|
||||||
case CT_Struct_Body:
|
case CT_Struct_Body:
|
||||||
case CT_Typename:
|
case CT_Typename:
|
||||||
log_failure("AST::validate_body: Invalid entry in body %s", GEN_NS code_debug_str(entry));
|
log_failure("AST::validate_body: Invalid entry in body %SC", code_debug_str(entry));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1259,7 +1259,7 @@ bool code_validate_body(Code self)
|
|||||||
{
|
{
|
||||||
if ( entry->Type != CT_Untyped )
|
if ( entry->Type != CT_Untyped )
|
||||||
{
|
{
|
||||||
log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %s", GEN_NS code_debug_str(entry) );
|
log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %SC", code_debug_str(entry) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1267,7 +1267,7 @@ bool code_validate_body(Code self)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_failure( "AST::validate_body: Invalid this AST does not have a body %s", code_debug_str(self) );
|
log_failure( "AST::validate_body: Invalid this AST does not have a body %SC", code_debug_str(self) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast(
|
|||||||
#pragma region Code C-Interface
|
#pragma region Code C-Interface
|
||||||
|
|
||||||
void code_append (Code code, Code other );
|
void code_append (Code code, Code other );
|
||||||
char const* code_debug_str (Code code);
|
StrC code_debug_str (Code code);
|
||||||
Code code_duplicate (Code code);
|
Code code_duplicate (Code code);
|
||||||
Code* code_entry (Code code, u32 idx );
|
Code* code_entry (Code code, u32 idx );
|
||||||
bool code_has_entries (Code code);
|
bool code_has_entries (Code code);
|
||||||
@ -198,7 +198,7 @@ bool code_is_valid (Code code);
|
|||||||
void code_set_global (Code code);
|
void code_set_global (Code code);
|
||||||
String code_to_string (Code self );
|
String code_to_string (Code self );
|
||||||
void code_to_string_ptr(Code self, String* result );
|
void code_to_string_ptr(Code self, String* result );
|
||||||
char const* code_type_str (Code self );
|
StrC code_type_str (Code self );
|
||||||
bool code_validate_body(Code self );
|
bool code_validate_body(Code self );
|
||||||
|
|
||||||
#pragma endregion Code C-Interface
|
#pragma endregion Code C-Interface
|
||||||
@ -214,7 +214,7 @@ struct Code
|
|||||||
AST* ast;
|
AST* ast;
|
||||||
|
|
||||||
# define Using_Code( Typename ) \
|
# define Using_Code( Typename ) \
|
||||||
forceinline char const* debug_str() { return code_debug_str(* this); } \
|
forceinline StrC debug_str() { return code_debug_str(* this); } \
|
||||||
forceinline Code duplicate() { return code_duplicate(* this); } \
|
forceinline Code duplicate() { return code_duplicate(* this); } \
|
||||||
forceinline bool is_equal( Code other ) { return code_is_equal(* this, other); } \
|
forceinline bool is_equal( Code other ) { return code_is_equal(* this, other); } \
|
||||||
forceinline bool is_body() { return code_is_body(* this); } \
|
forceinline bool is_body() { return code_is_body(* this); } \
|
||||||
@ -236,7 +236,7 @@ struct Code
|
|||||||
forceinline bool has_entries() { return code_has_entries(* this); }
|
forceinline bool has_entries() { return code_has_entries(* this); }
|
||||||
forceinline String to_string() { return code_to_string(* this); }
|
forceinline String to_string() { return code_to_string(* this); }
|
||||||
forceinline void to_string(String& result) { return code_to_string_ptr(* this, & result); }
|
forceinline void to_string(String& result) { return code_to_string_ptr(* this, & result); }
|
||||||
forceinline char const* type_str() { return code_type_str(* this); }
|
forceinline StrC type_str() { return code_type_str(* this); }
|
||||||
forceinline bool validate_body() { return code_validate_body(*this); }
|
forceinline bool validate_body() { return code_validate_body(*this); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3,13 +3,15 @@
|
|||||||
#include "ast.cpp"
|
#include "ast.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
forceinline
|
inline
|
||||||
String attributes_to_string(CodeAttributes attributes) {
|
String attributes_to_string(CodeAttributes attributes) {
|
||||||
GEN_ASSERT(attributes);
|
GEN_ASSERT(attributes);
|
||||||
return {(char*) strc_duplicate( attributes->Content, GlobalAllocator ).Ptr};
|
char* raw = ccast(char*, strc_duplicate( attributes->Content, GlobalAllocator ).Ptr);
|
||||||
|
String result = { raw };
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
forceinline
|
inline
|
||||||
void attributes_to_string_ref(CodeAttributes attributes, String* result) {
|
void attributes_to_string_ref(CodeAttributes attributes, String* result) {
|
||||||
GEN_ASSERT(attributes);
|
GEN_ASSERT(attributes);
|
||||||
GEN_ASSERT(result);
|
GEN_ASSERT(result);
|
||||||
@ -77,13 +79,15 @@ void body_to_string_export( CodeBody body, String* result )
|
|||||||
string_append_fmt( result, "};\n" );
|
string_append_fmt( result, "};\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
forceinline
|
inline
|
||||||
String comment_to_string(CodeComment comment) {
|
String comment_to_string(CodeComment comment) {
|
||||||
GEN_ASSERT(comment);
|
GEN_ASSERT(comment);
|
||||||
return {(char*) strc_duplicate( comment->Content, GlobalAllocator ).Ptr};
|
char* raw = ccast(char*, strc_duplicate( comment->Content, GlobalAllocator ).Ptr);
|
||||||
|
String result = { raw };
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
forceinline
|
inline
|
||||||
void comment_to_string_ref(CodeComment comment, String* result) {
|
void comment_to_string_ref(CodeComment comment, String* result) {
|
||||||
GEN_ASSERT(comment);
|
GEN_ASSERT(comment);
|
||||||
GEN_ASSERT(result);
|
GEN_ASSERT(result);
|
||||||
@ -184,9 +188,8 @@ void class_to_string_def( CodeClass self, String* result )
|
|||||||
|
|
||||||
if ( self->ParentType )
|
if ( self->ParentType )
|
||||||
{
|
{
|
||||||
char const* access_level = access_spec_to_str( self->ParentAccess );
|
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) );
|
||||||
string_append_fmt( result, "%SC : %s %S", self->Name, access_level, typename_to_string(self->ParentType) );
|
|
||||||
|
|
||||||
CodeTypename interface = cast(CodeTypename, self->ParentType->Next);
|
CodeTypename interface = cast(CodeTypename, self->ParentType->Next);
|
||||||
if ( interface )
|
if ( interface )
|
||||||
@ -195,10 +198,10 @@ void class_to_string_def( CodeClass self, String* result )
|
|||||||
while ( interface )
|
while ( interface )
|
||||||
{
|
{
|
||||||
string_append_fmt( result, ", %S", typename_to_string(interface) );
|
string_append_fmt( result, ", %S", typename_to_string(interface) );
|
||||||
interface = interface->Next ? cast(CodeTypename, interface->Next) : CodeTypename { nullptr };
|
interface = interface->Next ? cast(CodeTypename, interface->Next) : NullCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( self->Name )
|
else if ( self->Name.Len )
|
||||||
{
|
{
|
||||||
string_append_strc( result, self->Name );
|
string_append_strc( result, self->Name );
|
||||||
}
|
}
|
||||||
@ -263,7 +266,7 @@ String destructor_to_string(CodeDestructor self)
|
|||||||
|
|
||||||
void destructor_to_string_def(CodeDestructor self, String* result )
|
void destructor_to_string_def(CodeDestructor self, String* result )
|
||||||
{
|
{
|
||||||
if ( self->Name )
|
if ( self->Name.Len )
|
||||||
{
|
{
|
||||||
string_append_fmt( result, "%SC()", self->Name );
|
string_append_fmt( result, "%SC()", self->Name );
|
||||||
}
|
}
|
||||||
@ -439,7 +442,10 @@ void enum_to_string_class_fwd(CodeEnum self, String* result )
|
|||||||
|
|
||||||
String exec_to_string(CodeExec exec)
|
String exec_to_string(CodeExec exec)
|
||||||
{
|
{
|
||||||
return {(char*) strc_duplicate( exec->Content, GlobalAllocator ).Ptr};
|
GEN_ASSERT(exec);
|
||||||
|
char* raw = ccast(char*, strc_duplicate( exec->Content, GlobalAllocator ).Ptr);
|
||||||
|
String result = { raw };
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void extern_to_string(CodeExtern self, String* result )
|
void extern_to_string(CodeExtern self, String* result )
|
||||||
@ -622,10 +628,10 @@ String module_to_string(CodeModule self)
|
|||||||
|
|
||||||
void module_to_string_ref(CodeModule self, String* result )
|
void module_to_string_ref(CodeModule self, String* result )
|
||||||
{
|
{
|
||||||
if (((u32(ModuleFlag_Export) & u32(self->ModuleFlags)) == u32(ModuleFlag_Export)))
|
if (((scast(u32, ModuleFlag_Export) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Export)))
|
||||||
string_append_strc( result, txt("export "));
|
string_append_strc( result, txt("export "));
|
||||||
|
|
||||||
if (((u32(ModuleFlag_Import) & u32(self->ModuleFlags)) == u32(ModuleFlag_Import)))
|
if (((scast(u32, ModuleFlag_Import) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Import)))
|
||||||
string_append_strc( result, txt("import "));
|
string_append_strc( result, txt("import "));
|
||||||
|
|
||||||
string_append_fmt( result, "%SC;\n", self->Name );
|
string_append_fmt( result, "%SC;\n", self->Name );
|
||||||
@ -796,7 +802,7 @@ void opcast_to_string_def(CodeOpCast self, String* result )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( self->Name && self->Name.Len )
|
if ( self->Name.Ptr && self->Name.Len )
|
||||||
string_append_fmt( result, "%SC operator %S()", self->Name, typename_to_string(self->ValueType) );
|
string_append_fmt( result, "%SC operator %S()", self->Name, typename_to_string(self->ValueType) );
|
||||||
else
|
else
|
||||||
string_append_fmt( result, "operator %S()", typename_to_string(self->ValueType) );
|
string_append_fmt( result, "operator %S()", typename_to_string(self->ValueType) );
|
||||||
@ -814,7 +820,7 @@ void opcast_to_string_def(CodeOpCast self, String* result )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( self->Name && self->Name.Len )
|
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) );
|
string_append_fmt( result, "%SC operator %S()\n{\n%S\n}\n", self->Name, typename_to_string(self->ValueType), body_to_string(self->Body) );
|
||||||
else
|
else
|
||||||
string_append_fmt( result, "operator %S()\n{\n%S\n}\n", typename_to_string(self->ValueType), body_to_string(self->Body) );
|
string_append_fmt( result, "operator %S()\n{\n%S\n}\n", typename_to_string(self->ValueType), body_to_string(self->Body) );
|
||||||
@ -877,7 +883,7 @@ void params_to_string_ref( CodeParam self, String* result )
|
|||||||
// Could also be: ( <macro> <type <name>, ... )
|
// Could also be: ( <macro> <type <name>, ... )
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( self->Name )
|
if ( self->Name.Ptr && self->Name.Len )
|
||||||
{
|
{
|
||||||
if ( self->ValueType == nullptr )
|
if ( self->ValueType == nullptr )
|
||||||
string_append_fmt( result, " %SC", self->Name );
|
string_append_fmt( result, " %SC", self->Name );
|
||||||
@ -1036,9 +1042,9 @@ void struct_to_string_def( CodeStruct self, String* result )
|
|||||||
|
|
||||||
if ( self->ParentType )
|
if ( self->ParentType )
|
||||||
{
|
{
|
||||||
char const* access_level = access_spec_to_str( self->ParentAccess );
|
StrC access_level = access_spec_to_str( self->ParentAccess );
|
||||||
|
|
||||||
string_append_fmt( result, "%SC : %s %S", self->Name, access_level, typename_to_string(self->ParentType) );
|
string_append_fmt( result, "%SC : %SC %S", self->Name, access_level, typename_to_string(self->ParentType) );
|
||||||
|
|
||||||
CodeTypename interface = cast(CodeTypename, self->ParentType->Next);
|
CodeTypename interface = cast(CodeTypename, self->ParentType->Next);
|
||||||
if ( interface )
|
if ( interface )
|
||||||
@ -1047,10 +1053,10 @@ void struct_to_string_def( CodeStruct self, String* result )
|
|||||||
while ( interface )
|
while ( interface )
|
||||||
{
|
{
|
||||||
string_append_fmt( result, ", %S", typename_to_string(interface) );
|
string_append_fmt( result, ", %S", typename_to_string(interface) );
|
||||||
interface = interface->Next ? cast( CodeTypename, interface->Next) : CodeTypename { nullptr };
|
interface = interface->Next ? cast( CodeTypename, interface->Next) : NullCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( self->Name )
|
else if ( self->Name.Len )
|
||||||
{
|
{
|
||||||
string_append_strc( result, self->Name );
|
string_append_strc( result, self->Name );
|
||||||
}
|
}
|
||||||
@ -1238,7 +1244,7 @@ void union_to_string_def(CodeUnion self, String* result )
|
|||||||
if ( self->Attributes )
|
if ( self->Attributes )
|
||||||
string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) );
|
string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) );
|
||||||
|
|
||||||
if ( self->Name )
|
if ( self->Name.Len )
|
||||||
{
|
{
|
||||||
string_append_fmt( result, "%SC\n{\n%S\n}"
|
string_append_fmt( result, "%SC\n{\n%S\n}"
|
||||||
, self->Name
|
, self->Name
|
||||||
@ -1269,7 +1275,7 @@ void union_to_string_fwd(CodeUnion self, String* result )
|
|||||||
if ( self->Attributes )
|
if ( self->Attributes )
|
||||||
string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) );
|
string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) );
|
||||||
|
|
||||||
if ( self->Name )
|
if ( self->Name.Len )
|
||||||
{
|
{
|
||||||
string_append_fmt( result, "%SC", self->Name);
|
string_append_fmt( result, "%SC", self->Name);
|
||||||
}
|
}
|
||||||
@ -1331,7 +1337,7 @@ void using_to_string_ref(CodeUsing self, String* result )
|
|||||||
string_append_strc( result, txt("\n"));
|
string_append_strc( result, txt("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
forceinline
|
inline
|
||||||
void using_to_string_ns(CodeUsing self, String* result )
|
void using_to_string_ns(CodeUsing self, String* result )
|
||||||
{
|
{
|
||||||
GEN_ASSERT(self);
|
GEN_ASSERT(self);
|
||||||
@ -1342,7 +1348,7 @@ void using_to_string_ns(CodeUsing self, String* result )
|
|||||||
string_append_fmt( result, "using namespace %SC;\n", self->Name );
|
string_append_fmt( result, "using namespace %SC;\n", self->Name );
|
||||||
}
|
}
|
||||||
|
|
||||||
forceinline
|
inline
|
||||||
String var_to_string(CodeVar self)
|
String var_to_string(CodeVar self)
|
||||||
{
|
{
|
||||||
GEN_ASSERT(self);
|
GEN_ASSERT(self);
|
||||||
|
@ -101,10 +101,10 @@ Code& Code::operator ++()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
forceinline
|
forceinline
|
||||||
char const* code_type_str(Code self)
|
StrC code_type_str(Code self)
|
||||||
{
|
{
|
||||||
GEN_ASSERT(self != nullptr);
|
GEN_ASSERT(self != nullptr);
|
||||||
return codetype_to_str( self->Type ).Ptr;
|
return codetype_to_str( self->Type );
|
||||||
}
|
}
|
||||||
#pragma endregion Code
|
#pragma endregion Code
|
||||||
|
|
||||||
|
@ -101,10 +101,12 @@ void define_constants()
|
|||||||
access_public->Name = get_cached_string( txt("public:\n") );
|
access_public->Name = get_cached_string( txt("public:\n") );
|
||||||
code_set_global(access_public);
|
code_set_global(access_public);
|
||||||
|
|
||||||
attrib_api_export = def_attributes( code(GEN_API_Export_Code));
|
StrC api_export_str = code(GEN_API_Export_Code);
|
||||||
|
attrib_api_export = def_attributes( api_export_str );
|
||||||
code_set_global(cast(Code, attrib_api_export));
|
code_set_global(cast(Code, attrib_api_export));
|
||||||
|
|
||||||
attrib_api_import = def_attributes( code(GEN_API_Import_Code));
|
StrC api_import_str = code(GEN_API_Import_Code);
|
||||||
|
attrib_api_import = def_attributes( api_import_str );
|
||||||
code_set_global(cast(Code, attrib_api_import));
|
code_set_global(cast(Code, attrib_api_import));
|
||||||
|
|
||||||
module_global_fragment = make_code();
|
module_global_fragment = make_code();
|
||||||
@ -144,8 +146,13 @@ void define_constants()
|
|||||||
code_set_global((Code)preprocess_endif);
|
code_set_global((Code)preprocess_endif);
|
||||||
|
|
||||||
# define def_constant_code_type( Type_ ) \
|
# define def_constant_code_type( Type_ ) \
|
||||||
t_##Type_ = def_type( name(Type_) ); \
|
do \
|
||||||
code_set_global( cast(Code, t_##Type_));
|
{ \
|
||||||
|
Opts_def_type ops = {}; \
|
||||||
|
StrC name_str = name(Type_); \
|
||||||
|
t_##Type_ = def_type( name_str, ops ); \
|
||||||
|
code_set_global( cast(Code, t_##Type_)); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
def_constant_code_type( auto );
|
def_constant_code_type( auto );
|
||||||
def_constant_code_type( void );
|
def_constant_code_type( void );
|
||||||
@ -237,9 +244,10 @@ void init()
|
|||||||
{
|
{
|
||||||
// Setup global allocator
|
// Setup global allocator
|
||||||
{
|
{
|
||||||
GlobalAllocator = AllocatorInfo { & Global_Allocator_Proc, nullptr };
|
AllocatorInfo becasue_C = { & Global_Allocator_Proc, nullptr };
|
||||||
|
GlobalAllocator = becasue_C;
|
||||||
|
|
||||||
Global_AllocatorBuckets = array_init_reserve<Arena>( heap(), 128 );
|
Global_AllocatorBuckets = array_init_reserve(Arena, heap(), 128 );
|
||||||
|
|
||||||
if ( Global_AllocatorBuckets == nullptr )
|
if ( Global_AllocatorBuckets == nullptr )
|
||||||
GEN_FATAL( "Failed to reserve memory for Global_AllocatorBuckets");
|
GEN_FATAL( "Failed to reserve memory for Global_AllocatorBuckets");
|
||||||
@ -252,14 +260,33 @@ void init()
|
|||||||
array_append( Global_AllocatorBuckets, bucket );
|
array_append( Global_AllocatorBuckets, bucket );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Allocator_DataArrays.Proc == nullptr) {
|
||||||
|
Allocator_DataArrays = heap();
|
||||||
|
}
|
||||||
|
if (Allocator_CodePool.Proc == nullptr ) {
|
||||||
|
Allocator_CodePool = heap();
|
||||||
|
}
|
||||||
|
if (Allocator_Lexer.Proc == nullptr) {
|
||||||
|
Allocator_Lexer = heap();
|
||||||
|
}
|
||||||
|
if (Allocator_StringArena.Proc == nullptr) {
|
||||||
|
Allocator_StringArena = heap();
|
||||||
|
}
|
||||||
|
if (Allocator_StringTable.Proc == nullptr) {
|
||||||
|
Allocator_StringTable = heap();
|
||||||
|
}
|
||||||
|
if (Allocator_TypeTable.Proc == nullptr) {
|
||||||
|
Allocator_TypeTable = heap();
|
||||||
|
}
|
||||||
|
|
||||||
// Setup the arrays
|
// Setup the arrays
|
||||||
{
|
{
|
||||||
CodePools = array_init_reserve<Pool>( Allocator_DataArrays, InitSize_DataArrays );
|
CodePools = array_init_reserve(Pool, Allocator_DataArrays, InitSize_DataArrays );
|
||||||
|
|
||||||
if ( CodePools == nullptr )
|
if ( CodePools == nullptr )
|
||||||
GEN_FATAL( "gen::init: Failed to initialize the CodePools array" );
|
GEN_FATAL( "gen::init: Failed to initialize the CodePools array" );
|
||||||
|
|
||||||
StringArenas = array_init_reserve<Arena>( Allocator_DataArrays, InitSize_DataArrays );
|
StringArenas = array_init_reserve(Arena, Allocator_DataArrays, InitSize_DataArrays );
|
||||||
|
|
||||||
if ( StringArenas == nullptr )
|
if ( StringArenas == nullptr )
|
||||||
GEN_FATAL( "gen::init: Failed to initialize the StringArenas array" );
|
GEN_FATAL( "gen::init: Failed to initialize the StringArenas array" );
|
||||||
@ -286,14 +313,14 @@ void init()
|
|||||||
|
|
||||||
// Setup the hash tables
|
// Setup the hash tables
|
||||||
{
|
{
|
||||||
StringCache = hashtable_init<StringCached>(Allocator_StringTable);
|
StringCache = hashtable_init(StringCached, Allocator_StringTable);
|
||||||
|
|
||||||
if ( StringCache.Entries == nullptr )
|
if ( StringCache.Entries == nullptr )
|
||||||
GEN_FATAL( "gen::init: Failed to initialize the StringCache");
|
GEN_FATAL( "gen::init: Failed to initialize the StringCache");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preprocessor Defines
|
// Preprocessor Defines
|
||||||
PreprocessorDefines = array_init_reserve<StringCached>( GlobalAllocator, kilobytes(1) );
|
PreprocessorDefines = array_init_reserve(StringCached, GlobalAllocator, kilobytes(1) );
|
||||||
|
|
||||||
define_constants();
|
define_constants();
|
||||||
GEN_NS_PARSER init();
|
GEN_NS_PARSER init();
|
||||||
@ -377,7 +404,7 @@ AllocatorInfo get_string_allocator( s32 str_length )
|
|||||||
|
|
||||||
usize size_req = str_length + sizeof(StringHeader) + sizeof(char*);
|
usize size_req = str_length + sizeof(StringHeader) + sizeof(char*);
|
||||||
|
|
||||||
if ( last->TotalUsed + ssize(size_req) > last->TotalSize )
|
if ( last->TotalUsed + scast(ssize, size_req) > last->TotalSize )
|
||||||
{
|
{
|
||||||
Arena new_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena );
|
Arena new_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena );
|
||||||
|
|
||||||
@ -405,7 +432,7 @@ StringCached get_cached_string( StrC str )
|
|||||||
StrC result = string_to_strc( string_make_strc( get_string_allocator( str.Len ), str ));
|
StrC result = string_to_strc( string_make_strc( get_string_allocator( str.Len ), str ));
|
||||||
hashtable_set(StringCache, key, result );
|
hashtable_set(StringCache, key, result );
|
||||||
|
|
||||||
return { str.Len, result };
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used internally to retireve a Code object form the CodePool.
|
// Used internally to retireve a Code object form the CodePool.
|
||||||
@ -425,20 +452,8 @@ Code make_code()
|
|||||||
allocator = array_back( CodePools);
|
allocator = array_back( CodePools);
|
||||||
}
|
}
|
||||||
|
|
||||||
Code result { rcast( AST*, alloc( pool_allocator_info(allocator), sizeof(AST) )) };
|
Code result = { rcast( AST*, alloc( pool_allocator_info(allocator), sizeof(AST) )) };
|
||||||
mem_set( rcast(void*, cast(AST*, result)), 0, sizeof(AST) );
|
mem_set( rcast(void*, cast(AST*, result)), 0, sizeof(AST) );
|
||||||
// result->Type = ECode::Invalid;
|
|
||||||
|
|
||||||
// result->Content = { nullptr };
|
|
||||||
// result->Prev = { nullptr };
|
|
||||||
// result->Next = { nullptr };
|
|
||||||
// result->Token = nullptr;
|
|
||||||
// result->Parent = { nullptr };
|
|
||||||
// result->Name = { nullptr };
|
|
||||||
// result->Type = ECode::Invalid;
|
|
||||||
// result->ModuleFlags = ModuleFlag::Invalid;
|
|
||||||
// result->NumEntries = 0;
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ Code untyped_token_fmt( char const* fmt, s32 num_tokens, ... );
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
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 (StrC) and returns a StrC of the formatted string.
|
||||||
Tokens are provided in '<'identifier'>' format where '<' '>' are just angle brakcets (you can change it in token_fmt_va)
|
Tokens are provided in '<'identifier'>' format where '<' '>' are just angle brackets (you can change it in token_fmt_va)
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
Example - A string with:
|
Example - A string with:
|
||||||
typedef <type> <name> <name>;
|
typedef <type> <name> <name>;
|
||||||
@ -310,7 +310,7 @@ Code untyped_token_fmt( char const* fmt, s32 num_tokens, ... );
|
|||||||
"type", strc_for_type,
|
"type", strc_for_type,
|
||||||
"name", strc_for_name,
|
"name", strc_for_name,
|
||||||
and:
|
and:
|
||||||
stringize( typedef <type> <name> <name>; ) )
|
stringize( typedef <type> <name> <name>; )
|
||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
So the full call for this example would be:
|
So the full call for this example would be:
|
||||||
token_fmt(
|
token_fmt(
|
||||||
|
@ -5042,7 +5042,6 @@ CodeTypedef parse_typedef()
|
|||||||
Token pre_foward_tok = currtok;
|
Token pre_foward_tok = currtok;
|
||||||
if ( (idx - 3 ) == tokens.Idx )
|
if ( (idx - 3 ) == tokens.Idx )
|
||||||
{
|
{
|
||||||
log_fmt("Identified forward typedef\n");
|
|
||||||
// Its a forward declaration only
|
// Its a forward declaration only
|
||||||
type = parse_forward_or_definition( which, from_typedef );
|
type = parse_forward_or_definition( which, from_typedef );
|
||||||
// <ModuleFalgs> typedef <UnderlyingType: Forward Decl>
|
// <ModuleFalgs> typedef <UnderlyingType: Forward Decl>
|
||||||
|
@ -7,22 +7,22 @@
|
|||||||
|
|
||||||
// TODO : Convert global allocation strategy to use a slab allocation strategy.
|
// TODO : Convert global allocation strategy to use a slab allocation strategy.
|
||||||
global AllocatorInfo GlobalAllocator;
|
global AllocatorInfo GlobalAllocator;
|
||||||
global Array<Arena> Global_AllocatorBuckets;
|
global Array( Arena ) Global_AllocatorBuckets;
|
||||||
|
|
||||||
// TODO(Ed) : Make the code pool a dynamic arena
|
// TODO(Ed) : Make the code pool a dynamic arena
|
||||||
global Array< Pool > CodePools = { nullptr };
|
global Array( Pool ) CodePools = { nullptr };
|
||||||
global Array< Arena > StringArenas = { nullptr };
|
global Array( Arena ) StringArenas = { nullptr };
|
||||||
|
|
||||||
global StringTable StringCache;
|
global StringTable StringCache;
|
||||||
|
|
||||||
global Arena LexArena;
|
global Arena LexArena;
|
||||||
|
|
||||||
global AllocatorInfo Allocator_DataArrays = heap();
|
global AllocatorInfo Allocator_DataArrays = {0};
|
||||||
global AllocatorInfo Allocator_CodePool = heap();
|
global AllocatorInfo Allocator_CodePool = {0};
|
||||||
global AllocatorInfo Allocator_Lexer = heap();
|
global AllocatorInfo Allocator_Lexer = {0};
|
||||||
global AllocatorInfo Allocator_StringArena = heap();
|
global AllocatorInfo Allocator_StringArena = {0};
|
||||||
global AllocatorInfo Allocator_StringTable = heap();
|
global AllocatorInfo Allocator_StringTable = {0};
|
||||||
global AllocatorInfo Allocator_TypeTable = heap();
|
global AllocatorInfo Allocator_TypeTable = {0};
|
||||||
|
|
||||||
#pragma endregion StaticData
|
#pragma endregion StaticData
|
||||||
|
|
||||||
|
@ -44,18 +44,19 @@ enum AccessSpec : u32
|
|||||||
static_assert( size_of(AccessSpec) == size_of(u32), "AccessSpec not u32 size" );
|
static_assert( size_of(AccessSpec) == size_of(u32), "AccessSpec not u32 size" );
|
||||||
|
|
||||||
inline
|
inline
|
||||||
char const* access_spec_to_str( AccessSpec type )
|
StrC access_spec_to_str( AccessSpec type )
|
||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
char const* lookup[ (u32)AccessSpec_Num_AccessSpec ] = {
|
StrC lookup[ (u32)AccessSpec_Num_AccessSpec ] = {
|
||||||
"",
|
{ sizeof("") - 1, "" },
|
||||||
"private",
|
{ sizeof("prviate") - 1, "private" },
|
||||||
"protected",
|
{ sizeof("protected") - 1, "private" },
|
||||||
"public",
|
{ sizeof("public") - 1, "public" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StrC invalid = { sizeof("Invalid") - 1, "Invalid" };
|
||||||
if ( type > AccessSpec_Public )
|
if ( type > AccessSpec_Public )
|
||||||
return "Invalid";
|
return invalid;
|
||||||
|
|
||||||
return lookup[ (u32)type ];
|
return lookup[ (u32)type ];
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#ifndef bit
|
#ifndef bit
|
||||||
#define bit( Value ) ( 1 << Value )
|
#define bit( Value ) ( 1 << Value )
|
||||||
#define bitfield_is_equal( Type, Field, Mask ) ( (Type(Mask) & Type(Field)) == Type(Mask) )
|
#define bitfield_is_equal( Type, Field, Mask ) ( (scast(Type, Mask) & scast(Type, Field)) == scast(Type, Mask) )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Mainly intended for forcing the base library to utilize only C-valid constructs or type coercion
|
// Mainly intended for forcing the base library to utilize only C-valid constructs or type coercion
|
||||||
@ -317,10 +317,11 @@
|
|||||||
// The slot won't exist if that comma is not found. |
|
// The slot won't exist if that comma is not found. |
|
||||||
|
|
||||||
// For the occastion where an expression didn't resolve to a selection option the "default: <value>" wilbe set to:
|
// For the occastion where an expression didn't resolve to a selection option the "default: <value>" wilbe set to:
|
||||||
struct NO_RESOLVED_GENERIC_SELECTION {
|
typedef struct GENCPP_NO_RESOLVED_GENERIC_SELECTION GENCPP_NO_RESOLVED_GENERIC_SELECTION;
|
||||||
unsigned long long failure;
|
struct GENCPP_NO_RESOLVED_GENERIC_SELECTION {
|
||||||
|
void* _THE_VOID_SLOT_;
|
||||||
};
|
};
|
||||||
struct NO_RESOLVED_GENERIC_SELECTION const gen_generic_selection_fail = {};
|
GENCPP_NO_RESOLVED_GENERIC_SELECTION const gen_generic_selection_fail = {0};
|
||||||
// Which will provide the message: error: called object type 'struct NO_RESOLVED_GENERIC_SELECTION' is not a function or function pointer
|
// Which will provide the message: error: called object type 'struct NO_RESOLVED_GENERIC_SELECTION' is not a function or function pointer
|
||||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ struct Arena
|
|||||||
// This id is defined by Unreal for asserts
|
// This id is defined by Unreal for asserts
|
||||||
#pragma push_macro("check")
|
#pragma push_macro("check")
|
||||||
#undef check
|
#undef check
|
||||||
forceinline void check() { GEN_NS arena_check(this); }
|
forceinline void check() { arena_check(this); }
|
||||||
#pragma pop_macro("check")
|
#pragma pop_macro("check")
|
||||||
|
|
||||||
#pragma endregion Member Mapping
|
#pragma endregion Member Mapping
|
||||||
@ -335,7 +335,7 @@ struct FixedArena
|
|||||||
|
|
||||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
#pragma region Member Mapping
|
#pragma region Member Mapping
|
||||||
forceinline operator AllocatorInfo() { return GEN_NS allocator_info(this); }
|
forceinline operator AllocatorInfo() { return fixed_arena_allocator_info(this); }
|
||||||
|
|
||||||
forceinline static FixedArena init() { FixedArena result; fixed_arena_init<Size>(result); return result; }
|
forceinline static FixedArena init() { FixedArena result; fixed_arena_init<Size>(result); return result; }
|
||||||
forceinline ssize size_remaining(ssize alignment) { fixed_arena_size_remaining(this, alignment); }
|
forceinline ssize size_remaining(ssize alignment) { fixed_arena_size_remaining(this, alignment); }
|
||||||
|
Loading…
Reference in New Issue
Block a user