mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 11:11:46 -07:00
generated c_library compiles
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
|
||||
#pragma region Constants
|
||||
|
||||
extern PreprocessorMacro enum_underlying_macro;
|
||||
extern Macro enum_underlying_macro;
|
||||
|
||||
extern Code access_public;
|
||||
extern Code access_protected;
|
||||
|
@ -179,28 +179,28 @@ void define_constants()
|
||||
#endif
|
||||
|
||||
spec_const = def_specifier( Spec_Const); code_set_global( cast(Code, spec_const ));
|
||||
spec_consteval = def_specifier( Spec_Consteval); code_set_global( cast(Code, spec_consteval ));;
|
||||
spec_constexpr = def_specifier( Spec_Constexpr); code_set_global( cast(Code, spec_constexpr ));;
|
||||
spec_constinit = def_specifier( Spec_Constinit); code_set_global( cast(Code, spec_constinit ));;
|
||||
spec_extern_linkage = def_specifier( Spec_External_Linkage); code_set_global( cast(Code, spec_extern_linkage ));;
|
||||
spec_final = def_specifier( Spec_Final); code_set_global( cast(Code, spec_final ));;
|
||||
spec_forceinline = def_specifier( Spec_ForceInline); code_set_global( cast(Code, spec_forceinline ));;
|
||||
spec_global = def_specifier( Spec_Global); code_set_global( cast(Code, spec_global ));;
|
||||
spec_inline = def_specifier( Spec_Inline); code_set_global( cast(Code, spec_inline ));;
|
||||
spec_internal_linkage = def_specifier( Spec_Internal_Linkage); code_set_global( cast(Code, spec_internal_linkage ));;
|
||||
spec_local_persist = def_specifier( Spec_Local_Persist); code_set_global( cast(Code, spec_local_persist ));;
|
||||
spec_mutable = def_specifier( Spec_Mutable); code_set_global( cast(Code, spec_mutable ));;
|
||||
spec_neverinline = def_specifier( Spec_NeverInline); code_set_global( cast(Code, spec_neverinline ));;
|
||||
spec_noexcept = def_specifier( Spec_NoExceptions); code_set_global( cast(Code, spec_noexcept ));;
|
||||
spec_override = def_specifier( Spec_Override); code_set_global( cast(Code, spec_override ));;
|
||||
spec_ptr = def_specifier( Spec_Ptr); code_set_global( cast(Code, spec_ptr ));;
|
||||
spec_consteval = def_specifier( Spec_Consteval); code_set_global( cast(Code, spec_consteval ));
|
||||
spec_constexpr = def_specifier( Spec_Constexpr); code_set_global( cast(Code, spec_constexpr ));
|
||||
spec_constinit = def_specifier( Spec_Constinit); code_set_global( cast(Code, spec_constinit ));
|
||||
spec_extern_linkage = def_specifier( Spec_External_Linkage); code_set_global( cast(Code, spec_extern_linkage ));
|
||||
spec_final = def_specifier( Spec_Final); code_set_global( cast(Code, spec_final ));
|
||||
spec_forceinline = def_specifier( Spec_ForceInline); code_set_global( cast(Code, spec_forceinline ));
|
||||
spec_global = def_specifier( Spec_Global); code_set_global( cast(Code, spec_global ));
|
||||
spec_inline = def_specifier( Spec_Inline); code_set_global( cast(Code, spec_inline ));
|
||||
spec_internal_linkage = def_specifier( Spec_Internal_Linkage); code_set_global( cast(Code, spec_internal_linkage ));
|
||||
spec_local_persist = def_specifier( Spec_Local_Persist); code_set_global( cast(Code, spec_local_persist ));
|
||||
spec_mutable = def_specifier( Spec_Mutable); code_set_global( cast(Code, spec_mutable ));
|
||||
spec_neverinline = def_specifier( Spec_NeverInline); code_set_global( cast(Code, spec_neverinline ));
|
||||
spec_noexcept = def_specifier( Spec_NoExceptions); code_set_global( cast(Code, spec_noexcept ));
|
||||
spec_override = def_specifier( Spec_Override); code_set_global( cast(Code, spec_override ));
|
||||
spec_ptr = def_specifier( Spec_Ptr); code_set_global( cast(Code, spec_ptr ));
|
||||
spec_pure = def_specifier( Spec_Pure); code_set_global( cast(Code, spec_pure ));
|
||||
spec_ref = def_specifier( Spec_Ref); code_set_global( cast(Code, spec_ref ));;
|
||||
spec_register = def_specifier( Spec_Register); code_set_global( cast(Code, spec_register ));;
|
||||
spec_rvalue = def_specifier( Spec_RValue); code_set_global( cast(Code, spec_rvalue ));;
|
||||
spec_static_member = def_specifier( Spec_Static); code_set_global( cast(Code, spec_static_member ));;
|
||||
spec_thread_local = def_specifier( Spec_Thread_Local); code_set_global( cast(Code, spec_thread_local ));;
|
||||
spec_virtual = def_specifier( Spec_Virtual); code_set_global( cast(Code, spec_virtual ));;
|
||||
spec_ref = def_specifier( Spec_Ref); code_set_global( cast(Code, spec_ref ));
|
||||
spec_register = def_specifier( Spec_Register); code_set_global( cast(Code, spec_register ));
|
||||
spec_rvalue = def_specifier( Spec_RValue); code_set_global( cast(Code, spec_rvalue ));
|
||||
spec_static_member = def_specifier( Spec_Static); code_set_global( cast(Code, spec_static_member ));
|
||||
spec_thread_local = def_specifier( Spec_Thread_Local); code_set_global( cast(Code, spec_thread_local ));
|
||||
spec_virtual = def_specifier( Spec_Virtual); code_set_global( cast(Code, spec_virtual ));
|
||||
spec_volatile = def_specifier( Spec_Volatile); code_set_global( cast(Code, spec_volatile ));
|
||||
|
||||
spec_local_persist = def_specifiers( 1, Spec_Local_Persist );
|
||||
@ -211,7 +211,7 @@ void define_constants()
|
||||
enum_underlying_macro.Type = MT_Expression;
|
||||
enum_underlying_macro.Flags = MF_Functional;
|
||||
}
|
||||
register_preprocess_macro(enum_underlying_macro);
|
||||
register_macro(enum_underlying_macro);
|
||||
}
|
||||
|
||||
void init(Context* ctx)
|
||||
@ -315,8 +315,8 @@ void init(Context* ctx)
|
||||
if ( ctx->StrCache.Entries == nullptr )
|
||||
GEN_FATAL( "gen::init: Failed to initialize the StringCache");
|
||||
|
||||
ctx->PreprocessorMacros = hashtable_init(PreprocessorMacro, ctx->Allocator_DyanmicContainers);
|
||||
if (ctx->PreprocessorMacros.Hashes == nullptr || ctx->PreprocessorMacros.Entries == nullptr) {
|
||||
ctx->Macros = hashtable_init(Macro, ctx->Allocator_DyanmicContainers);
|
||||
if (ctx->Macros.Hashes == nullptr || ctx->Macros.Entries == nullptr) {
|
||||
GEN_FATAL( "gen::init: Failed to initialize the PreprocessMacros table" );
|
||||
}
|
||||
}
|
||||
@ -356,7 +356,7 @@ void deinit(Context* ctx)
|
||||
array_free( ctx->CodePools);
|
||||
array_free( ctx->StringArenas);
|
||||
|
||||
hashtable_destroy(ctx->PreprocessorMacros);
|
||||
hashtable_destroy(ctx->Macros);
|
||||
|
||||
left = array_num( ctx->Fallback_AllocatorBuckets);
|
||||
if (left)
|
||||
@ -401,7 +401,7 @@ void reset(Context* ctx)
|
||||
while ( left--, left );
|
||||
|
||||
hashtable_clear(ctx->StrCache);
|
||||
hashtable_clear(ctx->PreprocessorMacros);
|
||||
hashtable_clear(ctx->Macros);
|
||||
define_constants();
|
||||
}
|
||||
|
||||
@ -464,47 +464,47 @@ Code make_code()
|
||||
return result;
|
||||
}
|
||||
|
||||
PreprocessorMacro* lookup_preprocess_macro( Str name ) {
|
||||
Macro* lookup_macro( Str name ) {
|
||||
u32 key = crc32( name.Ptr, name.Len );
|
||||
return hashtable_get( _ctx->PreprocessorMacros, key );
|
||||
return hashtable_get( _ctx->Macros, key );
|
||||
}
|
||||
|
||||
void register_preprocess_macro( PreprocessorMacro macro ) {
|
||||
void register_macro( Macro macro ) {
|
||||
GEN_ASSERT_NOT_NULL(macro.Name.Ptr);
|
||||
GEN_ASSERT(macro.Name.Len > 0);
|
||||
u32 key = crc32( macro.Name.Ptr, macro.Name.Len );
|
||||
hashtable_set( _ctx->PreprocessorMacros, key, macro );
|
||||
hashtable_set( _ctx->Macros, key, macro );
|
||||
}
|
||||
|
||||
void register_preprocess_macros( s32 num, ... )
|
||||
void register_macros( s32 num, ... )
|
||||
{
|
||||
GEN_ASSERT(num > 0);
|
||||
va_list va;
|
||||
va_start(va, num);
|
||||
do
|
||||
{
|
||||
PreprocessorMacro macro = va_arg(va, PreprocessorMacro);
|
||||
Macro macro = va_arg(va, Macro);
|
||||
GEN_ASSERT_NOT_NULL(macro.Name.Ptr);
|
||||
GEN_ASSERT(macro.Name.Len > 0);
|
||||
|
||||
u32 key = crc32( macro.Name.Ptr, macro.Name.Len );
|
||||
hashtable_set( _ctx->PreprocessorMacros, key, macro );
|
||||
hashtable_set( _ctx->Macros, key, macro );
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void register_preprocess_macros( s32 num, PreprocessorMacro* macros )
|
||||
void register_macros( s32 num, Macro* macros )
|
||||
{
|
||||
GEN_ASSERT(num > 0);
|
||||
do
|
||||
{
|
||||
PreprocessorMacro macro = * macros;
|
||||
Macro macro = * macros;
|
||||
GEN_ASSERT_NOT_NULL(macro.Name.Ptr);
|
||||
GEN_ASSERT(macro.Name.Len > 0);
|
||||
|
||||
u32 key = crc32( macro.Name.Ptr, macro.Name.Len );
|
||||
hashtable_set( _ctx->PreprocessorMacros, key, macro );
|
||||
hashtable_set( _ctx->Macros, key, macro );
|
||||
++ macros;
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
@ -71,7 +71,7 @@ struct Context
|
||||
// Used by the lexer to persistently treat all these identifiers as preprocessor defines.
|
||||
// Populate with strings via gen::cache_str.
|
||||
// Functional defines must have format: id( ;at minimum to indicate that the define is only valid with arguments.
|
||||
HashTable(PreprocessorMacro) PreprocessorMacros;
|
||||
MacroTable Macros;
|
||||
|
||||
// Backend
|
||||
|
||||
@ -107,16 +107,16 @@ GEN_API void reset(Context* ctx);
|
||||
GEN_API void set_context(Context* ctx);
|
||||
|
||||
// Mostly intended for the parser
|
||||
GEN_API PreprocessorMacro* lookup_preprocess_macro( Str Name );
|
||||
GEN_API Macro* lookup_macro( Str Name );
|
||||
|
||||
// Alternative way to add a preprocess define entry for the lexer & parser to utilize
|
||||
// if the user doesn't want to use def_define
|
||||
// Macros are tracked by name so if the name already exists the entry will be overwritten.
|
||||
GEN_API void register_preprocess_macro( PreprocessorMacro macro );
|
||||
GEN_API void register_macro( Macro macro );
|
||||
|
||||
// Ease of use batch registration
|
||||
GEN_API void register_preprocess_macros( s32 num, ... );
|
||||
GEN_API void register_preprocess_macros( s32 num, PreprocessorMacro* macros );
|
||||
GEN_API void register_macros( s32 num, ... );
|
||||
GEN_API void register_macros( s32 num, Macro* macros );
|
||||
|
||||
// Used internally to retrive or make string allocations.
|
||||
// Strings are stored in a series of string arenas of fixed size (SizePer_StringArena)
|
||||
|
@ -578,8 +578,8 @@ CodeDefine def_define( Str name, MacroType type, Opts_def_define p )
|
||||
|
||||
b32 register_define = ! p.dont_register_to_preprocess_macros;
|
||||
if ( register_define ) {
|
||||
PreprocessorMacro macro_entry = { result->Name, type, p.flags };
|
||||
register_preprocess_macro(macro_entry);
|
||||
Macro macro_entry = { result->Name, type, p.flags };
|
||||
register_macro(macro_entry);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -128,8 +128,8 @@ s32 lex_preprocessor_define( LexContext* ctx )
|
||||
b32 not_specifier = spec == Spec_Invalid;
|
||||
b32 not_attribute = attrib <= Tok___Attributes_Start;
|
||||
|
||||
PreprocessorMacro macro = { name.Text, MT_Expression, (MacroFlags)0 };
|
||||
PreprocessorMacro* registered_macro = lookup_preprocess_macro(name.Text);
|
||||
Macro macro = { name.Text, MT_Expression, (MacroFlags)0 };
|
||||
Macro* registered_macro = lookup_macro(name.Text);
|
||||
|
||||
if ( registered_macro == nullptr && not_specifier && not_attribute ) {
|
||||
log_fmt("Warning: '%S' was not registered before the lexer processed its #define directive, it will be registered as a expression macro\n"
|
||||
@ -256,7 +256,7 @@ s32 lex_preprocessor_define( LexContext* ctx )
|
||||
}
|
||||
|
||||
if ( registered_macro == nullptr ) {
|
||||
register_preprocess_macro(macro);
|
||||
register_macro(macro);
|
||||
}
|
||||
|
||||
// Define's content handled by lex_preprocessor_directive (the original caller of this)
|
||||
@ -525,7 +525,7 @@ void lex_found_token( LexContext* ctx )
|
||||
return;
|
||||
}
|
||||
|
||||
PreprocessorMacro* macro = lookup_preprocess_macro( ctx->token.Text );
|
||||
Macro* macro = lookup_macro( ctx->token.Text );
|
||||
b32 has_args = ctx->left && (* ctx->scanner) == '(';
|
||||
b32 resolved_to_macro = false;
|
||||
if (macro) {
|
||||
|
@ -97,7 +97,7 @@ bool lex__eat(TokArray* self, TokType type )
|
||||
b32 is_identifier = at_idx.Type == Tok_Identifier;
|
||||
if ( not_accepted )
|
||||
{
|
||||
PreprocessorMacro* macro = lookup_preprocess_macro(at_idx.Text);
|
||||
Macro* macro = lookup_macro(at_idx.Text);
|
||||
b32 accept_as_identifier = macro && bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Identifier );
|
||||
not_accepted = type == Tok_Identifier && accept_as_identifier ? false : true;
|
||||
}
|
||||
@ -196,7 +196,6 @@ internal CodeComment parse_comment ();
|
||||
internal Code parse_complicated_definition ( TokType which );
|
||||
internal CodeBody parse_class_struct_body ( TokType which, Token name );
|
||||
internal Code parse_class_struct ( TokType which, bool inplace_def );
|
||||
internal CodeDefine parser_parse_define ();
|
||||
internal Code parse_expression ();
|
||||
internal Code parse_forward_or_definition ( TokType which, bool is_inplace );
|
||||
internal CodeFn parse_function_after_name ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename ret_type, Token name );
|
||||
@ -216,8 +215,9 @@ internal void parse_template_args ( Token* token );
|
||||
internal CodeVar parse_variable_after_name ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename type, Str name );
|
||||
internal CodeVar parse_variable_declaration_list ();
|
||||
|
||||
internal CodeClass parser_parse_class ( bool inplace_def );
|
||||
internal CodeClass parser_parse_class ( bool inplace_def );
|
||||
internal CodeConstructor parser_parse_constructor ( CodeSpecifiers specifiers );
|
||||
internal CodeDefine parser_parse_define ();
|
||||
internal CodeDestructor parser_parse_destructor ( CodeSpecifiers specifiers );
|
||||
internal CodeEnum parser_parse_enum ( bool inplace_def );
|
||||
internal CodeBody parser_parse_export_body ();
|
||||
@ -1293,89 +1293,6 @@ Code parse_complicated_definition( TokType which )
|
||||
}
|
||||
}
|
||||
|
||||
internal inline
|
||||
CodeDefine parser_parse_define()
|
||||
{
|
||||
push_scope();
|
||||
if ( check(Tok_Preprocess_Hash)) {
|
||||
// If parse_define is called by the user the hash reach here.
|
||||
eat(Tok_Preprocess_Hash);
|
||||
}
|
||||
|
||||
eat( Tok_Preprocess_Define );
|
||||
// #define
|
||||
|
||||
CodeDefine
|
||||
define = (CodeDefine) make_code();
|
||||
define->Type = CT_Preprocess_Define;
|
||||
if ( ! check( Tok_Identifier ) ) {
|
||||
log_failure( "Error, expected identifier after #define\n%s", parser_to_strbuilder(_ctx->parser) );
|
||||
parser_pop(& _ctx->parser);
|
||||
return InvalidCode;
|
||||
}
|
||||
_ctx->parser.Scope->Name = currtok.Text;
|
||||
define->Name = cache_str( tok_to_str(currtok) );
|
||||
eat( Tok_Identifier );
|
||||
// #define <Name>
|
||||
|
||||
PreprocessorMacro* macro = lookup_preprocess_macro(define->Name);
|
||||
if (macro_is_functional(* macro)) {
|
||||
eat( Tok_Capture_Start );
|
||||
// #define <Name> (
|
||||
CodeDefineParams params;
|
||||
if ( left && currtok.Type != Tok_Capture_End ) {
|
||||
params = (CodeDefineParams) make_code();
|
||||
params->Type = CT_Parameters_Define;
|
||||
params->Name = currtok.Text;
|
||||
params->NumEntries ++;
|
||||
|
||||
define->Params = params;
|
||||
eat( Tok_Preprocess_Define_Param );
|
||||
// #define <Name> ( <param>
|
||||
}
|
||||
|
||||
while( left && currtok.Type != Tok_Capture_End ) {
|
||||
eat( Tok_Comma );
|
||||
// #define <Name> ( <param>,
|
||||
|
||||
CodeDefineParams next_param = (CodeDefineParams) make_code();
|
||||
next_param->Type = CT_Parameters_Define;
|
||||
next_param->Name = currtok.Text;
|
||||
define_params_append(params, next_param);
|
||||
|
||||
// #define <Name> ( <param>, <next_param> ...
|
||||
eat( Tok_Preprocess_Define_Param );
|
||||
}
|
||||
|
||||
eat( Tok_Capture_End );
|
||||
// #define <Name> ( <params> )
|
||||
}
|
||||
|
||||
if ( ! check( Tok_Preprocess_Content ))
|
||||
{
|
||||
log_failure( "Error, expected content after #define %s\n%s", define->Name, parser_to_strbuilder(_ctx->parser) );
|
||||
parser_pop(& _ctx->parser);
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( currtok.Text.Len == 0 )
|
||||
{
|
||||
define->Body = untyped_str( txt("\n") );
|
||||
eat( Tok_Preprocess_Content );
|
||||
// #define <Name> ( <params> ) <Content>
|
||||
|
||||
parser_pop(& _ctx->parser);
|
||||
return define;
|
||||
}
|
||||
|
||||
define->Body = untyped_str( strbuilder_to_str( parser_strip_formatting( tok_to_str(currtok), parser_strip_formatting_dont_preserve_newlines )) );
|
||||
eat( Tok_Preprocess_Content );
|
||||
// #define <Name> ( <params> ) <Content>
|
||||
|
||||
parser_pop(& _ctx->parser);
|
||||
return define;
|
||||
}
|
||||
|
||||
internal inline
|
||||
Code parse_assignment_expression()
|
||||
{
|
||||
@ -2945,7 +2862,7 @@ Code parse_simple_preprocess( TokType which )
|
||||
eat( which );
|
||||
// <Macro>
|
||||
|
||||
PreprocessorMacro* macro = lookup_preprocess_macro( full_macro.Text );
|
||||
Macro* macro = lookup_macro( full_macro.Text );
|
||||
if ( which != Tok_Preprocess_Unsupported && macro == nullptr ) {
|
||||
log_failure("Expected the macro %S to be registered\n%S", full_macro, parser_to_strbuilder(_ctx->parser));
|
||||
return NullCode;
|
||||
@ -3484,6 +3401,93 @@ CodeConstructor parser_parse_constructor( CodeSpecifiers specifiers )
|
||||
return result;
|
||||
}
|
||||
|
||||
internal inline
|
||||
CodeDefine parser_parse_define()
|
||||
{
|
||||
push_scope();
|
||||
if ( check(Tok_Preprocess_Hash)) {
|
||||
// If parse_define is called by the user the hash reach here.
|
||||
eat(Tok_Preprocess_Hash);
|
||||
}
|
||||
|
||||
eat( Tok_Preprocess_Define );
|
||||
// #define
|
||||
|
||||
CodeDefine
|
||||
define = (CodeDefine) make_code();
|
||||
define->Type = CT_Preprocess_Define;
|
||||
if ( ! check( Tok_Identifier ) ) {
|
||||
log_failure( "Error, expected identifier after #define\n%s", parser_to_strbuilder(_ctx->parser) );
|
||||
parser_pop(& _ctx->parser);
|
||||
return InvalidCode;
|
||||
}
|
||||
_ctx->parser.Scope->Name = currtok.Text;
|
||||
define->Name = cache_str( tok_to_str(currtok) );
|
||||
eat( Tok_Identifier );
|
||||
// #define <Name>
|
||||
|
||||
Macro* macro = lookup_macro(define->Name);
|
||||
if (macro_is_functional(* macro)) {
|
||||
eat( Tok_Capture_Start );
|
||||
// #define <Name> (
|
||||
|
||||
// We provide the define params even if empty to make sure '()' are serialized.
|
||||
CodeDefineParams
|
||||
params = (CodeDefineParams) make_code();
|
||||
params->Type = CT_Parameters_Define;
|
||||
|
||||
if ( left && currtok.Type != Tok_Capture_End ) {
|
||||
params->Name = currtok.Text;
|
||||
params->NumEntries ++;
|
||||
|
||||
eat( Tok_Preprocess_Define_Param );
|
||||
// #define <Name> ( <param>
|
||||
}
|
||||
|
||||
while( left && currtok.Type != Tok_Capture_End ) {
|
||||
eat( Tok_Comma );
|
||||
// #define <Name> ( <param>,
|
||||
|
||||
CodeDefineParams next_param = (CodeDefineParams) make_code();
|
||||
next_param->Type = CT_Parameters_Define;
|
||||
next_param->Name = currtok.Text;
|
||||
define_params_append(params, next_param);
|
||||
|
||||
// #define <Name> ( <param>, <next_param> ...
|
||||
eat( Tok_Preprocess_Define_Param );
|
||||
}
|
||||
|
||||
eat( Tok_Capture_End );
|
||||
// #define <Name> ( <params> )
|
||||
|
||||
define->Params = params;
|
||||
}
|
||||
|
||||
if ( ! check( Tok_Preprocess_Content ))
|
||||
{
|
||||
log_failure( "Error, expected content after #define %s\n%s", define->Name, parser_to_strbuilder(_ctx->parser) );
|
||||
parser_pop(& _ctx->parser);
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( currtok.Text.Len == 0 )
|
||||
{
|
||||
define->Body = untyped_str( txt("\n") );
|
||||
eat( Tok_Preprocess_Content );
|
||||
// #define <Name> ( <params> ) <Content>
|
||||
|
||||
parser_pop(& _ctx->parser);
|
||||
return define;
|
||||
}
|
||||
|
||||
define->Body = untyped_str( strbuilder_to_str( parser_strip_formatting( tok_to_str(currtok), parser_strip_formatting_dont_preserve_newlines )) );
|
||||
eat( Tok_Preprocess_Content );
|
||||
// #define <Name> ( <params> ) <Content>
|
||||
|
||||
parser_pop(& _ctx->parser);
|
||||
return define;
|
||||
}
|
||||
|
||||
internal
|
||||
CodeDestructor parser_parse_destructor( CodeSpecifiers specifiers )
|
||||
{
|
||||
@ -4960,7 +4964,7 @@ CodeTypedef parser_parse_typedef()
|
||||
valid_macro |= left && currtok.Type == Tok_Preprocess_Macro_Stmt;
|
||||
// if (currtok.Type == Tok_Preprocess_Macro_Stmt)
|
||||
// {
|
||||
// PreprocessMacro* macro = lookup_preprocess_macro(currtok.Text);
|
||||
// PreprocessMacro* macro = lookup_macro(currtok.Text);
|
||||
// valid_macro |= macro && macro_expects_body(* macro));
|
||||
// }
|
||||
|
||||
|
@ -185,7 +185,7 @@ enum EMacroFlags : u16
|
||||
};
|
||||
typedef u16 MacroFlags;
|
||||
|
||||
struct PreprocessorMacro
|
||||
struct Macro
|
||||
{
|
||||
StrCached Name;
|
||||
MacroType Type;
|
||||
@ -193,11 +193,13 @@ struct PreprocessorMacro
|
||||
};
|
||||
|
||||
forceinline
|
||||
b32 macro_is_functional( PreprocessorMacro macro ) {
|
||||
b32 macro_is_functional( Macro macro ) {
|
||||
return bitfield_is_set( b16, macro.Flags, MF_Functional );
|
||||
}
|
||||
|
||||
forceinline
|
||||
b32 macro_expects_body( PreprocessorMacro macro ) {
|
||||
b32 macro_expects_body( Macro macro ) {
|
||||
return bitfield_is_set( b16, macro.Flags, MF_Expects_Body );
|
||||
}
|
||||
|
||||
typedef HashTable(Macro) MacroTable;
|
||||
|
@ -9,7 +9,7 @@ global Context* _ctx;
|
||||
#pragma region Constants
|
||||
global u32 context_counter;
|
||||
|
||||
global PreprocessorMacro enum_underlying_macro;
|
||||
global Macro enum_underlying_macro;
|
||||
|
||||
global Code Code_Global;
|
||||
global Code Code_Invalid;
|
||||
|
Reference in New Issue
Block a user