mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
borken : lots of stuff changed, explaining in later commit...v
This commit is contained in:
parent
ceea184d5a
commit
4d638a7255
37
.vscode/c_cpp_properties.json
vendored
37
.vscode/c_cpp_properties.json
vendored
@ -1,9 +1,9 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Win32 msvc",
|
||||
"name": "Bootstrap",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
"${workspaceFolder}/project/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
@ -15,10 +15,39 @@
|
||||
"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}/project/build/compile_commands.json"
|
||||
"compileCommands": "C:\\projects\\gencpp\\.vscode\\tasks.json",
|
||||
"compilerArgs": [
|
||||
"/EHsc-",
|
||||
"/GR-",
|
||||
"/Zc:preprocessor",
|
||||
"/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": "C:\\projects\\gencpp\\.vscode\\tasks.json"
|
||||
},
|
||||
{
|
||||
"name": "Win32 clang",
|
||||
@ -38,7 +67,7 @@
|
||||
"windowsSdkVersion": "10.0.19041.0",
|
||||
"compilerPath": "C:/Users/Ed/scoop/apps/llvm/current/bin/clang++.exe",
|
||||
"intelliSenseMode": "windows-clang-x64",
|
||||
"compileCommands": "${workspaceFolder}/project/build/compile_commands.json"
|
||||
"compileCommands": ".vscode/tasks.json"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
|
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -67,8 +67,10 @@
|
||||
"C_Cpp.files.exclude": {
|
||||
"**/.vscode": true,
|
||||
"**/.vs": true,
|
||||
"**/sanity.gen.hpp": true
|
||||
"**/sanity.gen.hpp": true,
|
||||
"test/**":true,
|
||||
},
|
||||
"autoHide.autoHidePanel": false,
|
||||
"autoHide.autoHideSideBar": false
|
||||
"autoHide.autoHideSideBar": false,
|
||||
"dimmer.enabled": true
|
||||
}
|
||||
|
144
.vscode/tasks.json
vendored
Normal file
144
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build Bootstrap",
|
||||
"type": "shell",
|
||||
"command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
|
||||
"args": [
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-File",
|
||||
"${workspaceFolder}/scripts/build.ci.ps1",
|
||||
"bootstrap",
|
||||
"msvc"
|
||||
],
|
||||
"group": "build",
|
||||
"problemMatcher": {
|
||||
"owner": "cpp",
|
||||
"fileLocation": [
|
||||
"relative",
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"pattern": {
|
||||
"regexp": "^(.*)\\((\\d+)\\)\\s*:\\s*(warning|error)\\s*(\\w+)\\s*:\\s*(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"severity": 3,
|
||||
"code": 4,
|
||||
"message": 5
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "shared",
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Build C Library",
|
||||
"type": "shell",
|
||||
"command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
|
||||
"args": [
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-File",
|
||||
"${workspaceFolder}/scripts/build.ci.ps1",
|
||||
"c_library",
|
||||
"msvc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": {
|
||||
"owner": "cpp",
|
||||
"fileLocation": [
|
||||
"relative",
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"pattern": {
|
||||
"regexp": "^(.*)\\((\\d+)\\)\\s*:\\s*(warning|error)\\s*(\\w+)\\s*:\\s*(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"severity": 3,
|
||||
"code": 4,
|
||||
"message": 5
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "shared",
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Build Singleheader (MSVC)",
|
||||
"type": "shell",
|
||||
"command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
|
||||
"args": [
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-File",
|
||||
"${workspaceFolder}/scripts/build.ci.ps1",
|
||||
"singleheader",
|
||||
"msvc",
|
||||
"debug"
|
||||
],
|
||||
"group": "build",
|
||||
"problemMatcher": {
|
||||
"owner": "cpp",
|
||||
"fileLocation": ["relative", "${workspaceFolder}"],
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(.*)\\((\\d+)\\)\\s*:\\s*(error|warning|info|note)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"severity": 3,
|
||||
"code": 4,
|
||||
"message": 5
|
||||
}
|
||||
]
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "shared",
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Build Unreal (MSVC)",
|
||||
"type": "shell",
|
||||
"command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
|
||||
"args": [
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-File",
|
||||
"${workspaceFolder}/scripts/build.ci.ps1",
|
||||
"unreal",
|
||||
"msvc",
|
||||
"debug"
|
||||
],
|
||||
"group": "build",
|
||||
"problemMatcher": {
|
||||
"owner": "cpp",
|
||||
"fileLocation": ["relative", "${workspaceFolder}"],
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(.*)\\((\\d+)\\)\\s*:\\s*(error|warning|info|note)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"severity": 3,
|
||||
"code": 4,
|
||||
"message": 5
|
||||
}
|
||||
]
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "shared",
|
||||
"clear": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
# gencpp
|
||||
|
||||
An attempt at simple staged metaprogramming for c/c++.
|
||||
An attempt at simple staged metaprogramming for C/C++.
|
||||
|
||||
The library API is a composition of code element constructors.
|
||||
These build up a code AST to then serialize with a file builder.
|
||||
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.
|
||||
|
||||
This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto).
|
||||
Its not meant to be a black box metaprogramming utility, it should be easy to intergrate into a user's project domain.
|
||||
@ -31,7 +31,7 @@ A metaprogram is built to generate files before the main program is built. We'll
|
||||
|
||||
`gen.cpp` \`s `main()` is defined as `gen_main()` which the user will have to define once for their program. There they will dictate everything that should be generated.
|
||||
|
||||
In order to keep the locality of this code within the same files the following pattern may be used (although this pattern isn't required at all):
|
||||
In order to keep the locality of this code within the same files the following pattern may be used (although this pattern isn't the best to use):
|
||||
|
||||
Within `program.cpp` :
|
||||
|
||||
@ -54,7 +54,6 @@ u32 gen_main()
|
||||
|
||||
// Regular runtime dependent on the generated code here.
|
||||
#endif
|
||||
|
||||
```
|
||||
|
||||
The design uses a constructive builder API for the code to generate.
|
||||
|
1146
gen_c_library/Test.jsonc
Normal file
1146
gen_c_library/Test.jsonc
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,6 @@
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1
|
||||
#define GEN_SUPPORT_CPP_REFERENCES 1
|
||||
#include "../project/gen.cpp"
|
||||
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
@ -97,6 +95,8 @@ CodeBody parse_file( const char* path )
|
||||
return code;
|
||||
}
|
||||
|
||||
constexpr bool helper_use_c_definition = true;
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
#define project_dir "../project/"
|
||||
@ -170,10 +170,12 @@ int gen_main()
|
||||
Code inlines = scan_file( project_dir "components/inlines.hpp" );
|
||||
Code header_end = scan_file( project_dir "components/header_end.hpp" );
|
||||
|
||||
CodeBody ecode = gen_ecode ( project_dir "enums/ECode.csv" );
|
||||
CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv" );
|
||||
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" );
|
||||
CodeBody ast_inlines = gen_ast_inlines();
|
||||
CodeBody ecode = gen_ecode ( project_dir "enums/ECode.csv", helper_use_c_definition );
|
||||
CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv", helper_use_c_definition );
|
||||
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv", helper_use_c_definition );
|
||||
|
||||
// Only has operator overload definitions that C doesn't need.
|
||||
// CodeBody ast_inlines = gen_ast_inlines();
|
||||
|
||||
CodeBody parsed_ast = parse_file( project_dir "components/ast.hpp" );
|
||||
CodeBody ast = def_body(CT_Global_Body);
|
||||
@ -292,15 +294,13 @@ R"(#define AST_ArrSpecs_Cap \
|
||||
case CT_Function:
|
||||
{
|
||||
CodeFn fn = cast(CodeFn, entry);
|
||||
if (fn->Specs) {
|
||||
s32 constexpr_found = fn->Specs.remove( Spec_Constexpr );
|
||||
if (constexpr_found > -1) {
|
||||
log_fmt("Found constexpr: %S\n", entry.to_string());
|
||||
fn->Specs.append(Spec_Inline);
|
||||
}
|
||||
// for ( StrC id : to_rename ) if (fn->Name.is_equal(id)) {
|
||||
// Array(CodeFn) list = * needs_selectors.get(id);
|
||||
// list.append(rename_function_to_unique_symbol(fn));
|
||||
// }
|
||||
}
|
||||
memory.append(fn);
|
||||
}
|
||||
break;
|
||||
|
@ -1,8 +1,6 @@
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1
|
||||
#define GEN_SUPPORT_CPP_REFERENCES 0
|
||||
#include "gen.cpp"
|
||||
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
|
@ -1,8 +1,7 @@
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#define GEN_SUPPORT_CPP_MEMBER_FEATURES 0
|
||||
#define GEN_SUPPORT_CPP_REFERENCES 0
|
||||
#define GEN_C_LIKE_CPP 1
|
||||
#include "gen.cpp"
|
||||
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
|
@ -362,7 +362,9 @@ Code code_duplicate(Code self)
|
||||
{
|
||||
Code result = make_code();
|
||||
|
||||
mem_copy( result.ast, self.ast, sizeof( AST ) );
|
||||
void* mem_result = rcast(void*, cast(AST*, result));
|
||||
void* mem_self = rcast(void*, cast(AST*, self));
|
||||
mem_copy( mem_result, mem_self, sizeof( AST ) );
|
||||
|
||||
result->Parent = { nullptr };
|
||||
return result;
|
||||
@ -409,173 +411,173 @@ void code_to_string_ptr( Code self, String* result )
|
||||
break;
|
||||
|
||||
case CT_Class:
|
||||
to_string_def(cast(CodeClass, self), result );
|
||||
class_to_string_def(cast(CodeClass, self), result );
|
||||
break;
|
||||
|
||||
case CT_Class_Fwd:
|
||||
to_string_fwd(cast(CodeClass, self), result );
|
||||
class_to_string_fwd(cast(CodeClass, self), result );
|
||||
break;
|
||||
|
||||
case CT_Constructor:
|
||||
to_string_def(cast(CodeConstructor, self), result );
|
||||
constructor_to_string_def(cast(CodeConstructor, self), result );
|
||||
break;
|
||||
|
||||
case CT_Constructor_Fwd:
|
||||
to_string_fwd(cast(CodeConstructor, self), result );
|
||||
constructor_to_string_fwd(cast(CodeConstructor, self), result );
|
||||
break;
|
||||
|
||||
case CT_Destructor:
|
||||
to_string_def(cast(CodeDestructor, self), result );
|
||||
destructor_to_string_def(cast(CodeDestructor, self), result );
|
||||
break;
|
||||
|
||||
case CT_Destructor_Fwd:
|
||||
to_string_fwd(cast(CodeDestructor, self), result );
|
||||
destructor_to_string_fwd(cast(CodeDestructor, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum:
|
||||
to_string_def(cast(CodeEnum, self), result );
|
||||
enum_to_string_def(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum_Fwd:
|
||||
to_string_fwd(cast(CodeEnum, self), result );
|
||||
enum_to_string_fwd(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum_Class:
|
||||
to_string_class_def(cast(CodeEnum, self), result );
|
||||
enum_to_string_class_def(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum_Class_Fwd:
|
||||
to_string_class_fwd(cast(CodeEnum, self), result );
|
||||
enum_to_string_class_fwd(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case CT_Export_Body:
|
||||
to_string_export(cast(CodeBody, self), result );
|
||||
body_to_string_export(cast(CodeBody, self), result );
|
||||
break;
|
||||
|
||||
case CT_Extern_Linkage:
|
||||
to_string(cast(CodeExtern, self), result );
|
||||
extern_to_string(cast(CodeExtern, self), result );
|
||||
break;
|
||||
|
||||
case CT_Friend:
|
||||
to_string(cast(CodeFriend, self), result );
|
||||
friend_to_string_ref(cast(CodeFriend, self), result );
|
||||
break;
|
||||
|
||||
case CT_Function:
|
||||
to_string_def(cast(CodeFn, self), result );
|
||||
fn_to_string_def(cast(CodeFn, self), result );
|
||||
break;
|
||||
|
||||
case CT_Function_Fwd:
|
||||
to_string_fwd(cast(CodeFn, self), result );
|
||||
fn_to_string_fwd(cast(CodeFn, self), result );
|
||||
break;
|
||||
|
||||
case CT_Module:
|
||||
to_string(cast(CodeModule, self), result );
|
||||
module_to_string_ref(cast(CodeModule, self), result );
|
||||
break;
|
||||
|
||||
case CT_Namespace:
|
||||
to_string(cast(CodeNS, self), result );
|
||||
namespace_to_string_ref(cast(CodeNS, self), result );
|
||||
break;
|
||||
|
||||
case CT_Operator:
|
||||
case CT_Operator_Member:
|
||||
to_string_def(cast(CodeOperator, self), result );
|
||||
code_op_to_string_def(cast(CodeOperator, self), result );
|
||||
break;
|
||||
|
||||
case CT_Operator_Fwd:
|
||||
case CT_Operator_Member_Fwd:
|
||||
to_string_fwd(cast(CodeOperator, self), result );
|
||||
code_op_to_string_fwd(cast(CodeOperator, self), result );
|
||||
break;
|
||||
|
||||
case CT_Operator_Cast:
|
||||
to_string_def(cast(CodeOpCast, self), result );
|
||||
opcast_to_string_def(cast(CodeOpCast, self), result );
|
||||
break;
|
||||
|
||||
case CT_Operator_Cast_Fwd:
|
||||
to_string_fwd(cast(CodeOpCast, self), result );
|
||||
opcast_to_string_fwd(cast(CodeOpCast, self), result );
|
||||
break;
|
||||
|
||||
case CT_Parameters:
|
||||
to_string(cast(CodeParam, self), result );
|
||||
params_to_string_ref(cast(CodeParam, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Define:
|
||||
to_string(cast(CodeDefine, self), result );
|
||||
define_to_string_ref(cast(CodeDefine, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_If:
|
||||
to_string_if(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_if(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_IfDef:
|
||||
to_string_ifdef(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_ifdef(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_IfNotDef:
|
||||
to_string_ifndef(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_ifndef(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Include:
|
||||
to_string(cast(CodeInclude, self), result );
|
||||
include_to_string_ref(cast(CodeInclude, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_ElIf:
|
||||
to_string_elif(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_elif(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Else:
|
||||
to_string_else(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_else(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_EndIf:
|
||||
to_string_endif(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_endif(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Pragma:
|
||||
to_string(cast(CodePragma, self), result );
|
||||
pragma_to_string_ref(cast(CodePragma, self), result );
|
||||
break;
|
||||
|
||||
case CT_Specifiers:
|
||||
to_string(cast(CodeSpecifiers, self), result );
|
||||
specifiers_to_string_ref(cast(CodeSpecifiers, self), result );
|
||||
break;
|
||||
|
||||
case CT_Struct:
|
||||
to_string_def(cast(CodeStruct, self), result );
|
||||
struct_to_string_def(cast(CodeStruct, self), result );
|
||||
break;
|
||||
|
||||
case CT_Struct_Fwd:
|
||||
to_string_fwd(cast(CodeStruct, self), result );
|
||||
struct_to_string_fwd(cast(CodeStruct, self), result );
|
||||
break;
|
||||
|
||||
case CT_Template:
|
||||
to_string(cast(CodeTemplate, self), result );
|
||||
template_to_string_ref(cast(CodeTemplate, self), result );
|
||||
break;
|
||||
|
||||
case CT_Typedef:
|
||||
to_string(cast(CodeTypedef, self), result );
|
||||
typedef_to_string_ref(cast(CodeTypedef, self), result );
|
||||
break;
|
||||
|
||||
case CT_Typename:
|
||||
to_string(cast(CodeTypename, self), result );
|
||||
typename_to_string_ref(cast(CodeTypename, self), result );
|
||||
break;
|
||||
|
||||
case CT_Union:
|
||||
to_string_def( cast(CodeUnion, self), result );
|
||||
union_to_string_def( cast(CodeUnion, self), result );
|
||||
break;
|
||||
|
||||
case CT_Union_Fwd:
|
||||
to_string_fwd( cast(CodeUnion, self), result );
|
||||
union_to_string_fwd( cast(CodeUnion, self), result );
|
||||
break;
|
||||
|
||||
case CT_Using:
|
||||
to_string(cast(CodeUsing, self), result );
|
||||
using_to_string_ref(cast(CodeUsing, self), result );
|
||||
break;
|
||||
|
||||
case CT_Using_Namespace:
|
||||
to_string_ns(cast(CodeUsing, self), result );
|
||||
using_to_string_ns(cast(CodeUsing, self), result );
|
||||
break;
|
||||
|
||||
case CT_Variable:
|
||||
to_string(cast(CodeVar, self), result );
|
||||
var_to_string_ref(cast(CodeVar, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum_Body:
|
||||
@ -586,7 +588,7 @@ void code_to_string_ptr( Code self, String* result )
|
||||
case CT_Namespace_Body:
|
||||
case CT_Struct_Body:
|
||||
case CT_Union_Body:
|
||||
to_string( cast(CodeBody, self), result );
|
||||
body_to_string_ref( cast(CodeBody, self), result );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1163,7 +1165,7 @@ bool code_validate_body(Code self)
|
||||
do \
|
||||
{ \
|
||||
CodeBody body = cast(CodeBody, self); \
|
||||
for ( Code code_entry = begin(body); code_entry != end(body); next(body, code_entry) ) \
|
||||
for ( Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry) ) \
|
||||
{ \
|
||||
switch ( code_entry->Type ) \
|
||||
{ \
|
||||
@ -1185,7 +1187,7 @@ bool code_validate_body(Code self)
|
||||
case CT_Enum_Body:
|
||||
{
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin(body); entry != end(body); next(body, entry) )
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )
|
||||
{
|
||||
if ( entry->Type != CT_Untyped )
|
||||
{
|
||||
@ -1213,7 +1215,7 @@ bool code_validate_body(Code self)
|
||||
case CT_Global_Body:
|
||||
{
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin(body); entry != end(body); next(body, entry) )
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )
|
||||
{
|
||||
switch (entry->Type)
|
||||
{
|
||||
@ -1253,7 +1255,7 @@ bool code_validate_body(Code self)
|
||||
case CT_Union_Body:
|
||||
{
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin(body); entry != end(body); next(body, entry) )
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )
|
||||
{
|
||||
if ( entry->Type != CT_Untyped )
|
||||
{
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "gen/especifier.hpp"
|
||||
#endif
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
struct AST;
|
||||
struct AST_Body;
|
||||
struct AST_Attributes;
|
||||
@ -158,17 +156,20 @@ GEN_NS_PARSER_BEGIN
|
||||
struct Token;
|
||||
GEN_NS_PARSER_END
|
||||
|
||||
#define Token_Typedef struct Token Token
|
||||
typedef Token_Typedef;
|
||||
#undef Token_Typedef
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
GEN_API_C_END
|
||||
template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( Type*, & self ); }
|
||||
GEN_API_C_BEGIN
|
||||
// Note(Ed): This is to alleviate an edge case with parsing usings or typedefs where I don't really have it setup
|
||||
// to parse a 'namespace' macro or a type with a macro.
|
||||
// I have ideas for ways to pack that into the typedef/using ast, but for now just keeping it like this
|
||||
#define ParserTokenType GEN_NS_PARSER Token
|
||||
typedef ParserTokenType Token;
|
||||
#undef ParserTokenType
|
||||
#endif
|
||||
|
||||
#pragma region Code Interface
|
||||
#if GEN_COMPILER_CPP
|
||||
template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( Type*, & self ); }
|
||||
#endif
|
||||
|
||||
#pragma region Code C-Interface
|
||||
void code_append (Code code, Code other );
|
||||
char const* code_debug_str (Code code);
|
||||
Code code_duplicate (Code code);
|
||||
@ -182,10 +183,9 @@ String code_to_string (Code self );
|
||||
void code_to_string_ptr(Code self, String* result );
|
||||
char const* code_type_str (Code self );
|
||||
bool code_validate_body(Code self );
|
||||
#pragma endregion Code Interface
|
||||
#pragma endregion Code C-Interface
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
GEN_API_C_END
|
||||
/*
|
||||
AST* wrapper
|
||||
- Not constantly have to append the '*' as this is written often..
|
||||
@ -196,33 +196,35 @@ struct Code
|
||||
AST* ast;
|
||||
|
||||
# define Using_Code( Typename ) \
|
||||
char const* debug_str() { return code_debug_str(* this); } \
|
||||
Code duplicate() { return code_duplicate(* this); } \
|
||||
bool is_equal( Code other ) { return code_is_equal(* this, other); } \
|
||||
bool is_body() { return code_is_body(* this); } \
|
||||
bool is_valid() { return code_is_valid(* this); } \
|
||||
void set_global() { return code_set_global(* this); }
|
||||
forceinline char const* debug_str() { return code_debug_str(* this); } \
|
||||
forceinline Code duplicate() { return code_duplicate(* this); } \
|
||||
forceinline bool is_equal( Code other ) { return code_is_equal(* this, other); } \
|
||||
forceinline bool is_body() { return code_is_body(* this); } \
|
||||
forceinline bool is_valid() { return code_is_valid(* this); } \
|
||||
forceinline void set_global() { return code_set_global(* this); }
|
||||
|
||||
# define Using_CodeOps( Typename ) \
|
||||
Typename& operator = ( Code other ); \
|
||||
bool operator ==( Code other ) { return (AST*)ast == other.ast; } \
|
||||
bool operator !=( Code other ) { return (AST*)ast != other.ast; } \
|
||||
forceinline Typename& operator = ( Code other ); \
|
||||
forceinline bool operator ==( Code other ) { return (AST*)ast == other.ast; } \
|
||||
forceinline bool operator !=( Code other ) { return (AST*)ast != other.ast; } \
|
||||
forceinline bool operator ==(std::nullptr_t) const { return ast == nullptr; } \
|
||||
forceinline bool operator !=(std::nullptr_t) const { return ast != nullptr; } \
|
||||
operator bool();
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
Using_Code( Code );
|
||||
void append(Code other) { return code_append(* this, other); }
|
||||
Code* entry(u32 idx) { return code_entry(* this, idx); }
|
||||
bool has_entries() { return code_has_entries(* this); }
|
||||
String to_string() { return code_to_string(* this); }
|
||||
void to_string(String& result) { return code_to_string_ptr(* this, & result); }
|
||||
char const* type_str() { return code_type_str(* this); }
|
||||
bool validate_body() { return code_validate_body(*this); }
|
||||
forceinline void append(Code other) { return code_append(* this, other); }
|
||||
forceinline Code* entry(u32 idx) { return code_entry(* this, idx); }
|
||||
forceinline bool has_entries() { return code_has_entries(* this); }
|
||||
forceinline String to_string() { return code_to_string(* this); }
|
||||
forceinline void to_string(String& result) { return code_to_string_ptr(* this, & result); }
|
||||
forceinline char const* type_str() { return code_type_str(* this); }
|
||||
forceinline bool validate_body() { return code_validate_body(*this); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( Code );
|
||||
forceinline AST* operator ->() { return ast; }
|
||||
|
||||
AST* operator ->() { return ast; }
|
||||
Code& operator ++();
|
||||
|
||||
// TODO(Ed) : Remove this overload.
|
||||
@ -237,11 +239,6 @@ struct Code
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(std::nullptr_t) const { return ast == nullptr; }
|
||||
bool operator!=(std::nullptr_t) const { return ast != nullptr; }
|
||||
friend bool operator==(std::nullptr_t, const Code code) { return code.ast == nullptr; }
|
||||
friend bool operator!=(std::nullptr_t, const Code code) { return code.ast != nullptr; }
|
||||
|
||||
#ifdef GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
# define operator explicit operator
|
||||
#endif
|
||||
@ -276,7 +273,6 @@ struct Code
|
||||
operator CodeVar() const;
|
||||
#undef operator
|
||||
};
|
||||
GEN_API_C_BEGIN
|
||||
#endif
|
||||
|
||||
#pragma region Statics
|
||||
@ -287,7 +283,6 @@ extern Code Code_Global;
|
||||
extern Code Code_Invalid;
|
||||
#pragma endregion Statics
|
||||
|
||||
typedef struct Code_POD Code_POD;
|
||||
struct Code_POD
|
||||
{
|
||||
AST* ast;
|
||||
@ -385,10 +380,12 @@ static_assert( sizeof(AST) == AST_POD_Size, "ERROR: AST POD is not size of AST_P
|
||||
struct InvalidCode_ImplictCaster;
|
||||
#define InvalidCode (InvalidCode_ImplictCaster{})
|
||||
#else
|
||||
#define InvalidCode Code_Invalid
|
||||
#define InvalidCode { (AST*)Code_Invalid }
|
||||
#endif
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
// Used when the its desired when omission is allowed in a definition.
|
||||
#define NullCode { nullptr }
|
||||
|
||||
GEN_API_C_END
|
||||
#else
|
||||
#define NullCode nullptr
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,139 +1,79 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
#pragma once #include "components/types.hpp"
|
||||
#pragma once
|
||||
#include "components/types.hpp"
|
||||
#endif
|
||||
|
||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
enum CodeType_Def enum_underlying( u32 )
|
||||
|
||||
{ CT_Invalid,
|
||||
CT_Untyped,
|
||||
CT_NewLine,
|
||||
CT_Comment,
|
||||
CT_Access_Private,
|
||||
CT_Access_Protected,
|
||||
CT_Access_Public,
|
||||
CT_PlatformAttributes,
|
||||
CT_Class,
|
||||
CT_Class_Fwd,
|
||||
CT_Class_Body,
|
||||
CT_Constructor,
|
||||
CT_Constructor_Fwd,
|
||||
CT_Destructor,
|
||||
CT_Destructor_Fwd,
|
||||
CT_Enum,
|
||||
CT_Enum_Fwd,
|
||||
CT_Enum_Body,
|
||||
CT_Enum_Class,
|
||||
CT_Enum_Class_Fwd,
|
||||
CT_Execution,
|
||||
CT_Export_Body,
|
||||
CT_Extern_Linkage,
|
||||
CT_Extern_Linkage_Body,
|
||||
CT_Friend,
|
||||
CT_Function,
|
||||
CT_Function_Fwd,
|
||||
CT_Function_Body,
|
||||
CT_Global_Body,
|
||||
CT_Module,
|
||||
CT_Namespace,
|
||||
CT_Namespace_Body,
|
||||
CT_Operator,
|
||||
CT_Operator_Fwd,
|
||||
CT_Operator_Member,
|
||||
CT_Operator_Member_Fwd,
|
||||
CT_Operator_Cast,
|
||||
CT_Operator_Cast_Fwd,
|
||||
CT_Parameters,
|
||||
CT_Preprocess_Define,
|
||||
CT_Preprocess_Include,
|
||||
CT_Preprocess_If,
|
||||
CT_Preprocess_IfDef,
|
||||
CT_Preprocess_IfNotDef,
|
||||
CT_Preprocess_ElIf,
|
||||
CT_Preprocess_Else,
|
||||
CT_Preprocess_EndIf,
|
||||
CT_Preprocess_Pragma,
|
||||
CT_Specifiers,
|
||||
CT_Struct,
|
||||
CT_Struct_Fwd,
|
||||
CT_Struct_Body,
|
||||
CT_Template,
|
||||
CT_Typedef,
|
||||
CT_Typename,
|
||||
CT_Union,
|
||||
CT_Union_Fwd,
|
||||
CT_Union_Body,
|
||||
CT_Using,
|
||||
CT_Using_Namespace,
|
||||
CT_Variable,
|
||||
CT_NumTypes };
|
||||
typedef enum CodeType_Def CodeType;
|
||||
|
||||
inline StrC codetype_to_str( CodeType type )
|
||||
enum CodeType : u32
|
||||
{
|
||||
local_persist StrC lookup[61] = {
|
||||
{ sizeof( "Invalid" ), "Invalid" },
|
||||
{ sizeof( "Untyped" ), "Untyped" },
|
||||
{ sizeof( "NewLine" ), "NewLine" },
|
||||
{ sizeof( "Comment" ), "Comment" },
|
||||
{ sizeof( "Access_Private" ), "Access_Private" },
|
||||
{ sizeof( "Access_Protected" ), "Access_Protected" },
|
||||
{ sizeof( "Access_Public" ), "Access_Public" },
|
||||
{ sizeof( "PlatformAttributes" ), "PlatformAttributes" },
|
||||
{ sizeof( "Class" ), "Class" },
|
||||
{ sizeof( "Class_Fwd" ), "Class_Fwd" },
|
||||
{ sizeof( "Class_Body" ), "Class_Body" },
|
||||
{ sizeof( "Constructor" ), "Constructor" },
|
||||
{ sizeof( "Constructor_Fwd" ), "Constructor_Fwd" },
|
||||
{ sizeof( "Destructor" ), "Destructor" },
|
||||
{ sizeof( "Destructor_Fwd" ), "Destructor_Fwd" },
|
||||
{ sizeof( "Enum" ), "Enum" },
|
||||
{ sizeof( "Enum_Fwd" ), "Enum_Fwd" },
|
||||
{ sizeof( "Enum_Body" ), "Enum_Body" },
|
||||
{ sizeof( "Enum_Class" ), "Enum_Class" },
|
||||
{ sizeof( "Enum_Class_Fwd" ), "Enum_Class_Fwd" },
|
||||
{ sizeof( "Execution" ), "Execution" },
|
||||
{ sizeof( "Export_Body" ), "Export_Body" },
|
||||
{ sizeof( "Extern_Linkage" ), "Extern_Linkage" },
|
||||
{ sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" },
|
||||
{ sizeof( "Friend" ), "Friend" },
|
||||
{ sizeof( "Function" ), "Function" },
|
||||
{ sizeof( "Function_Fwd" ), "Function_Fwd" },
|
||||
{ sizeof( "Function_Body" ), "Function_Body" },
|
||||
{ sizeof( "Global_Body" ), "Global_Body" },
|
||||
{ sizeof( "Module" ), "Module" },
|
||||
{ sizeof( "Namespace" ), "Namespace" },
|
||||
{ sizeof( "Namespace_Body" ), "Namespace_Body" },
|
||||
{ sizeof( "Operator" ), "Operator" },
|
||||
{ sizeof( "Operator_Fwd" ), "Operator_Fwd" },
|
||||
{ sizeof( "Operator_Member" ), "Operator_Member" },
|
||||
{ sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" },
|
||||
{ sizeof( "Operator_Cast" ), "Operator_Cast" },
|
||||
{ sizeof( "Operator_Cast_Fwd" ), "Operator_Cast_Fwd" },
|
||||
{ sizeof( "Parameters" ), "Parameters" },
|
||||
{ sizeof( "Preprocess_Define" ), "Preprocess_Define" },
|
||||
{ sizeof( "Preprocess_Include" ), "Preprocess_Include" },
|
||||
{ sizeof( "Preprocess_If" ), "Preprocess_If" },
|
||||
{ sizeof( "Preprocess_IfDef" ), "Preprocess_IfDef" },
|
||||
{ sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" },
|
||||
{ sizeof( "Preprocess_ElIf" ), "Preprocess_ElIf" },
|
||||
{ sizeof( "Preprocess_Else" ), "Preprocess_Else" },
|
||||
{ sizeof( "Preprocess_EndIf" ), "Preprocess_EndIf" },
|
||||
{ sizeof( "Preprocess_Pragma" ), "Preprocess_Pragma" },
|
||||
{ sizeof( "Specifiers" ), "Specifiers" },
|
||||
{ sizeof( "Struct" ), "Struct" },
|
||||
{ sizeof( "Struct_Fwd" ), "Struct_Fwd" },
|
||||
{ sizeof( "Struct_Body" ), "Struct_Body" },
|
||||
{ sizeof( "Template" ), "Template" },
|
||||
{ sizeof( "Typedef" ), "Typedef" },
|
||||
{ sizeof( "Typename" ), "Typename" },
|
||||
{ sizeof( "Union" ), "Union" },
|
||||
{ sizeof( "Union_Fwd" ), "Union_Fwd" },
|
||||
{ sizeof( "Union_Body" ), "Union_Body" },
|
||||
{ sizeof( "Using" ), "Using" },
|
||||
{ sizeof( "Using_Namespace" ), "Using_Namespace" },
|
||||
{ sizeof( "Variable" ), "Variable" },
|
||||
};
|
||||
return lookup[type];
|
||||
CT_Invalid,CT_Untyped,CT_NewLine,CT_Comment,CT_Access_Private,CT_Access_Protected,CT_Access_Public,CT_PlatformAttributes,CT_Class,CT_Class_Fwd,CT_Class_Body,CT_Constructor,CT_Constructor_Fwd,CT_Destructor,CT_Destructor_Fwd,CT_Enum,CT_Enum_Fwd,CT_Enum_Body,CT_Enum_Class,CT_Enum_Class_Fwd,CT_Execution,CT_Export_Body,CT_Extern_Linkage,CT_Extern_Linkage_Body,CT_Friend,CT_Function,CT_Function_Fwd,CT_Function_Body,CT_Global_Body,CT_Module,CT_Namespace,CT_Namespace_Body,CT_Operator,CT_Operator_Fwd,CT_Operator_Member,CT_Operator_Member_Fwd,CT_Operator_Cast,CT_Operator_Cast_Fwd,CT_Parameters,CT_Preprocess_Define,CT_Preprocess_Include,CT_Preprocess_If,CT_Preprocess_IfDef,CT_Preprocess_IfNotDef,CT_Preprocess_ElIf,CT_Preprocess_Else,CT_Preprocess_EndIf,CT_Preprocess_Pragma,CT_Specifiers,CT_Struct,CT_Struct_Fwd,CT_Struct_Body,CT_Template,CT_Typedef,CT_Typename,CT_Union,CT_Union_Fwd,CT_Union_Body,CT_Using,CT_Using_Namespace,CT_Variable,CT_NumTypes
|
||||
};
|
||||
typedef enum CodeType CodeType;
|
||||
inline
|
||||
StrC codetype_to_str( CodeType type)
|
||||
{
|
||||
local_persist StrC lookup[61] = { { sizeof("Invalid"), "Invalid" },
|
||||
{ sizeof("Untyped"), "Untyped" },
|
||||
{ sizeof("NewLine"), "NewLine" },
|
||||
{ sizeof("Comment"), "Comment" },
|
||||
{ sizeof("Access_Private"), "Access_Private" },
|
||||
{ sizeof("Access_Protected"), "Access_Protected" },
|
||||
{ sizeof("Access_Public"), "Access_Public" },
|
||||
{ sizeof("PlatformAttributes"), "PlatformAttributes" },
|
||||
{ sizeof("Class"), "Class" },
|
||||
{ sizeof("Class_Fwd"), "Class_Fwd" },
|
||||
{ sizeof("Class_Body"), "Class_Body" },
|
||||
{ sizeof("Constructor"), "Constructor" },
|
||||
{ sizeof("Constructor_Fwd"), "Constructor_Fwd" },
|
||||
{ sizeof("Destructor"), "Destructor" },
|
||||
{ sizeof("Destructor_Fwd"), "Destructor_Fwd" },
|
||||
{ sizeof("Enum"), "Enum" },
|
||||
{ sizeof("Enum_Fwd"), "Enum_Fwd" },
|
||||
{ sizeof("Enum_Body"), "Enum_Body" },
|
||||
{ sizeof("Enum_Class"), "Enum_Class" },
|
||||
{ sizeof("Enum_Class_Fwd"), "Enum_Class_Fwd" },
|
||||
{ sizeof("Execution"), "Execution" },
|
||||
{ sizeof("Export_Body"), "Export_Body" },
|
||||
{ sizeof("Extern_Linkage"), "Extern_Linkage" },
|
||||
{ sizeof("Extern_Linkage_Body"), "Extern_Linkage_Body" },
|
||||
{ sizeof("Friend"), "Friend" },
|
||||
{ sizeof("Function"), "Function" },
|
||||
{ sizeof("Function_Fwd"), "Function_Fwd" },
|
||||
{ sizeof("Function_Body"), "Function_Body" },
|
||||
{ sizeof("Global_Body"), "Global_Body" },
|
||||
{ sizeof("Module"), "Module" },
|
||||
{ sizeof("Namespace"), "Namespace" },
|
||||
{ sizeof("Namespace_Body"), "Namespace_Body" },
|
||||
{ sizeof("Operator"), "Operator" },
|
||||
{ sizeof("Operator_Fwd"), "Operator_Fwd" },
|
||||
{ sizeof("Operator_Member"), "Operator_Member" },
|
||||
{ sizeof("Operator_Member_Fwd"), "Operator_Member_Fwd" },
|
||||
{ sizeof("Operator_Cast"), "Operator_Cast" },
|
||||
{ sizeof("Operator_Cast_Fwd"), "Operator_Cast_Fwd" },
|
||||
{ sizeof("Parameters"), "Parameters" },
|
||||
{ sizeof("Preprocess_Define"), "Preprocess_Define" },
|
||||
{ sizeof("Preprocess_Include"), "Preprocess_Include" },
|
||||
{ sizeof("Preprocess_If"), "Preprocess_If" },
|
||||
{ sizeof("Preprocess_IfDef"), "Preprocess_IfDef" },
|
||||
{ sizeof("Preprocess_IfNotDef"), "Preprocess_IfNotDef" },
|
||||
{ sizeof("Preprocess_ElIf"), "Preprocess_ElIf" },
|
||||
{ sizeof("Preprocess_Else"), "Preprocess_Else" },
|
||||
{ sizeof("Preprocess_EndIf"), "Preprocess_EndIf" },
|
||||
{ sizeof("Preprocess_Pragma"), "Preprocess_Pragma" },
|
||||
{ sizeof("Specifiers"), "Specifiers" },
|
||||
{ sizeof("Struct"), "Struct" },
|
||||
{ sizeof("Struct_Fwd"), "Struct_Fwd" },
|
||||
{ sizeof("Struct_Body"), "Struct_Body" },
|
||||
{ sizeof("Template"), "Template" },
|
||||
{ sizeof("Typedef"), "Typedef" },
|
||||
{ sizeof("Typename"), "Typename" },
|
||||
{ sizeof("Union"), "Union" },
|
||||
{ sizeof("Union_Fwd"), "Union_Fwd" },
|
||||
{ sizeof("Union_Body"), "Union_Body" },
|
||||
{ sizeof("Using"), "Using" },
|
||||
{ sizeof("Using_Namespace"), "Using_Namespace" },
|
||||
{ sizeof("Variable"), "Variable" },
|
||||
}; return lookup[ type ];
|
||||
}
|
||||
|
||||
|
@ -1,111 +1,65 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
#pragma once #include "components/types.hpp"
|
||||
#pragma once
|
||||
#include "components/types.hpp"
|
||||
#endif
|
||||
|
||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
enum Operator_Def enum_underlying( u32 )
|
||||
|
||||
{ Op_Invalid,
|
||||
Op_Assign,
|
||||
Op_Assign_Add,
|
||||
Op_Assign_Subtract,
|
||||
Op_Assign_Multiply,
|
||||
Op_Assign_Divide,
|
||||
Op_Assign_Modulo,
|
||||
Op_Assign_BAnd,
|
||||
Op_Assign_BOr,
|
||||
Op_Assign_BXOr,
|
||||
Op_Assign_LShift,
|
||||
Op_Assign_RShift,
|
||||
Op_Increment,
|
||||
Op_Decrement,
|
||||
Op_Unary_Plus,
|
||||
Op_Unary_Minus,
|
||||
Op_UnaryNot,
|
||||
Op_Add,
|
||||
Op_Subtract,
|
||||
Op_Multiply,
|
||||
Op_Divide,
|
||||
Op_Modulo,
|
||||
Op_BNot,
|
||||
Op_BAnd,
|
||||
Op_BOr,
|
||||
Op_BXOr,
|
||||
Op_LShift,
|
||||
Op_RShift,
|
||||
Op_LAnd,
|
||||
Op_LOr,
|
||||
Op_LEqual,
|
||||
Op_LNot,
|
||||
Op_Lesser,
|
||||
Op_Greater,
|
||||
Op_LesserEqual,
|
||||
Op_GreaterEqual,
|
||||
Op_Subscript,
|
||||
Op_Indirection,
|
||||
Op_AddressOf,
|
||||
Op_MemberOfPointer,
|
||||
Op_PtrToMemOfPtr,
|
||||
Op_FunctionCall,
|
||||
Op_Comma,
|
||||
Op_New,
|
||||
Op_NewArray,
|
||||
Op_Delete,
|
||||
Op_DeleteArray,
|
||||
NumOps };
|
||||
typedef enum Operator_Def Operator;
|
||||
|
||||
inline StrC operator_to_str( Operator op )
|
||||
enum Operator : u32
|
||||
{
|
||||
local_persist StrC lookup[47] = {
|
||||
{ sizeof( "INVALID" ), "INVALID" },
|
||||
{ sizeof( "=" ), "=" },
|
||||
{ sizeof( "+=" ), "+=" },
|
||||
{ sizeof( "-=" ), "-=" },
|
||||
{ sizeof( "*=" ), "*=" },
|
||||
{ sizeof( "/=" ), "/=" },
|
||||
{ sizeof( "%=" ), "%=" },
|
||||
{ sizeof( "&=" ), "&=" },
|
||||
{ sizeof( "|=" ), "|=" },
|
||||
{ sizeof( "^=" ), "^=" },
|
||||
{ sizeof( "<<=" ), "<<=" },
|
||||
{ sizeof( ">>=" ), ">>=" },
|
||||
{ sizeof( "++" ), "++" },
|
||||
{ sizeof( "--" ), "--" },
|
||||
{ sizeof( "+" ), "+" },
|
||||
{ sizeof( "-" ), "-" },
|
||||
{ sizeof( "!" ), "!" },
|
||||
{ sizeof( "+" ), "+" },
|
||||
{ sizeof( "-" ), "-" },
|
||||
{ sizeof( "*" ), "*" },
|
||||
{ sizeof( "/" ), "/" },
|
||||
{ sizeof( "%" ), "%" },
|
||||
{ sizeof( "~" ), "~" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "|" ), "|" },
|
||||
{ sizeof( "^" ), "^" },
|
||||
{ sizeof( "<<" ), "<<" },
|
||||
{ sizeof( ">>" ), ">>" },
|
||||
{ sizeof( "&&" ), "&&" },
|
||||
{ sizeof( "||" ), "||" },
|
||||
{ sizeof( "==" ), "==" },
|
||||
{ sizeof( "!=" ), "!=" },
|
||||
{ sizeof( "<" ), "<" },
|
||||
{ sizeof( ">" ), ">" },
|
||||
{ sizeof( "<=" ), "<=" },
|
||||
{ sizeof( ">=" ), ">=" },
|
||||
{ sizeof( "[]" ), "[]" },
|
||||
{ sizeof( "*" ), "*" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "->" ), "->" },
|
||||
{ sizeof( "->*" ), "->*" },
|
||||
{ sizeof( "()" ), "()" },
|
||||
{ sizeof( "," ), "," },
|
||||
{ sizeof( "new" ), "new" },
|
||||
{ sizeof( "new[]" ), "new[]" },
|
||||
{ sizeof( "delete" ), "delete" },
|
||||
{ sizeof( "delete[]" ), "delete[]" },
|
||||
};
|
||||
return lookup[op];
|
||||
Op_Invalid,Op_Assign,Op_Assign_Add,Op_Assign_Subtract,Op_Assign_Multiply,Op_Assign_Divide,Op_Assign_Modulo,Op_Assign_BAnd,Op_Assign_BOr,Op_Assign_BXOr,Op_Assign_LShift,Op_Assign_RShift,Op_Increment,Op_Decrement,Op_Unary_Plus,Op_Unary_Minus,Op_UnaryNot,Op_Add,Op_Subtract,Op_Multiply,Op_Divide,Op_Modulo,Op_BNot,Op_BAnd,Op_BOr,Op_BXOr,Op_LShift,Op_RShift,Op_LAnd,Op_LOr,Op_LEqual,Op_LNot,Op_Lesser,Op_Greater,Op_LesserEqual,Op_GreaterEqual,Op_Subscript,Op_Indirection,Op_AddressOf,Op_MemberOfPointer,Op_PtrToMemOfPtr,Op_FunctionCall,Op_Comma,Op_New,Op_NewArray,Op_Delete,Op_DeleteArray,NumOps
|
||||
};
|
||||
typedef enum Operator Operator;
|
||||
inline
|
||||
StrC operator_to_str( Operator op)
|
||||
{
|
||||
local_persist StrC lookup[47] = { { sizeof("INVALID"), "INVALID" },
|
||||
{ sizeof("="), "=" },
|
||||
{ sizeof("+="), "+=" },
|
||||
{ sizeof("-="), "-=" },
|
||||
{ sizeof("*="), "*=" },
|
||||
{ sizeof("/="), "/=" },
|
||||
{ sizeof("%="), "%=" },
|
||||
{ sizeof("&="), "&=" },
|
||||
{ sizeof("|="), "|=" },
|
||||
{ sizeof("^="), "^=" },
|
||||
{ sizeof("<<="), "<<=" },
|
||||
{ sizeof(">>="), ">>=" },
|
||||
{ sizeof("++"), "++" },
|
||||
{ sizeof("--"), "--" },
|
||||
{ sizeof("+"), "+" },
|
||||
{ sizeof("-"), "-" },
|
||||
{ sizeof("!"), "!" },
|
||||
{ sizeof("+"), "+" },
|
||||
{ sizeof("-"), "-" },
|
||||
{ sizeof("*"), "*" },
|
||||
{ sizeof("/"), "/" },
|
||||
{ sizeof("%"), "%" },
|
||||
{ sizeof("~"), "~" },
|
||||
{ sizeof("&"), "&" },
|
||||
{ sizeof("|"), "|" },
|
||||
{ sizeof("^"), "^" },
|
||||
{ sizeof("<<"), "<<" },
|
||||
{ sizeof(">>"), ">>" },
|
||||
{ sizeof("&&"), "&&" },
|
||||
{ sizeof("||"), "||" },
|
||||
{ sizeof("=="), "==" },
|
||||
{ sizeof("!="), "!=" },
|
||||
{ sizeof("<"), "<" },
|
||||
{ sizeof(">"), ">" },
|
||||
{ sizeof("<="), "<=" },
|
||||
{ sizeof(">="), ">=" },
|
||||
{ sizeof("[]"), "[]" },
|
||||
{ sizeof("*"), "*" },
|
||||
{ sizeof("&"), "&" },
|
||||
{ sizeof("->"), "->" },
|
||||
{ sizeof("->*"), "->*" },
|
||||
{ sizeof("()"), "()" },
|
||||
{ sizeof(","), "," },
|
||||
{ sizeof("new"), "new" },
|
||||
{ sizeof("new[]"), "new[]" },
|
||||
{ sizeof("delete"), "delete" },
|
||||
{ sizeof("delete[]"), "delete[]" },
|
||||
}; return lookup[ op ];
|
||||
}
|
||||
|
||||
|
@ -1,68 +1,54 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
#pragma once #include "components/types.hpp"
|
||||
#pragma once
|
||||
#include "components/types.hpp"
|
||||
#endif
|
||||
|
||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
enum Specifier_Def enum_underlying( u32 )
|
||||
|
||||
{ Spec_Invalid, Spec_Consteval, Spec_Constexpr, Spec_Constinit, Spec_Explicit, Spec_External_Linkage, Spec_ForceInline,
|
||||
Spec_Global, Spec_Inline, Spec_Internal_Linkage, Spec_Local_Persist, Spec_Mutable, Spec_NeverInline, Spec_Ptr,
|
||||
Spec_Ref, Spec_Register, Spec_RValue, Spec_Static, Spec_Thread_Local, Spec_Virtual, Spec_Const,
|
||||
Spec_Final, Spec_NoExceptions, Spec_Override, Spec_Pure, Spec_Volatile, Spec_NumSpecifiers };
|
||||
typedef enum Specifier_Def Specifier;
|
||||
|
||||
inline bool spec_is_trailing( Specifier specifier )
|
||||
enum Specifier : u32
|
||||
{
|
||||
return specifier > Spec_Virtual;
|
||||
Spec_Invalid,Spec_Consteval,Spec_Constexpr,Spec_Constinit,Spec_Explicit,Spec_External_Linkage,Spec_ForceInline,Spec_Global,Spec_Inline,Spec_Internal_Linkage,Spec_Local_Persist,Spec_Mutable,Spec_NeverInline,Spec_Ptr,Spec_Ref,Spec_Register,Spec_RValue,Spec_Static,Spec_Thread_Local,Spec_Virtual,Spec_Const,Spec_Final,Spec_NoExceptions,Spec_Override,Spec_Pure,Spec_Volatile,Spec_NumSpecifiers
|
||||
};
|
||||
typedef enum Specifier Specifier;
|
||||
inline
|
||||
bool spec_is_trailing( Specifier specifier)
|
||||
{
|
||||
return specifier > Spec_Virtual;
|
||||
}
|
||||
inline
|
||||
StrC spec_to_str( Specifier type)
|
||||
{
|
||||
local_persist StrC lookup[26] = { { sizeof("INVALID"), "INVALID" },
|
||||
{ sizeof("consteval"), "consteval" },
|
||||
{ sizeof("constexpr"), "constexpr" },
|
||||
{ sizeof("constinit"), "constinit" },
|
||||
{ sizeof("explicit"), "explicit" },
|
||||
{ sizeof("extern"), "extern" },
|
||||
{ sizeof("forceinline"), "forceinline" },
|
||||
{ sizeof("global"), "global" },
|
||||
{ sizeof("inline"), "inline" },
|
||||
{ sizeof("internal"), "internal" },
|
||||
{ sizeof("local_persist"), "local_persist" },
|
||||
{ sizeof("mutable"), "mutable" },
|
||||
{ sizeof("neverinline"), "neverinline" },
|
||||
{ sizeof("*"), "*" },
|
||||
{ sizeof("&"), "&" },
|
||||
{ sizeof("register"), "register" },
|
||||
{ sizeof("&&"), "&&" },
|
||||
{ sizeof("static"), "static" },
|
||||
{ sizeof("thread_local"), "thread_local" },
|
||||
{ sizeof("virtual"), "virtual" },
|
||||
{ sizeof("const"), "const" },
|
||||
{ sizeof("final"), "final" },
|
||||
{ sizeof("noexcept"), "noexcept" },
|
||||
{ sizeof("override"), "override" },
|
||||
{ sizeof("= 0"), "= 0" },
|
||||
{ sizeof("volatile"), "volatile" },
|
||||
}; return lookup[ type ];
|
||||
}
|
||||
inline
|
||||
Specifier strc_to_specifier( StrC str)
|
||||
{
|
||||
local_persist u32 keymap[ Spec_NumSpecifiers ]; do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) { StrC enum_str = spec_to_str( (Specifier)index ); keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1); } do_once_end u32 hash = crc32( str.Ptr, str.Len ); for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) { if ( keymap[index] == hash ) return (Specifier)index; } return Spec_Invalid;
|
||||
}
|
||||
|
||||
inline StrC spec_to_str( Specifier type )
|
||||
{
|
||||
local_persist StrC lookup[26] = {
|
||||
{ sizeof( "INVALID" ), "INVALID" },
|
||||
{ sizeof( "consteval" ), "consteval" },
|
||||
{ sizeof( "constexpr" ), "constexpr" },
|
||||
{ sizeof( "constinit" ), "constinit" },
|
||||
{ sizeof( "explicit" ), "explicit" },
|
||||
{ sizeof( "extern" ), "extern" },
|
||||
{ sizeof( "forceinline" ), "forceinline" },
|
||||
{ sizeof( "global" ), "global" },
|
||||
{ sizeof( "inline" ), "inline" },
|
||||
{ sizeof( "internal" ), "internal" },
|
||||
{ sizeof( "local_persist" ), "local_persist" },
|
||||
{ sizeof( "mutable" ), "mutable" },
|
||||
{ sizeof( "neverinline" ), "neverinline" },
|
||||
{ sizeof( "*" ), "*" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "register" ), "register" },
|
||||
{ sizeof( "&&" ), "&&" },
|
||||
{ sizeof( "static" ), "static" },
|
||||
{ sizeof( "thread_local" ), "thread_local" },
|
||||
{ sizeof( "virtual" ), "virtual" },
|
||||
{ sizeof( "const" ), "const" },
|
||||
{ sizeof( "final" ), "final" },
|
||||
{ sizeof( "noexcept" ), "noexcept" },
|
||||
{ sizeof( "override" ), "override" },
|
||||
{ sizeof( "= 0" ), "= 0" },
|
||||
{ sizeof( "volatile" ), "volatile" },
|
||||
};
|
||||
return lookup[type];
|
||||
}
|
||||
|
||||
inline Specifier strc_to_specifier( StrC str )
|
||||
{
|
||||
local_persist u32 keymap[Spec_NumSpecifiers];
|
||||
do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
|
||||
{
|
||||
StrC enum_str = spec_to_str( (Specifier)index );
|
||||
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
||||
}
|
||||
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
||||
for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
|
||||
{
|
||||
if ( keymap[index] == hash )
|
||||
return (Specifier)index;
|
||||
}
|
||||
return Spec_Invalid;
|
||||
}
|
||||
|
@ -1,234 +1,124 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
#pragma once #include "components/types.hpp"
|
||||
#pragma once
|
||||
#include "components/types.hpp"
|
||||
#endif
|
||||
|
||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
GEN_NS_PARSER_BEGIN
|
||||
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" )
|
||||
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) \
|
||||
Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" )
|
||||
|
||||
enum TokType_Def : u32
|
||||
{
|
||||
Tok_Invalid,
|
||||
Tok_Access_Private,
|
||||
Tok_Access_Protected,
|
||||
Tok_Access_Public,
|
||||
Tok_Access_MemberSymbol,
|
||||
Tok_Access_StaticSymbol,
|
||||
Tok_Ampersand,
|
||||
Tok_Ampersand_DBL,
|
||||
Tok_Assign_Classifer,
|
||||
Tok_Attribute_Open,
|
||||
Tok_Attribute_Close,
|
||||
Tok_BraceCurly_Open,
|
||||
Tok_BraceCurly_Close,
|
||||
Tok_BraceSquare_Open,
|
||||
Tok_BraceSquare_Close,
|
||||
Tok_Capture_Start,
|
||||
Tok_Capture_End,
|
||||
Tok_Comment,
|
||||
Tok_Comment_End,
|
||||
Tok_Comment_Start,
|
||||
Tok_Char,
|
||||
Tok_Comma,
|
||||
Tok_Decl_Class,
|
||||
Tok_Decl_GNU_Attribute,
|
||||
Tok_Decl_MSVC_Attribute,
|
||||
Tok_Decl_Enum,
|
||||
Tok_Decl_Extern_Linkage,
|
||||
Tok_Decl_Friend,
|
||||
Tok_Decl_Module,
|
||||
Tok_Decl_Namespace,
|
||||
Tok_Decl_Operator,
|
||||
Tok_Decl_Struct,
|
||||
Tok_Decl_Template,
|
||||
Tok_Decl_Typedef,
|
||||
Tok_Decl_Using,
|
||||
Tok_Decl_Union,
|
||||
Tok_Identifier,
|
||||
Tok_Module_Import,
|
||||
Tok_Module_Export,
|
||||
Tok_NewLine,
|
||||
Tok_Number,
|
||||
Tok_Operator,
|
||||
Tok_Preprocess_Hash,
|
||||
Tok_Preprocess_Define,
|
||||
Tok_Preprocess_If,
|
||||
Tok_Preprocess_IfDef,
|
||||
Tok_Preprocess_IfNotDef,
|
||||
Tok_Preprocess_ElIf,
|
||||
Tok_Preprocess_Else,
|
||||
Tok_Preprocess_EndIf,
|
||||
Tok_Preprocess_Include,
|
||||
Tok_Preprocess_Pragma,
|
||||
Tok_Preprocess_Content,
|
||||
Tok_Preprocess_Macro,
|
||||
Tok_Preprocess_Unsupported,
|
||||
Tok_Spec_Alignas,
|
||||
Tok_Spec_Const,
|
||||
Tok_Spec_Consteval,
|
||||
Tok_Spec_Constexpr,
|
||||
Tok_Spec_Constinit,
|
||||
Tok_Spec_Explicit,
|
||||
Tok_Spec_Extern,
|
||||
Tok_Spec_Final,
|
||||
Tok_Spec_ForceInline,
|
||||
Tok_Spec_Global,
|
||||
Tok_Spec_Inline,
|
||||
Tok_Spec_Internal_Linkage,
|
||||
Tok_Spec_LocalPersist,
|
||||
Tok_Spec_Mutable,
|
||||
Tok_Spec_NeverInline,
|
||||
Tok_Spec_Override,
|
||||
Tok_Spec_Static,
|
||||
Tok_Spec_ThreadLocal,
|
||||
Tok_Spec_Volatile,
|
||||
Tok_Spec_Virtual,
|
||||
Tok_Star,
|
||||
Tok_Statement_End,
|
||||
Tok_StaticAssert,
|
||||
Tok_String,
|
||||
Tok_Type_Typename,
|
||||
Tok_Type_Unsigned,
|
||||
Tok_Type_Signed,
|
||||
Tok_Type_Short,
|
||||
Tok_Type_Long,
|
||||
Tok_Type_bool,
|
||||
Tok_Type_char,
|
||||
Tok_Type_int,
|
||||
Tok_Type_double,
|
||||
Tok_Type_MS_int8,
|
||||
Tok_Type_MS_int16,
|
||||
Tok_Type_MS_int32,
|
||||
Tok_Type_MS_int64,
|
||||
Tok_Type_MS_W64,
|
||||
Tok_Varadic_Argument,
|
||||
Tok___Attributes_Start,
|
||||
Tok_Attribute_API_Export,
|
||||
Tok_Attribute_API_Import,
|
||||
Tok_NumTokens
|
||||
Tok_Invalid,Tok_Access_Private,Tok_Access_Protected,Tok_Access_Public,Tok_Access_MemberSymbol,Tok_Access_StaticSymbol,Tok_Ampersand,Tok_Ampersand_DBL,Tok_Assign_Classifer,Tok_Attribute_Open,Tok_Attribute_Close,Tok_BraceCurly_Open,Tok_BraceCurly_Close,Tok_BraceSquare_Open,Tok_BraceSquare_Close,Tok_Capture_Start,Tok_Capture_End,Tok_Comment,Tok_Comment_End,Tok_Comment_Start,Tok_Char,Tok_Comma,Tok_Decl_Class,Tok_Decl_GNU_Attribute,Tok_Decl_MSVC_Attribute,Tok_Decl_Enum,Tok_Decl_Extern_Linkage,Tok_Decl_Friend,Tok_Decl_Module,Tok_Decl_Namespace,Tok_Decl_Operator,Tok_Decl_Struct,Tok_Decl_Template,Tok_Decl_Typedef,Tok_Decl_Using,Tok_Decl_Union,Tok_Identifier,Tok_Module_Import,Tok_Module_Export,Tok_NewLine,Tok_Number,Tok_Operator,Tok_Preprocess_Hash,Tok_Preprocess_Define,Tok_Preprocess_If,Tok_Preprocess_IfDef,Tok_Preprocess_IfNotDef,Tok_Preprocess_ElIf,Tok_Preprocess_Else,Tok_Preprocess_EndIf,Tok_Preprocess_Include,Tok_Preprocess_Pragma,Tok_Preprocess_Content,Tok_Preprocess_Macro,Tok_Preprocess_Unsupported,Tok_Spec_Alignas,Tok_Spec_Const,Tok_Spec_Consteval,Tok_Spec_Constexpr,Tok_Spec_Constinit,Tok_Spec_Explicit,Tok_Spec_Extern,Tok_Spec_Final,Tok_Spec_ForceInline,Tok_Spec_Global,Tok_Spec_Inline,Tok_Spec_Internal_Linkage,Tok_Spec_LocalPersist,Tok_Spec_Mutable,Tok_Spec_NeverInline,Tok_Spec_Override,Tok_Spec_Static,Tok_Spec_ThreadLocal,Tok_Spec_Volatile,Tok_Spec_Virtual,Tok_Star,Tok_Statement_End,Tok_StaticAssert,Tok_String,Tok_Type_Typename,Tok_Type_Unsigned,Tok_Type_Signed,Tok_Type_Short,Tok_Type_Long,Tok_Type_bool,Tok_Type_char,Tok_Type_int,Tok_Type_double,Tok_Type_MS_int8,Tok_Type_MS_int16,Tok_Type_MS_int32,Tok_Type_MS_int64,Tok_Type_MS_W64,Tok_Varadic_Argument,Tok___Attributes_Start,Tok_Attribute_API_Export,Tok_Attribute_API_Import,Tok_NumTokens
|
||||
};
|
||||
typedef enum TokType_Def TokType;
|
||||
|
||||
inline StrC to_str( TokType type )
|
||||
inline
|
||||
StrC to_str( TokType type)
|
||||
{
|
||||
local_persist StrC lookup[] {
|
||||
{ sizeof( "__invalid__" ), "__invalid__" },
|
||||
{ sizeof( "private" ), "private" },
|
||||
{ sizeof( "protected" ), "protected" },
|
||||
{ sizeof( "public" ), "public" },
|
||||
{ sizeof( "." ), "." },
|
||||
{ sizeof( "::" ), "::" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "&&" ), "&&" },
|
||||
{ sizeof( ":" ), ":" },
|
||||
{ sizeof( "[[" ), "[[" },
|
||||
{ sizeof( "]]" ), "]]" },
|
||||
{ sizeof( "{" ), "{" },
|
||||
{ sizeof( "}" ), "}" },
|
||||
{ sizeof( "[" ), "[" },
|
||||
{ sizeof( "]" ), "]" },
|
||||
{ sizeof( "(" ), "(" },
|
||||
{ sizeof( ")" ), ")" },
|
||||
{ sizeof( "__comment__" ), "__comment__" },
|
||||
{ sizeof( "__comment_end__" ), "__comment_end__" },
|
||||
{ sizeof( "__comment_start__" ), "__comment_start__" },
|
||||
{ sizeof( "__character__" ), "__character__" },
|
||||
{ sizeof( "," ), "," },
|
||||
{ sizeof( "class" ), "class" },
|
||||
{ sizeof( "__attribute__" ), "__attribute__" },
|
||||
{ sizeof( "__declspec" ), "__declspec" },
|
||||
{ sizeof( "enum" ), "enum" },
|
||||
{ sizeof( "extern" ), "extern" },
|
||||
{ sizeof( "friend" ), "friend" },
|
||||
{ sizeof( "module" ), "module" },
|
||||
{ sizeof( "namespace" ), "namespace" },
|
||||
{ sizeof( "operator" ), "operator" },
|
||||
{ sizeof( "struct" ), "struct" },
|
||||
{ sizeof( "template" ), "template" },
|
||||
{ sizeof( "typedef" ), "typedef" },
|
||||
{ sizeof( "using" ), "using" },
|
||||
{ sizeof( "union" ), "union" },
|
||||
{ sizeof( "__identifier__" ), "__identifier__" },
|
||||
{ sizeof( "import" ), "import" },
|
||||
{ sizeof( "export" ), "export" },
|
||||
{ sizeof( "__new_line__" ), "__new_line__" },
|
||||
{ sizeof( "__number__" ), "__number__" },
|
||||
{ sizeof( "__operator__" ), "__operator__" },
|
||||
{ sizeof( "#" ), "#" },
|
||||
{ sizeof( "define" ), "define" },
|
||||
{ sizeof( "if" ), "if" },
|
||||
{ sizeof( "ifdef" ), "ifdef" },
|
||||
{ sizeof( "ifndef" ), "ifndef" },
|
||||
{ sizeof( "elif" ), "elif" },
|
||||
{ sizeof( "else" ), "else" },
|
||||
{ sizeof( "endif" ), "endif" },
|
||||
{ sizeof( "include" ), "include" },
|
||||
{ sizeof( "pragma" ), "pragma" },
|
||||
{ sizeof( "__macro_content__" ), "__macro_content__" },
|
||||
{ sizeof( "__macro__" ), "__macro__" },
|
||||
{ sizeof( "__unsupported__" ), "__unsupported__" },
|
||||
{ sizeof( "alignas" ), "alignas" },
|
||||
{ sizeof( "const" ), "const" },
|
||||
{ sizeof( "consteval" ), "consteval" },
|
||||
{ sizeof( "constexpr" ), "constexpr" },
|
||||
{ sizeof( "constinit" ), "constinit" },
|
||||
{ sizeof( "explicit" ), "explicit" },
|
||||
{ sizeof( "extern" ), "extern" },
|
||||
{ sizeof( "final" ), "final" },
|
||||
{ sizeof( "forceinline" ), "forceinline" },
|
||||
{ sizeof( "global" ), "global" },
|
||||
{ sizeof( "inline" ), "inline" },
|
||||
{ sizeof( "internal" ), "internal" },
|
||||
{ sizeof( "local_persist" ), "local_persist" },
|
||||
{ sizeof( "mutable" ), "mutable" },
|
||||
{ sizeof( "neverinline" ), "neverinline" },
|
||||
{ sizeof( "override" ), "override" },
|
||||
{ sizeof( "static" ), "static" },
|
||||
{ sizeof( "thread_local" ), "thread_local" },
|
||||
{ sizeof( "volatile" ), "volatile" },
|
||||
{ sizeof( "virtual" ), "virtual" },
|
||||
{ sizeof( "*" ), "*" },
|
||||
{ sizeof( ";" ), ";" },
|
||||
{ sizeof( "static_assert" ), "static_assert" },
|
||||
{ sizeof( "__string__" ), "__string__" },
|
||||
{ sizeof( "typename" ), "typename" },
|
||||
{ sizeof( "unsigned" ), "unsigned" },
|
||||
{ sizeof( "signed" ), "signed" },
|
||||
{ sizeof( "short" ), "short" },
|
||||
{ sizeof( "long" ), "long" },
|
||||
{ sizeof( "bool" ), "bool" },
|
||||
{ sizeof( "char" ), "char" },
|
||||
{ sizeof( "int" ), "int" },
|
||||
{ sizeof( "double" ), "double" },
|
||||
{ sizeof( "__int8" ), "__int8" },
|
||||
{ sizeof( "__int16" ), "__int16" },
|
||||
{ sizeof( "__int32" ), "__int32" },
|
||||
{ sizeof( "__int64" ), "__int64" },
|
||||
{ sizeof( "_W64" ), "_W64" },
|
||||
{ sizeof( "..." ), "..." },
|
||||
{ sizeof( "__attrib_start__" ), "__attrib_start__" },
|
||||
{ sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" },
|
||||
{ sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" },
|
||||
};
|
||||
return lookup[type];
|
||||
local_persist StrC lookup[] { { sizeof("__invalid__"), "__invalid__" },
|
||||
{ sizeof("private"), "private" },
|
||||
{ sizeof("protected"), "protected" },
|
||||
{ sizeof("public"), "public" },
|
||||
{ sizeof("."), "." },
|
||||
{ sizeof("::"), "::" },
|
||||
{ sizeof("&"), "&" },
|
||||
{ sizeof("&&"), "&&" },
|
||||
{ sizeof(":"), ":" },
|
||||
{ sizeof("[["), "[[" },
|
||||
{ sizeof("]]"), "]]" },
|
||||
{ sizeof("{"), "{" },
|
||||
{ sizeof("}"), "}" },
|
||||
{ sizeof("["), "[" },
|
||||
{ sizeof("]"), "]" },
|
||||
{ sizeof("("), "(" },
|
||||
{ sizeof(")"), ")" },
|
||||
{ sizeof("__comment__"), "__comment__" },
|
||||
{ sizeof("__comment_end__"), "__comment_end__" },
|
||||
{ sizeof("__comment_start__"), "__comment_start__" },
|
||||
{ sizeof("__character__"), "__character__" },
|
||||
{ sizeof(","), "," },
|
||||
{ sizeof("class"), "class" },
|
||||
{ sizeof("__attribute__"), "__attribute__" },
|
||||
{ sizeof("__declspec"), "__declspec" },
|
||||
{ sizeof("enum"), "enum" },
|
||||
{ sizeof("extern"), "extern" },
|
||||
{ sizeof("friend"), "friend" },
|
||||
{ sizeof("module"), "module" },
|
||||
{ sizeof("namespace"), "namespace" },
|
||||
{ sizeof("operator"), "operator" },
|
||||
{ sizeof("struct"), "struct" },
|
||||
{ sizeof("template"), "template" },
|
||||
{ sizeof("typedef"), "typedef" },
|
||||
{ sizeof("using"), "using" },
|
||||
{ sizeof("union"), "union" },
|
||||
{ sizeof("__identifier__"), "__identifier__" },
|
||||
{ sizeof("import"), "import" },
|
||||
{ sizeof("export"), "export" },
|
||||
{ sizeof("__new_line__"), "__new_line__" },
|
||||
{ sizeof("__number__"), "__number__" },
|
||||
{ sizeof("__operator__"), "__operator__" },
|
||||
{ sizeof("#"), "#" },
|
||||
{ sizeof("define"), "define" },
|
||||
{ sizeof("if"), "if" },
|
||||
{ sizeof("ifdef"), "ifdef" },
|
||||
{ sizeof("ifndef"), "ifndef" },
|
||||
{ sizeof("elif"), "elif" },
|
||||
{ sizeof("else"), "else" },
|
||||
{ sizeof("endif"), "endif" },
|
||||
{ sizeof("include"), "include" },
|
||||
{ sizeof("pragma"), "pragma" },
|
||||
{ sizeof("__macro_content__"), "__macro_content__" },
|
||||
{ sizeof("__macro__"), "__macro__" },
|
||||
{ sizeof("__unsupported__"), "__unsupported__" },
|
||||
{ sizeof("alignas"), "alignas" },
|
||||
{ sizeof("const"), "const" },
|
||||
{ sizeof("consteval"), "consteval" },
|
||||
{ sizeof("constexpr"), "constexpr" },
|
||||
{ sizeof("constinit"), "constinit" },
|
||||
{ sizeof("explicit"), "explicit" },
|
||||
{ sizeof("extern"), "extern" },
|
||||
{ sizeof("final"), "final" },
|
||||
{ sizeof("forceinline"), "forceinline" },
|
||||
{ sizeof("global"), "global" },
|
||||
{ sizeof("inline"), "inline" },
|
||||
{ sizeof("internal"), "internal" },
|
||||
{ sizeof("local_persist"), "local_persist" },
|
||||
{ sizeof("mutable"), "mutable" },
|
||||
{ sizeof("neverinline"), "neverinline" },
|
||||
{ sizeof("override"), "override" },
|
||||
{ sizeof("static"), "static" },
|
||||
{ sizeof("thread_local"), "thread_local" },
|
||||
{ sizeof("volatile"), "volatile" },
|
||||
{ sizeof("virtual"), "virtual" },
|
||||
{ sizeof("*"), "*" },
|
||||
{ sizeof(";"), ";" },
|
||||
{ sizeof("static_assert"), "static_assert" },
|
||||
{ sizeof("__string__"), "__string__" },
|
||||
{ sizeof("typename"), "typename" },
|
||||
{ sizeof("unsigned"), "unsigned" },
|
||||
{ sizeof("signed"), "signed" },
|
||||
{ sizeof("short"), "short" },
|
||||
{ sizeof("long"), "long" },
|
||||
{ sizeof("bool"), "bool" },
|
||||
{ sizeof("char"), "char" },
|
||||
{ sizeof("int"), "int" },
|
||||
{ sizeof("double"), "double" },
|
||||
{ sizeof("__int8"), "__int8" },
|
||||
{ sizeof("__int16"), "__int16" },
|
||||
{ sizeof("__int32"), "__int32" },
|
||||
{ sizeof("__int64"), "__int64" },
|
||||
{ sizeof("_W64"), "_W64" },
|
||||
{ sizeof("..."), "..." },
|
||||
{ sizeof("__attrib_start__"), "__attrib_start__" },
|
||||
{ sizeof("GEN_API_Export_Code"), "GEN_API_Export_Code" },
|
||||
{ sizeof("GEN_API_Import_Code"), "GEN_API_Import_Code" },
|
||||
}; return lookup[ type ];
|
||||
}
|
||||
|
||||
inline TokType to_toktype( StrC str )
|
||||
inline
|
||||
TokType to_toktype( StrC str)
|
||||
{
|
||||
local_persist u32 keymap[Tok_NumTokens];
|
||||
do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||
{
|
||||
StrC enum_str = to_str( (TokType)index );
|
||||
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
||||
}
|
||||
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
||||
for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||
{
|
||||
if ( keymap[index] == hash )
|
||||
return (TokType)index;
|
||||
}
|
||||
return Tok_Invalid;
|
||||
local_persist u32 keymap[ Tok_NumTokens ]; do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ ) { StrC enum_str = to_str( (TokType)index ); keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1); } do_once_end u32 hash = crc32( str.Ptr, str.Len ); for ( u32 index = 0; index < Tok_NumTokens; index++ ) { if ( keymap[index] == hash ) return (TokType)index; } return Tok_Invalid;
|
||||
}
|
||||
|
||||
GEN_NS_PARSER_END
|
||||
|
@ -7,10 +7,11 @@
|
||||
inline
|
||||
void code_append( Code self, Code other )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(other.ast != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(other);
|
||||
GEN_ASSERT_MSG(self != other, "Attempted to recursively append Code AST to itself.");
|
||||
|
||||
if ( other->Parent )
|
||||
if ( other->Parent != nullptr )
|
||||
other = code_duplicate(other);
|
||||
|
||||
other->Parent = self;
|
||||
@ -34,7 +35,7 @@ void code_append( Code self, Code other )
|
||||
inline
|
||||
bool code_is_body(Code self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
switch (self->Type)
|
||||
{
|
||||
case CT_Enum_Body:
|
||||
@ -53,7 +54,7 @@ bool code_is_body(Code self)
|
||||
inline
|
||||
Code* code_entry( Code self, u32 idx )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(self != nullptr);
|
||||
Code* current = & self->Front;
|
||||
while ( idx >= 0 && current != nullptr )
|
||||
{
|
||||
@ -66,29 +67,31 @@ Code* code_entry( Code self, u32 idx )
|
||||
|
||||
return rcast( Code*, current);
|
||||
}
|
||||
inline
|
||||
forceinline
|
||||
bool code_is_valid(Code self)
|
||||
{
|
||||
return self.ast != nullptr && self.ast->Type != CT_Invalid;
|
||||
GEN_ASSERT(self);
|
||||
return self != nullptr && self->Type != CT_Invalid;
|
||||
}
|
||||
inline
|
||||
forceinline
|
||||
bool code_has_entries(AST* self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
return self->NumEntries > 0;
|
||||
}
|
||||
inline
|
||||
forceinline
|
||||
void code_set_global(Code self)
|
||||
{
|
||||
if ( self.ast == nullptr )
|
||||
if ( self == nullptr )
|
||||
{
|
||||
log_failure("Code::set_global: Cannot set code as global, AST is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
self->Parent.ast = Code_Global.ast;
|
||||
self->Parent = Code_Global;
|
||||
}
|
||||
inline
|
||||
#if GEN_COMPILER_CPP
|
||||
forceinline
|
||||
Code& Code::operator ++()
|
||||
{
|
||||
if ( ast )
|
||||
@ -96,7 +99,8 @@ Code& Code::operator ++()
|
||||
|
||||
return * this;
|
||||
}
|
||||
inline
|
||||
#endif
|
||||
forceinline
|
||||
char const* code_type_str(Code self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
@ -106,49 +110,57 @@ char const* code_type_str(Code self)
|
||||
|
||||
#pragma region CodeBody
|
||||
inline
|
||||
void append( CodeBody self, Code other )
|
||||
void body_append( CodeBody self, Code other )
|
||||
{
|
||||
GEN_ASSERT(other.ast != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(other);
|
||||
|
||||
if (code_is_body(other)) {
|
||||
append( self, cast(CodeBody, other) );
|
||||
body_append_body( self, cast(CodeBody, other) );
|
||||
return;
|
||||
}
|
||||
|
||||
code_append( cast(Code, self), other );
|
||||
}
|
||||
inline
|
||||
void append( CodeBody self, CodeBody body )
|
||||
void body_append_body( CodeBody self, CodeBody body )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(body);
|
||||
GEN_ASSERT_MSG(self != body, "Attempted to append body to itself.");
|
||||
|
||||
for ( Code entry : body ) {
|
||||
append( self, entry );
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); entry = next_CodeBody(body, entry) ) {
|
||||
body_append( self, entry );
|
||||
}
|
||||
}
|
||||
inline
|
||||
Code begin( CodeBody body) {
|
||||
if ( body.ast )
|
||||
return { rcast( AST*, body.ast)->Front };
|
||||
Code begin_CodeBody( CodeBody body) {
|
||||
GEN_ASSERT(body);
|
||||
if ( body != nullptr )
|
||||
return body->Front;
|
||||
return { nullptr };
|
||||
}
|
||||
inline
|
||||
Code end(CodeBody body ){
|
||||
return { rcast(AST*, body.ast)->Back->Next };
|
||||
forceinline
|
||||
Code end_CodeBody(CodeBody body ){
|
||||
GEN_ASSERT(body);
|
||||
return body->Back->Next;
|
||||
}
|
||||
inline
|
||||
Code next(CodeBody body, Code entry) {
|
||||
Code next_CodeBody(CodeBody body, Code entry) {
|
||||
GEN_ASSERT(body);
|
||||
GEN_ASSERT(entry);
|
||||
return entry->Next;
|
||||
}
|
||||
#pragma endregion CodeBody
|
||||
|
||||
#pragma region CodeClass
|
||||
inline
|
||||
void add_interface( CodeClass self, CodeTypename type )
|
||||
void class_add_interface( CodeClass self, CodeTypename type )
|
||||
{
|
||||
GEN_ASSERT(self.ast !=nullptr);
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(type);
|
||||
CodeTypename possible_slot = self->ParentType;
|
||||
if ( possible_slot.ast )
|
||||
if ( possible_slot != nullptr )
|
||||
{
|
||||
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
||||
self->ParentAccess = AccessSpec_Public;
|
||||
@ -156,24 +168,25 @@ void add_interface( CodeClass self, CodeTypename type )
|
||||
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
|
||||
}
|
||||
|
||||
while ( possible_slot.ast != nullptr )
|
||||
while ( possible_slot != nullptr )
|
||||
{
|
||||
possible_slot.ast = (AST_Typename*) possible_slot->Next.ast;
|
||||
possible_slot = possible_slot->Next;
|
||||
}
|
||||
|
||||
possible_slot.ast = type.ast;
|
||||
possible_slot = type;
|
||||
}
|
||||
#pragma endregion CodeClass
|
||||
|
||||
#pragma region CodeParam
|
||||
inline
|
||||
void append( CodeParam appendee, CodeParam other )
|
||||
void params_append( CodeParam appendee, CodeParam other )
|
||||
{
|
||||
GEN_ASSERT(appendee.ast != nullptr);
|
||||
GEN_ASSERT(appendee);
|
||||
GEN_ASSERT(other);
|
||||
Code self = cast(Code, appendee);
|
||||
Code entry = cast(Code, other);
|
||||
|
||||
if ( entry->Parent )
|
||||
if ( entry->Parent != nullptr )
|
||||
entry = code_duplicate( entry );
|
||||
|
||||
entry->Parent = self;
|
||||
@ -191,54 +204,61 @@ void append( CodeParam appendee, CodeParam other )
|
||||
self->NumEntries++;
|
||||
}
|
||||
inline
|
||||
CodeParam get(CodeParam self, s32 idx )
|
||||
CodeParam params_get(CodeParam self, s32 idx )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
CodeParam param = * self;
|
||||
GEN_ASSERT(self);
|
||||
CodeParam param = self;
|
||||
do
|
||||
{
|
||||
if ( ! ++ param )
|
||||
if ( ++ param != nullptr )
|
||||
return { nullptr };
|
||||
|
||||
param = cast(Code, param)->Next;
|
||||
param = cast(CodeParam, cast(Code, param)->Next);
|
||||
}
|
||||
while ( --idx );
|
||||
|
||||
return param;
|
||||
}
|
||||
inline
|
||||
bool has_entries(CodeParam self)
|
||||
forceinline
|
||||
bool params_has_entries(CodeParam self)
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
return self->NumEntries > 0;
|
||||
}
|
||||
inline
|
||||
#if GEN_COMPILER_CPP
|
||||
forceinline
|
||||
CodeParam& CodeParam::operator ++()
|
||||
{
|
||||
ast = ast->Next.ast;
|
||||
* this = ast->Next;
|
||||
return * this;
|
||||
}
|
||||
inline
|
||||
CodeParam begin(CodeParam params)
|
||||
#endif
|
||||
forceinline
|
||||
CodeParam begin_CodeParam(CodeParam params)
|
||||
{
|
||||
if ( params.ast )
|
||||
return { params.ast };
|
||||
if ( params != nullptr )
|
||||
return params;
|
||||
|
||||
return { nullptr };
|
||||
return NullCode;
|
||||
}
|
||||
inline
|
||||
CodeParam end(CodeParam params)
|
||||
forceinline
|
||||
CodeParam end_CodeParam(CodeParam params)
|
||||
{
|
||||
// return { (AST_Param*) rcast( AST*, ast)->Last };
|
||||
return { nullptr };
|
||||
}
|
||||
forceinline
|
||||
CodeParam next_CodeParam(CodeParam params, CodeParam param_iter)
|
||||
{
|
||||
return params->Next;
|
||||
}
|
||||
#pragma endregion CodeParam
|
||||
|
||||
#pragma region CodeSpecifiers
|
||||
inline
|
||||
bool append(CodeSpecifiers self, Specifier spec )
|
||||
bool specifiers_append(CodeSpecifiers self, Specifier spec )
|
||||
{
|
||||
if ( self.ast == nullptr )
|
||||
if ( self == nullptr )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
||||
return false;
|
||||
@ -254,9 +274,9 @@ bool append(CodeSpecifiers self, Specifier spec )
|
||||
return true;
|
||||
}
|
||||
inline
|
||||
s32 has(CodeSpecifiers self, Specifier spec)
|
||||
s32 specifiers_has(CodeSpecifiers self, Specifier spec)
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(self != nullptr);
|
||||
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
|
||||
if ( self->ArrSpecs[ idx ] == spec )
|
||||
return idx;
|
||||
@ -264,10 +284,9 @@ s32 has(CodeSpecifiers self, Specifier spec)
|
||||
return -1;
|
||||
}
|
||||
inline
|
||||
s32 remove( CodeSpecifiers self, Specifier to_remove )
|
||||
s32 specifiers_remove( CodeSpecifiers self, Specifier to_remove )
|
||||
{
|
||||
AST_Specifiers* ast = self.ast;
|
||||
if ( ast == nullptr )
|
||||
if ( self == nullptr )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
||||
return -1;
|
||||
@ -304,19 +323,24 @@ s32 remove( CodeSpecifiers self, Specifier to_remove )
|
||||
}
|
||||
return result;
|
||||
}
|
||||
inline
|
||||
Specifier* begin(CodeSpecifiers self)
|
||||
forceinline
|
||||
Specifier* begin_CodeSpecifiers(CodeSpecifiers self)
|
||||
{
|
||||
if ( self.ast )
|
||||
if ( self != nullptr )
|
||||
return & self->ArrSpecs[0];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
inline
|
||||
Specifier* end(CodeSpecifiers self)
|
||||
forceinline
|
||||
Specifier* end_CodeSpecifiers(CodeSpecifiers self)
|
||||
{
|
||||
return self->ArrSpecs + self->NumEntries;
|
||||
}
|
||||
forceinline
|
||||
Specifier* next_CodeSpecifiers(CodeSpecifiers self, Specifier* spec_iter)
|
||||
{
|
||||
return spec_iter + 1;
|
||||
}
|
||||
#pragma endregion CodeSpecifiers
|
||||
|
||||
#pragma region CodeStruct
|
||||
@ -324,7 +348,7 @@ inline
|
||||
void add_interface(CodeStruct self, CodeTypename type )
|
||||
{
|
||||
CodeTypename possible_slot = self->ParentType;
|
||||
if ( possible_slot.ast )
|
||||
if ( possible_slot != nullptr )
|
||||
{
|
||||
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
||||
self->ParentAccess = AccessSpec_Public;
|
||||
@ -332,12 +356,12 @@ void add_interface(CodeStruct self, CodeTypename type )
|
||||
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
|
||||
}
|
||||
|
||||
while ( possible_slot.ast != nullptr )
|
||||
while ( possible_slot != nullptr )
|
||||
{
|
||||
possible_slot.ast = (AST_Typename*) possible_slot->Next.ast;
|
||||
possible_slot = possible_slot->Next;
|
||||
}
|
||||
|
||||
possible_slot.ast = type.ast;
|
||||
possible_slot = type;
|
||||
}
|
||||
#pragma endregion Code
|
||||
|
||||
|
@ -84,12 +84,12 @@ void define_constants()
|
||||
t_empty = (CodeTypename) make_code();
|
||||
t_empty->Type = CT_Typename;
|
||||
t_empty->Name = get_cached_string( txt("") );
|
||||
code_set_global(t_empty);
|
||||
code_set_global(cast(Code, t_empty));
|
||||
|
||||
access_private = make_code();
|
||||
access_private->Type = CT_Access_Private;
|
||||
access_private->Name = get_cached_string( txt("private:\n") );
|
||||
code_set_global(access_private);
|
||||
code_set_global(cast(Code, access_private));
|
||||
|
||||
access_protected = make_code();
|
||||
access_protected->Type = CT_Access_Protected;
|
||||
@ -102,50 +102,50 @@ void define_constants()
|
||||
code_set_global(access_public);
|
||||
|
||||
attrib_api_export = def_attributes( code(GEN_API_Export_Code));
|
||||
code_set_global(attrib_api_export);
|
||||
code_set_global(cast(Code, attrib_api_export));
|
||||
|
||||
attrib_api_import = def_attributes( code(GEN_API_Import_Code));
|
||||
code_set_global(attrib_api_import);
|
||||
code_set_global(cast(Code, attrib_api_import));
|
||||
|
||||
module_global_fragment = make_code();
|
||||
module_global_fragment->Type = CT_Untyped;
|
||||
module_global_fragment->Name = get_cached_string( txt("module;") );
|
||||
module_global_fragment->Content = module_global_fragment->Name;
|
||||
code_set_global(module_global_fragment);
|
||||
code_set_global(cast(Code, module_global_fragment));
|
||||
|
||||
module_private_fragment = make_code();
|
||||
module_private_fragment->Type = CT_Untyped;
|
||||
module_private_fragment->Name = get_cached_string( txt("module : private;") );
|
||||
module_private_fragment->Content = module_private_fragment->Name;
|
||||
code_set_global(module_private_fragment);
|
||||
code_set_global(cast(Code, module_private_fragment));
|
||||
|
||||
fmt_newline = make_code();
|
||||
fmt_newline->Type = CT_NewLine;
|
||||
code_set_global(fmt_newline);
|
||||
code_set_global((Code)fmt_newline);
|
||||
|
||||
pragma_once = (CodePragma) make_code();
|
||||
pragma_once->Type = CT_Preprocess_Pragma;
|
||||
pragma_once->Name = get_cached_string( txt("once") );
|
||||
pragma_once->Content = pragma_once->Name;
|
||||
code_set_global(pragma_once);
|
||||
code_set_global((Code)pragma_once);
|
||||
|
||||
param_varadic = (CodeTypename) make_code();
|
||||
param_varadic = (CodeParam) make_code();
|
||||
param_varadic->Type = CT_Parameters;
|
||||
param_varadic->Name = get_cached_string( txt("...") );
|
||||
param_varadic->ValueType = t_empty;
|
||||
code_set_global(param_varadic);
|
||||
code_set_global((Code)param_varadic);
|
||||
|
||||
preprocess_else = (CodePreprocessCond) make_code();
|
||||
preprocess_else->Type = CT_Preprocess_Else;
|
||||
code_set_global(preprocess_else);
|
||||
code_set_global((Code)preprocess_else);
|
||||
|
||||
preprocess_endif = (CodePreprocessCond) make_code();
|
||||
preprocess_endif->Type = CT_Preprocess_EndIf;
|
||||
code_set_global(preprocess_endif);
|
||||
code_set_global((Code)preprocess_endif);
|
||||
|
||||
# define def_constant_code_type( Type_ ) \
|
||||
t_##Type_ = def_type( name(Type_) ); \
|
||||
code_set_global(t_##Type_);
|
||||
code_set_global( cast(Code, t_##Type_));
|
||||
|
||||
def_constant_code_type( auto );
|
||||
def_constant_code_type( void );
|
||||
@ -180,7 +180,7 @@ void define_constants()
|
||||
|
||||
# define def_constant_spec( Type_, ... ) \
|
||||
spec_##Type_ = def_specifiers( num_args(__VA_ARGS__), __VA_ARGS__); \
|
||||
code_set_global(spec_##Type_);
|
||||
code_set_global( cast(Code, spec_##Type_));
|
||||
|
||||
# pragma push_macro("forceinline")
|
||||
# pragma push_macro("global")
|
||||
@ -218,7 +218,7 @@ void define_constants()
|
||||
def_constant_spec( volatile, Spec_Volatile)
|
||||
|
||||
spec_local_persist = def_specifiers( 1, Spec_Local_Persist );
|
||||
code_set_global(spec_local_persist);
|
||||
code_set_global(cast(Code, spec_local_persist));
|
||||
|
||||
# pragma pop_macro("forceinline")
|
||||
# pragma pop_macro("global")
|
||||
@ -426,7 +426,7 @@ Code make_code()
|
||||
}
|
||||
|
||||
Code result { rcast( AST*, alloc( pool_allocator_info(allocator), sizeof(AST) )) };
|
||||
mem_set( result.ast, 0, sizeof(AST) );
|
||||
mem_set( rcast(void*, cast(AST*, result)), 0, sizeof(AST) );
|
||||
// result->Type = ECode::Invalid;
|
||||
|
||||
// result->Content = { nullptr };
|
||||
|
@ -29,19 +29,19 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
} \
|
||||
if ( params_code->Type != CT_Parameters ) \
|
||||
{ \
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(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(params_code->ValueType, ret_type) ) \
|
||||
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, \
|
||||
code_debug_str(params_code), \
|
||||
code_debug_str(ret_type) \
|
||||
code_debug_str(cast(Code, params_code)), \
|
||||
code_debug_str(cast(Code, ret_type)) \
|
||||
); \
|
||||
return OpValResult_Fail; \
|
||||
}
|
||||
@ -54,7 +54,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
|
||||
if ( ret_type->Type != CT_Typename )
|
||||
{
|
||||
log_failure("gen::def_operator: ret_type is not of typename type - %s", code_debug_str(ret_type));
|
||||
log_failure("gen::def_operator: ret_type is not of typename type - %s", code_debug_str(cast(Code, ret_type)));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s does not support non-member definition (more than one parameter provided) - %s",
|
||||
operator_to_str(op),
|
||||
code_debug_str(params_code)
|
||||
code_debug_str(cast(Code, params_code))
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -102,7 +102,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
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(params_code)
|
||||
, code_debug_str(cast(Code, params_code))
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -117,7 +117,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s params code provided is not of Parameters type - %s"
|
||||
, operator_to_str(op)
|
||||
, code_debug_str(params_code)
|
||||
, code_debug_str(cast(Code, params_code))
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -125,7 +125,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
switch ( params_code->NumEntries )
|
||||
{
|
||||
case 1:
|
||||
if ( code_is_equal(params_code->ValueType, t_int ) )
|
||||
if ( code_is_equal((Code)params_code->ValueType, (Code)t_int ) )
|
||||
is_member_symbol = true;
|
||||
|
||||
else
|
||||
@ -135,7 +135,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
case 2:
|
||||
check_param_eq_ret();
|
||||
|
||||
if ( ! code_is_equal(get(params_code, 1), t_int ) )
|
||||
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",
|
||||
@ -164,18 +164,18 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(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(params_code->ValueType, ret_type ) )
|
||||
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(params_code)
|
||||
, code_debug_str(ret_type)
|
||||
, code_debug_str((Code)params_code)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -209,7 +209,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure( "gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code) );
|
||||
log_failure( "gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code) );
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
@ -245,14 +245,14 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( ! code_is_equal(params_code->ValueType, ret_type ) )
|
||||
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(params_code)
|
||||
, code_debug_str(ret_type)
|
||||
, code_debug_str((Code)params_code)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -275,7 +275,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code));
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
@ -289,11 +289,11 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! code_is_equal(ret_type, t_bool ))
|
||||
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"
|
||||
, operator_to_str(op)
|
||||
, code_debug_str(ret_type)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -347,7 +347,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
case Op_PtrToMemOfPtr:
|
||||
if ( params_code )
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s expects no paramters - %s", operator_to_str(op), code_debug_str(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;
|
||||
@ -390,7 +390,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
}
|
||||
|
||||
#define null_check( Context_, Code_ ) \
|
||||
if ( ! Code_ ) \
|
||||
if ( Code_ != nullptr ) \
|
||||
{ \
|
||||
log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \
|
||||
return InvalidCode; \
|
||||
@ -501,7 +501,7 @@ CodeConstructor def_constructor( Opts_def_constructor p )
|
||||
|
||||
if ( params && params->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_constructor: params must be of Parameters type - %s", code_debug_str(params));
|
||||
log_failure("gen::def_constructor: params must be of Parameters type - %s", code_debug_str((Code)params));
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ CodeClass def_class( StrC name, Opts_def_struct p )
|
||||
{
|
||||
for (s32 idx = 0; idx < num_interfaces; idx++ )
|
||||
{
|
||||
add_interface(result, interfaces[idx] );
|
||||
class_add_interface(result, interfaces[idx] );
|
||||
}
|
||||
}
|
||||
|
||||
@ -692,13 +692,13 @@ CodeEnum def_enum( StrC name, Opts_def_enum p )
|
||||
|
||||
if ( type && type->Type != CT_Typename )
|
||||
{
|
||||
log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", code_debug_str(type) );
|
||||
log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", code_debug_str((Code)type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( attributes && attributes->Type != CT_PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", code_debug_str(attributes) );
|
||||
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", code_debug_str((Code)attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1161,7 +1161,7 @@ CodeSpecifiers def_specifier( Specifier spec )
|
||||
CodeSpecifiers
|
||||
result = (CodeSpecifiers) make_code();
|
||||
result->Type = CT_Specifiers;
|
||||
append(result, spec );
|
||||
specifiers_append(result, spec );
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1178,7 +1178,7 @@ CodeStruct def_struct( StrC name, Opts_def_struct p )
|
||||
|
||||
if ( attributes && attributes->Type != CT_PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", code_debug_str(attributes) );
|
||||
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", code_debug_str(cast(Code, attributes)) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1273,19 +1273,19 @@ CodeTypename def_type( StrC name, Opts_def_type p )
|
||||
|
||||
if ( attributes && attributes->Type != CT_PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_type: attributes is not of attributes type - %s", code_debug_str(attributes) );
|
||||
log_failure( "gen::def_type: attributes is not of attributes type - %s", code_debug_str((Code)attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( specifiers && specifiers->Type != CT_Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_type: specifiers is not of specifiers type - %s", code_debug_str(specifiers) );
|
||||
log_failure( "gen::def_type: specifiers is not of specifiers type - %s", code_debug_str((Code)specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( arrayexpr && arrayexpr->Type != CT_Untyped )
|
||||
{
|
||||
log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str(arrayexpr) );
|
||||
log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str((Code)arrayexpr) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1325,13 +1325,13 @@ CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef p )
|
||||
case CT_Typename:
|
||||
break;
|
||||
default:
|
||||
log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", code_debug_str(type) );
|
||||
log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", code_debug_str((Code)type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( p.attributes && p.attributes->Type != CT_PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", code_debug_str(p.attributes) );
|
||||
log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", code_debug_str((Code)p.attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1553,7 +1553,7 @@ CodeBody def_class_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1590,7 +1590,7 @@ CodeBody def_class_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -1624,7 +1624,7 @@ CodeBody def_enum_body( s32 num, ... )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, entry );
|
||||
body_append(result, entry );
|
||||
}
|
||||
while ( num--, num > 0 );
|
||||
va_end(va);
|
||||
@ -1656,7 +1656,7 @@ CodeBody def_enum_body( s32 num, Code* codes )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, entry );
|
||||
body_append(result, entry );
|
||||
}
|
||||
while ( codes++, num--, num > 0 );
|
||||
|
||||
@ -1694,7 +1694,7 @@ CodeBody def_export_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1731,7 +1731,7 @@ CodeBody def_export_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -1769,7 +1769,7 @@ CodeBody def_extern_link_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1806,8 +1806,7 @@ CodeBody def_extern_link_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -1846,7 +1845,7 @@ CodeBody def_function_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1882,7 +1881,7 @@ CodeBody def_function_body( s32 num, Code* codes )
|
||||
default:
|
||||
break;
|
||||
}
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -1913,8 +1912,8 @@ CodeBody def_global_body( s32 num, ... )
|
||||
switch (entry->Type)
|
||||
{
|
||||
case CT_Global_Body:
|
||||
// result.append( entry.code_cast<CodeBody>() ) ;
|
||||
append( result, cast(CodeBody, entry) );
|
||||
// result.body_append( entry.code_cast<CodeBody>() ) ;
|
||||
body_append( result, cast(CodeBody, entry) );
|
||||
continue;
|
||||
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
@ -1925,7 +1924,7 @@ CodeBody def_global_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1955,7 +1954,7 @@ CodeBody def_global_body( s32 num, Code* codes )
|
||||
switch (entry->Type)
|
||||
{
|
||||
case CT_Global_Body:
|
||||
append(result, cast(CodeBody, entry) );
|
||||
body_append(result, cast(CodeBody, entry) );
|
||||
continue;
|
||||
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
@ -1966,7 +1965,7 @@ CodeBody def_global_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -2004,7 +2003,7 @@ CodeBody def_namespace_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -2040,7 +2039,7 @@ CodeBody def_namespace_body( s32 num, Code* codes )
|
||||
default: break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -2078,7 +2077,7 @@ CodeParam def_params( s32 num, ... )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, param );
|
||||
params_append(result, param );
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
@ -2114,7 +2113,7 @@ CodeParam def_params( s32 num, CodeParam* codes )
|
||||
while( codes++, current = * codes, num--, num > 0 )
|
||||
{
|
||||
check_current();
|
||||
append(result, current );
|
||||
params_append(result, current );
|
||||
}
|
||||
# undef check_current
|
||||
|
||||
@ -2145,7 +2144,7 @@ CodeSpecifiers def_specifiers( s32 num, ... )
|
||||
{
|
||||
Specifier type = (Specifier)va_arg(va, int);
|
||||
|
||||
append(result, type );
|
||||
specifiers_append(result, type );
|
||||
}
|
||||
while ( --num, num );
|
||||
va_end(va);
|
||||
@ -2174,7 +2173,7 @@ CodeSpecifiers def_specifiers( s32 num, Specifier* specs )
|
||||
s32 idx = 0;
|
||||
do
|
||||
{
|
||||
append(result, specs[idx] );
|
||||
specifiers_append(result, specs[idx] );
|
||||
idx++;
|
||||
}
|
||||
while ( --num, num );
|
||||
@ -2213,7 +2212,7 @@ CodeBody def_struct_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -2250,7 +2249,7 @@ CodeBody def_struct_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -2284,7 +2283,7 @@ CodeBody def_union_body( s32 num, ... )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, entry );
|
||||
body_append(result, entry );
|
||||
}
|
||||
while ( num--, num > 0 );
|
||||
va_end(va);
|
||||
@ -2316,7 +2315,7 @@ CodeBody def_union_body( s32 num, CodeUnion* codes )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, entry );
|
||||
body_append(result, entry );
|
||||
}
|
||||
while ( codes++, num--, num > 0 );
|
||||
|
||||
|
@ -1124,7 +1124,7 @@ CodeBody parse_class_struct_body( TokType which, Token name )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, member );
|
||||
body_append(result, member );
|
||||
}
|
||||
|
||||
eat( Tok_BraceCurly_Close );
|
||||
@ -1448,7 +1448,7 @@ CodeFn parse_function_after_name(
|
||||
continue;
|
||||
}
|
||||
|
||||
append(specifiers, strc_to_specifier( to_str(currtok)) );
|
||||
specifiers_append(specifiers, strc_to_specifier( to_str(currtok)) );
|
||||
eat( currtok.Type );
|
||||
}
|
||||
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>
|
||||
@ -1468,7 +1468,7 @@ CodeFn parse_function_after_name(
|
||||
else if ( check(Tok_Operator) && currtok.Text[0] == '=' )
|
||||
{
|
||||
eat(Tok_Operator);
|
||||
append(specifiers, Spec_Pure );
|
||||
specifiers_append(specifiers, Spec_Pure );
|
||||
|
||||
eat( Tok_Number);
|
||||
Token stmt_end = currtok;
|
||||
@ -1574,7 +1574,7 @@ Code parse_function_body()
|
||||
|
||||
if ( len > 0 )
|
||||
{
|
||||
append( result, def_execution( { len, start.Text } ) );
|
||||
body_append( result, def_execution( { len, start.Text } ) );
|
||||
}
|
||||
|
||||
eat( Tok_BraceCurly_Close );
|
||||
@ -1891,7 +1891,7 @@ CodeBody parse_global_nspace( CodeType which )
|
||||
}
|
||||
|
||||
// log_fmt("Global Body Member: %s", member->debug_str());
|
||||
append(result, member );
|
||||
body_append(result, member );
|
||||
}
|
||||
|
||||
if ( which != CT_Global_Body )
|
||||
@ -2455,7 +2455,7 @@ CodeOperator parse_operator_after_ret_type(
|
||||
continue;
|
||||
}
|
||||
|
||||
append(specifiers, strc_to_specifier( to_str(currtok)) );
|
||||
specifiers_append(specifiers, strc_to_specifier( to_str(currtok)) );
|
||||
eat( currtok.Type );
|
||||
}
|
||||
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers>
|
||||
@ -2771,7 +2771,7 @@ CodeParam parse_params( bool use_template_capture )
|
||||
if ( check( Tok_Varadic_Argument ) )
|
||||
{
|
||||
eat( Tok_Varadic_Argument );
|
||||
append(result, param_varadic );
|
||||
params_append(result, param_varadic );
|
||||
continue;
|
||||
// ( <Macro> <ValueType> <Name> = <Expression>, ...
|
||||
}
|
||||
@ -2875,7 +2875,7 @@ CodeParam parse_params( bool use_template_capture )
|
||||
if ( value )
|
||||
param->Value = value;
|
||||
|
||||
append(result, param );
|
||||
params_append(result, param );
|
||||
}
|
||||
|
||||
if ( ! use_template_capture )
|
||||
@ -3305,7 +3305,7 @@ CodeVar parse_variable_declaration_list()
|
||||
"(Parser will add and continue to specifiers, but will most likely fail to compile)\n%s"
|
||||
, to_string(Context) );
|
||||
|
||||
append(specifiers, spec );
|
||||
specifiers_append(specifiers, spec );
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3327,7 +3327,7 @@ CodeVar parse_variable_declaration_list()
|
||||
// eat(currtok.Type);
|
||||
|
||||
if ( specifiers )
|
||||
append(specifiers, spec );
|
||||
specifiers_append(specifiers, spec );
|
||||
else
|
||||
specifiers = def_specifier( spec );
|
||||
}
|
||||
@ -3467,7 +3467,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
|
||||
if ( check( Tok_Spec_Virtual ) )
|
||||
{
|
||||
if ( specifiers )
|
||||
append(specifiers, Spec_Virtual );
|
||||
specifiers_append(specifiers, Spec_Virtual );
|
||||
else
|
||||
specifiers = def_specifier( Spec_Virtual );
|
||||
eat( Tok_Spec_Virtual );
|
||||
@ -3510,7 +3510,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
|
||||
eat( Tok_Number );
|
||||
// <Virtual Specifier> ~<Name>() = 0
|
||||
|
||||
append(specifiers, Spec_Pure );
|
||||
specifiers_append(specifiers, Spec_Pure );
|
||||
}
|
||||
else if ( left && str_compare_len( upcoming.Text, "default", sizeof("default") - 1 ) == 0)
|
||||
{
|
||||
@ -3762,7 +3762,7 @@ CodeEnum parse_enum( bool inplace_def )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(body, member );
|
||||
body_append(body, member );
|
||||
}
|
||||
|
||||
eat( Tok_BraceCurly_Close );
|
||||
@ -4206,7 +4206,7 @@ CodeOpCast parse_operator_cast( CodeSpecifiers specifiers )
|
||||
specifiers = def_specifier( Spec_Const );
|
||||
|
||||
else
|
||||
append(specifiers, Spec_Const );
|
||||
specifiers_append(specifiers, Spec_Const );
|
||||
|
||||
eat( Tok_Spec_Const );
|
||||
}
|
||||
@ -4965,6 +4965,7 @@ CodeTypedef parse_typedef()
|
||||
name = currtok;
|
||||
eat(Tok_Identifier);
|
||||
}
|
||||
// <ModuleFalgs> typedef <Preprocessed_Macro> <Identifier>
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -5250,7 +5251,7 @@ CodeUnion parse_union( bool inplace_def )
|
||||
}
|
||||
|
||||
if ( member )
|
||||
append(body, member );
|
||||
body_append(body, member );
|
||||
}
|
||||
// <ModuleFlags> union <Attributes> <Name> { <Body>
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region Basic Types
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
#define GEN_U8_MIN 0u
|
||||
#define GEN_U8_MAX 0xffu
|
||||
@ -127,14 +126,12 @@ typedef s32 b32;
|
||||
typedef void* mem_ptr;
|
||||
typedef void const* mem_ptr_const ;
|
||||
|
||||
#if ! GEN_COMPILER_C
|
||||
GEN_API_C_END
|
||||
#if GEN_COMPILER_CPP
|
||||
template<typename Type> uptr to_uptr( Type* ptr ) { return (uptr)ptr; }
|
||||
template<typename Type> sptr to_sptr( Type* ptr ) { return (sptr)ptr; }
|
||||
|
||||
template<typename Type> mem_ptr to_mem_ptr ( Type ptr ) { return (mem_ptr) ptr; }
|
||||
template<typename Type> mem_ptr_const to_mem_ptr_const( Type ptr ) { return (mem_ptr_const)ptr; }
|
||||
GEN_API_C_BEGIN
|
||||
#else
|
||||
#define to_uptr( ptr ) ((uptr)(ptr))
|
||||
#define to_sptr( ptr ) ((sptr)(ptr))
|
||||
@ -143,5 +140,4 @@ GEN_API_C_BEGIN
|
||||
#define to_mem_ptr_const( ptr) ((mem_ptr)ptr)
|
||||
#endif
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion Basic Types
|
||||
|
@ -26,12 +26,9 @@ template <class TType> using TRemovePtr = typename RemovePtr<TType>::Type;
|
||||
|
||||
struct ArrayHeader;
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if GEN_COMPILER_CPP
|
||||
template<class Type> struct Array;
|
||||
# define get_array_underlying_type(array) typename TRemovePtr<typeof(array)>:: DataType
|
||||
#else
|
||||
template<class Type> using Array = Type*;
|
||||
# define get_array_underlying_type(array) TRemovePtr<typeof(array)>
|
||||
#endif
|
||||
|
||||
usize array_grow_formula(ssize value);
|
||||
@ -62,7 +59,7 @@ struct ArrayHeader {
|
||||
usize Num;
|
||||
};
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if GEN_COMPILER_CPP
|
||||
template<class Type>
|
||||
struct Array
|
||||
{
|
||||
@ -104,7 +101,7 @@ struct Array
|
||||
};
|
||||
#endif
|
||||
|
||||
#if GEN_SUPPORT_CPP_REFERENCES
|
||||
#if GEN_COMPILER_CPP && 0
|
||||
template<class Type> bool append(Array<Type>& array, Array<Type> other) { return GEN_NS append( & array, other ); }
|
||||
template<class Type> bool append(Array<Type>& array, Type value) { return GEN_NS append( & array, value ); }
|
||||
template<class Type> bool append(Array<Type>& array, Type* items, usize item_num) { return GEN_NS append( & array, items, item_num ); }
|
||||
|
@ -6,7 +6,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region Debug
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... )
|
||||
{
|
||||
@ -46,5 +45,4 @@ s32 assert_crash( char const* condition )
|
||||
}
|
||||
#endif
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion Debug
|
||||
|
@ -56,10 +56,8 @@
|
||||
while (0)
|
||||
#endif
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... );
|
||||
s32 assert_crash( char const* condition );
|
||||
void process_exit( u32 code );
|
||||
GEN_API_C_END
|
||||
|
||||
#pragma endregion Debug
|
||||
|
@ -4,7 +4,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region File Handling
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
#if defined( GEN_SYSTEM_WINDOWS ) || defined( GEN_SYSTEM_CYGWIN )
|
||||
|
||||
@ -656,5 +655,4 @@ GEN_FILE_CLOSE_PROC( _memory_file_close )
|
||||
|
||||
FileOperations const memory_file_operations = { _memory_file_read, _memory_file_write, _memory_file_seek, _memory_file_close };
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion File Handling
|
||||
|
@ -4,11 +4,10 @@
|
||||
#endif
|
||||
|
||||
#pragma region File Handling
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
typedef u32 FileMode;
|
||||
|
||||
enum FileModeFlag_Def
|
||||
enum FileModeFlag
|
||||
{
|
||||
EFileMode_READ = bit( 0 ),
|
||||
EFileMode_WRITE = bit( 1 ),
|
||||
@ -16,18 +15,16 @@ enum FileModeFlag_Def
|
||||
EFileMode_RW = bit( 3 ),
|
||||
GEN_FILE_MODES = EFileMode_READ | EFileMode_WRITE | EFileMode_APPEND | EFileMode_RW,
|
||||
};
|
||||
typedef enum FileModeFlag_Def FileModeFlag;
|
||||
|
||||
// NOTE: Only used internally and for the file operations
|
||||
enum SeekWhenceType_Def
|
||||
enum SeekWhenceType
|
||||
{
|
||||
ESeekWhence_BEGIN = 0,
|
||||
ESeekWhence_CURRENT = 1,
|
||||
ESeekWhence_END = 2,
|
||||
};
|
||||
typedef enum SeekWhenceType_Def SeekWhenceType;
|
||||
|
||||
enum FileError_Def
|
||||
enum FileError
|
||||
{
|
||||
EFileError_NONE,
|
||||
EFileError_INVALID,
|
||||
@ -40,17 +37,15 @@ enum FileError_Def
|
||||
EFileError_NAME_TOO_LONG,
|
||||
EFileError_UNKNOWN,
|
||||
};
|
||||
typedef enum FileError_Def FileError;
|
||||
|
||||
union FileDescriptor_Def
|
||||
union FileDescriptor
|
||||
{
|
||||
void* p;
|
||||
sptr i;
|
||||
uptr u;
|
||||
};
|
||||
typedef union FileDescriptor_Def FileDescriptor;
|
||||
|
||||
typedef struct FileOperations_Def FileOperations;
|
||||
typedef struct FileOperations FileOperations;
|
||||
|
||||
#define GEN_FILE_OPEN_PROC( name ) FileError name( FileDescriptor* fd, FileOperations* ops, FileMode mode, char const* filename )
|
||||
#define GEN_FILE_READ_AT_PROC( name ) b32 name( FileDescriptor fd, void* buffer, ssize size, s64 offset, ssize* bytes_read, b32 stop_at_newline )
|
||||
@ -64,39 +59,35 @@ typedef GEN_FILE_WRITE_AT_PROC( FileWriteProc );
|
||||
typedef GEN_FILE_SEEK_PROC( FileSeekProc );
|
||||
typedef GEN_FILE_CLOSE_PROC( FileCloseProc );
|
||||
|
||||
struct FileOperations_Def
|
||||
struct FileOperations
|
||||
{
|
||||
FileReadProc* read_at;
|
||||
FileWriteProc* write_at;
|
||||
FileSeekProc* seek;
|
||||
FileCloseProc* close;
|
||||
};
|
||||
typedef struct FileOperations_Def FileOperations;
|
||||
|
||||
extern FileOperations const default_file_operations;
|
||||
|
||||
typedef u64 FileTime;
|
||||
|
||||
enum DirType_Def
|
||||
enum DirType
|
||||
{
|
||||
GEN_DIR_TYPE_FILE,
|
||||
GEN_DIR_TYPE_FOLDER,
|
||||
GEN_DIR_TYPE_UNKNOWN,
|
||||
};
|
||||
typedef enum DirType_Def DirType;
|
||||
|
||||
struct DirInfo_Def;
|
||||
typedef struct DirInfo_Def DirInfo;
|
||||
struct DirInfo;
|
||||
|
||||
struct DirEntry_Def
|
||||
struct DirEntry
|
||||
{
|
||||
char const* filename;
|
||||
DirInfo* dir_info;
|
||||
u8 type;
|
||||
};
|
||||
typedef struct DirEntry_Def DirEntry;
|
||||
|
||||
struct DirInfo_Def
|
||||
struct DirInfo
|
||||
{
|
||||
char const* fullpath;
|
||||
DirEntry* entries; // zpl_array
|
||||
@ -106,7 +97,7 @@ struct DirInfo_Def
|
||||
String buf;
|
||||
};
|
||||
|
||||
struct FileInfo_Def
|
||||
struct FileInfo
|
||||
{
|
||||
FileOperations ops;
|
||||
FileDescriptor fd;
|
||||
@ -116,9 +107,9 @@ struct FileInfo_Def
|
||||
FileTime last_write_time;
|
||||
DirEntry* dir;
|
||||
};
|
||||
typedef struct FileInfo_Def FileInfo;
|
||||
typedef struct FileInfo FileInfo;
|
||||
|
||||
enum FileStandardType_Def
|
||||
enum FileStandardType
|
||||
{
|
||||
EFileStandard_INPUT,
|
||||
EFileStandard_OUTPUT,
|
||||
@ -126,7 +117,7 @@ enum FileStandardType_Def
|
||||
|
||||
EFileStandard_COUNT,
|
||||
};
|
||||
typedef enum FileStandardType_Def FileStandardType;
|
||||
typedef enum FileStandardType FileStandardType;
|
||||
|
||||
/**
|
||||
* Get standard file I/O.
|
||||
@ -269,7 +260,7 @@ b32 file_write_at( FileInfo* file, void const* buffer, ssize size, s64 offset );
|
||||
*/
|
||||
b32 file_write_at_check( FileInfo* file, void const* buffer, ssize size, s64 offset, ssize* bytes_written );
|
||||
|
||||
enum FileStreamFlags_Def enum_underlying(u32)
|
||||
enum FileStreamFlags : u32
|
||||
{
|
||||
/* Allows us to write to the buffer directly. Beware: you can not append a new data! */
|
||||
EFileStream_WRITABLE = bit( 0 ),
|
||||
@ -280,7 +271,6 @@ enum FileStreamFlags_Def enum_underlying(u32)
|
||||
|
||||
EFileStream_UNDERLYING = GEN_U32_MAX,
|
||||
};
|
||||
typedef enum FileStreamFlags_Def FileStreamFlags;
|
||||
|
||||
/**
|
||||
* Opens a new memory stream
|
||||
@ -396,5 +386,4 @@ b32 file_write_at_check( FileInfo* f, void const* buffer, ssize size, s64 offset
|
||||
return f->ops.write_at( f->fd, buffer, size, offset, bytes_written );
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion File Handling
|
||||
|
@ -4,7 +4,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region Hashing
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
global u32 const _crc32_table[ 256 ] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd,
|
||||
@ -88,5 +87,4 @@ u64 crc64( void const* data, ssize len )
|
||||
return result;
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion Hashing
|
||||
|
@ -4,10 +4,8 @@
|
||||
#endif
|
||||
|
||||
#pragma region Hashing
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
u32 crc32( void const* data, ssize len );
|
||||
u64 crc64( void const* data, ssize len );
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion Hashing
|
||||
|
@ -19,10 +19,22 @@
|
||||
#define bitfield_is_equal( Type, Field, Mask ) ( (Type(Mask) & Type(Field)) == Type(Mask) )
|
||||
#endif
|
||||
|
||||
// Mainly intended for forcing the base library to utilize only C-valid constructs or type coercion
|
||||
#ifndef GEN_C_LIKE_CPP
|
||||
#define GEN_C_LIKE_CPP 0
|
||||
#endif
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
# ifndef cast
|
||||
# define cast( type, value ) (tmpl_cast<type>( value ))
|
||||
# endif
|
||||
#else
|
||||
# ifndef cast
|
||||
# define cast( type, value ) ( (type)(value) )
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
# ifndef ccast
|
||||
# define ccast( type, value ) ( const_cast< type >( (value) ) )
|
||||
# endif
|
||||
@ -36,9 +48,6 @@
|
||||
# define scast( type, value ) static_cast< type >( value )
|
||||
# endif
|
||||
#else
|
||||
# ifndef cast
|
||||
# define cast( type, value ) ( (type)(value) )
|
||||
# endif
|
||||
# ifndef ccast
|
||||
# define ccast( type, value ) ( (type)(value) )
|
||||
# endif
|
||||
@ -210,22 +219,6 @@
|
||||
# error "No thread local support"
|
||||
#endif
|
||||
|
||||
#if !defined(GEN_SUPPORT_CPP_REFERENCES)
|
||||
# define GEN_SUPPORT_CPP_REFERENCES 1
|
||||
#endif
|
||||
#if GEN_COMPILER_C && defined(GEN_SUPPORT_CPP_REFERENCES)
|
||||
# undef GEN_SUPPORT_CPP_REFERENCES
|
||||
# define GEN_SUPPORT_CPP_REFERENCES 0
|
||||
#endif
|
||||
|
||||
#if !defined(GEN_SUPPORT_CPP_MEMBER_FEATURES)
|
||||
# define GEN_SUPPORT_CPP_MEMBER_FEATURES 1
|
||||
#endif
|
||||
#if GEN_COMPILER_C && defined(GEN_SUPPORT_CPP_MEMBER_FEATURES)
|
||||
# undef GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
# define GEN_SUPPORT_CPP_MEMBER_FEATURES 0
|
||||
#endif
|
||||
|
||||
#if ! defined(typeof) && (!GEN_COMPILER_C || __STDC_VERSION__ < 202311L)
|
||||
# if ! GEN_COMPILER_C
|
||||
# define typeof decltype
|
||||
@ -239,7 +232,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef GEN_API_C_BEGIN
|
||||
# if GEN_COMPILER_C || (GEN_COMPILER_CPP && GEN_SUPPORT_CPP_REFERENCES)
|
||||
# if GEN_COMPILER_C
|
||||
# define GEN_API_C_BEGIN
|
||||
# define GEN_API_C_END
|
||||
# else
|
||||
@ -280,6 +273,16 @@
|
||||
#define struct_init(type, value) {value}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifndef GEN_OPTIMIZE_MAPPINGS_BEGIN
|
||||
# define GEN_OPTIMIZE_MAPPINGS_BEGIN _pragma(optimize("gt", on))
|
||||
# define GEN_OPITMIZE_MAPPINGS_END _pragma(optimize("", on))
|
||||
#endif
|
||||
#else
|
||||
# define GEN_OPTIMIZE_MAPPINGS_BEGIN
|
||||
# define GEN_OPITMIZE_MAPPINGS_END
|
||||
#endif
|
||||
|
||||
#if GEN_COMPILER_C
|
||||
// ------------------------ _Generic function overloading -----------------------------------------
|
||||
// This implemnents macros for utilizing "The Naive Extendible _Generic Macro" explained in:
|
||||
@ -295,12 +298,7 @@
|
||||
// Helper macros for argument selection
|
||||
#define GEN_SELECT_ARG_1( _1, ... ) _1 // <-- Of all th args passed pick _1.
|
||||
#define GEN_SELECT_ARG_2( _1, _2, ... ) _2 // <-- Of all the args passed pick _2.
|
||||
#define GEN_SELECT_ARG_3( _1, _2, _3, ... ) _3 // etc.. (by induction until _8, which we don't support any more beyond)
|
||||
// #define GEN_SELECT_ARG_4( _1, _2, _3, _4, ... ) _4
|
||||
// #define GEN_SELECT_ARG_5( _1, _2, _3, _4, _5, ... ) _5
|
||||
// #define GEN_SELECT_ARG_6( _1, _2, _3, _4, _5, _6, ... ) _6
|
||||
// #define GEN_SELECT_ARG_7( _1, _2, _3, _4, _5, _6, _7, ... ) _7
|
||||
// #define GEN_SELECT_ARG_8( _1, _2, _3, _4, _5, _6, _7, _8, ... ) _8
|
||||
#define GEN_SELECT_ARG_3( _1, _2, _3, ... ) _3 // etc..
|
||||
|
||||
#define GEN_GENERIC_SEL_ENTRY_TYPE GEN_SELECT_ARG_1 // Use the arg expansion macro to select arg 1 which should have the type.
|
||||
#define GEN_GENERIC_SEL_ENTRY_FUNCTION GEN_SELECT_ARG_2 // Use the arg expansion macro to select arg 2 which should have the function.
|
||||
@ -392,6 +390,7 @@ size_t gen_example_hash__P_long_long( long long val ) { return val * 2654435761u
|
||||
|
||||
// typedef void* GEN_GenericExampleType;
|
||||
// GEN_FUNCTION_GENERIC_EXAMPLE_DIRECT_TYPE( GEN_GenericExampleType );
|
||||
|
||||
// END OF ------------------------ _Generic function overloading ----------------------------------------- END OF
|
||||
#endif
|
||||
|
||||
|
@ -4,13 +4,12 @@
|
||||
#endif
|
||||
|
||||
#pragma region Memory
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
void* mem_copy( void* dest, void const* source, ssize n )
|
||||
{
|
||||
if ( dest == NULL )
|
||||
if ( dest == nullptr )
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return memcpy( dest, source, n );
|
||||
@ -518,5 +517,4 @@ void pool_clear(Pool* pool)
|
||||
pool->FreeList = pool->PhysicalStart;
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion Memory
|
||||
|
@ -22,8 +22,6 @@ void swap( Type& a, Type& b )
|
||||
b = tmp;
|
||||
}
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
//! Checks if value is power of 2.
|
||||
b32 is_power_of_two( ssize x );
|
||||
|
||||
@ -64,23 +62,21 @@ void zero_size( void* ptr, ssize size );
|
||||
//! Clears up an array.
|
||||
#define zero_array( a, count ) zero_size( ( a ), size_of( *( a ) ) * count )
|
||||
|
||||
enum AllocType_Def //enum_underlying(u8)
|
||||
enum AllocType : u8
|
||||
{
|
||||
EAllocation_ALLOC,
|
||||
EAllocation_FREE,
|
||||
EAllocation_FREE_ALL,
|
||||
EAllocation_RESIZE,
|
||||
};
|
||||
typedef enum AllocType_Def AllocType;
|
||||
|
||||
typedef void*(AllocatorProc)( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
|
||||
|
||||
struct AllocatorInfo_Def
|
||||
struct AllocatorInfo
|
||||
{
|
||||
AllocatorProc* Proc;
|
||||
void* Data;
|
||||
};
|
||||
typedef struct AllocatorInfo_Def AllocatorInfo;
|
||||
|
||||
enum AllocFlag
|
||||
{
|
||||
@ -144,12 +140,11 @@ constexpr AllocatorInfo heap( void ) { AllocatorInfo allocator = { heap_allocato
|
||||
//! Helper to free memory allocated by heap allocator.
|
||||
#define mfree( ptr ) free( heap(), ptr )
|
||||
|
||||
struct VirtualMemory_Def
|
||||
struct VirtualMemory
|
||||
{
|
||||
void* data;
|
||||
ssize size;
|
||||
};
|
||||
typedef struct VirtualMemory_Def VirtualMemory;
|
||||
|
||||
//! Initialize virtual memory from existing data.
|
||||
VirtualMemory vm_from_memory( void* data, ssize size );
|
||||
@ -173,8 +168,7 @@ b32 vm_purge( VirtualMemory vm );
|
||||
ssize virtual_memory_page_size( ssize* alignment_out );
|
||||
|
||||
#pragma region Arena
|
||||
struct Arena_Def;
|
||||
typedef struct Arena_Def Arena;
|
||||
struct Arena;
|
||||
|
||||
AllocatorInfo arena_allocator_info( Arena* arena );
|
||||
|
||||
@ -191,7 +185,7 @@ void arena_check (Arena* arena);
|
||||
void arena_free (Arena* arena);
|
||||
ssize arena_size_remaining(Arena* arena, ssize alignment);
|
||||
|
||||
struct Arena_Def
|
||||
struct Arena
|
||||
{
|
||||
AllocatorInfo Backing;
|
||||
void* PhysicalStart;
|
||||
@ -199,7 +193,7 @@ struct Arena_Def
|
||||
ssize TotalUsed;
|
||||
ssize TempCount;
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if GEN_COMPILER_CPP
|
||||
#pragma region Member Mapping
|
||||
forceinline operator AllocatorInfo() { return GEN_NS arena_allocator_info(this); }
|
||||
|
||||
@ -221,8 +215,7 @@ struct Arena_Def
|
||||
#endif
|
||||
};
|
||||
|
||||
#if GEN_SUPPORT_CPP_REFERENCES
|
||||
GEN_API_C_END
|
||||
#if GEN_COMPILER_CPP
|
||||
forceinline AllocatorInfo allocator_info(Arena& arena ) { return arena_allocator_info(& arena); }
|
||||
forceinline Arena init_sub (Arena& parent, ssize size) { return arena_init_sub( & parent, size); }
|
||||
forceinline ssize alignment_of (Arena& arena, ssize alignment) { return arena_alignment_of( & arena, alignment); }
|
||||
@ -234,7 +227,6 @@ forceinline ssize size_remaining(Arena& arena, ssize alignment) { return
|
||||
#undef check
|
||||
forceinline void check(Arena& arena) { return arena_check(& arena); };
|
||||
#pragma pop_macro("check")
|
||||
GEN_API_C_BEGIN
|
||||
#endif
|
||||
|
||||
|
||||
@ -320,8 +312,6 @@ ssize arena_size_remaining(Arena* arena, ssize alignment)
|
||||
}
|
||||
#pragma endregion Arena
|
||||
|
||||
GEN_API_C_END
|
||||
|
||||
#pragma region FixedArena
|
||||
template<s32 Size>
|
||||
struct FixedArena;
|
||||
@ -330,7 +320,7 @@ template<s32 Size> FixedArena<Size> fixed_arena_init();
|
||||
template<s32 Size> AllocatorInfo fixed_arena_allocator_info(FixedArena<Size>* fixed_arena );
|
||||
template<s32 Size> ssize fixed_arena_size_remaining(FixedArena<Size>* fixed_arena, ssize alignment);
|
||||
|
||||
#if GEN_SUPPORT_CPP_REFERENCES
|
||||
#if 0
|
||||
template<s32 Size> AllocatorInfo allocator_info( FixedArena<Size>& fixed_arena ) { return allocator_info(& fixed_arena); }
|
||||
template<s32 Size> ssize size_remaining(FixedArena<Size>& fixed_arena, ssize alignment) { return size_remaining( & fixed_arena, alignment); }
|
||||
#endif
|
||||
@ -343,7 +333,7 @@ struct FixedArena
|
||||
char memory[Size];
|
||||
Arena arena;
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if 0
|
||||
#pragma region Member Mapping
|
||||
forceinline operator AllocatorInfo() { return GEN_NS allocator_info(this); }
|
||||
|
||||
@ -389,11 +379,8 @@ using Arena_2MB = FixedArena< megabytes( 2 ) >;
|
||||
using Arena_4MB = FixedArena< megabytes( 4 ) >;
|
||||
#pragma endregion FixedArena
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
#pragma region Pool
|
||||
struct Pool_Def;
|
||||
typedef struct Pool_Def Pool;
|
||||
struct Pool;
|
||||
|
||||
void* pool_allocator_proc(void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags);
|
||||
|
||||
@ -403,15 +390,13 @@ AllocatorInfo pool_allocator_info(Pool* pool);
|
||||
void pool_clear(Pool* pool);
|
||||
void pool_free(Pool* pool);
|
||||
|
||||
#if GEN_SUPPORT_CPP_REFERENCES
|
||||
GEN_API_C_END
|
||||
#if 0
|
||||
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); }
|
||||
GEN_API_C_BEGIN
|
||||
#endif
|
||||
|
||||
struct Pool_Def
|
||||
struct Pool
|
||||
{
|
||||
AllocatorInfo Backing;
|
||||
void* PhysicalStart;
|
||||
@ -421,7 +406,7 @@ struct Pool_Def
|
||||
ssize TotalSize;
|
||||
ssize NumBlocks;
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
#pragma region Member Mapping
|
||||
forceinline operator AllocatorInfo() { return GEN_NS pool_allocator_info(this); }
|
||||
|
||||
@ -684,6 +669,4 @@ void zero_size( void* ptr, ssize size ) {
|
||||
mem_set( ptr, 0, size );
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
|
||||
#pragma endregion Memory
|
||||
|
@ -4,7 +4,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region ADT
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
#define _adt_fprintf( s_, fmt_, ... ) \
|
||||
do \
|
||||
@ -1112,5 +1111,4 @@ String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimi
|
||||
return output;
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion CSV
|
||||
|
@ -3,7 +3,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region ADT
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
enum ADT_Type : u32
|
||||
{
|
||||
@ -430,5 +429,4 @@ String csv_write_string( AllocatorInfo a, CSV_Object* obj )
|
||||
return csv_write_string_delimiter( a, obj, ',' );
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion CSV
|
||||
|
@ -76,17 +76,20 @@
|
||||
/* Platform compiler */
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
# define GEN_COMPILER_CLANG 0
|
||||
# pragma message("Detected MSVC")
|
||||
// # define GEN_COMPILER_CLANG 0
|
||||
# define GEN_COMPILER_MSVC 1
|
||||
# define GEN_COMPILER_GCC 0
|
||||
// # define GEN_COMPILER_GCC 0
|
||||
#elif defined( __GNUC__ )
|
||||
# define GEN_COMPILER_CLANG 0
|
||||
# define GEN_COMPILER_MSVC 0
|
||||
# pragma message("Detected GCC")
|
||||
// # define GEN_COMPILER_CLANG 0
|
||||
// # define GEN_COMPILER_MSVC 0
|
||||
# define GEN_COMPILER_GCC 1
|
||||
#elif defined( __clang__ )
|
||||
# pragma message("Detected CLANG")
|
||||
# define GEN_COMPILER_CLANG 1
|
||||
# define GEN_COMPILER_MSVC 0
|
||||
# define GEN_COMPILER_GCC 1
|
||||
// # define GEN_COMPILER_MSVC 0
|
||||
// # define GEN_COMPILER_GCC 0
|
||||
#else
|
||||
# error Unknown compiler
|
||||
#endif
|
||||
|
@ -6,7 +6,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region Printing
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
enum
|
||||
{
|
||||
@ -598,5 +597,4 @@ ssize str_fmt_out_err( char const* fmt, ... )
|
||||
return res;
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion Printing
|
||||
|
@ -5,9 +5,7 @@
|
||||
|
||||
#pragma region Printing
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
typedef struct FileInfo_Def FileInfo;
|
||||
typedef struct FileInfo FileInfo;
|
||||
|
||||
#ifndef GEN_PRINTF_MAXLEN
|
||||
# define GEN_PRINTF_MAXLEN kilobytes(128)
|
||||
@ -41,6 +39,4 @@ ssize log_fmt(char const* fmt, ...)
|
||||
return res;
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
|
||||
#pragma endregion Printing
|
||||
|
@ -5,7 +5,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region String Ops
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
internal
|
||||
ssize _scan_zpl_i64( const char* text, s32 base, s64* value )
|
||||
@ -213,5 +212,4 @@ f64 str_to_f64( const char* str, char** end_ptr )
|
||||
return result;
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion String Ops
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#pragma region String Ops
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
const char* char_first_occurence( const char* str, char c );
|
||||
|
||||
b32 char_is_alpha( char c );
|
||||
@ -286,6 +284,4 @@ void str_to_upper( char* str )
|
||||
}
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
|
||||
#pragma endregion String Ops
|
||||
|
@ -4,7 +4,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region String
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
String string_make_length( AllocatorInfo allocator, char const* str, ssize length )
|
||||
{
|
||||
@ -54,5 +53,4 @@ String string_make_reserve( AllocatorInfo allocator, ssize capacity )
|
||||
return result;
|
||||
}
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion String
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#pragma region Strings
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
struct StrC_Def;
|
||||
typedef struct StrC_Def StrC;
|
||||
|
||||
@ -18,8 +16,6 @@ b32 strc_starts_with (StrC str, StrC substring);
|
||||
StrC strc_to_str (char const* bad_string);
|
||||
StrC strc_visualize_whitespace(StrC str, AllocatorInfo allocator);
|
||||
|
||||
GEN_API_C_END
|
||||
|
||||
// Constant string with length.
|
||||
struct StrC_Def
|
||||
{
|
||||
@ -30,7 +26,7 @@ struct StrC_Def
|
||||
forceinline operator char const* () const { return Ptr; }
|
||||
forceinline char const& operator[]( ssize index ) const { return Ptr[index]; }
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
forceinline bool is_equal (StrC rhs) const { return GEN_NS strc_are_equal(* this, rhs); }
|
||||
forceinline char const* back () const { return GEN_NS strc_back(* this); }
|
||||
forceinline bool contains (StrC substring) const { return GEN_NS strc_contains(* this, substring); }
|
||||
@ -63,8 +59,6 @@ forceinline char const* end (StrC str) { return str.Ptr + str
|
||||
forceinline char const* next (StrC str, char const* iter) { return iter + 1; }
|
||||
#endif
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
inline
|
||||
bool strc_are_equal(StrC lhs, StrC rhs)
|
||||
{
|
||||
@ -113,24 +107,21 @@ StrC to_strc_from_c_str( char const* bad_str ) {
|
||||
StrC result = { str_len( bad_str ), bad_str };
|
||||
return result;
|
||||
}
|
||||
GEN_API_C_END
|
||||
|
||||
// Dynamic String
|
||||
// This is directly based off the ZPL string api.
|
||||
// They used a header pattern
|
||||
// I kept it for simplicty of porting but its not necessary to keep it that way.
|
||||
#pragma region String
|
||||
struct StringHeader_Def;
|
||||
typedef struct StringHeader_Def StringHeader;
|
||||
struct StringHeader;
|
||||
typedef struct StringHeader StringHeader;
|
||||
|
||||
#if GEN_COMPILER_C || ! GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if GEN_COMPILER_C
|
||||
typedef char* String;
|
||||
#else
|
||||
struct String;
|
||||
#endif
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
forceinline usize string_grow_formula(usize value);
|
||||
|
||||
String string_make_c_str (AllocatorInfo allocator, char const* str);
|
||||
@ -168,15 +159,13 @@ void string_trim (String str, char const* cut_set)
|
||||
void string_trim_space (String str);
|
||||
String string_visualize_whitespace(String const str);
|
||||
|
||||
GEN_API_C_END
|
||||
|
||||
struct StringHeader_Def {
|
||||
struct StringHeader {
|
||||
AllocatorInfo Allocator;
|
||||
ssize Capacity;
|
||||
ssize Length;
|
||||
};
|
||||
|
||||
#if GEN_COMPILER_CPP && GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if GEN_COMPILER_CPP
|
||||
struct String
|
||||
{
|
||||
char* Data;
|
||||
@ -203,6 +192,7 @@ struct String
|
||||
friend forceinline bool operator==(std::nullptr_t, const String str) { return str.Data == nullptr; }
|
||||
friend forceinline bool operator!=(std::nullptr_t, const String str) { return str.Data != nullptr; }
|
||||
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
forceinline char* begin() const { return Data; }
|
||||
forceinline char* end() const { return Data + string_length(* this); }
|
||||
|
||||
@ -273,6 +263,7 @@ struct String
|
||||
return string_append_c_str_len(this, buf, res);
|
||||
}
|
||||
#pragma endregion Member Mapping
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -282,13 +273,13 @@ forceinline char* string_end (String str) { return ((char*) s
|
||||
forceinline char* string_next (String str, char const* iter) { return ((char*) iter + 1); }
|
||||
GEN_API_C_END
|
||||
|
||||
#if GEN_COMPILER_CPP && 0
|
||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||
forceinline char* begin(String str) { return ((char*) str); }
|
||||
forceinline char* end (String str) { return ((char*) str + string_length(str)); }
|
||||
forceinline char* next (String str, char* iter) { return ((char*) iter + 1); }
|
||||
#endif
|
||||
|
||||
#if GEN_SUPPORT_CPP_REFERENCES
|
||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||
forceinline bool make_space_for(String& str, char const* to_append, ssize add_len);
|
||||
forceinline bool append(String& str, char c);
|
||||
forceinline bool append(String& str, char const* str_to_append);
|
||||
@ -301,8 +292,6 @@ forceinline void clear(String& str);
|
||||
forceinline void free(String& str);
|
||||
#endif
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
forceinline
|
||||
usize string_grow_formula(usize value) {
|
||||
// Using a very aggressive growth formula to reduce time mem_copying with recursive calls to append in this library.
|
||||
@ -755,8 +744,6 @@ StrC strc_visualize_whitespace(StrC str, AllocatorInfo allocator)
|
||||
// Should never be modified, if changed string is desired, cache_string( str ) another.
|
||||
typedef StrC StringCached;
|
||||
|
||||
GEN_API_C_END
|
||||
|
||||
// Implements basic string interning. Data structure is based off the ZPL Hashtable.
|
||||
typedef HashTable(StringCached) StringTable;
|
||||
#pragma endregion Strings
|
||||
|
@ -4,7 +4,6 @@
|
||||
#endif
|
||||
|
||||
#pragma region Timing
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
#ifdef GEN_BENCHMARK
|
||||
#if defined( GEN_COMPILER_MSVC ) && ! defined( __clang__ )
|
||||
@ -165,5 +164,4 @@ GEN_API_C_BEGIN
|
||||
}
|
||||
#endif
|
||||
|
||||
GEN_API_C_END
|
||||
#pragma endregion Timing
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#pragma region Timing
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
#ifdef GEN_BENCHMARK
|
||||
//! Return CPU timestamp.
|
||||
u64 read_cpu_time_stamp_counter( void );
|
||||
@ -18,6 +16,4 @@ f64 time_rel( void );
|
||||
u64 time_rel_ms( void );
|
||||
#endif
|
||||
|
||||
GEN_API_C_END
|
||||
|
||||
#pragma endregion Timing
|
||||
|
@ -8,7 +8,7 @@ GEN_NS_END
|
||||
|
||||
using namespace gen;
|
||||
|
||||
CodeBody gen_ecode( char const* path )
|
||||
CodeBody gen_ecode( char const* path, bool use_c_definition = false )
|
||||
{
|
||||
char scratch_mem[kilobytes(1)];
|
||||
Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) );
|
||||
@ -31,9 +31,19 @@ CodeBody gen_ecode( char const* path )
|
||||
string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code );
|
||||
}
|
||||
|
||||
CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", string_to_strc(enum_entries),
|
||||
"enum CodeType_Def enum_underlying(u32) { <entries> CT_NumTypes };"
|
||||
CodeEnum enum_code;
|
||||
if (use_c_definition)
|
||||
{
|
||||
enum_code = parse_enum(token_fmt_impl((3 + 1) / 2, "entries", string_to_strc(enum_entries),
|
||||
"enum CodeType enum_underlying(u32) { <entries> CT_NumTypes };"
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
enum_code = parse_enum(token_fmt_impl((3 + 1) / 2, "entries", string_to_strc(enum_entries),
|
||||
"enum CodeType : u32 { <entries> CT_NumTypes };"
|
||||
));
|
||||
}
|
||||
|
||||
#pragma push_macro("local_persist")
|
||||
#undef local_persist
|
||||
@ -57,12 +67,12 @@ CodeBody gen_ecode( char const* path )
|
||||
|
||||
//CodeNS nspace = def_namespace( name(ECode), def_namespace_body( args( enum_code, to_str ) ) );
|
||||
//CodeUsing code_t = def_using( name(CodeT), def_type( name(ECode::Type) ) );
|
||||
CodeTypedef code_t = parse_typedef(code(typedef enum CodeType_Def CodeType; ));
|
||||
CodeTypedef code_t = parse_typedef(code(typedef enum CodeType CodeType; ));
|
||||
|
||||
return def_global_body( args( enum_code, code_t, to_str, fmt_newline ) );
|
||||
}
|
||||
|
||||
CodeBody gen_eoperator( char const* path )
|
||||
CodeBody gen_eoperator( char const* path, bool use_c_definition = false )
|
||||
{
|
||||
char scratch_mem[kilobytes(4)];
|
||||
Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) );
|
||||
@ -87,16 +97,30 @@ CodeBody gen_eoperator( char const* path )
|
||||
string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||
}
|
||||
|
||||
#pragma push_macro("enum_underlying")
|
||||
#undef enum_underlying
|
||||
CodeEnum enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
||||
enum Operator_Def enum_underlying(u32)
|
||||
CodeEnum enum_code;
|
||||
if (use_c_definition)
|
||||
{
|
||||
#pragma push_macro("enum_underlying")
|
||||
#undef enum_underlying
|
||||
enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
||||
enum Operator enum_underlying(u32)
|
||||
{
|
||||
<entries>
|
||||
NumOps
|
||||
};
|
||||
)));
|
||||
#pragma pop_macro("enum_underlying")
|
||||
#pragma pop_macro("enum_underlying")
|
||||
}
|
||||
else
|
||||
{
|
||||
enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
||||
enum Operator : u32
|
||||
{
|
||||
<entries>
|
||||
NumOps
|
||||
};
|
||||
)));
|
||||
}
|
||||
|
||||
#pragma push_macro("local_persist")
|
||||
#undef local_persist
|
||||
@ -120,12 +144,12 @@ CodeBody gen_eoperator( char const* path )
|
||||
|
||||
//CodeNS nspace = def_namespace( name(EOperator), def_namespace_body( args( enum_code, to_str ) ) );
|
||||
//CodeUsing operator_t = def_using( name(OperatorT), def_type( name(EOperator::Type) ) );
|
||||
CodeTypedef operator_t = parse_typedef(code( typedef enum Operator_Def Operator; ));
|
||||
CodeTypedef operator_t = parse_typedef(code( typedef enum Operator Operator; ));
|
||||
|
||||
return def_global_body( args( enum_code, operator_t, to_str, fmt_newline ) );
|
||||
}
|
||||
|
||||
CodeBody gen_especifier( char const* path )
|
||||
CodeBody gen_especifier( char const* path, bool use_c_definition = false )
|
||||
{
|
||||
char scratch_mem[kilobytes(4)];
|
||||
Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) );
|
||||
@ -150,16 +174,30 @@ CodeBody gen_especifier( char const* path )
|
||||
string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
||||
}
|
||||
|
||||
#pragma push_macro("enum_underlying")
|
||||
#undef enum_underlying
|
||||
CodeEnum enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
||||
enum Specifier_Def enum_underlying(u32)
|
||||
CodeEnum enum_code;
|
||||
if (use_c_definition)
|
||||
{
|
||||
#pragma push_macro("enum_underlying")
|
||||
#undef enum_underlying
|
||||
enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
||||
enum Specifier enum_underlying(u32)
|
||||
{
|
||||
<entries>
|
||||
Spec_NumSpecifiers
|
||||
};
|
||||
)));
|
||||
#pragma pop_macro("enum_underlying")
|
||||
#pragma pop_macro("enum_underlying")
|
||||
}
|
||||
else
|
||||
{
|
||||
enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize(
|
||||
enum Specifier : u32
|
||||
{
|
||||
<entries>
|
||||
Spec_NumSpecifiers
|
||||
};
|
||||
)));
|
||||
}
|
||||
|
||||
CodeFn is_trailing = parse_function(token_fmt("specifier", string_to_strc(to_str_entries), stringize(
|
||||
inline
|
||||
@ -233,7 +271,7 @@ CodeBody gen_especifier( char const* path )
|
||||
|
||||
//CodeNS nspace = def_namespace( name(ESpecifier), def_namespace_body( args( enum_code, is_trailing, to_str, to_type ) ) );
|
||||
//CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) );
|
||||
CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier_Def Specifier; ));
|
||||
CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier Specifier; ));
|
||||
|
||||
return def_global_body( args( enum_code, specifier_t, is_trailing, to_str, to_type, fmt_newline ) );
|
||||
}
|
||||
@ -384,7 +422,7 @@ CodeBody gen_ast_inlines()
|
||||
inline
|
||||
<typename>& <typename>::operator =( Code other )
|
||||
{
|
||||
if ( other.ast && other->Parent )
|
||||
if ( other.ast != nullptr && other->Parent != nullptr )
|
||||
{
|
||||
ast = rcast( decltype(ast), code_duplicate(other).ast);
|
||||
ast->Parent = { nullptr };
|
||||
@ -451,36 +489,39 @@ CodeBody gen_ast_inlines()
|
||||
CodeBody impl_code_using = parse_global_body( token_fmt( "typename", StrC name(CodeUsing), code_impl_tmpl ));
|
||||
CodeBody impl_code_var = parse_global_body( token_fmt( "typename", StrC name(CodeVar), code_impl_tmpl ));
|
||||
|
||||
append(impl_code_attr, parse_global_body( token_fmt( "typename", StrC name(Attributes), codetype_impl_tmpl )));
|
||||
append(impl_code_cmt, parse_global_body( token_fmt( "typename", StrC name(Comment), codetype_impl_tmpl )));
|
||||
append(impl_code_constr, parse_global_body( token_fmt( "typename", StrC name(Constructor), codetype_impl_tmpl )));
|
||||
append(impl_code_define, parse_global_body( token_fmt( "typename", StrC name(Define), codetype_impl_tmpl )));
|
||||
append(impl_code_destruct, parse_global_body( token_fmt( "typename", StrC name(Destructor), codetype_impl_tmpl )));
|
||||
append(impl_code_enum, parse_global_body( token_fmt( "typename", StrC name(Enum), codetype_impl_tmpl )));
|
||||
append(impl_code_exec, parse_global_body( token_fmt( "typename", StrC name(Exec), codetype_impl_tmpl )));
|
||||
append(impl_code_extern, parse_global_body( token_fmt( "typename", StrC name(Extern), codetype_impl_tmpl )));
|
||||
append(impl_code_include, parse_global_body( token_fmt( "typename", StrC name(Include), codetype_impl_tmpl )));
|
||||
append(impl_code_friend, parse_global_body( token_fmt( "typename", StrC name(Friend), codetype_impl_tmpl )));
|
||||
append(impl_code_fn, parse_global_body( token_fmt( "typename", StrC name(Fn), codetype_impl_tmpl )));
|
||||
append(impl_code_module, parse_global_body( token_fmt( "typename", StrC name(Module), codetype_impl_tmpl )));
|
||||
append(impl_code_ns, parse_global_body( token_fmt( "typename", StrC name(NS), codetype_impl_tmpl )));
|
||||
append(impl_code_op, parse_global_body( token_fmt( "typename", StrC name(Operator), codetype_impl_tmpl )));
|
||||
append(impl_code_opcast, parse_global_body( token_fmt( "typename", StrC name(OpCast), codetype_impl_tmpl )));
|
||||
append(impl_code_pragma, parse_global_body( token_fmt( "typename", StrC name(Pragma), codetype_impl_tmpl )));
|
||||
append(impl_code_precond, parse_global_body( token_fmt( "typename", StrC name(PreprocessCond), codetype_impl_tmpl )));
|
||||
append(impl_code_tmpl, parse_global_body( token_fmt( "typename", StrC name(Template), codetype_impl_tmpl )));
|
||||
append(impl_code_type, parse_global_body( token_fmt( "typename", StrC name(Typename), codetype_impl_tmpl )));
|
||||
append(impl_code_typedef, parse_global_body( token_fmt( "typename", StrC name(Typedef), codetype_impl_tmpl )));
|
||||
append(impl_code_union, parse_global_body( token_fmt( "typename", StrC name(Union), codetype_impl_tmpl )));
|
||||
append(impl_code_using, parse_global_body( token_fmt( "typename", StrC name(Using), codetype_impl_tmpl )));
|
||||
append(impl_code_var, parse_global_body( token_fmt( "typename", StrC name(Var), codetype_impl_tmpl )));
|
||||
body_append(impl_code_attr, parse_global_body( token_fmt( "typename", StrC name(Attributes), codetype_impl_tmpl )));
|
||||
body_append(impl_code_cmt, parse_global_body( token_fmt( "typename", StrC name(Comment), codetype_impl_tmpl )));
|
||||
body_append(impl_code_constr, parse_global_body( token_fmt( "typename", StrC name(Constructor), codetype_impl_tmpl )));
|
||||
body_append(impl_code_define, parse_global_body( token_fmt( "typename", StrC name(Define), codetype_impl_tmpl )));
|
||||
body_append(impl_code_destruct, parse_global_body( token_fmt( "typename", StrC name(Destructor), codetype_impl_tmpl )));
|
||||
body_append(impl_code_enum, parse_global_body( token_fmt( "typename", StrC name(Enum), codetype_impl_tmpl )));
|
||||
body_append(impl_code_exec, parse_global_body( token_fmt( "typename", StrC name(Exec), codetype_impl_tmpl )));
|
||||
body_append(impl_code_extern, parse_global_body( token_fmt( "typename", StrC name(Extern), codetype_impl_tmpl )));
|
||||
body_append(impl_code_include, parse_global_body( token_fmt( "typename", StrC name(Include), codetype_impl_tmpl )));
|
||||
body_append(impl_code_friend, parse_global_body( token_fmt( "typename", StrC name(Friend), codetype_impl_tmpl )));
|
||||
body_append(impl_code_fn, parse_global_body( token_fmt( "typename", StrC name(Fn), codetype_impl_tmpl )));
|
||||
body_append(impl_code_module, parse_global_body( token_fmt( "typename", StrC name(Module), codetype_impl_tmpl )));
|
||||
body_append(impl_code_ns, parse_global_body( token_fmt( "typename", StrC name(NS), codetype_impl_tmpl )));
|
||||
body_append(impl_code_op, parse_global_body( token_fmt( "typename", StrC name(Operator), codetype_impl_tmpl )));
|
||||
body_append(impl_code_opcast, parse_global_body( token_fmt( "typename", StrC name(OpCast), codetype_impl_tmpl )));
|
||||
body_append(impl_code_pragma, parse_global_body( token_fmt( "typename", StrC name(Pragma), codetype_impl_tmpl )));
|
||||
body_append(impl_code_precond, parse_global_body( token_fmt( "typename", StrC name(PreprocessCond), codetype_impl_tmpl )));
|
||||
body_append(impl_code_tmpl, parse_global_body( token_fmt( "typename", StrC name(Template), codetype_impl_tmpl )));
|
||||
body_append(impl_code_type, parse_global_body( token_fmt( "typename", StrC name(Typename), codetype_impl_tmpl )));
|
||||
body_append(impl_code_typedef, parse_global_body( token_fmt( "typename", StrC name(Typedef), codetype_impl_tmpl )));
|
||||
body_append(impl_code_union, parse_global_body( token_fmt( "typename", StrC name(Union), codetype_impl_tmpl )));
|
||||
body_append(impl_code_using, parse_global_body( token_fmt( "typename", StrC name(Using), codetype_impl_tmpl )));
|
||||
body_append(impl_code_var, parse_global_body( token_fmt( "typename", StrC name(Var), codetype_impl_tmpl )));
|
||||
|
||||
#pragma push_macro("forceinline")
|
||||
#undef forceinline
|
||||
char const* cast_tmpl = stringize(
|
||||
inline Code::operator Code<typename>() const
|
||||
forceinline Code::operator Code<typename>() const
|
||||
{
|
||||
return { (AST_<typename>*) ast };
|
||||
}
|
||||
);
|
||||
#pragma pop_macro("forceinline")
|
||||
|
||||
CodeBody impl_cast_body = parse_global_body( token_fmt( "typename", StrC name(Body), cast_tmpl ));
|
||||
CodeBody impl_cast_attribute = parse_global_body( token_fmt( "typename", StrC name(Attributes), cast_tmpl ));
|
||||
@ -547,6 +588,7 @@ CodeBody gen_ast_inlines()
|
||||
def_pragma( txt("endregion generated code inline implementation")),
|
||||
fmt_newline,
|
||||
def_pragma( txt("region generated AST/Code cast implementation")),
|
||||
untyped_str(txt("GEN_OPTIMIZE_MAPPINGS_BEGIN\n")),
|
||||
fmt_newline,
|
||||
impl_cast_body,
|
||||
impl_cast_attribute,
|
||||
@ -577,6 +619,7 @@ CodeBody gen_ast_inlines()
|
||||
impl_cast_using,
|
||||
impl_cast_var,
|
||||
fmt_newline,
|
||||
untyped_str(txt("GEN_OPITMIZE_MAPPINGS_END\n")),
|
||||
def_pragma( txt("endregion generated AST/Code cast implementation")),
|
||||
fmt_newline
|
||||
));
|
||||
|
@ -9,8 +9,6 @@ $refactor_unreal = Join-Path $PSScriptRoot 'refactor_unreal.ps1'
|
||||
$incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1'
|
||||
$vendor_toolchain = Join-Path $PSScriptRoot 'helpers/vendor_toolchain.ps1'
|
||||
|
||||
Import-Module $target_arch
|
||||
|
||||
function Get-ScriptRepoRoot {
|
||||
$currentPath = $PSScriptRoot
|
||||
while ($currentPath -ne $null -and $currentPath -ne "")
|
||||
@ -33,7 +31,7 @@ function Get-ScriptRepoRoot {
|
||||
}
|
||||
$path_root = Get-ScriptRepoRoot
|
||||
|
||||
Import-Module $target_arch
|
||||
# Import-Module $target_arch
|
||||
Import-Module $format_cpp
|
||||
|
||||
Push-Location $path_root
|
||||
|
@ -188,7 +188,7 @@ if ( $vendor -match "clang" )
|
||||
# $compiler_args += $flag_time_trace
|
||||
}
|
||||
if ( $optimize ) {
|
||||
$compiler_args += $flag_optimize_fast
|
||||
$compiler_args += $flag_optimize_size
|
||||
}
|
||||
else {
|
||||
$compiler_args += $flag_no_optimization
|
||||
@ -268,7 +268,7 @@ if ( $vendor -match "clang" )
|
||||
# $compiler_args += $flag_time_trace
|
||||
}
|
||||
if ( $optimize ) {
|
||||
$compiler_args += $flag_optimize_fast
|
||||
$compiler_args += $flag_optimize_size
|
||||
}
|
||||
else {
|
||||
$compiler_args += $flag_no_optimization
|
||||
@ -348,7 +348,9 @@ if ( $vendor -match "msvc" )
|
||||
$flag_optimize_fast = '/O2'
|
||||
$flag_optimize_size = '/O1'
|
||||
$flag_optimize_intrinsics = '/Oi'
|
||||
$flag_optimized_debug_forceinline = '/d2Obforceinline'
|
||||
$flag_optimized_debug = '/Zo'
|
||||
$flag_
|
||||
$flag_out_name = '/OUT:'
|
||||
$flag_path_interm = '/Fo'
|
||||
$flag_path_debug = '/Fd'
|
||||
@ -388,7 +390,7 @@ if ( $vendor -match "msvc" )
|
||||
}
|
||||
|
||||
if ( $optimize ) {
|
||||
$compiler_args += $flag_optimize_fast
|
||||
$compiler_args += $flag_optimize_size
|
||||
}
|
||||
else {
|
||||
$compiler_args += $flag_no_optimization
|
||||
@ -403,6 +405,7 @@ if ( $vendor -match "msvc" )
|
||||
|
||||
if ( $optimize ) {
|
||||
$compiler_args += $flag_optimized_debug
|
||||
$compiler_args += $flag_optimized_debug_forceinline
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -474,7 +477,7 @@ if ( $vendor -match "msvc" )
|
||||
}
|
||||
|
||||
if ( $optimize ) {
|
||||
$compiler_args += $flag_optimize_fast
|
||||
$compiler_args += $flag_optimize_size
|
||||
}
|
||||
else {
|
||||
$compiler_args += $flag_no_optimization
|
||||
|
Loading…
Reference in New Issue
Block a user