latest gencpp

This commit is contained in:
Edward R. Gonzalez 2024-12-16 21:05:13 -05:00
parent 3109ea4641
commit a4969ee266
11 changed files with 1699 additions and 999 deletions

View File

@ -128,8 +128,8 @@ void Execute_GasaModule_Codegen()
generate_AttributeSets(); generate_AttributeSets();
generate_DevOptionsCache(); generate_DevOptionsCache();
// generate_HostWidgetController(); // generate_HostWidgetController();
change_SBlueprintActionMenu_Construct(); // change_SBlueprintActionMenu_Construct();
change_EditorContentList(); // change_EditorContentList();
gen::deinit( & gen_ctx); gen::deinit( & gen_ctx);
}); });

View File

@ -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. 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). 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. Gencpp's serialization does not provide coherent formatting of the code. The user should use a formatter after serializing.

View File

@ -25,13 +25,13 @@ These are containers representing a scope body of a definition that can be of th
Fields: Fields:
```cpp ```cpp
StrCached Name; StrCached Name;
Code Front; Code Front;
Code Back; Code Back;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
s32 NumEntries; s32 NumEntries;
``` ```
The `Front` member represents the start of the link list and `Back` the end. 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: Fields:
```cpp ```cpp
StrCached Content; StrCached Content;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -80,13 +80,13 @@ Stores a comment.
Fields: Fields:
```cpp ```cpp
StrCached Content; StrCached Content;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -109,12 +109,12 @@ CodeComment InlineCmt; // Only supported by forward declarations
CodeAttributes Attributes; CodeAttributes Attributes;
CodeType ParentType; CodeType ParentType;
CodeBody Body; CodeBody Body;
StrCached Name; StrCached Name;
CodeType Prev; CodeType Prev;
CodeType Next; CodeType Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
AccessSpec ParentAccess; AccessSpec ParentAccess;
``` ```
@ -139,16 +139,16 @@ You'll notice that only one parent type is supported only with parent access. Th
Fields: Fields:
```cpp ```cpp
CodeComment InlineCmt; // Only supported by forward declarations CodeComment InlineCmt; // Only supported by forward declarations
Code InitializerList; Code InitializerList;
CodeParams Params; CodeParams Params;
Code Body; Code Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -178,13 +178,14 @@ Represents a preprocessor define
Fields: Fields:
```cpp ```cpp
StrCached Content; CodeDefineParams Params;
StrCached Name; Code Body;
Code Prev; StrCached Name;
Code Next; Code Prev;
Token* Tok; Code Next;
Code Parent; Token* Tok;
CodeT Type; Code Parent;
CodeType Type;
``` ```
Serialization: Serialization:
@ -193,6 +194,28 @@ Serialization:
#define <Name> <Content> #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 ## Destructor
Fields: Fields:
@ -201,12 +224,12 @@ Fields:
CodeComment InlineCmt; CodeComment InlineCmt;
CodeSpecifiers Specs; CodeSpecifiers Specs;
Code Body; Code Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -242,8 +265,8 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
StrCached Name; StrCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -271,13 +294,13 @@ Will be obsolute when function body parsing is implemented.
Fields: Fields:
```cpp ```cpp
StrCached Content; StrCached Content;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -286,18 +309,18 @@ Serialization:
<Content> <Content>
``` ```
## External Linkage ## External Linkage (Extern)
Fields: Fields:
```cpp ```cpp
CodeBody Body; CodeBody Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -314,13 +337,13 @@ extern "<Name>"
Fields: Fields:
```cpp ```cpp
StrCached Content; StrCached Content;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Code Parent; Code Parent;
Token* Tok; Token* Tok;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -336,14 +359,14 @@ This library (until its necessary become some third-party library to do otherwis
Fields: Fields:
```cpp ```cpp
CodeComment InlineCmt; CodeComment InlineCmt;
Code Declaration; Code Declaration;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -363,12 +386,12 @@ CodeSpecifiers Specs;
CodeType ReturnType; CodeType ReturnType;
CodeParams Params; CodeParams Params;
CodeBody Body; CodeBody Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -390,13 +413,13 @@ Serialization:
Fields: Fields:
```cpp ```cpp
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
Serialization: Serialization:
@ -410,14 +433,14 @@ Serialization:
Fields: Fields:
```cpp ```cpp
CodeBody Body; CodeBody Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
Serialization: Serialization:
@ -440,12 +463,12 @@ CodeSpecifiers Specs;
CodeType ReturnType; CodeType ReturnType;
CodeParams Params; CodeParams Params;
CodeBody Body; CodeBody Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
OperatorT Op; OperatorT Op;
``` ```
@ -472,12 +495,12 @@ CodeComment InlineCmt;
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeType ValueType; CodeType ValueType;
CodeBody Body; CodeBody Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -498,17 +521,17 @@ Serialization:
Fields: Fields:
```cpp ```cpp
CodeType ValueType; CodeType ValueType;
Code Macro; Code Macro;
Code Value; Code Value;
Code PostNameMacro; Code PostNameMacro;
StrCached Name; StrCached Name;
CodeParams Last; CodeParams Last;
CodeParams Next; CodeParams Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
s32 NumEntries; s32 NumEntries;
``` ```
Serialization: Serialization:
@ -524,13 +547,13 @@ Serialization:
Fields: Fields:
```cpp ```cpp
StrCached Content; StrCached Content;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -544,13 +567,13 @@ Serialization:
Fields: Fields:
```cpp ```cpp
StrCached Content; StrCached Content;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -566,12 +589,12 @@ Fields:
```cpp ```cpp
SpecifierT ArrSpecs[ AST_ArrSpecs_Cap ]; SpecifierT ArrSpecs[ AST_ArrSpecs_Cap ];
CodeSpecifiers NextSpecs; CodeSpecifiers NextSpecs;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
s32 NumEntries; s32 NumEntries;
``` ```
@ -586,15 +609,15 @@ Serialization:
Fields: Fields:
```cpp ```cpp
CodeParams Params; CodeParams Params;
Code Declaration; Code Declaration;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
Serialization: Serialization:
@ -621,8 +644,8 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
StrCached Name; StrCached Name;
CodeT Type; CodeType Type;
b32 IsParamPack; b32 IsParamPack;
ETypenameTag TypeTag; ETypenameTag TypeTag;
``` ```
@ -647,16 +670,16 @@ Those (macros) don't use the underlying type field as everything was serialized
Fields: Fields:
```cpp ```cpp
CodeComment InlineCmt; CodeComment InlineCmt;
Code UnderlyingType; Code UnderlyingType;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok Token* Tok
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
b32 IsFunction; b32 IsFunction;
``` ```
Serialization: Serialization:
@ -682,12 +705,12 @@ Fields:
```cpp ```cpp
CodeAttributes Attributes; CodeAttributes Attributes;
CodeBody Body; CodeBody Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -708,12 +731,12 @@ Fields:
CodeComment InlineCmt; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
CodeType UnderlyingType; CodeType UnderlyingType;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -740,13 +763,13 @@ CodeSpecifiers Specs;
CodeType ValueType; CodeType ValueType;
Code BitfieldSize; Code BitfieldSize;
Code Value; Code Value;
StrCached Name; StrCached Name;
CodeVar NextVar; CodeVar NextVar;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
s32 VarParenthesizedInit; s32 VarParenthesizedInit;
``` ```

View File

@ -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, 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 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. 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.

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,9 @@
# Parsing # 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. 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 ```cpp
CodeClass parse_class ( Str class_def ); CodeClass parse_class ( Str class_def );
CodeConstructor parse_constructor ( Str constructor_def ); CodeConstructor parse_constructor ( Str constructor_def );
CodeDefine parse_define ( Str define_def );
CodeDestructor parse_destructor ( Str destructor_def ); CodeDestructor parse_destructor ( Str destructor_def );
CodeEnum parse_enum ( Str enum_def ); CodeEnum parse_enum ( Str enum_def );
CodeBody parse_export_body ( Str export_def ); CodeBody parse_export_body ( Str export_def );
@ -53,38 +54,98 @@ The keywords supported for the preprocessor are:
* endif * endif
* pragma * 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. 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 ) 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*** ***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). 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: 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` * Disable with: `#define GEN_PARSER_DISABLE_MACRO_FUNCTION_SIGNATURES`
* typedefs allow for a preprocessed macro: `typedef MACRO();` * typedefs allow for a preprocessed macro: `typedef MACRO();`
* Disable with: `#define GEN_PARSER_DISABLE_MACRO_TYPEDEF` * Disable with: `#define GEN_PARSER_DISABLE_MACRO_TYPEDEF`
* Macros can behave as typenames * 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)* *(Exceptions are added on an on-demand basis)*
*(See functions `parse_operator_function_or_variable` and `parse_typedef` )* *(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. 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. 1. The register macro interface within [interface.hpp](../base/components/interface.hpp).
* 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. 2. Using `def_define` to create a CodeDefine and making sure to not set `opts.dont_register_to_preprocess_macros` to `true`.
* 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`.
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. * 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) * 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.* * *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) * 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. * 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).**

View File

@ -15,3 +15,20 @@ If using the library's provided build scripts:
```ps1 ```ps1
.\build.ps1 <compiler> <debug or omit> unreal .\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.

View File

@ -26,7 +26,7 @@ This means that the typename entry for the parameter AST would be either:
***Concepts and Constraints are not supported*** ***Concepts and Constraints are not supported***
Its a [todo](https://github.com/Ed94/gencpp/issues/21) 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. * `GEN_DEFINE_ATTRIBUTE_TOKENS` : Allows user to define their own attribute macros for use in parsing.
* This can be generated using base.cpp. * 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_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_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_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 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. 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. 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) [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* *`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`* *`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`* *`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: The width dictates how much the static array can hold before it must give way to using an allocated array:
```cpp ```cpp
@ -73,41 +104,16 @@ int AST_ArrSpecs_Cap =
) )
/ sizeof(Specifier) - 1; / sizeof(Specifier) - 1;
``` ```
*Ex: If the AST_POD_Size is 128 the capacity of the static array is 20.*
Data Notes: 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. * 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. * Code types have member symbols but their data layout is enforced to be POD types.
* This library treats memory failures as fatal. * 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. * 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. * 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). * `_ctx->Allocator_Temp` is used.
* 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.
* 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. * 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): * Any modifcations to an existing AST should be to just construct another with the modifications done on-demand while traversing the AST (non-destructive).
* `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`
The following CodeTypes are used which the user may optionally use strong typing with if they enable: `GEN_ENFORCE_STRONG_CODE_TYPES` 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 * CodeClass
* CodeConstructor * CodeConstructor
* CodeDefine * CodeDefine
* CodeDefineParams
* CodeDestructor * CodeDestructor
* CodeEnum * CodeEnum
* CodeExec * CodeExec
@ -127,7 +134,7 @@ The following CodeTypes are used which the user may optionally use strong typing
* CodeModule * CodeModule
* CodeNS * CodeNS
* CodeOperator * CodeOperator
* CodeOpCast * CodeOpCast : User defined member operator conversion
* CodeParams : Has support for `for : range` iterating across parameters. * CodeParams : Has support for `for : range` iterating across parameters.
* CodePreprocessCond * CodePreprocessCond
* CodePragma * CodePragma
@ -140,11 +147,15 @@ The following CodeTypes are used which the user may optionally use strong typing
* CodeUsing * CodeUsing
* CodeVar * 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. 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 * Upfront
* Parsing * Parsing
@ -164,6 +175,7 @@ Interface :``
* def_class * def_class
* def_constructor * def_constructor
* def_define * def_define
* def_define_params
* def_destructor * def_destructor
* def_enum * def_enum
* def_execution * 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: When using the body functions, its recommended to use the args macro to auto determine the number of arguments for the varadic:
```cpp ```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. 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 ### Parse construction
@ -238,12 +271,12 @@ Interface :
* parse_class * parse_class
* parse_constructor * parse_constructor
* parse_define
* parse_destructor * parse_destructor
* parse_enum * parse_enum
* parse_export_body * parse_export_body
* parse_extern_link * parse_extern_link
* parse_friend * parse_friend
* Purposefully are only support forward declares with this constructor.
* parse_function * parse_function
* parse_global_body * parse_global_body
* parse_namespace * 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: The following are provided predefined by the library as they are commonly used:
* `enum_underlying_macro`
* `access_public` * `access_public`
* `access_protected` * `access_protected`
* `access_private` * `access_private`

File diff suppressed because it is too large Load Diff

View File

@ -270,11 +270,11 @@ GEN_NS_BEGIN
#define src_line_str stringize( __LINE__ ) #define src_line_str stringize( __LINE__ )
#ifndef do_once #ifndef do_once
#define do_once() \ #define do_once() \
static int __do_once_counter_##src_line_str = 0; \ 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 ) for ( ; __do_once_counter_##src_line_str != 1; __do_once_counter_##src_line_str = 1 )
#define do_once_defer( expression ) \ #define do_once_defer( expression ) \
static int __do_once_counter_##src_line_str = 0; \ 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 ) ) for ( ; __do_once_counter_##src_line_str != 1; __do_once_counter_##src_line_str = 1, ( expression ) )
#define do_once_start \ #define do_once_start \
do \ do \
@ -852,10 +852,10 @@ template<typename Type> mem_ptr_const to_mem_ptr_const( Type ptr ) { return (mem
#if GEN_BUILD_DEBUG #if GEN_BUILD_DEBUG
# if defined( GEN_COMPILER_MSVC ) # if defined( GEN_COMPILER_MSVC )
# if _MSC_VER < 1300 # 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! */ # define GEN_DEBUG_TRAP() __asm int 3 /* Trap to debugger! */
# else # else
#pragma message("GEN_BUILD_DEBUG: __debugbreak()") // #pragma message("GEN_BUILD_DEBUG: __debugbreak()")
# define GEN_DEBUG_TRAP() __debugbreak() # define GEN_DEBUG_TRAP() __debugbreak()
# endif # endif
# elif defined( GEN_COMPILER_TINYC ) # elif defined( GEN_COMPILER_TINYC )
@ -864,7 +864,7 @@ template<typename Type> mem_ptr_const to_mem_ptr_const( Type ptr ) { return (mem
# define GEN_DEBUG_TRAP() __builtin_trap() # define GEN_DEBUG_TRAP() __builtin_trap()
# endif # endif
#else #else
#pragma message("GEN_BUILD_DEBUG: omitted") // #pragma message("GEN_BUILD_DEBUG: omitted")
# define GEN_DEBUG_TRAP() # define GEN_DEBUG_TRAP()
#endif #endif
@ -2182,10 +2182,9 @@ bool array_fill(Array<Type> array, usize begin, usize end, Type value)
ArrayHeader* header = array_get_header(array); ArrayHeader* header = array_get_header(array);
if (begin < 0 || end > header->Num) 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; array[idx] = value;
} }
@ -2654,7 +2653,7 @@ HashTableFindResult hashtable__find(HashTable<Type> table, u64 key)
if (table.Entries[result.EntryIndex].Key == key) if (table.Entries[result.EntryIndex].Key == key)
break; break;
result.PrevIndex = result.EntryIndex; result.PrevIndex = result.EntryIndex;
result.EntryIndex = table.Entries[result.EntryIndex].Next; result.EntryIndex = table.Entries[result.EntryIndex].Next;
} }
} }

View File

@ -42,7 +42,7 @@
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l | | \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
| Unreal Engine | | | | __} | | | Unreal Engine | | | | __} | |
| l_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 | ! 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 | ! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |
@ -605,7 +605,18 @@ inline Str spec_to_str( Specifier type )
inline bool spec_is_trailing( Specifier specifier ) 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 ) inline Specifier str_to_specifier( Str str )
@ -663,8 +674,8 @@ enum TokType : u32
Tok_BraceCurly_Close, Tok_BraceCurly_Close,
Tok_BraceSquare_Open, Tok_BraceSquare_Open,
Tok_BraceSquare_Close, Tok_BraceSquare_Close,
Tok_Capture_Start, Tok_Paren_Open,
Tok_Capture_End, Tok_Paren_Close,
Tok_Comment, Tok_Comment,
Tok_Comment_End, Tok_Comment_End,
Tok_Comment_Start, Tok_Comment_Start,
@ -923,11 +934,6 @@ AccessSpec tok_to_access_specifier(Token tok) {
return scast(AccessSpec, tok.Type); return scast(AccessSpec, tok.Type);
} }
FORCEINLINE
Str tok_to_str(Token tok) {
return tok.Text;
}
FORCEINLINE FORCEINLINE
bool tok_is_valid( Token tok ) { bool tok_is_valid( Token tok ) {
return tok.Text.Ptr && tok.Text.Len && tok.Type != Tok_Invalid; return tok.Text.Ptr && tok.Text.Len && tok.Type != Tok_Invalid;
@ -1012,8 +1018,6 @@ enum MacroType : u16
MT_Expression, // A macro is assumed to be a expression if not resolved. MT_Expression, // A macro is assumed to be a expression if not resolved.
MT_Statement, MT_Statement,
MT_Typename, MT_Typename,
MT_Attribute, // More of a note to the parser than anythign else (attributes should be defined in the user attribues def).
MT_Specifier, // More of a note to the parser than anythign else (specifiers should be defined in the user attribues def).
MT_Block_Start, // Not Supported yet MT_Block_Start, // Not Supported yet
MT_Block_End, // Not Supported yet MT_Block_End, // Not Supported yet
MT_Case_Statement, // Not Supported yet MT_Case_Statement, // Not Supported yet
@ -1040,8 +1044,6 @@ Str macrotype_to_str( MacroType type )
{ "Statement", sizeof("Statement") - 1 }, { "Statement", sizeof("Statement") - 1 },
{ "Expression", sizeof("Expression") - 1 }, { "Expression", sizeof("Expression") - 1 },
{ "Typename", sizeof("Typename") - 1 }, { "Typename", sizeof("Typename") - 1 },
{ "Attribute(Macro)", sizeof("Attribute(Macro)") - 1 },
{ "Specifier(Macro)", sizeof("Specifier(Macro)") - 1 },
{ "Block_Start", sizeof("Block_Start") - 1 }, { "Block_Start", sizeof("Block_Start") - 1 },
{ "Block_End", sizeof("Block_End") - 1 }, { "Block_End", sizeof("Block_End") - 1 },
{ "Case_Statement", sizeof("Case_Statement") - 1 }, { "Case_Statement", sizeof("Case_Statement") - 1 },
@ -1144,7 +1146,7 @@ struct AST_Pragma;
struct AST_PreprocessCond; struct AST_PreprocessCond;
struct AST_Specifiers; struct AST_Specifiers;
#if GEN_EXECUTION_EXPRESSION_SUPPORT #ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
struct AST_Expr; struct AST_Expr;
struct AST_Expr_Assign; struct AST_Expr_Assign;
struct AST_Expr_Alignof; struct AST_Expr_Alignof;
@ -1241,7 +1243,7 @@ struct CodePragma;
struct CodeSpecifiers; struct CodeSpecifiers;
#endif #endif
#if GEN_EXECUTION_EXPRESSION_SUPPORT #ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
#if GEN_COMPILER_C #if GEN_COMPILER_C
typedef AST_Expr* CodeExpr; typedef AST_Expr* CodeExpr;
@ -1916,7 +1918,7 @@ struct CodeExec
AST_Exec *ast; AST_Exec *ast;
}; };
#if GEN_EXECUTION_EXPRESSION_SUPPORT #ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
struct CodeExpr struct CodeExpr
{ {
#if ! GEN_C_LIKE_CPP #if ! GEN_C_LIKE_CPP
@ -2243,7 +2245,7 @@ struct CodePreprocessCond
AST_PreprocessCond* ast; AST_PreprocessCond* ast;
}; };
#if GEN_EXECUTION_EXPRESSION_SUPPORT #ifdef GEN_EXECUTION_EXPRESSION_SUPPORT
struct CodeStmt struct CodeStmt
{ {
#if ! GEN_C_LIKE_CPP #if ! GEN_C_LIKE_CPP
@ -2750,16 +2752,16 @@ GEN_OPITMIZE_MAPPINGS_END
struct AST_Body struct AST_Body
{ {
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
Code Front; Code Front;
Code Back; Code Back;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries; s32 NumEntries;
}; };
static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same size as AST"); static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same size as AST");
@ -2768,7 +2770,7 @@ struct AST_Attributes
{ {
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StrCached Content; StrCached Content;
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
@ -2786,7 +2788,7 @@ struct AST_BaseClass
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
@ -2803,7 +2805,7 @@ struct AST_Comment
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StrCached Content; StrCached Content;
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
@ -2821,14 +2823,14 @@ struct AST_Class
{ {
CodeComment InlineCmt; // Only supported by forward declarations CodeComment InlineCmt; // Only supported by forward declarations
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ]; char _PAD_SPECS_ [ sizeof(AST*) ];
CodeTypename ParentType; CodeTypename ParentType;
char _PAD_PARAMS_[ sizeof(AST*) ]; char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
CodeTypename Prev; CodeTypename Prev;
CodeTypename Next; CodeTypename Next;
Token* Tok; Token* Tok;
@ -2851,10 +2853,10 @@ struct AST_Constructor
Code InitializerList; Code InitializerList;
CodeParams Params; CodeParams Params;
Code Body; Code Body;
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ]; char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
@ -2876,13 +2878,13 @@ struct AST_Define
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 1 ]; char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 1 ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the same size as AST"); static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the same size as AST");
@ -2897,7 +2899,7 @@ struct AST_DefineParams
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries; s32 NumEntries;
}; };
static_assert( sizeof(AST_DefineParams) == sizeof(AST), "ERROR: AST_DefineParams is not the same size as AST"); static_assert( sizeof(AST_DefineParams) == sizeof(AST), "ERROR: AST_DefineParams is not the same size as AST");
@ -2913,10 +2915,10 @@ struct AST_Destructor
CodeSpecifiers Specs; CodeSpecifiers Specs;
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ]; char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
Code Body; Code Body;
char _PAD_PROPERTIES_3_ [ sizeof(AST*) ]; char _PAD_PROPERTIES_3_ [ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
@ -2938,10 +2940,10 @@ struct AST_Enum
CodeTypename UnderlyingType; CodeTypename UnderlyingType;
Code UnderlyingTypeMacro; Code UnderlyingTypeMacro;
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
@ -2958,7 +2960,7 @@ struct AST_Exec
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StrCached Content; StrCached Content;
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
@ -2968,7 +2970,7 @@ struct AST_Exec
}; };
static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST"); 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 struct AST_Expr
{ {
union { union {
@ -3236,13 +3238,13 @@ struct AST_Extern
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; 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"); static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the same size as AST");
@ -3252,13 +3254,13 @@ struct AST_Include
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StrCached Content; StrCached Content;
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not the same size as AST"); static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not the same size as AST");
@ -3271,16 +3273,16 @@ struct AST_Friend
CodeComment InlineCmt; CodeComment InlineCmt;
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
Code Declaration; Code Declaration;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the same size as AST"); static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the same size as AST");
@ -3294,19 +3296,19 @@ struct AST_Fn
CodeAttributes Attributes; CodeAttributes Attributes;
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeTypename ReturnType; CodeTypename ReturnType;
CodeParams Params; CodeParams Params;
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ]; char _PAD_PROPERTIES_ [ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same size as AST"); static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same size as AST");
@ -3315,14 +3317,14 @@ struct AST_Module
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; 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"); static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the same size as AST");
@ -3331,45 +3333,45 @@ struct AST_NS
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct { struct {
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same size as AST"); static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same size as AST");
struct AST_Operator struct AST_Operator
{ {
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeTypename ReturnType; CodeTypename ReturnType;
CodeParams Params; CodeParams Params;
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ]; char _PAD_PROPERTIES_ [ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
Operator Op; Operator Op;
}; };
static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not the same size as AST"); static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not the same size as AST");
@ -3379,22 +3381,22 @@ struct AST_OpCast
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
char _PAD_PROPERTIES_[ sizeof(AST*) ]; char _PAD_PROPERTIES_[ sizeof(AST*) ];
CodeSpecifiers Specs; CodeSpecifiers Specs;
CodeTypename ValueType; CodeTypename ValueType;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_3_[ sizeof(AST*) ]; char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST"); static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST");
@ -3405,7 +3407,7 @@ struct AST_Params
struct struct
{ {
// TODO(Ed): Support attributes for parameters (Some prefix macros can be converted to that...) // TODO(Ed): Support attributes for parameters (Some prefix macros can be converted to that...)
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
CodeTypename ValueType; CodeTypename ValueType;
Code Macro; Code Macro;
Code Value; Code Value;
@ -3413,14 +3415,14 @@ struct AST_Params
// char _PAD_PROPERTIES_3_[sizeof( AST* )]; // char _PAD_PROPERTIES_3_[sizeof( AST* )];
}; };
}; };
StrCached Name; StrCached Name;
CodeParams Last; CodeParams Last;
CodeParams Next; CodeParams Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries; s32 NumEntries;
}; };
static_assert( sizeof(AST_Params) == sizeof(AST), "ERROR: AST_Params is not the same size as AST"); static_assert( sizeof(AST_Params) == sizeof(AST), "ERROR: AST_Params is not the same size as AST");
@ -3430,13 +3432,13 @@ struct AST_Pragma
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StrCached Content; StrCached Content;
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the same size as AST"); static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the same size as AST");
@ -3444,40 +3446,40 @@ struct AST_PreprocessCond
{ {
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StrCached Content; StrCached Content;
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
}; };
static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_PreprocessCond is not the same size as AST"); static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_PreprocessCond is not the same size as AST");
struct AST_Specifiers struct AST_Specifiers
{ {
Specifier ArrSpecs[ AST_ArrSpecs_Cap ]; Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
StrCached Name; StrCached Name;
CodeSpecifiers NextSpecs; CodeSpecifiers NextSpecs;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries; s32 NumEntries;
}; };
static_assert( sizeof(AST_Specifiers) == sizeof(AST), "ERROR: AST_Specifier is not the same size as AST"); 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 struct AST_Stmt
{ {
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3492,7 +3494,7 @@ struct AST_Stmt_Break
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3507,7 +3509,7 @@ struct AST_Stmt_Case
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3522,7 +3524,7 @@ struct AST_Stmt_Continue
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3537,7 +3539,7 @@ struct AST_Stmt_Decl
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3552,7 +3554,7 @@ struct AST_Stmt_Do
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3567,7 +3569,7 @@ struct AST_Stmt_Expr
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3582,7 +3584,7 @@ struct AST_Stmt_Else
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3597,7 +3599,7 @@ struct AST_Stmt_If
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3612,7 +3614,7 @@ struct AST_Stmt_For
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3627,7 +3629,7 @@ struct AST_Stmt_Goto
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3642,7 +3644,7 @@ struct AST_Stmt_Label
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3657,7 +3659,7 @@ struct AST_Stmt_Switch
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3672,7 +3674,7 @@ struct AST_Stmt_While
union { union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
}; };
StrCached Name; StrCached Name;
CodeExpr Prev; CodeExpr Prev;
CodeExpr Next; CodeExpr Next;
Token* Tok; Token* Tok;
@ -3691,14 +3693,14 @@ struct AST_Struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ]; char _PAD_SPECS_ [ sizeof(AST*) ];
CodeTypename ParentType; CodeTypename ParentType;
char _PAD_PARAMS_[ sizeof(AST*) ]; char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
CodeTypename Prev; CodeTypename Prev;
CodeTypename Next; CodeTypename Next;
Token* Tok; Token* Tok;
@ -3715,20 +3717,20 @@ struct AST_Template
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
CodeParams Params; CodeParams Params;
Code Declaration; Code Declaration;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not the same size as AST"); static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not the same size as AST");
@ -3750,13 +3752,13 @@ struct AST_Type
// CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures // CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
b32 IsParamPack; b32 IsParamPack;
}; };
static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST"); static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST");
@ -3783,7 +3785,7 @@ struct AST_Typename
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
struct { struct {
b16 IsParamPack; // Used by typename to know if type should be considered a parameter pack. 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) ETypenameTag TypeTag; // Used by typename to keep track of explicitly declared tags for the identifier (enum, struct, union)
@ -3798,9 +3800,9 @@ struct AST_Typedef
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ];
Code UnderlyingType; Code UnderlyingType;
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
}; };
}; };
StrCached Name; StrCached Name;
@ -3822,19 +3824,19 @@ struct AST_Union
{ {
char _PAD_INLINE_CMT_[ sizeof(AST*) ]; char _PAD_INLINE_CMT_[ sizeof(AST*) ];
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the same size as AST"); static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the same size as AST");
@ -3846,19 +3848,19 @@ struct AST_Using
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ]; char _PAD_SPECS_ [ sizeof(AST*) ];
CodeTypename UnderlyingType; CodeTypename UnderlyingType;
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ]; char _PAD_UNUSED_[ sizeof(u32) ];
}; };
static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the same size as AST"); static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the same size as AST");
@ -3874,17 +3876,17 @@ struct AST_Var
CodeTypename ValueType; CodeTypename ValueType;
Code BitfieldSize; Code BitfieldSize;
Code Value; Code Value;
CodeVar NextVar; CodeVar NextVar;
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
s32 VarParenthesizedInit; s32 VarParenthesizedInit;
}; };
static_assert( sizeof(AST_Var) == sizeof(AST), "ERROR: AST_Var is not the same size as AST"); static_assert( sizeof(AST_Var) == sizeof(AST), "ERROR: AST_Var is not the same size as AST");
@ -3982,6 +3984,9 @@ struct Context
// TODO(Ed): Active parse context vs a parse result need to be separated conceptually // TODO(Ed): Active parse context vs a parse result need to be separated conceptually
ParseContext parser; 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 // Initialize the library. There first ctx initialized must exist for lifetime of other contextes that come after as its the one that
@ -4010,7 +4015,11 @@ GEN_API void register_macro( Macro macro );
// Ease of use batch registration // Ease of use batch registration
GEN_API void register_macros( s32 num, ... ); GEN_API void register_macros( s32 num, ... );
GEN_API void register_macros( s32 num, Macro* macros ); 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. // Used internally to retrive or make string allocations.
// Strings are stored in a series of string arenas of fixed size (SizePer_StringArena) // Strings are stored in a series of string arenas of fixed size (SizePer_StringArena)
@ -4165,37 +4174,50 @@ 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, // 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. /// or provide as an array of Code objects.
GEN_API CodeBody def_class_body ( s32 num, ... ); GEN_API CodeBody def_class_body ( s32 num, ... );
GEN_API CodeBody def_class_body ( s32 num, Code* codes ); 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 ( s32 num, ... );
GEN_API CodeDefineParams def_define_params ( s32 num, CodeDefineParams* codes ); 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 ( s32 num, ... );
GEN_API CodeBody def_enum_body ( s32 num, Code* codes ); 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 ( s32 num, ... );
GEN_API CodeBody def_export_body ( s32 num, Code* codes); 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 ( s32 num, ... );
GEN_API CodeBody def_extern_link_body( s32 num, Code* codes ); 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 ( s32 num, ... );
GEN_API CodeBody def_function_body ( s32 num, Code* codes ); 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 ( s32 num, ... );
GEN_API CodeBody def_global_body ( s32 num, Code* codes ); 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 ( s32 num, ... );
GEN_API CodeBody def_namespace_body ( s32 num, Code* codes ); GEN_API CodeBody def_namespace_body_arr ( s32 num, Code* codes );
GEN_API CodeParams def_params ( s32 num, ... ); GEN_API CodeParams def_params ( s32 num, ... );
GEN_API CodeParams def_params ( s32 num, CodeParams* params ); GEN_API CodeParams def_params_arr ( s32 num, CodeParams* params );
GEN_API CodeSpecifiers def_specifiers ( s32 num, ... ); GEN_API CodeSpecifiers def_specifiers ( s32 num, ... );
GEN_API CodeSpecifiers def_specifiers ( s32 num, Specifier* specs ); GEN_API CodeSpecifiers def_specifiers_arr ( s32 num, Specifier* specs );
GEN_API CodeBody def_struct_body ( s32 num, ... ); GEN_API CodeBody def_struct_body ( s32 num, ... );
GEN_API CodeBody def_struct_body ( s32 num, Code* codes ); 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 ( s32 num, ... );
GEN_API CodeBody def_union_body ( s32 num, Code* codes ); 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 #pragma endregion Upfront
#pragma region Parsing #pragma region Parsing
// TODO(Ed) : Implmeent the new parser API design.
#if 0 #if 0
struct StackNode struct StackNode
{ {