mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Compare commits
3 Commits
0b03b3cd92
...
b027778328
Author | SHA1 | Date | |
---|---|---|---|
b027778328 | |||
a6143e12b4 | |||
868b93cdd0 |
@ -15,7 +15,9 @@ Builder builder_open( char const* path )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Buffer = strbuilder_make_reserve( _ctx->Allocator_Temp, _ctx->InitSize_BuilderBuffer );
|
Context* ctx = get_context();
|
||||||
|
GEN_ASSERT_NOT_NULL(ctx);
|
||||||
|
result.Buffer = strbuilder_make_reserve( ctx->Allocator_Temp, ctx->InitSize_BuilderBuffer );
|
||||||
|
|
||||||
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
||||||
return result;
|
return result;
|
||||||
|
@ -25,13 +25,14 @@ Builder builder_open ( char const* path );
|
|||||||
void builder_pad_lines ( Builder* builder, s32 num );
|
void builder_pad_lines ( Builder* builder, s32 num );
|
||||||
void builder_print ( Builder* builder, Code code );
|
void builder_print ( Builder* builder, Code code );
|
||||||
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va );
|
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va );
|
||||||
void builder_print_fmt ( Builder* builder, char const* fmt, ... ) {
|
void builder_write ( Builder* builder );
|
||||||
|
|
||||||
|
forceinline void builder_print_fmt ( Builder* builder, char const* fmt, ... ) {
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start( va, fmt );
|
va_start( va, fmt );
|
||||||
builder_print_fmt_va( builder, fmt, va );
|
builder_print_fmt_va( builder, fmt, va );
|
||||||
va_end( va );
|
va_end( va );
|
||||||
}
|
}
|
||||||
void builder_write( Builder* builder );
|
|
||||||
|
|
||||||
struct Builder
|
struct Builder
|
||||||
{
|
{
|
||||||
@ -56,10 +57,10 @@ struct Builder
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
void builder_pad_lines( Builder& builder, s32 num ) { return builder_pad_lines(& builder, num); }
|
forceinline void builder_pad_lines( Builder& builder, s32 num ) { return builder_pad_lines(& builder, num); }
|
||||||
void builder_print ( Builder& builder, Code code ) { return builder_print(& builder, code); }
|
forceinline void builder_print ( Builder& builder, Code code ) { return builder_print(& builder, code); }
|
||||||
void builder_write ( Builder& builder ) { return builder_write(& builder ); }
|
forceinline void builder_write ( Builder& builder ) { return builder_write(& builder ); }
|
||||||
void builder_print_fmt( Builder& builder, char const* fmt, ...) {
|
forceinline void builder_print_fmt( Builder& builder, char const* fmt, ...) {
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start( va, fmt );
|
va_start( va, fmt );
|
||||||
builder_print_fmt_va( & builder, fmt, va );
|
builder_print_fmt_va( & builder, fmt, va );
|
||||||
|
@ -20,7 +20,7 @@ Code scan_file( char const* path )
|
|||||||
GEN_FATAL("scan_file: %s is empty", path );
|
GEN_FATAL("scan_file: %s is empty", path );
|
||||||
}
|
}
|
||||||
|
|
||||||
StrBuilder str = strbuilder_make_reserve( _ctx->Allocator_Temp, fsize );
|
StrBuilder str = strbuilder_make_reserve( get_context()->Allocator_Temp, fsize );
|
||||||
file_read( & file, str, fsize );
|
file_read( & file, str, fsize );
|
||||||
strbuilder_get_header(str)->Length = fsize;
|
strbuilder_get_header(str)->Length = fsize;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ Code scan_file( char const* path )
|
|||||||
}
|
}
|
||||||
|
|
||||||
CodeBody parse_file( const char* path ) {
|
CodeBody parse_file( const char* path ) {
|
||||||
FileContents file = file_read_contents( _ctx->Allocator_Temp, true, path );
|
FileContents file = file_read_contents( get_context()->Allocator_Temp, true, path );
|
||||||
Str content = { (char const*)file.data, file.size };
|
Str content = { (char const*)file.data, file.size };
|
||||||
CodeBody code = parse_global_body( content );
|
CodeBody code = parse_global_body( content );
|
||||||
log_fmt("\nParsed: %s\n", path);
|
log_fmt("\nParsed: %s\n", path);
|
||||||
|
@ -262,9 +262,9 @@ forceinline void define_params_append (CodeDefineParams appendee
|
|||||||
forceinline CodeDefineParams define_params_get (CodeDefineParams self, s32 idx ) { return (CodeDefineParams) (Code) params_get( cast(CodeParams, self), idx); }
|
forceinline CodeDefineParams define_params_get (CodeDefineParams self, s32 idx ) { return (CodeDefineParams) (Code) params_get( cast(CodeParams, self), idx); }
|
||||||
forceinline bool define_params_has_entries(CodeDefineParams self) { return params_has_entries( cast(CodeParams, self)); }
|
forceinline bool define_params_has_entries(CodeDefineParams self) { return params_has_entries( cast(CodeParams, self)); }
|
||||||
|
|
||||||
CodeDefineParams begin_CodeDefineParams(CodeDefineParams params) { return (CodeDefineParams) (Code) begin_CodeParams( cast(CodeParams, (Code)params)); }
|
forceinline CodeDefineParams begin_CodeDefineParams(CodeDefineParams params) { return (CodeDefineParams) (Code) begin_CodeParams( cast(CodeParams, (Code)params)); }
|
||||||
CodeDefineParams end_CodeDefineParams (CodeDefineParams params) { return (CodeDefineParams) (Code) end_CodeParams ( cast(CodeParams, (Code)params)); }
|
forceinline CodeDefineParams end_CodeDefineParams (CodeDefineParams params) { return (CodeDefineParams) (Code) end_CodeParams ( cast(CodeParams, (Code)params)); }
|
||||||
CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter) { return (CodeDefineParams) (Code) next_CodeParams ( cast(CodeParams, (Code)params), cast(CodeParams, (Code)entry_iter)); }
|
forceinline CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter) { return (CodeDefineParams) (Code) next_CodeParams ( cast(CodeParams, (Code)params), cast(CodeParams, (Code)entry_iter)); }
|
||||||
|
|
||||||
#if GEN_COMPILER_CPP
|
#if GEN_COMPILER_CPP
|
||||||
forceinline
|
forceinline
|
||||||
|
@ -376,6 +376,13 @@ void deinit(Context* ctx)
|
|||||||
if (_ctx == ctx)
|
if (_ctx == ctx)
|
||||||
_ctx = nullptr;
|
_ctx = nullptr;
|
||||||
-- context_counter;
|
-- context_counter;
|
||||||
|
|
||||||
|
Context wipe = {};
|
||||||
|
* ctx = wipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
Context* get_context() {
|
||||||
|
return _ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(Context* ctx)
|
void reset(Context* ctx)
|
||||||
|
@ -79,6 +79,8 @@ struct Context
|
|||||||
u32 InitSize_Fallback_Allocator_Bucket_Size;
|
u32 InitSize_Fallback_Allocator_Bucket_Size;
|
||||||
Array(Arena) Fallback_AllocatorBuckets;
|
Array(Arena) Fallback_AllocatorBuckets;
|
||||||
|
|
||||||
|
StringTable token_fmt_map;
|
||||||
|
|
||||||
// Array(Token) LexerTokens;
|
// Array(Token) LexerTokens;
|
||||||
|
|
||||||
Array(Pool) CodePools;
|
Array(Pool) CodePools;
|
||||||
@ -100,6 +102,9 @@ GEN_API void init(Context* ctx);
|
|||||||
// However on Windows at least, it doesn't need to occur as the OS will clean up after the process.
|
// However on Windows at least, it doesn't need to occur as the OS will clean up after the process.
|
||||||
GEN_API void deinit(Context* ctx);
|
GEN_API void deinit(Context* ctx);
|
||||||
|
|
||||||
|
// Retrieves the active context (not usually needed, but here in case...)
|
||||||
|
GEN_API Context* get_context();
|
||||||
|
|
||||||
// Clears the allocations, but doesn't free the memoery, then calls init() again.
|
// Clears the allocations, but doesn't free the memoery, then calls init() again.
|
||||||
// Ease of use.
|
// Ease of use.
|
||||||
GEN_API void reset(Context* ctx);
|
GEN_API void reset(Context* ctx);
|
||||||
@ -378,12 +383,20 @@ GEN_API Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... );
|
|||||||
#ifndef name
|
#ifndef name
|
||||||
// Convienence for defining any name used with the gen api.
|
// Convienence for defining any name used with the gen api.
|
||||||
// Lets you provide the length and string literal to the functions without the need for the DSL.
|
// Lets you provide the length and string literal to the functions without the need for the DSL.
|
||||||
#define name( Id_ ) { stringize(Id_), sizeof(stringize( Id_ )) - 1 }
|
# if GEN_COMPILER_C
|
||||||
|
# define name( Id_ ) (Str){ stringize(Id_), sizeof(stringize( Id_ )) - 1 }
|
||||||
|
# else
|
||||||
|
# define name( Id_ ) Str { stringize(Id_), sizeof(stringize( Id_ )) - 1 }
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef code
|
#ifndef code
|
||||||
// Same as name just used to indicate intention of literal for code instead of names.
|
// Same as name just used to indicate intention of literal for code instead of names.
|
||||||
#define code( ... ) { stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 }
|
# if GEN_COMPILER_C
|
||||||
|
# define code( ... ) (Str){ stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 }
|
||||||
|
# else
|
||||||
|
# define code( ... ) Str { stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 }
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef args
|
#ifndef args
|
||||||
|
@ -8,9 +8,8 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
char const* buf_begin = buf;
|
char const* buf_begin = buf;
|
||||||
ssize remaining = buf_size;
|
ssize remaining = buf_size;
|
||||||
|
|
||||||
local_persist StringTable tok_map;
|
if (_ctx->token_fmt_map.Hashes == nullptr) {
|
||||||
do_once() {
|
_ctx->token_fmt_map = hashtable_init(Str, _ctx->Allocator_DyanmicContainers );
|
||||||
tok_map = hashtable_init(Str, _ctx->Allocator_DyanmicContainers );
|
|
||||||
}
|
}
|
||||||
// Populate token pairs
|
// Populate token pairs
|
||||||
{
|
{
|
||||||
@ -22,7 +21,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
Str value = va_arg( va, Str );
|
Str value = va_arg( va, Str );
|
||||||
|
|
||||||
u32 key = crc32( token, c_str_len(token) );
|
u32 key = crc32( token, c_str_len(token) );
|
||||||
hashtable_set( tok_map, key, value );
|
hashtable_set( _ctx->token_fmt_map, key, value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +56,8 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
|
|
||||||
char const* token = fmt + 1;
|
char const* token = fmt + 1;
|
||||||
|
|
||||||
u32 key = crc32( token, tok_len );
|
u32 key = crc32( token, tok_len );
|
||||||
Str* value = hashtable_get(tok_map, key );
|
Str* value = hashtable_get(_ctx->token_fmt_map, key );
|
||||||
|
|
||||||
if ( value )
|
if ( value )
|
||||||
{
|
{
|
||||||
@ -87,7 +86,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
current = * fmt;
|
current = * fmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hashtable_clear(tok_map);
|
hashtable_clear(_ctx->token_fmt_map);
|
||||||
ssize result = buf_size - remaining;
|
ssize result = buf_size - remaining;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1274,7 +1274,7 @@ CodeUsing def_using_namespace( Str name )
|
|||||||
|
|
||||||
CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable p )
|
CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable p )
|
||||||
{
|
{
|
||||||
if ( ! name_check( def_variable, name ) || null_check( def_variable, type ) ) {
|
if ( ! name_check( def_variable, name ) || ! null_check( def_variable, type ) ) {
|
||||||
GEN_DEBUG_TRAP();
|
GEN_DEBUG_TRAP();
|
||||||
return InvalidCode;
|
return InvalidCode;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ s32 lex_preprocessor_define( LexContext* ctx )
|
|||||||
array_append( _ctx->Lexer_Tokens, opening_paren );
|
array_append( _ctx->Lexer_Tokens, opening_paren );
|
||||||
move_forward();
|
move_forward();
|
||||||
|
|
||||||
Token last_parameter;
|
Token last_parameter = {};
|
||||||
// We need to tokenize the define's arguments now:
|
// We need to tokenize the define's arguments now:
|
||||||
while( ctx->left && * ctx->scanner != ')')
|
while( ctx->left && * ctx->scanner != ')')
|
||||||
{
|
{
|
||||||
|
@ -2490,7 +2490,40 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
|
|||||||
// Example : <Capture_Start> <Value> <Comma>
|
// Example : <Capture_Start> <Value> <Comma>
|
||||||
// idx +1 +2
|
// idx +1 +2
|
||||||
bool detected_comma = _ctx->parser.Tokens.Arr[ _ctx->parser.Tokens.Idx + 2 ].Type == Tok_Comma;
|
bool detected_comma = _ctx->parser.Tokens.Arr[ _ctx->parser.Tokens.Idx + 2 ].Type == Tok_Comma;
|
||||||
if ( detected_capture && ! detected_comma )
|
|
||||||
|
b32 detected_non_varadic_unpaired_param = detected_comma && nexttok.Type != Tok_Varadic_Argument;
|
||||||
|
if (! detected_non_varadic_unpaired_param && nexttok.Type == Tok_Preprocess_Macro_Expr) for( s32 break_scope = 0; break_scope == 0; ++ break_scope)
|
||||||
|
{
|
||||||
|
Macro* macro = lookup_macro( nexttok.Text );
|
||||||
|
if (macro == nullptr || ! macro_is_functional(* macro))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// ( <Macro_Expr> (
|
||||||
|
// Idx +1 +2
|
||||||
|
s32 idx = _ctx->parser.Tokens.Idx + 1;
|
||||||
|
s32 level = 0;
|
||||||
|
|
||||||
|
// Find end of the token expression
|
||||||
|
for ( ; idx < array_num(_ctx->parser.Tokens.Arr); idx++ )
|
||||||
|
{
|
||||||
|
Token tok = _ctx->parser.Tokens.Arr[ idx ];
|
||||||
|
|
||||||
|
if ( tok.Type == Tok_Capture_Start )
|
||||||
|
level++;
|
||||||
|
else if ( tok.Type == Tok_Capture_End && level > 0 )
|
||||||
|
level--;
|
||||||
|
if (level == 0 && tok.Type == Tok_Capture_End)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++ idx; // Will incremnt to possible comma position
|
||||||
|
|
||||||
|
if ( _ctx->parser.Tokens.Arr[ idx ].Type != Tok_Comma )
|
||||||
|
break;
|
||||||
|
|
||||||
|
detected_non_varadic_unpaired_param = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( detected_capture && ! detected_non_varadic_unpaired_param )
|
||||||
{
|
{
|
||||||
// Dealing with a function
|
// Dealing with a function
|
||||||
result = cast(Code, parse_function_after_name( ModuleFlag_None, attributes, specifiers, type, name ));
|
result = cast(Code, parse_function_after_name( ModuleFlag_None, attributes, specifiers, type, name ));
|
||||||
@ -3002,7 +3035,7 @@ Code parse_simple_preprocess( TokType which )
|
|||||||
|| str_contains(calling_proc, txt("parse_class_struct_body"))
|
|| str_contains(calling_proc, txt("parse_class_struct_body"))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (peektok.Type == Tok_Statement_End)
|
if (left && peektok.Type == Tok_Statement_End)
|
||||||
{
|
{
|
||||||
Token stmt_end = currtok;
|
Token stmt_end = currtok;
|
||||||
eat( Tok_Statement_End );
|
eat( Tok_Statement_End );
|
||||||
@ -5015,7 +5048,6 @@ CodeTypedef parser_parse_typedef()
|
|||||||
// valid_macro |= macro && macro_expects_body(* macro));
|
// valid_macro |= macro && macro_expects_body(* macro));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Code macro;
|
|
||||||
if ( valid_macro )
|
if ( valid_macro )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
enum TokFlags : u32
|
enum TokFlags : u32
|
||||||
{
|
{
|
||||||
TF_Operator = bit(0),
|
TF_Operator = bit(0),
|
||||||
TF_Assign = bit(1),
|
TF_Assign = bit(1),
|
||||||
TF_Preprocess = bit(2),
|
TF_Preprocess = bit(2),
|
||||||
TF_Preprocess_Cond = bit(3),
|
TF_Preprocess_Cond = bit(3),
|
||||||
@ -152,6 +152,7 @@ TokType macrotype_to_toktype( MacroType type ) {
|
|||||||
return Tok_Invalid;
|
return Tok_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
Str macrotype_to_str( MacroType type )
|
Str macrotype_to_str( MacroType type )
|
||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
@ -216,4 +217,9 @@ b32 macro_expects_body( Macro macro ) {
|
|||||||
return bitfield_is_set( b16, macro.Flags, MF_Expects_Body );
|
return bitfield_is_set( b16, macro.Flags, MF_Expects_Body );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
|
forceinline b32 is_functional( Macro macro ) { return bitfield_is_set( b16, macro.Flags, MF_Functional ); }
|
||||||
|
forceinline b32 expects_body ( Macro macro ) { return bitfield_is_set( b16, macro.Flags, MF_Expects_Body ); }
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef HashTable(Macro) MacroTable;
|
typedef HashTable(Macro) MacroTable;
|
||||||
|
@ -143,6 +143,7 @@ Array<Type> array_init_reserve(AllocatorInfo allocator, ssize capacity)
|
|||||||
return {rcast(Type*, header + 1)};
|
return {rcast(Type*, header + 1)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
forceinline
|
||||||
usize array_grow_formula(ssize value) {
|
usize array_grow_formula(ssize value) {
|
||||||
return 2 * value + 8;
|
return 2 * value + 8;
|
||||||
}
|
}
|
||||||
@ -202,7 +203,7 @@ bool array_append_at(Array<Type>* array, Type item, usize idx)
|
|||||||
ArrayHeader* header = array_get_header(* array);
|
ArrayHeader* header = array_get_header(* array);
|
||||||
|
|
||||||
ssize slot = idx;
|
ssize slot = idx;
|
||||||
if (slot >= header->Num)
|
if (slot >= (ssize)(header->Num))
|
||||||
slot = header->Num - 1;
|
slot = header->Num - 1;
|
||||||
|
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
@ -354,7 +355,6 @@ bool array_reserve(Array<Type>* array, usize new_capacity)
|
|||||||
{
|
{
|
||||||
GEN_ASSERT( array != nullptr);
|
GEN_ASSERT( array != nullptr);
|
||||||
GEN_ASSERT(* array != nullptr);
|
GEN_ASSERT(* array != nullptr);
|
||||||
GEN_ASSERT(num > 0)
|
|
||||||
ArrayHeader* header = array_get_header(array);
|
ArrayHeader* header = array_get_header(array);
|
||||||
|
|
||||||
if (header->Capacity < new_capacity)
|
if (header->Capacity < new_capacity)
|
||||||
@ -763,7 +763,7 @@ HashTableFindResult hashtable__find(HashTable<Type> table, u64 key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Type> forceinline
|
template<typename Type> forceinline
|
||||||
bool hashtable_full(HashTable<Type> table) {
|
b32 hashtable_full(HashTable<Type> table) {
|
||||||
GEN_ASSERT_NOT_NULL(table.Hashes);
|
GEN_ASSERT_NOT_NULL(table.Hashes);
|
||||||
GEN_ASSERT_NOT_NULL(table.Entries);
|
GEN_ASSERT_NOT_NULL(table.Entries);
|
||||||
usize critical_load = usize(HashTable_CriticalLoadScale * f32(array_num(table.Hashes)));
|
usize critical_load = usize(HashTable_CriticalLoadScale * f32(array_num(table.Hashes)));
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
// NOTE: Things that shouldn't happen with a message!
|
// NOTE: Things that shouldn't happen with a message!
|
||||||
#define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ )
|
#define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ )
|
||||||
|
|
||||||
#if GEN_BULD_DEBUG
|
#if GEN_BUILD_DEBUG
|
||||||
#define GEN_FATAL( ... ) \
|
#define GEN_FATAL( ... ) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
@ -86,14 +86,16 @@
|
|||||||
#define stringize( ... ) stringize_va( __VA_ARGS__ )
|
#define stringize( ... ) stringize_va( __VA_ARGS__ )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef do_once
|
#define src_line_str stringize(__LINE__)
|
||||||
#define do_once() \
|
|
||||||
static int __do_once_counter_##__LINE__ = 0; \
|
|
||||||
for(; __do_once_counter_##__LINE__ != 1; __do_once_counter_##__LINE__ = 1 ) \
|
|
||||||
|
|
||||||
#define do_once_defer( expression ) \
|
#ifndef do_once
|
||||||
static int __do_once_counter_##__LINE__ = 0; \
|
#define do_once() \
|
||||||
for(; __do_once_counter_##__LINE__ != 1; __do_once_counter_##__LINE__ = 1, (expression)) \
|
static int __do_once_counter_##src_line_str = 0; \
|
||||||
|
for(; __do_once_counter_##src_line_str != 1; __do_once_counter_##src_line_str = 1 ) \
|
||||||
|
|
||||||
|
#define do_once_defer( expression ) \
|
||||||
|
static int __do_once_counter_##src_line_str = 0; \
|
||||||
|
for(; __do_once_counter_##src_line_str != 1; __do_once_counter_##src_line_str = 1, (expression)) \
|
||||||
|
|
||||||
#define do_once_start \
|
#define do_once_start \
|
||||||
do \
|
do \
|
||||||
|
@ -346,25 +346,25 @@ void* arena_allocator_proc( void* allocator_data, AllocType type, ssize size, ss
|
|||||||
switch ( type )
|
switch ( type )
|
||||||
{
|
{
|
||||||
case EAllocation_ALLOC :
|
case EAllocation_ALLOC :
|
||||||
|
{
|
||||||
|
void* end = pointer_add( arena->PhysicalStart, arena->TotalUsed );
|
||||||
|
ssize total_size = align_forward_s64( size, alignment );
|
||||||
|
|
||||||
|
// NOTE: Out of memory
|
||||||
|
if ( arena->TotalUsed + total_size > (ssize) arena->TotalSize )
|
||||||
{
|
{
|
||||||
void* end = pointer_add( arena->PhysicalStart, arena->TotalUsed );
|
// zpl__printf_err("%s", "Arena out of memory\n");
|
||||||
ssize total_size = align_forward_s64( size, alignment );
|
GEN_FATAL("Arena out of memory! (Possibly could not fit for the largest size Arena!!)");
|
||||||
|
|
||||||
// NOTE: Out of memory
|
|
||||||
if ( arena->TotalUsed + total_size > (ssize) arena->TotalSize )
|
|
||||||
{
|
|
||||||
// zpl__printf_err("%s", "Arena out of memory\n");
|
|
||||||
GEN_FATAL("Arena out of memory! (Possibly could not fit for the largest size Arena!!)");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = align_forward( end, alignment );
|
|
||||||
arena->TotalUsed += total_size;
|
|
||||||
|
|
||||||
if ( flags & ALLOCATOR_FLAG_CLEAR_TO_ZERO )
|
|
||||||
zero_size( ptr, size );
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
|
ptr = align_forward( end, alignment );
|
||||||
|
arena->TotalUsed += total_size;
|
||||||
|
|
||||||
|
if ( flags & ALLOCATOR_FLAG_CLEAR_TO_ZERO )
|
||||||
|
zero_size( ptr, size );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EAllocation_FREE :
|
case EAllocation_FREE :
|
||||||
// NOTE: Free all at once
|
// NOTE: Free all at once
|
||||||
|
@ -229,7 +229,6 @@ forceinline void check(Arena& arena) { return arena_check(& arena); }
|
|||||||
#pragma pop_macro("check")
|
#pragma pop_macro("check")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
AllocatorInfo arena_allocator_info( Arena* arena ) {
|
AllocatorInfo arena_allocator_info( Arena* arena ) {
|
||||||
GEN_ASSERT(arena != nullptr);
|
GEN_ASSERT(arena != nullptr);
|
||||||
@ -392,9 +391,9 @@ void pool_clear(Pool* pool);
|
|||||||
void pool_free(Pool* pool);
|
void pool_free(Pool* pool);
|
||||||
|
|
||||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); }
|
forceinline AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); }
|
||||||
void clear(Pool& pool) { return pool_clear(& pool); }
|
forceinline void clear(Pool& pool) { return pool_clear(& pool); }
|
||||||
void free(Pool& pool) { return pool_free(& pool); }
|
forceinline void free(Pool& pool) { return pool_free(& pool); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Pool
|
struct Pool
|
||||||
|
@ -392,6 +392,7 @@ bool strbuilder_append_string(StrBuilder* str, StrBuilder const other) {
|
|||||||
return strbuilder_append_c_str_len(str, (char const*)other, strbuilder_length(other));
|
return strbuilder_append_c_str_len(str, (char const*)other, strbuilder_length(other));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
bool strbuilder_append_fmt(StrBuilder* str, char const* fmt, ...) {
|
bool strbuilder_append_fmt(StrBuilder* str, char const* fmt, ...) {
|
||||||
GEN_ASSERT(str != nullptr);
|
GEN_ASSERT(str != nullptr);
|
||||||
ssize res;
|
ssize res;
|
||||||
|
@ -283,7 +283,7 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false )
|
|||||||
body_append(result, enum_code);
|
body_append(result, enum_code);
|
||||||
if (use_c_definition)
|
if (use_c_definition)
|
||||||
{
|
{
|
||||||
CodeTypedef specifier_t = parse_typedef( code(typedef u32 Specifier; ));
|
CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier Specifier; ));
|
||||||
body_append(result, specifier_t);
|
body_append(result, specifier_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,60 +499,60 @@ CodeBody gen_ast_inlines()
|
|||||||
#pragma pop_macro("GEN_NS")
|
#pragma pop_macro("GEN_NS")
|
||||||
#pragma pop_macro("CodeInvalid")
|
#pragma pop_macro("CodeInvalid")
|
||||||
|
|
||||||
CodeBody impl_code = parse_global_body( token_fmt( "typename", Str name(Code), code_impl_tmpl ));
|
CodeBody impl_code = parse_global_body( token_fmt( "typename", name(Code), code_impl_tmpl ));
|
||||||
CodeBody impl_code_body = parse_global_body( token_fmt( "typename", Str name(CodeBody), code_impl_tmpl ));
|
CodeBody impl_code_body = parse_global_body( token_fmt( "typename", name(CodeBody), code_impl_tmpl ));
|
||||||
CodeBody impl_code_attr = parse_global_body( token_fmt( "typename", Str name(CodeAttributes), code_impl_tmpl ));
|
CodeBody impl_code_attr = parse_global_body( token_fmt( "typename", name(CodeAttributes), code_impl_tmpl ));
|
||||||
CodeBody impl_code_cmt = parse_global_body( token_fmt( "typename", Str name(CodeComment), code_impl_tmpl ));
|
CodeBody impl_code_cmt = parse_global_body( token_fmt( "typename", name(CodeComment), code_impl_tmpl ));
|
||||||
CodeBody impl_code_constr = parse_global_body( token_fmt( "typename", Str name(CodeConstructor), code_impl_tmpl ));
|
CodeBody impl_code_constr = parse_global_body( token_fmt( "typename", name(CodeConstructor), code_impl_tmpl ));
|
||||||
CodeBody impl_code_class = parse_global_body( token_fmt( "typename", Str name(CodeClass), code_impl_tmpl ));
|
CodeBody impl_code_class = parse_global_body( token_fmt( "typename", name(CodeClass), code_impl_tmpl ));
|
||||||
CodeBody impl_code_define = parse_global_body( token_fmt( "typename", Str name(CodeDefine), code_impl_tmpl ));
|
CodeBody impl_code_define = parse_global_body( token_fmt( "typename", name(CodeDefine), code_impl_tmpl ));
|
||||||
CodeBody impl_code_define_params = parse_global_body( token_fmt( "typename", Str name(CodeDefineParams), code_impl_tmpl ));
|
CodeBody impl_code_define_params = parse_global_body( token_fmt( "typename", name(CodeDefineParams), code_impl_tmpl ));
|
||||||
CodeBody impl_code_destruct = parse_global_body( token_fmt( "typename", Str name(CodeDestructor), code_impl_tmpl ));
|
CodeBody impl_code_destruct = parse_global_body( token_fmt( "typename", name(CodeDestructor), code_impl_tmpl ));
|
||||||
CodeBody impl_code_enum = parse_global_body( token_fmt( "typename", Str name(CodeEnum), code_impl_tmpl ));
|
CodeBody impl_code_enum = parse_global_body( token_fmt( "typename", name(CodeEnum), code_impl_tmpl ));
|
||||||
CodeBody impl_code_exec = parse_global_body( token_fmt( "typename", Str name(CodeExec), code_impl_tmpl ));
|
CodeBody impl_code_exec = parse_global_body( token_fmt( "typename", name(CodeExec), code_impl_tmpl ));
|
||||||
CodeBody impl_code_extern = parse_global_body( token_fmt( "typename", Str name(CodeExtern), code_impl_tmpl ));
|
CodeBody impl_code_extern = parse_global_body( token_fmt( "typename", name(CodeExtern), code_impl_tmpl ));
|
||||||
CodeBody impl_code_include = parse_global_body( token_fmt( "typename", Str name(CodeInclude), code_impl_tmpl ));
|
CodeBody impl_code_include = parse_global_body( token_fmt( "typename", name(CodeInclude), code_impl_tmpl ));
|
||||||
CodeBody impl_code_friend = parse_global_body( token_fmt( "typename", Str name(CodeFriend), code_impl_tmpl ));
|
CodeBody impl_code_friend = parse_global_body( token_fmt( "typename", name(CodeFriend), code_impl_tmpl ));
|
||||||
CodeBody impl_code_fn = parse_global_body( token_fmt( "typename", Str name(CodeFn), code_impl_tmpl ));
|
CodeBody impl_code_fn = parse_global_body( token_fmt( "typename", name(CodeFn), code_impl_tmpl ));
|
||||||
CodeBody impl_code_module = parse_global_body( token_fmt( "typename", Str name(CodeModule), code_impl_tmpl ));
|
CodeBody impl_code_module = parse_global_body( token_fmt( "typename", name(CodeModule), code_impl_tmpl ));
|
||||||
CodeBody impl_code_ns = parse_global_body( token_fmt( "typename", Str name(CodeNS), code_impl_tmpl ));
|
CodeBody impl_code_ns = parse_global_body( token_fmt( "typename", name(CodeNS), code_impl_tmpl ));
|
||||||
CodeBody impl_code_op = parse_global_body( token_fmt( "typename", Str name(CodeOperator), code_impl_tmpl ));
|
CodeBody impl_code_op = parse_global_body( token_fmt( "typename", name(CodeOperator), code_impl_tmpl ));
|
||||||
CodeBody impl_code_opcast = parse_global_body( token_fmt( "typename", Str name(CodeOpCast), code_impl_tmpl ));
|
CodeBody impl_code_opcast = parse_global_body( token_fmt( "typename", name(CodeOpCast), code_impl_tmpl ));
|
||||||
CodeBody impl_code_params = parse_global_body( token_fmt( "typename", Str name(CodeParams), code_impl_tmpl ));
|
CodeBody impl_code_params = parse_global_body( token_fmt( "typename", name(CodeParams), code_impl_tmpl ));
|
||||||
CodeBody impl_code_pragma = parse_global_body( token_fmt( "typename", Str name(CodePragma), code_impl_tmpl ));
|
CodeBody impl_code_pragma = parse_global_body( token_fmt( "typename", name(CodePragma), code_impl_tmpl ));
|
||||||
CodeBody impl_code_precond = parse_global_body( token_fmt( "typename", Str name(CodePreprocessCond), code_impl_tmpl ));
|
CodeBody impl_code_precond = parse_global_body( token_fmt( "typename", name(CodePreprocessCond), code_impl_tmpl ));
|
||||||
CodeBody impl_code_specs = parse_global_body( token_fmt( "typename", Str name(CodeSpecifiers), code_impl_tmpl ));
|
CodeBody impl_code_specs = parse_global_body( token_fmt( "typename", name(CodeSpecifiers), code_impl_tmpl ));
|
||||||
CodeBody impl_code_struct = parse_global_body( token_fmt( "typename", Str name(CodeStruct), code_impl_tmpl ));
|
CodeBody impl_code_struct = parse_global_body( token_fmt( "typename", name(CodeStruct), code_impl_tmpl ));
|
||||||
CodeBody impl_code_tmpl = parse_global_body( token_fmt( "typename", Str name(CodeTemplate), code_impl_tmpl ));
|
CodeBody impl_code_tmpl = parse_global_body( token_fmt( "typename", name(CodeTemplate), code_impl_tmpl ));
|
||||||
CodeBody impl_code_type = parse_global_body( token_fmt( "typename", Str name(CodeTypename), code_impl_tmpl ));
|
CodeBody impl_code_type = parse_global_body( token_fmt( "typename", name(CodeTypename), code_impl_tmpl ));
|
||||||
CodeBody impl_code_typedef = parse_global_body( token_fmt( "typename", Str name(CodeTypedef), code_impl_tmpl ));
|
CodeBody impl_code_typedef = parse_global_body( token_fmt( "typename", name(CodeTypedef), code_impl_tmpl ));
|
||||||
CodeBody impl_code_union = parse_global_body( token_fmt( "typename", Str name(CodeUnion), code_impl_tmpl ));
|
CodeBody impl_code_union = parse_global_body( token_fmt( "typename", name(CodeUnion), code_impl_tmpl ));
|
||||||
CodeBody impl_code_using = parse_global_body( token_fmt( "typename", Str name(CodeUsing), code_impl_tmpl ));
|
CodeBody impl_code_using = parse_global_body( token_fmt( "typename", name(CodeUsing), code_impl_tmpl ));
|
||||||
CodeBody impl_code_var = parse_global_body( token_fmt( "typename", Str name(CodeVar), code_impl_tmpl ));
|
CodeBody impl_code_var = parse_global_body( token_fmt( "typename", name(CodeVar), code_impl_tmpl ));
|
||||||
|
|
||||||
body_append(impl_code_attr, parse_global_body( token_fmt( "typename", Str name(Attributes), codetype_impl_tmpl )));
|
body_append(impl_code_attr, parse_global_body( token_fmt( "typename", name(Attributes), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_cmt, parse_global_body( token_fmt( "typename", Str name(Comment), codetype_impl_tmpl )));
|
body_append(impl_code_cmt, parse_global_body( token_fmt( "typename", name(Comment), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_constr, parse_global_body( token_fmt( "typename", Str name(Constructor), codetype_impl_tmpl )));
|
body_append(impl_code_constr, parse_global_body( token_fmt( "typename", name(Constructor), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_define, parse_global_body( token_fmt( "typename", Str name(Define), codetype_impl_tmpl )));
|
body_append(impl_code_define, parse_global_body( token_fmt( "typename", name(Define), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_destruct, parse_global_body( token_fmt( "typename", Str name(Destructor), codetype_impl_tmpl )));
|
body_append(impl_code_destruct, parse_global_body( token_fmt( "typename", name(Destructor), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_enum, parse_global_body( token_fmt( "typename", Str name(Enum), codetype_impl_tmpl )));
|
body_append(impl_code_enum, parse_global_body( token_fmt( "typename", name(Enum), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_exec, parse_global_body( token_fmt( "typename", Str name(Exec), codetype_impl_tmpl )));
|
body_append(impl_code_exec, parse_global_body( token_fmt( "typename", name(Exec), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_extern, parse_global_body( token_fmt( "typename", Str name(Extern), codetype_impl_tmpl )));
|
body_append(impl_code_extern, parse_global_body( token_fmt( "typename", name(Extern), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_include, parse_global_body( token_fmt( "typename", Str name(Include), codetype_impl_tmpl )));
|
body_append(impl_code_include, parse_global_body( token_fmt( "typename", name(Include), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_friend, parse_global_body( token_fmt( "typename", Str name(Friend), codetype_impl_tmpl )));
|
body_append(impl_code_friend, parse_global_body( token_fmt( "typename", name(Friend), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_fn, parse_global_body( token_fmt( "typename", Str name(Fn), codetype_impl_tmpl )));
|
body_append(impl_code_fn, parse_global_body( token_fmt( "typename", name(Fn), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_module, parse_global_body( token_fmt( "typename", Str name(Module), codetype_impl_tmpl )));
|
body_append(impl_code_module, parse_global_body( token_fmt( "typename", name(Module), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_ns, parse_global_body( token_fmt( "typename", Str name(NS), codetype_impl_tmpl )));
|
body_append(impl_code_ns, parse_global_body( token_fmt( "typename", name(NS), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_op, parse_global_body( token_fmt( "typename", Str name(Operator), codetype_impl_tmpl )));
|
body_append(impl_code_op, parse_global_body( token_fmt( "typename", name(Operator), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_opcast, parse_global_body( token_fmt( "typename", Str name(OpCast), codetype_impl_tmpl )));
|
body_append(impl_code_opcast, parse_global_body( token_fmt( "typename", name(OpCast), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_pragma, parse_global_body( token_fmt( "typename", Str name(Pragma), codetype_impl_tmpl )));
|
body_append(impl_code_pragma, parse_global_body( token_fmt( "typename", name(Pragma), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_precond, parse_global_body( token_fmt( "typename", Str name(PreprocessCond), codetype_impl_tmpl )));
|
body_append(impl_code_precond, parse_global_body( token_fmt( "typename", name(PreprocessCond), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_tmpl, parse_global_body( token_fmt( "typename", Str name(Template), codetype_impl_tmpl )));
|
body_append(impl_code_tmpl, parse_global_body( token_fmt( "typename", name(Template), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_type, parse_global_body( token_fmt( "typename", Str name(Typename), codetype_impl_tmpl )));
|
body_append(impl_code_type, parse_global_body( token_fmt( "typename", name(Typename), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_typedef, parse_global_body( token_fmt( "typename", Str name(Typedef), codetype_impl_tmpl )));
|
body_append(impl_code_typedef, parse_global_body( token_fmt( "typename", name(Typedef), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_union, parse_global_body( token_fmt( "typename", Str name(Union), codetype_impl_tmpl )));
|
body_append(impl_code_union, parse_global_body( token_fmt( "typename", name(Union), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_using, parse_global_body( token_fmt( "typename", Str name(Using), codetype_impl_tmpl )));
|
body_append(impl_code_using, parse_global_body( token_fmt( "typename", name(Using), codetype_impl_tmpl )));
|
||||||
body_append(impl_code_var, parse_global_body( token_fmt( "typename", Str name(Var), codetype_impl_tmpl )));
|
body_append(impl_code_var, parse_global_body( token_fmt( "typename", name(Var), codetype_impl_tmpl )));
|
||||||
|
|
||||||
#pragma push_macro("forceinline")
|
#pragma push_macro("forceinline")
|
||||||
#undef forceinline
|
#undef forceinline
|
||||||
@ -564,35 +564,35 @@ CodeBody gen_ast_inlines()
|
|||||||
);
|
);
|
||||||
#pragma pop_macro("forceinline")
|
#pragma pop_macro("forceinline")
|
||||||
|
|
||||||
CodeBody impl_cast_body = parse_global_body( token_fmt( "typename", Str name(Body), cast_tmpl ));
|
CodeBody impl_cast_body = parse_global_body( token_fmt( "typename", name(Body), cast_tmpl ));
|
||||||
CodeBody impl_cast_attribute = parse_global_body( token_fmt( "typename", Str name(Attributes), cast_tmpl ));
|
CodeBody impl_cast_attribute = parse_global_body( token_fmt( "typename", name(Attributes), cast_tmpl ));
|
||||||
CodeBody impl_cast_cmt = parse_global_body( token_fmt( "typename", Str name(Comment), cast_tmpl ));
|
CodeBody impl_cast_cmt = parse_global_body( token_fmt( "typename", name(Comment), cast_tmpl ));
|
||||||
CodeBody impl_cast_constr = parse_global_body( token_fmt( "typename", Str name(Constructor), cast_tmpl ));
|
CodeBody impl_cast_constr = parse_global_body( token_fmt( "typename", name(Constructor), cast_tmpl ));
|
||||||
CodeBody impl_cast_class = parse_global_body( token_fmt( "typename", Str name(Class), cast_tmpl ));
|
CodeBody impl_cast_class = parse_global_body( token_fmt( "typename", name(Class), cast_tmpl ));
|
||||||
CodeBody impl_cast_define = parse_global_body( token_fmt( "typename", Str name(Define), cast_tmpl ));
|
CodeBody impl_cast_define = parse_global_body( token_fmt( "typename", name(Define), cast_tmpl ));
|
||||||
CodeBody impl_cast_define_params = parse_global_body( token_fmt( "typename", Str name(DefineParams), cast_tmpl ));
|
CodeBody impl_cast_define_params = parse_global_body( token_fmt( "typename", name(DefineParams), cast_tmpl ));
|
||||||
CodeBody impl_cast_destruct = parse_global_body( token_fmt( "typename", Str name(Destructor), cast_tmpl ));
|
CodeBody impl_cast_destruct = parse_global_body( token_fmt( "typename", name(Destructor), cast_tmpl ));
|
||||||
CodeBody impl_cast_enum = parse_global_body( token_fmt( "typename", Str name(Enum), cast_tmpl ));
|
CodeBody impl_cast_enum = parse_global_body( token_fmt( "typename", name(Enum), cast_tmpl ));
|
||||||
CodeBody impl_cast_exec = parse_global_body( token_fmt( "typename", Str name(Exec), cast_tmpl ));
|
CodeBody impl_cast_exec = parse_global_body( token_fmt( "typename", name(Exec), cast_tmpl ));
|
||||||
CodeBody impl_cast_extern = parse_global_body( token_fmt( "typename", Str name(Extern), cast_tmpl ));
|
CodeBody impl_cast_extern = parse_global_body( token_fmt( "typename", name(Extern), cast_tmpl ));
|
||||||
CodeBody impl_cast_friend = parse_global_body( token_fmt( "typename", Str name(Friend), cast_tmpl ));
|
CodeBody impl_cast_friend = parse_global_body( token_fmt( "typename", name(Friend), cast_tmpl ));
|
||||||
CodeBody impl_cast_fn = parse_global_body( token_fmt( "typename", Str name(Fn), cast_tmpl ));
|
CodeBody impl_cast_fn = parse_global_body( token_fmt( "typename", name(Fn), cast_tmpl ));
|
||||||
CodeBody impl_cast_include = parse_global_body( token_fmt( "typename", Str name(Include), cast_tmpl ));
|
CodeBody impl_cast_include = parse_global_body( token_fmt( "typename", name(Include), cast_tmpl ));
|
||||||
CodeBody impl_cast_module = parse_global_body( token_fmt( "typename", Str name(Module), cast_tmpl ));
|
CodeBody impl_cast_module = parse_global_body( token_fmt( "typename", name(Module), cast_tmpl ));
|
||||||
CodeBody impl_cast_ns = parse_global_body( token_fmt( "typename", Str name(NS), cast_tmpl ));
|
CodeBody impl_cast_ns = parse_global_body( token_fmt( "typename", name(NS), cast_tmpl ));
|
||||||
CodeBody impl_cast_op = parse_global_body( token_fmt( "typename", Str name(Operator), cast_tmpl ));
|
CodeBody impl_cast_op = parse_global_body( token_fmt( "typename", name(Operator), cast_tmpl ));
|
||||||
CodeBody impl_cast_opcast = parse_global_body( token_fmt( "typename", Str name(OpCast), cast_tmpl ));
|
CodeBody impl_cast_opcast = parse_global_body( token_fmt( "typename", name(OpCast), cast_tmpl ));
|
||||||
CodeBody impl_cast_params = parse_global_body( token_fmt( "typename", Str name(Params), cast_tmpl ));
|
CodeBody impl_cast_params = parse_global_body( token_fmt( "typename", name(Params), cast_tmpl ));
|
||||||
CodeBody impl_cast_pragma = parse_global_body( token_fmt( "typename", Str name(Pragma), cast_tmpl ));
|
CodeBody impl_cast_pragma = parse_global_body( token_fmt( "typename", name(Pragma), cast_tmpl ));
|
||||||
CodeBody impl_cast_precond = parse_global_body( token_fmt( "typename", Str name(PreprocessCond), cast_tmpl ));
|
CodeBody impl_cast_precond = parse_global_body( token_fmt( "typename", name(PreprocessCond), cast_tmpl ));
|
||||||
CodeBody impl_cast_specs = parse_global_body( token_fmt( "typename", Str name(Specifiers), cast_tmpl ));
|
CodeBody impl_cast_specs = parse_global_body( token_fmt( "typename", name(Specifiers), cast_tmpl ));
|
||||||
CodeBody impl_cast_struct = parse_global_body( token_fmt( "typename", Str name(Struct), cast_tmpl ));
|
CodeBody impl_cast_struct = parse_global_body( token_fmt( "typename", name(Struct), cast_tmpl ));
|
||||||
CodeBody impl_cast_tmpl = parse_global_body( token_fmt( "typename", Str name(Template), cast_tmpl ));
|
CodeBody impl_cast_tmpl = parse_global_body( token_fmt( "typename", name(Template), cast_tmpl ));
|
||||||
CodeBody impl_cast_type = parse_global_body( token_fmt( "typename", Str name(Typename), cast_tmpl ));
|
CodeBody impl_cast_type = parse_global_body( token_fmt( "typename", name(Typename), cast_tmpl ));
|
||||||
CodeBody impl_cast_typedef = parse_global_body( token_fmt( "typename", Str name(Typedef), cast_tmpl ));
|
CodeBody impl_cast_typedef = parse_global_body( token_fmt( "typename", name(Typedef), cast_tmpl ));
|
||||||
CodeBody impl_cast_union = parse_global_body( token_fmt( "typename", Str name(Union), cast_tmpl ));
|
CodeBody impl_cast_union = parse_global_body( token_fmt( "typename", name(Union), cast_tmpl ));
|
||||||
CodeBody impl_cast_using = parse_global_body( token_fmt( "typename", Str name(Using), cast_tmpl ));
|
CodeBody impl_cast_using = parse_global_body( token_fmt( "typename", name(Using), cast_tmpl ));
|
||||||
CodeBody impl_cast_var = parse_global_body( token_fmt( "typename", Str name(Var), cast_tmpl ));
|
CodeBody impl_cast_var = parse_global_body( token_fmt( "typename", name(Var), cast_tmpl ));
|
||||||
|
|
||||||
CodeBody result = def_global_body( args(
|
CodeBody result = def_global_body( args(
|
||||||
def_pragma( txt("region generated code inline implementation")),
|
def_pragma( txt("region generated code inline implementation")),
|
||||||
|
@ -147,6 +147,7 @@ int gen_main()
|
|||||||
Code strings = scan_file( path_base "dependencies/strings.hpp" );
|
Code strings = scan_file( path_base "dependencies/strings.hpp" );
|
||||||
Code filesystem = scan_file( path_base "dependencies/filesystem.hpp" );
|
Code filesystem = scan_file( path_base "dependencies/filesystem.hpp" );
|
||||||
Code timing = scan_file( path_base "dependencies/timing.hpp" );
|
Code timing = scan_file( path_base "dependencies/timing.hpp" );
|
||||||
|
Code parsing = scan_file( path_base "dependencies/parsing.hpp" );
|
||||||
|
|
||||||
Builder
|
Builder
|
||||||
header = Builder::open("gen/gen.dep.hpp");
|
header = Builder::open("gen/gen.dep.hpp");
|
||||||
@ -168,6 +169,7 @@ int gen_main()
|
|||||||
header.print( strings );
|
header.print( strings );
|
||||||
header.print( filesystem );
|
header.print( filesystem );
|
||||||
header.print( timing );
|
header.print( timing );
|
||||||
|
header.print(parsing);
|
||||||
|
|
||||||
header.print_fmt( "\nGEN_NS_END\n" );
|
header.print_fmt( "\nGEN_NS_END\n" );
|
||||||
header.print( fmt_newline );
|
header.print( fmt_newline );
|
||||||
@ -186,6 +188,7 @@ int gen_main()
|
|||||||
Code strings = scan_file( path_base "dependencies/strings.cpp" );
|
Code strings = scan_file( path_base "dependencies/strings.cpp" );
|
||||||
Code filesystem = scan_file( path_base "dependencies/filesystem.cpp" );
|
Code filesystem = scan_file( path_base "dependencies/filesystem.cpp" );
|
||||||
Code timing = scan_file( path_base "dependencies/timing.cpp" );
|
Code timing = scan_file( path_base "dependencies/timing.cpp" );
|
||||||
|
Code parsing = scan_file( path_base "dependencies/parsing.cpp" );
|
||||||
|
|
||||||
Builder
|
Builder
|
||||||
src = Builder::open( "gen/gen.dep.cpp" );
|
src = Builder::open( "gen/gen.dep.cpp" );
|
||||||
@ -204,6 +207,7 @@ int gen_main()
|
|||||||
src.print( strings );
|
src.print( strings );
|
||||||
src.print( filesystem );
|
src.print( filesystem );
|
||||||
src.print( timing );
|
src.print( timing );
|
||||||
|
src.print( parsing );
|
||||||
|
|
||||||
src.print_fmt( "\nGEN_NS_END\n" );
|
src.print_fmt( "\nGEN_NS_END\n" );
|
||||||
src.print( fmt_newline );
|
src.print( fmt_newline );
|
||||||
@ -310,14 +314,20 @@ int gen_main()
|
|||||||
|
|
||||||
src.print_fmt( "\n#pragma region Interface\n" );
|
src.print_fmt( "\n#pragma region Interface\n" );
|
||||||
src.print( interface );
|
src.print( interface );
|
||||||
|
|
||||||
src.print( upfront );
|
src.print( upfront );
|
||||||
|
|
||||||
src.print_fmt( "\n#pragma region Parsing\n\n" );
|
src.print_fmt( "\n#pragma region Parsing\n\n" );
|
||||||
src.print( lexer );
|
src.print( lexer );
|
||||||
src.print( parser_case_macros );
|
src.print( parser_case_macros );
|
||||||
src.print( parser );
|
src.print( parser );
|
||||||
src.print( parsing_interface );
|
src.print( parsing_interface );
|
||||||
src.print( untyped );
|
|
||||||
src.print_fmt( "\n#pragma endregion Parsing\n\n" );
|
src.print_fmt( "\n#pragma endregion Parsing\n\n" );
|
||||||
|
|
||||||
|
src.print_fmt( "\n#pragma region Untyped\n\n" );
|
||||||
|
src.print( untyped );
|
||||||
|
src.print_fmt( "#pragma endregion \n\n" );
|
||||||
|
|
||||||
src.print_fmt( "#pragma endregion Interface\n\n" );
|
src.print_fmt( "#pragma endregion Interface\n\n" );
|
||||||
|
|
||||||
src.print_fmt( "GEN_NS_END\n\n");
|
src.print_fmt( "GEN_NS_END\n\n");
|
||||||
@ -364,7 +374,6 @@ int gen_main()
|
|||||||
|
|
||||||
// gen_scanner.hpp
|
// gen_scanner.hpp
|
||||||
{
|
{
|
||||||
Code parsing = scan_file( path_base "dependencies/parsing.hpp" );
|
|
||||||
Code scanner = scan_file( path_base "auxillary/scanner.hpp" );
|
Code scanner = scan_file( path_base "auxillary/scanner.hpp" );
|
||||||
|
|
||||||
Builder
|
Builder
|
||||||
@ -375,7 +384,6 @@ int gen_main()
|
|||||||
header.print( fmt_newline );
|
header.print( fmt_newline );
|
||||||
header.print( def_include( txt("gen.hpp") ) );
|
header.print( def_include( txt("gen.hpp") ) );
|
||||||
header.print_fmt( "\nGEN_NS_BEGIN\n" );
|
header.print_fmt( "\nGEN_NS_BEGIN\n" );
|
||||||
header.print( parsing );
|
|
||||||
header.print( scanner );
|
header.print( scanner );
|
||||||
header.print_fmt( "\nGEN_NS_END\n" );
|
header.print_fmt( "\nGEN_NS_END\n" );
|
||||||
header.print( fmt_newline );
|
header.print( fmt_newline );
|
||||||
@ -385,7 +393,6 @@ int gen_main()
|
|||||||
|
|
||||||
// gen.scanner.cpp
|
// gen.scanner.cpp
|
||||||
{
|
{
|
||||||
Code parsing = scan_file( path_base "dependencies/parsing.cpp" );
|
|
||||||
Code scanner = scan_file( path_base "auxillary/scanner.cpp" );
|
Code scanner = scan_file( path_base "auxillary/scanner.cpp" );
|
||||||
|
|
||||||
Builder
|
Builder
|
||||||
@ -395,8 +402,7 @@ int gen_main()
|
|||||||
src.print( fmt_newline );
|
src.print( fmt_newline );
|
||||||
src.print( def_include( txt("gen.scanner.hpp") ) );
|
src.print( def_include( txt("gen.scanner.hpp") ) );
|
||||||
src.print_fmt( "\nGEN_NS_BEGIN\n" );
|
src.print_fmt( "\nGEN_NS_BEGIN\n" );
|
||||||
src.print( parsing );
|
src.print( scanner );
|
||||||
// src.print( scanner );
|
|
||||||
src.print_fmt( "\nGEN_NS_END\n" );
|
src.print_fmt( "\nGEN_NS_END\n" );
|
||||||
src.print( fmt_newline );
|
src.print( fmt_newline );
|
||||||
src.print( pop_ignores );
|
src.print( pop_ignores );
|
||||||
|
Loading…
Reference in New Issue
Block a user