mirror of
https://github.com/Ed94/gencpp.git
synced 2025-07-03 12:21:04 -07:00
Compare commits
2 Commits
v0.19-Alph
...
163ad0a511
Author | SHA1 | Date | |
---|---|---|---|
163ad0a511 | |||
e3c2a577ba |
@ -16,8 +16,8 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
local_persist
|
local_persist
|
||||||
char tok_map_mem[ TokenFmt_TokenMap_MemSize ];
|
char tok_map_mem[ TokenFmt_TokenMap_MemSize ];
|
||||||
|
|
||||||
tok_map_arena = Arena::init_from_memory( tok_map_mem, sizeof(tok_map_mem) );
|
init_from_memory( tok_map_arena, tok_map_mem, sizeof(tok_map_mem) );
|
||||||
tok_map = HashTable<StrC>::init( tok_map_arena );
|
tok_map = HashTable<StrC>::init( tok_map_arena );
|
||||||
|
|
||||||
s32 left = num_tokens - 1;
|
s32 left = num_tokens - 1;
|
||||||
|
|
||||||
|
@ -712,7 +712,10 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
|
|||||||
|
|
||||||
local_persist
|
local_persist
|
||||||
char interface_arr_mem[ kilobytes(4) ] {0};
|
char interface_arr_mem[ kilobytes(4) ] {0};
|
||||||
Array<CodeType> interfaces = Array<CodeType>::init_reserve( Arena::init_from_memory(interface_arr_mem, kilobytes(4) ), 4 );
|
Array<CodeType> interfaces; {
|
||||||
|
Arena arena; init_from_memory(arena, interface_arr_mem, kilobytes(4) );
|
||||||
|
Array<CodeType>::init_reserve( arena, 4 );
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(Ed) : Make an AST_DerivedType, we'll store any arbitary derived type into there as a linear linked list of them.
|
// TODO(Ed) : Make an AST_DerivedType, we'll store any arbitary derived type into there as a linear linked list of them.
|
||||||
if ( check( TokType::Assign_Classifer ) )
|
if ( check( TokType::Assign_Classifer ) )
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
{ \
|
{ \
|
||||||
if ( ! ( cond ) ) \
|
if ( ! ( cond ) ) \
|
||||||
{ \
|
{ \
|
||||||
assert_handler( #cond, __FILE__, scast( s64, __LINE__ ), msg, ##__VA_ARGS__ ); \
|
assert_handler( #cond, __FILE__, scast( s64, __LINE__ ), msg, ##__VA_ARGS__ ); \
|
||||||
GEN_DEBUG_TRAP(); \
|
GEN_DEBUG_TRAP(); \
|
||||||
} \
|
} \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#pragma region Memory
|
#pragma region Memory
|
||||||
|
|
||||||
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
|
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
|
||||||
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
|
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
|
||||||
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
|
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
|
||||||
#define terabytes( x ) ( gigabytes( x ) * ( s64 )( 1024 ) )
|
#define terabytes( x ) ( gigabytes( x ) * ( s64 )( 1024 ) )
|
||||||
@ -170,23 +170,20 @@ b32 gen_vm_purge( VirtualMemory vm );
|
|||||||
//! Retrieve VM's page size and alignment.
|
//! Retrieve VM's page size and alignment.
|
||||||
ssize gen_virtual_memory_page_size( ssize* alignment_out );
|
ssize gen_virtual_memory_page_size( ssize* alignment_out );
|
||||||
|
|
||||||
|
|
||||||
|
struct Arena;
|
||||||
|
void init_from_memory( Arena& arena, void* start, ssize size );
|
||||||
|
|
||||||
struct Arena
|
struct Arena
|
||||||
{
|
{
|
||||||
static
|
static
|
||||||
void* allocator_proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
|
void* allocator_proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
|
||||||
|
|
||||||
static
|
//forceinline static
|
||||||
Arena init_from_memory( void* start, ssize size )
|
//Arena init_from_memory( void* start, ssize size ) {
|
||||||
{
|
// Arena result; GEN_NS init_from_memory( result, start, size );
|
||||||
return
|
// return result;
|
||||||
{
|
//}
|
||||||
{ nullptr, nullptr },
|
|
||||||
start,
|
|
||||||
size,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
Arena init_from_allocator( AllocatorInfo backing, ssize size )
|
Arena init_from_allocator( AllocatorInfo backing, ssize size )
|
||||||
@ -249,16 +246,25 @@ struct Arena
|
|||||||
|
|
||||||
AllocatorInfo Backing;
|
AllocatorInfo Backing;
|
||||||
void* PhysicalStart;
|
void* PhysicalStart;
|
||||||
ssize TotalSize;
|
ssize TotalSize;
|
||||||
ssize TotalUsed;
|
ssize TotalUsed;
|
||||||
ssize TempCount;
|
ssize TempCount;
|
||||||
|
|
||||||
operator AllocatorInfo()
|
operator AllocatorInfo() { return { allocator_proc, this }; }
|
||||||
{
|
|
||||||
return { allocator_proc, this };
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void init_from_memory( Arena& arena, void* start, ssize size )
|
||||||
|
{
|
||||||
|
arena =
|
||||||
|
{
|
||||||
|
{ nullptr, nullptr },
|
||||||
|
start,
|
||||||
|
size,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Just a wrapper around using an arena with memory associated with its scope instead of from an allocator.
|
// Just a wrapper around using an arena with memory associated with its scope instead of from an allocator.
|
||||||
// Used for static segment or stack allocations.
|
// Used for static segment or stack allocations.
|
||||||
template< s32 Size >
|
template< s32 Size >
|
||||||
|
@ -168,6 +168,44 @@ struct String
|
|||||||
return Data[ length() - 1 ];
|
return Data[ length() - 1 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool contains(StrC substring) const
|
||||||
|
{
|
||||||
|
Header const& header = * rcast( Header const*, Data - sizeof( Header ));
|
||||||
|
|
||||||
|
if (substring.Len > header.Length)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ssize main_len = header.Length;
|
||||||
|
ssize sub_len = substring.Len;
|
||||||
|
|
||||||
|
for (ssize idx = 0; idx <= main_len - sub_len; ++idx)
|
||||||
|
{
|
||||||
|
if (str_compare(Data + idx, substring.Ptr, sub_len) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool contains(String const& substring) const
|
||||||
|
{
|
||||||
|
Header const& header = * rcast( Header const*, Data - sizeof( Header ));
|
||||||
|
|
||||||
|
if (substring.length() > header.Length)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ssize main_len = header.Length;
|
||||||
|
ssize sub_len = substring.length();
|
||||||
|
|
||||||
|
for (ssize idx = 0; idx <= main_len - sub_len; ++idx)
|
||||||
|
{
|
||||||
|
if (str_compare(Data + idx, substring.Data, sub_len) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ssize capacity() const
|
ssize capacity() const
|
||||||
{
|
{
|
||||||
Header const&
|
Header const&
|
||||||
|
Reference in New Issue
Block a user