Templates, test changes (prob not working), progress on parsing bodies and operators.

This time, really not touching for a couple of weeks.
This commit is contained in:
2023-07-10 01:15:25 -04:00
parent 9df177edf4
commit ed6a1d0f95
14 changed files with 1343 additions and 503 deletions

View File

@ -114,7 +114,6 @@ Code gen__array( StrC type, sw type_size )
Header& header = get_header();
return Data[ header.Num - 1 ];
))
, spec_inline
);
Code clear = def_function( name(clear), __, t_void
@ -122,7 +121,6 @@ Code gen__array( StrC type, sw type_size )
Header& header = get_header();
header.Num = 0;
))
, spec_inline
);
Code fill;
@ -155,14 +153,12 @@ Code gen__array( StrC type, sw type_size )
Header& header = get_header();
zpl::free( header.Allocator, & header );
))
, spec_inline
);
Code get_header = def_function( name(get_header), __, t_header_ref
, def_execution( code(
return * ( rcast( Header*, Data ) - 1 );
))
, spec_inline
);
Code grow = def_function( name(grow), def_param( t_uw, name(min_capacity)), t_bool
@ -182,7 +178,6 @@ Code gen__array( StrC type, sw type_size )
, def_execution( code(
return get_header().Num;
))
, spec_inline
);
Code pop = def_function( name(pop), __, t_bool
@ -192,7 +187,6 @@ Code gen__array( StrC type, sw type_size )
ZPL_ASSERT( header.Num > 0 );
header.Num--;
))
, spec_inline
);
Code remove_at = def_function( name(remove_at), def_param( t_uw, name(idx)), t_void
@ -203,7 +197,6 @@ Code gen__array( StrC type, sw type_size )
mem_move( header + idx, header + idx + 1, sizeof( Type ) * ( header->Num - idx - 1 ) );
header->Num--;
))
, spec_inline
);
Code reserve = def_function( name(reserve), def_param( t_uw, name(new_capacity)), t_bool
@ -316,7 +309,7 @@ Array(GenArrayRequest) GenArrayRequests;
void gen__array_request( StrC type, sw size, StrC dep = {} )
{
do_once_start
array_init( GenArrayRequests, g_allocator );
array_init( GenArrayRequests, Memory::GlobalAllocator );
do_once_end
// Make sure we don't already have a request for the type.

View File

@ -101,7 +101,6 @@ Code gen__buffer( StrC type, sw type_size )
Data[ header.Num ] = value;
header.Num++;
))
, spec_inline
);
Code appendv;
@ -121,7 +120,6 @@ Code gen__buffer( StrC type, sw type_size )
header.Num += num;
))
, spec_inline
);
}
@ -130,7 +128,6 @@ Code gen__buffer( StrC type, sw type_size )
Header& header = get_header();
header.Num = 0;
))
, spec_inline
);
Code end = def_function( name(end), __, t_type_ref
@ -138,7 +135,6 @@ Code gen__buffer( StrC type, sw type_size )
Header& header = get_header();
return Data[ header.Num - 1 ];
))
, spec_inline
);
Code free = def_function( name(free), __, t_void
@ -146,21 +142,18 @@ Code gen__buffer( StrC type, sw type_size )
Header& header = get_header();
zpl::free( header.Backing, & header );
))
, spec_inline
);
Code get_header = def_function( name(get_header), __, t_header_ref
, def_execution( code(
return * ( rcast( Header*, Data ) - 1 );
))
, spec_inline
);
Code num = def_function( name(num), __, t_sw
, def_execution( code(
return get_header().Num;
))
, spec_inline
);
Code pop = def_function( name(pop), __, t_type
@ -169,7 +162,6 @@ Code gen__buffer( StrC type, sw type_size )
header.Num--;
return Data[ header.Num ];
))
, spec_inline
);
Code wipe = def_function( name(wipe), __, t_void
@ -178,7 +170,6 @@ Code gen__buffer( StrC type, sw type_size )
header.Num = 0;
mem_set( Data, 0, header.Capacity * sizeof( Type ) );
))
, spec_inline
);
Code op_type_ptr = untyped_str( code(
@ -223,7 +214,7 @@ Array(GenBufferRequest) GenBufferRequests;
void gen__buffer_request( StrC type, sw size, StrC dep = {} )
{
do_once_start
array_init( GenBufferRequests, g_allocator );
array_init( GenBufferRequests, Memory::GlobalAllocator );
do_once_end
// Make sure we don't already have a request for the type.

View File

@ -90,7 +90,7 @@ Code gen__hashtable( StrC type, sw type_size )
Code clear = def_function( name(clear), __, t_void
, def_execution( code(
if ( s32 idx = 0; idx < Hashes.num(), idx++ )
for ( s32 idx = 0; idx < Hashes.num(), idx++ )
Hashes[ idx ] = -1;
Entries.clear();
@ -100,11 +100,10 @@ Code gen__hashtable( StrC type, sw type_size )
Code destroy = def_function( name(destroy), __, t_void
, def_execution( code(
if ( Hashes )
Hashes .free();
Hashes.free();
if ( Entries )
Entries.free();
))
, spec_inline
);
Code get = def_function( name(get), def_param( t_u64, name(key)), t_type_ptr
@ -174,7 +173,6 @@ Code gen__hashtable( StrC type, sw type_size )
sw new_num = array_grow_formula( Entries.num() );
rehash( new_num );
))
, spec_inline
);
Code rehash;
@ -214,7 +212,6 @@ Code gen__hashtable( StrC type, sw type_size )
new_ht.Entries[ last_added_index ].Value = entry.Value;
}
// <type>* old_ht = this;
// *this = new_ht;
// old_ht.destroy();
@ -320,7 +317,6 @@ Code gen__hashtable( StrC type, sw type_size )
return -1;
))
, spec_inline
);
Code add_entry = def_function( name(add_entry), def_param( t_u64, name(key)), t_sw
@ -332,7 +328,6 @@ Code gen__hashtable( StrC type, sw type_size )
Entries.append( entry );
return idx;
))
, spec_inline
);
Code find = def_function( name(find), def_param( t_u64, name(key)), t_find_result
@ -362,7 +357,6 @@ Code gen__hashtable( StrC type, sw type_size )
, def_execution( code(
return 0.75f * Hashes.num() < Entries.num();
))
, spec_inline
);
hashtable = def_struct( name, def_struct_body( 24
@ -411,7 +405,7 @@ Array(GenHashTableRequest) GenHashTableRequests;
void gen__hashtable_request( StrC type, sw size, StrC dep = {} )
{
do_once_start
array_init( GenHashTableRequests, g_allocator );
array_init( GenHashTableRequests, Memory::GlobalAllocator );
gen_array( sw );
do_once_end

View File

@ -80,7 +80,6 @@ Code gen__ring( StrC type, sw type_size )
if ( Head == Tail )
Tail = ( Tail + 1 ) % Capacity;
))
, spec_inline
);
Code appendv;
@ -102,21 +101,18 @@ Code gen__ring( StrC type, sw type_size )
, def_execution( code(
return Head == Tail;
))
, spec_inline
);
Code free = def_function( name(free), __, t_void
, def_execution( code(
Buffer.free();
))
, spec_inline
);
Code full = def_function( name(full), __, t_bool
, def_execution( code(
return (Head + 1) % Capacity == Tail;
))
, spec_inline
);
Code get = def_function( name(get), __, t_type_ref
@ -134,7 +130,6 @@ Code gen__ring( StrC type, sw type_size )
Tail = 0;
Buffer.wipe();
))
, spec_inline
);
ring = def_struct( name, def_struct_body( 14,
@ -172,7 +167,7 @@ Array(GenRingRequest) GenRingRequests;
void gen__ring_request( StrC type, sw size, StrC dep = {} )
{
do_once_start
array_init( GenRingRequests, g_allocator );
array_init( GenRingRequests, Memory::GlobalAllocator );
do_once_end
// Make sure we don't already have a request for the type.