mirror of
https://github.com/Ed94/gencpp.git
synced 2025-07-01 03:11:03 -07:00
Compare commits
38 Commits
v0.22-Alph
...
6533a3be29
Author | SHA1 | Date | |
---|---|---|---|
6533a3be29 | |||
adbcb2a83b | |||
15847f10b9 | |||
8952cf5f1b | |||
2bdd49fd19 | |||
0f95c916dd | |||
527fb3b132 | |||
abffa74ad8 | |||
772d0de5c1 | |||
cb50f93af5 | |||
e4f564b165 | |||
0b78b74fbc | |||
5d8883ec45 | |||
c90c210e04 | |||
980d1d7134 | |||
b027778328 | |||
a6143e12b4 | |||
868b93cdd0 | |||
0b03b3cd92 | |||
572e957c17 | |||
63bc3bebed | |||
70872c29d1 | |||
e9752cb906 | |||
7946954017 | |||
4fe1a4da65 | |||
956ab73130 | |||
f93250da07 | |||
1b4f9a2e77 | |||
c8cf55403b | |||
76257123da | |||
3c249d2fae | |||
683f13deab | |||
a7da5f2060 | |||
db88979b75 | |||
e04f72ddca | |||
e8bb381520 | |||
a33b3644d9 | |||
96ffca3094 |
9
.gitignore
vendored
9
.gitignore
vendored
@ -32,3 +32,12 @@ test/gen/original
|
||||
singleheader/gen/scratch.hpp
|
||||
test/gen/scratch.cpp
|
||||
gen_c_library/gen
|
||||
|
||||
**/*.sln
|
||||
**/*.sln.DotSettings.user
|
||||
**/*.10x
|
||||
**/*.vcxproj
|
||||
**/*.vcxproj.filters
|
||||
**/*.vcxproj.user
|
||||
test/c_library/gen
|
||||
test/cpp_library/gen
|
||||
|
67
.vscode/c_cpp_properties.json
vendored
67
.vscode/c_cpp_properties.json
vendored
@ -28,27 +28,6 @@
|
||||
"/FC"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Win32 msvc c_library",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/gen_c_library/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
"GEN_TIME",
|
||||
"GEN_IMPLEMENTATION",
|
||||
// "GEN_DONT_USE_NAMESPACE"
|
||||
"GEN_INTELLISENSE_DIRECTIVES",
|
||||
"INTELLISENSE_DIRECTIVES"
|
||||
],
|
||||
"cppStandard": "c++17",
|
||||
"windowsSdkVersion": "10.0.19041.0",
|
||||
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe",
|
||||
"intelliSenseMode": "msvc-x64",
|
||||
"compileCommands": "${workspaceFolder}/.vscode/tasks.json"
|
||||
},
|
||||
{
|
||||
"name": "Win32 clang",
|
||||
"includePath": [
|
||||
@ -64,10 +43,56 @@
|
||||
"GEN_INTELLISENSE_DIRECTIVES",
|
||||
"INTELLISENSE_DIRECTIVES"
|
||||
],
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"windowsSdkVersion": "10.0.19041.0",
|
||||
"compilerPath": "clang++.exe",
|
||||
"intelliSenseMode": "windows-clang-x64",
|
||||
"compileCommands": "${workspaceFolder}/.vscode/tasks.json"
|
||||
},
|
||||
{
|
||||
"name": "Win32 msvc c_library",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/gen_c_library/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
"GEN_TIME",
|
||||
"GEN_IMPLEMENTATION",
|
||||
// "GEN_DONT_USE_NAMESPACE"
|
||||
"GEN_INTELLISENSE_DIRECTIVES",
|
||||
"INTELLISENSE_DIRECTIVES"
|
||||
],
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"windowsSdkVersion": "10.0.19041.0",
|
||||
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe",
|
||||
"intelliSenseMode": "msvc-x64",
|
||||
"compileCommands": "${workspaceFolder}/.vscode/tasks.json"
|
||||
},
|
||||
{
|
||||
"name": "Win32 msvc c_library test",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/test/c_library/**",
|
||||
"${workspaceFolder}/gen_c_library/gen/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
"GEN_TIME",
|
||||
"GEN_IMPLEMENTATION",
|
||||
// "GEN_DONT_USE_NAMESPACE"
|
||||
"GEN_INTELLISENSE_DIRECTIVES",
|
||||
"INTELLISENSE_DIRECTIVES"
|
||||
],
|
||||
"cStandard": "c11",
|
||||
"windowsSdkVersion": "10.0.19041.0",
|
||||
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe",
|
||||
"intelliSenseMode": "msvc-x64",
|
||||
"compileCommands": "${workspaceFolder}/.vscode/tasks.json"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
|
22
.vscode/settings.json
vendored
22
.vscode/settings.json
vendored
@ -73,5 +73,25 @@
|
||||
},
|
||||
"autoHide.autoHidePanel": false,
|
||||
"autoHide.autoHideSideBar": false,
|
||||
"dimmer.enabled": false
|
||||
"dimmer.enabled": false,
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#fa1b49",
|
||||
"activityBar.background": "#fa1b49",
|
||||
"activityBar.foreground": "#e7e7e7",
|
||||
"activityBar.inactiveForeground": "#e7e7e799",
|
||||
"activityBarBadge.background": "#155e02",
|
||||
"activityBarBadge.foreground": "#e7e7e7",
|
||||
"commandCenter.border": "#e7e7e799",
|
||||
"sash.hoverBorder": "#fa1b49",
|
||||
"statusBar.background": "#dd0531",
|
||||
"statusBar.foreground": "#e7e7e7",
|
||||
"statusBarItem.hoverBackground": "#fa1b49",
|
||||
"statusBarItem.remoteBackground": "#dd0531",
|
||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||
"titleBar.activeBackground": "#dd0531",
|
||||
"titleBar.activeForeground": "#e7e7e7",
|
||||
"titleBar.inactiveBackground": "#dd053199",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
},
|
||||
"peacock.color": "#dd0531"
|
||||
}
|
||||
|
16
LICENSE
16
LICENSE
@ -26,3 +26,19 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Source URL: https://github.com/Ed94/gencpp
|
||||
|
||||
Acknowledgements
|
||||
|
||||
* The dependencies for gencpp source are derived from the zpl library: https://github.com/zpl-c/zpl
|
||||
|
||||
Special thanks to:
|
||||
|
||||
* The Handmade Community.
|
||||
|
||||
* Casey Muratori, Ginger Bill (Bill Hall), Mr. 4th (Allen Webster), Ryan Fluery: Influnced conceptually how to handle staged metaprograming.
|
||||
|
||||
* Jonathan Blow: Jai's metaprogramming influenced the design of this library.
|
||||
|
||||
* My friends for putting up with discord spam on this library.
|
||||
|
@ -1,6 +1,9 @@
|
||||
# gencpp
|
||||
|
||||
An attempt at simple staged metaprogramming for C/C++.
|
||||
An attempt at simple staged metaprogramming for C/C++. Reflect and generate code for your codebase at runtime!
|
||||
|
||||

|
||||

|
||||
|
||||
The library API is a composition of code element constructors, and a non-standards-compliant single-pass C/C++ parser.
|
||||
These build up a code AST to then serialize with a file builder, or can be traversed for staged-reflection of C/C++ code.
|
||||
@ -49,7 +52,11 @@ Within `program.cpp` :
|
||||
|
||||
u32 gen_main()
|
||||
{
|
||||
gen::Context ctx;
|
||||
gen::init(& ctx);
|
||||
...
|
||||
gen::deinit(& ctx);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -8,7 +8,13 @@
|
||||
|
||||
The library is fragmented into a series of headers and source files meant to be scanned in and then generated to a standard target format, or a user's desires.
|
||||
|
||||
Standard formats:
|
||||
If using the library's provided build scripts:
|
||||
|
||||
```ps1
|
||||
.\build.ps1 <compiler> <debug or omit> base
|
||||
```
|
||||
|
||||
## Content Overview
|
||||
|
||||
* **base**: Files are in granular pieces separated into four directories:
|
||||
* **dependencies**: Originally from the c-zpl library and modified thereafter.
|
||||
@ -27,7 +33,7 @@ Standard formats:
|
||||
* **gen_segemetned**: Dependencies go into gen.dep.{hpp/cpp} and components into gen.{hpp/cpp}
|
||||
* **gen_singleheader**: Everything into a single file: gen.hpp
|
||||
* **gen_unreal_engine**: Like gen_segemented but the library is modified slightly to compile as a thirdparty library within an Unreal Engine plugin or module.
|
||||
* **gen_c_library**: The library is heavily modifed into C11 compliant code. A segemented and single-header set of variants are generatd.
|
||||
* **gen_c_library**: The library is heavily modifed into C11 compliant code. A segemented and single-header set of variants are generated.
|
||||
|
||||
Code not making up the core library is located in `auxiliary/<auxiliary_name>.<hpp/cpp>`. These are optional extensions or tools for the library.
|
||||
|
||||
@ -117,15 +123,15 @@ The vast majority of macros should be single-line subsitutions that either add:
|
||||
|
||||
There are ***five*** header files which are automatically generated using [base_codegen.hpp](./helpers/base_codegen.hpp) by [base.cpp](./base.cpp). They are all located in [components/gen](./components/gen/).
|
||||
|
||||
* [`ecodetypes.hpp`](./components/gen/ecode.hpp): `CodeType` enum definition and related implementaiton. Generation is based off of [`ECodeType.csv](./enums/ECodeTypes.csv).
|
||||
* [`especifier.hpp`](./components/gen/especifier.hpp): `Specifier` enum definition, etc. Generated using [`ESpecifier.csv`](./enums/ESpecifier.csv).
|
||||
* [`eoperator.hpp`](./components/gen/eoperator.hpp): `Operator` enum definition, etc. Generated using [`EOperator.hpp`](./enums/EOperator.csv).
|
||||
* [`etoktype.cpp`](./components/gen/etoktype.cpp): `TokType` enum defininition, etc. Used by the lexer and parser backend. Uses two csvs:
|
||||
* [`ETokType.csv`](./enums/ETokType.csv): Provides the enum entries and their strinng ids.
|
||||
* [`AttributeTokens.csv`](./enums/AttributeTokens.csv): Provides tokens entries that should be considered as attributes by the lexer and parser. Sspecfiically macro attributes such as those use for exporting symbols.
|
||||
* [`ast_inlines.hpp`](./components/gen/ast_inlines.hpp): Member trivial `operator` definitions for C++ code types. Does not use a csv.
|
||||
* [ecodetypes.hpp](./components/gen/ecode.hpp): `CodeType` enum definition and related implementaiton. Generation is based off of [ECodeType.csv](./enums/ECodeTypes.csv).
|
||||
* [especifier.hpp](./components/gen/especifier.hpp): `Specifier` enum definition, etc. Generated using [ESpecifier.csv](./enums/ESpecifier.csv).
|
||||
* [eoperator.hpp](./components/gen/eoperator.hpp): `Operator` enum definition, etc. Generated using [EOperator.hpp](./enums/EOperator.csv).
|
||||
* [etoktype.cpp](./components/gen/etoktype.cpp): `TokType` enum defininition, etc. Used by the lexer and parser backend. Uses two csvs:
|
||||
* [ETokType.csv](./enums/ETokType.csv): Provides the enum entries and their strinng ids.
|
||||
* [AttributeTokens.csv](./enums/AttributeTokens.csv): Provides tokens entries that should be considered as attributes by the lexer and parser. Sspecfiically macro attributes such as those use for exporting symbols.
|
||||
* [ast_inlines.hpp](./components/gen/ast_inlines.hpp): Member trivial `operator` definitions for C++ code types. Does not use a csv.
|
||||
|
||||
[`misc.hpp`](./helpers/misc.hpp): Has shared functions used by the library generation meta-programs throughout this codebase.
|
||||
[misc.hpp](./helpers/misc.hpp): Has shared functions used by the library generation meta-programs throughout this codebase.
|
||||
|
||||
If using the library's provided build scripts:
|
||||
|
||||
@ -154,9 +160,53 @@ Names or Content fields are interned strings and thus showed be cached using `ca
|
||||
|
||||
`def_operator` is the most sophisticated upfront constructor as it has multiple permutations of definitions that could be created that are not trivial to determine if valid.
|
||||
|
||||
The parser is documented under [`docs/Parsing.md`](../docs/Parsing.md) and [`docs/Parser_Algo.md`](../docs/Parser_Algo.md).
|
||||
The parser is documented under [`docs/Parsing.md`](../docs/Parsing.md) and [`docs/Parser_Algo.md`](../docs/Parser_Algo.md). Read that and the entire library if you want to extend it.
|
||||
|
||||
### Attributes
|
||||
|
||||
To add additional macro attributes, all that has to be done is modifying [`AttributeTokens.csv`](./enums/AttributeTokens.csv).
|
||||
|
||||
### Specifiers
|
||||
|
||||
To add additional macro specifiers, the following needs to be done:
|
||||
|
||||
1. Adjust [especifier.hpp](./components/gen/especifier.hpp)
|
||||
2. Adjust [etoktype.cpp](./components/gen/etoktype.cpp)
|
||||
3. Adjust [parser_case_macros.cpp](./components/parser_case_macros.cpp)
|
||||
|
||||
If the specifier is a new trailing specifier on function definitions:
|
||||
|
||||
Head into [base_codegen.hpp](./helpers/base_codegen.hpp): `gen_especifier`. There will be an `is_trailing` function that needs to be adjusted with an additional case for the user's new trailing specifier.
|
||||
|
||||
### Code Types
|
||||
|
||||
These require the following to be handled to the equivalent extent as the other types:
|
||||
|
||||
1. Adjust [ECodeTypes.csv](./enums/ECodeTypes.csv) with the new types
|
||||
2. Define a new `AST_<Name>` and `Code<Name>`. See
|
||||
* [ast.hpp](./components/ast.hpp): Initial forwards and user defined conversion for Code.
|
||||
* [ast_types.hpp](./components/ast_types.hpp): Define the `AST_<Name>` struct.
|
||||
* [code_types.hpp](./components/code_types.hpp): Defne the `CodeType` struct. If its needs an iterator see: `struct CodeBody` & `struct CodeParams`.
|
||||
3. [ast_case_macros.cpp](./components/ast_case_macros.cpp): Review cases here if the new code type needs to be considered.
|
||||
4. [ast.cpp](./components/ast.cpp): Need to review
|
||||
* `code_debug_str`
|
||||
* `code_is_equal`
|
||||
* `code_to_strbuilder_ptr`
|
||||
* `code_validate_body`
|
||||
5. [code_serialization.cpp](./components/code_serialization.cpp): Define serialization here.
|
||||
6. [inlines.hpp](./components/inlines.hpp): Any inline definitions for the `struct Code<Name>` are defined here.
|
||||
7. [interface.cpp](./components/interface.hpp): Define the `Code<Name>` upfront and parsing interface.
|
||||
8. [interface.upfront.cpp](./components/interface.upfront.cpp): Define the upfront constructor implementation.
|
||||
9. [interface.parsing.cpp](./components/interface.parsing.cpp): Define the parsing interface implementation.
|
||||
10. [lexer.cpp](./components/lexer.cpp): Adjust the lexer as needed.
|
||||
11. [parser.cpp](./components/parser.cpp): Adjust the parser as needed.
|
||||
|
||||
## A note on compilation and runtime generation speed
|
||||
|
||||
The library is designed to be fast to compile and generate code at runtime as fast as resonable possible on a debug build.
|
||||
The library is designed to be fast to compile and generate code at runtime as fast as possible on a debug build.
|
||||
Its recommended that your metaprogam be compiled using a single translation unit (unity build).
|
||||
|
||||
## Whats with the expression / executions support #ifd and enums?
|
||||
|
||||
The library is a *work in progress* and those are unfinished hypotheticals for adding the ability to manage or parse the AST of expresions or execution scope code.
|
||||
They are entirely untested and not meant to be used yet, futher there is no parsing support or an upfront interface for what CodeTypes are defined so far.
|
||||
|
@ -15,7 +15,9 @@ Builder builder_open( char const* path )
|
||||
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 );
|
||||
return result;
|
||||
|
@ -25,13 +25,14 @@ Builder builder_open ( char const* path );
|
||||
void builder_pad_lines ( Builder* builder, s32 num );
|
||||
void builder_print ( Builder* builder, Code code );
|
||||
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_start( va, fmt );
|
||||
builder_print_fmt_va( builder, fmt, va );
|
||||
va_end( va );
|
||||
}
|
||||
void builder_write( Builder* builder );
|
||||
|
||||
struct Builder
|
||||
{
|
||||
@ -56,10 +57,10 @@ struct Builder
|
||||
};
|
||||
|
||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||
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); }
|
||||
void builder_write ( Builder& builder ) { return builder_write(& builder ); }
|
||||
void builder_print_fmt( Builder& builder, char const* fmt, ...) {
|
||||
forceinline void builder_pad_lines( Builder& builder, s32 num ) { return builder_pad_lines(& builder, num); }
|
||||
forceinline void builder_print ( Builder& builder, Code code ) { return builder_print(& builder, code); }
|
||||
forceinline void builder_write ( Builder& builder ) { return builder_write(& builder ); }
|
||||
forceinline void builder_print_fmt( Builder& builder, char const* fmt, ...) {
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
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 );
|
||||
}
|
||||
|
||||
StrBuilder str = strbuilder_make_reserve( _ctx->Allocator_Temp, fsize );
|
||||
StrBuilder str = strbuilder_make_reserve( get_context()->Allocator_Temp, fsize );
|
||||
file_read( & file, str, fsize );
|
||||
strbuilder_get_header(str)->Length = fsize;
|
||||
|
||||
@ -117,7 +117,7 @@ Code scan_file( char const* 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 };
|
||||
CodeBody code = parse_global_body( content );
|
||||
log_fmt("\nParsed: %s\n", path);
|
||||
|
@ -1,6 +1,5 @@
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#define GEN_C_LIKE_CPP 1
|
||||
#include "gen.cpp"
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
|
@ -36,7 +36,6 @@ Str code_debug_str(Code self)
|
||||
case CT_Execution:
|
||||
case CT_Comment:
|
||||
case CT_PlatformAttributes:
|
||||
case CT_Preprocess_Define:
|
||||
case CT_Preprocess_Include:
|
||||
case CT_Preprocess_Pragma:
|
||||
case CT_Preprocess_If:
|
||||
@ -52,6 +51,11 @@ Str code_debug_str(Code self)
|
||||
strbuilder_append_fmt( result, "\n\tContent: %S", self->Content );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Define:
|
||||
// TODO(ED): Needs implementaton
|
||||
log_failure("code_debug_str: NOT IMPLEMENTED for CT_Preprocess_Define");
|
||||
break;
|
||||
|
||||
case CT_Class:
|
||||
case CT_Struct:
|
||||
if ( self->Prev )
|
||||
@ -259,6 +263,11 @@ Str code_debug_str(Code self)
|
||||
strbuilder_append_fmt( result, "\n\tValue : %S", self->Value ? strbuilder_to_str( code_to_strbuilder(self->Value)) : txt("Null") );
|
||||
break;
|
||||
|
||||
case CT_Parameters_Define:
|
||||
// TODO(ED): Needs implementaton
|
||||
log_failure("code_debug_str: NOT IMPLEMENTED for CT_Parameters_Define");
|
||||
break;
|
||||
|
||||
case CT_Specifiers:
|
||||
{
|
||||
strbuilder_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
||||
@ -497,6 +506,10 @@ void code_to_strbuilder_ptr( Code self, StrBuilder* result )
|
||||
params_to_strbuilder_ref(cast(CodeParams, self), result );
|
||||
break;
|
||||
|
||||
case CT_Parameters_Define:
|
||||
define_params_to_strbuilder_ref(cast(CodeDefineParams, self), result);
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Define:
|
||||
define_to_strbuilder_ref(cast(CodeDefine, self), result );
|
||||
break;
|
||||
@ -987,11 +1000,17 @@ bool code_is_equal( Code self, Code other )
|
||||
return true;
|
||||
}
|
||||
|
||||
case CT_Parameters_Define:
|
||||
{
|
||||
// TODO(ED): Needs implementaton
|
||||
log_failure("code_is_equal: NOT IMPLEMENTED for CT_Parameters_Define");
|
||||
return false;
|
||||
}
|
||||
|
||||
case CT_Preprocess_Define:
|
||||
{
|
||||
check_member_str( Name );
|
||||
check_member_content( Content );
|
||||
|
||||
check_member_content( Body->Content );
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1165,7 +1184,7 @@ bool code_validate_body(Code self)
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_CLASS_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_CLASS_UNALLOWED_TYPES_CASES:
|
||||
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry));
|
||||
return false;
|
||||
|
||||
@ -1192,7 +1211,7 @@ bool code_validate_body(Code self)
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES_CASES:
|
||||
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry));
|
||||
return false;
|
||||
|
||||
@ -1206,7 +1225,7 @@ bool code_validate_body(Code self)
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES_CASES:
|
||||
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry));
|
||||
return false;
|
||||
|
||||
@ -1220,7 +1239,7 @@ bool code_validate_body(Code self)
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES_CASES:
|
||||
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry));
|
||||
return false;
|
||||
|
||||
@ -1234,7 +1253,7 @@ bool code_validate_body(Code self)
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES_CASES:
|
||||
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry));
|
||||
return false;
|
||||
}
|
||||
@ -1245,7 +1264,7 @@ bool code_validate_body(Code self)
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES_CASES:
|
||||
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry));
|
||||
return false;
|
||||
}
|
||||
@ -1256,7 +1275,7 @@ bool code_validate_body(Code self)
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES_CASES:
|
||||
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry));
|
||||
return false;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ struct AST_Constructor;
|
||||
// struct AST_BaseClass;
|
||||
struct AST_Class;
|
||||
struct AST_Define;
|
||||
struct AST_DefineParams;
|
||||
struct AST_Destructor;
|
||||
struct AST_Enum;
|
||||
struct AST_Exec;
|
||||
@ -42,7 +43,7 @@ struct AST_Pragma;
|
||||
struct AST_PreprocessCond;
|
||||
struct AST_Specifiers;
|
||||
|
||||
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
#ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
struct AST_Expr;
|
||||
struct AST_Expr_Assign;
|
||||
struct AST_Expr_Alignof;
|
||||
@ -98,6 +99,7 @@ typedef AST_Comment* CodeComment;
|
||||
typedef AST_Class* CodeClass;
|
||||
typedef AST_Constructor* CodeConstructor;
|
||||
typedef AST_Define* CodeDefine;
|
||||
typedef AST_DefineParams* CodeDefineParams;
|
||||
typedef AST_Destructor* CodeDestructor;
|
||||
typedef AST_Enum* CodeEnum;
|
||||
typedef AST_Exec* CodeExec;
|
||||
@ -120,6 +122,7 @@ struct CodeComment;
|
||||
struct CodeClass;
|
||||
struct CodeConstructor;
|
||||
struct CodeDefine;
|
||||
struct CodeDefineParams;
|
||||
struct CodeDestructor;
|
||||
struct CodeEnum;
|
||||
struct CodeExec;
|
||||
@ -137,7 +140,7 @@ struct CodePragma;
|
||||
struct CodeSpecifiers;
|
||||
#endif
|
||||
|
||||
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
#ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
|
||||
#if GEN_COMPILER_C
|
||||
typedef AST_Expr* CodeExpr;
|
||||
@ -305,6 +308,7 @@ struct Code
|
||||
operator CodeClass() const;
|
||||
operator CodeConstructor() const;
|
||||
operator CodeDefine() const;
|
||||
operator CodeDefineParams() const;
|
||||
operator CodeDestructor() const;
|
||||
operator CodeExec() const;
|
||||
operator CodeEnum() const;
|
||||
@ -365,6 +369,7 @@ int AST_ArrSpecs_Cap =
|
||||
|
||||
/*
|
||||
Simple AST POD with functionality to seralize into C++ syntax.
|
||||
TODO(Ed): Eventually haven't a transparent AST like this will longer be viable once statements & expressions are in (most likely....)
|
||||
*/
|
||||
struct AST
|
||||
{
|
||||
@ -372,7 +377,7 @@ struct AST
|
||||
struct
|
||||
{
|
||||
Code InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
Code Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
||||
Code Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable // TODO(Ed): Parameters can have attributes
|
||||
Code Specs; // Destructor, Function, Operator, Typename, Variable
|
||||
union {
|
||||
Code InitializerList; // Constructor
|
||||
@ -384,12 +389,12 @@ struct AST
|
||||
union {
|
||||
Code Macro; // Parameter
|
||||
Code BitfieldSize; // Variable (Class/Struct Data Member)
|
||||
Code Params; // Constructor, Function, Operator, Template, Typename
|
||||
Code Params; // Constructor, Define, Function, Operator, Template, Typename
|
||||
Code UnderlyingTypeMacro; // Enum
|
||||
};
|
||||
union {
|
||||
Code ArrExpr; // Typename
|
||||
Code Body; // Class, Constructor, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
||||
Code Body; // Class, Constructor, Define, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
||||
Code Declaration; // Friend, Template
|
||||
Code Value; // Parameter, Variable
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
// These macros are used in the swtich cases are used within ast.cpp, inteface.upfront.cpp, parser.cpp
|
||||
// These macros are used in the swtich cases within ast.cpp, inteface.upfront.cpp, parser.cpp
|
||||
|
||||
# define GEN_AST_BODY_CLASS_UNALLOWED_TYPES \
|
||||
# define GEN_AST_BODY_CLASS_UNALLOWED_TYPES_CASES \
|
||||
case CT_PlatformAttributes: \
|
||||
case CT_Class_Body: \
|
||||
case CT_Enum_Body: \
|
||||
@ -16,9 +16,9 @@
|
||||
case CT_Specifiers: \
|
||||
case CT_Struct_Body: \
|
||||
case CT_Typename
|
||||
# define GEN_AST_BODY_STRUCT_UNALLOWED_TYPES GEN_AST_BODY_CLASS_UNALLOWED_TYPES
|
||||
# define GEN_AST_BODY_STRUCT_UNALLOWED_TYPES_CASES GEN_AST_BODY_CLASS_UNALLOWED_TYPES_CASES
|
||||
|
||||
# define GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES \
|
||||
# define GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES_CASES \
|
||||
case CT_Access_Public: \
|
||||
case CT_Access_Protected: \
|
||||
case CT_Access_Private: \
|
||||
@ -41,7 +41,7 @@
|
||||
case CT_Struct_Body: \
|
||||
case CT_Typename
|
||||
|
||||
# define GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES \
|
||||
# define GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES_CASES \
|
||||
case CT_Access_Public: \
|
||||
case CT_Access_Protected: \
|
||||
case CT_Access_Private: \
|
||||
@ -58,10 +58,10 @@
|
||||
case CT_Specifiers: \
|
||||
case CT_Struct_Body: \
|
||||
case CT_Typename
|
||||
# define GEN_AST_BODY_EXPORT_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
# define GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
# define GEN_AST_BODY_EXPORT_UNALLOWED_TYPES_CASES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES_CASES
|
||||
# define GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES_CASES GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES_CASES
|
||||
|
||||
# define GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES \
|
||||
# define GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES_CASES \
|
||||
case CT_Access_Public: \
|
||||
case CT_Access_Protected: \
|
||||
case CT_Access_Private: \
|
||||
|
@ -29,26 +29,27 @@
|
||||
struct AST_Body
|
||||
{
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
Code Front;
|
||||
Code Back;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
s32 NumEntries;
|
||||
StrCached Name;
|
||||
Code Front;
|
||||
Code Back;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
s32 NumEntries;
|
||||
};
|
||||
static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same size as AST");
|
||||
|
||||
// TODO(Ed): Support chaining attributes (Use parameter linkage pattern)
|
||||
struct AST_Attributes
|
||||
{
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
StrCached Content;
|
||||
StrCached Content;
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
@ -64,7 +65,7 @@ struct AST_BaseClass
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
@ -81,7 +82,7 @@ struct AST_Comment
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
StrCached Content;
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
@ -99,14 +100,14 @@ struct AST_Class
|
||||
{
|
||||
CodeComment InlineCmt; // Only supported by forward declarations
|
||||
CodeAttributes Attributes;
|
||||
char _PAD_SPECS_ [ sizeof(AST*) ];
|
||||
char _PAD_SPECS_ [ sizeof(AST*) ];
|
||||
CodeTypename ParentType;
|
||||
char _PAD_PARAMS_[ sizeof(AST*) ];
|
||||
char _PAD_PARAMS_[ sizeof(AST*) ];
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeTypename Prev;
|
||||
CodeTypename Next;
|
||||
Token* Tok;
|
||||
@ -129,10 +130,10 @@ struct AST_Constructor
|
||||
Code InitializerList;
|
||||
CodeParams Params;
|
||||
Code Body;
|
||||
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
|
||||
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
@ -146,17 +147,39 @@ struct AST_Define
|
||||
{
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
StrCached Content;
|
||||
struct
|
||||
{
|
||||
char _PAD_PROPERTIES_ [ sizeof(AST*) * 4 ];
|
||||
CodeDefineParams Params;
|
||||
Code Body; // Should be completely serialized for now to a: StrCached Content.
|
||||
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 1 ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the same size as AST");
|
||||
|
||||
struct AST_DefineParams
|
||||
{
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
CodeDefineParams Last;
|
||||
CodeDefineParams Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
s32 NumEntries;
|
||||
};
|
||||
static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the same size as AST");
|
||||
static_assert( sizeof(AST_DefineParams) == sizeof(AST), "ERROR: AST_DefineParams is not the same size as AST");
|
||||
|
||||
struct AST_Destructor
|
||||
{
|
||||
@ -169,10 +192,10 @@ struct AST_Destructor
|
||||
CodeSpecifiers Specs;
|
||||
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
|
||||
Code Body;
|
||||
char _PAD_PROPERTIES_3_ [ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_3_ [ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
@ -194,10 +217,10 @@ struct AST_Enum
|
||||
CodeTypename UnderlyingType;
|
||||
Code UnderlyingTypeMacro;
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
@ -214,7 +237,7 @@ struct AST_Exec
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
StrCached Content;
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
@ -224,7 +247,7 @@ struct AST_Exec
|
||||
};
|
||||
static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST");
|
||||
|
||||
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
#ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
struct AST_Expr
|
||||
{
|
||||
union {
|
||||
@ -492,13 +515,13 @@ struct AST_Extern
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the same size as AST");
|
||||
|
||||
@ -508,13 +531,13 @@ struct AST_Include
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
StrCached Content;
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not the same size as AST");
|
||||
|
||||
@ -527,16 +550,16 @@ struct AST_Friend
|
||||
CodeComment InlineCmt;
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
|
||||
Code Declaration;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the same size as AST");
|
||||
|
||||
@ -550,19 +573,19 @@ struct AST_Fn
|
||||
CodeAttributes Attributes;
|
||||
CodeSpecifiers Specs;
|
||||
CodeTypename ReturnType;
|
||||
CodeParams Params;
|
||||
CodeParams Params;
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same size as AST");
|
||||
|
||||
@ -571,14 +594,14 @@ struct AST_Module
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the same size as AST");
|
||||
|
||||
@ -587,45 +610,45 @@ struct AST_NS
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
struct {
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same size as AST");
|
||||
|
||||
struct AST_Operator
|
||||
{
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
struct
|
||||
{
|
||||
CodeComment InlineCmt;
|
||||
CodeAttributes Attributes;
|
||||
CodeSpecifiers Specs;
|
||||
CodeTypename ReturnType;
|
||||
CodeParams Params;
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
|
||||
CodeComment InlineCmt;
|
||||
CodeAttributes Attributes;
|
||||
CodeSpecifiers Specs;
|
||||
CodeTypename ReturnType;
|
||||
CodeParams Params;
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
Operator Op;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
Operator Op;
|
||||
};
|
||||
static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not the same size as AST");
|
||||
|
||||
@ -635,22 +658,22 @@ struct AST_OpCast
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
struct
|
||||
{
|
||||
CodeComment InlineCmt;
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) ];
|
||||
CodeSpecifiers Specs;
|
||||
CodeTypename ValueType;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
|
||||
CodeComment InlineCmt;
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) ];
|
||||
CodeSpecifiers Specs;
|
||||
CodeTypename ValueType;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST");
|
||||
|
||||
@ -660,7 +683,8 @@ struct AST_Params
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
struct
|
||||
{
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
|
||||
// TODO(Ed): Support attributes for parameters (Some prefix macros can be converted to that...)
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
|
||||
CodeTypename ValueType;
|
||||
Code Macro;
|
||||
Code Value;
|
||||
@ -668,14 +692,14 @@ struct AST_Params
|
||||
// char _PAD_PROPERTIES_3_[sizeof( AST* )];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
CodeParams Last;
|
||||
CodeParams Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
s32 NumEntries;
|
||||
StrCached Name;
|
||||
CodeParams Last;
|
||||
CodeParams Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
s32 NumEntries;
|
||||
};
|
||||
static_assert( sizeof(AST_Params) == sizeof(AST), "ERROR: AST_Params is not the same size as AST");
|
||||
|
||||
@ -685,13 +709,13 @@ struct AST_Pragma
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
StrCached Content;
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the same size as AST");
|
||||
|
||||
@ -699,40 +723,40 @@ struct AST_PreprocessCond
|
||||
{
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
StrCached Content;
|
||||
StrCached Content;
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_PreprocessCond is not the same size as AST");
|
||||
|
||||
struct AST_Specifiers
|
||||
{
|
||||
Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
|
||||
Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
|
||||
StrCached Name;
|
||||
CodeSpecifiers NextSpecs;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
s32 NumEntries;
|
||||
CodeSpecifiers NextSpecs;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
s32 NumEntries;
|
||||
};
|
||||
static_assert( sizeof(AST_Specifiers) == sizeof(AST), "ERROR: AST_Specifier is not the same size as AST");
|
||||
|
||||
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
#ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
struct AST_Stmt
|
||||
{
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -747,7 +771,7 @@ struct AST_Stmt_Break
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -762,7 +786,7 @@ struct AST_Stmt_Case
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -777,7 +801,7 @@ struct AST_Stmt_Continue
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -792,7 +816,7 @@ struct AST_Stmt_Decl
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -807,7 +831,7 @@ struct AST_Stmt_Do
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -822,7 +846,7 @@ struct AST_Stmt_Expr
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -837,7 +861,7 @@ struct AST_Stmt_Else
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -852,7 +876,7 @@ struct AST_Stmt_If
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -867,7 +891,7 @@ struct AST_Stmt_For
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -882,7 +906,7 @@ struct AST_Stmt_Goto
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -897,7 +921,7 @@ struct AST_Stmt_Label
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -912,7 +936,7 @@ struct AST_Stmt_Switch
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -927,7 +951,7 @@ struct AST_Stmt_While
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeExpr Prev;
|
||||
CodeExpr Next;
|
||||
Token* Tok;
|
||||
@ -946,14 +970,14 @@ struct AST_Struct
|
||||
{
|
||||
CodeComment InlineCmt;
|
||||
CodeAttributes Attributes;
|
||||
char _PAD_SPECS_ [ sizeof(AST*) ];
|
||||
char _PAD_SPECS_ [ sizeof(AST*) ];
|
||||
CodeTypename ParentType;
|
||||
char _PAD_PARAMS_[ sizeof(AST*) ];
|
||||
char _PAD_PARAMS_[ sizeof(AST*) ];
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeTypename Prev;
|
||||
CodeTypename Next;
|
||||
Token* Tok;
|
||||
@ -970,20 +994,20 @@ struct AST_Template
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
struct
|
||||
{
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
|
||||
CodeParams Params;
|
||||
Code Declaration;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not the same size as AST");
|
||||
|
||||
@ -1005,13 +1029,13 @@ struct AST_Type
|
||||
// CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
b32 IsParamPack;
|
||||
};
|
||||
static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST");
|
||||
@ -1038,7 +1062,7 @@ struct AST_Typename
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
||||
struct {
|
||||
b16 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
|
||||
ETypenameTag TypeTag; // Used by typename to keep track of explicitly declared tags for the identifier (enum, struct, union)
|
||||
@ -1053,9 +1077,9 @@ struct AST_Typedef
|
||||
struct
|
||||
{
|
||||
CodeComment InlineCmt;
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ];
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ];
|
||||
Code UnderlyingType;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
@ -1077,19 +1101,19 @@ struct AST_Union
|
||||
{
|
||||
char _PAD_INLINE_CMT_[ sizeof(AST*) ];
|
||||
CodeAttributes Attributes;
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the same size as AST");
|
||||
|
||||
@ -1101,19 +1125,19 @@ struct AST_Using
|
||||
{
|
||||
CodeComment InlineCmt;
|
||||
CodeAttributes Attributes;
|
||||
char _PAD_SPECS_ [ sizeof(AST*) ];
|
||||
char _PAD_SPECS_ [ sizeof(AST*) ];
|
||||
CodeTypename UnderlyingType;
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
|
||||
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
char _PAD_UNUSED_[ sizeof(u32) ];
|
||||
};
|
||||
static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the same size as AST");
|
||||
|
||||
@ -1129,17 +1153,17 @@ struct AST_Var
|
||||
CodeTypename ValueType;
|
||||
Code BitfieldSize;
|
||||
Code Value;
|
||||
CodeVar NextVar;
|
||||
CodeVar NextVar;
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
s32 VarParenthesizedInit;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
s32 VarParenthesizedInit;
|
||||
};
|
||||
static_assert( sizeof(AST_Var) == sizeof(AST), "ERROR: AST_Var is not the same size as AST");
|
||||
|
||||
|
@ -176,7 +176,7 @@ void class_to_strbuilder_def( CodeClass self, StrBuilder* result )
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
strbuilder_append_str( result, txt("class ") );
|
||||
@ -221,7 +221,7 @@ void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result )
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes )
|
||||
@ -241,12 +241,48 @@ void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result )
|
||||
|
||||
StrBuilder define_to_strbuilder(CodeDefine define)
|
||||
{
|
||||
return strbuilder_fmt_buf( _ctx->Allocator_Temp, "#define %S %S", define->Name, define->Content );
|
||||
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
|
||||
define_to_strbuilder_ref(define, & result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void define_to_strbuilder_ref(CodeDefine define, StrBuilder* result )
|
||||
{
|
||||
strbuilder_append_fmt( result, "#define %S %S", define->Name, define->Content );
|
||||
GEN_ASSERT(define);
|
||||
GEN_ASSERT(define->Body);
|
||||
GEN_ASSERT(define->Body->Content.Ptr && define->Body->Content.Len > 0);
|
||||
if (define->Params) {
|
||||
StrBuilder params_builder = define_params_to_strbuilder(define->Params);
|
||||
strbuilder_append_fmt( result, "#define %S(%S) %S", define->Name, strbuilder_to_str(params_builder), define->Body->Content );
|
||||
}
|
||||
else {
|
||||
strbuilder_append_fmt( result, "#define %S %S", define->Name, define->Body->Content );
|
||||
}
|
||||
}
|
||||
|
||||
StrBuilder define_params_to_strbuilder(CodeDefineParams params)
|
||||
{
|
||||
GEN_ASSERT(params);
|
||||
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
|
||||
define_params_to_strbuilder_ref( params, & result );
|
||||
return result;
|
||||
}
|
||||
|
||||
void define_params_to_strbuilder_ref(CodeDefineParams self, StrBuilder* result)
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(result);
|
||||
if ( self->Name.Ptr && self->Name.Len )
|
||||
{
|
||||
strbuilder_append_fmt( result, " %S", self->Name );
|
||||
}
|
||||
if ( self->NumEntries - 1 > 0 )
|
||||
{
|
||||
for ( CodeDefineParams param = begin_CodeDefineParams(self->Next); param != end_CodeDefineParams(self->Next); param = next_CodeDefineParams(self->Next, param) )
|
||||
{
|
||||
strbuilder_append_fmt( result, ", %SB", define_params_to_strbuilder(param) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StrBuilder destructor_to_strbuilder(CodeDestructor self)
|
||||
@ -329,7 +365,7 @@ StrBuilder enum_to_strbuilder(CodeEnum self)
|
||||
|
||||
void enum_to_strbuilder_def(CodeEnum self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes || self->UnderlyingType || self->UnderlyingTypeMacro )
|
||||
@ -362,7 +398,7 @@ void enum_to_strbuilder_def(CodeEnum self, StrBuilder* result )
|
||||
|
||||
void enum_to_strbuilder_fwd(CodeEnum self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes )
|
||||
@ -389,7 +425,7 @@ void enum_to_strbuilder_fwd(CodeEnum self, StrBuilder* result )
|
||||
|
||||
void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes || self->UnderlyingType )
|
||||
@ -421,7 +457,7 @@ void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result )
|
||||
|
||||
void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
strbuilder_append_str( result, txt("enum class ") );
|
||||
@ -505,7 +541,7 @@ StrBuilder fn_to_strbuilder(CodeFn self)
|
||||
|
||||
void fn_to_strbuilder_def(CodeFn self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export") );
|
||||
|
||||
if ( self->Attributes )
|
||||
@ -558,7 +594,7 @@ void fn_to_strbuilder_def(CodeFn self, StrBuilder* result )
|
||||
|
||||
void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes )
|
||||
@ -646,7 +682,7 @@ StrBuilder namespace_to_strbuilder(CodeNS self)
|
||||
|
||||
void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
strbuilder_append_fmt( result, "namespace %S\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) );
|
||||
@ -671,7 +707,7 @@ StrBuilder code_op_to_strbuilder(CodeOperator self)
|
||||
|
||||
void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes )
|
||||
@ -725,7 +761,7 @@ void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result )
|
||||
|
||||
void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes )
|
||||
@ -865,7 +901,6 @@ void opcast_to_strbuilder_fwd(CodeOpCast self, StrBuilder* result )
|
||||
|
||||
StrBuilder params_to_strbuilder(CodeParams self)
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(self);
|
||||
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
|
||||
params_to_strbuilder_ref( self, & result );
|
||||
@ -1001,12 +1036,24 @@ void specifiers_to_strbuilder_ref( CodeSpecifiers self, StrBuilder* result )
|
||||
GEN_ASSERT(result);
|
||||
s32 idx = 0;
|
||||
s32 left = self->NumEntries;
|
||||
while ( left-- )
|
||||
while ( left -- )
|
||||
{
|
||||
Str spec = spec_to_str( self->ArrSpecs[idx] );
|
||||
strbuilder_append_fmt( result, "%.*s ", spec.Len, spec.Ptr );
|
||||
Specifier spec = self->ArrSpecs[idx];
|
||||
Str spec_str = spec_to_str( spec );
|
||||
if ( idx > 0 ) switch (spec) {
|
||||
case Spec_Ptr:
|
||||
case Spec_Ref:
|
||||
case Spec_RValue:
|
||||
break;
|
||||
|
||||
default:
|
||||
strbuilder_append_str(result, txt(" "));
|
||||
break;
|
||||
}
|
||||
strbuilder_append_fmt( result, "%S", spec_str );
|
||||
idx++;
|
||||
}
|
||||
strbuilder_append_str(result, txt(" "));
|
||||
}
|
||||
|
||||
StrBuilder struct_to_strbuilder(CodeStruct self)
|
||||
@ -1030,7 +1077,7 @@ void struct_to_strbuilder_def( CodeStruct self, StrBuilder* result )
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(result);
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
strbuilder_append_str( result, txt("struct ") );
|
||||
@ -1076,7 +1123,7 @@ void struct_to_strbuilder_fwd( CodeStruct self, StrBuilder* result )
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(result);
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes )
|
||||
@ -1105,7 +1152,7 @@ void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result )
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(result);
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Params )
|
||||
@ -1123,7 +1170,7 @@ StrBuilder typedef_to_strbuilder(CodeTypedef self)
|
||||
|
||||
void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
strbuilder_append_str( result, txt("typedef "));
|
||||
@ -1236,7 +1283,7 @@ StrBuilder union_to_strbuilder(CodeUnion self)
|
||||
|
||||
void union_to_strbuilder_def(CodeUnion self, StrBuilder* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
strbuilder_append_str( result, txt("union ") );
|
||||
@ -1267,7 +1314,7 @@ void union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result )
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(result);
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
strbuilder_append_str( result, txt("union ") );
|
||||
@ -1304,7 +1351,7 @@ void using_to_strbuilder_ref(CodeUsing self, StrBuilder* result )
|
||||
{
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(result);
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes )
|
||||
@ -1371,7 +1418,7 @@ void var_to_strbuilder_ref(CodeVar self, StrBuilder* result )
|
||||
|
||||
strbuilder_append_str( result, self->Name );
|
||||
|
||||
if ( self->ValueType->ArrExpr )
|
||||
if ( self->ValueType && self->ValueType->ArrExpr )
|
||||
{
|
||||
strbuilder_append_fmt( result, "[ %SB ]", code_to_strbuilder(self->ValueType->ArrExpr) );
|
||||
|
||||
@ -1401,7 +1448,7 @@ void var_to_strbuilder_ref(CodeVar self, StrBuilder* result )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
strbuilder_append_str( result, txt("export ") );
|
||||
|
||||
if ( self->Attributes || self->Specs )
|
||||
@ -1410,7 +1457,7 @@ void var_to_strbuilder_ref(CodeVar self, StrBuilder* result )
|
||||
strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) );
|
||||
|
||||
if ( self->Specs )
|
||||
strbuilder_append_fmt( result, "%SB\n", specifiers_to_strbuilder(self->Specs) );
|
||||
strbuilder_append_fmt( result, "%SB", specifiers_to_strbuilder(self->Specs) );
|
||||
|
||||
strbuilder_append_fmt( result, "%SB %S", typename_to_strbuilder(self->ValueType), self->Name );
|
||||
|
||||
@ -1454,7 +1501,7 @@ void var_to_strbuilder_ref(CodeVar self, StrBuilder* result )
|
||||
if ( self->BitfieldSize )
|
||||
strbuilder_append_fmt( result, "%SB %S : %SB", typename_to_strbuilder(self->ValueType), self->Name, code_to_strbuilder(self->BitfieldSize) );
|
||||
|
||||
else if ( self->ValueType->ArrExpr )
|
||||
else if ( self->ValueType && self->ValueType->ArrExpr )
|
||||
{
|
||||
strbuilder_append_fmt( result, "%SB %S[ %SB ]", typename_to_strbuilder(self->ValueType), self->Name, code_to_strbuilder(self->ValueType->ArrExpr) );
|
||||
|
||||
|
@ -32,7 +32,17 @@ GEN_API StrBuilder class_to_strbuilder ( CodeClass self );
|
||||
GEN_API void class_to_strbuilder_def( CodeClass self, StrBuilder* result );
|
||||
GEN_API void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result );
|
||||
|
||||
GEN_API void params_append (CodeParams params, CodeParams param );
|
||||
GEN_API void define_params_append (CodeDefineParams appendee, CodeDefineParams other );
|
||||
GEN_API CodeDefineParams define_params_get (CodeDefineParams params, s32 idx);
|
||||
GEN_API bool define_params_has_entries (CodeDefineParams params );
|
||||
GEN_API StrBuilder define_params_to_strbuilder (CodeDefineParams params );
|
||||
GEN_API void define_params_to_strbuilder_ref(CodeDefineParams params, StrBuilder* result );
|
||||
|
||||
GEN_API CodeDefineParams begin_CodeDefineParams(CodeDefineParams params);
|
||||
GEN_API CodeDefineParams end_CodeDefineParams (CodeDefineParams params);
|
||||
GEN_API CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter);
|
||||
|
||||
GEN_API void params_append (CodeParams appendee, CodeParams other );
|
||||
GEN_API CodeParams params_get (CodeParams params, s32 idx);
|
||||
GEN_API bool params_has_entries (CodeParams params );
|
||||
GEN_API StrBuilder params_to_strbuilder (CodeParams params );
|
||||
@ -192,12 +202,11 @@ struct CodeParams
|
||||
{
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
Using_Code( CodeParams );
|
||||
forceinline void append( CodeParams other );
|
||||
forceinline CodeParams get( s32 idx );
|
||||
forceinline bool has_entries();
|
||||
forceinline StrBuilder to_strbuilder();
|
||||
forceinline void to_strbuilder( StrBuilder& result );
|
||||
|
||||
forceinline void append( CodeParams other ) { return params_append(* this, other); }
|
||||
forceinline CodeParams get( s32 idx ) { return params_get( * this, idx); }
|
||||
forceinline bool has_entries() { return params_has_entries(* this); }
|
||||
forceinline StrBuilder to_strbuilder() { return params_to_strbuilder(* this); }
|
||||
forceinline void to_strbuilder( StrBuilder& result ) { return params_to_strbuilder_ref(*this, & result); }
|
||||
#endif
|
||||
Using_CodeOps( CodeParams );
|
||||
forceinline CodeParams begin() { return begin_CodeParams(* this); }
|
||||
@ -212,6 +221,29 @@ struct CodeParams
|
||||
AST_Params* ast;
|
||||
};
|
||||
|
||||
struct CodeDefineParams
|
||||
{
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
Using_Code( CodeDefineParams );
|
||||
forceinline void append( CodeDefineParams other ) { return params_append( cast(CodeParams, * this), cast(CodeParams, other)); }
|
||||
forceinline CodeDefineParams get( s32 idx ) { return (CodeDefineParams) (Code) params_get( cast(CodeParams, * this), idx); }
|
||||
forceinline bool has_entries() { return params_has_entries( cast(CodeParams, * this)); }
|
||||
forceinline StrBuilder to_strbuilder() { return define_params_to_strbuilder(* this); }
|
||||
forceinline void to_strbuilder( StrBuilder& result ) { return define_params_to_strbuilder_ref(* this, & result); }
|
||||
#endif
|
||||
Using_CodeOps( CodeDefineParams );
|
||||
forceinline CodeDefineParams begin() { return (CodeDefineParams) (Code) begin_CodeParams( cast(CodeParams, * this)); }
|
||||
forceinline CodeDefineParams end() { return (CodeDefineParams) (Code) end_CodeParams( cast(CodeParams, * this)); }
|
||||
forceinline operator Code() { return { (AST*)ast }; }
|
||||
forceinline CodeDefineParams operator *() { return * this; } // Required to support for-range iteration.
|
||||
forceinline AST_DefineParams* operator->() {
|
||||
GEN_ASSERT(ast);
|
||||
return ast;
|
||||
}
|
||||
forceinline CodeDefineParams& operator++();
|
||||
AST_DefineParams* ast;
|
||||
};
|
||||
|
||||
struct CodeSpecifiers
|
||||
{
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
@ -330,7 +362,7 @@ struct CodeExec
|
||||
AST_Exec *ast;
|
||||
};
|
||||
|
||||
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
#ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
struct CodeExpr
|
||||
{
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
@ -657,7 +689,7 @@ struct CodePreprocessCond
|
||||
AST_PreprocessCond* ast;
|
||||
};
|
||||
|
||||
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
#ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
|
||||
struct CodeStmt
|
||||
{
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
@ -941,6 +973,7 @@ struct InvalidCode_ImplictCaster
|
||||
operator CodeClass () const { return cast(CodeClass, Code_Invalid); }
|
||||
operator CodeConstructor () const { return cast(CodeConstructor, Code_Invalid); }
|
||||
operator CodeDefine () const { return cast(CodeDefine, Code_Invalid); }
|
||||
operator CodeDefineParams () const { return cast(CodeDefineParams, Code_Invalid); }
|
||||
operator CodeDestructor () const { return cast(CodeDestructor, Code_Invalid); }
|
||||
operator CodeExec () const { return cast(CodeExec, Code_Invalid); }
|
||||
operator CodeEnum () const { return cast(CodeEnum, Code_Invalid); }
|
||||
@ -974,6 +1007,7 @@ struct NullCode_ImplicitCaster
|
||||
operator CodeClass () const { return {nullptr}; }
|
||||
operator CodeConstructor () const { return {nullptr}; }
|
||||
operator CodeDefine () const { return {nullptr}; }
|
||||
operator CodeDefineParams () const { return {nullptr}; }
|
||||
operator CodeDestructor () const { return {nullptr}; }
|
||||
operator CodeExec () const { return {nullptr}; }
|
||||
operator CodeEnum () const { return {nullptr}; }
|
||||
@ -1024,17 +1058,23 @@ forceinline StrBuilder to_strbuilder ( CodeClass self )
|
||||
forceinline void to_strbuilder_def( CodeClass self, StrBuilder& result ) { return class_to_strbuilder_def(self, & result); }
|
||||
forceinline void to_strbuilder_fwd( CodeClass self, StrBuilder& result ) { return class_to_strbuilder_fwd(self, & result); }
|
||||
|
||||
forceinline void append (CodeParams params, CodeParams param ) { return params_append(params, param); }
|
||||
forceinline CodeParams get (CodeParams params, s32 idx) { return params_get(params, idx); }
|
||||
forceinline bool has_entries (CodeParams params ) { return params_has_entries(params); }
|
||||
forceinline StrBuilder to_strbuilder(CodeParams params ) { return params_to_strbuilder(params); }
|
||||
forceinline void to_strbuilder(CodeParams params, StrBuilder& result ) { return params_to_strbuilder_ref(params, & result); }
|
||||
forceinline void append (CodeDefineParams appendee, CodeDefineParams other ) { params_append(cast(CodeParams, appendee), cast(CodeParams, other)); }
|
||||
forceinline CodeDefineParams get (CodeDefineParams params, s32 idx) { return (CodeDefineParams) (Code) params_get(cast(CodeParams, params), idx); }
|
||||
forceinline bool has_entries (CodeDefineParams params ) { return params_has_entries(cast(CodeParams, params)); }
|
||||
forceinline StrBuilder to_strbuilder(CodeDefineParams params ) { return define_params_to_strbuilder(params); }
|
||||
forceinline void to_strbuilder(CodeDefineParams params, StrBuilder& result ) { return define_params_to_strbuilder_ref(params, & result); }
|
||||
|
||||
forceinline void append (CodeParams appendee, CodeParams other ) { return params_append(appendee, other); }
|
||||
forceinline CodeParams get (CodeParams params, s32 idx) { return params_get(params, idx); }
|
||||
forceinline bool has_entries (CodeParams params ) { return params_has_entries(params); }
|
||||
forceinline StrBuilder to_strbuilder(CodeParams params ) { return params_to_strbuilder(params); }
|
||||
forceinline void to_strbuilder(CodeParams params, StrBuilder& result ) { return params_to_strbuilder_ref(params, & result); }
|
||||
|
||||
forceinline bool append (CodeSpecifiers specifiers, Specifier spec) { return specifiers_append(specifiers, spec); }
|
||||
forceinline s32 has (CodeSpecifiers specifiers, Specifier spec) { return specifiers_has(specifiers, spec); }
|
||||
forceinline s32 remove (CodeSpecifiers specifiers, Specifier to_remove ) { return specifiers_remove(specifiers, to_remove); }
|
||||
forceinline StrBuilder to_strbuilder(CodeSpecifiers specifiers) { return specifiers_to_strbuilder(specifiers); }
|
||||
forceinline void to_strbuilder(CodeSpecifiers specifiers, StrBuilder& result) { return specifiers_to_strbuilder_ref(specifiers, & result); }
|
||||
forceinline void to_strbuilder(CodeSpecifiers specifiers, StrBuilder& result) { return specifiers_to_strbuilder_ref(specifiers, & result); }
|
||||
|
||||
forceinline void add_interface (CodeStruct self, CodeTypename interface) { return struct_add_interface(self, interface); }
|
||||
forceinline StrBuilder to_strbuilder (CodeStruct self) { return struct_to_strbuilder(self); }
|
||||
|
@ -179,6 +179,22 @@ inline AST_Define* CodeDefine::operator->()
|
||||
return ast;
|
||||
}
|
||||
|
||||
inline CodeDefineParams& CodeDefineParams::operator=( Code other )
|
||||
{
|
||||
if ( other.ast != nullptr && other->Parent != nullptr )
|
||||
{
|
||||
ast = rcast( decltype( ast ), code_duplicate( other ).ast );
|
||||
ast->Parent = { nullptr };
|
||||
}
|
||||
ast = rcast( decltype( ast ), other.ast );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline CodeDefineParams::operator bool()
|
||||
{
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline CodeDestructor& CodeDestructor::operator=( Code other )
|
||||
{
|
||||
if ( other.ast != nullptr && other->Parent != nullptr )
|
||||
@ -851,6 +867,11 @@ forceinline Code::operator CodeDefine() const
|
||||
return { (AST_Define*)ast };
|
||||
}
|
||||
|
||||
forceinline Code::operator CodeDefineParams() const
|
||||
{
|
||||
return { (AST_DefineParams*)ast };
|
||||
}
|
||||
|
||||
forceinline Code::operator CodeDestructor() const
|
||||
{
|
||||
return { (AST_Destructor*)ast };
|
||||
|
@ -46,6 +46,7 @@ enum CodeType : u32
|
||||
CT_Operator_Cast,
|
||||
CT_Operator_Cast_Fwd,
|
||||
CT_Parameters,
|
||||
CT_Parameters_Define,
|
||||
CT_Preprocess_Define,
|
||||
CT_Preprocess_Include,
|
||||
CT_Preprocess_If,
|
||||
@ -74,7 +75,7 @@ enum CodeType : u32
|
||||
|
||||
inline Str codetype_to_str( CodeType type )
|
||||
{
|
||||
local_persist Str lookup[61] = {
|
||||
local_persist Str lookup[] = {
|
||||
{ "Invalid", sizeof( "Invalid" ) - 1 },
|
||||
{ "Untyped", sizeof( "Untyped" ) - 1 },
|
||||
{ "NewLine", sizeof( "NewLine" ) - 1 },
|
||||
@ -114,6 +115,7 @@ inline Str codetype_to_str( CodeType type )
|
||||
{ "Operator_Cast", sizeof( "Operator_Cast" ) - 1 },
|
||||
{ "Operator_Cast_Fwd", sizeof( "Operator_Cast_Fwd" ) - 1 },
|
||||
{ "Parameters", sizeof( "Parameters" ) - 1 },
|
||||
{ "Parameters_Define", sizeof( "Parameters_Define" ) - 1 },
|
||||
{ "Preprocess_Define", sizeof( "Preprocess_Define" ) - 1 },
|
||||
{ "Preprocess_Include", sizeof( "Preprocess_Include" ) - 1 },
|
||||
{ "Preprocess_If", sizeof( "Preprocess_If" ) - 1 },
|
||||
@ -142,7 +144,7 @@ inline Str codetype_to_str( CodeType type )
|
||||
|
||||
inline Str codetype_to_keyword_str( CodeType type )
|
||||
{
|
||||
local_persist Str lookup[61] = {
|
||||
local_persist Str lookup[] = {
|
||||
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||
@ -182,6 +184,7 @@ inline Str codetype_to_keyword_str( CodeType type )
|
||||
{ "operator", sizeof( "operator" ) - 1 },
|
||||
{ "operator", sizeof( "operator" ) - 1 },
|
||||
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||
{ "define", sizeof( "define" ) - 1 },
|
||||
{ "include", sizeof( "include" ) - 1 },
|
||||
{ "if", sizeof( "if" ) - 1 },
|
||||
|
@ -60,7 +60,7 @@ enum Operator : u32
|
||||
|
||||
inline Str operator_to_str( Operator op )
|
||||
{
|
||||
local_persist Str lookup[47] = {
|
||||
local_persist Str lookup[] = {
|
||||
{ "INVALID", sizeof( "INVALID" ) - 1 },
|
||||
{ "=", sizeof( "=" ) - 1 },
|
||||
{ "+=", sizeof( "+=" ) - 1 },
|
||||
|
@ -39,7 +39,7 @@ enum Specifier : u32
|
||||
|
||||
inline Str spec_to_str( Specifier type )
|
||||
{
|
||||
local_persist Str lookup[26] = {
|
||||
local_persist Str lookup[] = {
|
||||
{ "INVALID", sizeof( "INVALID" ) - 1 },
|
||||
{ "consteval", sizeof( "consteval" ) - 1 },
|
||||
{ "constexpr", sizeof( "constexpr" ) - 1 },
|
||||
@ -72,7 +72,18 @@ inline Str spec_to_str( Specifier type )
|
||||
|
||||
inline bool spec_is_trailing( Specifier specifier )
|
||||
{
|
||||
return specifier > Spec_Virtual;
|
||||
switch (specifier) {
|
||||
case Spec_Const:
|
||||
case Spec_Final:
|
||||
case Spec_NoExceptions:
|
||||
case Spec_Override:
|
||||
case Spec_Pure:
|
||||
case Spec_Volatile:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline Specifier str_to_specifier( Str str )
|
||||
|
@ -24,8 +24,8 @@ enum TokType : u32
|
||||
Tok_BraceCurly_Close,
|
||||
Tok_BraceSquare_Open,
|
||||
Tok_BraceSquare_Close,
|
||||
Tok_Capture_Start,
|
||||
Tok_Capture_End,
|
||||
Tok_Paren_Open,
|
||||
Tok_Paren_Close,
|
||||
Tok_Comment,
|
||||
Tok_Comment_End,
|
||||
Tok_Comment_Start,
|
||||
@ -53,6 +53,7 @@ enum TokType : u32
|
||||
Tok_Operator,
|
||||
Tok_Preprocess_Hash,
|
||||
Tok_Preprocess_Define,
|
||||
Tok_Preprocess_Define_Param,
|
||||
Tok_Preprocess_If,
|
||||
Tok_Preprocess_IfDef,
|
||||
Tok_Preprocess_IfNotDef,
|
||||
@ -62,7 +63,9 @@ enum TokType : u32
|
||||
Tok_Preprocess_Include,
|
||||
Tok_Preprocess_Pragma,
|
||||
Tok_Preprocess_Content,
|
||||
Tok_Preprocess_Macro,
|
||||
Tok_Preprocess_Macro_Expr,
|
||||
Tok_Preprocess_Macro_Stmt,
|
||||
Tok_Preprocess_Macro_Typename,
|
||||
Tok_Preprocess_Unsupported,
|
||||
Tok_Spec_Alignas,
|
||||
Tok_Spec_Const,
|
||||
@ -111,102 +114,105 @@ enum TokType : u32
|
||||
inline Str toktype_to_str( TokType type )
|
||||
{
|
||||
local_persist Str lookup[] = {
|
||||
{ "__invalid__", sizeof( "__invalid__" ) - 1 },
|
||||
{ "private", sizeof( "private" ) - 1 },
|
||||
{ "protected", sizeof( "protected" ) - 1 },
|
||||
{ "public", sizeof( "public" ) - 1 },
|
||||
{ ".", sizeof( "." ) - 1 },
|
||||
{ "::", sizeof( "::" ) - 1 },
|
||||
{ "&", sizeof( "&" ) - 1 },
|
||||
{ "&&", sizeof( "&&" ) - 1 },
|
||||
{ ":", sizeof( ":" ) - 1 },
|
||||
{ "[[", sizeof( "[[" ) - 1 },
|
||||
{ "]]", sizeof( "]]" ) - 1 },
|
||||
{ "{", sizeof( "{" ) - 1 },
|
||||
{ "}", sizeof( "}" ) - 1 },
|
||||
{ "[", sizeof( "[" ) - 1 },
|
||||
{ "]", sizeof( "]" ) - 1 },
|
||||
{ "(", sizeof( "(" ) - 1 },
|
||||
{ ")", sizeof( ")" ) - 1 },
|
||||
{ "__comment__", sizeof( "__comment__" ) - 1 },
|
||||
{ "__comment_end__", sizeof( "__comment_end__" ) - 1 },
|
||||
{ "__comment_start__", sizeof( "__comment_start__" ) - 1 },
|
||||
{ "__character__", sizeof( "__character__" ) - 1 },
|
||||
{ ",", sizeof( "," ) - 1 },
|
||||
{ "class", sizeof( "class" ) - 1 },
|
||||
{ "__attribute__", sizeof( "__attribute__" ) - 1 },
|
||||
{ "__declspec", sizeof( "__declspec" ) - 1 },
|
||||
{ "enum", sizeof( "enum" ) - 1 },
|
||||
{ "extern", sizeof( "extern" ) - 1 },
|
||||
{ "friend", sizeof( "friend" ) - 1 },
|
||||
{ "module", sizeof( "module" ) - 1 },
|
||||
{ "namespace", sizeof( "namespace" ) - 1 },
|
||||
{ "operator", sizeof( "operator" ) - 1 },
|
||||
{ "struct", sizeof( "struct" ) - 1 },
|
||||
{ "template", sizeof( "template" ) - 1 },
|
||||
{ "typedef", sizeof( "typedef" ) - 1 },
|
||||
{ "using", sizeof( "using" ) - 1 },
|
||||
{ "union", sizeof( "union" ) - 1 },
|
||||
{ "__identifier__", sizeof( "__identifier__" ) - 1 },
|
||||
{ "import", sizeof( "import" ) - 1 },
|
||||
{ "export", sizeof( "export" ) - 1 },
|
||||
{ "__new_line__", sizeof( "__new_line__" ) - 1 },
|
||||
{ "__number__", sizeof( "__number__" ) - 1 },
|
||||
{ "__operator__", sizeof( "__operator__" ) - 1 },
|
||||
{ "#", sizeof( "#" ) - 1 },
|
||||
{ "define", sizeof( "define" ) - 1 },
|
||||
{ "if", sizeof( "if" ) - 1 },
|
||||
{ "ifdef", sizeof( "ifdef" ) - 1 },
|
||||
{ "ifndef", sizeof( "ifndef" ) - 1 },
|
||||
{ "elif", sizeof( "elif" ) - 1 },
|
||||
{ "else", sizeof( "else" ) - 1 },
|
||||
{ "endif", sizeof( "endif" ) - 1 },
|
||||
{ "include", sizeof( "include" ) - 1 },
|
||||
{ "pragma", sizeof( "pragma" ) - 1 },
|
||||
{ "__macro_content__", sizeof( "__macro_content__" ) - 1 },
|
||||
{ "__macro__", sizeof( "__macro__" ) - 1 },
|
||||
{ "__unsupported__", sizeof( "__unsupported__" ) - 1 },
|
||||
{ "alignas", sizeof( "alignas" ) - 1 },
|
||||
{ "const", sizeof( "const" ) - 1 },
|
||||
{ "consteval", sizeof( "consteval" ) - 1 },
|
||||
{ "constexpr", sizeof( "constexpr" ) - 1 },
|
||||
{ "constinit", sizeof( "constinit" ) - 1 },
|
||||
{ "explicit", sizeof( "explicit" ) - 1 },
|
||||
{ "extern", sizeof( "extern" ) - 1 },
|
||||
{ "final", sizeof( "final" ) - 1 },
|
||||
{ "forceinline", sizeof( "forceinline" ) - 1 },
|
||||
{ "global", sizeof( "global" ) - 1 },
|
||||
{ "inline", sizeof( "inline" ) - 1 },
|
||||
{ "internal", sizeof( "internal" ) - 1 },
|
||||
{ "local_persist", sizeof( "local_persist" ) - 1 },
|
||||
{ "mutable", sizeof( "mutable" ) - 1 },
|
||||
{ "neverinline", sizeof( "neverinline" ) - 1 },
|
||||
{ "override", sizeof( "override" ) - 1 },
|
||||
{ "static", sizeof( "static" ) - 1 },
|
||||
{ "thread_local", sizeof( "thread_local" ) - 1 },
|
||||
{ "volatile", sizeof( "volatile" ) - 1 },
|
||||
{ "virtual", sizeof( "virtual" ) - 1 },
|
||||
{ "*", sizeof( "*" ) - 1 },
|
||||
{ ";", sizeof( ";" ) - 1 },
|
||||
{ "static_assert", sizeof( "static_assert" ) - 1 },
|
||||
{ "__string__", sizeof( "__string__" ) - 1 },
|
||||
{ "typename", sizeof( "typename" ) - 1 },
|
||||
{ "unsigned", sizeof( "unsigned" ) - 1 },
|
||||
{ "signed", sizeof( "signed" ) - 1 },
|
||||
{ "short", sizeof( "short" ) - 1 },
|
||||
{ "long", sizeof( "long" ) - 1 },
|
||||
{ "bool", sizeof( "bool" ) - 1 },
|
||||
{ "char", sizeof( "char" ) - 1 },
|
||||
{ "int", sizeof( "int" ) - 1 },
|
||||
{ "double", sizeof( "double" ) - 1 },
|
||||
{ "__int8", sizeof( "__int8" ) - 1 },
|
||||
{ "__int16", sizeof( "__int16" ) - 1 },
|
||||
{ "__int32", sizeof( "__int32" ) - 1 },
|
||||
{ "__int64", sizeof( "__int64" ) - 1 },
|
||||
{ "_W64", sizeof( "_W64" ) - 1 },
|
||||
{ "...", sizeof( "..." ) - 1 },
|
||||
{ "__attrib_start__", sizeof( "__attrib_start__" ) - 1 },
|
||||
{ "GEN_API", sizeof( "GEN_API" ) - 1 },
|
||||
{ "__invalid__", sizeof( "__invalid__" ) - 1 },
|
||||
{ "private", sizeof( "private" ) - 1 },
|
||||
{ "protected", sizeof( "protected" ) - 1 },
|
||||
{ "public", sizeof( "public" ) - 1 },
|
||||
{ ".", sizeof( "." ) - 1 },
|
||||
{ "::", sizeof( "::" ) - 1 },
|
||||
{ "&", sizeof( "&" ) - 1 },
|
||||
{ "&&", sizeof( "&&" ) - 1 },
|
||||
{ ":", sizeof( ":" ) - 1 },
|
||||
{ "[[", sizeof( "[[" ) - 1 },
|
||||
{ "]]", sizeof( "]]" ) - 1 },
|
||||
{ "{", sizeof( "{" ) - 1 },
|
||||
{ "}", sizeof( "}" ) - 1 },
|
||||
{ "[", sizeof( "[" ) - 1 },
|
||||
{ "]", sizeof( "]" ) - 1 },
|
||||
{ "(", sizeof( "(" ) - 1 },
|
||||
{ ")", sizeof( ")" ) - 1 },
|
||||
{ "__comment__", sizeof( "__comment__" ) - 1 },
|
||||
{ "__comment_end__", sizeof( "__comment_end__" ) - 1 },
|
||||
{ "__comment_start__", sizeof( "__comment_start__" ) - 1 },
|
||||
{ "__character__", sizeof( "__character__" ) - 1 },
|
||||
{ ",", sizeof( "," ) - 1 },
|
||||
{ "class", sizeof( "class" ) - 1 },
|
||||
{ "__attribute__", sizeof( "__attribute__" ) - 1 },
|
||||
{ "__declspec", sizeof( "__declspec" ) - 1 },
|
||||
{ "enum", sizeof( "enum" ) - 1 },
|
||||
{ "extern", sizeof( "extern" ) - 1 },
|
||||
{ "friend", sizeof( "friend" ) - 1 },
|
||||
{ "module", sizeof( "module" ) - 1 },
|
||||
{ "namespace", sizeof( "namespace" ) - 1 },
|
||||
{ "operator", sizeof( "operator" ) - 1 },
|
||||
{ "struct", sizeof( "struct" ) - 1 },
|
||||
{ "template", sizeof( "template" ) - 1 },
|
||||
{ "typedef", sizeof( "typedef" ) - 1 },
|
||||
{ "using", sizeof( "using" ) - 1 },
|
||||
{ "union", sizeof( "union" ) - 1 },
|
||||
{ "__identifier__", sizeof( "__identifier__" ) - 1 },
|
||||
{ "import", sizeof( "import" ) - 1 },
|
||||
{ "export", sizeof( "export" ) - 1 },
|
||||
{ "__new_line__", sizeof( "__new_line__" ) - 1 },
|
||||
{ "__number__", sizeof( "__number__" ) - 1 },
|
||||
{ "__operator__", sizeof( "__operator__" ) - 1 },
|
||||
{ "#", sizeof( "#" ) - 1 },
|
||||
{ "define", sizeof( "define" ) - 1 },
|
||||
{ "__define_param__", sizeof( "__define_param__" ) - 1 },
|
||||
{ "if", sizeof( "if" ) - 1 },
|
||||
{ "ifdef", sizeof( "ifdef" ) - 1 },
|
||||
{ "ifndef", sizeof( "ifndef" ) - 1 },
|
||||
{ "elif", sizeof( "elif" ) - 1 },
|
||||
{ "else", sizeof( "else" ) - 1 },
|
||||
{ "endif", sizeof( "endif" ) - 1 },
|
||||
{ "include", sizeof( "include" ) - 1 },
|
||||
{ "pragma", sizeof( "pragma" ) - 1 },
|
||||
{ "__macro_content__", sizeof( "__macro_content__" ) - 1 },
|
||||
{ "__macro_expression__", sizeof( "__macro_expression__" ) - 1 },
|
||||
{ "__macro_statment__", sizeof( "__macro_statment__" ) - 1 },
|
||||
{ "__macro_typename__", sizeof( "__macro_typename__" ) - 1 },
|
||||
{ "__unsupported__", sizeof( "__unsupported__" ) - 1 },
|
||||
{ "alignas", sizeof( "alignas" ) - 1 },
|
||||
{ "const", sizeof( "const" ) - 1 },
|
||||
{ "consteval", sizeof( "consteval" ) - 1 },
|
||||
{ "constexpr", sizeof( "constexpr" ) - 1 },
|
||||
{ "constinit", sizeof( "constinit" ) - 1 },
|
||||
{ "explicit", sizeof( "explicit" ) - 1 },
|
||||
{ "extern", sizeof( "extern" ) - 1 },
|
||||
{ "final", sizeof( "final" ) - 1 },
|
||||
{ "forceinline", sizeof( "forceinline" ) - 1 },
|
||||
{ "global", sizeof( "global" ) - 1 },
|
||||
{ "inline", sizeof( "inline" ) - 1 },
|
||||
{ "internal", sizeof( "internal" ) - 1 },
|
||||
{ "local_persist", sizeof( "local_persist" ) - 1 },
|
||||
{ "mutable", sizeof( "mutable" ) - 1 },
|
||||
{ "neverinline", sizeof( "neverinline" ) - 1 },
|
||||
{ "override", sizeof( "override" ) - 1 },
|
||||
{ "static", sizeof( "static" ) - 1 },
|
||||
{ "thread_local", sizeof( "thread_local" ) - 1 },
|
||||
{ "volatile", sizeof( "volatile" ) - 1 },
|
||||
{ "virtual", sizeof( "virtual" ) - 1 },
|
||||
{ "*", sizeof( "*" ) - 1 },
|
||||
{ ";", sizeof( ";" ) - 1 },
|
||||
{ "static_assert", sizeof( "static_assert" ) - 1 },
|
||||
{ "__string__", sizeof( "__string__" ) - 1 },
|
||||
{ "typename", sizeof( "typename" ) - 1 },
|
||||
{ "unsigned", sizeof( "unsigned" ) - 1 },
|
||||
{ "signed", sizeof( "signed" ) - 1 },
|
||||
{ "short", sizeof( "short" ) - 1 },
|
||||
{ "long", sizeof( "long" ) - 1 },
|
||||
{ "bool", sizeof( "bool" ) - 1 },
|
||||
{ "char", sizeof( "char" ) - 1 },
|
||||
{ "int", sizeof( "int" ) - 1 },
|
||||
{ "double", sizeof( "double" ) - 1 },
|
||||
{ "__int8", sizeof( "__int8" ) - 1 },
|
||||
{ "__int16", sizeof( "__int16" ) - 1 },
|
||||
{ "__int32", sizeof( "__int32" ) - 1 },
|
||||
{ "__int64", sizeof( "__int64" ) - 1 },
|
||||
{ "_W64", sizeof( "_W64" ) - 1 },
|
||||
{ "...", sizeof( "..." ) - 1 },
|
||||
{ "__attrib_start__", sizeof( "__attrib_start__" ) - 1 },
|
||||
{ "GEN_API", sizeof( "GEN_API" ) - 1 },
|
||||
};
|
||||
return lookup[type];
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#pragma region Constants
|
||||
|
||||
extern Str enum_underlying_sig;
|
||||
extern Macro enum_underlying_macro;
|
||||
|
||||
extern Code access_public;
|
||||
extern Code access_protected;
|
||||
|
@ -15,7 +15,7 @@
|
||||
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
|
||||
| | | | | __} | |
|
||||
| l_l l_l {___/ |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.20-Alpha |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.23-Alpha |
|
||||
! ============================================================================================ |
|
||||
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
|
||||
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |
|
||||
|
@ -257,6 +257,25 @@ CodeParams next_CodeParams(CodeParams params, CodeParams param_iter)
|
||||
}
|
||||
#pragma endregion CodeParams
|
||||
|
||||
#pragma region CodeDefineParams
|
||||
forceinline void define_params_append (CodeDefineParams appendee, CodeDefineParams other ) { params_append( cast(CodeParams, appendee), cast(CodeParams, other) ); }
|
||||
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 CodeDefineParams begin_CodeDefineParams(CodeDefineParams params) { return (CodeDefineParams) (Code) begin_CodeParams( cast(CodeParams, (Code)params)); }
|
||||
forceinline CodeDefineParams end_CodeDefineParams (CodeDefineParams params) { return (CodeDefineParams) (Code) end_CodeParams ( cast(CodeParams, (Code)params)); }
|
||||
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
|
||||
forceinline
|
||||
CodeDefineParams& CodeDefineParams::operator ++()
|
||||
{
|
||||
* this = ast->Next;
|
||||
return * this;
|
||||
}
|
||||
#endif
|
||||
#pragma endregion CodeDefineParams
|
||||
|
||||
#pragma region CodeSpecifiers
|
||||
inline
|
||||
bool specifiers_append(CodeSpecifiers self, Specifier spec )
|
||||
|
@ -179,37 +179,39 @@ 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 );
|
||||
code_set_global(cast(Code, spec_local_persist));
|
||||
|
||||
if (enum_underlying_sig.Len == 0) {
|
||||
enum_underlying_sig = txt("enum_underlying(");
|
||||
if (enum_underlying_macro.Name.Len == 0) {
|
||||
enum_underlying_macro.Name = txt("enum_underlying");
|
||||
enum_underlying_macro.Type = MT_Expression;
|
||||
enum_underlying_macro.Flags = MF_Functional;
|
||||
}
|
||||
array_append( _ctx->PreprocessorDefines, enum_underlying_sig);
|
||||
register_macro(enum_underlying_macro);
|
||||
}
|
||||
|
||||
void init(Context* ctx)
|
||||
@ -270,8 +272,8 @@ void init(Context* ctx)
|
||||
ctx->CodePool_NumBlocks = kilobytes(16);
|
||||
}
|
||||
|
||||
if (ctx->InitSize_LexArena == 0 ) {
|
||||
ctx->InitSize_LexArena = megabytes(4);
|
||||
if (ctx->InitSize_LexerTokens == 0 ) {
|
||||
ctx->InitSize_LexerTokens = kilobytes(64);
|
||||
}
|
||||
if (ctx->SizePer_StringArena == 0) {
|
||||
ctx->SizePer_StringArena = megabytes(1);
|
||||
@ -301,9 +303,6 @@ void init(Context* ctx)
|
||||
GEN_FATAL( "gen::init: Failed to initialize the code pool" );
|
||||
array_append( ctx->CodePools, code_pool );
|
||||
|
||||
// TODO(Ed): This is going to be phased out most likely.
|
||||
ctx->LexArena = arena_init_from_allocator( ctx->Allocator_DyanmicContainers, ctx->InitSize_LexArena );
|
||||
|
||||
// TODO(Ed): Eventually the string arenas needs to be phased out for a dedicated string slab allocator
|
||||
Arena strbuilder_arena = arena_init_from_allocator( ctx->Allocator_StrCache, ctx->SizePer_StringArena );
|
||||
if ( strbuilder_arena.PhysicalStart == nullptr )
|
||||
@ -315,9 +314,12 @@ void init(Context* ctx)
|
||||
ctx->StrCache = hashtable_init(StrCached, ctx->Allocator_DyanmicContainers);
|
||||
if ( ctx->StrCache.Entries == nullptr )
|
||||
GEN_FATAL( "gen::init: Failed to initialize the StringCache");
|
||||
|
||||
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" );
|
||||
}
|
||||
}
|
||||
// Preprocessor Defines
|
||||
ctx->PreprocessorDefines = array_init_reserve(StrCached, ctx->Allocator_DyanmicContainers, kilobytes(1) );
|
||||
|
||||
define_constants();
|
||||
parser_init();
|
||||
@ -354,9 +356,7 @@ void deinit(Context* ctx)
|
||||
array_free( ctx->CodePools);
|
||||
array_free( ctx->StringArenas);
|
||||
|
||||
arena_free(& ctx->LexArena);
|
||||
|
||||
array_free(ctx->PreprocessorDefines);
|
||||
hashtable_destroy(ctx->Macros);
|
||||
|
||||
left = array_num( ctx->Fallback_AllocatorBuckets);
|
||||
if (left)
|
||||
@ -376,6 +376,13 @@ void deinit(Context* ctx)
|
||||
if (_ctx == ctx)
|
||||
_ctx = nullptr;
|
||||
-- context_counter;
|
||||
|
||||
Context wipe = {};
|
||||
* ctx = wipe;
|
||||
}
|
||||
|
||||
Context* get_context() {
|
||||
return _ctx;
|
||||
}
|
||||
|
||||
void reset(Context* ctx)
|
||||
@ -401,6 +408,7 @@ void reset(Context* ctx)
|
||||
while ( left--, left );
|
||||
|
||||
hashtable_clear(ctx->StrCache);
|
||||
hashtable_clear(ctx->Macros);
|
||||
define_constants();
|
||||
}
|
||||
|
||||
@ -463,10 +471,51 @@ Code make_code()
|
||||
return result;
|
||||
}
|
||||
|
||||
void set_preprocess_define( Str id, b32 is_functional ) {
|
||||
StrBuilder builder = strbuilder_make_str( _ctx->Allocator_Temp, id );
|
||||
if (is_functional) {
|
||||
strbuilder_append_char( & builder, '(' );
|
||||
}
|
||||
array_append( _ctx->PreprocessorDefines, cache_str( strbuilder_to_str(builder)) );
|
||||
Macro* lookup_macro( Str name ) {
|
||||
u32 key = crc32( name.Ptr, name.Len );
|
||||
return hashtable_get( _ctx->Macros, key );
|
||||
}
|
||||
|
||||
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 );
|
||||
macro.Name = cache_str(macro.Name);
|
||||
hashtable_set( _ctx->Macros, key, macro );
|
||||
}
|
||||
|
||||
void register_macros( s32 num, ... )
|
||||
{
|
||||
GEN_ASSERT(num > 0);
|
||||
va_list va;
|
||||
va_start(va, num);
|
||||
do
|
||||
{
|
||||
Macro macro = va_arg(va, Macro);
|
||||
GEN_ASSERT_NOT_NULL(macro.Name.Ptr);
|
||||
GEN_ASSERT(macro.Name.Len > 0);
|
||||
macro.Name = cache_str(macro.Name);
|
||||
|
||||
u32 key = crc32( macro.Name.Ptr, macro.Name.Len );
|
||||
hashtable_set( _ctx->Macros, key, macro );
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void register_macros_arr( s32 num, Macro* macros )
|
||||
{
|
||||
GEN_ASSERT(num > 0);
|
||||
do
|
||||
{
|
||||
Macro macro = * macros;
|
||||
GEN_ASSERT_NOT_NULL(macro.Name.Ptr);
|
||||
GEN_ASSERT(macro.Name.Len > 0);
|
||||
macro.Name = cache_str(macro.Name);
|
||||
|
||||
u32 key = crc32( macro.Name.Ptr, macro.Name.Len );
|
||||
hashtable_set( _ctx->Macros, key, macro );
|
||||
++ macros;
|
||||
}
|
||||
while (num--, num > 0);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ struct Context
|
||||
u32 CodePool_NumBlocks;
|
||||
|
||||
// TODO(Ed): Review these... (No longer needed if using the proper allocation strategy)
|
||||
u32 InitSize_LexArena;
|
||||
u32 InitSize_LexerTokens;
|
||||
u32 SizePer_StringArena;
|
||||
|
||||
// TODO(Ed): Symbol Table
|
||||
@ -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.
|
||||
Array(StrCached) PreprocessorDefines;
|
||||
MacroTable Macros;
|
||||
|
||||
// Backend
|
||||
|
||||
@ -79,6 +79,8 @@ struct Context
|
||||
u32 InitSize_Fallback_Allocator_Bucket_Size;
|
||||
Array(Arena) Fallback_AllocatorBuckets;
|
||||
|
||||
StringTable token_fmt_map;
|
||||
|
||||
// Array(Token) LexerTokens;
|
||||
|
||||
Array(Pool) CodePools;
|
||||
@ -87,13 +89,13 @@ struct Context
|
||||
StringTable StrCache;
|
||||
|
||||
// TODO(Ed): This needs to be just handled by a parser context
|
||||
|
||||
Arena LexArena;
|
||||
StringTable Lexer_defines;
|
||||
Array(Token) Lexer_Tokens;
|
||||
|
||||
// TODO(Ed): Active parse context vs a parse result need to be separated conceptually
|
||||
ParseContext parser;
|
||||
|
||||
// TODO(Ed): Formatting - This will eventually be in a separate struct when in the process of serialization of the builder.
|
||||
s32 temp_serialize_indent;
|
||||
};
|
||||
|
||||
// Initialize the library. There first ctx initialized must exist for lifetime of other contextes that come after as its the one that
|
||||
@ -103,15 +105,30 @@ 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.
|
||||
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.
|
||||
// Ease of use.
|
||||
GEN_API void reset(Context* ctx);
|
||||
|
||||
GEN_API void set_context(Context* ctx);
|
||||
|
||||
// Mostly intended for the parser
|
||||
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
|
||||
GEN_API void set_preprocess_define( Str id, b32 is_functional );
|
||||
// Macros are tracked by name so if the name already exists the entry will be overwritten.
|
||||
GEN_API void register_macro( Macro macro );
|
||||
|
||||
// Ease of use batch registration
|
||||
GEN_API void register_macros( s32 num, ... );
|
||||
GEN_API void register_macros_arr( s32 num, Macro* macros );
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
forceinline void register_macros( s32 num, Macro* macros ) { return register_macros_arr(num, macros); }
|
||||
#endif
|
||||
|
||||
// Used internally to retrive or make string allocations.
|
||||
// Strings are stored in a series of string arenas of fixed size (SizePer_StringArena)
|
||||
@ -150,9 +167,12 @@ struct Opts_def_constructor {
|
||||
GEN_API CodeConstructor def_constructor( Opts_def_constructor opts GEN_PARAM_DEFAULT );
|
||||
|
||||
struct Opts_def_define {
|
||||
b32 dont_append_preprocess_defines;
|
||||
CodeDefineParams params;
|
||||
Str content;
|
||||
MacroFlags flags;
|
||||
b32 dont_register_to_preprocess_macros;
|
||||
};
|
||||
GEN_API CodeDefine def_define( Str name, Str content, Opts_def_define opts GEN_PARAM_DEFAULT );
|
||||
GEN_API CodeDefine def_define( Str name, MacroType type, Opts_def_define opts GEN_PARAM_DEFAULT );
|
||||
|
||||
struct Opts_def_destructor {
|
||||
Code body;
|
||||
@ -263,28 +283,45 @@ GEN_API CodeBody def_body( CodeType type );
|
||||
// There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num,
|
||||
/// or provide as an array of Code objects.
|
||||
|
||||
GEN_API CodeBody def_class_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_class_body ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_enum_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_enum_body ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_export_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_export_body ( s32 num, Code* codes);
|
||||
GEN_API CodeBody def_extern_link_body( s32 num, ... );
|
||||
GEN_API CodeBody def_extern_link_body( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_function_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_function_body ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_global_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_global_body ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_namespace_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_namespace_body ( s32 num, Code* codes );
|
||||
GEN_API CodeParams def_params ( s32 num, ... );
|
||||
GEN_API CodeParams def_params ( s32 num, CodeParams* params );
|
||||
GEN_API CodeSpecifiers def_specifiers ( s32 num, ... );
|
||||
GEN_API CodeSpecifiers def_specifiers ( s32 num, Specifier* specs );
|
||||
GEN_API CodeBody def_struct_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_struct_body ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_union_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_union_body ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_class_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_class_body_arr ( s32 num, Code* codes );
|
||||
GEN_API CodeDefineParams def_define_params ( s32 num, ... );
|
||||
GEN_API CodeDefineParams def_define_params_arr ( s32 num, CodeDefineParams* codes );
|
||||
GEN_API CodeBody def_enum_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_enum_body_arr ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_export_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_export_body_arr ( s32 num, Code* codes);
|
||||
GEN_API CodeBody def_extern_link_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_extern_link_body_arr ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_function_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_function_body_arr ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_global_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_global_body_arr ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_namespace_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_namespace_body_arr ( s32 num, Code* codes );
|
||||
GEN_API CodeParams def_params ( s32 num, ... );
|
||||
GEN_API CodeParams def_params_arr ( s32 num, CodeParams* params );
|
||||
GEN_API CodeSpecifiers def_specifiers ( s32 num, ... );
|
||||
GEN_API CodeSpecifiers def_specifiers_arr ( s32 num, Specifier* specs );
|
||||
GEN_API CodeBody def_struct_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_struct_body_arr ( s32 num, Code* codes );
|
||||
GEN_API CodeBody def_union_body ( s32 num, ... );
|
||||
GEN_API CodeBody def_union_body_arr ( s32 num, Code* codes );
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
forceinline CodeBody def_class_body ( s32 num, Code* codes ) { return def_class_body_arr(num, codes); }
|
||||
forceinline CodeDefineParams def_define_params ( s32 num, CodeDefineParams* codes ) { return def_define_params_arr(num, codes); }
|
||||
forceinline CodeBody def_enum_body ( s32 num, Code* codes ) { return def_enum_body_arr(num, codes); }
|
||||
forceinline CodeBody def_export_body ( s32 num, Code* codes) { return def_export_body_arr(num, codes); }
|
||||
forceinline CodeBody def_extern_link_body( s32 num, Code* codes ) { return def_extern_link_body_arr(num, codes); }
|
||||
forceinline CodeBody def_function_body ( s32 num, Code* codes ) { return def_function_body_arr(num, codes); }
|
||||
forceinline CodeBody def_global_body ( s32 num, Code* codes ) { return def_global_body_arr(num, codes); }
|
||||
forceinline CodeBody def_namespace_body ( s32 num, Code* codes ) { return def_namespace_body_arr(num, codes); }
|
||||
forceinline CodeParams def_params ( s32 num, CodeParams* params ) { return def_params_arr(num, params); }
|
||||
forceinline CodeSpecifiers def_specifiers ( s32 num, Specifier* specs ) { return def_specifiers_arr(num, specs); }
|
||||
forceinline CodeBody def_struct_body ( s32 num, Code* codes ) { return def_struct_body_arr(num, codes); }
|
||||
forceinline CodeBody def_union_body ( s32 num, Code* codes ) { return def_union_body_arr(num, codes); }
|
||||
#endif
|
||||
|
||||
#pragma endregion Upfront
|
||||
|
||||
@ -326,6 +363,7 @@ CodeBody parse_file( Str path );
|
||||
|
||||
GEN_API CodeClass parse_class ( Str class_def );
|
||||
GEN_API CodeConstructor parse_constructor ( Str constructor_def );
|
||||
GEN_API CodeDefine parse_define ( Str define_def );
|
||||
GEN_API CodeDestructor parse_destructor ( Str destructor_def );
|
||||
GEN_API CodeEnum parse_enum ( Str enum_def );
|
||||
GEN_API CodeBody parse_export_body ( Str export_def );
|
||||
@ -367,12 +405,20 @@ GEN_API Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... );
|
||||
#ifndef name
|
||||
// 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.
|
||||
#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
|
||||
|
||||
#ifndef code
|
||||
// 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
|
||||
|
||||
#ifndef args
|
||||
|
@ -73,7 +73,7 @@ CodeConstructor parse_constructor( Str def )
|
||||
|
||||
if ( NumSpecifiers )
|
||||
{
|
||||
specifiers = def_specifiers( NumSpecifiers, specs_found );
|
||||
specifiers = def_specifiers_arr( NumSpecifiers, specs_found );
|
||||
// <specifiers> ...
|
||||
}
|
||||
|
||||
@ -82,6 +82,21 @@ CodeConstructor parse_constructor( Str def )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeDefine parse_define( Str def )
|
||||
{
|
||||
check_parse_args( def );
|
||||
|
||||
TokArray toks = lex( def );
|
||||
if ( toks.Arr == nullptr )
|
||||
return InvalidCode;
|
||||
|
||||
_ctx->parser.Tokens = toks;
|
||||
push_scope();
|
||||
CodeDefine result = parser_parse_define();
|
||||
parser_pop(& _ctx->parser);
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeDestructor parse_destructor( Str def )
|
||||
{
|
||||
check_parse_args( def );
|
||||
|
@ -8,9 +8,8 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
||||
char const* buf_begin = buf;
|
||||
ssize remaining = buf_size;
|
||||
|
||||
local_persist StringTable tok_map;
|
||||
do_once() {
|
||||
tok_map = hashtable_init(Str, _ctx->Allocator_DyanmicContainers );
|
||||
if (_ctx->token_fmt_map.Hashes == nullptr) {
|
||||
_ctx->token_fmt_map = hashtable_init(Str, _ctx->Allocator_DyanmicContainers );
|
||||
}
|
||||
// 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 );
|
||||
|
||||
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;
|
||||
|
||||
u32 key = crc32( token, tok_len );
|
||||
Str* value = hashtable_get(tok_map, key );
|
||||
u32 key = crc32( token, tok_len );
|
||||
Str* value = hashtable_get(_ctx->token_fmt_map, key );
|
||||
|
||||
if ( value )
|
||||
{
|
||||
@ -87,7 +86,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
||||
current = * fmt;
|
||||
}
|
||||
}
|
||||
hashtable_clear(tok_map);
|
||||
hashtable_clear(_ctx->token_fmt_map);
|
||||
ssize result = buf_size - remaining;
|
||||
return result;
|
||||
}
|
||||
|
@ -25,22 +25,22 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
# define check_params() \
|
||||
if ( ! params_code ) \
|
||||
{ \
|
||||
log_failure("gen::def_operator: params is null and operator%s requires it", operator_to_str(op)); \
|
||||
log_failure("gen::def_operator: params is null and operator %S requires it", operator_to_str(op)); \
|
||||
return OpValResult_Fail; \
|
||||
} \
|
||||
if ( params_code->Type != CT_Parameters ) \
|
||||
{ \
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str( cast(Code, params_code))); \
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %S", code_debug_str( cast(Code, params_code))); \
|
||||
return OpValResult_Fail; \
|
||||
}
|
||||
|
||||
# define check_param_eq_ret() \
|
||||
if ( ! is_member_symbol && ! code_is_equal(cast(Code, params_code->ValueType), cast(Code, ret_type)) ) \
|
||||
{ \
|
||||
log_failure("gen::def_operator: operator%s requires first parameter to equal return type\n" \
|
||||
"param types: %s\n" \
|
||||
"return type: %s", \
|
||||
operator_to_str(op).Ptr, \
|
||||
log_failure("gen::def_operator: operator %S requires first parameter to equal return type\n" \
|
||||
"param types: %S\n" \
|
||||
"return type: %S", \
|
||||
operator_to_str(op), \
|
||||
code_debug_str(cast(Code, params_code)), \
|
||||
code_debug_str(cast(Code, ret_type)) \
|
||||
); \
|
||||
@ -50,12 +50,15 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
|
||||
if ( ! ret_type )
|
||||
{
|
||||
log_failure("gen::def_operator: ret_type is null but is required by operator%s", operator_to_str(op));
|
||||
log_failure("gen::def_operator: ret_type is null but is required by operator %S", operator_to_str(op));
|
||||
}
|
||||
|
||||
if ( ret_type->Type != CT_Typename )
|
||||
{
|
||||
log_failure("gen::def_operator: ret_type is not of typename type - %s", code_debug_str(cast(Code, ret_type)));
|
||||
log_failure("gen::def_operator: operator %S - ret_type is not of typename type - %S",
|
||||
operator_to_str(op),
|
||||
code_debug_str(cast(Code, ret_type))
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
@ -70,7 +73,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
if ( params_code->NumEntries > 1 )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s does not support non-member definition (more than one parameter provided) - %s",
|
||||
"operator %S does not support non-member definition (more than one parameter provided) - %S",
|
||||
operator_to_str(op),
|
||||
code_debug_str(cast(Code, params_code))
|
||||
);
|
||||
@ -100,7 +103,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
|
||||
if (params_code->NumEntries > 2 )
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s may not be defined with more than two parametes - param count; %d\n%s"
|
||||
log_failure("gen::def_operator: operator %S may not be defined with more than two parametes - param count; %d\n%S"
|
||||
, operator_to_str(op)
|
||||
, params_code->NumEntries
|
||||
, code_debug_str(cast(Code, params_code))
|
||||
@ -116,7 +119,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s params code provided is not of Parameters type - %s"
|
||||
log_failure("gen::def_operator: operator %S params code provided is not of Parameters type - %S"
|
||||
, operator_to_str(op)
|
||||
, code_debug_str(cast(Code, params_code))
|
||||
);
|
||||
@ -139,7 +142,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
if ( ! code_is_equal((Code)params_get(params_code, 1), (Code)t_int ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s requires second parameter of non-member definition to be int for post-decrement",
|
||||
"operator %S requires second parameter of non-member definition to be int for post-decrement",
|
||||
operator_to_str(op)
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
@ -147,7 +150,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
break;
|
||||
|
||||
default:
|
||||
log_failure("gen::def_operator: operator%s recieved unexpected number of parameters recived %d instead of 0-2"
|
||||
log_failure("gen::def_operator: operator %S recieved unexpected number of parameters recived %d instead of 0-2"
|
||||
, operator_to_str(op)
|
||||
, params_code->NumEntries
|
||||
);
|
||||
@ -165,16 +168,16 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code));
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %S", code_debug_str((Code)params_code));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
if ( code_is_equal((Code)params_code->ValueType, (Code)ret_type ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %s\n"
|
||||
"return type: %s\n"
|
||||
"operator %S is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %S\n"
|
||||
"return type: %S\n"
|
||||
, code_debug_str((Code)params_code)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
@ -183,7 +186,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
|
||||
if ( params_code->NumEntries > 1 )
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s may not have more than one parameter - param count: %d"
|
||||
log_failure("gen::def_operator: operator %S may not have more than one parameter - param count: %d"
|
||||
, operator_to_str(op)
|
||||
, params_code->NumEntries
|
||||
);
|
||||
@ -198,7 +201,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
#if 0
|
||||
if ( ! ret_type.is_equal( t_bool) )
|
||||
{
|
||||
log_failure( "gen::def_operator: return type is not a boolean - %s", code_debug_str(params_code) );
|
||||
log_failure( "gen::def_operator: operator %S return type is not a boolean - %S", operator_to_str(op) code_debug_str(params_code) );
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
#endif
|
||||
@ -210,14 +213,14 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure( "gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code) );
|
||||
log_failure( "gen::def_operator: operator %S - params is not of Parameters type - %S", operator_to_str(op), code_debug_str((Code)params_code) );
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
if ( params_code->NumEntries > 1 )
|
||||
{
|
||||
log_failure(
|
||||
"gen::def_operator: operator%s may not have more than one parameter - param count: %d",
|
||||
"gen::def_operator: operator %S may not have more than one parameter - param count: %d",
|
||||
operator_to_str( op ),
|
||||
params_code->NumEntries
|
||||
);
|
||||
@ -246,21 +249,22 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( ! code_is_equal((Code)params_code->ValueType, (Code)ret_type ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %s\n"
|
||||
"return type: %s\n"
|
||||
, code_debug_str((Code)params_code)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
// This is allowed for arithemtic operators
|
||||
// if ( ! code_is_equal((Code)params_code->ValueType, (Code)ret_type ) )
|
||||
// {
|
||||
// log_failure("gen::def_operator: "
|
||||
// "operator %S is non-member symbol yet first paramter does not equal return type\n"
|
||||
// "param type: %S\n"
|
||||
// "return type: %S\n"
|
||||
// , code_debug_str((Code)params_code)
|
||||
// , code_debug_str((Code)ret_type)
|
||||
// );
|
||||
// return OpValResult_Fail;
|
||||
// }
|
||||
break;
|
||||
|
||||
default:
|
||||
log_failure("gen::def_operator: operator%s recieved unexpected number of paramters recived %d instead of 0-2"
|
||||
log_failure("gen::def_operator: operator %S recieved unexpected number of paramters recived %d instead of 0-2"
|
||||
, operator_to_str(op)
|
||||
, params_code->NumEntries
|
||||
);
|
||||
@ -276,13 +280,13 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code));
|
||||
log_failure("gen::def_operator: operator %S - params is not of Parameters type - %S", operator_to_str(op), code_debug_str((Code)params_code));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
if ( params_code->NumEntries != 1 )
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s recieved unexpected number of paramters recived %d instead of 0-1"
|
||||
log_failure("gen::def_operator: operator %S recieved unexpected number of paramters recived %d instead of 0-1"
|
||||
, operator_to_str(op)
|
||||
, params_code->NumEntries
|
||||
);
|
||||
@ -292,7 +296,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
|
||||
if ( ! code_is_equal((Code)ret_type, (Code)t_bool ))
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s return type must be of type bool - %s"
|
||||
log_failure("gen::def_operator: operator %S return type must be of type bool - %S"
|
||||
, operator_to_str(op)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
@ -320,7 +324,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
break;
|
||||
|
||||
default:
|
||||
log_failure("gen::def_operator: operator%s recieved unexpected number of paramters recived %d instead of 1-2"
|
||||
log_failure("gen::def_operator: operator %S recieved unexpected number of paramters recived %d instead of 1-2"
|
||||
, operator_to_str(op)
|
||||
, params_code->NumEntries
|
||||
);
|
||||
@ -333,7 +337,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
case Op_MemberOfPointer:
|
||||
if ( params_code && params_code->NumEntries > 1)
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s recieved unexpected number of paramters recived %d instead of 0-1"
|
||||
log_failure("gen::def_operator: operator %S recieved unexpected number of paramters recived %d instead of 0-1"
|
||||
, operator_to_str(op)
|
||||
, params_code->NumEntries
|
||||
);
|
||||
@ -348,7 +352,7 @@ OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTy
|
||||
case Op_PtrToMemOfPtr:
|
||||
if ( params_code )
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s expects no paramters - %s", operator_to_str(op), code_debug_str((Code)params_code));
|
||||
log_failure("gen::def_operator: operator %S expects no paramters - %S", operator_to_str(op), code_debug_str((Code)params_code));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
break;
|
||||
@ -512,7 +516,6 @@ CodeClass def_class( Str name, Opts_def_struct p )
|
||||
GEN_DEBUG_TRAP();
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) {
|
||||
log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", code_debug_str(p.attributes) );
|
||||
GEN_DEBUG_TRAP();
|
||||
@ -525,9 +528,12 @@ CodeClass def_class( Str name, Opts_def_struct p )
|
||||
}
|
||||
|
||||
CodeClass
|
||||
result = (CodeClass) make_code();
|
||||
result->Name = cache_str( name );
|
||||
result->ModuleFlags = p.mflags;
|
||||
result = (CodeClass) make_code();
|
||||
result->Name = cache_str( name );
|
||||
result->ModuleFlags = p.mflags;
|
||||
result->Attributes = p.attributes;
|
||||
result->ParentAccess = p.parent_access;
|
||||
result->ParentType = p.parent;
|
||||
if ( p.body )
|
||||
{
|
||||
switch ( p.body->Type )
|
||||
@ -548,44 +554,32 @@ CodeClass def_class( Str name, Opts_def_struct p )
|
||||
else {
|
||||
result->Type = CT_Class_Fwd;
|
||||
}
|
||||
|
||||
result->Attributes = p.attributes;
|
||||
result->ParentAccess = p.parent_access;
|
||||
result->ParentType = p.parent;
|
||||
|
||||
for (s32 idx = 0; idx < p.num_interfaces; idx++ ) {
|
||||
class_add_interface(result, p.interfaces[idx] );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeDefine def_define( Str name, Str content, Opts_def_define p )
|
||||
CodeDefine def_define( Str name, MacroType type, Opts_def_define p )
|
||||
{
|
||||
if ( ! name_check( def_define, name ) ) {
|
||||
GEN_DEBUG_TRAP();
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
CodeDefine
|
||||
result = (CodeDefine) make_code();
|
||||
result->Type = CT_Preprocess_Define;
|
||||
result->Name = cache_str( name );
|
||||
|
||||
if ( content.Len <= 0 || content.Ptr == nullptr )
|
||||
result->Content = cache_str( txt("") );
|
||||
result->Params = p.params;
|
||||
if ( p.content.Len <= 0 || p.content.Ptr == nullptr )
|
||||
result->Body = untyped_str( txt("\n") );
|
||||
else
|
||||
result->Content = cache_str( strbuilder_to_str(strbuilder_fmt_buf(_ctx->Allocator_Temp, "%S\n", content)) );
|
||||
result->Body = untyped_str( strbuilder_to_str(strbuilder_fmt_buf(_ctx->Allocator_Temp, "%S\n", p.content)) );
|
||||
|
||||
b32 append_preprocess_defines = ! p.dont_append_preprocess_defines;
|
||||
if ( append_preprocess_defines ) {
|
||||
// Add the define to PreprocessorDefines for usage in parsing
|
||||
s32 lex_id_len = 0;
|
||||
for (; lex_id_len < result->Name.Len; ++ lex_id_len ) {
|
||||
if ( result->Name.Ptr[lex_id_len] == '(' )
|
||||
break;
|
||||
}
|
||||
Str lex_id = { result->Name.Ptr, lex_id_len };
|
||||
array_append(_ctx->PreprocessorDefines, cache_str(lex_id) );
|
||||
b32 register_define = ! p.dont_register_to_preprocess_macros;
|
||||
if ( register_define ) {
|
||||
Macro macro_entry = { result->Name, type, p.flags };
|
||||
register_macro(macro_entry);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -1280,7 +1274,7 @@ CodeUsing def_using_namespace( Str name )
|
||||
|
||||
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();
|
||||
return InvalidCode;
|
||||
}
|
||||
@ -1360,7 +1354,7 @@ CodeBody def_class_body( s32 num, ... )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_CLASS_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_CLASS_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1375,7 +1369,7 @@ CodeBody def_class_body( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_class_body( s32 num, Code* codes )
|
||||
CodeBody def_class_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_class_body );
|
||||
|
||||
@ -1392,7 +1386,7 @@ CodeBody def_class_body( s32 num, Code* codes )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_CLASS_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_CLASS_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_class_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1406,6 +1400,67 @@ CodeBody def_class_body( s32 num, Code* codes )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeDefineParams def_define_params( s32 num, ... )
|
||||
{
|
||||
def_body_start( def_define_params );
|
||||
|
||||
va_list va;
|
||||
va_start(va, num);
|
||||
|
||||
Code_POD pod = va_arg(va, Code_POD);
|
||||
CodeDefineParams param = pcast( CodeDefineParams, pod );
|
||||
|
||||
null_check( def_define_params, param );
|
||||
if ( param->Type != CT_Parameters_Define ) {
|
||||
log_failure( "gen::def_define_params: param %d is not a parameter for a preprocessor define", num - num + 1 );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
CodeDefineParams result = (CodeDefineParams) code_duplicate(param);
|
||||
while ( -- num )
|
||||
{
|
||||
pod = va_arg(va, Code_POD);
|
||||
param = pcast( CodeDefineParams, pod );
|
||||
if ( param->Type != CT_Parameters_Define ) {
|
||||
log_failure( "gen::def_define_params: param %d is not a parameter for a preprocessor define", num - num + 1 );
|
||||
return InvalidCode;
|
||||
}
|
||||
define_params_append(result, param );
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeDefineParams def_define_params_arr( s32 num, CodeDefineParams* codes )
|
||||
{
|
||||
def_body_code_array_start( def_define_params );
|
||||
|
||||
# define check_current(current) \
|
||||
if ( current == nullptr ) { \
|
||||
log_failure("gen::def_define_params: Provide a null code in codes array"); \
|
||||
return InvalidCode; \
|
||||
} \
|
||||
if (current->Type != CT_Parameters_Define ) { \
|
||||
log_failure("gen::def_define_params: Code in coes array is not of paramter for preprocessor define type - %s", code_debug_str(current) ); \
|
||||
return InvalidCode; \
|
||||
}
|
||||
CodeDefineParams current = (CodeDefineParams)code_duplicate(* codes);
|
||||
check_current(current);
|
||||
|
||||
CodeDefineParams
|
||||
result = (CodeDefineParams) make_code();
|
||||
result->Name = current->Name;
|
||||
result->Type = current->Type;
|
||||
while( codes++, current = * codes, num--, num > 0 ) {
|
||||
check_current(current);
|
||||
define_params_append(result, current );
|
||||
}
|
||||
# undef check_current
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_enum_body( s32 num, ... )
|
||||
{
|
||||
def_body_start( def_enum_body );
|
||||
@ -1436,7 +1491,7 @@ CodeBody def_enum_body( s32 num, ... )
|
||||
return (CodeBody) result;
|
||||
}
|
||||
|
||||
CodeBody def_enum_body( s32 num, Code* codes )
|
||||
CodeBody def_enum_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_enum_body );
|
||||
|
||||
@ -1482,7 +1537,7 @@ CodeBody def_export_body( s32 num, ... )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1497,7 +1552,7 @@ CodeBody def_export_body( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_export_body( s32 num, Code* codes )
|
||||
CodeBody def_export_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_export_body );
|
||||
|
||||
@ -1514,7 +1569,7 @@ CodeBody def_export_body( s32 num, Code* codes )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_export_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1548,7 +1603,7 @@ CodeBody def_extern_link_body( s32 num, ... )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1563,7 +1618,7 @@ CodeBody def_extern_link_body( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_extern_link_body( s32 num, Code* codes )
|
||||
CodeBody def_extern_link_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_extern_linkage_body );
|
||||
|
||||
@ -1581,7 +1636,7 @@ CodeBody def_extern_link_body( s32 num, Code* codes )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_extern_linkage_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1615,7 +1670,7 @@ CodeBody def_function_body( s32 num, ... )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" stringize(def_function_body) ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1630,7 +1685,7 @@ CodeBody def_function_body( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_function_body( s32 num, Code* codes )
|
||||
CodeBody def_function_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_function_body );
|
||||
|
||||
@ -1647,7 +1702,7 @@ CodeBody def_function_body( s32 num, Code* codes )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_function_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1686,7 +1741,7 @@ CodeBody def_global_body( s32 num, ... )
|
||||
body_append_body( result, cast(CodeBody, entry) );
|
||||
continue;
|
||||
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1701,7 +1756,7 @@ CodeBody def_global_body( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_global_body( s32 num, Code* codes )
|
||||
CodeBody def_global_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_global_body );
|
||||
|
||||
@ -1722,7 +1777,7 @@ CodeBody def_global_body( s32 num, Code* codes )
|
||||
body_append_body(result, cast(CodeBody, entry) );
|
||||
continue;
|
||||
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_global_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1757,7 +1812,7 @@ CodeBody def_namespace_body( s32 num, ... )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1772,7 +1827,7 @@ CodeBody def_namespace_body( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_namespace_body( s32 num, Code* codes )
|
||||
CodeBody def_namespace_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_namespace_body );
|
||||
|
||||
@ -1789,7 +1844,7 @@ CodeBody def_namespace_body( s32 num, Code* codes )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", code_debug_str(entry) );
|
||||
return InvalidCode;
|
||||
|
||||
@ -1834,7 +1889,7 @@ CodeParams def_params( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeParams def_params( s32 num, CodeParams* codes )
|
||||
CodeParams def_params_arr( s32 num, CodeParams* codes )
|
||||
{
|
||||
def_body_code_array_start( def_params );
|
||||
|
||||
@ -1890,7 +1945,7 @@ CodeSpecifiers def_specifiers( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeSpecifiers def_specifiers( s32 num, Specifier* specs )
|
||||
CodeSpecifiers def_specifiers_arr( s32 num, Specifier* specs )
|
||||
{
|
||||
if ( num <= 0 ) {
|
||||
log_failure("gen::def_specifiers: num cannot be zero or less");
|
||||
@ -1934,7 +1989,7 @@ CodeBody def_struct_body( s32 num, ... )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", code_debug_str(entry));
|
||||
return InvalidCode;
|
||||
|
||||
@ -1949,7 +2004,7 @@ CodeBody def_struct_body( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_struct_body( s32 num, Code* codes )
|
||||
CodeBody def_struct_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_struct_body );
|
||||
|
||||
@ -1966,7 +2021,7 @@ CodeBody def_struct_body( s32 num, Code* codes )
|
||||
}
|
||||
switch (entry->Type)
|
||||
{
|
||||
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES:
|
||||
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES_CASES:
|
||||
log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", code_debug_str(entry) );
|
||||
return InvalidCode;
|
||||
|
||||
@ -2010,7 +2065,7 @@ CodeBody def_union_body( s32 num, ... )
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeBody def_union_body( s32 num, Code* codes )
|
||||
CodeBody def_union_body_arr( s32 num, Code* codes )
|
||||
{
|
||||
def_body_code_array_start( def_union_body );
|
||||
|
||||
|
@ -112,6 +112,158 @@ void lexer_end_line( LexContext* ctx )
|
||||
}
|
||||
#define end_line() lexer_end_line(ctx)
|
||||
|
||||
// TODO(Ed): We need to to attempt to recover from a lex failure?
|
||||
s32 lex_preprocessor_define( LexContext* ctx )
|
||||
{
|
||||
Token name = { { ctx->scanner, 1 }, Tok_Identifier, ctx->line, ctx->column, TF_Preprocess };
|
||||
move_forward();
|
||||
|
||||
while ( ctx->left && ( char_is_alphanumeric((* ctx->scanner)) || (* ctx->scanner) == '_' ) ) {
|
||||
move_forward();
|
||||
name.Text.Len++;
|
||||
}
|
||||
|
||||
Specifier spec = str_to_specifier( name.Text );
|
||||
TokType attrib = str_to_toktype( name.Text );
|
||||
b32 not_specifier = spec == Spec_Invalid;
|
||||
b32 not_attribute = attrib <= Tok___Attributes_Start;
|
||||
|
||||
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"
|
||||
, name.Text
|
||||
);
|
||||
// GEN_DEBUG_TRAP();
|
||||
}
|
||||
array_append( _ctx->Lexer_Tokens, name );
|
||||
|
||||
if ( ctx->left && (* ctx->scanner) == '(' )
|
||||
{
|
||||
if (registered_macro && ! macro_is_functional(* registered_macro)) {
|
||||
log_fmt("Warning: %S registered macro is not flagged as functional yet the definition detects opening parenthesis '(' for arguments\n"
|
||||
, name.Text
|
||||
);
|
||||
// GEN_DEBUG_TRAP();
|
||||
}
|
||||
else {
|
||||
macro.Flags |= MF_Functional;
|
||||
}
|
||||
|
||||
Token opening_paren = { { ctx->scanner, 1 }, Tok_Paren_Open, ctx->line, ctx->column, TF_Preprocess };
|
||||
array_append( _ctx->Lexer_Tokens, opening_paren );
|
||||
move_forward();
|
||||
|
||||
Token last_parameter = {};
|
||||
// We need to tokenize the define's arguments now:
|
||||
while( ctx->left && * ctx->scanner != ')')
|
||||
{
|
||||
skip_whitespace();
|
||||
|
||||
Str possible_varadic = { ctx->scanner, 3 };
|
||||
if ( ctx->left > 3 && str_are_equal( txt("..."), possible_varadic ) ) {
|
||||
Token parameter = { { ctx->scanner, 3 }, Tok_Preprocess_Define_Param, ctx->line, ctx->column, TF_Preprocess };
|
||||
move_forward();
|
||||
move_forward();
|
||||
move_forward();
|
||||
|
||||
array_append(_ctx->Lexer_Tokens, parameter);
|
||||
skip_whitespace();
|
||||
last_parameter = parameter;
|
||||
|
||||
while ( (* ctx->scanner) == '\\' ) {
|
||||
move_forward();
|
||||
skip_whitespace();
|
||||
}
|
||||
if (* ctx->scanner != ')' )
|
||||
{
|
||||
log_failure("lex_preprocessor_define(%d, %d): Expected a ')' after '...' (varaidc macro param) %S\n"
|
||||
, ctx->line
|
||||
, ctx->column
|
||||
, name.Text
|
||||
);
|
||||
return Lex_ReturnNull;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if ( (* ctx->scanner) == '\\' ) {
|
||||
move_forward();
|
||||
skip_whitespace();
|
||||
continue;
|
||||
}
|
||||
else if ( char_is_alpha( (* ctx->scanner) ) || (* ctx->scanner) == '_' )
|
||||
{
|
||||
Token parameter = { { ctx->scanner, 1 }, Tok_Preprocess_Define_Param, ctx->line, ctx->column, TF_Preprocess };
|
||||
move_forward();
|
||||
|
||||
while ( ctx->left && ( char_is_alphanumeric((* ctx->scanner)) || (* ctx->scanner) == '_' ) )
|
||||
{
|
||||
move_forward();
|
||||
parameter.Text.Len++;
|
||||
}
|
||||
array_append(_ctx->Lexer_Tokens, parameter);
|
||||
skip_whitespace();
|
||||
last_parameter = parameter;
|
||||
}
|
||||
else {
|
||||
log_failure("lex_preprocessor_define(%d, %d): Expected a '_' or alpha character for a parameter name for %S\n"
|
||||
, ctx->line
|
||||
, ctx->column
|
||||
, name.Text
|
||||
);
|
||||
return Lex_ReturnNull;
|
||||
}
|
||||
|
||||
if (* ctx->scanner == ')' )
|
||||
break;
|
||||
|
||||
// There should be a comma
|
||||
if ( * ctx->scanner != ',' ) {
|
||||
log_failure("lex_preprocessor_define(%d, %d): Expected a comma after parameter %S for %S\n"
|
||||
, ctx->line
|
||||
, ctx->column
|
||||
, last_parameter.Text
|
||||
, name.Text
|
||||
);
|
||||
return Lex_ReturnNull;
|
||||
}
|
||||
Token comma = { { ctx->scanner, 1 }, Tok_Comma, ctx->line, ctx->column, TF_Preprocess };
|
||||
array_append(_ctx->Lexer_Tokens, comma);
|
||||
move_forward();
|
||||
}
|
||||
|
||||
if ( * ctx->scanner != ')' ) {
|
||||
log_failure("lex_preprocessor_define(%d, %d): Expected a ')' after last_parameter %S for %S (ran out of characters...)\n"
|
||||
, ctx->line
|
||||
, ctx->column
|
||||
, last_parameter.Text
|
||||
, name.Text
|
||||
);
|
||||
return Lex_ReturnNull;
|
||||
}
|
||||
Token closing_paren = { { ctx->scanner, 1 }, Tok_Paren_Close, ctx->line, ctx->column, TF_Preprocess };
|
||||
array_append(_ctx->Lexer_Tokens, closing_paren);
|
||||
move_forward();
|
||||
}
|
||||
else if ( registered_macro && macro_is_functional( * registered_macro) ) {
|
||||
if (registered_macro && ! macro_is_functional(* registered_macro)) {
|
||||
log_fmt("Warning: %S registered macro is flagged as functional yet the definition detects no opening parenthesis '(' for arguments\n"
|
||||
, name.Text
|
||||
);
|
||||
GEN_DEBUG_TRAP();
|
||||
}
|
||||
}
|
||||
|
||||
if ( registered_macro == nullptr ) {
|
||||
register_macro(macro);
|
||||
}
|
||||
|
||||
// Define's content handled by lex_preprocessor_directive (the original caller of this)
|
||||
return Lex_Continue;
|
||||
}
|
||||
|
||||
// TODO(Ed): We need to to attempt to recover from a lex failure?
|
||||
forceinline
|
||||
s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
{
|
||||
@ -215,28 +367,9 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
|
||||
if ( ctx->token.Type == Tok_Preprocess_Define )
|
||||
{
|
||||
Token name = { { ctx->scanner, 0 }, Tok_Identifier, ctx->line, ctx->column, TF_Preprocess };
|
||||
|
||||
name.Text.Ptr = ctx->scanner;
|
||||
name.Text.Len = 1;
|
||||
move_forward();
|
||||
|
||||
while ( ctx->left && ( char_is_alphanumeric((* ctx->scanner)) || (* ctx->scanner) == '_' ) )
|
||||
{
|
||||
move_forward();
|
||||
name.Text.Len++;
|
||||
}
|
||||
|
||||
if ( ctx->left && (* ctx->scanner) == '(' )
|
||||
{
|
||||
move_forward();
|
||||
name.Text.Len++;
|
||||
}
|
||||
|
||||
array_append( _ctx->Lexer_Tokens, name );
|
||||
|
||||
u64 key = crc32( name.Text.Ptr, name.Text.Len );
|
||||
hashtable_set(ctx->defines, key, tok_to_str(name) );
|
||||
u32 result = lex_preprocessor_define(ctx); // handles: #define <name>( <params> ) - define's content handled later on within this scope.
|
||||
if (result != Lex_Continue)
|
||||
return Lex_ReturnNull;
|
||||
}
|
||||
|
||||
Token preprocess_content = { { ctx->scanner, 0 }, Tok_Preprocess_Content, ctx->line, ctx->column, TF_Preprocess };
|
||||
@ -286,7 +419,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
s32 within_string = false;
|
||||
s32 within_char = false;
|
||||
|
||||
// SkipWhitespace();
|
||||
// Consume preprocess content
|
||||
while ( ctx->left )
|
||||
{
|
||||
if ( (* ctx->scanner) == '"' && ! within_char )
|
||||
@ -322,6 +455,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
, (* ctx->scanner), ctx->line, ctx->column
|
||||
, directive_str, preprocess_content.Line, preprocess_content.Column
|
||||
, content_str );
|
||||
return Lex_ReturnNull;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -349,30 +483,24 @@ s32 lex_preprocessor_directive( LexContext* ctx )
|
||||
forceinline
|
||||
void lex_found_token( LexContext* ctx )
|
||||
{
|
||||
if ( ctx->token.Type != Tok_Invalid )
|
||||
{
|
||||
if ( ctx->token.Type != Tok_Invalid ) {
|
||||
array_append( _ctx->Lexer_Tokens, ctx->token );
|
||||
return;
|
||||
}
|
||||
|
||||
TokType type = str_to_toktype( tok_to_str(ctx->token) );
|
||||
|
||||
if (type <= Tok_Access_Public && type >= Tok_Access_Private )
|
||||
{
|
||||
if (type <= Tok_Access_Public && type >= Tok_Access_Private ) {
|
||||
ctx->token.Flags |= TF_AccessSpecifier;
|
||||
}
|
||||
|
||||
if ( type > Tok___Attributes_Start )
|
||||
{
|
||||
if ( type > Tok___Attributes_Start ) {
|
||||
ctx->token.Flags |= TF_Attribute;
|
||||
}
|
||||
|
||||
if ( type == Tok_Decl_Extern_Linkage )
|
||||
{
|
||||
skip_whitespace();
|
||||
|
||||
if ( (* ctx->scanner) != '"' )
|
||||
{
|
||||
if ( (* ctx->scanner) != '"' ) {
|
||||
type = Tok_Spec_Extern;
|
||||
ctx->token.Flags |= TF_Specifier;
|
||||
}
|
||||
@ -381,7 +509,6 @@ void lex_found_token( LexContext* ctx )
|
||||
array_append( _ctx->Lexer_Tokens, ctx->token );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( type <= Tok_Star && type >= Tok_Spec_Alignas)
|
||||
|| type == Tok_Ampersand
|
||||
|| type == Tok_Ampersand_DBL )
|
||||
@ -391,8 +518,6 @@ void lex_found_token( LexContext* ctx )
|
||||
array_append( _ctx->Lexer_Tokens, ctx->token );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( type != Tok_Invalid )
|
||||
{
|
||||
ctx->token.Type = type;
|
||||
@ -400,50 +525,31 @@ void lex_found_token( LexContext* ctx )
|
||||
return;
|
||||
}
|
||||
|
||||
u64 key = 0;
|
||||
if ( (* ctx->scanner) == '(')
|
||||
key = crc32( ctx->token.Text.Ptr, ctx->token.Text.Len + 1 );
|
||||
else
|
||||
key = crc32( ctx->token.Text.Ptr, ctx->token.Text.Len );
|
||||
|
||||
Str* define = hashtable_get(ctx->defines, key );
|
||||
if ( define )
|
||||
{
|
||||
ctx->token.Type = Tok_Preprocess_Macro;
|
||||
|
||||
// Want to ignore any arguments the define may have as they can be execution expressions.
|
||||
if ( ctx->left && (* ctx->scanner) == '(' )
|
||||
{
|
||||
move_forward();
|
||||
ctx->token.Text.Len++;
|
||||
|
||||
s32 level = 0;
|
||||
while ( ctx->left && ((* ctx->scanner) != ')' || level > 0) )
|
||||
{
|
||||
if ( (* ctx->scanner) == '(' )
|
||||
level++;
|
||||
|
||||
else if ( (* ctx->scanner) == ')' && level > 0 )
|
||||
level--;
|
||||
|
||||
move_forward();
|
||||
ctx->token.Text.Len++;
|
||||
}
|
||||
|
||||
move_forward();
|
||||
ctx->token.Text.Len++;
|
||||
Macro* macro = lookup_macro( ctx->token.Text );
|
||||
b32 has_args = ctx->left && (* ctx->scanner) == '(';
|
||||
b32 resolved_to_macro = false;
|
||||
if (macro) {
|
||||
ctx->token.Type = macrotype_to_toktype(macro->Type);
|
||||
b32 is_functional = macro_is_functional(* macro);
|
||||
resolved_to_macro = has_args ? is_functional : ! is_functional;
|
||||
if ( ! resolved_to_macro && GEN_BUILD_DEBUG ) {
|
||||
log_fmt("Info(%d, %d): %S identified as a macro but usage here does not resolve to one (interpreting as identifier)\n"
|
||||
, ctx->token.Line
|
||||
, ctx->token.Line
|
||||
, macro->Name
|
||||
);
|
||||
}
|
||||
}
|
||||
if ( resolved_to_macro )
|
||||
{
|
||||
// TODO(Ed): When we introduce a macro AST (and expression support), we'll properly lex this section.
|
||||
// Want to ignore any arguments the define may have as they can be execution expressions.
|
||||
if ( has_args ) {
|
||||
ctx->token.Flags |= TF_Macro_Functional;
|
||||
}
|
||||
if ( bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Attribute) ) {
|
||||
ctx->token.Flags |= TF_Attribute;
|
||||
}
|
||||
|
||||
//if ( (* ctx->scanner) == '\r' && ctx->scanner[1] == '\n' )
|
||||
//{
|
||||
// move_forward();
|
||||
// ctx->token..Text.Length++;
|
||||
//}
|
||||
//else if ( (* ctx->scanner) == '\n' )
|
||||
//{
|
||||
// move_forward();
|
||||
// ctx->token..Text.Length++;
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -453,6 +559,7 @@ void lex_found_token( LexContext* ctx )
|
||||
array_append( _ctx->Lexer_Tokens, ctx->token );
|
||||
}
|
||||
|
||||
// TODO(Ed): We need to to attempt to recover from a lex failure?
|
||||
neverinline
|
||||
// TokArray lex( Array<Token> tokens, Str content )
|
||||
TokArray lex( Str content )
|
||||
@ -461,7 +568,6 @@ TokArray lex( Str content )
|
||||
c.content = content;
|
||||
c.left = content.Len;
|
||||
c.scanner = content.Ptr;
|
||||
c.defines = _ctx->Lexer_defines;
|
||||
|
||||
char const* word = c.scanner;
|
||||
s32 word_length = 0;
|
||||
@ -477,26 +583,10 @@ TokArray lex( Str content )
|
||||
return null_array;
|
||||
}
|
||||
|
||||
for ( StrCached* entry = array_begin(_ctx->PreprocessorDefines); entry != array_end(_ctx->PreprocessorDefines); entry = array_next(_ctx->PreprocessorDefines, entry))
|
||||
{
|
||||
s32 length = 0;
|
||||
char const* entry_scanner = (*entry).Ptr;
|
||||
while ( entry->Len > length && (char_is_alphanumeric( *entry_scanner ) || *entry_scanner == '_') )
|
||||
{
|
||||
entry_scanner++;
|
||||
length ++;
|
||||
}
|
||||
if ( entry_scanner[0] == '(' )
|
||||
{
|
||||
length++;
|
||||
}
|
||||
|
||||
u64 key = crc32( entry->Ptr, length );
|
||||
hashtable_set(c.defines, key, * entry );
|
||||
}
|
||||
|
||||
array_clear(_ctx->Lexer_Tokens);
|
||||
|
||||
b32 preprocess_args = true;
|
||||
|
||||
while (c.left )
|
||||
{
|
||||
#if 0
|
||||
@ -707,7 +797,7 @@ TokArray lex( Str content )
|
||||
{
|
||||
Str text = { c.scanner, 1 };
|
||||
c.token.Text = text;
|
||||
c.token.Type = Tok_Capture_Start;
|
||||
c.token.Type = Tok_Paren_Open;
|
||||
|
||||
if (c.left)
|
||||
move_forward();
|
||||
@ -717,7 +807,7 @@ TokArray lex( Str content )
|
||||
{
|
||||
Str text = { c.scanner, 1 };
|
||||
c.token.Text = text;
|
||||
c.token.Type = Tok_Capture_End;
|
||||
c.token.Type = Tok_Paren_Close;
|
||||
|
||||
if (c.left)
|
||||
move_forward();
|
||||
@ -938,7 +1028,7 @@ TokArray lex( Str content )
|
||||
goto FoundToken;
|
||||
}
|
||||
|
||||
// Dash is unfortunatlly a bit more complicated...
|
||||
// Dash is unfortunately a bit more complicated...
|
||||
case '-':
|
||||
{
|
||||
Str text = { c.scanner, 1 };
|
||||
@ -1075,8 +1165,7 @@ TokArray lex( Str content )
|
||||
c.token.Text = text;
|
||||
move_forward();
|
||||
|
||||
while ( c.left && ( char_is_alphanumeric((* ctx->scanner)) || (* ctx->scanner) == '_' ) )
|
||||
{
|
||||
while ( c.left && ( char_is_alphanumeric((* ctx->scanner)) || (* ctx->scanner) == '_' ) ) {
|
||||
move_forward();
|
||||
c.token.Text.Len++;
|
||||
}
|
||||
@ -1102,8 +1191,7 @@ TokArray lex( Str content )
|
||||
move_forward();
|
||||
c.token.Text.Len++;
|
||||
|
||||
while ( c.left && char_is_hex_digit((* ctx->scanner)) )
|
||||
{
|
||||
while ( c.left && char_is_hex_digit((* ctx->scanner)) ) {
|
||||
move_forward();
|
||||
c.token.Text.Len++;
|
||||
}
|
||||
@ -1111,8 +1199,7 @@ TokArray lex( Str content )
|
||||
goto FoundToken;
|
||||
}
|
||||
|
||||
while ( c.left && char_is_digit((* ctx->scanner)) )
|
||||
{
|
||||
while ( c.left && char_is_digit((* ctx->scanner)) ) {
|
||||
move_forward();
|
||||
c.token.Text.Len++;
|
||||
}
|
||||
@ -1122,8 +1209,7 @@ TokArray lex( Str content )
|
||||
move_forward();
|
||||
c.token.Text.Len++;
|
||||
|
||||
while ( c.left && char_is_digit((* ctx->scanner)) )
|
||||
{
|
||||
while ( c.left && char_is_digit((* ctx->scanner)) ) {
|
||||
move_forward();
|
||||
c.token.Text.Len++;
|
||||
}
|
||||
@ -1141,8 +1227,7 @@ TokArray lex( Str content )
|
||||
c.token.Text.Len++;
|
||||
|
||||
// Handle 'll'/'LL' as a special case when we just processed an 'l'/'L'
|
||||
if (c.left && (prev == 'l' || prev == 'L') && ((* ctx->scanner) == 'l' || (* ctx->scanner) == 'L'))
|
||||
{
|
||||
if (c.left && (prev == 'l' || prev == 'L') && ((* ctx->scanner) == 'l' || (* ctx->scanner) == 'L')) {
|
||||
move_forward();
|
||||
c.token.Text.Len++;
|
||||
}
|
||||
@ -1168,8 +1253,7 @@ TokArray lex( Str content )
|
||||
log_failure( "Failed to lex token '%c' (%d, %d)\n%s", (* ctx->scanner), c.line, c.column, context_str );
|
||||
|
||||
// Skip to next whitespace since we can't know if anything else is valid until then.
|
||||
while ( c.left && ! char_is_space( (* ctx->scanner) ) )
|
||||
{
|
||||
while ( c.left && ! char_is_space( (* ctx->scanner) ) ) {
|
||||
move_forward();
|
||||
}
|
||||
}
|
||||
@ -1178,17 +1262,15 @@ TokArray lex( Str content )
|
||||
{
|
||||
lex_found_token( ctx );
|
||||
TokType last_type = array_back(_ctx->Lexer_Tokens)->Type;
|
||||
if ( last_type == Tok_Preprocess_Macro )
|
||||
if ( last_type == Tok_Preprocess_Macro_Stmt || last_type == Tok_Preprocess_Macro_Expr )
|
||||
{
|
||||
Token thanks_c = { { c.scanner, 0 }, Tok_Invalid, c.line, c.column, TF_Null };
|
||||
c.token = thanks_c;
|
||||
if ( (* ctx->scanner) == '\r')
|
||||
{
|
||||
if ( (* ctx->scanner) == '\r') {
|
||||
move_forward();
|
||||
c.token.Text.Len = 1;
|
||||
}
|
||||
|
||||
if ( (* ctx->scanner) == '\n' )
|
||||
if ( (* ctx->scanner) == '\n' )
|
||||
{
|
||||
c.token.Type = Tok_NewLine;
|
||||
c.token.Text.Len++;
|
||||
@ -1201,20 +1283,16 @@ TokArray lex( Str content )
|
||||
}
|
||||
}
|
||||
|
||||
if ( array_num(_ctx->Lexer_Tokens) == 0 )
|
||||
{
|
||||
if ( array_num(_ctx->Lexer_Tokens) == 0 ) {
|
||||
log_failure( "Failed to lex any tokens" );
|
||||
{
|
||||
TokArray tok_array = {};
|
||||
return tok_array;
|
||||
}
|
||||
TokArray tok_array = {};
|
||||
return tok_array;
|
||||
}
|
||||
|
||||
hashtable_clear(_ctx->Lexer_defines);
|
||||
// defines_map_arena.free();
|
||||
TokArray result = { _ctx->Lexer_Tokens, 0 };
|
||||
return result;
|
||||
}
|
||||
|
||||
#undef move_forward
|
||||
#undef skip_whitespace
|
||||
#undef end_line
|
||||
|
File diff suppressed because it is too large
Load Diff
105
base/components/parser_case_macros.cpp
Normal file
105
base/components/parser_case_macros.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
// These macros are used in the swtich cases within parser.cpp
|
||||
|
||||
#define GEN_PARSER_CLASS_STRUCT_BODY_ALLOWED_MEMBER_TOK_SPECIFIER_CASES \
|
||||
case Tok_Spec_Consteval: \
|
||||
case Tok_Spec_Constexpr: \
|
||||
case Tok_Spec_Constinit: \
|
||||
case Tok_Spec_Explicit: \
|
||||
case Tok_Spec_ForceInline: \
|
||||
case Tok_Spec_Inline: \
|
||||
case Tok_Spec_Mutable: \
|
||||
case Tok_Spec_NeverInline: \
|
||||
case Tok_Spec_Static: \
|
||||
case Tok_Spec_Volatile: \
|
||||
case Tok_Spec_Virtual
|
||||
|
||||
#define GEN_PARSER_CLASS_STRUCT_BODY_ALLOWED_MEMBER_SPECIFIER_CASES \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_Constinit: \
|
||||
case Spec_Explicit: \
|
||||
case Spec_Inline: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_Mutable: \
|
||||
case Spec_NeverInline: \
|
||||
case Spec_Static: \
|
||||
case Spec_Volatile: \
|
||||
case Spec_Virtual
|
||||
|
||||
#define GEN_PARSER_CLASS_GLOBAL_NSPACE_ALLOWED_MEMBER_TOK_SPECIFIER_CASES \
|
||||
case Tok_Spec_Consteval: \
|
||||
case Tok_Spec_Constexpr: \
|
||||
case Tok_Spec_Constinit: \
|
||||
case Tok_Spec_Extern: \
|
||||
case Tok_Spec_ForceInline: \
|
||||
case Tok_Spec_Global: \
|
||||
case Tok_Spec_Inline: \
|
||||
case Tok_Spec_Internal_Linkage: \
|
||||
case Tok_Spec_NeverInline: \
|
||||
case Tok_Spec_Static
|
||||
|
||||
#define GEN_PARSER_CLASS_GLOBAL_NSPACE_ALLOWED_MEMBER_SPECIFIER_CASES \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_Constinit: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_Global: \
|
||||
case Spec_External_Linkage: \
|
||||
case Spec_Internal_Linkage: \
|
||||
case Spec_Inline: \
|
||||
case Spec_Mutable: \
|
||||
case Spec_NeverInline: \
|
||||
case Spec_Static: \
|
||||
case Spec_Volatile
|
||||
|
||||
#define GEN_PARSER_FRIEND_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Inline: \
|
||||
case Spec_ForceInline
|
||||
|
||||
#define GEN_PARSER_FUNCTION_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Consteval: \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_External_Linkage: \
|
||||
case Spec_Internal_Linkage: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_Inline: \
|
||||
case Spec_NeverInline: \
|
||||
case Spec_Static
|
||||
|
||||
#define GEN_PARSER_OPERATOR_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_Inline: \
|
||||
case Spec_NeverInline: \
|
||||
case Spec_Static
|
||||
|
||||
#define GEN_PARSER_TEMPLATE_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_Constinit: \
|
||||
case Spec_External_Linkage: \
|
||||
case Spec_Global: \
|
||||
case Spec_Inline: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_Local_Persist: \
|
||||
case Spec_Mutable: \
|
||||
case Spec_Static: \
|
||||
case Spec_Thread_Local: \
|
||||
case Spec_Volatile
|
||||
|
||||
#define GEN_PARSER_VARIABLE_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_Constinit: \
|
||||
case Spec_External_Linkage: \
|
||||
case Spec_Global: \
|
||||
case Spec_Inline: \
|
||||
case Spec_Local_Persist: \
|
||||
case Spec_Mutable: \
|
||||
case Spec_Static: \
|
||||
case Spec_Thread_Local: \
|
||||
case Spec_Volatile
|
||||
|
||||
|
||||
|
@ -4,21 +4,24 @@
|
||||
#include "gen/ecode.hpp"
|
||||
#include "gen/eoperator.hpp"
|
||||
#include "gen/especifier.hpp"
|
||||
#include "gen/etoktype.hpp"
|
||||
#endif
|
||||
|
||||
enum TokFlags : u32
|
||||
{
|
||||
TF_Operator = bit(0),
|
||||
TF_Assign = bit(1),
|
||||
TF_Preprocess = bit(2),
|
||||
TF_Preprocess_Cond = bit(3),
|
||||
TF_Attribute = bit(6),
|
||||
TF_AccessOperator = bit( 7 ),
|
||||
TF_AccessSpecifier = bit( 8 ),
|
||||
TF_Specifier = bit( 9 ),
|
||||
TF_EndDefinition = bit( 10 ), // Either ; or }
|
||||
TF_Formatting = bit( 11 ),
|
||||
TF_Literal = bit( 12 ),
|
||||
TF_Operator = bit(0),
|
||||
TF_Assign = bit(1),
|
||||
TF_Preprocess = bit(2),
|
||||
TF_Preprocess_Cond = bit(3),
|
||||
TF_Attribute = bit(6),
|
||||
TF_AccessOperator = bit(7),
|
||||
TF_AccessSpecifier = bit(8),
|
||||
TF_Specifier = bit(9),
|
||||
TF_EndDefinition = bit(10), // Either ; or }
|
||||
TF_Formatting = bit(11),
|
||||
TF_Literal = bit(12),
|
||||
TF_Macro_Functional = bit(13),
|
||||
TF_Macro_Expects_Body = bit(14),
|
||||
|
||||
TF_Null = 0,
|
||||
TF_UnderlyingType = GEN_U32_MAX,
|
||||
@ -52,42 +55,42 @@ bool tok_is_valid( Token tok ) {
|
||||
|
||||
forceinline
|
||||
bool tok_is_access_operator(Token tok) {
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_AccessOperator );
|
||||
return bitfield_is_set( u32, tok.Flags, TF_AccessOperator );
|
||||
}
|
||||
|
||||
forceinline
|
||||
bool tok_is_access_specifier(Token tok) {
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_AccessSpecifier );
|
||||
return bitfield_is_set( u32, tok.Flags, TF_AccessSpecifier );
|
||||
}
|
||||
|
||||
forceinline
|
||||
bool tok_is_attribute(Token tok) {
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Attribute );
|
||||
return bitfield_is_set( u32, tok.Flags, TF_Attribute );
|
||||
}
|
||||
|
||||
forceinline
|
||||
bool tok_is_operator(Token tok) {
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Operator );
|
||||
return bitfield_is_set( u32, tok.Flags, TF_Operator );
|
||||
}
|
||||
|
||||
forceinline
|
||||
bool tok_is_preprocessor(Token tok) {
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Preprocess );
|
||||
return bitfield_is_set( u32, tok.Flags, TF_Preprocess );
|
||||
}
|
||||
|
||||
forceinline
|
||||
bool tok_is_preprocess_cond(Token tok) {
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Preprocess_Cond );
|
||||
return bitfield_is_set( u32, tok.Flags, TF_Preprocess_Cond );
|
||||
}
|
||||
|
||||
forceinline
|
||||
bool tok_is_specifier(Token tok) {
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_Specifier );
|
||||
return bitfield_is_set( u32, tok.Flags, TF_Specifier );
|
||||
}
|
||||
|
||||
forceinline
|
||||
bool tok_is_end_definition(Token tok) {
|
||||
return bitfield_is_equal( u32, tok.Flags, TF_EndDefinition );
|
||||
return bitfield_is_set( u32, tok.Flags, TF_EndDefinition );
|
||||
}
|
||||
|
||||
StrBuilder tok_to_strbuilder(Token tok);
|
||||
@ -105,7 +108,7 @@ struct LexContext
|
||||
char const* scanner;
|
||||
s32 line;
|
||||
s32 column;
|
||||
StringTable defines;
|
||||
// StringTable defines;
|
||||
Token token;
|
||||
};
|
||||
|
||||
@ -123,3 +126,96 @@ struct ParseContext
|
||||
TokArray Tokens;
|
||||
StackNode* Scope;
|
||||
};
|
||||
|
||||
enum MacroType : u16
|
||||
{
|
||||
MT_Expression, // A macro is assumed to be a expression if not resolved.
|
||||
MT_Statement,
|
||||
MT_Typename,
|
||||
MT_Block_Start, // Not Supported yet
|
||||
MT_Block_End, // Not Supported yet
|
||||
MT_Case_Statement, // Not Supported yet
|
||||
|
||||
MT_UnderlyingType = GEN_U16_MAX,
|
||||
};
|
||||
|
||||
forceinline
|
||||
TokType macrotype_to_toktype( MacroType type ) {
|
||||
switch ( type ) {
|
||||
case MT_Statement : return Tok_Preprocess_Macro_Stmt;
|
||||
case MT_Expression : return Tok_Preprocess_Macro_Expr;
|
||||
case MT_Typename : return Tok_Preprocess_Macro_Typename;
|
||||
}
|
||||
// All others unsupported for now.
|
||||
return Tok_Invalid;
|
||||
}
|
||||
|
||||
inline
|
||||
Str macrotype_to_str( MacroType type )
|
||||
{
|
||||
local_persist
|
||||
Str lookup[] = {
|
||||
{ "Statement", sizeof("Statement") - 1 },
|
||||
{ "Expression", sizeof("Expression") - 1 },
|
||||
{ "Typename", sizeof("Typename") - 1 },
|
||||
{ "Block_Start", sizeof("Block_Start") - 1 },
|
||||
{ "Block_End", sizeof("Block_End") - 1 },
|
||||
{ "Case_Statement", sizeof("Case_Statement") - 1 },
|
||||
};
|
||||
local_persist
|
||||
Str invalid = { "Invalid", sizeof("Invalid") };
|
||||
if ( type > MT_Case_Statement )
|
||||
return invalid;
|
||||
|
||||
return lookup[ type ];
|
||||
}
|
||||
|
||||
enum EMacroFlags : u16
|
||||
{
|
||||
MF_Functional = bit(0), // Macro has parameters (args expected to be passed)
|
||||
MF_Expects_Body = bit(1), // Expects to assign a braced scope to its body.
|
||||
|
||||
// lex__eat wil treat this macro as an identifier if the parser attempts to consume it as one.
|
||||
// ^^^ This is a kludge because we don't support push/pop macro pragmas rn.
|
||||
MF_Allow_As_Identifier = bit(2),
|
||||
|
||||
// lex__eat wil treat this macro as an attribute if the parser attempts to consume it as one.
|
||||
// ^^^ This a kludge because unreal has a macro that behaves as both a 'statement' and an attribute (UE_DEPRECATED, PRAGMA_ENABLE_DEPRECATION_WARNINGS, etc)
|
||||
// TODO(Ed): We can keep the MF_Allow_As_Attribute flag for macros, however, we need to add the ability of AST_Attributes to chain themselves.
|
||||
// Its thats already a thing in the standard language anyway
|
||||
// & it would allow UE_DEPRECATED, (UE_PROPERTY / UE_FUNCTION) to chain themselves as attributes of a resolved member function/varaible definition
|
||||
MF_Allow_As_Attribute = bit(3),
|
||||
|
||||
// When a macro is encountered after attributs and specifiers while parsing a function, or variable:
|
||||
// It will consume the macro and treat it as resolving the definition. (Yes this is for Unreal Engine)
|
||||
// (MUST BE OF MT_Statement TYPE)
|
||||
MF_Allow_As_Definition = bit(4),
|
||||
|
||||
MF_Null = 0,
|
||||
MF_UnderlyingType = GEN_U16_MAX,
|
||||
};
|
||||
typedef u16 MacroFlags;
|
||||
|
||||
struct Macro
|
||||
{
|
||||
StrCached Name;
|
||||
MacroType Type;
|
||||
MacroFlags Flags;
|
||||
};
|
||||
|
||||
forceinline
|
||||
b32 macro_is_functional( Macro macro ) {
|
||||
return bitfield_is_set( b16, macro.Flags, MF_Functional );
|
||||
}
|
||||
|
||||
forceinline
|
||||
b32 macro_expects_body( Macro macro ) {
|
||||
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;
|
||||
|
@ -5,11 +5,10 @@
|
||||
|
||||
#pragma region StaticData
|
||||
global Context* _ctx;
|
||||
global u32 context_counter;
|
||||
|
||||
#pragma region Constants
|
||||
global u32 context_counter;
|
||||
|
||||
global Str enum_underlying_sig;
|
||||
global Macro enum_underlying_macro;
|
||||
|
||||
global Code Code_Global;
|
||||
global Code Code_Invalid;
|
||||
|
@ -143,13 +143,14 @@ Array<Type> array_init_reserve(AllocatorInfo allocator, ssize capacity)
|
||||
return {rcast(Type*, header + 1)};
|
||||
}
|
||||
|
||||
forceinline
|
||||
usize array_grow_formula(ssize value) {
|
||||
return 2 * value + 8;
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
bool array_append_array(Array<Type>* array, Array<Type> other) {
|
||||
return array_append_items(array, (Type*)other, num(other));
|
||||
return array_append_items(array, (Type*)other, array_num(other));
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
@ -179,13 +180,13 @@ bool array_append_items(Array<Type>* array, Type* items, usize item_num)
|
||||
GEN_ASSERT(* array != nullptr);
|
||||
GEN_ASSERT(items != nullptr);
|
||||
GEN_ASSERT(item_num > 0);
|
||||
ArrayHeader* header = array_get_header(array);
|
||||
ArrayHeader* header = array_get_header(* array);
|
||||
|
||||
if (header->Num + item_num > header->Capacity)
|
||||
{
|
||||
if ( ! grow(array, header->Capacity + item_num))
|
||||
if ( ! array_grow(array, header->Capacity + item_num))
|
||||
return false;
|
||||
header = array_get_header(array);
|
||||
header = array_get_header(* array);
|
||||
}
|
||||
|
||||
mem_copy((Type*)array + header->Num, items, item_num * sizeof(Type));
|
||||
@ -202,7 +203,7 @@ bool array_append_at(Array<Type>* array, Type item, usize idx)
|
||||
ArrayHeader* header = array_get_header(* array);
|
||||
|
||||
ssize slot = idx;
|
||||
if (slot >= header->Num)
|
||||
if (slot >= (ssize)(header->Num))
|
||||
slot = header->Num - 1;
|
||||
|
||||
if (slot < 0)
|
||||
@ -281,10 +282,9 @@ bool array_fill(Array<Type> array, usize begin, usize end, Type value)
|
||||
ArrayHeader* header = array_get_header(array);
|
||||
|
||||
if (begin < 0 || end > header->Num)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
for (ssize idx = ssize(begin); idx < ssize(end); idx++)
|
||||
{
|
||||
for (ssize idx = ssize(begin); idx < ssize(end); idx++) {
|
||||
array[idx] = value;
|
||||
}
|
||||
|
||||
@ -354,7 +354,6 @@ bool array_reserve(Array<Type>* array, usize new_capacity)
|
||||
{
|
||||
GEN_ASSERT( array != nullptr);
|
||||
GEN_ASSERT(* array != nullptr);
|
||||
GEN_ASSERT(num > 0)
|
||||
ArrayHeader* header = array_get_header(array);
|
||||
|
||||
if (header->Capacity < new_capacity)
|
||||
@ -754,7 +753,7 @@ HashTableFindResult hashtable__find(HashTable<Type> table, u64 key)
|
||||
if (table.Entries[result.EntryIndex].Key == key)
|
||||
break;
|
||||
|
||||
result.PrevIndex = result.EntryIndex;
|
||||
result.PrevIndex = result.EntryIndex;
|
||||
result.EntryIndex = table.Entries[result.EntryIndex].Next;
|
||||
}
|
||||
}
|
||||
@ -763,7 +762,7 @@ HashTableFindResult hashtable__find(HashTable<Type> table, u64 key)
|
||||
}
|
||||
|
||||
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.Entries);
|
||||
usize critical_load = usize(HashTable_CriticalLoadScale * f32(array_num(table.Hashes)));
|
||||
|
@ -11,10 +11,10 @@
|
||||
#if GEN_BUILD_DEBUG
|
||||
# if defined( GEN_COMPILER_MSVC )
|
||||
# if _MSC_VER < 1300
|
||||
#pragma message("GEN_BUILD_DEBUG: __asm int 3")
|
||||
// #pragma message("GEN_BUILD_DEBUG: __asm int 3")
|
||||
# define GEN_DEBUG_TRAP() __asm int 3 /* Trap to debugger! */
|
||||
# else
|
||||
#pragma message("GEN_BUILD_DEBUG: __debugbreak()")
|
||||
// #pragma message("GEN_BUILD_DEBUG: __debugbreak()")
|
||||
# define GEN_DEBUG_TRAP() __debugbreak()
|
||||
# endif
|
||||
# elif defined( GEN_COMPILER_TINYC )
|
||||
@ -23,7 +23,7 @@
|
||||
# define GEN_DEBUG_TRAP() __builtin_trap()
|
||||
# endif
|
||||
#else
|
||||
#pragma message("GEN_BUILD_DEBUG: omitted")
|
||||
// #pragma message("GEN_BUILD_DEBUG: omitted")
|
||||
# define GEN_DEBUG_TRAP()
|
||||
#endif
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
// NOTE: Things that shouldn't happen with a message!
|
||||
#define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ )
|
||||
|
||||
#if GEN_BULD_DEBUG
|
||||
#if GEN_BUILD_DEBUG
|
||||
#define GEN_FATAL( ... ) \
|
||||
do \
|
||||
{ \
|
||||
|
@ -34,8 +34,8 @@
|
||||
#endif
|
||||
|
||||
#ifndef bit
|
||||
#define bit( Value ) ( 1 << Value )
|
||||
#define bitfield_is_equal( Type, Field, Mask ) ( (scast(Type, Mask) & scast(Type, Field)) == scast(Type, Mask) )
|
||||
#define bit( Value ) ( 1 << Value )
|
||||
#define bitfield_is_set( Type, Field, Mask ) ( (scast(Type, Mask) & scast(Type, Field)) == scast(Type, Mask) )
|
||||
#endif
|
||||
|
||||
// Mainly intended for forcing the base library to utilize only C-valid constructs or type coercion
|
||||
@ -86,14 +86,16 @@
|
||||
#define stringize( ... ) stringize_va( __VA_ARGS__ )
|
||||
#endif
|
||||
|
||||
#ifndef do_once
|
||||
#define do_once() \
|
||||
static int __do_once_counter_##__LINE__ = 0; \
|
||||
for(; __do_once_counter_##__LINE__ != 1; __do_once_counter_##__LINE__ = 1 ) \
|
||||
#define src_line_str stringize(__LINE__)
|
||||
|
||||
#define do_once_defer( expression ) \
|
||||
static int __do_once_counter_##__LINE__ = 0; \
|
||||
for(; __do_once_counter_##__LINE__ != 1; __do_once_counter_##__LINE__ = 1, (expression)) \
|
||||
#ifndef do_once
|
||||
#define do_once() \
|
||||
local_persist 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 ) \
|
||||
local_persist 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 \
|
||||
do \
|
||||
@ -248,9 +250,9 @@
|
||||
# if ! GEN_COMPILER_C
|
||||
# define typeof decltype
|
||||
# elif defined(_MSC_VER)
|
||||
# define typeof(x) __typeof__(x)
|
||||
# define typeof __typeof__
|
||||
# elif defined(__GNUC__) || defined(__clang__)
|
||||
# define typeof(x) __typeof__(x)
|
||||
# define typeof __typeof__
|
||||
# else
|
||||
# error "Compiler not supported"
|
||||
# endif
|
||||
|
@ -346,25 +346,25 @@ void* arena_allocator_proc( void* allocator_data, AllocType type, ssize size, ss
|
||||
switch ( type )
|
||||
{
|
||||
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 );
|
||||
ssize total_size = align_forward_s64( size, alignment );
|
||||
|
||||
// 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 );
|
||||
// zpl__printf_err("%s", "Arena out of memory\n");
|
||||
GEN_FATAL("Arena out of memory! (Possibly could not fit for the largest size Arena!!)");
|
||||
}
|
||||
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 :
|
||||
// NOTE: Free all at once
|
||||
|
@ -225,11 +225,10 @@ forceinline ssize size_remaining(Arena& arena, ssize alignment) { return
|
||||
// This id is defined by Unreal for asserts
|
||||
#pragma push_macro("check")
|
||||
#undef check
|
||||
forceinline void check(Arena& arena) { return arena_check(& arena); };
|
||||
forceinline void check(Arena& arena) { return arena_check(& arena); }
|
||||
#pragma pop_macro("check")
|
||||
#endif
|
||||
|
||||
|
||||
inline
|
||||
AllocatorInfo arena_allocator_info( Arena* arena ) {
|
||||
GEN_ASSERT(arena != nullptr);
|
||||
@ -392,9 +391,9 @@ void pool_clear(Pool* pool);
|
||||
void pool_free(Pool* pool);
|
||||
|
||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||
AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); }
|
||||
void clear(Pool& pool) { return pool_clear(& pool); }
|
||||
void free(Pool& pool) { return pool_free(& pool); }
|
||||
forceinline AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); }
|
||||
forceinline void clear(Pool& pool) { return pool_clear(& pool); }
|
||||
forceinline void free(Pool& pool) { return pool_free(& pool); }
|
||||
#endif
|
||||
|
||||
struct Pool
|
||||
|
@ -40,9 +40,9 @@ struct Str
|
||||
|
||||
#ifndef txt
|
||||
# if GEN_COMPILER_CPP
|
||||
# define txt( text ) Str { ( text ), sizeof( text ) - 1 }
|
||||
# define txt( text ) GEN_NS Str { ( text ), sizeof( text ) - 1 }
|
||||
# else
|
||||
# define txt( text ) (Str){ ( text ), sizeof( text ) - 1 }
|
||||
# define txt( text ) (GEN_NS Str){ ( text ), sizeof( text ) - 1 }
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
inline
|
||||
bool strbuilder_append_fmt(StrBuilder* str, char const* fmt, ...) {
|
||||
GEN_ASSERT(str != nullptr);
|
||||
ssize res;
|
||||
@ -599,7 +600,7 @@ void strbuilder_skip_line(StrBuilder str)
|
||||
}
|
||||
|
||||
inline
|
||||
void strip_space(StrBuilder str)
|
||||
void strbuilder_strip_space(StrBuilder str)
|
||||
{
|
||||
char* write_pos = str;
|
||||
char* read_pos = str;
|
||||
|
@ -37,6 +37,7 @@ Operator_Member_Fwd, "operator"
|
||||
Operator_Cast, "operator"
|
||||
Operator_Cast_Fwd, "operator"
|
||||
Parameters, "__NA__"
|
||||
Parameters_Define, "__NA__"
|
||||
Preprocess_Define, "define"
|
||||
Preprocess_Include, "include"
|
||||
Preprocess_If, "if"
|
||||
|
|
@ -1,95 +1,98 @@
|
||||
Invalid, "__invalid__"
|
||||
Access_Private, "private"
|
||||
Access_Protected, "protected"
|
||||
Access_Public, "public"
|
||||
Access_MemberSymbol, "."
|
||||
Access_StaticSymbol, "::"
|
||||
Ampersand, "&"
|
||||
Ampersand_DBL, "&&"
|
||||
Assign_Classifer, ":"
|
||||
Attribute_Open, "[["
|
||||
Attribute_Close, "]]"
|
||||
BraceCurly_Open, "{"
|
||||
BraceCurly_Close, "}"
|
||||
BraceSquare_Open, "["
|
||||
BraceSquare_Close, "]"
|
||||
Capture_Start, "("
|
||||
Capture_End, ")"
|
||||
Comment, "__comment__"
|
||||
Comment_End, "__comment_end__"
|
||||
Comment_Start, "__comment_start__"
|
||||
Char, "__character__"
|
||||
Comma, ","
|
||||
Decl_Class, "class"
|
||||
Decl_GNU_Attribute, "__attribute__"
|
||||
Decl_MSVC_Attribute, "__declspec"
|
||||
Decl_Enum, "enum"
|
||||
Decl_Extern_Linkage, "extern"
|
||||
Decl_Friend, "friend"
|
||||
Decl_Module, "module"
|
||||
Decl_Namespace, "namespace"
|
||||
Decl_Operator, "operator"
|
||||
Decl_Struct, "struct"
|
||||
Decl_Template, "template"
|
||||
Decl_Typedef, "typedef"
|
||||
Decl_Using, "using"
|
||||
Decl_Union, "union"
|
||||
Identifier, "__identifier__"
|
||||
Module_Import, "import"
|
||||
Module_Export, "export"
|
||||
NewLine, "__new_line__"
|
||||
Number, "__number__"
|
||||
Operator, "__operator__"
|
||||
Preprocess_Hash, "#"
|
||||
Preprocess_Define, "define"
|
||||
Preprocess_If, "if"
|
||||
Preprocess_IfDef, "ifdef"
|
||||
Preprocess_IfNotDef, "ifndef"
|
||||
Preprocess_ElIf, "elif"
|
||||
Preprocess_Else, "else"
|
||||
Preprocess_EndIf, "endif"
|
||||
Preprocess_Include, "include"
|
||||
Preprocess_Pragma, "pragma"
|
||||
Preprocess_Content, "__macro_content__"
|
||||
Preprocess_Macro, "__macro__"
|
||||
Preprocess_Unsupported, "__unsupported__"
|
||||
Spec_Alignas, "alignas"
|
||||
Spec_Const, "const"
|
||||
Spec_Consteval, "consteval"
|
||||
Spec_Constexpr, "constexpr"
|
||||
Spec_Constinit, "constinit"
|
||||
Spec_Explicit, "explicit"
|
||||
Spec_Extern, "extern"
|
||||
Spec_Final, "final"
|
||||
Spec_ForceInline, "forceinline"
|
||||
Spec_Global, "global"
|
||||
Spec_Inline, "inline"
|
||||
Spec_Internal_Linkage, "internal"
|
||||
Spec_LocalPersist, "local_persist"
|
||||
Spec_Mutable, "mutable"
|
||||
Spec_NeverInline, "neverinline"
|
||||
Spec_Override, "override"
|
||||
Spec_Static, "static"
|
||||
Spec_ThreadLocal, "thread_local"
|
||||
Spec_Volatile, "volatile"
|
||||
Spec_Virtual, "virtual"
|
||||
Star, "*"
|
||||
Statement_End, ";"
|
||||
StaticAssert, "static_assert"
|
||||
String, "__string__"
|
||||
Type_Typename, "typename"
|
||||
Type_Unsigned, "unsigned"
|
||||
Type_Signed, "signed"
|
||||
Type_Short, "short"
|
||||
Type_Long, "long"
|
||||
Type_bool, "bool"
|
||||
Type_char, "char"
|
||||
Type_int, "int"
|
||||
Type_double, "double"
|
||||
Type_MS_int8, "__int8"
|
||||
Type_MS_int16, "__int16"
|
||||
Type_MS_int32, "__int32"
|
||||
Type_MS_int64, "__int64"
|
||||
Type_MS_W64, "_W64"
|
||||
Varadic_Argument, "..."
|
||||
__Attributes_Start, "__attrib_start__"
|
||||
Invalid, "__invalid__"
|
||||
Access_Private, "private"
|
||||
Access_Protected, "protected"
|
||||
Access_Public, "public"
|
||||
Access_MemberSymbol, "."
|
||||
Access_StaticSymbol, "::"
|
||||
Ampersand, "&"
|
||||
Ampersand_DBL, "&&"
|
||||
Assign_Classifer, ":"
|
||||
Attribute_Open, "[["
|
||||
Attribute_Close, "]]"
|
||||
BraceCurly_Open, "{"
|
||||
BraceCurly_Close, "}"
|
||||
BraceSquare_Open, "["
|
||||
BraceSquare_Close, "]"
|
||||
Paren_Open, "("
|
||||
Paren_Close, ")"
|
||||
Comment, "__comment__"
|
||||
Comment_End, "__comment_end__"
|
||||
Comment_Start, "__comment_start__"
|
||||
Char, "__character__"
|
||||
Comma, ","
|
||||
Decl_Class, "class"
|
||||
Decl_GNU_Attribute, "__attribute__"
|
||||
Decl_MSVC_Attribute, "__declspec"
|
||||
Decl_Enum, "enum"
|
||||
Decl_Extern_Linkage, "extern"
|
||||
Decl_Friend, "friend"
|
||||
Decl_Module, "module"
|
||||
Decl_Namespace, "namespace"
|
||||
Decl_Operator, "operator"
|
||||
Decl_Struct, "struct"
|
||||
Decl_Template, "template"
|
||||
Decl_Typedef, "typedef"
|
||||
Decl_Using, "using"
|
||||
Decl_Union, "union"
|
||||
Identifier, "__identifier__"
|
||||
Module_Import, "import"
|
||||
Module_Export, "export"
|
||||
NewLine, "__new_line__"
|
||||
Number, "__number__"
|
||||
Operator, "__operator__"
|
||||
Preprocess_Hash, "#"
|
||||
Preprocess_Define, "define"
|
||||
Preprocess_Define_Param, "__define_param__"
|
||||
Preprocess_If, "if"
|
||||
Preprocess_IfDef, "ifdef"
|
||||
Preprocess_IfNotDef, "ifndef"
|
||||
Preprocess_ElIf, "elif"
|
||||
Preprocess_Else, "else"
|
||||
Preprocess_EndIf, "endif"
|
||||
Preprocess_Include, "include"
|
||||
Preprocess_Pragma, "pragma"
|
||||
Preprocess_Content, "__macro_content__"
|
||||
Preprocess_Macro_Expr, "__macro_expression__"
|
||||
Preprocess_Macro_Stmt, "__macro_statment__"
|
||||
Preprocess_Macro_Typename, "__macro_typename__"
|
||||
Preprocess_Unsupported, "__unsupported__"
|
||||
Spec_Alignas, "alignas"
|
||||
Spec_Const, "const"
|
||||
Spec_Consteval, "consteval"
|
||||
Spec_Constexpr, "constexpr"
|
||||
Spec_Constinit, "constinit"
|
||||
Spec_Explicit, "explicit"
|
||||
Spec_Extern, "extern"
|
||||
Spec_Final, "final"
|
||||
Spec_ForceInline, "forceinline"
|
||||
Spec_Global, "global"
|
||||
Spec_Inline, "inline"
|
||||
Spec_Internal_Linkage, "internal"
|
||||
Spec_LocalPersist, "local_persist"
|
||||
Spec_Mutable, "mutable"
|
||||
Spec_NeverInline, "neverinline"
|
||||
Spec_Override, "override"
|
||||
Spec_Static, "static"
|
||||
Spec_ThreadLocal, "thread_local"
|
||||
Spec_Volatile, "volatile"
|
||||
Spec_Virtual, "virtual"
|
||||
Star, "*"
|
||||
Statement_End, ";"
|
||||
StaticAssert, "static_assert"
|
||||
String, "__string__"
|
||||
Type_Typename, "typename"
|
||||
Type_Unsigned, "unsigned"
|
||||
Type_Signed, "signed"
|
||||
Type_Short, "short"
|
||||
Type_Long, "long"
|
||||
Type_bool, "bool"
|
||||
Type_char, "char"
|
||||
Type_int, "int"
|
||||
Type_double, "double"
|
||||
Type_MS_int8, "__int8"
|
||||
Type_MS_int16, "__int16"
|
||||
Type_MS_int32, "__int32"
|
||||
Type_MS_int64, "__int64"
|
||||
Type_MS_W64, "_W64"
|
||||
Varadic_Argument, "..."
|
||||
__Attributes_Start, "__attrib_start__"
|
||||
|
|
@ -32,6 +32,7 @@ GEN_NS_BEGIN
|
||||
#include "components/interface.cpp"
|
||||
#include "components/interface.upfront.cpp"
|
||||
#include "components/lexer.cpp"
|
||||
#include "components/parser_case_macros.cpp"
|
||||
#include "components/parser.cpp"
|
||||
#include "components/interface.parsing.cpp"
|
||||
#include "components/interface.untyped.cpp"
|
||||
|
@ -9,10 +9,7 @@ using namespace gen;
|
||||
|
||||
CodeBody gen_ecode( char const* path, bool use_c_definition = false )
|
||||
{
|
||||
FixedArena_32KB scratch; fixed_arena_init(& scratch);
|
||||
AllocatorInfo scratch_info = fixed_arena_allocator_info(& scratch);
|
||||
|
||||
CSV_Columns2 csv_enum = parse_csv_two_columns( scratch_info, path );
|
||||
CSV_Columns2 csv_enum = parse_csv_two_columns( _ctx->Allocator_Temp, path );
|
||||
StrBuilder enum_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(1) );
|
||||
StrBuilder to_c_str_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(1) );
|
||||
StrBuilder to_keyword_c_str_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(1) );
|
||||
@ -50,7 +47,7 @@ CodeBody gen_ecode( char const* path, bool use_c_definition = false )
|
||||
Str codetype_to_str( CodeType type )
|
||||
{
|
||||
local_persist
|
||||
Str lookup[<num>] = {
|
||||
Str lookup[] = {
|
||||
<entries>
|
||||
};
|
||||
return lookup[ type ];
|
||||
@ -60,7 +57,7 @@ CodeBody gen_ecode( char const* path, bool use_c_definition = false )
|
||||
Str codetype_to_keyword_str( CodeType type )
|
||||
{
|
||||
local_persist
|
||||
Str lookup[ <num> ] = {
|
||||
Str lookup[] = {
|
||||
<keywords>
|
||||
};
|
||||
return lookup[ type ];
|
||||
@ -93,10 +90,7 @@ CodeBody gen_ecode( char const* path, bool use_c_definition = false )
|
||||
|
||||
CodeBody gen_eoperator( char const* path, bool use_c_definition = false )
|
||||
{
|
||||
FixedArena_16KB scratch; fixed_arena_init(& scratch);
|
||||
AllocatorInfo scratch_info = fixed_arena_allocator_info(& scratch);
|
||||
|
||||
CSV_Columns2 csv_enum = parse_csv_two_columns( scratch_info, path );
|
||||
CSV_Columns2 csv_enum = parse_csv_two_columns( _ctx->Allocator_Temp, path );
|
||||
StrBuilder enum_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, 32 );
|
||||
StrBuilder to_c_str_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, 32 );
|
||||
|
||||
@ -145,7 +139,7 @@ CodeBody gen_eoperator( char const* path, bool use_c_definition = false )
|
||||
Str operator_to_str( Operator op )
|
||||
{
|
||||
local_persist
|
||||
Str lookup[<num>] = {
|
||||
Str lookup[] = {
|
||||
<entries>
|
||||
};
|
||||
|
||||
@ -178,12 +172,9 @@ CodeBody gen_eoperator( char const* path, bool use_c_definition = false )
|
||||
|
||||
CodeBody gen_especifier( char const* path, bool use_c_definition = false )
|
||||
{
|
||||
FixedArena_16KB scratch; fixed_arena_init(& scratch);
|
||||
AllocatorInfo scratch_info = fixed_arena_allocator_info(& scratch);
|
||||
|
||||
CSV_Columns2 csv_enum = parse_csv_two_columns( scratch_info, path );
|
||||
StrBuilder enum_entries = strbuilder_make_reserve( scratch_info, kilobytes(1) );
|
||||
StrBuilder to_c_str_entries = strbuilder_make_reserve( scratch_info, kilobytes(1) );
|
||||
CSV_Columns2 csv_enum = parse_csv_two_columns( _ctx->Allocator_Temp, path );
|
||||
StrBuilder enum_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(1) );
|
||||
StrBuilder to_c_str_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(1) );
|
||||
|
||||
for (usize idx = 0; idx < array_num(csv_enum.Col_1); idx++)
|
||||
{
|
||||
@ -223,7 +214,18 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false )
|
||||
inline
|
||||
bool spec_is_trailing( Specifier specifier )
|
||||
{
|
||||
return specifier > Spec_Virtual;
|
||||
switch (specifier) {
|
||||
case Spec_Const:
|
||||
case Spec_Final:
|
||||
case Spec_NoExceptions:
|
||||
case Spec_Override:
|
||||
case Spec_Pure:
|
||||
case Spec_Volatile:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
)));
|
||||
|
||||
@ -246,7 +248,7 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false )
|
||||
Str spec_to_str( Specifier type )
|
||||
{
|
||||
local_persist
|
||||
Str lookup[<num>] = {
|
||||
Str lookup[] = {
|
||||
<entries>
|
||||
};
|
||||
|
||||
@ -292,7 +294,7 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false )
|
||||
body_append(result, enum_code);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -317,29 +319,24 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false )
|
||||
|
||||
CodeBody gen_etoktype( char const* etok_path, char const* attr_path, bool use_c_definition = false )
|
||||
{
|
||||
FixedArena_64KB scratch; fixed_arena_init(& scratch);
|
||||
AllocatorInfo scratch_info = fixed_arena_allocator_info(& scratch);
|
||||
|
||||
FileContents enum_content = file_read_contents( scratch_info, file_zero_terminate, etok_path );
|
||||
|
||||
FileContents enum_content = file_read_contents( _ctx->Allocator_Temp, file_zero_terminate, etok_path );
|
||||
CSV_Object csv_enum_nodes;
|
||||
csv_parse( &csv_enum_nodes, rcast(char*, enum_content.data), scratch_info, false );
|
||||
|
||||
FileContents attrib_content = file_read_contents( scratch_info, file_zero_terminate, attr_path );
|
||||
csv_parse( &csv_enum_nodes, rcast(char*, enum_content.data), _ctx->Allocator_Temp, false );
|
||||
|
||||
FileContents attrib_content = file_read_contents( _ctx->Allocator_Temp, file_zero_terminate, attr_path );
|
||||
CSV_Object csv_attr_nodes;
|
||||
csv_parse( &csv_attr_nodes, rcast(char*, attrib_content.data), scratch_info, false );
|
||||
csv_parse( &csv_attr_nodes, rcast(char*, attrib_content.data), _ctx->Allocator_Temp, false );
|
||||
|
||||
Array<ADT_Node> enum_strs = csv_enum_nodes.nodes[0].nodes;
|
||||
Array<ADT_Node> enum_c_str_strs = csv_enum_nodes.nodes[1].nodes;
|
||||
Array<ADT_Node> attribute_strs = csv_attr_nodes.nodes[0].nodes;
|
||||
Array<ADT_Node> attribute_c_str_strs = csv_attr_nodes.nodes[1].nodes;
|
||||
|
||||
StrBuilder enum_entries = strbuilder_make_reserve( scratch_info, kilobytes(2) );
|
||||
StrBuilder to_c_str_entries = strbuilder_make_reserve( scratch_info, kilobytes(4) );
|
||||
StrBuilder attribute_entries = strbuilder_make_reserve( scratch_info, kilobytes(2) );
|
||||
StrBuilder to_c_str_attributes = strbuilder_make_reserve( scratch_info, kilobytes(4) );
|
||||
StrBuilder attribute_define_entries = strbuilder_make_reserve( scratch_info, kilobytes(4) );
|
||||
StrBuilder enum_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(2) );
|
||||
StrBuilder to_c_str_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(4) );
|
||||
StrBuilder attribute_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(2) );
|
||||
StrBuilder to_c_str_attributes = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(4) );
|
||||
StrBuilder attribute_define_entries = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(4) );
|
||||
|
||||
for (usize idx = 0; idx < array_num(enum_strs); idx++)
|
||||
{
|
||||
@ -367,7 +364,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path, bool use_c_
|
||||
|
||||
#pragma push_macro("GEN_DEFINE_ATTRIBUTE_TOKENS")
|
||||
#undef GEN_DEFINE_ATTRIBUTE_TOKENS
|
||||
CodeDefine attribute_entires_def = def_define( name(GEN_DEFINE_ATTRIBUTE_TOKENS), strbuilder_to_str(attribute_define_entries) );
|
||||
CodeDefine attribute_entires_def = def_define( name(GEN_DEFINE_ATTRIBUTE_TOKENS), MT_Statement, { {}, strbuilder_to_str(attribute_define_entries) } );
|
||||
#pragma pop_macro("GEN_DEFINE_ATTRIBUTE_TOKENS")
|
||||
|
||||
// We cannot parse this enum, it has Attribute names as enums
|
||||
@ -513,59 +510,60 @@ CodeBody gen_ast_inlines()
|
||||
#pragma pop_macro("GEN_NS")
|
||||
#pragma pop_macro("CodeInvalid")
|
||||
|
||||
CodeBody impl_code = parse_global_body( token_fmt( "typename", Str name(Code), code_impl_tmpl ));
|
||||
CodeBody impl_code_body = parse_global_body( token_fmt( "typename", Str name(CodeBody), code_impl_tmpl ));
|
||||
CodeBody impl_code_attr = parse_global_body( token_fmt( "typename", Str name(CodeAttributes), code_impl_tmpl ));
|
||||
CodeBody impl_code_cmt = parse_global_body( token_fmt( "typename", Str name(CodeComment), code_impl_tmpl ));
|
||||
CodeBody impl_code_constr = parse_global_body( token_fmt( "typename", Str name(CodeConstructor), code_impl_tmpl ));
|
||||
CodeBody impl_code_class = parse_global_body( token_fmt( "typename", Str name(CodeClass), code_impl_tmpl ));
|
||||
CodeBody impl_code_define = parse_global_body( token_fmt( "typename", Str name(CodeDefine), code_impl_tmpl ));
|
||||
CodeBody impl_code_destruct = parse_global_body( token_fmt( "typename", Str name(CodeDestructor), code_impl_tmpl ));
|
||||
CodeBody impl_code_enum = parse_global_body( token_fmt( "typename", Str name(CodeEnum), code_impl_tmpl ));
|
||||
CodeBody impl_code_exec = parse_global_body( token_fmt( "typename", Str name(CodeExec), code_impl_tmpl ));
|
||||
CodeBody impl_code_extern = parse_global_body( token_fmt( "typename", Str name(CodeExtern), code_impl_tmpl ));
|
||||
CodeBody impl_code_include = parse_global_body( token_fmt( "typename", Str name(CodeInclude), code_impl_tmpl ));
|
||||
CodeBody impl_code_friend = parse_global_body( token_fmt( "typename", Str name(CodeFriend), code_impl_tmpl ));
|
||||
CodeBody impl_code_fn = parse_global_body( token_fmt( "typename", Str name(CodeFn), code_impl_tmpl ));
|
||||
CodeBody impl_code_module = parse_global_body( token_fmt( "typename", Str name(CodeModule), code_impl_tmpl ));
|
||||
CodeBody impl_code_ns = parse_global_body( token_fmt( "typename", Str name(CodeNS), code_impl_tmpl ));
|
||||
CodeBody impl_code_op = parse_global_body( token_fmt( "typename", Str name(CodeOperator), code_impl_tmpl ));
|
||||
CodeBody impl_code_opcast = parse_global_body( token_fmt( "typename", Str name(CodeOpCast), code_impl_tmpl ));
|
||||
CodeBody impl_code_params = parse_global_body( token_fmt( "typename", Str name(CodeParams), code_impl_tmpl ));
|
||||
CodeBody impl_code_pragma = parse_global_body( token_fmt( "typename", Str name(CodePragma), code_impl_tmpl ));
|
||||
CodeBody impl_code_precond = parse_global_body( token_fmt( "typename", Str name(CodePreprocessCond), code_impl_tmpl ));
|
||||
CodeBody impl_code_specs = parse_global_body( token_fmt( "typename", Str name(CodeSpecifiers), code_impl_tmpl ));
|
||||
CodeBody impl_code_struct = parse_global_body( token_fmt( "typename", Str name(CodeStruct), code_impl_tmpl ));
|
||||
CodeBody impl_code_tmpl = parse_global_body( token_fmt( "typename", Str name(CodeTemplate), code_impl_tmpl ));
|
||||
CodeBody impl_code_type = parse_global_body( token_fmt( "typename", Str name(CodeTypename), code_impl_tmpl ));
|
||||
CodeBody impl_code_typedef = parse_global_body( token_fmt( "typename", Str name(CodeTypedef), code_impl_tmpl ));
|
||||
CodeBody impl_code_union = parse_global_body( token_fmt( "typename", Str name(CodeUnion), code_impl_tmpl ));
|
||||
CodeBody impl_code_using = parse_global_body( token_fmt( "typename", Str name(CodeUsing), code_impl_tmpl ));
|
||||
CodeBody impl_code_var = parse_global_body( token_fmt( "typename", Str name(CodeVar), 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", name(CodeBody), 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", name(CodeComment), 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", name(CodeClass), 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", name(CodeDefineParams), 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", name(CodeEnum), 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", name(CodeExtern), 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", name(CodeFriend), 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", name(CodeModule), 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", name(CodeOperator), 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", name(CodeParams), 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", name(CodePreprocessCond), 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", name(CodeStruct), 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", name(CodeTypename), 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", name(CodeUnion), 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", 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_cmt, parse_global_body( token_fmt( "typename", Str 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_define, parse_global_body( token_fmt( "typename", Str 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_enum, parse_global_body( token_fmt( "typename", Str 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_extern, parse_global_body( token_fmt( "typename", Str 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_friend, parse_global_body( token_fmt( "typename", Str 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_module, parse_global_body( token_fmt( "typename", Str 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_op, parse_global_body( token_fmt( "typename", Str 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_pragma, parse_global_body( token_fmt( "typename", Str 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_tmpl, parse_global_body( token_fmt( "typename", Str 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_typedef, parse_global_body( token_fmt( "typename", Str 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_using, parse_global_body( token_fmt( "typename", Str 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_attr, parse_global_body( token_fmt( "typename", name(Attributes), 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", name(Constructor), 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", name(Destructor), 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", name(Exec), 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", name(Include), 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", name(Fn), 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", name(NS), 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", name(OpCast), 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", name(PreprocessCond), 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", name(Typename), 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", name(Union), 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", name(Var), codetype_impl_tmpl )));
|
||||
|
||||
#pragma push_macro("forceinline")
|
||||
#undef forceinline
|
||||
@ -577,34 +575,35 @@ CodeBody gen_ast_inlines()
|
||||
);
|
||||
#pragma pop_macro("forceinline")
|
||||
|
||||
CodeBody impl_cast_body = parse_global_body( token_fmt( "typename", Str name(Body), cast_tmpl ));
|
||||
CodeBody impl_cast_attribute = parse_global_body( token_fmt( "typename", Str name(Attributes), cast_tmpl ));
|
||||
CodeBody impl_cast_cmt = parse_global_body( token_fmt( "typename", Str name(Comment), cast_tmpl ));
|
||||
CodeBody impl_cast_constr = parse_global_body( token_fmt( "typename", Str name(Constructor), cast_tmpl ));
|
||||
CodeBody impl_cast_class = parse_global_body( token_fmt( "typename", Str name(Class), cast_tmpl ));
|
||||
CodeBody impl_cast_define = parse_global_body( token_fmt( "typename", Str name(Define), cast_tmpl ));
|
||||
CodeBody impl_cast_destruct = parse_global_body( token_fmt( "typename", Str name(Destructor), cast_tmpl ));
|
||||
CodeBody impl_cast_enum = parse_global_body( token_fmt( "typename", Str name(Enum), cast_tmpl ));
|
||||
CodeBody impl_cast_exec = parse_global_body( token_fmt( "typename", Str name(Exec), cast_tmpl ));
|
||||
CodeBody impl_cast_extern = parse_global_body( token_fmt( "typename", Str name(Extern), cast_tmpl ));
|
||||
CodeBody impl_cast_friend = parse_global_body( token_fmt( "typename", Str name(Friend), cast_tmpl ));
|
||||
CodeBody impl_cast_fn = parse_global_body( token_fmt( "typename", Str name(Fn), cast_tmpl ));
|
||||
CodeBody impl_cast_include = parse_global_body( token_fmt( "typename", Str name(Include), cast_tmpl ));
|
||||
CodeBody impl_cast_module = parse_global_body( token_fmt( "typename", Str name(Module), cast_tmpl ));
|
||||
CodeBody impl_cast_ns = parse_global_body( token_fmt( "typename", Str name(NS), cast_tmpl ));
|
||||
CodeBody impl_cast_op = parse_global_body( token_fmt( "typename", Str name(Operator), cast_tmpl ));
|
||||
CodeBody impl_cast_opcast = parse_global_body( token_fmt( "typename", Str name(OpCast), cast_tmpl ));
|
||||
CodeBody impl_cast_params = parse_global_body( token_fmt( "typename", Str name(Params), cast_tmpl ));
|
||||
CodeBody impl_cast_pragma = parse_global_body( token_fmt( "typename", Str name(Pragma), cast_tmpl ));
|
||||
CodeBody impl_cast_precond = parse_global_body( token_fmt( "typename", Str name(PreprocessCond), cast_tmpl ));
|
||||
CodeBody impl_cast_specs = parse_global_body( token_fmt( "typename", Str name(Specifiers), cast_tmpl ));
|
||||
CodeBody impl_cast_struct = parse_global_body( token_fmt( "typename", Str name(Struct), cast_tmpl ));
|
||||
CodeBody impl_cast_tmpl = parse_global_body( token_fmt( "typename", Str name(Template), cast_tmpl ));
|
||||
CodeBody impl_cast_type = parse_global_body( token_fmt( "typename", Str name(Typename), cast_tmpl ));
|
||||
CodeBody impl_cast_typedef = parse_global_body( token_fmt( "typename", Str name(Typedef), cast_tmpl ));
|
||||
CodeBody impl_cast_union = parse_global_body( token_fmt( "typename", Str name(Union), cast_tmpl ));
|
||||
CodeBody impl_cast_using = parse_global_body( token_fmt( "typename", Str name(Using), cast_tmpl ));
|
||||
CodeBody impl_cast_var = parse_global_body( token_fmt( "typename", Str name(Var), 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", name(Attributes), 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", name(Constructor), 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", name(Define), 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", name(Destructor), 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", name(Exec), 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", name(Friend), 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", name(Include), 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", name(NS), 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", name(OpCast), 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", name(Pragma), 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", name(Specifiers), 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", name(Template), 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", name(Typedef), 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", name(Using), cast_tmpl ));
|
||||
CodeBody impl_cast_var = parse_global_body( token_fmt( "typename", name(Var), cast_tmpl ));
|
||||
|
||||
CodeBody result = def_global_body( args(
|
||||
def_pragma( txt("region generated code inline implementation")),
|
||||
@ -616,6 +615,7 @@ CodeBody gen_ast_inlines()
|
||||
impl_code_constr,
|
||||
impl_code_class,
|
||||
impl_code_define,
|
||||
impl_code_define_params,
|
||||
impl_code_destruct,
|
||||
impl_code_enum,
|
||||
impl_code_exec,
|
||||
@ -650,6 +650,7 @@ CodeBody gen_ast_inlines()
|
||||
impl_cast_constr,
|
||||
impl_cast_class,
|
||||
impl_cast_define,
|
||||
impl_cast_define_params,
|
||||
impl_cast_destruct,
|
||||
impl_cast_enum,
|
||||
impl_cast_exec,
|
||||
|
@ -41,7 +41,7 @@
|
||||
#undef local_persist
|
||||
|
||||
#undef bit
|
||||
#undef bitfield_is_equal
|
||||
#undef bitfield_is_set
|
||||
|
||||
#undef cast
|
||||
|
||||
@ -173,12 +173,12 @@
|
||||
|
||||
#undef GEN_DEFINE_ATTRIBUTE_TOKENS
|
||||
|
||||
#undef GEN_AST_BODY_CLASS_UNALLOWED_TYPES
|
||||
#undef GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES
|
||||
#undef GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
#undef GEN_AST_BODY_EXPORT_UNALLOWED_TYPES
|
||||
#undef GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES
|
||||
#undef GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES
|
||||
#undef GEN_AST_BODY_CLASS_UNALLOWED_TYPES_CASES
|
||||
#undef GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES_CASES
|
||||
#undef GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES_CASES
|
||||
#undef GEN_AST_BODY_EXPORT_UNALLOWED_TYPES_CASES
|
||||
#undef GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES_CASES
|
||||
#undef GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES_CASES
|
||||
|
||||
#undef GEN_GLOBAL_BUCKET_SIZE
|
||||
#undef GEN_CODEPOOL_NUM_BLOCKS
|
||||
|
@ -53,6 +53,7 @@ StrBuilder <prefix>_to_strbuilder(Code code);
|
||||
|
||||
Where the first generates strings allocated using Allocator_StringArena and the other appends an existing strings with their backed allocator.
|
||||
|
||||
Serialization of for the AST is defined for `Code` in [`ast.chpp`](../base/components/ast.cpp) with `code_to_strbuilder_ptr` & `code_to_strbuilder`.
|
||||
Serialization of for the AST is defined for `Code` in [`ast.cpp`](../base/components/ast.cpp) with `code_to_strbuilder_ptr` & `code_to_strbuilder`.
|
||||
Serializtion for the rest of the code types is within [`code_serialization.cpp`](../base/components/code_serialization.cpp).
|
||||
|
||||
Gencpp's serialization does not provide coherent formatting of the code. The user should use a formatter after serializing.
|
||||
|
@ -25,13 +25,13 @@ These are containers representing a scope body of a definition that can be of th
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Name;
|
||||
Code Front;
|
||||
Code Back;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
s32 NumEntries;
|
||||
StrCached Name;
|
||||
Code Front;
|
||||
Code Back;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
s32 NumEntries;
|
||||
```
|
||||
|
||||
The `Front` member represents the start of the link list and `Back` the end.
|
||||
@ -56,13 +56,13 @@ Represent standard or vendor specific C/C++ attributes.
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -80,13 +80,13 @@ Stores a comment.
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -109,12 +109,12 @@ CodeComment InlineCmt; // Only supported by forward declarations
|
||||
CodeAttributes Attributes;
|
||||
CodeType ParentType;
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeType Prev;
|
||||
CodeType Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
AccessSpec ParentAccess;
|
||||
```
|
||||
@ -139,16 +139,16 @@ You'll notice that only one parent type is supported only with parent access. Th
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
CodeComment InlineCmt; // Only supported by forward declarations
|
||||
Code InitializerList;
|
||||
CodeParams Params;
|
||||
Code Body;
|
||||
CodeComment InlineCmt; // Only supported by forward declarations
|
||||
Code InitializerList;
|
||||
CodeParams Params;
|
||||
Code Body;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -178,13 +178,14 @@ Represents a preprocessor define
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeDefineParams Params;
|
||||
Code Body;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -193,6 +194,28 @@ Serialization:
|
||||
#define <Name> <Content>
|
||||
```
|
||||
|
||||
## DefineParams
|
||||
|
||||
Preprocessor define's parameters.
|
||||
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Name;
|
||||
Code Last;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
s32 NumEntries;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
|
||||
```cpp
|
||||
<Name>, <Next> ...
|
||||
```
|
||||
|
||||
## Destructor
|
||||
|
||||
Fields:
|
||||
@ -201,12 +224,12 @@ Fields:
|
||||
CodeComment InlineCmt;
|
||||
CodeSpecifiers Specs;
|
||||
Code Body;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -242,8 +265,8 @@ Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
StrCached Name;
|
||||
CodeT Type;
|
||||
StrCached Name;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
```
|
||||
|
||||
@ -271,13 +294,13 @@ Will be obsolute when function body parsing is implemented.
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -286,18 +309,18 @@ Serialization:
|
||||
<Content>
|
||||
```
|
||||
|
||||
## External Linkage
|
||||
## External Linkage (Extern)
|
||||
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -314,13 +337,13 @@ extern "<Name>"
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Code Parent;
|
||||
Token* Tok;
|
||||
CodeT Type;
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Code Parent;
|
||||
Token* Tok;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -336,14 +359,14 @@ This library (until its necessary become some third-party library to do otherwis
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
CodeComment InlineCmt;
|
||||
Code Declaration;
|
||||
CodeComment InlineCmt;
|
||||
Code Declaration;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -363,12 +386,12 @@ CodeSpecifiers Specs;
|
||||
CodeType ReturnType;
|
||||
CodeParams Params;
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
```
|
||||
|
||||
@ -390,13 +413,13 @@ Serialization:
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -410,14 +433,14 @@ Serialization:
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -440,12 +463,12 @@ CodeSpecifiers Specs;
|
||||
CodeType ReturnType;
|
||||
CodeParams Params;
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
OperatorT Op;
|
||||
```
|
||||
@ -472,12 +495,12 @@ CodeComment InlineCmt;
|
||||
CodeSpecifiers Specs;
|
||||
CodeType ValueType;
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -498,17 +521,17 @@ Serialization:
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
CodeType ValueType;
|
||||
Code Macro;
|
||||
Code Value;
|
||||
Code PostNameMacro;
|
||||
StrCached Name;
|
||||
CodeParams Last;
|
||||
CodeParams Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
s32 NumEntries;
|
||||
CodeType ValueType;
|
||||
Code Macro;
|
||||
Code Value;
|
||||
Code PostNameMacro;
|
||||
StrCached Name;
|
||||
CodeParams Last;
|
||||
CodeParams Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
s32 NumEntries;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -524,13 +547,13 @@ Serialization:
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -544,13 +567,13 @@ Serialization:
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
StrCached Content;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -566,12 +589,12 @@ Fields:
|
||||
```cpp
|
||||
SpecifierT ArrSpecs[ AST_ArrSpecs_Cap ];
|
||||
CodeSpecifiers NextSpecs;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
s32 NumEntries;
|
||||
```
|
||||
|
||||
@ -586,15 +609,15 @@ Serialization:
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
CodeParams Params;
|
||||
Code Declaration;
|
||||
CodeParams Params;
|
||||
Code Declaration;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -621,8 +644,8 @@ Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
StrCached Name;
|
||||
CodeT Type;
|
||||
StrCached Name;
|
||||
CodeType Type;
|
||||
b32 IsParamPack;
|
||||
ETypenameTag TypeTag;
|
||||
```
|
||||
@ -647,16 +670,16 @@ Those (macros) don't use the underlying type field as everything was serialized
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
CodeComment InlineCmt;
|
||||
Code UnderlyingType;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
b32 IsFunction;
|
||||
CodeComment InlineCmt;
|
||||
Code UnderlyingType;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok
|
||||
Code Parent;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
b32 IsFunction;
|
||||
```
|
||||
|
||||
Serialization:
|
||||
@ -682,12 +705,12 @@ Fields:
|
||||
```cpp
|
||||
CodeAttributes Attributes;
|
||||
CodeBody Body;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
```
|
||||
|
||||
@ -708,12 +731,12 @@ Fields:
|
||||
CodeComment InlineCmt;
|
||||
CodeAttributes Attributes;
|
||||
CodeType UnderlyingType;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
```
|
||||
|
||||
@ -740,13 +763,13 @@ CodeSpecifiers Specs;
|
||||
CodeType ValueType;
|
||||
Code BitfieldSize;
|
||||
Code Value;
|
||||
StrCached Name;
|
||||
StrCached Name;
|
||||
CodeVar NextVar;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
Token* Tok;
|
||||
Code Parent;
|
||||
CodeT Type;
|
||||
CodeType Type;
|
||||
ModuleFlag ModuleFlags;
|
||||
s32 VarParenthesizedInit;
|
||||
```
|
||||
|
@ -12,7 +12,9 @@ gencpp uses a hand-written recursive descent parser. Both the lexer and parser c
|
||||
|
||||
### Lexer
|
||||
|
||||
The lex procedure does the lexical pass of content provided as a `Str` type.
|
||||
File: [lexer.cpp](../base/components/lexer.cpp)
|
||||
|
||||
The `lex` procedure does the lexical pass of content provided as a `Str` type.
|
||||
The tokens are stored (for now) in `Lexer_Tokens`.
|
||||
|
||||
Fields:
|
||||
@ -24,17 +26,15 @@ s32 Idx;
|
||||
|
||||
What token types are supported can be found in [ETokType.csv](../base/enums/ETokType.csv) you can also find the token types in [ETokType.h](../base/components/gen/etoktype.cpp) , which is the generated enum from the csv file.
|
||||
|
||||
Tokens are defined with the struct `gen::parser::Token`:
|
||||
|
||||
Fields:
|
||||
|
||||
```cpp
|
||||
char const* Text;
|
||||
sptr Length;
|
||||
TokType Type;
|
||||
s32 Line;
|
||||
s32 Column;
|
||||
u32 Flags;
|
||||
struct Token
|
||||
{
|
||||
Str Text;
|
||||
TokType Type;
|
||||
s32 Line;
|
||||
s32 Column;
|
||||
u32 Flags;
|
||||
}
|
||||
```
|
||||
|
||||
Flags is a bitfield made up of TokFlags (Token Flags):
|
||||
@ -52,25 +52,17 @@ Flags is a bitfield made up of TokFlags (Token Flags):
|
||||
* `TF_EndDefinition` : Can be interpreted as an end definition for a scope.
|
||||
* `TF_Formatting` : Considered a part of the formatting
|
||||
* `TF_Literal` : Anything considered a literal by C++.
|
||||
|
||||
I plan to replace IsAssign with a general flags field and properly keep track of all operator types instead of abstracting it away to `ETokType::Operator`.
|
||||
|
||||
Traversing the tokens is done with the following interface macros:
|
||||
|
||||
| Macro | Description |
|
||||
| --- | --- |
|
||||
| `currtok_noskip` | Get the current token without skipping whitespace |
|
||||
| `currtok` | Get the current token, skip any whitespace tokens |
|
||||
| `prevtok` | Get the previous token (does not skip whitespace) |
|
||||
| `nexttok` | Get the next token (does not skip whitespace) |
|
||||
| `eat( Token Type )` | Check to see if the current token is of the given type, if so, advance Token's index to the next token |
|
||||
| `left` | Get the number of tokens left in the token array |
|
||||
| `check_noskip` | Check to see if the current token is of the given type, without skipping whitespace |
|
||||
| `check` | Check to see if the current token is of the given type, skip any whitespace tokens |
|
||||
* `TF_Macro_Functional` : Used to indicate macro token is flagged as `MF_Functional`.
|
||||
* `TF_Macro_Expects_Body` : Used to indicate macro token is flagged as `MF_Expects_Body`.
|
||||
|
||||
### Parser
|
||||
|
||||
The parser has a limited user interface, only specific types of definitions or statements are expected to be provided by the user directly when using to construct an AST dynamically (See SOA for example). It however does attempt to provide capability to parse a full C/C++ from production codebases.
|
||||
Files:
|
||||
|
||||
* [interface.parsering.cpp](../base/components/interface.parsing.cpp)
|
||||
* [parser.cpp](../base/components/parser.cpp)
|
||||
|
||||
The parser has a limited user interface, only specific types of definitions or statements are expected to be provided by the user directly when using to construct an AST dynamically. It however does attempt to provide capability to parse a full C/C++ from production codebases.
|
||||
|
||||
Each public user interface procedure has the following format:
|
||||
|
||||
@ -89,8 +81,7 @@ Each public user interface procedure has the following format:
|
||||
}
|
||||
```
|
||||
|
||||
The most top-level parsing procedure used for C/C++ file parsing is `parse_global_body`:
|
||||
|
||||
The most top-level parsing procedure used for C/C++ file parsing is `parse_global_body`.
|
||||
It uses a helper procedure called `parse_global_nspace`.
|
||||
|
||||
Each internal procedure will have the following format:
|
||||
@ -111,126 +102,300 @@ internal
|
||||
}
|
||||
```
|
||||
|
||||
The parsing implementation contains throughut the codeapths to indicate how far their contextual AST node has been resolved.
|
||||
|
||||
Example:
|
||||
|
||||
```c
|
||||
internal
|
||||
CodeFn parser_parse_function()
|
||||
{
|
||||
push_scope();
|
||||
|
||||
Specifier specs_found[16] = { Spec_NumSpecifiers };
|
||||
s32 NumSpecifiers = 0;
|
||||
|
||||
CodeAttributes attributes = { nullptr };
|
||||
CodeSpecifiers specifiers = { nullptr };
|
||||
ModuleFlag mflags = ModuleFlag_None;
|
||||
|
||||
if ( check(Tok_Module_Export) ) {
|
||||
mflags = ModuleFlag_Export;
|
||||
eat( Tok_Module_Export );
|
||||
}
|
||||
// <export>
|
||||
|
||||
attributes = parse_attributes();
|
||||
// <export> <Attributes>
|
||||
|
||||
while ( left && tok_is_specifier(currtok) )
|
||||
{
|
||||
Specifier spec = str_to_specifier( tok_to_str(currtok) );
|
||||
|
||||
switch ( spec )
|
||||
{
|
||||
GEN_PARSER_FUNCTION_ALLOWED_SPECIFIER_CASES:
|
||||
break;
|
||||
|
||||
default:
|
||||
log_failure( "Invalid specifier %S for functon\n%SB", spec_to_str(spec), parser_to_strbuilder(_ctx->parser) );
|
||||
parser_pop(& _ctx->parser);
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( spec == Spec_Const )
|
||||
continue;
|
||||
|
||||
specs_found[NumSpecifiers] = spec;
|
||||
NumSpecifiers++;
|
||||
eat( currtok.Type );
|
||||
}
|
||||
|
||||
if ( NumSpecifiers ) {
|
||||
specifiers = def_specifiers_arr( NumSpecifiers, specs_found );
|
||||
}
|
||||
// <export> <Attributes> <Specifiers>
|
||||
|
||||
CodeTypename ret_type = parser_parse_type(parser_not_from_template, nullptr);
|
||||
if ( cast(Code, ret_type) == Code_Invalid ) {
|
||||
parser_pop(& _ctx->parser);
|
||||
return InvalidCode;
|
||||
}
|
||||
// <export> <Attributes> <Specifiers> <ReturnType>
|
||||
|
||||
Token name = parse_identifier(nullptr);
|
||||
_ctx->parser.Scope->Name = name.Text;
|
||||
if ( ! tok_is_valid(name) ) {
|
||||
parser_pop(& _ctx->parser);
|
||||
return InvalidCode;
|
||||
}
|
||||
// <export> <Attributes> <Specifiers> <ReturnType> <Name>
|
||||
|
||||
CodeFn result = parse_function_after_name( mflags, attributes, specifiers, ret_type, name );
|
||||
// <export> <Attributes> <Specifiers> <ReturnType> <Name> ...
|
||||
|
||||
parser_pop(& _ctx->parser);
|
||||
return result;
|
||||
}
|
||||
```
|
||||
|
||||
In the above `parse_function` implementation:
|
||||
|
||||
`// <intutive expression of AST component> ...`
|
||||
|
||||
Will be conventionlly used where by that point in time for the codepath: `<intutive expression of AST component>` should be resolved for the AST.
|
||||
|
||||
## Outline of parsing codepaths
|
||||
|
||||
Below is an outline of the general alogirithim used for these internal procedures. The intention is to provide a basic briefing to aid the user in traversing the actual code definitions. These appear in the same order as they are in the `parser.cpp` file
|
||||
|
||||
***NOTE: This is still heavily in an alpha state. A large swaph of this can change, make sure these docs are up to date before considering them 1:1 with the repo commit your considering.***
|
||||
|
||||
## `parse_array_decl`
|
||||
|
||||
1. Check if its an array declaration with no expression.
|
||||
1. Consume and return empty array declaration
|
||||
2. Opening square bracket
|
||||
3. Consume expression
|
||||
4. Closing square bracket
|
||||
5. If adjacent opening bracket
|
||||
1. Repeat array declaration parse until no brackets remain
|
||||
|
||||
## `parse_assignment_expression`
|
||||
|
||||
1. Eat the assignment operator
|
||||
2. Make sure there is content or at least an end statement after.
|
||||
3. Flatten the assignment expression to an untyped Code string.
|
||||
1. Push parser scope
|
||||
2. Check for empty array `[]`
|
||||
1. Return untyped string with single space if found
|
||||
3. Check for opening bracket `[`
|
||||
1. Validate parser not at EOF
|
||||
2. Reject empty array expression
|
||||
3. Capture expression tokens until closing bracket
|
||||
4. Calculate expression span length
|
||||
5. Convert to untyped string
|
||||
4. Validate and consume closing bracket `]`
|
||||
5. Handle multi-dimensional case
|
||||
1. If adjacent `[` detected, recursively parse
|
||||
2. Link array expressions via Next pointer
|
||||
6. Pop parser scope
|
||||
7. Return array expression or NullCode on failure
|
||||
|
||||
## `parse_attributes`
|
||||
|
||||
1. Check for standard attribute
|
||||
2. Check for GNU attribute
|
||||
3. Check for MSVC attribute
|
||||
4. Check for a token registered as an attribute
|
||||
a. Check and grab the arguments of a token registered of an attribute if it has any.
|
||||
5. Repeat for chained attributes. Flatten them to a single attribute AST node.
|
||||
1. Push parser scope and initialize tracking
|
||||
1. Store initial token position
|
||||
2. Initialize length counter
|
||||
2. Process attributes while available
|
||||
1. Handle C++ style attributes `[[...]]`
|
||||
1. Consume opening `[[`
|
||||
2. Capture content until closing `]]`
|
||||
3. Calculate attribute span length
|
||||
2. Handle GNU style `__attribute__((...))`
|
||||
1. Consume `__attribute__` keyword and opening `((`
|
||||
2. Capture content until closing `))`
|
||||
3. Calculate attribute span length
|
||||
3. Handle MSVC style `__declspec(...)`
|
||||
1. Consume `__declspec` and opening `(`
|
||||
2. Capture content until closing `)`
|
||||
3. Calculate attribute span length
|
||||
4. Handle macro-style attributes
|
||||
1. Consume attribute token
|
||||
2. If followed by parentheses
|
||||
1. Handle nested parentheses tracking
|
||||
2. Capture content maintaining paren balance
|
||||
3. Calculate attribute span length
|
||||
3. Generate attribute code if content captured
|
||||
1. Create attribute text span from start position and length
|
||||
2. Strip formatting from attribute text
|
||||
3. Construct Code node
|
||||
1. Set type to `CT_PlatformAttributes`
|
||||
2. Cache and set Name and Content fields
|
||||
4. Return as CodeAttributes
|
||||
4. Pop parser scope
|
||||
5. Return NullCode if no attributes found
|
||||
|
||||
## `parse_class_struct`
|
||||
|
||||
1. Check for export module specifier
|
||||
2. class or struct keyword
|
||||
3. `parse_attributes`
|
||||
4. If identifier : `parse_identifier`
|
||||
5. Parse inherited parent or interfaces
|
||||
6. If opening curly brace : `parse_class_struct_body`
|
||||
7. If not an inplace definition
|
||||
1. End statement
|
||||
2. Check for inline comment
|
||||
1. Validate token type is class or struct
|
||||
1. Return InvalidCode if validation fails
|
||||
2. Initialize class/struct metadata
|
||||
1. Access specifier (default)
|
||||
2. Parent class/struct reference
|
||||
3. Class/struct body
|
||||
4. Attributes
|
||||
5. Module flags
|
||||
3. Parse module export flag if present
|
||||
1. Set ModuleFlag_Export
|
||||
2. Consume export token
|
||||
4. Consume class/struct token
|
||||
5. Parse attributes via `parse_attributes()`
|
||||
6. Parse class/struct identifier
|
||||
1. Update parser scope name
|
||||
7. Initialize interface array (4KB arena)
|
||||
8. Parse inheritance/implementation
|
||||
1. If classifier token (`:`) present
|
||||
1. Parse access specifier if exists
|
||||
2. Parse parent class/struct name
|
||||
3. Parse additional interfaces
|
||||
1. Separated by commas
|
||||
2. Optional access specifiers
|
||||
3. Store in interface array
|
||||
9. Parse class body if present
|
||||
1. Triggered by opening brace
|
||||
2. Parse via `parse_class_struct_body`
|
||||
10. Handle statement termination
|
||||
1. Skip for inplace definitions
|
||||
2. Consume semicolon
|
||||
3. Parse inline comment if present
|
||||
11. Construct result node
|
||||
1. Create class definition if Tok_Decl_Class
|
||||
2. Create struct definition if Tok_Decl_Struct
|
||||
3. Attach inline comment if exists
|
||||
12. Cleanup interface array and return result
|
||||
|
||||
## `parse_class_struct_body`
|
||||
|
||||
1. Opening curly brace
|
||||
2. Parse the body (Possible options):
|
||||
1. Ignore dangling end statements
|
||||
2. Newline : ast constant
|
||||
3. Comment : `parse_comment`
|
||||
4. Access_Public : ast constant
|
||||
5. Access_Protected : ast constant
|
||||
6. Access_Private : ast constant
|
||||
7. Decl_Class : `parse_complicated_definition`
|
||||
8. Decl_Enum : `parse_complicated_definition`
|
||||
9. Decl_Friend : `parse_friend`
|
||||
10. Decl_Operator : `parse_operator_cast`
|
||||
11. Decl_Struct : `parse_complicated_definition`
|
||||
12. Decl_Template : `parse_template`
|
||||
13. Decl_Typedef : `parse_typedef`
|
||||
14. Decl_Union : `parse_complicated_definition`
|
||||
15. Decl_Using : `parse_using`
|
||||
16. Operator == '~'
|
||||
1. `parse_destructor`
|
||||
17. Preprocess_Define : `parse_define`
|
||||
18. Preprocess_Include : `parse_include`
|
||||
19. Preprocess_Conditional (if, ifdef, ifndef, elif, else, endif) : `parse_preprocess_cond` or else/endif ast constant
|
||||
20. Preprocess_Macro : `parse_simple_preprocess`
|
||||
21. Preprocess_Pragma : `parse_pragma`
|
||||
22. Preprocess_Unsupported : `parse_simple_preprocess`
|
||||
23. StaticAssert : `parse_static_assert`
|
||||
24. The following compound into a resolved definition or declaration:
|
||||
1. Attributes (Standard, GNU, MSVC) : `parse_attributes`
|
||||
2. Specifiers (consteval, constexpr, constinit, explicit, forceinline, inline, mutable, neverinline, static, volatile, virtual)
|
||||
3. Possible Destructor : `parse_destructor`
|
||||
4. Possible User defined operator cast : `parse_operator_cast`
|
||||
5. Possible Constructor : `parse_constructor`
|
||||
6. Something that has the following: (identifier, const, unsigned, signed, short, long, bool, char, int, double)
|
||||
1. Possible Constructor `parse_constructor`
|
||||
2. Possible Operator, Function, or varaible : `parse_operator_function_or_variable`
|
||||
25. Something completely unknown (will just make untyped...) : `parse_untyped`
|
||||
1. Initialize scope and body structure
|
||||
1. Push parser scope
|
||||
2. Consume opening brace
|
||||
3. Create code node with `CT_Class_Body` or `CT_Struct_Body` type
|
||||
2. Parse body members while not at closing brace
|
||||
1. Initialize member parsing state
|
||||
1. Code member (InvalidCode)
|
||||
2. Attributes (null)
|
||||
3. Specifiers (null)
|
||||
4. Function expectation flag
|
||||
2. Handle preprocessor hash if present
|
||||
3. Process member by token type in switch statement
|
||||
1. Statement termination - warn and skip
|
||||
2. Newline - format member
|
||||
3. Comments - parse comment
|
||||
4. Access specifiers - `public/protected/private`
|
||||
5. Declarations - `class/enum/struct/union/typedef/using`
|
||||
6. Operators - `destructors/casts`
|
||||
7. Preprocessor directives - `define/include/conditionals/pragmas`
|
||||
8. Preprocessor statement macros
|
||||
9. Report naked preprocossor expression macros detected as an error.
|
||||
10. Static assertions
|
||||
11. Attributes and specifiers
|
||||
1. Parse attributes
|
||||
2. Parse valid member specifiers
|
||||
3. Handle `attribute-specifier-attribute` case
|
||||
12. Identifiers and types
|
||||
1. Check for constructors
|
||||
2. Parse `operator/function/variable`
|
||||
13. Default - capture unknown content until closing brace
|
||||
4. Validate member parsing
|
||||
1. Return InvalidCode if member invalid
|
||||
2. Append valid member to body
|
||||
3. Finalize body
|
||||
1. Consume closing brace
|
||||
2. Pop parser scope
|
||||
3. Return completed CodeBody
|
||||
|
||||
## `parse_comment`
|
||||
|
||||
1. Just wrap the token into a cached string ( the lexer did the processing )
|
||||
|
||||
## `parse_compilcated_definition`
|
||||
## `parse_complicated_definition`
|
||||
|
||||
This is a helper function used by the following functions to help resolve a declaration or definition:
|
||||
1. Initialize parsing context
|
||||
1. Push scope
|
||||
2. Set inplace flag false
|
||||
3. Get token array reference
|
||||
2. Scan ahead for statement termination
|
||||
1. Track brace nesting level
|
||||
2. Find first semicolon at level 0
|
||||
3. Handle declaration variants
|
||||
1. Forward declaration case
|
||||
1. Check if only 2 tokens before semicolon
|
||||
2. Parse via `parse_forward_or_definition`
|
||||
2. Function with trailing specifiers
|
||||
1. Identify trailing specifiers
|
||||
2. Check for function pattern
|
||||
3. Parse as `operator/function/variable`
|
||||
4. Return `InvalidCode` if pattern invalid
|
||||
3. Identifier-based declarations
|
||||
1. Check identifier patterns
|
||||
1. Inplace definition `{...} id;`
|
||||
2. Namespace type variable `which id id;`
|
||||
3. Enum with class qualifier
|
||||
4. `Pointer/reference` types
|
||||
2. Parse as `operator/function/variable` if valid
|
||||
3. Return `InvalidCode` if pattern invalid
|
||||
4. Basic type declarations
|
||||
1. Validate enum class pattern
|
||||
2. Parse via `parser_parse_enum`
|
||||
3. Return `InvalidCode` if invalid
|
||||
5. Direct definitions
|
||||
1. Handle closing brace - `parse_forward_or_definition`
|
||||
2. Handle array definitions - `parse_operator_function_or_variable`
|
||||
3. Return InvalidCode for unknown patterns
|
||||
|
||||
* `parse_class_struct_body`
|
||||
* `parse_global_nspace`
|
||||
* `parse_union`
|
||||
## `parse_assignment_expression`
|
||||
|
||||
A portion of the code in `parse_typedef` is very similar to this as both have to resolve a similar issue.
|
||||
|
||||
1. Look ahead to the termination token (End statement)
|
||||
2. Check to see if it fits the pattern for a forward declare
|
||||
3. If the previous token was an identifier ( `token[-1]` ):
|
||||
1. Look back one more token : `[-2]`
|
||||
2. If the token has a closing brace its an inplace definition
|
||||
3. If the `token[-2]` is an identifier & `token[-3]` is the declaration type, its a variable using a namespaced type.
|
||||
4. If the `token[-2]` is an indirection, then its a variable using a namespaced/forwarded type.
|
||||
5. If the `token[-2]` is an assign classifier, and the starting tokens were the which type with possible `class` token after, its an enum forward declaration.
|
||||
6. If any of the above is the case, `parse_operator_function_or_variable`
|
||||
4. If the `token[2]` is a vendor fundamental type (builtin) then it is an enum forward declaration.
|
||||
5. If the previous token was a closing curly brace, its a definition : `parse_forward_or_definition`
|
||||
6. If the previous token was a closing square brace, its an array definition : `parse_operator_function_or_variable`
|
||||
|
||||
## `parse_define`
|
||||
|
||||
1. Define directive
|
||||
2. Get identifier
|
||||
3. Get Content (Optional)
|
||||
1. Initialize expression parsing
|
||||
1. Null expression pointer
|
||||
2. Consume assignment operator token
|
||||
3. Capture initial expression token
|
||||
2. Validate expression presence
|
||||
1. Check for immediate termination
|
||||
2. Return `InvalidCode` if missing expression
|
||||
3. Parse balanced expression
|
||||
1. Track nesting level for
|
||||
1. Curly braces
|
||||
2. Parentheses
|
||||
2. Continue until
|
||||
1. End of input, or
|
||||
2. Statement terminator, or
|
||||
3. Unnested comma
|
||||
3. Consume tokens sequentially
|
||||
4. Generate expression code
|
||||
1. Calculate expression span length
|
||||
2. Convert to untyped string
|
||||
3. Return expression node
|
||||
|
||||
## `parse_forward_or_definition`
|
||||
|
||||
* Parse any of the following for either a forward declaration or definition:
|
||||
1. Decl_Class : `parse_class`
|
||||
2. Decl_Enum : `parse_enum`
|
||||
3. Decl_Struct : `parse_struct`
|
||||
4. Decl_Union : `parse_union`
|
||||
1. Declaration type routing
|
||||
1. Class (`Tok_Decl_Class`) -> `parser_parse_class`
|
||||
2. Enum (`Tok_Decl_Enum`) -> `parser_parse_enum`
|
||||
3. Struct (`Tok_Decl_Struct`) -> `parser_parse_struct`
|
||||
4. Union (`Tok_Decl_Union`) -> `parser_parse_union`
|
||||
2. Error handling
|
||||
1. Return `InvalidCode` for unsupported token types
|
||||
2. Log failure with parser context
|
||||
|
||||
`is_inplace` flag propagates to specialized codepaths to maintain parsing context.
|
||||
|
||||
## `parse_function_after_name`
|
||||
|
||||
@ -239,80 +404,191 @@ after its been made ceratin that the type of declaration or definition is indeed
|
||||
|
||||
By the point this function is called the following are known : export module flag, attributes, specifiers, return type, & name
|
||||
|
||||
1. `parse_parameters`
|
||||
2. parse postfix specifiers (we do not check if the specifier here is correct or not to be here... yet)
|
||||
3. If there is a body : `parse_body`
|
||||
4. Otherwise :
|
||||
1. Statment end
|
||||
2. Check for inline comment
|
||||
1. Parameter parsing
|
||||
1. Push scope
|
||||
2. Parse parameter list with parentheses
|
||||
2. Post-parameter specifier processing
|
||||
1. Collect trailing specifiers
|
||||
2. Initialize or append to existing specifiers
|
||||
3. Parse function termination
|
||||
1. Function body case
|
||||
1. Parse body if open brace found
|
||||
2. Validate body type (`CT_Function_Body` or `CT_Untyped`)
|
||||
2. Pure virtual case
|
||||
1. Handle "`= 0`" syntax
|
||||
2. Append pure specifier
|
||||
3. Forward declaration case
|
||||
1. Consume statement terminator
|
||||
4. Handle inline comments for all cases
|
||||
4. Construct function node
|
||||
1. Strip whitespace from name
|
||||
2. Initialize `CodeFn` with base properties
|
||||
1. Name (cached, stripped)
|
||||
2. Module flags
|
||||
3. Set node type
|
||||
1. `CT_Function` if body present
|
||||
2. `CT_Function_Fwd` if declaration only
|
||||
4. Attach components
|
||||
1. Attributes if present
|
||||
2. Specifiers if present
|
||||
3. Return type
|
||||
4. Parameters if present
|
||||
5. Inline comment if present
|
||||
5. Cleanup and return
|
||||
1. Pop scope
|
||||
2. Return completed function node
|
||||
|
||||
## `parse_function_body`
|
||||
|
||||
Currently there is no actual parsing of the function body. Any content with the braces is shoved into an execution AST node.
|
||||
In the future statements and expressions will be parsed.
|
||||
|
||||
1. Open curly brace
|
||||
2. Grab all tokens between the brace and the closing brace, shove them in a execution AST node.
|
||||
3. Closing curly brace
|
||||
1. Initialize body parsing
|
||||
1. Push scope
|
||||
2. Consume opening brace
|
||||
3. Create CodeBody with CT_Function_Body type
|
||||
2. Capture function content
|
||||
1. Record start token position
|
||||
2. Track brace nesting level
|
||||
3. Consume tokens while
|
||||
1. Input remains AND
|
||||
2. Not at unmatched closing brace
|
||||
4. Update level counters
|
||||
1. Increment on open brace
|
||||
2. Decrement on closing brace when level > 0
|
||||
3. Process captured content
|
||||
1. Calculate content length via pointer arithmetic
|
||||
2. Create execution block if content exists
|
||||
1. Construct string span from start position and length
|
||||
2. Wrap in execution node
|
||||
3. Append to body
|
||||
4. Finalize
|
||||
1. Consume closing brace
|
||||
2. Pop scope
|
||||
3. Return cast body node
|
||||
|
||||
## `parse_global_nspace`
|
||||
|
||||
1. Make sure this is being called for a valid type (namespace, global body, export body, linkage body)
|
||||
2. If its not a global body, consume the opening curly brace
|
||||
3. Parse the body (Possible options):
|
||||
1. Ignore dangling end statements
|
||||
2. NewLine : ast constant
|
||||
3. Comment : `parse_comment`
|
||||
4. Decl_Cass : `parse_complicated_definition`
|
||||
5. Decl_Enum : `parse_complicated_definition`
|
||||
6. Decl_Extern_Linkage : `parse_extern_link`
|
||||
7. Decl_Namespace : `parse_namespace`
|
||||
8. Decl_Struct : `parse_complicated_definition`
|
||||
9. Decl_Template : `parse_template`
|
||||
10. Decl_Typedef : `parse_typedef`
|
||||
11. Decl_Union : `parse_complicated_definition`
|
||||
12. Decl_Using : `parse_using`
|
||||
13. Preprocess_Define : `parse_define`
|
||||
14. Preprocess_Include : `parse_include`
|
||||
15. Preprocess_If, IfDef, IfNotDef, Elif : `parse_preprocess_cond`
|
||||
16. Preprocess_Else : ast constant
|
||||
17. Preprocess_Endif : ast constant
|
||||
18. Preprocess_Macro : `parse_simple_preprocess`
|
||||
19. Preprocess_Pragma : `parse_pragma`
|
||||
20. Preprocess_Unsupported : `parse_simple_preprocess`
|
||||
21. StaticAssert : `parse_static_assert`
|
||||
22. Module_Export : `parse_export_body`
|
||||
23. Module_Import : NOT_IMPLEMENTED
|
||||
24. The following compound into a resolved definition or declaration:
|
||||
1. Attributes ( Standard, GNU, MSVC, Macro ) : `parse_attributes`
|
||||
2. Specifiers ( consteval, constexpr, constinit, extern, forceinline, global, inline, internal_linkage, neverinline, static )
|
||||
3. Is either ( identifier, const specifier, long, short, signed, unsigned, bool, char, double, int)
|
||||
1. Attempt to parse as construtor or destructor : `parse_global_nspace_constructor_destructor`
|
||||
2. If its an operator cast (definition outside class) : `parse_operator_cast`
|
||||
3. Its an operator, function, or varaible : `parse_operator_function_or_varaible`
|
||||
4. If its not a global body, consume the closing curly brace
|
||||
1. State initialization
|
||||
1. Push parser scope
|
||||
2. Validate namespace type (Global, Namespace, Export, Extern Linkage)
|
||||
3. Consume opening brace for non-global scopes
|
||||
4. Initialize `CodeBody` with specified body type: `which`
|
||||
2. Member parsing loop (while not at closing brace)
|
||||
1. Reset parse state
|
||||
* Member code
|
||||
* Attributes
|
||||
* Specifiers
|
||||
* Function expectation flag
|
||||
2. Member type handling
|
||||
1. Declarations
|
||||
* `Class/Struct/Union/Enum` via `parse_complicated_definition`
|
||||
* `Template/Typedef/Using` via dedicated parsers
|
||||
* `Namespace/Export/Extern` declarations
|
||||
2. Preprocessor directivess
|
||||
* Include/Define
|
||||
* Conditionals `(if / ifdef / ifndef / elif / else / endif)`
|
||||
* Pragmas
|
||||
* Preprocessor statement macros
|
||||
* Report naked preprocossor expression macros detected as an error.
|
||||
3. Comments/Formatting
|
||||
* Newlines
|
||||
* Comments
|
||||
4. Static assertions
|
||||
3. Attributes and specifiers
|
||||
1. Parse attributes if present
|
||||
2. Collect valid specifiers (max 16)
|
||||
3. Handle `consteval` for function expectation
|
||||
4. Identifier resolution
|
||||
1. Check `constructor/destructor` implementation
|
||||
2. Look ahead for user defined operator implementation outside of class
|
||||
3. Default to `operator/function/variable` parse
|
||||
3. Member validation/storage
|
||||
1. Validate parsed member
|
||||
2. Append to body if valid
|
||||
3. Return `InvalidCode` on parse failure
|
||||
4. Scope finalization
|
||||
1. Consume closing brace for non-global scopes
|
||||
2. Pop parser scope
|
||||
3. Return completed body
|
||||
|
||||
## `parse_global_nspace_constructor_destructor`
|
||||
|
||||
1. Look ahead for the start of the arguments for a possible constructor/destructor
|
||||
2. Go back past the identifier
|
||||
3. Check to see if its a destructor by checking for the `~`
|
||||
4. Continue the next token should be a `::`
|
||||
5. Determine if the next valid identifier (ignoring possible template parameters) is the same as the first identifier of the function.
|
||||
6. If it is we have either a constructor or destructor so parse using their respective functions (`parse_constructor`, `parse_destructor`).
|
||||
1. Forward Token Analysis
|
||||
1. Scan for parameter list opening parenthesis
|
||||
2. Template Expression Handling
|
||||
* Track template nesting depth
|
||||
* Account for nested parentheses within templates
|
||||
* Skip until template closure or parameter start
|
||||
|
||||
```cpp
|
||||
// Valid patterns:
|
||||
ClassName :: ClassName(...)
|
||||
ClassName :: ~ClassName(...)
|
||||
ClassName< T ... > :: ClassName(...)
|
||||
```
|
||||
|
||||
2. Constructor/Destructor Identification
|
||||
1. Token Validation Sequence
|
||||
* Verify identifier preceding parameters
|
||||
* Check for destructor indicator (`~`)
|
||||
* Validate scope resolution operator (`::`)
|
||||
2. Left-side Token Analysis
|
||||
* Process nested template expressions
|
||||
* Maintain template/capture level tracking
|
||||
* Locate matching identifier token
|
||||
3. Parser Resolution
|
||||
1. Name Pattern Validation
|
||||
* Compare identifier tokens for exact match
|
||||
2. Specialized Parsing
|
||||
* Route to `parser_parse_destructor` for '~' prefix
|
||||
* Route to `parser_parse_constructor` for direct match
|
||||
3. Apply specifiers to resulting node
|
||||
4. Return result (`NullCode` on pattern mismatch)
|
||||
|
||||
### Implementation Constraints
|
||||
|
||||
* Cannot definitively distinguish nested namespaces with identical names
|
||||
* Return type detection requires parser enhancement
|
||||
* Template parameter validation is syntax-based only
|
||||
* Future enhancement: Implement type parsing with rollback capability
|
||||
|
||||
## `parse_identifier`
|
||||
|
||||
This is going to get heavily changed down the line to have a more broken down "identifier expression" so that the qualifier, template args, etc, can be distinguished between the targeted identifier.
|
||||
The function can parse all of them, however the AST node compresses them all into a string.
|
||||
|
||||
1. Consume first identifier
|
||||
2. `parse_template_args`
|
||||
3. While there is a static symbol accessor ( `::` )
|
||||
1. Consume `::`
|
||||
2. Consume member identifier
|
||||
3. `parse_template args` (for member identifier)
|
||||
4. If a `~` is encounted and the scope is for a destructor's identifier, do not consume it and return with what parsed.
|
||||
1. Initialize identifier context
|
||||
1. Push parser scope
|
||||
2. Capture initial token as name
|
||||
3. Set scope name from token text
|
||||
2. Process initial identifier component
|
||||
1. Consume identifier token
|
||||
2. Parse template arguments if present
|
||||
3. Handle qualified identifiers (loop while `::` found)
|
||||
1. Consume static access operator
|
||||
2. Validate token sequence:
|
||||
1. Handle destructor operator (`~`)
|
||||
* Validate destructor parsing context
|
||||
* Update name span if valid
|
||||
* Return invalid on context mismatch
|
||||
2. Process member function pointer (`*`)
|
||||
* Set possible_member_function flag if context allows
|
||||
* Return invalid if pointer unexpected
|
||||
3. Verify identifier token follows
|
||||
3. Update identifier span
|
||||
1. Extend name length to include new qualifier
|
||||
2. Consume identifier token
|
||||
3. Parse additional template arguments
|
||||
4. Return completed identifier token
|
||||
|
||||
Technical notes:
|
||||
|
||||
* Current implementation treats identifier as single token span
|
||||
* TODO: Refactor to AST-based identifier representation for:
|
||||
* Distinct qualifier/symbol tracking
|
||||
* Improved semantic analysis capabilities
|
||||
* Better support for nested symbol resolution
|
||||
|
||||
## `parse_include`
|
||||
|
||||
@ -323,16 +599,45 @@ The function can parse all of them, however the AST node compresses them all int
|
||||
|
||||
This is needed as a operator defintion is not easily resolvable early on, as such this function handles resolving a operator after its been made ceratin that the type of declaration or definition is indeed for a operator signature.
|
||||
|
||||
By the point this function is called the following are known : export module flag, attributes, specifiers, return type
|
||||
By the point this function is called the following are known : export module flag, attributes, specifiers, and return type
|
||||
|
||||
1. If there is any qualifiers for the operator, parse them
|
||||
2. Consume operator keyword
|
||||
3. Determine the operator type (This will be offloaded to the lexer moreso than how it is now) & consume
|
||||
4. `parse_params`
|
||||
5. If there is no parameters this is operator is a member of pointer if its symbols is a *.
|
||||
6. Parse postfix specifiers
|
||||
7. If there is a opening curly brace, `parse function_body`
|
||||
8. Otherwise: consume end statement, check for inline comment.
|
||||
1. Initialize operator context
|
||||
1. Push scope
|
||||
2. Parse qualified namespace identifier
|
||||
3. Consume `operator` keyword
|
||||
2. Operator identification
|
||||
1. Validate operator token presence
|
||||
2. Set scope name from operator token
|
||||
3. Map operator token to internal operator enum:
|
||||
* Arithmetic: `+, -, *, /, %`
|
||||
* Assignment: `+=, -=, *=, /=, %=, =`
|
||||
* Bitwise: `&, |, ^, ~, >>`
|
||||
* Logical: `&&, ||, !, ==`
|
||||
* Comparison: `<, >, <=, >=`
|
||||
* Member access: `->, ->*`
|
||||
* Special: `(), [], new, delete`
|
||||
4. Handle array variants for new/delete
|
||||
3. Parameter and specifier processing
|
||||
1. Parse parameter list
|
||||
2. Handle multiply/member-pointer ambiguity
|
||||
3. Collect trailing specifiers
|
||||
4. Merge with existing specifiers
|
||||
4. Function body handling
|
||||
1. Parse implementation if present
|
||||
2. Otherwise consume statement terminator
|
||||
3. Capture inline comments
|
||||
5. Result construction
|
||||
1. Create operator node with:
|
||||
* Operator type
|
||||
* Namespace qualification
|
||||
* Parameters
|
||||
* Return type
|
||||
* Implementation body
|
||||
* Specifiers
|
||||
* Attributes
|
||||
* Module flags
|
||||
2. Attach inline comments
|
||||
6. Pop scope
|
||||
|
||||
## `parse_operator_function_or_variable`
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
# Parsing
|
||||
|
||||
The library features a naive single-pass parser tailored for only what the library needs to construct the supported syntax of C++ into its AST for *"front-end"* meta-programming purposes.
|
||||
The library features a naive single-pass parser, tailored for only what the library needs; for construction of C++ code into gencpp's AST for *"front-end"* meta-programming purposes.
|
||||
|
||||
This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around ~7000 loc. I hope to keep it under 10k loc worst case.
|
||||
This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around ~7000 loc. I hope to keep it under 10-15k loc worst case.
|
||||
|
||||
You can think of this parser as *frontend parser* vs a *semantic parser*. Its intuitively similar to WYSIWYG. What you ***precerive*** as the syntax from the user-side before the compiler gets a hold of it, is what you get.
|
||||
|
||||
@ -17,6 +17,7 @@ User exposed interface:
|
||||
```cpp
|
||||
CodeClass parse_class ( Str class_def );
|
||||
CodeConstructor parse_constructor ( Str constructor_def );
|
||||
CodeDefine parse_define ( Str define_def );
|
||||
CodeDestructor parse_destructor ( Str destructor_def );
|
||||
CodeEnum parse_enum ( Str enum_def );
|
||||
CodeBody parse_export_body ( Str export_def );
|
||||
@ -53,38 +54,98 @@ The keywords supported for the preprocessor are:
|
||||
* endif
|
||||
* pragma
|
||||
|
||||
Each directive `#` line is considered one preproecessor unit, and will be treated as one Preprocessor AST.
|
||||
Each directive `#` line is considered one preproecessor unit, and will be treated as one Preprocessor AST node.
|
||||
If a directive is used with an unsupported keyword its will be processed as an untyped AST.
|
||||
|
||||
The preprocessor lines are stored as members of their associated scope they are parsed within. ( Global, Namespace, Class/Struct )
|
||||
***Again (Its not standard): These ASTs will be considered members or entries of braced scope they reside within***
|
||||
The preprocessor lines are stored as members of their associated scope they are parsed within ( Global, Namespace, Class/Struct ).
|
||||
***Again: These ASTs will be considered members or entries of braced scope they reside within***
|
||||
|
||||
Any preprocessor definition abuse that changes the syntax of the core language is unsupported and will fail to parse if not kept within an execution scope (function body, or expression assignment).
|
||||
Exceptions:
|
||||
|
||||
* function signatures are allowed for a preprocessed macro: `neverinline MACRO() { ... }`
|
||||
* varaible definitions are allowed for a preprocessed macro `extern MACRO();`
|
||||
* function definitions are allowed for a preprocessed macro: `neverinline MACRO() { ... }`
|
||||
* Disable with: `#define GEN_PARSER_DISABLE_MACRO_FUNCTION_SIGNATURES`
|
||||
* typedefs allow for a preprocessed macro: `typedef MACRO();`
|
||||
* Disable with: `#define GEN_PARSER_DISABLE_MACRO_TYPEDEF`
|
||||
* Macros can behave as typenames
|
||||
* There is some macro support in paramters for functions or templates *(Specifically added to support parsing Unreal Engine source)*.
|
||||
* There is some macro support in parameters for functions or templates *(Specifically added to support parsing Unreal Engine source)*.
|
||||
|
||||
*(Exceptions are added on an on-demand basis)*
|
||||
*(See functions `parse_operator_function_or_variable` and `parse_typedef` )*
|
||||
|
||||
Adding your own exceptions is possible by simply modifying the parser to allow for the syntax you need.
|
||||
|
||||
*Note: You could interpret this strictness as a feature. This would allow the user to see if their codebase or a third-party's codebase some some egregious preprocessor abuse.*
|
||||
*Note: You could interpret this strictness as a feature. This would allow the user to see if their codebase or a third-party's codebase contains some egregious preprocessor abuse.*
|
||||
|
||||
If a macro is not defined withint e scope of parsing a set of files, it can be defined beforehand by:
|
||||
Macros used within a file should be registered by the user before parsing. This can be done two ways:
|
||||
|
||||
* Appending the [`PreprocessorDefines`](https://github.com/Ed94/gencpp/blob/a18b5b97aa5cfd20242065cbf53462a623cd18fa/base/components/header_end.hpp#L137) array.
|
||||
* For functional macros a "(" just needs to be added after the name like: `<name>(` so that it will tokenize its arguments as part of the token during lexing.
|
||||
* Defining a CodeDefine using `def_define`. The definition will be processed by the interface for user into `PreprocessorDefines`.
|
||||
* This can be prevented by setting the optional prameter `dont_append_preprocess_defines`.
|
||||
1. The register macro interface within [interface.hpp](../base/components/interface.hpp).
|
||||
2. Using `def_define` to create a CodeDefine and making sure to not set `opts.dont_register_to_preprocess_macros` to `true`.
|
||||
|
||||
The lexing and parsing takes shortcuts from whats expected in the standard.
|
||||
## Registering macros
|
||||
|
||||
While the registeration of macros in the meta-program's side for parsing can be considered tedius, its necessary for the parser to accurately resolve the macros intent in one pass (and it provides some hygenics by verifying that they are used as intended).
|
||||
|
||||
The following can be used to register a macro:
|
||||
|
||||
```c
|
||||
GEN_API void register_macro( Macro macro );
|
||||
GEN_API void register_macros( s32 num, ... );
|
||||
GEN_API void register_macros_arr( s32 num, Macro* macros );
|
||||
```
|
||||
|
||||
The Macro typename is defined with the following in [parser_types.hpp](../base/components/parser_types.hpp):
|
||||
|
||||
```c
|
||||
struct Macro
|
||||
{
|
||||
StrCached Name;
|
||||
MacroType Type;
|
||||
MacroFlags Flags;
|
||||
};
|
||||
```
|
||||
|
||||
The macro can be designated one of the following types:
|
||||
|
||||
* `MT_Expression`: Intended to resolve to an expression expansion.
|
||||
* `MT_Statement`: Intended to resolve an statement expansion.
|
||||
* `MT_Typename`: Intended to resolve to a typename.
|
||||
|
||||
Additioonally tthe following flags may be set:
|
||||
|
||||
* `MF_Functional`: The macro intended to be passed arguments are at least have the calling `()` as part of its usage.
|
||||
* `MF_Expects_Body`: The parser should expect a braced-body `{ ... }` after the macro signature `<name> <params>`
|
||||
* `MF_Allow_As_Identifier`: Will allow the macro to be an acceptable token/s when an `Tok_Identifier` is expected.
|
||||
* `MF_Allow_As_Attribute`: Will allow the macro to be an acceptable token/s when an attribute token/s is expected.
|
||||
* `MF_Allow_As_Definition`: Will allow the macro be an acceptable token/s when the parser expects a declartion or definition to resolve after attributes or specifiers have been identified beforehand.
|
||||
* This flag requires that the macro is of type `MT_Statement` to make any sense of usage.
|
||||
|
||||
If a macro is not defined the following warning will be issued if `GEN_BUILD_DEBUG=1` during lexing within [lexer.cpp](../base/components/lexer.cpp) - `lex_preprocessor_define`:
|
||||
|
||||
```c
|
||||
log_fmt("Warning: '%S' was not registered before the lexer processed its #define directive, it will be registered as a expression macro\n"
|
||||
, name.Text
|
||||
);
|
||||
```
|
||||
|
||||
Further within the same scope, the lexer will issue a warning if it detects a macro was not flagged as function but has an open parenthesis `(` token right after is name with no whitespace:
|
||||
|
||||
```c
|
||||
log_fmt("Warning: %S registered macro is not flagged as functional yet the definition detects opening parenthesis '(' for arguments\n"
|
||||
, name.Text
|
||||
);
|
||||
```
|
||||
|
||||
Macros are tracked using a `MacroTable Macros;` defined as a member of the library's `Context`.
|
||||
|
||||
```c
|
||||
typedef HashTable(Macro) MacroTable;
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
* Empty lines used throughout the file are preserved for formatting purposes during ast serialization (they have a dedicated Token: `Tok_NewLine`).
|
||||
* Numeric literals are not checked for validity.
|
||||
* The parse API treats any execution scope definitions with no validation and are turned into untyped Code ASTs. (There is a [todo](https://github.com/Ed94/gencpp/issues/49) to add support)
|
||||
* *This includes the assignment of variables.*
|
||||
@ -95,4 +156,4 @@ The lexing and parsing takes shortcuts from whats expected in the standard.
|
||||
* Parsing attributes can be extended to support user defined macros by defining `GEN_DEFINE_ATTRIBUTE_TOKENS` (see `gen.hpp` for the formatting)
|
||||
* This is useful for example: parsing Unreal `Module_API` macros.
|
||||
|
||||
Empty lines used throughout the file are preserved for formatting purposes during ast serialization.
|
||||
**The lexer & parser do not gracefully attempt to continue when it comes across incorrect code, and doesn't properly track errors into a listing (yet).**
|
||||
|
110
docs/Readme.md
110
docs/Readme.md
@ -26,7 +26,7 @@ This means that the typename entry for the parameter AST would be either:
|
||||
***Concepts and Constraints are not supported***
|
||||
Its a [todo](https://github.com/Ed94/gencpp/issues/21)
|
||||
|
||||
### Feature Macros:
|
||||
### Feature Macros
|
||||
|
||||
* `GEN_DEFINE_ATTRIBUTE_TOKENS` : Allows user to define their own attribute macros for use in parsing.
|
||||
* This can be generated using base.cpp.
|
||||
@ -36,10 +36,41 @@ Its a [todo](https://github.com/Ed94/gencpp/issues/21)
|
||||
* `GEN_EXPOSE_BACKEND` : Will expose symbols meant for internal use only.
|
||||
* `GEN_ROLL_OWN_DEPENDENCIES` : Optional override so that user may define the dependencies themselves.
|
||||
* `GEN_DONT_ALLOW_INVALID_CODE` (Not implemented yet) : Will fail when an invalid code is constructed, parsed, or serialized.
|
||||
* `GEN_C_LIKE_PP` : Setting to `<true or 1>` Will prevent usage of function defnitions using references and structs with member functions. Structs will still have user-defined operator conversions, for-range support, and other operator overloads
|
||||
* `GEN_C_LIKE_CPP` : Setting to `<true or 1>` Will prevent usage of function defnitions using references and structs with member functions. Structs will still have user-defined operator conversions, for-range support, and other operator overloads
|
||||
|
||||
### The Data & Interface
|
||||
|
||||
The library's persistent state is managed tracked by a context struct: `global Context* _ctx;` defined within [static_data.cpp](../base/components/static_data.cpp)
|
||||
|
||||
https://github.com/Ed94/gencpp/blob/967a044637f1615c709cb723dc61118fcc08dcdb/base/components/interface.hpp#L39-L97
|
||||
|
||||
The interface for the context:
|
||||
|
||||
* `init`: Initializtion
|
||||
* `deinit`: De-initialization.
|
||||
* `reset`: Clears the allocations, but doesn't free the memoery, then calls `init()` on `_ctx` again.
|
||||
* `get_context`: Retreive the currently tracked context.
|
||||
* `set_context`: Swap out the current tracked context.
|
||||
|
||||
|
||||
#### Allocato usage
|
||||
|
||||
* `Allocator_DyanmicContainers`: Growing arrays, hash tables. (Unbounded sized containers)
|
||||
* `Allocator_Pool`: Fixed-sized object allocations (ASTs, etc)
|
||||
* `Allocator_StrCache`: StrCached allocations
|
||||
* `Allocator_Temp`: Temporary alloations mostly intended for StrBuilder usage. Manually cleared by the user by their own discretion.
|
||||
|
||||
The allocator definitions used are exposed to the user incase they want to dictate memory usage
|
||||
|
||||
* Allocators are defined with the `AllocatorInfo` structure found in [`memory.hpp`](../base/dependencies/memory.hpp)
|
||||
* Most of the work is just defining the allocation procedure:
|
||||
|
||||
```cpp
|
||||
void* ( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
|
||||
```
|
||||
|
||||
For any allocator above that the user does not define before `init`, a fallback allocator will be assigned that utiizes the `fallback_allocator_proc` wtihin [interface.cpp](../base/components/interface.cpp).
|
||||
|
||||
As mentioned in root readme, the user is provided Code objects by calling the constructor's functions to generate them or find existing matches.
|
||||
|
||||
The AST is managed by the library and provided to the user via its interface.
|
||||
@ -47,14 +78,14 @@ However, the user may specifiy memory configuration.
|
||||
|
||||
[Data layout of AST struct (Subject to heavily change with upcoming todos)](../base/components/ast.hpp#L396-461)
|
||||
|
||||
https://github.com/Ed94/gencpp/blob/eea4ebf5c40d5d87baa465abfb1be30845b2377e/base/components/ast.hpp#L396-L461
|
||||
https://github.com/Ed94/gencpp/blob/967a044637f1615c709cb723dc61118fcc08dcdb/base/components/ast.hpp#L369-L435
|
||||
|
||||
*`StringCahced` is a typedef for `Str` (a string slice), to denote it is an interned string*
|
||||
*`CodeType` is enum taggin the type of code. Has an underlying type of `u32`*
|
||||
*`OperatorT` is a typedef for `EOperator::Type` which has an underlying type of `u32`*
|
||||
*`StrBuilder` is the dynamically allocated string type for the library*
|
||||
*`StrBuilder` is the dynamically allocating string builder type for the library*
|
||||
|
||||
AST widths are setup to be AST_POD_Size.
|
||||
AST widths are setup to be AST_POD_Size (128 bytes by default).
|
||||
The width dictates how much the static array can hold before it must give way to using an allocated array:
|
||||
|
||||
```cpp
|
||||
@ -73,41 +104,16 @@ int AST_ArrSpecs_Cap =
|
||||
)
|
||||
/ sizeof(Specifier) - 1;
|
||||
```
|
||||
|
||||
*Ex: If the AST_POD_Size is 128 the capacity of the static array is 20.*
|
||||
|
||||
Data Notes:
|
||||
|
||||
* The allocator definitions used are exposed to the user incase they want to dictate memory usage
|
||||
* You'll find the memory handling in `init`, `deinit`, `reset`, `gen_strbuilder_allocator`, `cache_str`, `make_code`.
|
||||
* Allocators are defined with the `AllocatorInfo` structure found in [`memory.hpp`](../base/dependencies/memory.hpp)
|
||||
* Most of the work is just defining the allocation procedure:
|
||||
|
||||
```cpp
|
||||
void* ( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
|
||||
```
|
||||
|
||||
* ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type.
|
||||
* Code types have member symbols but their data layout is enforced to be POD types.
|
||||
* This library treats memory failures as fatal.
|
||||
* Cached Strings are stored in their own set of arenas. AST constructors use cached strings for names, and content.
|
||||
* `StringArenas`, `StringCache`, `Allocator_StringArena`, and `Allocator_StringTable` are the associated containers or allocators.
|
||||
* Strings used for serialization and file buffers are not contained by those used for cached strings.
|
||||
* They are currently using `FallbackAllocator`, which are tracked array of arenas that grows as needed (adds buckets when one runs out).
|
||||
* Memory within the buckets is not reused, so its inherently wasteful.
|
||||
* I will be augmenting the default allocator with virtual memory & a slab allocator in the [future](https://github.com/Ed94/gencpp/issues/12)
|
||||
* Intrusive linked lists used children nodes on bodies, and parameters.
|
||||
* `_ctx->Allocator_Temp` is used.
|
||||
* Its intended to generate the AST in one go and serialize after. The constructors and serializer are designed to be a "one pass, front to back" setup.
|
||||
* Allocations can be tuned by defining the folloiwng macros (will be moved to runtime configuration in the future):
|
||||
* `GEN_GLOBAL_BUCKET_SIZE` : Size of each bucket area for the global allocator
|
||||
* `GEN_CODEPOOL_NUM_BLOCKS` : Number of blocks per code pool in the code allocator
|
||||
* `GEN_SIZE_PER_STRING_ARENA` : Size per arena used with string caching.
|
||||
* `GEN_MAX_COMMENT_LINE_LENGTH` : Longest length a comment can have per line.
|
||||
* `GEN_MAX_NAME_LENGTH` : Max length of any identifier.
|
||||
* `GEN_MAX_UNTYPED_STR_LENGTH` : Max content length for any untyped code.
|
||||
* `TokenMap_FixedArena` : token_fmt_va uses local_persit memory of this arena type for the hashtable.
|
||||
* `GEN_LEX_ALLOCATOR_SIZE`
|
||||
* `GEN_BUILDER_STR_BUFFER_RESERVE`
|
||||
* Any modifcations to an existing AST should be to just construct another with the modifications done on-demand while traversing the AST (non-destructive).
|
||||
|
||||
The following CodeTypes are used which the user may optionally use strong typing with if they enable: `GEN_ENFORCE_STRONG_CODE_TYPES`
|
||||
|
||||
@ -117,6 +123,7 @@ The following CodeTypes are used which the user may optionally use strong typing
|
||||
* CodeClass
|
||||
* CodeConstructor
|
||||
* CodeDefine
|
||||
* CodeDefineParams
|
||||
* CodeDestructor
|
||||
* CodeEnum
|
||||
* CodeExec
|
||||
@ -127,7 +134,7 @@ The following CodeTypes are used which the user may optionally use strong typing
|
||||
* CodeModule
|
||||
* CodeNS
|
||||
* CodeOperator
|
||||
* CodeOpCast
|
||||
* CodeOpCast : User defined member operator conversion
|
||||
* CodeParams : Has support for `for : range` iterating across parameters.
|
||||
* CodePreprocessCond
|
||||
* CodePragma
|
||||
@ -140,11 +147,15 @@ The following CodeTypes are used which the user may optionally use strong typing
|
||||
* CodeUsing
|
||||
* CodeVar
|
||||
|
||||
Each Code boy has an associated "filtered AST" with the naming convention: `AST_<CodeName>`
|
||||
Each `struct Code<Name>` has an associated "filtered AST" with the naming convention: `AST_<CodeName>`
|
||||
Unrelated fields of the AST for that node type are omitted and only necessary padding members are defined otherwise.
|
||||
Retrieving a raw version of the ast can be done using the `raw()` function defined in each AST.
|
||||
|
||||
## There are three sets of interfaces for Code AST generation the library provides
|
||||
For the interface related to these code types see:
|
||||
|
||||
* [ast.hpp](../base/components/ast.hpp): Under the region pragma `Code C-Interface`
|
||||
* [code_types.hpp](../base/components/code_types.hpp): Under the region pragma `Code C-Interface`. Additional functionlity for c++ will be within the struct definitions or at the end of the file.
|
||||
|
||||
## There are three categories of interfaces for Code AST generation & reflection
|
||||
|
||||
* Upfront
|
||||
* Parsing
|
||||
@ -164,6 +175,7 @@ Interface :``
|
||||
* def_class
|
||||
* def_constructor
|
||||
* def_define
|
||||
* def_define_params
|
||||
* def_destructor
|
||||
* def_enum
|
||||
* def_execution
|
||||
@ -218,6 +230,27 @@ Code <name>
|
||||
|
||||
```
|
||||
|
||||
All optional parmeters are defined within `struct Opts_def_<functon name>`. This was done to setup a [macro trick](https://x.com/vkrajacic/status/1749816169736073295) for default optional parameers in the C library:
|
||||
|
||||
```cpp
|
||||
struct gen_Opts_def_struct
|
||||
{
|
||||
gen_CodeBody body;
|
||||
gen_CodeTypename parent;
|
||||
gen_AccessSpec parent_access;
|
||||
gen_CodeAttributes attributes;
|
||||
gen_CodeTypename* interfaces;
|
||||
gen_s32 num_interfaces;
|
||||
gen_ModuleFlag mflags;
|
||||
};
|
||||
typedef struct gen_Opts_def_struct gen_Opts_def_struct;
|
||||
|
||||
GEN_API gen_CodeClass gen_def__struct( gen_Str name, gen_Opts_def_struct opts GEN_PARAM_DEFAULT );
|
||||
#define gen_def_struct( name, ... ) gen_def__struct( name, ( gen_Opts_def_struct ) { __VA_ARGS__ } )
|
||||
```
|
||||
|
||||
In the C++ library, the `def_<funtion name>` is not wrapped in a macro.
|
||||
|
||||
When using the body functions, its recommended to use the args macro to auto determine the number of arguments for the varadic:
|
||||
|
||||
```cpp
|
||||
@ -228,7 +261,7 @@ def_global_body( 3, ht_entry, array_ht_entry, hashtable );
|
||||
```
|
||||
|
||||
If a more incremental approach is desired for the body ASTs, `Code def_body( CodeT type )` can be used to create an empty body.
|
||||
When the members have been populated use: `AST::validate_body` to verify that the members are valid entires for that type.
|
||||
When the members have been populated use: `code_validate_body` to verify that the members are valid entires for that type.
|
||||
|
||||
### Parse construction
|
||||
|
||||
@ -238,12 +271,12 @@ Interface :
|
||||
|
||||
* parse_class
|
||||
* parse_constructor
|
||||
* parse_define
|
||||
* parse_destructor
|
||||
* parse_enum
|
||||
* parse_export_body
|
||||
* parse_extern_link
|
||||
* parse_friend
|
||||
* Purposefully are only support forward declares with this constructor.
|
||||
* parse_function
|
||||
* parse_global_body
|
||||
* parse_namespace
|
||||
@ -322,6 +355,7 @@ Code <name> = parse_<function name>( gen_code_str );
|
||||
|
||||
The following are provided predefined by the library as they are commonly used:
|
||||
|
||||
* `enum_underlying_macro`
|
||||
* `access_public`
|
||||
* `access_protected`
|
||||
* `access_private`
|
||||
|
BIN
docs/assets/Code_-_Insiders_2024-12-15_22-52-13.gif
Normal file
BIN
docs/assets/Code_-_Insiders_2024-12-15_22-52-13.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 150 KiB |
BIN
docs/assets/Code_-_Insiders_2024-12-15_22-57-58.gif
Normal file
BIN
docs/assets/Code_-_Insiders_2024-12-15_22-57-58.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 250 KiB |
BIN
docs/assets/Code_-_Insiders_2024-12-15_23-04-07.gif
Normal file
BIN
docs/assets/Code_-_Insiders_2024-12-15_23-04-07.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 175 KiB |
@ -1,7 +1,5 @@
|
||||
## Navigation
|
||||
|
||||
# base
|
||||
|
||||
[Top](../Readme.md)
|
||||
|
||||
* [docs](../docs/Readme.md)
|
||||
@ -15,9 +13,133 @@ The output will be in the `gen_segmented/gen` directory (if the directory does n
|
||||
If using the library's provided build scripts:
|
||||
|
||||
```ps1
|
||||
.\build.ps1 <compiler> <debug or omit> c_library
|
||||
.\build.ps1 <compiler> <debug or omit> c_lib
|
||||
```
|
||||
|
||||
To generate a static or dynamic library:
|
||||
|
||||
```ps1
|
||||
.\build.ps1 <compiler> <debug or omit> c_lib_static c_lib_dyn
|
||||
```
|
||||
|
||||
All free from tag identifiers will be prefixed with `gen_` or `GEN_` as the namespace. This can either be changed after generation with a `.refactor` script (or your preferred subst method), OR by modifying [c_library.refactor](./c_library.refactor).
|
||||
|
||||
**If c_library.refactor is modified you may need to modify c_library.cpp and its [components](./components/). As some of the container generation relies on that prefix.**
|
||||
|
||||
## Generation structure
|
||||
|
||||
1. Files are scanned in or parsed.
|
||||
* If they are parsed, its dude to requiring some changes to either naming, or adding additonal definitions (container generation, typedefs, etc).
|
||||
2. All scanned or parsed code is refactored (identifiers substs) and/or formatted.
|
||||
3. Singleheader generated.
|
||||
4. Segemented headers and source generated.
|
||||
|
||||
## Templated container generation
|
||||
|
||||
The array and hashtable containers used across this library are generated using the following implementatioon:
|
||||
|
||||
* [containers.array.hpp](./components/containers.array.hpp)
|
||||
* [containers.hashtable.hpp](./components/containers.hashtable.hpp)
|
||||
|
||||
These are functionally (and interface wise) equivalent to the library's `Array<Type>` `HashTable<Type>` within [containers.hpp](../base/dependencies/containers.hpp)
|
||||
|
||||
Both files follow the same patter of providing three procedures:
|
||||
|
||||
* `gen_<container>_base` : Intended to be called once, defines universal "base" definitions.
|
||||
* `gen_<container>` : Called per instatiation of the container for a given set of dependent args.
|
||||
* `gen_<container>_generic_selection_interface` : Intended to be called once after all of the instantiated containers have finished generating. It will generate a set of generic selection macros as described by Macro Usage section below.
|
||||
|
||||
A simple `<container>_DefinitionCounter` is used to know how many instantiations of the template have occured. This is used to determine how to define `GENERIC_SLOT_<ID>_<functionID>` for the generic interface along with how many slots the `_Generic` macro will need to have generated.
|
||||
|
||||
## Macro Usage
|
||||
|
||||
For the most part macros are kept minimal with exception to `_Generic`...
|
||||
*(I will be explaining this thing for the rest of this seciton along with gencpp c library's usage of it)*
|
||||
|
||||
The `_Generic` macro plays a key role in reducing direct need of the user to wrangle with mangled definition identifiers of 'templated' containers or for type coercion to map distinct data types to a common code path.
|
||||
|
||||
Because of its lack of use in many C11 libraries.. and, of those that do; they usually end up obfuscating it with excessive preprocessor abuse; Effort was put into minimizing how much of these macros are handled by the preprocessor vs gencpp itself.
|
||||
|
||||
The usual presentation (done bare) is the following:
|
||||
|
||||
```c
|
||||
#define macro_that_selects_typeof_arg(arg, y) \
|
||||
_Generic( (arg), \
|
||||
int : some expression, \
|
||||
double : some other expression, \
|
||||
struct Whatnot : something else again, \
|
||||
default : fallback expression \
|
||||
)
|
||||
```
|
||||
|
||||
Where `_Generic` can be considered the follwoing (psuedo-C):
|
||||
|
||||
```c
|
||||
#define type_expr_pair(type, expr) type: expr
|
||||
|
||||
C_Expression _Generic( selector_arg, a_type_expr_pair, ... ) {
|
||||
switch( typeof(selector_arg)) {
|
||||
case a_type_expr_pair:
|
||||
return a_type_expr_pari.expr;
|
||||
...
|
||||
default:
|
||||
return default.expr;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The first `arg` of _Generic behaves as the "controlling expression" or the expression that resolves to a type which will dictate which of the following expressions provided after to `_Generic` will be resolved as the one used inline for the implemenation.
|
||||
|
||||
|
||||
For this library's purposes we'll be using the functional macro equivalent *(if there is an exception I'll link it at the end of this section)*:
|
||||
|
||||
```c
|
||||
#define macro_that_uses_selector_arg_for_resolving_a_fucntion( selecting_exp) \
|
||||
_Generic( (arg), \
|
||||
int : func_use_int, \
|
||||
double : func_use_double, \
|
||||
struct Whatnot : func_use_Whatnot, \
|
||||
default : struct SIGNALS_FAILURE \
|
||||
) (selecting_exp)
|
||||
```
|
||||
|
||||
In this case, we directly added `(selecting_exp)` to the end there.. as we want to directly have the macro resolve to calling a resolved procedure. A default has been set to a struct as that leads to a neat compiler message that would otherwise be impossible beause static_assert is a statement and thus cannot be used within a slot.
|
||||
|
||||
Now, even with gencpp generating this type-expression table, we still need wrapper macros to achieve function 'overloading' for the templated containers as _Generic has a [significant drawback](https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/c11-generic/):
|
||||
|
||||
> Discarded expressions still have to be semantically valid.
|
||||
|
||||
The only way to absolve this issue [(without resorting to nasty preprocessor hacks)](https://github.com/JacksonAllan/CC/blob/main/articles/Better_C_Generics_Part_1_The_Extendible_Generic.md) is with wrapping expressions in 'slot' resolving macros that do not expand if the slot is not defined:
|
||||
|
||||
```c
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GENERIC_SLOT_1__function_sig )
|
||||
```
|
||||
|
||||
`GENERIC_SLOT_1__function_sig` is our warpper of a "`int, func_use_int`" pair. The `GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT` is a verbse named macro to indicate that that pair will be expanded ***ONLY IF*** its defined.
|
||||
|
||||
So for any given templated container interface. Expect the follwoing (taken straight from generation, and just cleaned up formatting):
|
||||
|
||||
```c
|
||||
#define gen_array_append( selector_arg, ... ) _Generic( \
|
||||
(selector_arg ), \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_1__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_2__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_3__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_4__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_5__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_6__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_7__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_8__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_9__array_append ) \
|
||||
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( GEN_GENERIC_SLOT_10__array_append ) \
|
||||
default: gen_generic_selection_fail \
|
||||
) GEN_RESOLVED_FUNCTION_CALL( &selector_arg, __VA_ARGS__ )
|
||||
|
||||
```
|
||||
|
||||
*Note(Ed): Unfortunately I cannot get clang-format to output these macros sanely like the above..*
|
||||
*Eventually I'll add some basic builtin formatting but if the user has suggestions for something better I'm open ears...*
|
||||
|
||||
`GEN_RESOLVED_FUNCTION_CALL` is an empty define, its just to indicate that its intended to expand to a function call.
|
||||
|
||||
To see the the actual macro definitions used - see: [generic_macros.h](./components/generic_macros.h). They'll be injected right after the usual macros in the generated header file.
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#include "gen.cpp"
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
|
||||
@ -65,19 +64,123 @@ int gen_main()
|
||||
Context ctx {};
|
||||
gen::init(& ctx);
|
||||
|
||||
ctx.PreprocessorDefines.append(txt("GEN_API_C_BEGIN"));
|
||||
ctx.PreprocessorDefines.append(txt("GEN_API_C_END"));
|
||||
ctx.PreprocessorDefines.append(txt("Array("));
|
||||
ctx.PreprocessorDefines.append(txt("HashTable("));
|
||||
ctx.PreprocessorDefines.append(txt("GEN_NS_PARSER"));
|
||||
ctx.PreprocessorDefines.append(txt("GEN_NS_PARSER_BEGIN"));
|
||||
ctx.PreprocessorDefines.append(txt("GEN_NS_PARSER_END"));
|
||||
ctx.PreprocessorDefines.append(txt("Using_Code("));
|
||||
ctx.PreprocessorDefines.append(txt("Using_CodeOps("));
|
||||
ctx.PreprocessorDefines.append(txt("GEN_OPTIMIZE_MAPPINGS_BEGIN"));
|
||||
ctx.PreprocessorDefines.append(txt("GEN_OPITMIZE_MAPPINGS_END"));
|
||||
ctx.PreprocessorDefines.append(txt("GEN_PARAM_DEFAULT"));
|
||||
//PreprocessorDefines.append(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"));
|
||||
register_macros( args(
|
||||
(Macro { txt("bit"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("bitfield_is_set"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_C_LIKE_CPP"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("cast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("ccast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("rcast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("pcast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("scast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("stringize_va"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("stringize"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("do_once"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("do_once_defer"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("do_once_start"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("do_once_end"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("labeled_scope_start"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("labeled_scope_end"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("compiler_decorated_func_name"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("num_args_impl"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("num_args"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("count_of"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("clamp"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("is_between"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("size_of"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("min"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("max"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("offset_of"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("static_assert"), MT_Statement, MF_Functional }),
|
||||
(Macro { txt("typeof"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("GEN_API_C_BEGIN"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("GEN_API_C_END"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("nullptr"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("GEN_REMOVE_PTR"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_PARAM_DEFAULT"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("struct_init"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_OPTIMIZE_MAPPINGS_BEGIN"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("GEN_OPITMIZE_MAPPINGS_END"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("Array"), MT_Typename, MF_Functional }),
|
||||
(Macro { txt("HashTable"), MT_Typename, MF_Functional }),
|
||||
(Macro { txt("Using_Code"), MT_Statement, MF_Functional }),
|
||||
(Macro { txt("Using_CodeOps"), MT_Statement, MF_Functional }),
|
||||
(Macro { txt("kilobytes"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("megabytes"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("gigabytes"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("terabytes"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN__ONES"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("GEN__HIGHS"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("GEN__HAS_ZERO"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("zero_item"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("zero_array"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_DEFAULT_MEMORY_ALIGNMENT"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("GEN_DEFAULT_ALLOCATOR_FLAGS"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("alloc_item"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("alloc_array"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("malloc"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("mfree"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_PRINTF_MAXLEN"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("cast_to_str"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("current"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("txt"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_FILE_OPEN_PROC"), MT_Statement, MF_Functional | MF_Expects_Body }),
|
||||
(Macro { txt("GEN_FILE_READ_AT_PROC"), MT_Statement, MF_Functional | MF_Expects_Body }),
|
||||
(Macro { txt("GEN_FILE_WRITE_AT_PROC"), MT_Statement, MF_Functional | MF_Expects_Body }),
|
||||
(Macro { txt("GEN_FILE_SEEK_PROC"), MT_Statement, MF_Functional | MF_Expects_Body }),
|
||||
(Macro { txt("GEN_FILE_CLOSE_PROC"), MT_Statement, MF_Functional | MF_Expects_Body }),
|
||||
(Macro { txt("log_failure"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("operator"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("InvalidCode"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("NullCode"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("Verify_POD"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("gen_main"), MT_Statement, MF_Null })
|
||||
));
|
||||
register_macros( args(
|
||||
(Macro { txt("name"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("code"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("args"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("code_str"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("code_fmt"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("parse_fmt"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("token_fmt"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("check_member_val"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("check_member_str"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("check_member_content"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("check_member_ast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("check_params"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("check_param_eq_ret"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("specs"), MT_Expression, MF_Functional | MF_Allow_As_Identifier }),
|
||||
(Macro { txt("name_check"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("null_check"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("def_body_start"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("def_body_code_array_start"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("move_forward"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("skip_whitespace"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("end_line"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("check_parse_args"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("currtok_noskip"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("currtok"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("peektok"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("prevtok"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("nexttok"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("nexttok_noskip"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("eat"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("left"), MT_Expression, MF_Null | MF_Allow_As_Identifier }),
|
||||
(Macro { txt("def_assign"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("CHECK_WAS_DEFINED"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("check_noskip"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("check"), MT_Expression, MF_Functional | MF_Allow_As_Identifier }),
|
||||
(Macro { txt("push_scope"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("cut_length"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("cut_ptr"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("pos"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("move_fwd"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("Entry"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("CheckEndParams"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("UseTemplateCapture"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("check_current"), MT_Expression, MF_Functional })
|
||||
));
|
||||
|
||||
Code push_ignores = scan_file( path_base "helpers/push_ignores.inline.hpp" );
|
||||
Code pop_ignores = scan_file( path_base "helpers/pop_ignores.inline.hpp" );
|
||||
@ -139,8 +242,8 @@ int gen_main()
|
||||
CodeTemplate tmpl = cast(CodeTemplate, entry);
|
||||
if ( tmpl->Declaration->Name.contains(txt("swap")))
|
||||
{
|
||||
log_fmt("SWAPPED");
|
||||
CodeBody macro_swap = parse_global_body( txt(R"(
|
||||
register_macro({ txt("swap"), MT_Expression, MF_Functional });
|
||||
CodeDefine macro_swap = parse_define( txt(R"(
|
||||
#define swap( a, b ) \
|
||||
do \
|
||||
{ \
|
||||
@ -241,7 +344,8 @@ do \
|
||||
{
|
||||
if ( str_contains(entry->Name, txt("Msg_Invalid_Value")))
|
||||
{
|
||||
CodeDefine define = def_define(entry->Name, entry->Value->Content);
|
||||
Opts_def_define opts = { {}, entry->Value->Content };
|
||||
CodeDefine define = def_define(entry->Name, MT_Expression, opts );
|
||||
header_printing.append(define);
|
||||
continue;
|
||||
}
|
||||
@ -407,7 +511,8 @@ do \
|
||||
CodeVar var = cast(CodeVar, entry);
|
||||
if (var->Specs.has(Spec_Constexpr) > -1)
|
||||
{
|
||||
CodeDefine define = def_define(entry->Name, entry->Value->Content);
|
||||
Opts_def_define opts = { {}, entry->Value->Content };
|
||||
CodeDefine define = def_define(entry->Name, MT_Expression, opts);
|
||||
header_filesystem.append(define);
|
||||
continue;
|
||||
}
|
||||
@ -695,6 +800,9 @@ do \
|
||||
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_ast, ast );
|
||||
if (found) break;
|
||||
|
||||
found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_ast, ast );
|
||||
if (found) break;
|
||||
|
||||
ast.append(entry);
|
||||
}
|
||||
break;
|
||||
@ -811,7 +919,8 @@ R"(#define AST_ArrSpecs_Cap \
|
||||
ast.append(def);
|
||||
break;
|
||||
}
|
||||
CodeDefine def = def_define(var->Name, var->Value.to_strbuilder());
|
||||
Opts_def_define opts = { {}, var->Value.to_strbuilder() };
|
||||
CodeDefine def = def_define(var->Name, MT_Expression, opts );
|
||||
ast.append(def);
|
||||
break;
|
||||
}
|
||||
@ -832,6 +941,7 @@ R"(#define AST_ArrSpecs_Cap \
|
||||
txt("CodeClass"),
|
||||
txt("CodeConstructor"),
|
||||
txt("CodeDefine"),
|
||||
txt("CodeDefineParams"),
|
||||
txt("CodeDestructor"),
|
||||
txt("CodeEnum"),
|
||||
txt("CodeExec"),
|
||||
@ -871,6 +981,9 @@ R"(#define AST_ArrSpecs_Cap \
|
||||
found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_code_types, code_types );
|
||||
if (found) break;
|
||||
|
||||
found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_code_types, code_types);
|
||||
if (found) break;
|
||||
|
||||
code_types.append(entry);
|
||||
}
|
||||
break;
|
||||
@ -965,7 +1078,10 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
case CT_Preprocess_If:
|
||||
case CT_Preprocess_IfDef:
|
||||
{
|
||||
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_code_types, code_types );
|
||||
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_ast_types, ast_types );
|
||||
if (found) break;
|
||||
|
||||
found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_ast_types, ast_types);
|
||||
if (found) break;
|
||||
|
||||
ast_types.append(entry);
|
||||
@ -1005,8 +1121,9 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
break;
|
||||
}
|
||||
|
||||
CodeBody array_arena = gen_array(txt("gen_Arena"), txt("Array_gen_Arena"));
|
||||
CodeBody array_pool = gen_array(txt("gen_Pool"), txt("Array_gen_Pool"));
|
||||
CodeBody array_arena = gen_array(txt("gen_Arena"), txt("Array_gen_Arena"));
|
||||
CodeBody array_pool = gen_array(txt("gen_Pool"), txt("Array_gen_Pool"));
|
||||
CodeBody ht_preprocessor_macro = gen_hashtable(txt("gen_Macro"), txt("MacroTable"));
|
||||
|
||||
CodeBody parsed_interface = parse_file( path_base "components/interface.hpp" );
|
||||
CodeBody interface = def_body(CT_Global_Body);
|
||||
@ -1017,6 +1134,12 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_interface, interface );
|
||||
if (found) break;
|
||||
|
||||
found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface);
|
||||
if (found) break;
|
||||
|
||||
found = ignore_preprocess_cond_block(txt("0"), entry, parsed_interface, interface);
|
||||
if (found) break;
|
||||
|
||||
interface.append(entry);
|
||||
}
|
||||
break;
|
||||
@ -1027,13 +1150,6 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
CodeFn fn = cast(CodeFn, entry);
|
||||
Code prev = entry->Prev;
|
||||
|
||||
if (prev && prev->Name.is_equal(entry->Name)) {
|
||||
// rename second definition so there isn't a symbol conflict
|
||||
StrBuilder postfix_arr = StrBuilder::fmt_buf(_ctx->Allocator_Temp, "%S_arr", entry->Name);
|
||||
entry->Name = cache_str(postfix_arr.to_str());
|
||||
postfix_arr.free();
|
||||
}
|
||||
|
||||
b32 handled= false;
|
||||
for ( CodeParams opt_param : fn->Params ) if (opt_param->ValueType->Name.starts_with(txt("Opts_")))
|
||||
{
|
||||
@ -1209,8 +1325,10 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
if (var->Specs)
|
||||
{
|
||||
s32 constexpr_found = var->Specs.remove( Spec_Constexpr );
|
||||
if (constexpr_found > -1) {
|
||||
CodeDefine define = def_define(entry->Name, entry->Value->Content);
|
||||
if (constexpr_found > -1)
|
||||
{
|
||||
Opts_def_define opts = { {}, entry->Value->Content };
|
||||
CodeDefine define = def_define(entry->Name, MT_Expression, opts );
|
||||
header_end.append(define);
|
||||
continue;
|
||||
}
|
||||
@ -1244,9 +1362,27 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
Code src_static_data = scan_file( path_base "components/static_data.cpp" );
|
||||
Code src_ast_case_macros = scan_file( path_base "components/ast_case_macros.cpp" );
|
||||
Code src_code_serialization = scan_file( path_base "components/code_serialization.cpp" );
|
||||
Code src_interface = scan_file( path_base "components/interface.cpp" );
|
||||
|
||||
Code src_parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
|
||||
Code src_untyped = scan_file( path_base "components/interface.untyped.cpp" );
|
||||
Code src_parser_case_macros = scan_file( path_base "components/parser_case_macros.cpp" );
|
||||
|
||||
CodeBody parsed_src_interface = parse_file( path_base "components/interface.cpp" );
|
||||
CodeBody src_interface = def_body(CT_Global_Body);
|
||||
for ( Code entry = parsed_src_interface.begin(); entry != parsed_src_interface.end(); ++ entry ) switch( entry ->Type )
|
||||
{
|
||||
case CT_Function:
|
||||
{
|
||||
CodeFn fn = cast(CodeFn, entry);
|
||||
Code prev = entry->Prev;
|
||||
src_interface.append(fn);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
src_interface.append(entry);
|
||||
break;
|
||||
}
|
||||
|
||||
CodeBody parsed_src_ast = parse_file( path_base "components/ast.cpp" );
|
||||
CodeBody src_ast = def_body(CT_Global_Body);
|
||||
@ -1305,28 +1441,14 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
{
|
||||
CodeFn fn = cast(CodeFn, entry);
|
||||
Code prev = entry->Prev;
|
||||
|
||||
for ( CodeParams arr_param : fn->Params )
|
||||
if ( fn->Name.starts_with(txt("def_"))
|
||||
&& ( (arr_param->ValueType->Name.starts_with(txt("Specifier")) && fn->Params->NumEntries > 1)
|
||||
|| arr_param->ValueType->Name.starts_with(txt("Code")) )
|
||||
)
|
||||
{
|
||||
// rename second definition so there isn't a symbol conflict
|
||||
StrBuilder postfix_arr = StrBuilder::fmt_buf(_ctx->Allocator_Temp, "%S_arr", fn->Name);
|
||||
fn->Name = cache_str(postfix_arr.to_str());
|
||||
postfix_arr.free();
|
||||
}
|
||||
|
||||
for ( CodeParams opt_param : fn->Params ) if (opt_param->ValueType->Name.starts_with(txt("Opts_")))
|
||||
{
|
||||
// The frontend names are warapped in macros so we need to give it the intenral symbol name
|
||||
Str prefix = txt("def_");
|
||||
Str actual_name = { fn->Name.Ptr + prefix.Len, fn->Name.Len - prefix.Len };
|
||||
Str new_name = StrBuilder::fmt_buf(_ctx->Allocator_Temp, "def__%S", actual_name ).to_str();
|
||||
|
||||
fn->Name = cache_str(new_name);
|
||||
}
|
||||
|
||||
src_upfront.append(fn);
|
||||
}
|
||||
break;
|
||||
@ -1466,7 +1588,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
Code rf_header_parsing = refactor_and_format(header_parsing);
|
||||
|
||||
Code rf_types = refactor_and_format(types);
|
||||
Code rf_parser_types = refactor_and_format(parser_types);
|
||||
Code rf_parser_types = refactor_and_format(parser_types);
|
||||
Code rf_ecode = refactor_and_format(ecode);
|
||||
Code rf_eoperator = refactor_and_format(eoperator);
|
||||
Code rf_especifier = refactor_and_format(especifier);
|
||||
@ -1477,10 +1599,11 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
Code rf_interface = refactor_and_format(interface);
|
||||
Code rf_inlines = refactor_and_format(inlines);
|
||||
|
||||
Code rf_array_string_cached = refactor_and_format(array_string_cached);
|
||||
Code rf_header_end = refactor_and_format(header_end);
|
||||
Code rf_header_builder = refactor_and_format(header_builder);
|
||||
Code rf_header_scanner = refactor_and_format( scan_file( path_base "auxillary/scanner.hpp" ));
|
||||
Code rf_ht_preprocessor_macro = refactor_and_format(ht_preprocessor_macro);
|
||||
Code rf_array_string_cached = refactor_and_format(array_string_cached);
|
||||
Code rf_header_end = refactor_and_format(header_end);
|
||||
Code rf_header_builder = refactor_and_format(header_builder);
|
||||
Code rf_header_scanner = refactor_and_format( scan_file( path_base "auxillary/scanner.hpp" ));
|
||||
|
||||
Code r_src_dep_start = refactor(src_dep_start);
|
||||
Code r_src_debug = refactor(src_debug);
|
||||
@ -1500,8 +1623,9 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
Code r_src_ast_case_macros = refactor(src_ast_case_macros);
|
||||
Code r_src_ast = refactor(src_ast);
|
||||
Code r_src_code_serialization = refactor(src_code_serialization);
|
||||
Code r_src_parser_case_macros = refactor(src_parser_case_macros);
|
||||
|
||||
Code r_src_interface = refactor(src_interface);
|
||||
Code r_src_interface = refactor_and_format(src_interface);
|
||||
Code r_src_upfront = refactor_and_format(src_upfront);
|
||||
Code r_src_lexer = refactor_and_format(src_lexer);
|
||||
Code rf_array_code_typename = refactor_and_format(array_code_typename);
|
||||
@ -1534,7 +1658,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
header.print( r_header_macros );
|
||||
header.print( header_generic_macros );
|
||||
|
||||
header.print_fmt( "GEN_API_C_BEGIN\n" );
|
||||
header.print_fmt( "\nGEN_API_C_BEGIN\n" );
|
||||
|
||||
header.print( r_header_basic_types );
|
||||
header.print( r_header_debug );
|
||||
@ -1584,6 +1708,8 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
header.print( rf_array_pool);
|
||||
header.print( fmt_newline);
|
||||
header.print( rf_array_string_cached );
|
||||
header.print( fmt_newline);
|
||||
header.print( rf_ht_preprocessor_macro );
|
||||
|
||||
header.print( rf_interface );
|
||||
header.print(fmt_newline);
|
||||
@ -1649,6 +1775,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
||||
header.print( fmt_newline);
|
||||
header.print( rf_array_code_typename );
|
||||
header.print( fmt_newline);
|
||||
header.print( r_src_parser_case_macros );
|
||||
header.print( rf_src_parser );
|
||||
header.print( r_src_parsing );
|
||||
header.print_fmt( "\n#pragma endregion Parsing\n" );
|
||||
|
@ -21,7 +21,7 @@ word global, gen_global
|
||||
word internal, gen_internal
|
||||
word local_persist, gen_local_persist
|
||||
word bit, gen_bit
|
||||
word bitfield_is_equal, gen_bitfield_is_equal
|
||||
word bitfield_is_set, gen_bitfield_is_set
|
||||
word cast, gen_cast
|
||||
word ccast, gen_ccast
|
||||
word pcast, gen_pcast
|
||||
@ -310,6 +310,14 @@ word spec_to_str, gen_spec_to_str
|
||||
word spec_is_trailing, gen_spec_is_trailing
|
||||
// word str_to_specifier, gen_str_to_specifier
|
||||
|
||||
word MacroType, gen_MacroType
|
||||
word EMacroFlags, gen_EMacroFlags
|
||||
word MacroFlags, gen_MacroFlags
|
||||
word Macro, gen_Macro
|
||||
|
||||
namespace macro_, gen_macro_
|
||||
namespace macrotype, gen_macrotype_
|
||||
|
||||
// AST
|
||||
|
||||
word AST, gen_AST
|
||||
@ -325,6 +333,7 @@ word CodeComment, gen_CodeComment
|
||||
word CodeClass, gen_CodeClass
|
||||
word CodeConstructor, gen_CodeConstructor
|
||||
word CodeDefine, gen_CodeDefine
|
||||
word CodeDefineParams, gen_CodeDefineParams
|
||||
word CodeDestructor, gen_CodeDestructor
|
||||
word CodeEnum, gen_CodeEnum
|
||||
word CodeExec, gen_CodeExec
|
||||
@ -350,6 +359,8 @@ word CodeVar, gen_CodeVar
|
||||
|
||||
// Code Interface
|
||||
|
||||
word Context, gen_Context
|
||||
|
||||
namespace code_, gen_code_
|
||||
|
||||
word Code_Global, gen_Code_Global
|
||||
@ -397,6 +408,8 @@ namespace var_, gen_var_
|
||||
|
||||
// Gen Interface
|
||||
|
||||
word _ctx, gen__ctx
|
||||
|
||||
word init, gen_init
|
||||
word deinit, gen_deinit
|
||||
word reset, gen_reset
|
||||
@ -407,6 +420,8 @@ word make_code, gen_make_code
|
||||
|
||||
namespace set_allocator_, gen_set_allocator_
|
||||
|
||||
namespace Opts_, gen_Opts_
|
||||
|
||||
namespace def_, gen_def_
|
||||
namespace parse_, gen_parse_
|
||||
namespace token_, gen_token_
|
||||
@ -443,6 +458,9 @@ namespace builder_, gen_builder_
|
||||
|
||||
word scan_file, gen_scan_file
|
||||
|
||||
word CSV_Column, gen_CSV_Column
|
||||
word CSV_Columns2, gen_CSV_Columns2
|
||||
|
||||
// Implementation (prviate)
|
||||
|
||||
word _format_info, gen__format_info
|
||||
|
@ -22,9 +22,9 @@ CodeBody gen_array_base()
|
||||
Code get_header = untyped_str( txt( "#define array_get_header( self ) ( (ArrayHeader*)( self ) - 1)\n" ));
|
||||
Code type_define = untyped_str( txt( "#define Array(Type) gen_Array_##Type\n"));
|
||||
|
||||
Code array_begin = def_define(txt("array_begin(array)"), code( (array) ));
|
||||
Code array_end = def_define(txt("array_end(array)"), code( (array + array_get_header(array)->Num ) ));
|
||||
Code array_next = def_define(txt("array_next(array, entry)"), code( (entry + 1) ));
|
||||
Code array_begin = def_define(txt("array_begin(array)"), MT_Expression, { {}, code( (array) ) } );
|
||||
Code array_end = def_define(txt("array_end(array)"), MT_Expression, { {}, code( (array + array_get_header(array)->Num ) ) } );
|
||||
Code array_next = def_define(txt("array_next(array, entry)"), MT_Expression, { {}, code( (entry + 1) ) } );
|
||||
|
||||
return def_global_body( args(
|
||||
fmt_newline,
|
||||
@ -238,10 +238,10 @@ CodeBody gen_array( Str type, Str array_name )
|
||||
GEN_ASSERT(begin <= end);
|
||||
ArrayHeader* header = array_get_header( self );
|
||||
|
||||
if ( begin < 0 || end >= header->Num )
|
||||
if ( begin < 0 || end > header->Num )
|
||||
return false;
|
||||
|
||||
for ( ssize idx = begin; idx < end; idx ++ )
|
||||
for ( ssize idx = (ssize)begin; idx < (ssize)end; idx ++ )
|
||||
self[ idx ] = value;
|
||||
|
||||
return true;
|
||||
|
@ -19,7 +19,7 @@ CodeBody gen_hashtable_base()
|
||||
));
|
||||
|
||||
Code define_type = untyped_str(txt(
|
||||
R"(#define HashTable(_type) struct _type
|
||||
R"(#define HashTable(_type) struct gen_HashTable_##_type
|
||||
)"
|
||||
));
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
| \_____|\___}_l |_|\___} .__/| .__/ {_____/ \__\__/_l\__. |\___/\__,_l \____}{_____}{_____} |
|
||||
| | | | | __} | |
|
||||
| l_l l_l {___/ |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.20-Alpha |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.23-Alpha |
|
||||
! ============================================================================================= |
|
||||
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
|
||||
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |
|
||||
|
@ -89,7 +89,14 @@ CodeBody gen_fixed_arenas()
|
||||
result.append(arena_interface_2mb);
|
||||
result.append(arena_interface_4mb);
|
||||
|
||||
CodeDefine def = def_define(txt("fixed_arena_allocator_info(fixed_arena)"), txt("( (AllocatorInfo) { arena_allocator_proc, & (fixed_arena)->arena } )"));
|
||||
register_macros( args(
|
||||
( Macro { txt("fixed_arena_allocator_info"), MT_Expression, MF_Functional }),
|
||||
( Macro { txt("fixed_arena_init"), MT_Expression, MF_Functional }),
|
||||
( Macro { txt("fixed_arena_free"), MT_Expression, MF_Functional }),
|
||||
( Macro { txt("fixed_arena_size_remaining"), MT_Expression, MF_Functional })
|
||||
));
|
||||
|
||||
CodeDefine def = parse_define(txt("#define fixed_arena_allocator_info(fixed_arena) ( (AllocatorInfo) { arena_allocator_proc, & (fixed_arena)->arena } )\n"));
|
||||
result.append(def);
|
||||
result.append(fmt_newline);
|
||||
|
||||
|
@ -7,12 +7,13 @@ void convert_cpp_enum_to_c( CodeEnum to_convert, CodeBody to_append )
|
||||
{
|
||||
#pragma push_macro("enum_underlying")
|
||||
#undef enum_underlying
|
||||
StrCached type = to_convert->UnderlyingType ? to_convert->UnderlyingType.to_strbuilder().to_str() : to_convert->Name;
|
||||
CodeTypedef tdef = parse_typedef(token_fmt("type", type, "name", to_convert->Name, stringize( typedef enum <type> <name>; )));
|
||||
if (to_convert->UnderlyingType)
|
||||
{
|
||||
to_convert->UnderlyingTypeMacro = untyped_str(token_fmt("type", to_convert->UnderlyingType->Name, stringize(enum_underlying(<type>))));
|
||||
to_convert->UnderlyingType = CodeTypename{nullptr};
|
||||
}
|
||||
CodeTypedef tdef = parse_typedef(token_fmt("name", to_convert->Name, stringize( typedef enum <name> <name>; )));
|
||||
to_append.append(to_convert);
|
||||
to_append.append(tdef);
|
||||
#pragma pop_macro("enum_underlying")
|
||||
|
@ -8,11 +8,13 @@
|
||||
|
||||
# Segemented Library Generation
|
||||
|
||||
Create a segemented library using `segemented.cpp`
|
||||
|
||||
The principal (user) files are `gen.hpp` and `gen.cpp`.
|
||||
They contain includes for its various components: `components/<component_name>.<hpp/cpp>`
|
||||
|
||||
Dependencies are bundled into `gen.dep.<hpp/cpp>`. They are included in `gen.<hpp/cpp>` before component includes.
|
||||
Just like the `gen.<hpp/cpp>` they include their components: `dependencies/<dependency_name>.<hpp/cpp>`
|
||||
Just like the `gen.<hpp/cpp>` they include their components: `dependencies/<dependency_name>.<hpp/cpp>`. The auxillary content (builder & scanner) is given their own files.
|
||||
|
||||
If using the library's provided build scripts:
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#define GEN_C_LIKE_CPP 1
|
||||
#include "gen.cpp"
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
@ -193,6 +192,7 @@ int gen_main()
|
||||
Code interface = scan_file( path_base "components/interface.cpp" );
|
||||
Code upfront = scan_file( path_base "components/interface.upfront.cpp" );
|
||||
Code lexer = scan_file( path_base "components/lexer.cpp" );
|
||||
Code parser_case_macros = scan_file( path_base "components/parser_case_macros.cpp" );
|
||||
Code parser = scan_file( path_base "components/parser.cpp" );
|
||||
Code parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
|
||||
Code untyped = scan_file( path_base "components/interface.untyped.cpp" );
|
||||
@ -217,6 +217,7 @@ int gen_main()
|
||||
builder_print( src, upfront );
|
||||
builder_print_fmt( src, "\n#pragma region Parsing\n\n" );
|
||||
builder_print( src, lexer );
|
||||
builder_print( src, parser_case_macros );
|
||||
builder_print( src, parser );
|
||||
builder_print( src, parsing_interface );
|
||||
builder_print_fmt( src, "\n#pragma endregion Parsing\n\n" );
|
||||
|
@ -15,7 +15,7 @@
|
||||
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
|
||||
| Singleheader | | | | __} | |
|
||||
| l_l l_l {___/ |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.20-Alpha |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.23-Alpha |
|
||||
! ============================================================================================ |
|
||||
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
|
||||
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |
|
||||
|
@ -1,6 +1,5 @@
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#include "gen.cpp"
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
|
||||
@ -210,16 +209,17 @@ int gen_main()
|
||||
header.print_fmt( roll_own_dependencies_guard_end );
|
||||
}
|
||||
|
||||
Code static_data = scan_file( path_base "components/static_data.cpp" );
|
||||
Code ast_case_macros = scan_file( path_base "components/ast_case_macros.cpp" );
|
||||
Code ast = scan_file( path_base "components/ast.cpp" );
|
||||
Code code = scan_file( path_base "components/code_serialization.cpp" );
|
||||
Code interface = scan_file( path_base "components/interface.cpp" );
|
||||
Code upfront = scan_file( path_base "components/interface.upfront.cpp" );
|
||||
Code lexer = scan_file( path_base "components/lexer.cpp" );
|
||||
Code parser = scan_file( path_base "components/parser.cpp" );
|
||||
Code parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
|
||||
Code untyped = scan_file( path_base "components/interface.untyped.cpp" );
|
||||
Code static_data = scan_file( path_base "components/static_data.cpp" );
|
||||
Code ast_case_macros = scan_file( path_base "components/ast_case_macros.cpp" );
|
||||
Code ast = scan_file( path_base "components/ast.cpp" );
|
||||
Code code = scan_file( path_base "components/code_serialization.cpp" );
|
||||
Code interface = scan_file( path_base "components/interface.cpp" );
|
||||
Code upfront = scan_file( path_base "components/interface.upfront.cpp" );
|
||||
Code lexer = scan_file( path_base "components/lexer.cpp" );
|
||||
Code parser_case_macros = scan_file( path_base "components/parser_case_macros.cpp" );
|
||||
Code parser = scan_file( path_base "components/parser.cpp" );
|
||||
Code parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
|
||||
Code untyped = scan_file( path_base "components/interface.untyped.cpp" );
|
||||
|
||||
header.print_fmt( "\nGEN_NS_BEGIN\n");
|
||||
header.print( static_data );
|
||||
@ -236,6 +236,7 @@ int gen_main()
|
||||
header.print( upfront );
|
||||
header.print_fmt( "\n#pragma region Parsing\n\n" );
|
||||
header.print( lexer );
|
||||
header.print( parser_case_macros );
|
||||
header.print( parser );
|
||||
header.print( parsing_interface );
|
||||
header.print_fmt( "\n#pragma endregion Parsing\n" );
|
||||
|
@ -15,3 +15,20 @@ If using the library's provided build scripts:
|
||||
```ps1
|
||||
.\build.ps1 <compiler> <debug or omit> unreal
|
||||
```
|
||||
|
||||
## Notables
|
||||
|
||||
For the most part this follows the same conventions as `gen_segmented`.
|
||||
|
||||
This generator uses a separate enumeration definitions for the following:
|
||||
|
||||
* [AttributeTokens.csv](./enums/AttributeTokens.csv) : Add your own <MODULE>_API attributes, etc here that are encountered within the Engine.
|
||||
* [ESpecifier.csv](./enums/ESpecifier.csv) : Adds the `FORCEINLINE` & `FORCEINLINE_DEBUGGABLE` specfiers (additions are made as they are encountered)
|
||||
* [ETokType.csv](./enums/ETokType.csv) : Same modifications as ESpecifier.csv.
|
||||
|
||||
A separate [parser_case_macros.cpp](./components/parser_case_macros.cpp) is used to accomodate for the new forceinline specifiers.
|
||||
|
||||
The `global` macro the library uses is redefined as an empty substiution.
|
||||
|
||||
|
||||
The expected usage of this library is to put into into a third-party plugin module to then use either in editor modules or in shell script done in some stage of hot-reloading or building the Unreal Engine or Project.
|
||||
|
@ -16,7 +16,7 @@
|
||||
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
|
||||
| Unreal Engine | | | | __} | |
|
||||
| l_l l_l {___/ |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.20-Alpha |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.23-Alpha |
|
||||
! ============================================================================================ |
|
||||
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
|
||||
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |
|
||||
|
108
gen_unreal_engine/components/parser_case_macros.cpp
Normal file
108
gen_unreal_engine/components/parser_case_macros.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
// These macros are used in the swtich cases within parser.cpp
|
||||
|
||||
#define GEN_PARSER_CLASS_STRUCT_BODY_ALLOWED_MEMBER_TOK_SPECIFIER_CASES \
|
||||
case Tok_Spec_Consteval: \
|
||||
case Tok_Spec_Constexpr: \
|
||||
case Tok_Spec_Constinit: \
|
||||
case Tok_Spec_Explicit: \
|
||||
case Tok_Spec_ForceInline: \
|
||||
case Tok_Spec_ForceInline_Debuggable: \
|
||||
case Tok_Spec_Inline: \
|
||||
case Tok_Spec_Mutable: \
|
||||
case Tok_Spec_NeverInline: \
|
||||
case Tok_Spec_Static: \
|
||||
case Tok_Spec_Volatile: \
|
||||
case Tok_Spec_Virtual
|
||||
|
||||
#define GEN_PARSER_CLASS_STRUCT_BODY_ALLOWED_MEMBER_SPECIFIER_CASES \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_Constinit: \
|
||||
case Spec_Explicit: \
|
||||
case Spec_Inline: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_ForceInline_Debuggable: \
|
||||
case Spec_Mutable: \
|
||||
case Spec_NeverInline: \
|
||||
case Spec_Static: \
|
||||
case Spec_Volatile: \
|
||||
case Spec_Virtual
|
||||
|
||||
#define GEN_PARSER_CLASS_GLOBAL_NSPACE_ALLOWED_MEMBER_TOK_SPECIFIER_CASES \
|
||||
case Tok_Spec_Consteval: \
|
||||
case Tok_Spec_Constexpr: \
|
||||
case Tok_Spec_Constinit: \
|
||||
case Tok_Spec_Extern: \
|
||||
case Tok_Spec_ForceInline: \
|
||||
case Tok_Spec_ForceInline_Debuggable: \
|
||||
case Tok_Spec_Global: \
|
||||
case Tok_Spec_Inline: \
|
||||
case Tok_Spec_Internal_Linkage: \
|
||||
case Tok_Spec_NeverInline: \
|
||||
case Tok_Spec_Static
|
||||
|
||||
#define GEN_PARSER_CLASS_GLOBAL_NSPACE_ALLOWED_MEMBER_SPECIFIER_CASES \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_Constinit: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_ForceInline_Debuggable: \
|
||||
case Spec_Global: \
|
||||
case Spec_External_Linkage: \
|
||||
case Spec_Internal_Linkage: \
|
||||
case Spec_Inline: \
|
||||
case Spec_Mutable: \
|
||||
case Spec_NeverInline: \
|
||||
case Spec_Static: \
|
||||
case Spec_Volatile
|
||||
|
||||
#define GEN_PARSER_FRIEND_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Inline: \
|
||||
case Spec_ForceInline
|
||||
|
||||
#define GEN_PARSER_FUNCTION_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Consteval: \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_External_Linkage: \
|
||||
case Spec_Internal_Linkage: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_ForceInline_Debuggable: \
|
||||
case Spec_Inline: \
|
||||
case Spec_NeverInline: \
|
||||
case Spec_Static
|
||||
|
||||
#define GEN_PARSER_OPERATOR_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_Inline: \
|
||||
case Spec_NeverInline: \
|
||||
case Spec_Static
|
||||
|
||||
#define GEN_PARSER_TEMPLATE_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_Constinit: \
|
||||
case Spec_External_Linkage: \
|
||||
case Spec_Global: \
|
||||
case Spec_Inline: \
|
||||
case Spec_ForceInline: \
|
||||
case Spec_ForceInline_Debuggable: \
|
||||
case Spec_Local_Persist: \
|
||||
case Spec_Mutable: \
|
||||
case Spec_Static: \
|
||||
case Spec_Thread_Local: \
|
||||
case Spec_Volatile
|
||||
|
||||
#define GEN_PARSER_VARIABLE_ALLOWED_SPECIFIER_CASES \
|
||||
case Spec_Const: \
|
||||
case Spec_Constexpr: \
|
||||
case Spec_Constinit: \
|
||||
case Spec_External_Linkage: \
|
||||
case Spec_Global: \
|
||||
case Spec_Inline: \
|
||||
case Spec_Local_Persist: \
|
||||
case Spec_Mutable: \
|
||||
case Spec_Static: \
|
||||
case Spec_Thread_Local: \
|
||||
case Spec_Volatile
|
@ -4,4 +4,4 @@ COREUOBJECT_API, COREUOBJECT_API
|
||||
ENGINE_API, ENGINE_API
|
||||
GAMEPLAYABILITIES_API, GAMEPLAYABILITIES_API
|
||||
UMG_API, UMG_API
|
||||
UE_DEPRECATED, UE_DEPRECATED
|
||||
GASA_API, GASA_API
|
|
27
gen_unreal_engine/enums/ESpecifier.csv
Normal file
27
gen_unreal_engine/enums/ESpecifier.csv
Normal file
@ -0,0 +1,27 @@
|
||||
Invalid, INVALID
|
||||
Consteval, consteval
|
||||
Constexpr, constexpr
|
||||
Constinit, constinit
|
||||
Explicit, explicit
|
||||
External_Linkage, extern
|
||||
ForceInline, FORCEINLINE
|
||||
ForceInline_Debuggable, FORCEINLINE_DEBUGGABLE
|
||||
Global, global
|
||||
Inline, inline
|
||||
Internal_Linkage, internal
|
||||
Local_Persist, local_persist
|
||||
Mutable, mutable
|
||||
NeverInline, neverinline
|
||||
Ptr, *
|
||||
Ref, &
|
||||
Register, register
|
||||
RValue, &&
|
||||
Static, static
|
||||
Thread_Local, thread_local
|
||||
Virtual, virtual
|
||||
Const, const
|
||||
Final, final
|
||||
NoExceptions, noexcept
|
||||
Override, override
|
||||
Pure, = 0
|
||||
Volatile, volatile
|
|
99
gen_unreal_engine/enums/ETokType.csv
Normal file
99
gen_unreal_engine/enums/ETokType.csv
Normal file
@ -0,0 +1,99 @@
|
||||
Invalid, "__invalid__"
|
||||
Access_Private, "private"
|
||||
Access_Protected, "protected"
|
||||
Access_Public, "public"
|
||||
Access_MemberSymbol, "."
|
||||
Access_StaticSymbol, "::"
|
||||
Ampersand, "&"
|
||||
Ampersand_DBL, "&&"
|
||||
Assign_Classifer, ":"
|
||||
Attribute_Open, "[["
|
||||
Attribute_Close, "]]"
|
||||
BraceCurly_Open, "{"
|
||||
BraceCurly_Close, "}"
|
||||
BraceSquare_Open, "["
|
||||
BraceSquare_Close, "]"
|
||||
Paren_Open, "("
|
||||
Paren_Close, ")"
|
||||
Comment, "__comment__"
|
||||
Comment_End, "__comment_end__"
|
||||
Comment_Start, "__comment_start__"
|
||||
Char, "__character__"
|
||||
Comma, ","
|
||||
Decl_Class, "class"
|
||||
Decl_GNU_Attribute, "__attribute__"
|
||||
Decl_MSVC_Attribute, "__declspec"
|
||||
Decl_Enum, "enum"
|
||||
Decl_Extern_Linkage, "extern"
|
||||
Decl_Friend, "friend"
|
||||
Decl_Module, "module"
|
||||
Decl_Namespace, "namespace"
|
||||
Decl_Operator, "operator"
|
||||
Decl_Struct, "struct"
|
||||
Decl_Template, "template"
|
||||
Decl_Typedef, "typedef"
|
||||
Decl_Using, "using"
|
||||
Decl_Union, "union"
|
||||
Identifier, "__identifier__"
|
||||
Module_Import, "import"
|
||||
Module_Export, "export"
|
||||
NewLine, "__new_line__"
|
||||
Number, "__number__"
|
||||
Operator, "__operator__"
|
||||
Preprocess_Hash, "#"
|
||||
Preprocess_Define, "define"
|
||||
Preprocess_Define_Param, "__define_param__"
|
||||
Preprocess_If, "if"
|
||||
Preprocess_IfDef, "ifdef"
|
||||
Preprocess_IfNotDef, "ifndef"
|
||||
Preprocess_ElIf, "elif"
|
||||
Preprocess_Else, "else"
|
||||
Preprocess_EndIf, "endif"
|
||||
Preprocess_Include, "include"
|
||||
Preprocess_Pragma, "pragma"
|
||||
Preprocess_Content, "__macro_content__"
|
||||
Preprocess_Macro_Expr, "__macro_expression__"
|
||||
Preprocess_Macro_Stmt, "__macro_statment__"
|
||||
Preprocess_Macro_Typename, "__macro_typename__"
|
||||
Preprocess_Unsupported, "__unsupported__"
|
||||
Spec_Alignas, "alignas"
|
||||
Spec_Const, "const"
|
||||
Spec_Consteval, "consteval"
|
||||
Spec_Constexpr, "constexpr"
|
||||
Spec_Constinit, "constinit"
|
||||
Spec_Explicit, "explicit"
|
||||
Spec_Extern, "extern"
|
||||
Spec_Final, "final"
|
||||
Spec_ForceInline, "FORCEINLINE"
|
||||
Spec_ForceInline_Debuggable, "FORCEINLINE_DEBUGGABLE"
|
||||
Spec_Global, "global"
|
||||
Spec_Inline, "inline"
|
||||
Spec_Internal_Linkage, "internal"
|
||||
Spec_LocalPersist, "local_persist"
|
||||
Spec_Mutable, "mutable"
|
||||
Spec_NeverInline, "neverinline"
|
||||
Spec_Override, "override"
|
||||
Spec_Static, "static"
|
||||
Spec_ThreadLocal, "thread_local"
|
||||
Spec_Volatile, "volatile"
|
||||
Spec_Virtual, "virtual"
|
||||
Star, "*"
|
||||
Statement_End, ";"
|
||||
StaticAssert, "static_assert"
|
||||
String, "__string__"
|
||||
Type_Typename, "typename"
|
||||
Type_Unsigned, "unsigned"
|
||||
Type_Signed, "signed"
|
||||
Type_Short, "short"
|
||||
Type_Long, "long"
|
||||
Type_bool, "bool"
|
||||
Type_char, "char"
|
||||
Type_int, "int"
|
||||
Type_double, "double"
|
||||
Type_MS_int8, "__int8"
|
||||
Type_MS_int16, "__int16"
|
||||
Type_MS_int32, "__int32"
|
||||
Type_MS_int64, "__int64"
|
||||
Type_MS_W64, "_W64"
|
||||
Varadic_Argument, "..."
|
||||
__Attributes_Start, "__attrib_start__"
|
|
@ -1,6 +1,5 @@
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#include "gen.cpp"
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
|
||||
@ -64,6 +63,46 @@ int gen_main()
|
||||
Code ue_forceinline = code_str(FORCEINLINE);
|
||||
// Code
|
||||
|
||||
register_macros( args(
|
||||
(Macro { txt("bit"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("bitfield_is_set"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_C_LIKE_CPP"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("cast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("ccast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("rcast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("pcast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("scast"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("stringize_va"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("stringize"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("do_once"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("do_once_defer"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("do_once_start"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("do_once_end"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("labeled_scope_start"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("labeled_scope_end"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("compiler_decorated_func_name"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("num_args_impl"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("num_args"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("count_of"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("clamp"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("is_between"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("size_of"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("min"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("max"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("offset_of"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("static_assert"), MT_Statement, MF_Functional }),
|
||||
(Macro { txt("typeof"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("GEN_API_C_BEGIN"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("GEN_API_C_END"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("nullptr"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("GEN_REMOVE_PTR"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_PARAM_DEFAULT"), MT_Expression, MF_Null }),
|
||||
(Macro { txt("struct_init"), MT_Expression, MF_Functional }),
|
||||
(Macro { txt("GEN_OPTIMIZE_MAPPINGS_BEGIN"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("GEN_OPITMIZE_MAPPINGS_END"), MT_Statement, MF_Null }),
|
||||
(Macro { txt("src_line_str"), MT_Expression, MF_Null })
|
||||
));
|
||||
|
||||
// gen_dep.hpp
|
||||
{
|
||||
CodeBody macros = def_body( CT_Global_Body );
|
||||
@ -108,6 +147,7 @@ int gen_main()
|
||||
Code strings = scan_file( path_base "dependencies/strings.hpp" );
|
||||
Code filesystem = scan_file( path_base "dependencies/filesystem.hpp" );
|
||||
Code timing = scan_file( path_base "dependencies/timing.hpp" );
|
||||
Code parsing = scan_file( path_base "dependencies/parsing.hpp" );
|
||||
|
||||
Builder
|
||||
header = Builder::open("gen/gen.dep.hpp");
|
||||
@ -129,6 +169,7 @@ int gen_main()
|
||||
header.print( strings );
|
||||
header.print( filesystem );
|
||||
header.print( timing );
|
||||
header.print(parsing);
|
||||
|
||||
header.print_fmt( "\nGEN_NS_END\n" );
|
||||
header.print( fmt_newline );
|
||||
@ -147,6 +188,7 @@ int gen_main()
|
||||
Code strings = scan_file( path_base "dependencies/strings.cpp" );
|
||||
Code filesystem = scan_file( path_base "dependencies/filesystem.cpp" );
|
||||
Code timing = scan_file( path_base "dependencies/timing.cpp" );
|
||||
Code parsing = scan_file( path_base "dependencies/parsing.cpp" );
|
||||
|
||||
Builder
|
||||
src = Builder::open( "gen/gen.dep.cpp" );
|
||||
@ -165,6 +207,7 @@ int gen_main()
|
||||
src.print( strings );
|
||||
src.print( filesystem );
|
||||
src.print( timing );
|
||||
src.print( parsing );
|
||||
|
||||
src.print_fmt( "\nGEN_NS_END\n" );
|
||||
src.print( fmt_newline );
|
||||
@ -186,13 +229,13 @@ int gen_main()
|
||||
|
||||
CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" );
|
||||
CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" );
|
||||
CodeBody especifier = gen_especifier( path_base "enums/ESpecifier.csv" );
|
||||
CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" );
|
||||
CodeBody ast_inlines = gen_ast_inlines();
|
||||
|
||||
// Note(Ed): The Attribute tokens need to be expanded and regenerated on a per-project/installation of this library for a specific codebase of Unreal.
|
||||
// We can support an arbitrary set of modules or plugin apis for parsing
|
||||
// but its up to the user to define them all (This will just provide whats I've used up till now).
|
||||
CodeBody etoktype = gen_etoktype( path_base "enums/ETokType.csv", "enums/AttributeTokens.csv" );
|
||||
CodeBody etoktype = gen_etoktype( "enums/ETokType.csv", "enums/AttributeTokens.csv" );
|
||||
|
||||
Builder
|
||||
header = Builder::open( "gen/gen.hpp" );
|
||||
@ -247,6 +290,7 @@ int gen_main()
|
||||
Code interface = scan_file( path_base "components/interface.cpp" );
|
||||
Code upfront = scan_file( path_base "components/interface.upfront.cpp" );
|
||||
Code lexer = scan_file( path_base "components/lexer.cpp" );
|
||||
Code parser_case_macros = scan_file( "components/parser_case_macros.cpp" );
|
||||
Code parser = scan_file( path_base "components/parser.cpp" );
|
||||
Code parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
|
||||
Code untyped = scan_file( path_base "components/interface.untyped.cpp" );
|
||||
@ -270,13 +314,20 @@ int gen_main()
|
||||
|
||||
src.print_fmt( "\n#pragma region Interface\n" );
|
||||
src.print( interface );
|
||||
|
||||
src.print( upfront );
|
||||
|
||||
src.print_fmt( "\n#pragma region Parsing\n\n" );
|
||||
src.print( lexer );
|
||||
src.print( parser_case_macros );
|
||||
src.print( parser );
|
||||
src.print( parsing_interface );
|
||||
src.print( untyped );
|
||||
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( "GEN_NS_END\n\n");
|
||||
@ -323,7 +374,6 @@ int gen_main()
|
||||
|
||||
// gen_scanner.hpp
|
||||
{
|
||||
Code parsing = scan_file( path_base "dependencies/parsing.hpp" );
|
||||
Code scanner = scan_file( path_base "auxillary/scanner.hpp" );
|
||||
|
||||
Builder
|
||||
@ -334,7 +384,6 @@ int gen_main()
|
||||
header.print( fmt_newline );
|
||||
header.print( def_include( txt("gen.hpp") ) );
|
||||
header.print_fmt( "\nGEN_NS_BEGIN\n" );
|
||||
header.print( parsing );
|
||||
header.print( scanner );
|
||||
header.print_fmt( "\nGEN_NS_END\n" );
|
||||
header.print( fmt_newline );
|
||||
@ -344,7 +393,6 @@ int gen_main()
|
||||
|
||||
// gen.scanner.cpp
|
||||
{
|
||||
Code parsing = scan_file( path_base "dependencies/parsing.cpp" );
|
||||
Code scanner = scan_file( path_base "auxillary/scanner.cpp" );
|
||||
|
||||
Builder
|
||||
@ -354,8 +402,7 @@ int gen_main()
|
||||
src.print( fmt_newline );
|
||||
src.print( def_include( txt("gen.scanner.hpp") ) );
|
||||
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_newline );
|
||||
src.print( pop_ignores );
|
||||
|
79
gencpp.10x
79
gencpp.10x
@ -1,79 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<N10X>
|
||||
<Workspace>
|
||||
<IncludeFilter>&apos;.&apos;,**/project/**,</IncludeFilter>
|
||||
<ExcludeFilter>*.obj,*.lib,*.pch,*.dll,*.pdb,.vs,Debug,Release,x64,obj,*.user,Intermediate,**/sanity.gen.hpp,**/gen_c_library,**/gen_segmented,**/gen_singlheader,**/test,**/gen_unreal_engine,**/scripts,**/docs,</ExcludeFilter>
|
||||
<SyncFiles>true</SyncFiles>
|
||||
<Recursive>true</Recursive>
|
||||
<ShowEmptyFolders>true</ShowEmptyFolders>
|
||||
<IncludeFilesWithoutExt>false</IncludeFilesWithoutExt>
|
||||
<IsVirtual>false</IsVirtual>
|
||||
<IsFolder>false</IsFolder>
|
||||
<BuildCommand>pwsh ./scripts/build.ps1 msvc debug bootstrap</BuildCommand>
|
||||
<RebuildCommand>pwsh ./scripts/build.ps1 msvc debug c_library</RebuildCommand>
|
||||
<BuildFileCommand></BuildFileCommand>
|
||||
<CleanCommand>pwsh ./scripts/clean.ps1</CleanCommand>
|
||||
<BuildWorkingDirectory></BuildWorkingDirectory>
|
||||
<CancelBuild></CancelBuild>
|
||||
<Exe>./test/gen/build/gencpp.exe</Exe>
|
||||
<Args></Args>
|
||||
<WorkingDirectory></WorkingDirectory>
|
||||
<DebugCommand>pwsh ./scripts/build.ps1</DebugCommand>
|
||||
<DebugSln></DebugSln>
|
||||
<UseVisualStudioEnvBat>true</UseVisualStudioEnvBat>
|
||||
<CaptureExeOutput>false</CaptureExeOutput>
|
||||
<Configurations>
|
||||
<Configuration>Debug</Configuration>
|
||||
<Configuration>Release</Configuration>
|
||||
<Configuration>bootstrap debug</Configuration>
|
||||
</Configurations>
|
||||
<Platforms>
|
||||
<Platform>x64</Platform>
|
||||
</Platforms>
|
||||
<AdditionalIncludePaths>
|
||||
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\include</AdditionalIncludePath>
|
||||
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\ATLMFC\include</AdditionalIncludePath>
|
||||
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\VS\include</AdditionalIncludePath>
|
||||
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt</AdditionalIncludePath>
|
||||
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um</AdditionalIncludePath>
|
||||
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared</AdditionalIncludePath>
|
||||
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt</AdditionalIncludePath>
|
||||
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt</AdditionalIncludePath>
|
||||
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um</AdditionalIncludePath>
|
||||
</AdditionalIncludePaths>
|
||||
<Defines>
|
||||
<Define>GEN_TIME</Define>
|
||||
<Define>GEN_SYSTEM_WINDOWS</Define>
|
||||
<Define>GEN_INTELLISENSE_DIRECTIVES</Define>
|
||||
<Define>GEN_EXECUTION_EXPRESSION_SUPPORT</Define>
|
||||
<Define>GEN_BENCHMARK</Define>
|
||||
<Define>GEN_COMPILER_MSVC</Define>
|
||||
<Define>GEN_IMPLEMENTATION</Define>
|
||||
</Defines>
|
||||
<ConfigProperties>
|
||||
<ConfigAndPlatform>
|
||||
<Name>Debug:x64</Name>
|
||||
<Defines></Defines>
|
||||
<ForceIncludes></ForceIncludes>
|
||||
</ConfigAndPlatform>
|
||||
<ConfigAndPlatform>
|
||||
<Name>bootstrap debug:x64</Name>
|
||||
<Defines></Defines>
|
||||
<ForceIncludes></ForceIncludes>
|
||||
</ConfigAndPlatform>
|
||||
<Config>
|
||||
<Name>Debug</Name>
|
||||
<Defines></Defines>
|
||||
</Config>
|
||||
<Config>
|
||||
<Name>bootstrap debug</Name>
|
||||
<Defines></Defines>
|
||||
</Config>
|
||||
<Platform>
|
||||
<Name>x64</Name>
|
||||
<Defines></Defines>
|
||||
</Platform>
|
||||
</ConfigProperties>
|
||||
<Children></Children>
|
||||
</Workspace>
|
||||
</N10X>
|
48
gencpp.sln
48
gencpp.sln
@ -1,48 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.33516.290
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gencpp", "gencpp.vcxproj", "{53AF600D-C09C-4F39-83E0-E022AA9479F2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
bootstrap debug|x64 = bootstrap debug|x64
|
||||
bootstrap debug|x86 = bootstrap debug|x86
|
||||
bootstrap release|x64 = bootstrap release|x64
|
||||
bootstrap release|x86 = bootstrap release|x86
|
||||
singleheader debug|x64 = singleheader debug|x64
|
||||
singleheader debug|x86 = singleheader debug|x86
|
||||
singleheader release|x64 = singleheader release|x64
|
||||
singleheader release|x86 = singleheader release|x86
|
||||
test debug|x64 = test debug|x64
|
||||
test debug|x86 = test debug|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x64.ActiveCfg = bootstrap release|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x64.Build.0 = bootstrap release|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x86.ActiveCfg = bootstrap debug|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x86.Build.0 = bootstrap debug|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x64.ActiveCfg = bootstrap release|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x86.ActiveCfg = bootstrap release|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x86.Build.0 = bootstrap release|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x64.ActiveCfg = singleheader debug|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x64.Build.0 = singleheader debug|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x86.ActiveCfg = singleheader debug|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x86.Build.0 = singleheader debug|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x64.ActiveCfg = bootstrap debug|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x64.Build.0 = bootstrap debug|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x86.ActiveCfg = singleheader release|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x86.Build.0 = singleheader release|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x64.ActiveCfg = test debug|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x64.Build.0 = test debug|x64
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x86.ActiveCfg = test debug|Win32
|
||||
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x86.Build.0 = test debug|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B12D2F1D-037C-44E1-B24B-2612E3DE0193}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,3 +0,0 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:StrBuilder x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=53AF600D_002DC09C_002D4F39_002D83E0_002DE022AA9479F2_002Fd_003Athirdparty_002Ff_003Azpl_002Eh/@EntryIndexedValue">ForceIncluded</s:StrBuilder>
|
||||
<s:StrBuilder x:Key="/Default/CodeInspection/Highlighting/SweaWarningsMode/@EntryValue">ShowAndRun</s:StrBuilder></wpf:ResourceDictionary>
|
376
gencpp.vcxproj
376
gencpp.vcxproj
@ -1,376 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="bootstrap debug|Win32">
|
||||
<Configuration>bootstrap debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="bootstrap debug|x64">
|
||||
<Configuration>bootstrap debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="bootstrap release|Win32">
|
||||
<Configuration>bootstrap release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="bootstrap release|x64">
|
||||
<Configuration>bootstrap release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="singleheader debug|Win32">
|
||||
<Configuration>singleheader debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="singleheader debug|x64">
|
||||
<Configuration>singleheader debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="singleheader release|Win32">
|
||||
<Configuration>singleheader release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="singleheader release|x64">
|
||||
<Configuration>singleheader release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="test debug|Win32">
|
||||
<Configuration>test debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="test debug|x64">
|
||||
<Configuration>test debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<ProjectGuid>{53AF600D-C09C-4F39-83E0-E022AA9479F2}</ProjectGuid>
|
||||
<Keyword>MakeFileProj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'">
|
||||
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
|
||||
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
|
||||
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
|
||||
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'">
|
||||
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
|
||||
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
|
||||
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
|
||||
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'">
|
||||
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
|
||||
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
|
||||
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
|
||||
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'">
|
||||
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
|
||||
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
|
||||
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
|
||||
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'">
|
||||
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
|
||||
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
|
||||
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
|
||||
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
|
||||
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug bootstrap</NMakeBuildCommandLine>
|
||||
<NMakeReBuildCommandLine>
|
||||
</NMakeReBuildCommandLine>
|
||||
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
|
||||
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<IncludePath>$(ProjectDir)project;$(IncludePath)</IncludePath>
|
||||
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
|
||||
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug test</NMakeBuildCommandLine>
|
||||
<NMakeReBuildCommandLine />
|
||||
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
|
||||
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
|
||||
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
|
||||
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug singleheader</NMakeBuildCommandLine>
|
||||
<NMakeReBuildCommandLine>
|
||||
</NMakeReBuildCommandLine>
|
||||
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
|
||||
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
|
||||
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
|
||||
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc release singleheader</NMakeBuildCommandLine>
|
||||
<NMakeReBuildCommandLine>
|
||||
</NMakeReBuildCommandLine>
|
||||
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
|
||||
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
|
||||
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
|
||||
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc release bootstrap</NMakeBuildCommandLine>
|
||||
<NMakeReBuildCommandLine>
|
||||
</NMakeReBuildCommandLine>
|
||||
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
|
||||
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
|
||||
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
|
||||
<ClCompile>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
|
||||
<ClCompile>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
|
||||
<ClCompile>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
|
||||
<ClCompile>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
|
||||
<ClCompile>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include=".editorconfig" />
|
||||
<None Include="project\enums\AttributeTokens.csv" />
|
||||
<None Include="project\enums\ECode.csv" />
|
||||
<None Include="project\enums\EOperator.csv" />
|
||||
<None Include="project\enums\ESpecifier.csv" />
|
||||
<None Include="project\enums\ETokType.csv" />
|
||||
<None Include="Readme.md" />
|
||||
<None Include="scripts\.clang-format" />
|
||||
<None Include="scripts\build.ci.ps1" />
|
||||
<None Include="scripts\build.ps1" />
|
||||
<None Include="scripts\clean.ps1" />
|
||||
<None Include="scripts\genccp.natstepfilter" />
|
||||
<None Include="scripts\gencpp.refactor" />
|
||||
<None Include="scripts\helpers\devshell.ps1" />
|
||||
<None Include="scripts\helpers\target_arch.psm1" />
|
||||
<None Include="scripts\package_release.ps1" />
|
||||
<None Include="scripts\refactor.ps1" />
|
||||
<None Include="test\gen\meson.build" />
|
||||
<None Include="test\meson.build" />
|
||||
<None Include="test\Readme.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="gen_c_library\gen\gen.h" />
|
||||
<ClInclude Include="project\auxillary\builder.hpp" />
|
||||
<ClInclude Include="project\auxillary\editor.hpp" />
|
||||
<ClInclude Include="project\auxillary\scanner.hpp" />
|
||||
<ClInclude Include="project\components\ast.hpp" />
|
||||
<ClInclude Include="project\components\ast_types.hpp" />
|
||||
<ClInclude Include="project\components\code_types.hpp" />
|
||||
<ClInclude Include="project\components\gen\ast_inlines.hpp" />
|
||||
<ClInclude Include="project\components\gen\ecode.hpp" />
|
||||
<ClInclude Include="project\components\gen\eoperator.hpp" />
|
||||
<ClInclude Include="project\components\gen\especifier.hpp" />
|
||||
<ClInclude Include="project\components\header_end.hpp" />
|
||||
<ClInclude Include="project\components\header_start.hpp" />
|
||||
<ClInclude Include="project\components\inlines.hpp" />
|
||||
<ClInclude Include="project\components\interface.hpp" />
|
||||
<ClInclude Include="project\components\types.hpp" />
|
||||
<ClInclude Include="project\dependencies\basic_types.hpp" />
|
||||
<ClInclude Include="project\dependencies\containers.hpp" />
|
||||
<ClInclude Include="project\dependencies\debug.hpp" />
|
||||
<ClInclude Include="project\dependencies\filesystem.hpp" />
|
||||
<ClInclude Include="project\dependencies\hashing.hpp" />
|
||||
<ClInclude Include="project\dependencies\header_start.hpp" />
|
||||
<ClInclude Include="project\dependencies\macros.hpp" />
|
||||
<ClInclude Include="project\dependencies\memory.hpp" />
|
||||
<ClInclude Include="project\dependencies\parsing.hpp" />
|
||||
<ClInclude Include="project\dependencies\printing.hpp" />
|
||||
<ClInclude Include="project\dependencies\strings.hpp" />
|
||||
<ClInclude Include="project\dependencies\string_ops.hpp" />
|
||||
<ClInclude Include="project\dependencies\timing.hpp" />
|
||||
<ClInclude Include="project\gen.dep.hpp" />
|
||||
<ClInclude Include="project\gen.hpp" />
|
||||
<ClInclude Include="project\helpers\helper.hpp" />
|
||||
<ClInclude Include="project\helpers\pop_ignores.inline.hpp" />
|
||||
<ClInclude Include="project\helpers\push_ignores.inline.hpp" />
|
||||
<ClInclude Include="project\helpers\undef.macros.hpp" />
|
||||
<ClInclude Include="singleheader\components\header_start.hpp" />
|
||||
<ClInclude Include="test\CURSED_TYPEDEF.h" />
|
||||
<ClInclude Include="test\DummyInclude.hpp" />
|
||||
<ClInclude Include="test\Parsed\Buffer.Parsed.hpp" />
|
||||
<ClInclude Include="test\Parsed\HashTable.Parsed.hpp" />
|
||||
<ClInclude Include="test\Parsed\Ring.Parsed.hpp" />
|
||||
<ClInclude Include="test\parsing.hpp" />
|
||||
<ClInclude Include="test\SOA.hpp" />
|
||||
<ClInclude Include="test\upfront.hpp" />
|
||||
<ClInclude Include="test\Upfront\Array.Upfront.hpp" />
|
||||
<ClInclude Include="test\Upfront\Buffer.Upfront.hpp" />
|
||||
<ClInclude Include="test\Upfront\HashTable.Upfront.hpp" />
|
||||
<ClInclude Include="test\Upfront\Ring.Upfront.hpp" />
|
||||
<ClInclude Include="test\Upfront\Sanity.Upfront.hpp" />
|
||||
<ClInclude Include="test\Parsed\Array.Parsed.hpp" />
|
||||
<ClInclude Include="test\Parsed\Sanity.Parsed.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="project\auxillary\builder.cpp" />
|
||||
<ClCompile Include="project\auxillary\scanner.cpp" />
|
||||
<ClCompile Include="project\bootstrap.cpp" />
|
||||
<ClCompile Include="project\components\ast.cpp" />
|
||||
<ClCompile Include="project\components\ast_case_macros.cpp" />
|
||||
<ClCompile Include="project\components\code_serialization.cpp" />
|
||||
<ClCompile Include="project\components\gen\etoktype.cpp" />
|
||||
<ClCompile Include="project\components\interface.cpp" />
|
||||
<ClCompile Include="project\components\interface.parsing.cpp" />
|
||||
<ClCompile Include="project\components\interface.untyped.cpp" />
|
||||
<ClCompile Include="project\components\interface.upfront.cpp" />
|
||||
<ClCompile Include="project\components\lexer.cpp" />
|
||||
<ClCompile Include="project\components\parser.cpp" />
|
||||
<ClCompile Include="project\components\src_start.cpp" />
|
||||
<ClCompile Include="project\components\static_data.cpp" />
|
||||
<ClCompile Include="project\dependencies\debug.cpp" />
|
||||
<ClCompile Include="project\dependencies\filesystem.cpp" />
|
||||
<ClCompile Include="project\dependencies\hashing.cpp" />
|
||||
<ClCompile Include="project\dependencies\memory.cpp" />
|
||||
<ClCompile Include="project\dependencies\parsing.cpp" />
|
||||
<ClCompile Include="project\dependencies\printing.cpp" />
|
||||
<ClCompile Include="project\dependencies\src_start.cpp" />
|
||||
<ClCompile Include="project\dependencies\strings.cpp" />
|
||||
<ClCompile Include="project\dependencies\string_ops.cpp" />
|
||||
<ClCompile Include="project\dependencies\timing.cpp" />
|
||||
<ClCompile Include="project\Example.cpp" />
|
||||
<ClCompile Include="project\gen.cpp" />
|
||||
<ClCompile Include="project\gen.dep.cpp" />
|
||||
<ClCompile Include="singleheader\singleheader.cpp" />
|
||||
<ClCompile Include="test\parsed\test.parsing.cpp" />
|
||||
<ClCompile Include="test\parsing.cpp" />
|
||||
<ClCompile Include="test\sanity.cpp" />
|
||||
<ClCompile Include="test\SOA.cpp" />
|
||||
<ClCompile Include="test\test.cpp" />
|
||||
<ClCompile Include="test\test.parsing.cpp" />
|
||||
<ClCompile Include="test\test.singleheader_ast.cpp" />
|
||||
<ClCompile Include="test\test.Upfront.cpp" />
|
||||
<ClCompile Include="test\upfront.cpp" />
|
||||
<ClCompile Include="test\upfront\test.upfront.cpp" />
|
||||
<ClCompile Include="test\validate_bootstrap.cpp" />
|
||||
<ClCompile Include="test\validate_singleheader.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include=".vscode\gencpp.natvis" />
|
||||
<Natvis Include="scripts\gencpp.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="project\enums\AttributeTokens.csv" />
|
||||
<Content Include="project\enums\ECode.csv" />
|
||||
<Content Include="project\enums\EOperator.csv" />
|
||||
<Content Include="project\enums\ESpecifier.csv" />
|
||||
<Content Include="project\enums\ETokType.csv" />
|
||||
<Content Include="scripts\.clang-format" />
|
||||
<Content Include="scripts\helpers\devshell.ps1" />
|
||||
<Content Include="scripts\helpers\target_arch.psm1" />
|
||||
<Content Include="scripts\refactor.ps1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="singleheader\gen\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,320 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="project\gen.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\test.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\test.Upfront.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\gen.dep.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\parsing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\sanity.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\SOA.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\upfront.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\test.parsing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\ast.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\ast_case_macros.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\interface.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\interface.parsing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\interface.upfront.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\src_start.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\static_data.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\bootstrap.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\debug.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\filesystem.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\hashing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\memory.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\parsing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\printing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\src_start.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\string_ops.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\strings.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\dependencies\timing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\auxillary\builder.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\auxillary\scanner.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="singleheader\singleheader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\test.singleheader_ast.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\parsed\test.parsing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\upfront\test.upfront.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\validate_singleheader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test\validate_bootstrap.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\interface.untyped.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\gen\etoktype.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\Example.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\parser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\lexer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="project\components\code_serialization.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="project\gen.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\DummyInclude.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Parsed\Buffer.Parsed.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Parsed\HashTable.Parsed.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Parsed\Ring.Parsed.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\SOA.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Upfront\Array.Upfront.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Upfront\Buffer.Upfront.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Upfront\HashTable.Upfront.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Upfront\Ring.Upfront.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Upfront\Sanity.Upfront.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Parsed\Array.Parsed.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\Parsed\Sanity.Parsed.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\gen.dep.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\parsing.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\upfront.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\ast.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\ast_types.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\header_end.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\header_start.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\inlines.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\interface.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\types.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\helpers\helper.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\helpers\pop_ignores.inline.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\helpers\push_ignores.inline.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\helpers\undef.macros.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\basic_types.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\containers.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\debug.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\filesystem.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\hashing.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\header_start.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\macros.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\memory.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\parsing.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\printing.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\string_ops.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\strings.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\dependencies\timing.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\auxillary\builder.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\auxillary\editor.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\auxillary\scanner.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="singleheader\components\header_start.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\gen\ast_inlines.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\gen\ecode.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\gen\eoperator.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\gen\especifier.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test\CURSED_TYPEDEF.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="project\components\code_types.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include=".editorconfig" />
|
||||
<None Include="Readme.md" />
|
||||
<None Include="scripts\build.ci.ps1" />
|
||||
<None Include="scripts\build.ps1" />
|
||||
<None Include="scripts\clean.ps1" />
|
||||
<None Include="test\gen\meson.build" />
|
||||
<None Include="test\meson.build" />
|
||||
<None Include="test\Readme.md" />
|
||||
<None Include="scripts\genccp.natstepfilter" />
|
||||
<None Include="scripts\gencpp.refactor" />
|
||||
<None Include="project\enums\AttributeTokens.csv" />
|
||||
<None Include="project\enums\ECode.csv" />
|
||||
<None Include="project\enums\EOperator.csv" />
|
||||
<None Include="project\enums\ESpecifier.csv" />
|
||||
<None Include="project\enums\ETokType.csv" />
|
||||
<None Include="scripts\helpers\devshell.ps1" />
|
||||
<None Include="scripts\helpers\target_arch.psm1" />
|
||||
<None Include="scripts\package_release.ps1" />
|
||||
<None Include="scripts\refactor.ps1" />
|
||||
<None Include="scripts\.clang-format" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include=".vscode\gencpp.natvis" />
|
||||
<Natvis Include="scripts\gencpp.natvis" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
|
||||
<LocalDebuggerAttach>false</LocalDebuggerAttach>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
|
||||
<LocalDebuggerAttach>false</LocalDebuggerAttach>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
|
||||
<LocalDebuggerAttach>false</LocalDebuggerAttach>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
|
||||
<LocalDebuggerAttach>false</LocalDebuggerAttach>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
|
||||
<LocalDebuggerAttach>false</LocalDebuggerAttach>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -15,11 +15,13 @@ Its main uage is the [c_library generation](../gen_c_library/).
|
||||
Remove any generated content from the repository.
|
||||
|
||||
**`build.ps1`**
|
||||
Build c_library, segmented, singleheader, unreal. Supports msvc or clang, release or debug.
|
||||
Build c library (segmented, singleheader, static, or dynamic), cpp library (segmented, singleheader, or unreal). Supports msvc or clang, release or debug.
|
||||
|
||||
```
|
||||
```erlang
|
||||
args:
|
||||
c_library
|
||||
c_lib : Build c11 library (singleheader & segmented)
|
||||
c_lib_static : Build static c11 library
|
||||
c_lib_dyn : Buidl dyanmic c11
|
||||
segemented
|
||||
singleheader
|
||||
unreal
|
||||
|
@ -325,18 +325,23 @@ if ( $unreal )
|
||||
. $refactor_unreal
|
||||
}
|
||||
|
||||
if ( $test )
|
||||
# C Library testing
|
||||
if ( $test -and $false )
|
||||
{
|
||||
$path_test_c_lib = join-path $path_test c_library
|
||||
$path_build = join-path $path_test_c_lib build
|
||||
|
||||
$path_test_c = join-path $path_test c_library
|
||||
$path_build = join-path $path_test_c build
|
||||
$path_gen = join-path $path_test_c gen
|
||||
if ( -not(Test-Path($path_build) )) {
|
||||
New-Item -ItemType Directory -Path $path_build
|
||||
}
|
||||
if ( -not(Test-Path($path_gen) )) {
|
||||
New-Item -ItemType Directory -Path $path_gen
|
||||
}
|
||||
|
||||
$includes = @( $path_c_library )
|
||||
$unit = join-path $path_test_c_lib "gen.c"
|
||||
$executable = join-path $path_build "gen_c_library_test.exe"
|
||||
$path_singleheader_include = join-path $path_c_library gen
|
||||
$includes = @( $path_singleheader_include )
|
||||
$unit = join-path $path_test_c "test.c"
|
||||
$executable = join-path $path_build "test.exe"
|
||||
|
||||
$compiler_args = @()
|
||||
$compiler_args += ( $flag_define + 'GEN_TIME' )
|
||||
@ -350,7 +355,7 @@ if ( $test )
|
||||
|
||||
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
|
||||
|
||||
Push-Location $path_test_c_lib
|
||||
Push-Location $path_test_c
|
||||
if ( Test-Path( $executable ) ) {
|
||||
write-host "`nRunning c_library test"
|
||||
$time_taken = Measure-Command { & $executable
|
||||
@ -362,6 +367,45 @@ if ( $test )
|
||||
}
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
if ($test -and $true)
|
||||
{
|
||||
$path_test_cpp = join-path $path_test cpp_library
|
||||
$path_build = join-path $path_test_cpp build
|
||||
$path_gen = join-path $path_test_cpp gen
|
||||
if ( -not(Test-Path($path_build) )) {
|
||||
New-Item -ItemType Directory -Path $path_build
|
||||
}
|
||||
if ( -not(Test-Path($path_gen) )) {
|
||||
New-Item -ItemType Directory -Path $path_gen
|
||||
}
|
||||
|
||||
$path_singleheader_include = join-path $path_singleheader gen
|
||||
$includes = @( $path_singleheader_include )
|
||||
$unit = join-path $path_test_cpp "test.cpp"
|
||||
$executable = join-path $path_build "test.exe"
|
||||
|
||||
$compiler_args = @()
|
||||
$compiler_args += ( $flag_define + 'GEN_TIME' )
|
||||
|
||||
$linker_args = @(
|
||||
$flag_link_win_subsystem_console
|
||||
)
|
||||
|
||||
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
|
||||
|
||||
Push-Location $path_test_cpp
|
||||
if ( Test-Path( $executable ) ) {
|
||||
write-host "`nRunning cpp_library test"
|
||||
$time_taken = Measure-Command { & $executable
|
||||
| ForEach-Object {
|
||||
write-host `t $_ -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
write-host "`nc_library generator completed in $($time_taken.TotalMilliseconds) ms"
|
||||
}
|
||||
Pop-Location
|
||||
}
|
||||
#endregion Building
|
||||
|
||||
Pop-Location # $path_root
|
||||
|
@ -1,9 +0,0 @@
|
||||
#define GEN_IMPLEMENTATION
|
||||
#include "gen/gen_singleheader.h"
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
// init();
|
||||
__debugbreak();
|
||||
return 0;
|
||||
}
|
32
test/c_library/test.c
Normal file
32
test/c_library/test.c
Normal file
@ -0,0 +1,32 @@
|
||||
#define GEN_IMPLEMENTATION
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#include "gen_singleheader.h"
|
||||
|
||||
#define gen_iterator( Type, container, iter ) \
|
||||
gen_begin_ ## Type(container); \
|
||||
iter != gen_end_ ## Type(container); \
|
||||
code = gen_next_ ## Type(container, iter)
|
||||
|
||||
int main()
|
||||
{
|
||||
gen_Context ctx = {0};
|
||||
gen_init(& ctx);
|
||||
|
||||
gen_Builder src_hello = gen_builder_open("gen/hello.c");
|
||||
gen_CodeVar hello_var = gen_parse_variable(code(
|
||||
char const* hello_gencpp_str = "HELLO GENCPP C11 !";
|
||||
));
|
||||
gen_builder_print( & src_hello, (gen_Code)hello_var );
|
||||
gen_builder_write(& src_hello);
|
||||
|
||||
gen_CodeBody body = gen_parse_file("gen/hello.c");
|
||||
for (gen_Code code = gen_iterator(CodeBody, body, code)) switch (code->Type) {
|
||||
case CT_Variable:
|
||||
gen_CodeVar var = (gen_CodeVar) code;
|
||||
gen_log_fmt("%S", var->Value);
|
||||
break;
|
||||
}
|
||||
|
||||
gen_deinit(& ctx);
|
||||
return 0;
|
||||
}
|
29
test/cpp_library/test.cpp
Normal file
29
test/cpp_library/test.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#define GEN_IMPLEMENTATION
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#include "gen.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace gen;
|
||||
Context ctx = {};
|
||||
gen::init( & ctx);
|
||||
|
||||
Builder src_hello = builder_open("gen/hello.cpp");
|
||||
CodeVar hello_var = parse_variable( code(
|
||||
constexpr char const* hello_gencpp_str = "HELLO GENCPP !";
|
||||
));
|
||||
src_hello.print(hello_var);
|
||||
src_hello.write();
|
||||
|
||||
CodeBody body = parse_file("gen/hello.cpp");
|
||||
for ( Code code : body ) switch (code->Type) {
|
||||
case CT_Variable:
|
||||
CodeVar var = cast(CodeVar, code);
|
||||
log_fmt("%S", var->Value);
|
||||
break;
|
||||
}
|
||||
|
||||
gen::deinit(& ctx);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user