Added support for predefining preprocessor defines before parsing strings of code.

This prevents issues for preprocessor defines not getting treated properly for specific circumstances (such as macro wrappers for specifiers).
This commit is contained in:
2023-11-21 20:09:14 -05:00
parent be023325a9
commit 772db608be
6 changed files with 57 additions and 18 deletions

View File

@ -289,6 +289,9 @@ void init()
GEN_FATAL( "gen::init: Failed to initialize the StringCache");
}
// Preprocessor Defines
PreprocessorDefines = Array<StringCached>::init_reserve( GlobalAllocator, kilobytes(1) );
define_constants();
parser::init();
}
@ -332,6 +335,8 @@ void deinit()
}
while ( left--, left );
PreprocessorDefines.free();
Global_AllocatorBuckets.free();
parser::deinit();
}
@ -418,18 +423,18 @@ Code make_code()
}
Code result { rcast( AST*, alloc( * allocator, sizeof(AST) )) };
// mem_set( result.ast, 0, sizeof(AST) );
result->Type = ECode::Invalid;
mem_set( result.ast, 0, sizeof(AST) );
// result->Type = ECode::Invalid;
result->Content = { nullptr };
result->Prev = { nullptr };
result->Next = { nullptr };
result->Token = nullptr;
result->Parent = { nullptr };
result->Name = { nullptr };
result->Type = ECode::Invalid;
result->ModuleFlags = ModuleFlag::Invalid;
result->NumEntries = 0;
// result->Content = { nullptr };
// result->Prev = { nullptr };
// result->Next = { nullptr };
// result->Token = nullptr;
// result->Parent = { nullptr };
// result->Name = { nullptr };
// result->Type = ECode::Invalid;
// result->ModuleFlags = ModuleFlag::Invalid;
// result->NumEntries = 0;
return result;
}