1
0
mirror of https://github.com/Ed94/gencpp.git synced 2025-07-08 22:55:45 -07:00

Progresss

This commit is contained in:
2024-12-01 21:59:43 -05:00
parent 80cb3f4eca
commit fec709cc76
14 changed files with 233 additions and 166 deletions

@ -11,7 +11,7 @@ internal void deinit();
internal
void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags )
{
Arena* last = & back(Global_AllocatorBuckets);
Arena* last = back(& Global_AllocatorBuckets);
switch ( type )
{
@ -24,10 +24,10 @@ void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, s
if ( bucket.PhysicalStart == nullptr )
GEN_FATAL( "Failed to create bucket for Global_AllocatorBuckets");
if ( ! append( Global_AllocatorBuckets, bucket ) )
if ( ! append( & Global_AllocatorBuckets, bucket ) )
GEN_FATAL( "Failed to append bucket to Global_AllocatorBuckets");
last = & back(Global_AllocatorBuckets);
last = back(& Global_AllocatorBuckets);
}
return alloc_align( allocator_info(last), size, alignment );
@ -51,10 +51,10 @@ void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, s
if ( bucket.PhysicalStart == nullptr )
GEN_FATAL( "Failed to create bucket for Global_AllocatorBuckets");
if ( ! append( Global_AllocatorBuckets, bucket ) )
if ( ! append( & Global_AllocatorBuckets, bucket ) )
GEN_FATAL( "Failed to append bucket to Global_AllocatorBuckets");
last = & back(Global_AllocatorBuckets);
last = back(& Global_AllocatorBuckets);
}
void* result = alloc_align( last->Backing, size, alignment );
@ -249,7 +249,7 @@ void init()
if ( bucket.PhysicalStart == nullptr )
GEN_FATAL( "Failed to create first bucket for Global_AllocatorBuckets");
append( Global_AllocatorBuckets, bucket );
append( & Global_AllocatorBuckets, bucket );
}
// Setup the arrays
@ -272,7 +272,7 @@ void init()
if ( code_pool.PhysicalStart == nullptr )
GEN_FATAL( "gen::init: Failed to initialize the code pool" );
append(CodePools, code_pool );
append( & CodePools, code_pool );
LexArena = arena_init_from_allocator( Allocator_Lexer, LexAllocator_Size );
@ -281,7 +281,7 @@ void init()
if ( string_arena.PhysicalStart == nullptr )
GEN_FATAL( "gen::init: Failed to initialize the string arena" );
append(StringArenas, string_arena );
append( & StringArenas, string_arena );
}
// Setup the hash tables
@ -323,12 +323,12 @@ void deinit()
destroy(StringCache);
free(CodePools);
free(StringArenas);
free( & CodePools);
free( & StringArenas);
free(& LexArena);
free(PreprocessorDefines);
free(& PreprocessorDefines);
index = 0;
left = num(Global_AllocatorBuckets);
@ -373,7 +373,7 @@ void reset()
AllocatorInfo get_string_allocator( s32 str_length )
{
Arena* last = & back(StringArenas);
Arena* last = back(& StringArenas);
usize size_req = str_length + sizeof(StringHeader) + sizeof(char*);
@ -381,10 +381,10 @@ AllocatorInfo get_string_allocator( s32 str_length )
{
Arena new_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena );
if ( ! append(StringArenas, new_arena ) )
if ( ! append( & StringArenas, new_arena ) )
GEN_FATAL( "gen::get_string_allocator: Failed to allocate a new string arena" );
last = & back(StringArenas);
last = back(& StringArenas);
}
return allocator_info(last);
@ -411,7 +411,7 @@ StringCached get_cached_string( StrC str )
// Used internally to retireve a Code object form the CodePool.
Code make_code()
{
Pool* allocator = & back(CodePools);
Pool* allocator = back( & CodePools);
if ( allocator->FreeList == nullptr )
{
Pool code_pool = pool_init( Allocator_CodePool, CodePool_NumBlocks, sizeof(AST) );
@ -419,10 +419,10 @@ Code make_code()
if ( code_pool.PhysicalStart == nullptr )
GEN_FATAL( "gen::make_code: Failed to allocate a new code pool - CodePool allcoator returned nullptr." );
if ( ! append( CodePools, code_pool ) )
if ( ! append( & CodePools, code_pool ) )
GEN_FATAL( "gen::make_code: Failed to allocate a new code pool - CodePools failed to append new pool." );
allocator = & back(CodePools);
allocator = back( & CodePools);
}
Code result { rcast( AST*, alloc( allocator_info(allocator), sizeof(AST) )) };

@ -222,7 +222,7 @@ s32 lex_preprocessor_directive(
, Token& token )
{
char const* hash = scanner;
append(Tokens, { hash, 1, TokType::Preprocess_Hash, line, column, TF_Preprocess } );
append( & Tokens, { hash, 1, TokType::Preprocess_Hash, line, column, TF_Preprocess } );
move_forward();
SkipWhitespace();
@ -298,14 +298,14 @@ s32 lex_preprocessor_directive(
token.Length = token.Length + token.Text - hash;
token.Text = hash;
append(Tokens, token );
append( & Tokens, token );
return Lex_Continue; // Skip found token, its all handled here.
}
if ( token.Type == TokType::Preprocess_Else || token.Type == TokType::Preprocess_EndIf )
{
token.Flags |= TF_Preprocess_Cond;
append(Tokens, token );
append( & Tokens, token );
end_line();
return Lex_Continue;
}
@ -314,7 +314,7 @@ s32 lex_preprocessor_directive(
token.Flags |= TF_Preprocess_Cond;
}
append(Tokens, token );
append( & Tokens, token );
SkipWhitespace();
@ -338,7 +338,7 @@ s32 lex_preprocessor_directive(
name.Length++;
}
append(Tokens, name );
append( & Tokens, name );
u64 key = crc32( name.Text, name.Length );
set<StrC>(defines, key, name );
@ -384,7 +384,7 @@ s32 lex_preprocessor_directive(
move_forward();
}
append(Tokens, preprocess_content );
append( & Tokens, preprocess_content );
return Lex_Continue; // Skip found token, its all handled here.
}
@ -446,7 +446,7 @@ s32 lex_preprocessor_directive(
preprocess_content.Length++;
}
append(Tokens, preprocess_content );
append( & Tokens, preprocess_content );
return Lex_Continue; // Skip found token, its all handled here.
}
@ -461,7 +461,7 @@ void lex_found_token( StrC& content
{
if ( token.Type != TokType::Invalid )
{
append(Tokens, token );
append( & Tokens, token );
return;
}
@ -488,7 +488,7 @@ void lex_found_token( StrC& content
}
token.Type = type;
append(Tokens, token );
append( & Tokens, token );
return;
}
@ -498,7 +498,7 @@ void lex_found_token( StrC& content
{
token.Type = type;
token.Flags |= TF_Specifier;
append(Tokens, token );
append( & Tokens, token );
return;
}
@ -506,7 +506,7 @@ void lex_found_token( StrC& content
if ( type != TokType::Invalid )
{
token.Type = type;
append(Tokens, token );
append( & Tokens, token );
return;
}
@ -558,7 +558,7 @@ void lex_found_token( StrC& content
token.Type = TokType::Identifier;
}
append(Tokens, token );
append( & Tokens, token );
}
@ -630,7 +630,7 @@ TokArray lex( StrC content )
token.Type = TokType::NewLine;
token.Length++;
append(Tokens, token );
append( & Tokens, token );
continue;
}
}
@ -1099,7 +1099,7 @@ TokArray lex( StrC content )
move_forward();
token.Length++;
}
append(Tokens, token );
append( & Tokens, token );
continue;
}
else if ( current == '*' )
@ -1135,7 +1135,7 @@ TokArray lex( StrC content )
move_forward();
token.Length++;
}
append(Tokens, token );
append( & Tokens, token );
// end_line();
continue;
}

@ -52,7 +52,7 @@ struct ParseContext
sptr length = scope_start.Length;
char const* current = scope_start.Text + length;
while ( current <= back(Tokens.Arr).Text && *current != '\n' && length < 74 )
while ( current <= back( & Tokens.Arr)->Text && *current != '\n' && length < 74 )
{
current++;
length++;
@ -745,7 +745,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
}
Token interface_tok = parse_identifier();
append(interfaces, def_type( interface_tok ) );
append( & interfaces, def_type( interface_tok ) );
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> <Name>, ...
}
}
@ -777,7 +777,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false )
if ( inline_cmt )
result->InlineCmt = inline_cmt;
free(interfaces);
free(& interfaces);
return result;
}