2024-10-25 02:04:11 -07:00
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
2024-04-13 13:18:57 -07:00
# pragma once
2024-10-25 02:04:11 -07:00
# ifdef __clang__
2024-12-14 05:46:22 -08:00
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-const-variable"
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
# pragma clang diagnostic ignored "-Wswitch"
# pragma clang diagnostic ignored "-Wunused-variable"
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wvarargs"
# pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic ignored "-Wbraced-scalar-init"
# pragma clang diagnostic ignored "-W#pragma-messages"
# pragma clang diagnostic ignored "-Wstatic-in-inline"
2024-04-13 13:18:57 -07:00
# endif
2024-10-25 02:04:11 -07:00
# ifdef __GNUC__
2024-12-14 05:46:22 -08:00
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
# pragma GCC diagnostic ignored "-Wcomment"
# pragma GCC diagnostic ignored "-Wswitch"
# pragma GCC diagnostic ignored "-Wunused-variable"
2024-04-13 13:18:57 -07:00
# endif
/*
2024-12-14 05:46:22 -08:00
gencpp : An attempt at " simple " staged metaprogramming for c / c + + .
See Readme . md for more information from the project repository .
Public Address :
https : //github.com/Ed94/gencpp
This is a variant intended for use with Unreal Engine 5
https : //github.com/Ed94/gencpp --------------------------------------------------------------.
| _____ _____ _ _ |
| / ____ ) / ____ } | | | |
| | / ___ ___ _ __ ___ _ __ _ __ | { ___ | | __ _ _ , __ _ , ___ __ | | |
| | | { _ | / _ \ ' _ \ / __ } ' _ l | ' _ l ` \ ___ \ | __ / _ ` | / _ ` | / _ \ / _ ` | |
| | l__j | ___ / | | | { __ ; | + l } | + l | ____ ) | l | ( _ | | { _ | | ___ / ( _ | | |
| \ _____ | \ ___ } _l | _ | \ ___ } , __ / | , __ / ( _____ / \ __ \ __ / _ | \ __ , | \ ___ } \ __ , _l |
| Unreal Engine | | | | __ } | |
| l_l l_l { ___ / |
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VERSION : v0 .20 - Alpha |
! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = |
! WARNING : THIS IS AN ALPHA VERSION OF THE LIBRARY , USE AT YOUR OWN DISCRETION |
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |
! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = /
2024-04-13 13:18:57 -07:00
*/
2024-12-14 05:46:22 -08:00
# if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
# error Gen.hpp : GEN_TIME not defined
2024-04-13 13:18:57 -07:00
# endif
//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file.
// Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
# ifndef GEN_ROLL_OWN_DEPENDENCIES
2024-12-14 05:46:22 -08:00
# include "gen.dep.hpp"
2024-04-13 13:18:57 -07:00
# endif
# ifndef GEN_NS_BEGIN
2024-12-14 05:46:22 -08:00
# ifdef GEN_DONT_USE_NAMESPACE
# define GEN_NS
# define GEN_NS_BEGIN
# define GEN_NS_END
# else
# define GEN_NS gen::
# define GEN_NS_BEGIN namespace gen {
# define GEN_NS_END }
# endif
2024-04-13 13:18:57 -07:00
# endif
GEN_NS_BEGIN
# pragma region Types
2024-12-14 05:46:22 -08:00
/*
________ __ __ ________
| \ | \ | \ | \
| ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ _______ __ __ ______ ____ _______ | ▓ ▓ \ | ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ __ __ ______ ______ _______
| ▓ ▓ __ | \ | \ | \ \ \ / \ | ▓ ▓ ▓ \ | ▓ ▓ | ▓ ▓ | \ | \ / \ / \ / \
| ▓ ▓ \ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓ \ ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓
| ▓ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ \ ▓ ▓ \ | ▓ ▓ \ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \
| ▓ ▓ _____ | ▓ ▓ | ▓ ▓ ▓ ▓ __ / ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ _ \ ▓ ▓ ▓ ▓ ▓ ▓ \ | ▓ ▓ \ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ __ / ▓ ▓ ▓ ▓ __ / ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ _ \ ▓ ▓ ▓ ▓ ▓ ▓ \
| ▓ ▓ \ ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓
\ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ _ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓
| \ __ | ▓ ▓ ▓ ▓
\ ▓ ▓ ▓ ▓ ▓ ▓
\ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓
*/
using LogFailType = ssize ( * ) ( char const * , . . . ) ;
2024-04-13 13:18:57 -07:00
// By default this library will either crash or exit if an error is detected while generating codes.
// Even if set to not use GEN_FATAL, GEN_FATAL will still be used for memory failures as the library is unusable when they occur.
# ifdef GEN_DONT_USE_FATAL
2024-12-14 05:46:22 -08:00
# define log_failure log_fmt
2024-04-13 13:18:57 -07:00
# else
2024-12-14 05:46:22 -08:00
# define log_failure GEN_FATAL
2024-04-13 13:18:57 -07:00
# endif
2024-12-14 05:46:22 -08:00
enum AccessSpec : u32
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
AccessSpec_Default ,
AccessSpec_Private ,
AccessSpec_Protected ,
AccessSpec_Public ,
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
AccessSpec_Num_AccessSpec ,
AccessSpec_Invalid ,
AccessSpec_SizeDef = GEN_U32_MAX ,
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( size_of ( AccessSpec ) = = size_of ( u32 ) , " AccessSpec not u32 size " ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
inline
Str access_spec_to_str ( AccessSpec type )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
local_persist
Str lookup [ ( u32 ) AccessSpec_Num_AccessSpec ] = {
{ " " , sizeof ( " " ) - 1 } ,
{ " private " , sizeof ( " prviate " ) - 1 } ,
{ " private " , sizeof ( " protected " ) - 1 } ,
{ " public " , sizeof ( " public " ) - 1 } ,
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
Str invalid = { " Invalid " , sizeof ( " Invalid " ) - 1 } ;
if ( type > AccessSpec_Public )
return invalid ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
return lookup [ ( u32 ) type ] ;
2024-04-13 13:18:57 -07:00
}
enum CodeFlag : u32
{
2024-12-14 05:46:22 -08:00
CodeFlag_None = 0 ,
CodeFlag_FunctionType = bit ( 0 ) ,
CodeFlag_ParamPack = bit ( 1 ) ,
CodeFlag_Module_Export = bit ( 2 ) ,
CodeFlag_Module_Import = bit ( 3 ) ,
CodeFlag_SizeDef = GEN_U32_MAX ,
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( size_of ( CodeFlag ) = = size_of ( u32 ) , " CodeFlag not u32 size " ) ;
2024-04-13 13:18:57 -07:00
// Used to indicate if enum definitoin is an enum class or regular enum.
2024-12-14 05:46:22 -08:00
enum EnumDecl : u8
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
EnumDecl_Regular ,
EnumDecl_Class ,
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
EnumT_SizeDef = GEN_U8_MAX ,
} ;
typedef u8 EnumT ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
enum ModuleFlag : u32
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ModuleFlag_None = 0 ,
ModuleFlag_Export = bit ( 0 ) ,
ModuleFlag_Import = bit ( 1 ) ,
2024-04-13 13:18:57 -07:00
Num_ModuleFlags ,
2024-12-14 05:46:22 -08:00
ModuleFlag_Invalid ,
ModuleFlag_SizeDef = GEN_U32_MAX ,
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( size_of ( ModuleFlag ) = = size_of ( u32 ) , " ModuleFlag not u32 size " ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
inline
Str module_flag_to_str ( ModuleFlag flag )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
local_persist
Str lookup [ ( u32 ) Num_ModuleFlags ] = {
{ " __none__ " , sizeof ( " __none__ " ) - 1 } ,
{ " export " , sizeof ( " export " ) - 1 } ,
{ " import " , sizeof ( " import " ) - 1 } ,
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
local_persist
Str invalid_flag = { " invalid " , sizeof ( " invalid " ) } ;
if ( flag > ModuleFlag_Import )
return invalid_flag ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
return lookup [ ( u32 ) flag ] ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
enum EPreprocessCond : u32
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
PreprocessCond_If ,
PreprocessCond_IfDef ,
PreprocessCond_IfNotDef ,
PreprocessCond_ElIf ,
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
EPreprocessCond_SizeDef = GEN_U32_MAX ,
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( size_of ( EPreprocessCond ) = = size_of ( u32 ) , " EPreprocessCond not u32 size " ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
enum ETypenameTag : u16
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
Tag_None ,
Tag_Class ,
Tag_Enum ,
Tag_Struct ,
Tag_Union ,
Tag_UnderlyingType = GEN_U16_MAX ,
} ;
static_assert ( size_of ( ETypenameTag ) = = size_of ( u16 ) , " ETypenameTag is not u16 size " ) ;
enum CodeType : 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 ,
2024-12-15 07:46:36 -08:00
CT_Parameters_Define ,
2024-12-14 05:46:22 -08:00
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 ,
CT_UnderlyingType = GEN_U32_MAX
} ;
inline Str codetype_to_str ( CodeType type )
{
2024-12-15 07:46:36 -08:00
local_persist Str lookup [ ] = {
2024-12-14 05:46:22 -08:00
{ " Invalid " , sizeof ( " Invalid " ) - 1 } ,
{ " Untyped " , sizeof ( " Untyped " ) - 1 } ,
{ " NewLine " , sizeof ( " NewLine " ) - 1 } ,
{ " Comment " , sizeof ( " Comment " ) - 1 } ,
{ " Access_Private " , sizeof ( " Access_Private " ) - 1 } ,
{ " Access_Protected " , sizeof ( " Access_Protected " ) - 1 } ,
{ " Access_Public " , sizeof ( " Access_Public " ) - 1 } ,
{ " PlatformAttributes " , sizeof ( " PlatformAttributes " ) - 1 } ,
{ " Class " , sizeof ( " Class " ) - 1 } ,
{ " Class_Fwd " , sizeof ( " Class_Fwd " ) - 1 } ,
{ " Class_Body " , sizeof ( " Class_Body " ) - 1 } ,
{ " Constructor " , sizeof ( " Constructor " ) - 1 } ,
{ " Constructor_Fwd " , sizeof ( " Constructor_Fwd " ) - 1 } ,
{ " Destructor " , sizeof ( " Destructor " ) - 1 } ,
{ " Destructor_Fwd " , sizeof ( " Destructor_Fwd " ) - 1 } ,
{ " Enum " , sizeof ( " Enum " ) - 1 } ,
{ " Enum_Fwd " , sizeof ( " Enum_Fwd " ) - 1 } ,
{ " Enum_Body " , sizeof ( " Enum_Body " ) - 1 } ,
{ " Enum_Class " , sizeof ( " Enum_Class " ) - 1 } ,
{ " Enum_Class_Fwd " , sizeof ( " Enum_Class_Fwd " ) - 1 } ,
{ " Execution " , sizeof ( " Execution " ) - 1 } ,
{ " Export_Body " , sizeof ( " Export_Body " ) - 1 } ,
{ " Extern_Linkage " , sizeof ( " Extern_Linkage " ) - 1 } ,
{ " Extern_Linkage_Body " , sizeof ( " Extern_Linkage_Body " ) - 1 } ,
{ " Friend " , sizeof ( " Friend " ) - 1 } ,
{ " Function " , sizeof ( " Function " ) - 1 } ,
{ " Function_Fwd " , sizeof ( " Function_Fwd " ) - 1 } ,
{ " Function_Body " , sizeof ( " Function_Body " ) - 1 } ,
{ " Global_Body " , sizeof ( " Global_Body " ) - 1 } ,
{ " Module " , sizeof ( " Module " ) - 1 } ,
{ " Namespace " , sizeof ( " Namespace " ) - 1 } ,
{ " Namespace_Body " , sizeof ( " Namespace_Body " ) - 1 } ,
{ " Operator " , sizeof ( " Operator " ) - 1 } ,
{ " Operator_Fwd " , sizeof ( " Operator_Fwd " ) - 1 } ,
{ " Operator_Member " , sizeof ( " Operator_Member " ) - 1 } ,
{ " Operator_Member_Fwd " , sizeof ( " Operator_Member_Fwd " ) - 1 } ,
{ " Operator_Cast " , sizeof ( " Operator_Cast " ) - 1 } ,
{ " Operator_Cast_Fwd " , sizeof ( " Operator_Cast_Fwd " ) - 1 } ,
{ " Parameters " , sizeof ( " Parameters " ) - 1 } ,
2024-12-15 07:46:36 -08:00
{ " Parameters_Define " , sizeof ( " Parameters_Define " ) - 1 } ,
2024-12-14 05:46:22 -08:00
{ " Preprocess_Define " , sizeof ( " Preprocess_Define " ) - 1 } ,
{ " Preprocess_Include " , sizeof ( " Preprocess_Include " ) - 1 } ,
{ " Preprocess_If " , sizeof ( " Preprocess_If " ) - 1 } ,
{ " Preprocess_IfDef " , sizeof ( " Preprocess_IfDef " ) - 1 } ,
{ " Preprocess_IfNotDef " , sizeof ( " Preprocess_IfNotDef " ) - 1 } ,
{ " Preprocess_ElIf " , sizeof ( " Preprocess_ElIf " ) - 1 } ,
{ " Preprocess_Else " , sizeof ( " Preprocess_Else " ) - 1 } ,
{ " Preprocess_EndIf " , sizeof ( " Preprocess_EndIf " ) - 1 } ,
{ " Preprocess_Pragma " , sizeof ( " Preprocess_Pragma " ) - 1 } ,
{ " Specifiers " , sizeof ( " Specifiers " ) - 1 } ,
{ " Struct " , sizeof ( " Struct " ) - 1 } ,
{ " Struct_Fwd " , sizeof ( " Struct_Fwd " ) - 1 } ,
{ " Struct_Body " , sizeof ( " Struct_Body " ) - 1 } ,
{ " Template " , sizeof ( " Template " ) - 1 } ,
{ " Typedef " , sizeof ( " Typedef " ) - 1 } ,
{ " Typename " , sizeof ( " Typename " ) - 1 } ,
{ " Union " , sizeof ( " Union " ) - 1 } ,
{ " Union_Fwd " , sizeof ( " Union_Fwd " ) - 1 } ,
{ " Union_Body " , sizeof ( " Union_Body " ) - 1 } ,
{ " Using " , sizeof ( " Using " ) - 1 } ,
{ " Using_Namespace " , sizeof ( " Using_Namespace " ) - 1 } ,
{ " Variable " , sizeof ( " Variable " ) - 1 } ,
} ;
return lookup [ type ] ;
}
inline Str codetype_to_keyword_str ( CodeType type )
{
2024-12-15 07:46:36 -08:00
local_persist Str lookup [ ] = {
2024-12-14 05:46:22 -08:00
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " // " , sizeof ( " // " ) - 1 } ,
{ " private " , sizeof ( " private " ) - 1 } ,
{ " protected " , sizeof ( " protected " ) - 1 } ,
{ " public " , sizeof ( " public " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " class " , sizeof ( " class " ) - 1 } ,
{ " clsss " , sizeof ( " clsss " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " enum " , sizeof ( " enum " ) - 1 } ,
{ " enum " , sizeof ( " enum " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " enum class " , sizeof ( " enum class " ) - 1 } ,
{ " enum class " , sizeof ( " enum class " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " extern " , sizeof ( " extern " ) - 1 } ,
{ " extern " , sizeof ( " extern " ) - 1 } ,
{ " friend " , sizeof ( " friend " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " module " , sizeof ( " module " ) - 1 } ,
{ " namespace " , sizeof ( " namespace " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " operator " , sizeof ( " operator " ) - 1 } ,
{ " operator " , sizeof ( " operator " ) - 1 } ,
{ " operator " , sizeof ( " operator " ) - 1 } ,
{ " operator " , sizeof ( " operator " ) - 1 } ,
{ " operator " , sizeof ( " operator " ) - 1 } ,
{ " operator " , sizeof ( " operator " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
2024-12-15 07:46:36 -08:00
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
2024-12-14 05:46:22 -08:00
{ " define " , sizeof ( " define " ) - 1 } ,
{ " include " , sizeof ( " include " ) - 1 } ,
{ " if " , sizeof ( " if " ) - 1 } ,
{ " ifdef " , sizeof ( " ifdef " ) - 1 } ,
{ " ifndef " , sizeof ( " ifndef " ) - 1 } ,
{ " elif " , sizeof ( " elif " ) - 1 } ,
{ " else " , sizeof ( " else " ) - 1 } ,
{ " endif " , sizeof ( " endif " ) - 1 } ,
{ " pragma " , sizeof ( " pragma " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " struct " , sizeof ( " struct " ) - 1 } ,
{ " struct " , sizeof ( " struct " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " template " , sizeof ( " template " ) - 1 } ,
{ " typedef " , sizeof ( " typedef " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " union " , sizeof ( " union " ) - 1 } ,
{ " union " , sizeof ( " union " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
{ " using " , sizeof ( " using " ) - 1 } ,
{ " using namespace " , sizeof ( " using namespace " ) - 1 } ,
{ " __NA__ " , sizeof ( " __NA__ " ) - 1 } ,
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
return lookup [ type ] ;
}
FORCEINLINE Str to_str ( CodeType type )
{
return codetype_to_str ( type ) ;
}
FORCEINLINE Str to_keyword_str ( CodeType type )
{
return codetype_to_keyword_str ( type ) ;
}
enum Operator : 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 ,
Op_NumOps ,
Op_UnderlyingType = 0xffffffffu
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
inline Str operator_to_str ( Operator op )
{
2024-12-15 07:46:36 -08:00
local_persist Str lookup [ ] = {
2024-12-14 05:46:22 -08:00
{ " INVALID " , sizeof ( " INVALID " ) - 1 } ,
{ " = " , sizeof ( " = " ) - 1 } ,
{ " += " , sizeof ( " += " ) - 1 } ,
{ " -= " , sizeof ( " -= " ) - 1 } ,
{ " *= " , sizeof ( " *= " ) - 1 } ,
{ " /= " , sizeof ( " /= " ) - 1 } ,
{ " %= " , sizeof ( " %= " ) - 1 } ,
{ " &= " , sizeof ( " &= " ) - 1 } ,
{ " |= " , sizeof ( " |= " ) - 1 } ,
{ " ^= " , sizeof ( " ^= " ) - 1 } ,
{ " <<= " , sizeof ( " <<= " ) - 1 } ,
{ " >>= " , sizeof ( " >>= " ) - 1 } ,
{ " ++ " , sizeof ( " ++ " ) - 1 } ,
{ " -- " , sizeof ( " -- " ) - 1 } ,
{ " + " , sizeof ( " + " ) - 1 } ,
{ " - " , sizeof ( " - " ) - 1 } ,
{ " ! " , sizeof ( " ! " ) - 1 } ,
{ " + " , sizeof ( " + " ) - 1 } ,
{ " - " , sizeof ( " - " ) - 1 } ,
{ " * " , sizeof ( " * " ) - 1 } ,
{ " / " , sizeof ( " / " ) - 1 } ,
{ " % " , sizeof ( " % " ) - 1 } ,
{ " ~ " , sizeof ( " ~ " ) - 1 } ,
{ " & " , sizeof ( " & " ) - 1 } ,
{ " | " , sizeof ( " | " ) - 1 } ,
{ " ^ " , sizeof ( " ^ " ) - 1 } ,
{ " << " , sizeof ( " << " ) - 1 } ,
{ " >> " , sizeof ( " >> " ) - 1 } ,
{ " && " , sizeof ( " && " ) - 1 } ,
{ " || " , sizeof ( " || " ) - 1 } ,
{ " == " , sizeof ( " == " ) - 1 } ,
{ " != " , sizeof ( " != " ) - 1 } ,
{ " < " , sizeof ( " < " ) - 1 } ,
{ " > " , sizeof ( " > " ) - 1 } ,
{ " <= " , sizeof ( " <= " ) - 1 } ,
{ " >= " , sizeof ( " >= " ) - 1 } ,
{ " [] " , sizeof ( " [] " ) - 1 } ,
{ " * " , sizeof ( " * " ) - 1 } ,
{ " & " , sizeof ( " & " ) - 1 } ,
{ " -> " , sizeof ( " -> " ) - 1 } ,
{ " ->* " , sizeof ( " ->* " ) - 1 } ,
{ " () " , sizeof ( " () " ) - 1 } ,
{ " , " , sizeof ( " , " ) - 1 } ,
{ " new " , sizeof ( " new " ) - 1 } ,
{ " new[] " , sizeof ( " new[] " ) - 1 } ,
{ " delete " , sizeof ( " delete " ) - 1 } ,
{ " delete[] " , sizeof ( " delete[] " ) - 1 } ,
} ;
return lookup [ op ] ;
}
FORCEINLINE Str to_str ( Operator op )
{
return operator_to_str ( op ) ;
}
enum Specifier : u32
{
Spec_Invalid ,
Spec_Consteval ,
Spec_Constexpr ,
Spec_Constinit ,
Spec_Explicit ,
Spec_External_Linkage ,
Spec_ForceInline ,
2024-12-15 07:46:36 -08:00
Spec_ForceInline_Debuggable ,
2024-12-14 05:46:22 -08:00
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 ,
Spec_UnderlyingType = 0xffffffffu
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
inline Str spec_to_str ( Specifier type )
{
2024-12-15 07:46:36 -08:00
local_persist Str lookup [ ] = {
{ " INVALID " , sizeof ( " INVALID " ) - 1 } ,
{ " consteval " , sizeof ( " consteval " ) - 1 } ,
{ " constexpr " , sizeof ( " constexpr " ) - 1 } ,
{ " constinit " , sizeof ( " constinit " ) - 1 } ,
{ " explicit " , sizeof ( " explicit " ) - 1 } ,
{ " extern " , sizeof ( " extern " ) - 1 } ,
{ " FORCEINLINE " , sizeof ( " FORCEINLINE " ) - 1 } ,
{ " FORCEINLINE_DEBUGGABLE " , sizeof ( " FORCEINLINE_DEBUGGABLE " ) - 1 } ,
{ " global " , sizeof ( " global " ) - 1 } ,
{ " inline " , sizeof ( " inline " ) - 1 } ,
{ " internal " , sizeof ( " internal " ) - 1 } ,
{ " local_persist " , sizeof ( " local_persist " ) - 1 } ,
{ " mutable " , sizeof ( " mutable " ) - 1 } ,
{ " neverinline " , sizeof ( " neverinline " ) - 1 } ,
{ " * " , sizeof ( " * " ) - 1 } ,
{ " & " , sizeof ( " & " ) - 1 } ,
{ " register " , sizeof ( " register " ) - 1 } ,
{ " && " , sizeof ( " && " ) - 1 } ,
{ " static " , sizeof ( " static " ) - 1 } ,
{ " thread_local " , sizeof ( " thread_local " ) - 1 } ,
{ " virtual " , sizeof ( " virtual " ) - 1 } ,
{ " const " , sizeof ( " const " ) - 1 } ,
{ " final " , sizeof ( " final " ) - 1 } ,
{ " noexcept " , sizeof ( " noexcept " ) - 1 } ,
{ " override " , sizeof ( " override " ) - 1 } ,
{ " = 0 " , sizeof ( " = 0 " ) - 1 } ,
{ " volatile " , sizeof ( " volatile " ) - 1 } ,
2024-12-14 05:46:22 -08:00
} ;
return lookup [ type ] ;
}
inline bool spec_is_trailing ( Specifier specifier )
{
return specifier > Spec_Virtual ;
}
inline Specifier str_to_specifier ( Str str )
{
local_persist u32 keymap [ Spec_NumSpecifiers ] ;
do_once_start for ( u32 index = 0 ; index < Spec_NumSpecifiers ; index + + )
{
Str enum_str = spec_to_str ( ( Specifier ) index ) ;
keymap [ index ] = crc32 ( enum_str . Ptr , enum_str . Len ) ;
}
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 ;
}
FORCEINLINE Str to_str ( Specifier spec )
{
return spec_to_str ( spec ) ;
}
FORCEINLINE Specifier to_type ( Str str )
{
return str_to_specifier ( str ) ;
}
FORCEINLINE bool is_trailing ( Specifier specifier )
{
return spec_is_trailing ( specifier ) ;
}
2024-12-15 11:13:44 -08:00
# define GEN_DEFINE_ATTRIBUTE_TOKENS \
Entry ( Tok_Attribute_API_Export , " GEN_API_Export_Code " ) Entry ( Tok_Attribute_API_Import , " GEN_API_Import_Code " ) \
Entry ( Tok_Attribute_COREUOBJECT_API , " COREUOBJECT_API " ) Entry ( Tok_Attribute_ENGINE_API , " ENGINE_API " ) \
Entry ( Tok_Attribute_GAMEPLAYABILITIES_API , " GAMEPLAYABILITIES_API " ) Entry ( Tok_Attribute_UMG_API , " UMG_API " )
2024-12-14 05:46:22 -08:00
enum TokType : 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 ,
2024-12-15 11:13:44 -08:00
Tok_Preprocess_Define_Param ,
2024-12-14 05:46:22 -08:00
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 ,
2024-12-15 07:46:36 -08:00
Tok_Preprocess_Macro_Expr ,
Tok_Preprocess_Macro_Stmt ,
Tok_Preprocess_Macro_Typename ,
2024-12-14 05:46:22 -08:00
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 ,
2024-12-15 07:46:36 -08:00
Tok_Spec_ForceInline_Debuggable ,
2024-12-14 05:46:22 -08:00
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_Attribute_COREUOBJECT_API ,
Tok_Attribute_ENGINE_API ,
Tok_Attribute_GAMEPLAYABILITIES_API ,
Tok_Attribute_UMG_API ,
Tok_NumTokens
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
inline Str toktype_to_str ( TokType type )
{
local_persist Str lookup [ ] = {
2024-12-15 07:46:36 -08:00
{ " __invalid__ " , sizeof ( " __invalid__ " ) - 1 } ,
{ " private " , sizeof ( " private " ) - 1 } ,
{ " protected " , sizeof ( " protected " ) - 1 } ,
{ " public " , sizeof ( " public " ) - 1 } ,
{ " . " , sizeof ( " . " ) - 1 } ,
{ " :: " , sizeof ( " :: " ) - 1 } ,
{ " & " , sizeof ( " & " ) - 1 } ,
{ " && " , sizeof ( " && " ) - 1 } ,
{ " : " , sizeof ( " : " ) - 1 } ,
{ " [[ " , sizeof ( " [[ " ) - 1 } ,
{ " ]] " , sizeof ( " ]] " ) - 1 } ,
{ " { " , sizeof ( " { " ) - 1 } ,
{ " } " , sizeof ( " } " ) - 1 } ,
{ " [ " , sizeof ( " [ " ) - 1 } ,
{ " ] " , sizeof ( " ] " ) - 1 } ,
{ " ( " , sizeof ( " ( " ) - 1 } ,
{ " ) " , sizeof ( " ) " ) - 1 } ,
{ " __comment__ " , sizeof ( " __comment__ " ) - 1 } ,
{ " __comment_end__ " , sizeof ( " __comment_end__ " ) - 1 } ,
{ " __comment_start__ " , sizeof ( " __comment_start__ " ) - 1 } ,
{ " __character__ " , sizeof ( " __character__ " ) - 1 } ,
{ " , " , sizeof ( " , " ) - 1 } ,
{ " class " , sizeof ( " class " ) - 1 } ,
{ " __attribute__ " , sizeof ( " __attribute__ " ) - 1 } ,
{ " __declspec " , sizeof ( " __declspec " ) - 1 } ,
{ " enum " , sizeof ( " enum " ) - 1 } ,
{ " extern " , sizeof ( " extern " ) - 1 } ,
{ " friend " , sizeof ( " friend " ) - 1 } ,
{ " module " , sizeof ( " module " ) - 1 } ,
{ " namespace " , sizeof ( " namespace " ) - 1 } ,
{ " operator " , sizeof ( " operator " ) - 1 } ,
{ " struct " , sizeof ( " struct " ) - 1 } ,
{ " template " , sizeof ( " template " ) - 1 } ,
{ " typedef " , sizeof ( " typedef " ) - 1 } ,
{ " using " , sizeof ( " using " ) - 1 } ,
{ " union " , sizeof ( " union " ) - 1 } ,
{ " __identifier__ " , sizeof ( " __identifier__ " ) - 1 } ,
{ " import " , sizeof ( " import " ) - 1 } ,
{ " export " , sizeof ( " export " ) - 1 } ,
{ " __new_line__ " , sizeof ( " __new_line__ " ) - 1 } ,
{ " __number__ " , sizeof ( " __number__ " ) - 1 } ,
{ " __operator__ " , sizeof ( " __operator__ " ) - 1 } ,
{ " # " , sizeof ( " # " ) - 1 } ,
{ " define " , sizeof ( " define " ) - 1 } ,
2024-12-15 11:13:44 -08:00
{ " __define_param__ " , sizeof ( " __define_param__ " ) - 1 } ,
2024-12-15 07:46:36 -08:00
{ " if " , sizeof ( " if " ) - 1 } ,
{ " ifdef " , sizeof ( " ifdef " ) - 1 } ,
{ " ifndef " , sizeof ( " ifndef " ) - 1 } ,
{ " elif " , sizeof ( " elif " ) - 1 } ,
{ " else " , sizeof ( " else " ) - 1 } ,
{ " endif " , sizeof ( " endif " ) - 1 } ,
{ " include " , sizeof ( " include " ) - 1 } ,
{ " pragma " , sizeof ( " pragma " ) - 1 } ,
{ " __macro_content__ " , sizeof ( " __macro_content__ " ) - 1 } ,
{ " __macro_expression__ " , sizeof ( " __macro_expression__ " ) - 1 } ,
{ " __macro_statment__ " , sizeof ( " __macro_statment__ " ) - 1 } ,
{ " __macro_typename__ " , sizeof ( " __macro_typename__ " ) - 1 } ,
{ " __unsupported__ " , sizeof ( " __unsupported__ " ) - 1 } ,
{ " alignas " , sizeof ( " alignas " ) - 1 } ,
{ " const " , sizeof ( " const " ) - 1 } ,
{ " consteval " , sizeof ( " consteval " ) - 1 } ,
{ " constexpr " , sizeof ( " constexpr " ) - 1 } ,
{ " constinit " , sizeof ( " constinit " ) - 1 } ,
{ " explicit " , sizeof ( " explicit " ) - 1 } ,
{ " extern " , sizeof ( " extern " ) - 1 } ,
{ " final " , sizeof ( " final " ) - 1 } ,
{ " FORCEINLINE " , sizeof ( " FORCEINLINE " ) - 1 } ,
{ " FORCEINLINE_DEBUGGABLE " , sizeof ( " FORCEINLINE_DEBUGGABLE " ) - 1 } ,
{ " global " , sizeof ( " global " ) - 1 } ,
{ " inline " , sizeof ( " inline " ) - 1 } ,
{ " internal " , sizeof ( " internal " ) - 1 } ,
{ " local_persist " , sizeof ( " local_persist " ) - 1 } ,
{ " mutable " , sizeof ( " mutable " ) - 1 } ,
{ " neverinline " , sizeof ( " neverinline " ) - 1 } ,
{ " override " , sizeof ( " override " ) - 1 } ,
{ " static " , sizeof ( " static " ) - 1 } ,
{ " thread_local " , sizeof ( " thread_local " ) - 1 } ,
{ " volatile " , sizeof ( " volatile " ) - 1 } ,
{ " virtual " , sizeof ( " virtual " ) - 1 } ,
{ " * " , sizeof ( " * " ) - 1 } ,
{ " ; " , sizeof ( " ; " ) - 1 } ,
{ " static_assert " , sizeof ( " static_assert " ) - 1 } ,
{ " __string__ " , sizeof ( " __string__ " ) - 1 } ,
{ " typename " , sizeof ( " typename " ) - 1 } ,
{ " unsigned " , sizeof ( " unsigned " ) - 1 } ,
{ " signed " , sizeof ( " signed " ) - 1 } ,
{ " short " , sizeof ( " short " ) - 1 } ,
{ " long " , sizeof ( " long " ) - 1 } ,
{ " bool " , sizeof ( " bool " ) - 1 } ,
{ " char " , sizeof ( " char " ) - 1 } ,
{ " int " , sizeof ( " int " ) - 1 } ,
{ " double " , sizeof ( " double " ) - 1 } ,
{ " __int8 " , sizeof ( " __int8 " ) - 1 } ,
{ " __int16 " , sizeof ( " __int16 " ) - 1 } ,
{ " __int32 " , sizeof ( " __int32 " ) - 1 } ,
{ " __int64 " , sizeof ( " __int64 " ) - 1 } ,
{ " _W64 " , sizeof ( " _W64 " ) - 1 } ,
{ " ... " , sizeof ( " ... " ) - 1 } ,
{ " __attrib_start__ " , sizeof ( " __attrib_start__ " ) - 1 } ,
{ " GEN_API_Export_Code " , sizeof ( " GEN_API_Export_Code " ) - 1 } ,
{ " GEN_API_Import_Code " , sizeof ( " GEN_API_Import_Code " ) - 1 } ,
{ " COREUOBJECT_API " , sizeof ( " COREUOBJECT_API " ) - 1 } ,
{ " ENGINE_API " , sizeof ( " ENGINE_API " ) - 1 } ,
{ " GAMEPLAYABILITIES_API " , sizeof ( " GAMEPLAYABILITIES_API " ) - 1 } ,
{ " UMG_API " , sizeof ( " UMG_API " ) - 1 } ,
2024-12-14 05:46:22 -08:00
} ;
return lookup [ type ] ;
}
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
inline TokType str_to_toktype ( Str str )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
local_persist u32 keymap [ Tok_NumTokens ] ;
do_once_start for ( u32 index = 0 ; index < Tok_NumTokens ; index + + )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
Str enum_str = toktype_to_str ( ( TokType ) index ) ;
keymap [ index ] = crc32 ( enum_str . Ptr , enum_str . Len ) ;
}
do_once_end u32 hash = crc32 ( str . Ptr , str . Len ) ;
for ( u32 index = 0 ; index < Tok_NumTokens ; index + + )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( keymap [ index ] = = hash )
return ( TokType ) index ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return Tok_Invalid ;
}
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
enum TokFlags : u32
{
2024-12-15 07:46:36 -08:00
TF_Operator = bit ( 0 ) ,
TF_Assign = bit ( 1 ) ,
TF_Preprocess = bit ( 2 ) ,
TF_Preprocess_Cond = bit ( 3 ) ,
TF_Attribute = bit ( 6 ) ,
TF_AccessOperator = bit ( 7 ) ,
TF_AccessSpecifier = bit ( 8 ) ,
TF_Specifier = bit ( 9 ) ,
TF_EndDefinition = bit ( 10 ) , // Either ; or }
TF_Formatting = bit ( 11 ) ,
TF_Literal = bit ( 12 ) ,
TF_Macro_Functional = bit ( 13 ) ,
TF_Macro_Expects_Body = bit ( 14 ) ,
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
TF_Null = 0 ,
TF_UnderlyingType = GEN_U32_MAX ,
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
struct Token
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
Str Text ;
TokType Type ;
s32 Line ;
s32 Column ;
u32 Flags ;
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
constexpr Token NullToken { { } , Tok_Invalid , 0 , 0 , TF_Null } ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
FORCEINLINE
AccessSpec tok_to_access_specifier ( Token tok ) {
return scast ( AccessSpec , tok . Type ) ;
}
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
FORCEINLINE
Str tok_to_str ( Token tok ) {
return tok . Text ;
}
FORCEINLINE
bool tok_is_valid ( Token tok ) {
return tok . Text . Ptr & & tok . Text . Len & & tok . Type ! = Tok_Invalid ;
}
FORCEINLINE
bool tok_is_access_operator ( Token tok ) {
2024-12-15 07:46:36 -08:00
return bitfield_is_set ( u32 , tok . Flags , TF_AccessOperator ) ;
2024-12-14 05:46:22 -08:00
}
FORCEINLINE
bool tok_is_access_specifier ( Token tok ) {
2024-12-15 07:46:36 -08:00
return bitfield_is_set ( u32 , tok . Flags , TF_AccessSpecifier ) ;
2024-12-14 05:46:22 -08:00
}
FORCEINLINE
bool tok_is_attribute ( Token tok ) {
2024-12-15 07:46:36 -08:00
return bitfield_is_set ( u32 , tok . Flags , TF_Attribute ) ;
2024-12-14 05:46:22 -08:00
}
FORCEINLINE
bool tok_is_operator ( Token tok ) {
2024-12-15 07:46:36 -08:00
return bitfield_is_set ( u32 , tok . Flags , TF_Operator ) ;
2024-12-14 05:46:22 -08:00
}
FORCEINLINE
bool tok_is_preprocessor ( Token tok ) {
2024-12-15 07:46:36 -08:00
return bitfield_is_set ( u32 , tok . Flags , TF_Preprocess ) ;
2024-12-14 05:46:22 -08:00
}
FORCEINLINE
bool tok_is_preprocess_cond ( Token tok ) {
2024-12-15 07:46:36 -08:00
return bitfield_is_set ( u32 , tok . Flags , TF_Preprocess_Cond ) ;
2024-12-14 05:46:22 -08:00
}
FORCEINLINE
bool tok_is_specifier ( Token tok ) {
2024-12-15 07:46:36 -08:00
return bitfield_is_set ( u32 , tok . Flags , TF_Specifier ) ;
2024-12-14 05:46:22 -08:00
}
FORCEINLINE
bool tok_is_end_definition ( Token tok ) {
2024-12-15 07:46:36 -08:00
return bitfield_is_set ( u32 , tok . Flags , TF_EndDefinition ) ;
2024-12-14 05:46:22 -08:00
}
StrBuilder tok_to_strbuilder ( Token tok ) ;
struct TokArray
{
Array ( Token ) Arr ;
s32 Idx ;
} ;
struct LexContext
{
Str content ;
s32 left ;
char const * scanner ;
s32 line ;
s32 column ;
2024-12-15 07:46:36 -08:00
// StringTable defines;
2024-12-14 05:46:22 -08:00
Token token ;
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
struct StackNode
{
StackNode * Prev ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
Token * Start ;
Str Name ; // The name of the AST node (if parsed)
Str ProcName ; // The name of the procedure
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
struct ParseContext
{
TokArray Tokens ;
StackNode * Scope ;
} ;
2024-12-15 07:46:36 -08:00
enum MacroType : u16
{
MT_Expression , // A macro is assumed to be a expression if not resolved.
MT_Statement ,
MT_Typename ,
MT_Attribute , // More of a note to the parser than anythign else (attributes should be defined in the user attribues def).
MT_Specifier , // More of a note to the parser than anythign else (specifiers should be defined in the user attribues def).
MT_Block_Start , // Not Supported yet
MT_Block_End , // Not Supported yet
MT_Case_Statement , // Not Supported yet
MT_UnderlyingType = GEN_U16_MAX ,
} ;
FORCEINLINE
TokType macrotype_to_toktype ( MacroType type ) {
switch ( type ) {
case MT_Statement : return Tok_Preprocess_Macro_Stmt ;
case MT_Expression : return Tok_Preprocess_Macro_Expr ;
case MT_Typename : return Tok_Preprocess_Macro_Typename ;
}
// All others unsupported for now.
return Tok_Invalid ;
}
Str macrotype_to_str ( MacroType type )
{
local_persist
Str lookup [ ] = {
{ " Statement " , sizeof ( " Statement " ) - 1 } ,
{ " Expression " , sizeof ( " Expression " ) - 1 } ,
{ " Typename " , sizeof ( " Typename " ) - 1 } ,
{ " Attribute(Macro) " , sizeof ( " Attribute(Macro) " ) - 1 } ,
{ " Specifier(Macro) " , sizeof ( " Specifier(Macro) " ) - 1 } ,
{ " Block_Start " , sizeof ( " Block_Start " ) - 1 } ,
{ " Block_End " , sizeof ( " Block_End " ) - 1 } ,
{ " Case_Statement " , sizeof ( " Case_Statement " ) - 1 } ,
} ;
local_persist
Str invalid = { " Invalid " , sizeof ( " Invalid " ) } ;
if ( type > MT_Case_Statement )
return invalid ;
return lookup [ type ] ;
}
enum EMacroFlags : u16
{
MF_Functional = bit ( 0 ) , // Macro has parameters (args expected to be passed)
MF_Expects_Body = bit ( 1 ) , // Expects to assign a braced scope to its body.
2024-12-15 11:13:44 -08:00
// lex__eat wil treat this macro as an identifier if the parser attempts to consume it as one.
// ^^^ This is a kludge because we don't support push/pop macro pragmas rn.
MF_Allow_As_Identifier = bit ( 2 ) ,
// lex__eat wil treat this macro as an attribute if the parser attempts to consume it as one.
// ^^^ This a kludge because unreal has a macro that behaves as both a 'statement' and an attribute (UE_DEPRECATED, PRAGMA_ENABLE_DEPRECATION_WARNINGS, etc)
// TODO(Ed): We can keep the MF_Allow_As_Attribute flag for macros, however, we need to add the ability of AST_Attributes to chain themselves.
// Its thats already a thing in the standard language anyway
// & it would allow UE_DEPRECATED, (UE_PROPERTY / UE_FUNCTION) to chain themselves as attributes of a resolved member function/varaible definition
MF_Allow_As_Attribute = bit ( 3 ) ,
// When a macro is encountered after attributs and specifiers while parsing a function, or variable:
// It will consume the macro and treat it as resolving the definition. (Yes this is for Unreal Engine)
// (MUST BE OF MT_Statement TYPE)
MF_Allow_As_Definition = bit ( 4 ) ,
2024-12-15 07:46:36 -08:00
MF_Null = 0 ,
MF_UnderlyingType = GEN_U16_MAX ,
} ;
typedef u16 MacroFlags ;
struct Macro
{
StrCached Name ;
MacroType Type ;
MacroFlags Flags ;
} ;
FORCEINLINE
b32 macro_is_functional ( Macro macro ) {
return bitfield_is_set ( b16 , macro . Flags , MF_Functional ) ;
}
FORCEINLINE
b32 macro_expects_body ( Macro macro ) {
return bitfield_is_set ( b16 , macro . Flags , MF_Expects_Body ) ;
}
typedef HashTable ( Macro ) MacroTable ;
2024-04-13 13:18:57 -07:00
# pragma endregion Types
# pragma region AST
2024-12-14 05:46:22 -08:00
/*
______ ______ ________ __ __ ______ __
/ \ / \ | \ | \ | \ / \ | \
| ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ \ | ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ \ ______ ____ | ▓ ▓ ______
| ▓ ▓ __ | ▓ ▓ ▓ ▓ ___ \ ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ \ | ▓ ▓ | ▓ ▓ \ ▓ ▓ / \ / ▓ ▓ / \
| ▓ ▓ ▓ ▓ \ ▓ ▓ \ | ▓ ▓ | ▓ ▓ ▓ ▓ \ ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \
| ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ _ \ ▓ ▓ ▓ ▓ ▓ ▓ \ | ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ | ▓ ▓ __ | ▓ ▓ | ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓
| ▓ ▓ | ▓ ▓ \ __ | ▓ ▓ | ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ | ▓ ▓ __ / \ ▓ ▓ __ / ▓ ▓ ▓ ▓ __ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓
| ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ \
\ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓
*/
2024-04-13 13:18:57 -07:00
struct AST ;
struct AST_Body ;
struct AST_Attributes ;
struct AST_Comment ;
struct AST_Constructor ;
// struct AST_BaseClass;
struct AST_Class ;
struct AST_Define ;
2024-12-15 07:46:36 -08:00
struct AST_DefineParams ;
2024-04-13 13:18:57 -07:00
struct AST_Destructor ;
struct AST_Enum ;
struct AST_Exec ;
struct AST_Extern ;
struct AST_Include ;
struct AST_Friend ;
struct AST_Fn ;
struct AST_Module ;
struct AST_NS ;
struct AST_Operator ;
struct AST_OpCast ;
2024-12-14 05:46:22 -08:00
struct AST_Params ;
2024-04-13 13:18:57 -07:00
struct AST_Pragma ;
struct AST_PreprocessCond ;
struct AST_Specifiers ;
# if GEN_EXECUTION_EXPRESSION_SUPPORT
struct AST_Expr ;
struct AST_Expr_Assign ;
struct AST_Expr_Alignof ;
struct AST_Expr_Binary ;
struct AST_Expr_CStyleCast ;
struct AST_Expr_FunctionalCast ;
struct AST_Expr_CppCast ;
struct AST_Expr_ProcCall ;
struct AST_Expr_Decltype ;
2024-12-14 05:46:22 -08:00
struct AST_Expr_Comma ; // TODO(Ed) : This is a binary op not sure if it needs its own AST...
struct AST_Expr_AMS ; // Access Member Symbol
2024-04-13 13:18:57 -07:00
struct AST_Expr_Sizeof ;
struct AST_Expr_Subscript ;
struct AST_Expr_Ternary ;
struct AST_Expr_UnaryPrefix ;
struct AST_Expr_UnaryPostfix ;
struct AST_Expr_Element ;
struct AST_Stmt ;
struct AST_Stmt_Break ;
struct AST_Stmt_Case ;
struct AST_Stmt_Continue ;
struct AST_Stmt_Decl ;
struct AST_Stmt_Do ;
2024-12-14 05:46:22 -08:00
struct AST_Stmt_Expr ; // TODO(Ed) : Is this distinction needed? (Should it be a flag instead?)
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Else ;
struct AST_Stmt_If ;
struct AST_Stmt_For ;
struct AST_Stmt_Goto ;
struct AST_Stmt_Label ;
struct AST_Stmt_Switch ;
struct AST_Stmt_While ;
# endif
struct AST_Struct ;
struct AST_Template ;
2024-12-14 05:46:22 -08:00
struct AST_Typename ;
2024-04-13 13:18:57 -07:00
struct AST_Typedef ;
struct AST_Union ;
struct AST_Using ;
struct AST_Var ;
2024-12-14 05:46:22 -08:00
# if GEN_COMPILER_C
typedef AST * Code ;
# else
2024-04-13 13:18:57 -07:00
struct Code ;
2024-12-14 05:46:22 -08:00
# endif
# if GEN_COMPILER_C
typedef AST_Body * CodeBody ;
typedef AST_Attributes * CodeAttributes ;
typedef AST_Comment * CodeComment ;
typedef AST_Class * CodeClass ;
typedef AST_Constructor * CodeConstructor ;
typedef AST_Define * CodeDefine ;
2024-12-15 07:46:36 -08:00
typedef AST_DefineParams * CodeDefineParams ;
2024-12-14 05:46:22 -08:00
typedef AST_Destructor * CodeDestructor ;
typedef AST_Enum * CodeEnum ;
typedef AST_Exec * CodeExec ;
typedef AST_Extern * CodeExtern ;
typedef AST_Include * CodeInclude ;
typedef AST_Friend * CodeFriend ;
typedef AST_Fn * CodeFn ;
typedef AST_Module * CodeModule ;
typedef AST_NS * CodeNS ;
typedef AST_Operator * CodeOperator ;
typedef AST_OpCast * CodeOpCast ;
typedef AST_Params * CodeParams ;
typedef AST_PreprocessCond * CodePreprocessCond ;
typedef AST_Pragma * CodePragma ;
typedef AST_Specifiers * CodeSpecifiers ;
# else
2024-04-13 13:18:57 -07:00
struct CodeBody ;
struct CodeAttributes ;
struct CodeComment ;
struct CodeClass ;
struct CodeConstructor ;
struct CodeDefine ;
2024-12-15 07:46:36 -08:00
struct CodeDefineParams ;
2024-04-13 13:18:57 -07:00
struct CodeDestructor ;
struct CodeEnum ;
struct CodeExec ;
struct CodeExtern ;
struct CodeInclude ;
struct CodeFriend ;
struct CodeFn ;
struct CodeModule ;
struct CodeNS ;
struct CodeOperator ;
struct CodeOpCast ;
2024-12-14 05:46:22 -08:00
struct CodeParams ;
2024-04-13 13:18:57 -07:00
struct CodePreprocessCond ;
struct CodePragma ;
struct CodeSpecifiers ;
2024-12-14 05:46:22 -08:00
# endif
2024-04-13 13:18:57 -07:00
# if GEN_EXECUTION_EXPRESSION_SUPPORT
2024-12-14 05:46:22 -08:00
# if GEN_COMPILER_C
typedef AST_Expr * CodeExpr ;
typedef AST_Expr_Assign * CodeExpr_Assign ;
typedef AST_Expr_Alignof * CodeExpr_Alignof ;
typedef AST_Expr_Binary * CodeExpr_Binary ;
typedef AST_Expr_CStyleCast * CodeExpr_CStyleCast ;
typedef AST_Expr_FunctionalCast * CodeExpr_FunctionalCast ;
typedef AST_Expr_CppCast * CodeExpr_CppCast ;
typedef AST_Expr_Element * CodeExpr_Element ;
typedef AST_Expr_ProcCall * CodeExpr_ProcCall ;
typedef AST_Expr_Decltype * CodeExpr_Decltype ;
typedef AST_Expr_Comma * CodeExpr_Comma ;
typedef AST_Expr_AMS * CodeExpr_AMS ; // Access Member Symbol
typedef AST_Expr_Sizeof * CodeExpr_Sizeof ;
typedef AST_Expr_Subscript * CodeExpr_Subscript ;
typedef AST_Expr_Ternary * CodeExpr_Ternary ;
typedef AST_Expr_UnaryPrefix * CodeExpr_UnaryPrefix ;
typedef AST_Expr_UnaryPostfix * CodeExpr_UnaryPostfix ;
# else
2024-04-13 13:18:57 -07:00
struct CodeExpr ;
struct CodeExpr_Assign ;
struct CodeExpr_Alignof ;
struct CodeExpr_Binary ;
struct CodeExpr_CStyleCast ;
struct CodeExpr_FunctionalCast ;
struct CodeExpr_CppCast ;
struct CodeExpr_Element ;
struct CodeExpr_ProcCall ;
struct CodeExpr_Decltype ;
struct CodeExpr_Comma ;
2024-12-14 05:46:22 -08:00
struct CodeExpr_AMS ; // Access Member Symbol
2024-04-13 13:18:57 -07:00
struct CodeExpr_Sizeof ;
struct CodeExpr_Subscript ;
struct CodeExpr_Ternary ;
struct CodeExpr_UnaryPrefix ;
struct CodeExpr_UnaryPostfix ;
2024-12-14 05:46:22 -08:00
# endif
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# if GEN_COMPILER_C
typedef AST_Stmt * CodeStmt ;
typedef AST_Stmt_Break * CodeStmt_Break ;
typedef AST_Stmt_Case * CodeStmt_Case ;
typedef AST_Stmt_Continue * CodeStmt_Continue ;
typedef AST_Stmt_Decl * CodeStmt_Decl ;
typedef AST_Stmt_Do * CodeStmt_Do ;
typedef AST_Stmt_Expr * CodeStmt_Expr ;
typedef AST_Stmt_Else * CodeStmt_Else ;
typedef AST_Stmt_If * CodeStmt_If ;
typedef AST_Stmt_For * CodeStmt_For ;
typedef AST_Stmt_Goto * CodeStmt_Goto ;
typedef AST_Stmt_Label * CodeStmt_Label ;
typedef AST_Stmt_Switch * CodeStmt_Switch ;
typedef AST_Stmt_While * CodeStmt_While ;
# else
2024-04-13 13:18:57 -07:00
struct CodeStmt ;
struct CodeStmt_Break ;
struct CodeStmt_Case ;
struct CodeStmt_Continue ;
struct CodeStmt_Decl ;
struct CodeStmt_Do ;
struct CodeStmt_Expr ;
struct CodeStmt_Else ;
struct CodeStmt_If ;
struct CodeStmt_For ;
struct CodeStmt_Goto ;
struct CodeStmt_Label ;
struct CodeStmt_Switch ;
struct CodeStmt_While ;
# endif
2024-12-14 05:46:22 -08:00
// GEN_EXECUTION_EXPRESSION_SUPPORT
# endif
# if GEN_COMPILER_C
typedef AST_Struct * CodeStruct ;
typedef AST_Template * CodeTemplate ;
typedef AST_Typename * CodeTypename ;
typedef AST_Typedef * CodeTypedef ;
typedef AST_Union * CodeUnion ;
typedef AST_Using * CodeUsing ;
typedef AST_Var * CodeVar ;
# else
2024-04-13 13:18:57 -07:00
struct CodeStruct ;
struct CodeTemplate ;
2024-12-14 05:46:22 -08:00
struct CodeTypename ;
2024-04-13 13:18:57 -07:00
struct CodeTypedef ;
struct CodeUnion ;
struct CodeUsing ;
struct CodeVar ;
2024-12-14 05:46:22 -08:00
# endif
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# if GEN_COMPILER_CPP
template < class Type > FORCEINLINE Type tmpl_cast ( Code self ) { return * rcast ( Type * , & self ) ; }
# endif
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# pragma region Code C-Interface
GEN_API void code_append ( Code code , Code other ) ;
GEN_API Str code_debug_str ( Code code ) ;
GEN_API Code code_duplicate ( Code code ) ;
GEN_API Code * code_entry ( Code code , u32 idx ) ;
GEN_API bool code_has_entries ( Code code ) ;
GEN_API bool code_is_body ( Code code ) ;
GEN_API bool code_is_equal ( Code code , Code other ) ;
GEN_API bool code_is_valid ( Code code ) ;
GEN_API void code_set_global ( Code code ) ;
GEN_API StrBuilder code_to_strbuilder ( Code self ) ;
GEN_API void code_to_strbuilder_ptr ( Code self , StrBuilder * result ) ;
GEN_API Str code_type_str ( Code self ) ;
GEN_API bool code_validate_body ( Code self ) ;
# pragma endregion Code C-Interface
# if GEN_COMPILER_CPP
2024-04-13 13:18:57 -07:00
/*
2024-12-14 05:46:22 -08:00
AST * wrapper
- Not constantly have to append the ' * ' as this is written often . .
- Allows for implicit conversion to any of the ASTs ( raw or filtered ) .
2024-04-13 13:18:57 -07:00
*/
struct Code
{
2024-12-14 05:46:22 -08:00
AST * ast ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# define Using_Code( Typename ) \
FORCEINLINE Str 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 ) \
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 ; } \
2024-04-13 13:18:57 -07:00
operator bool ( ) ;
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( Code ) ;
2024-12-14 05:46:22 -08:00
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 StrBuilder to_strbuilder ( ) { return code_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return code_to_strbuilder_ptr ( * this , & result ) ; }
FORCEINLINE Str type_str ( ) { return code_type_str ( * this ) ; }
FORCEINLINE bool validate_body ( ) { return code_validate_body ( * this ) ; }
# endif
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
Using_CodeOps ( Code ) ;
FORCEINLINE Code operator * ( ) { return * this ; } // Required to support for-range iteration.
FORCEINLINE AST * operator - > ( ) { return ast ; }
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
Code & operator + + ( ) ;
2024-04-13 13:18:57 -07:00
# ifdef GEN_ENFORCE_STRONG_CODE_TYPES
2024-12-14 05:46:22 -08:00
# define operator explicit operator
2024-04-13 13:18:57 -07:00
# endif
operator CodeBody ( ) const ;
operator CodeAttributes ( ) const ;
// operator CodeBaseClass() const;
operator CodeComment ( ) const ;
operator CodeClass ( ) const ;
operator CodeConstructor ( ) const ;
operator CodeDefine ( ) const ;
2024-12-15 07:46:36 -08:00
operator CodeDefineParams ( ) const ;
2024-04-13 13:18:57 -07:00
operator CodeDestructor ( ) const ;
operator CodeExec ( ) const ;
operator CodeEnum ( ) const ;
operator CodeExtern ( ) const ;
operator CodeInclude ( ) const ;
operator CodeFriend ( ) const ;
operator CodeFn ( ) const ;
operator CodeModule ( ) const ;
operator CodeNS ( ) const ;
operator CodeOperator ( ) const ;
operator CodeOpCast ( ) const ;
2024-12-14 05:46:22 -08:00
operator CodeParams ( ) const ;
2024-04-13 13:18:57 -07:00
operator CodePragma ( ) const ;
operator CodePreprocessCond ( ) const ;
operator CodeSpecifiers ( ) const ;
operator CodeStruct ( ) const ;
operator CodeTemplate ( ) const ;
2024-12-14 05:46:22 -08:00
operator CodeTypename ( ) const ;
2024-04-13 13:18:57 -07:00
operator CodeTypedef ( ) const ;
operator CodeUnion ( ) const ;
operator CodeUsing ( ) const ;
operator CodeVar ( ) const ;
2024-12-14 05:46:22 -08:00
# undef operator
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
# endif
# pragma region Statics
// Used to identify ASTs that should always be duplicated. (Global constant ASTs)
extern Code Code_Global ;
// Used to identify invalid generated code.
extern Code Code_Invalid ;
# pragma endregion Statics
2024-04-13 13:18:57 -07:00
struct Code_POD
{
AST * ast ;
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( Code ) = = sizeof ( Code_POD ) , " ERROR: Code is not POD " ) ;
2024-04-13 13:18:57 -07:00
// Desired width of the AST data structure.
constexpr int const AST_POD_Size = 128 ;
2024-12-14 05:46:22 -08:00
constexpr static
int AST_ArrSpecs_Cap =
(
AST_POD_Size
- sizeof ( Code )
- sizeof ( StrCached )
- sizeof ( Code ) * 2
- sizeof ( Token * )
- sizeof ( Code )
- sizeof ( CodeType )
- sizeof ( ModuleFlag )
- sizeof ( u32 )
)
/ sizeof ( Specifier ) - 1 ;
2024-04-13 13:18:57 -07:00
/*
2024-12-14 05:46:22 -08:00
Simple AST POD with functionality to seralize into C + + syntax .
2024-12-15 07:46:36 -08:00
TODO ( Ed ) : Eventually haven ' t a transparent AST like this will longer be viable once statements & expressions are in ( most likely . . . . )
2024-04-13 13:18:57 -07:00
*/
struct AST
{
2024-12-14 05:46:22 -08:00
union {
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
Code InlineCmt ; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
2024-12-15 07:46:36 -08:00
Code Attributes ; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable // TODO(Ed): Parameters can have attributes
2024-12-14 05:46:22 -08:00
Code Specs ; // Destructor, Function, Operator, Typename, Variable
union {
Code InitializerList ; // Constructor
Code ParentType ; // Class, Struct, ParentType->Next has a possible list of interfaces.
Code ReturnType ; // Function, Operator, Typename
Code UnderlyingType ; // Enum, Typedef
Code ValueType ; // Parameter, Variable
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
union {
Code Macro ; // Parameter
Code BitfieldSize ; // Variable (Class/Struct Data Member)
2024-12-15 07:46:36 -08:00
Code Params ; // Constructor, Define, Function, Operator, Template, Typename
2024-12-14 05:46:22 -08:00
Code UnderlyingTypeMacro ; // Enum
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
union {
Code ArrExpr ; // Typename
2024-12-15 07:46:36 -08:00
Code Body ; // Class, Constructor, Define, Destructor, Enum, Friend, Function, Namespace, Struct, Union
2024-12-14 05:46:22 -08:00
Code Declaration ; // Friend, Template
Code Value ; // Parameter, Variable
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
union {
Code NextVar ; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
Code SuffixSpecs ; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
Code PostNameMacro ; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Content ; // Attributes, Comment, Execution, Include
struct {
Specifier ArrSpecs [ AST_ArrSpecs_Cap ] ; // Specifiers
Code NextSpecs ; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
union {
Code Prev ;
Code Front ;
Code Last ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
union {
Code Next ;
Code Back ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
Token * Token ; // Reference to starting token, only avaialble if it was derived from parsing.
Code Parent ;
CodeType Type ;
// CodeFlag CodeFlags;
ModuleFlag ModuleFlags ;
union {
b32 IsFunction ; // Used by typedef to not serialize the name field.
struct {
b16 IsParamPack ; // Used by typename to know if type should be considered a parameter pack.
ETypenameTag TypeTag ; // Used by typename to keep track of explicitly declared tags for the identifier (enum, struct, union)
} ;
Operator Op ;
AccessSpec ParentAccess ;
s32 NumEntries ;
s32 VarParenthesizedInit ; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST ) = = AST_POD_Size , " ERROR: AST is not size of AST_POD_Size " ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# if GEN_COMPILER_CPP
// Uses an implicitly overloaded cast from the AST to the desired code type.
// Necessary if the user wants GEN_ENFORCE_STRONG_CODE_TYPES
struct InvalidCode_ImplictCaster ;
# define InvalidCode (InvalidCode_ImplictCaster{})
# else
# define InvalidCode (void*){ (void*)Code_Invalid }
# endif
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# if GEN_COMPILER_CPP
struct NullCode_ImplicitCaster ;
// Used when the its desired when omission is allowed in a definition.
# define NullCode (NullCode_ImplicitCaster{})
# else
# define NullCode nullptr
# endif
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
/*
______ __ ______ __ ______
/ \ | \ | \ | \ / \
| ▓ ▓ ▓ ▓ ▓ ▓ \ ______ ____ | ▓ ▓ ______ \ ▓ ▓ ▓ ▓ ▓ ▓ _______ _ | ▓ ▓ _ ______ ______ | ▓ ▓ ▓ ▓ ▓ ▓ \ ______ _______ ______
| ▓ ▓ \ ▓ ▓ / \ / ▓ ▓ / \ | ▓ ▓ | \ | ▓ ▓ \ / \ / \ | ▓ ▓ _ \ ▓ ▓ | \ / \ / \
| ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ | ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ \ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \
| ▓ ▓ __ | ▓ ▓ | ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ __ | ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ / ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓
| ▓ ▓ __ / \ ▓ ▓ __ / ▓ ▓ ▓ ▓ __ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ _ | ▓ ▓ _ | ▓ ▓ | ▓ ▓ | ▓ ▓ | \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ _____ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓
\ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ \ | ▓ ▓ \ ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ \ \ ▓ ▓ \
\ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓
*/
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# pragma region Code Type C-Interface
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API void body_append ( CodeBody body , Code other ) ;
GEN_API void body_append_body ( CodeBody body , CodeBody other ) ;
GEN_API StrBuilder body_to_strbuilder ( CodeBody body ) ;
GEN_API void body_to_strbuilder_ref ( CodeBody body , StrBuilder * result ) ;
GEN_API void body_to_strbuilder_export ( CodeBody body , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API Code begin_CodeBody ( CodeBody body ) ;
GEN_API Code end_CodeBody ( CodeBody body ) ;
GEN_API Code next_CodeBody ( CodeBody body , Code entry_iter ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API void class_add_interface ( CodeClass self , CodeTypename interface ) ;
GEN_API StrBuilder class_to_strbuilder ( CodeClass self ) ;
GEN_API void class_to_strbuilder_def ( CodeClass self , StrBuilder * result ) ;
GEN_API void class_to_strbuilder_fwd ( CodeClass self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-15 07:46:36 -08:00
GEN_API void define_params_append ( CodeDefineParams appendee , CodeDefineParams other ) ;
GEN_API CodeDefineParams define_params_get ( CodeDefineParams params , s32 idx ) ;
GEN_API bool define_params_has_entries ( CodeDefineParams params ) ;
GEN_API StrBuilder define_params_to_strbuilder ( CodeDefineParams params ) ;
GEN_API void define_params_to_strbuilder_ref ( CodeDefineParams params , StrBuilder * result ) ;
GEN_API CodeDefineParams begin_CodeDefineParams ( CodeDefineParams params ) ;
GEN_API CodeDefineParams end_CodeDefineParams ( CodeDefineParams params ) ;
GEN_API CodeDefineParams next_CodeDefineParams ( CodeDefineParams params , CodeDefineParams entry_iter ) ;
GEN_API void params_append ( CodeParams appendee , CodeParams other ) ;
2024-12-14 05:46:22 -08:00
GEN_API CodeParams params_get ( CodeParams params , s32 idx ) ;
GEN_API bool params_has_entries ( CodeParams params ) ;
GEN_API StrBuilder params_to_strbuilder ( CodeParams params ) ;
GEN_API void params_to_strbuilder_ref ( CodeParams params , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API CodeParams begin_CodeParams ( CodeParams params ) ;
GEN_API CodeParams end_CodeParams ( CodeParams params ) ;
GEN_API CodeParams next_CodeParams ( CodeParams params , CodeParams entry_iter ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API bool specifiers_append ( CodeSpecifiers specifiers , Specifier spec ) ;
GEN_API s32 specifiers_has ( CodeSpecifiers specifiers , Specifier spec ) ;
GEN_API s32 specifiers_remove ( CodeSpecifiers specifiers , Specifier to_remove ) ;
GEN_API StrBuilder specifiers_to_strbuilder ( CodeSpecifiers specifiers ) ;
GEN_API void specifiers_to_strbuilder_ref ( CodeSpecifiers specifiers , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API Specifier * begin_CodeSpecifiers ( CodeSpecifiers specifiers ) ;
GEN_API Specifier * end_CodeSpecifiers ( CodeSpecifiers specifiers ) ;
GEN_API Specifier * next_CodeSpecifiers ( CodeSpecifiers specifiers , Specifier * spec_iter ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API void struct_add_interface ( CodeStruct self , CodeTypename interface ) ;
GEN_API StrBuilder struct_to_strbuilder ( CodeStruct self ) ;
GEN_API void struct_to_strbuilder_fwd ( CodeStruct self , StrBuilder * result ) ;
GEN_API void struct_to_strbuilder_def ( CodeStruct self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder attributes_to_strbuilder ( CodeAttributes attributes ) ;
GEN_API void attributes_to_strbuilder_ref ( CodeAttributes attributes , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder comment_to_strbuilder ( CodeComment comment ) ;
GEN_API void comment_to_strbuilder_ref ( CodeComment comment , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder constructor_to_strbuilder ( CodeConstructor constructor ) ;
GEN_API void constructor_to_strbuilder_def ( CodeConstructor constructor , StrBuilder * result ) ;
GEN_API void constructor_to_strbuilder_fwd ( CodeConstructor constructor , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder define_to_strbuilder ( CodeDefine self ) ;
GEN_API void define_to_strbuilder_ref ( CodeDefine self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder destructor_to_strbuilder ( CodeDestructor destructor ) ;
GEN_API void destructor_to_strbuilder_fwd ( CodeDestructor destructor , StrBuilder * result ) ;
GEN_API void destructor_to_strbuilder_def ( CodeDestructor destructor , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder enum_to_strbuilder ( CodeEnum self ) ;
GEN_API void enum_to_strbuilder_def ( CodeEnum self , StrBuilder * result ) ;
GEN_API void enum_to_strbuilder_fwd ( CodeEnum self , StrBuilder * result ) ;
GEN_API void enum_to_strbuilder_class_def ( CodeEnum self , StrBuilder * result ) ;
GEN_API void enum_to_strbuilder_class_fwd ( CodeEnum self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder exec_to_strbuilder ( CodeExec exec ) ;
GEN_API void exec_to_strbuilder_ref ( CodeExec exec , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API void extern_to_strbuilder ( CodeExtern self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder include_to_strbuilder ( CodeInclude self ) ;
GEN_API void include_to_strbuilder_ref ( CodeInclude self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder friend_to_strbuilder ( CodeFriend self ) ;
GEN_API void friend_to_strbuilder_ref ( CodeFriend self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder fn_to_strbuilder ( CodeFn self ) ;
GEN_API void fn_to_strbuilder_def ( CodeFn self , StrBuilder * result ) ;
GEN_API void fn_to_strbuilder_fwd ( CodeFn self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder module_to_strbuilder ( CodeModule self ) ;
GEN_API void module_to_strbuilder_ref ( CodeModule self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder namespace_to_strbuilder ( CodeNS self ) ;
GEN_API void namespace_to_strbuilder_ref ( CodeNS self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder code_op_to_strbuilder ( CodeOperator self ) ;
GEN_API void code_op_to_strbuilder_fwd ( CodeOperator self , StrBuilder * result ) ;
GEN_API void code_op_to_strbuilder_def ( CodeOperator self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder opcast_to_strbuilder ( CodeOpCast op_cast ) ;
GEN_API void opcast_to_strbuilder_def ( CodeOpCast op_cast , StrBuilder * result ) ;
GEN_API void opcast_to_strbuilder_fwd ( CodeOpCast op_cast , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder pragma_to_strbuilder ( CodePragma self ) ;
GEN_API void pragma_to_strbuilder_ref ( CodePragma self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder preprocess_to_strbuilder ( CodePreprocessCond cond ) ;
GEN_API void preprocess_to_strbuilder_if ( CodePreprocessCond cond , StrBuilder * result ) ;
GEN_API void preprocess_to_strbuilder_ifdef ( CodePreprocessCond cond , StrBuilder * result ) ;
GEN_API void preprocess_to_strbuilder_ifndef ( CodePreprocessCond cond , StrBuilder * result ) ;
GEN_API void preprocess_to_strbuilder_elif ( CodePreprocessCond cond , StrBuilder * result ) ;
GEN_API void preprocess_to_strbuilder_else ( CodePreprocessCond cond , StrBuilder * result ) ;
GEN_API void preprocess_to_strbuilder_endif ( CodePreprocessCond cond , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder template_to_strbuilder ( CodeTemplate self ) ;
GEN_API void template_to_strbuilder_ref ( CodeTemplate self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder typename_to_strbuilder ( CodeTypename self ) ;
GEN_API void typename_to_strbuilder_ref ( CodeTypename self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder typedef_to_strbuilder ( CodeTypedef self ) ;
GEN_API void typedef_to_strbuilder_ref ( CodeTypedef self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder union_to_strbuilder ( CodeUnion self ) ;
GEN_API void union_to_strbuilder_def ( CodeUnion self , StrBuilder * result ) ;
GEN_API void union_to_strbuilder_fwd ( CodeUnion self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder using_to_strbuilder ( CodeUsing op_cast ) ;
GEN_API void using_to_strbuilder_ref ( CodeUsing op_cast , StrBuilder * result ) ;
GEN_API void using_to_strbuilder_ns ( CodeUsing op_cast , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API StrBuilder var_to_strbuilder ( CodeVar self ) ;
GEN_API void var_to_strbuilder_ref ( CodeVar self , StrBuilder * result ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# pragma endregion Code Type C-Interface
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# if GEN_COMPILER_CPP
# pragma region Code Types C++
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
// These structs are not used at all by the C vairant.
static_assert ( GEN_COMPILER_CPP , " This should not be compiled with the C-library " ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# define Verify_POD(Type) static_assert(size_of(Code##Type) == size_of(AST_##Type), "ERROR: Code##Type is not a POD")
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
struct CodeBody
{
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeBody ) ;
FORCEINLINE void append ( Code other ) { return body_append ( * this , other ) ; }
FORCEINLINE void append ( CodeBody body ) { return body_append ( * this , body ) ; }
FORCEINLINE bool has_entries ( ) { return code_has_entries ( * this ) ; }
FORCEINLINE StrBuilder to_strbuilder ( ) { return body_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return body_to_strbuilder_ref ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_export ( StrBuilder & result ) { return body_to_strbuilder_export ( * this , & result ) ; }
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# endif
FORCEINLINE Code begin ( ) { return begin_CodeBody ( * this ) ; }
FORCEINLINE Code end ( ) { return end_CodeBody ( * this ) ; }
Using_CodeOps ( CodeBody ) ;
FORCEINLINE operator Code ( ) { return * rcast ( Code * , this ) ; }
FORCEINLINE AST_Body * operator - > ( ) { return ast ; }
AST_Body * ast ;
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
struct CodeClass
{
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeClass ) ;
FORCEINLINE void add_interface ( CodeType interface ) ;
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) ;
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) ;
# endif
Using_CodeOps ( CodeClass ) ;
FORCEINLINE operator Code ( ) { return * rcast ( Code * , this ) ; }
FORCEINLINE AST_Class * operator - > ( ) {
GEN_ASSERT ( ast ) ;
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
AST_Class * ast ;
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
struct CodeParams
{
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeParams ) ;
2024-12-15 07:46:36 -08:00
FORCEINLINE void append ( CodeParams other ) { return params_append ( * this , other ) ; }
FORCEINLINE CodeParams get ( s32 idx ) { return params_get ( * this , idx ) ; }
FORCEINLINE bool has_entries ( ) { return params_has_entries ( * this ) ; }
FORCEINLINE StrBuilder to_strbuilder ( ) { return params_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return params_to_strbuilder_ref ( * this , & result ) ; }
2024-12-14 05:46:22 -08:00
# endif
Using_CodeOps ( CodeParams ) ;
FORCEINLINE CodeParams begin ( ) { return begin_CodeParams ( * this ) ; }
FORCEINLINE CodeParams end ( ) { return end_CodeParams ( * this ) ; }
FORCEINLINE operator Code ( ) { return { ( AST * ) ast } ; }
FORCEINLINE CodeParams operator * ( ) { return * this ; } // Required to support for-range iteration.
FORCEINLINE AST_Params * operator - > ( ) {
GEN_ASSERT ( ast ) ;
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
CodeParams & operator + + ( ) ;
AST_Params * ast ;
} ;
2024-04-13 13:18:57 -07:00
2024-12-15 07:46:36 -08:00
struct CodeDefineParams
{
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeDefineParams ) ;
FORCEINLINE void append ( CodeDefineParams other ) { return params_append ( cast ( CodeParams , * this ) , cast ( CodeParams , other ) ) ; }
FORCEINLINE CodeDefineParams get ( s32 idx ) { return ( CodeDefineParams ) ( Code ) params_get ( cast ( CodeParams , * this ) , idx ) ; }
FORCEINLINE bool has_entries ( ) { return params_has_entries ( cast ( CodeParams , * this ) ) ; }
FORCEINLINE StrBuilder to_strbuilder ( ) { return define_params_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return define_params_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeDefineParams ) ;
FORCEINLINE CodeDefineParams begin ( ) { return ( CodeDefineParams ) ( Code ) begin_CodeParams ( cast ( CodeParams , * this ) ) ; }
FORCEINLINE CodeDefineParams end ( ) { return ( CodeDefineParams ) ( Code ) end_CodeParams ( cast ( CodeParams , * this ) ) ; }
FORCEINLINE operator Code ( ) { return { ( AST * ) ast } ; }
FORCEINLINE CodeDefineParams operator * ( ) { return * this ; } // Required to support for-range iteration.
FORCEINLINE AST_DefineParams * operator - > ( ) {
GEN_ASSERT ( ast ) ;
return ast ;
}
FORCEINLINE CodeDefineParams & operator + + ( ) ;
AST_DefineParams * ast ;
} ;
2024-04-13 13:18:57 -07:00
struct CodeSpecifiers
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeSpecifiers ) ;
2024-12-14 05:46:22 -08:00
bool append ( Specifier spec ) { return specifiers_append ( * this , spec ) ; }
s32 has ( Specifier spec ) { return specifiers_has ( * this , spec ) ; }
s32 remove ( Specifier to_remove ) { return specifiers_remove ( * this , to_remove ) ; }
StrBuilder to_strbuilder ( ) { return specifiers_to_strbuilder ( * this ) ; }
void to_strbuilder ( StrBuilder & result ) { return specifiers_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeSpecifiers ) ;
FORCEINLINE operator Code ( ) { return { ( AST * ) ast } ; }
FORCEINLINE Code operator * ( ) { return * this ; } // Required to support for-range iteration.
FORCEINLINE AST_Specifiers * operator - > ( ) {
GEN_ASSERT ( ast ) ;
2024-04-13 13:18:57 -07:00
return ast ;
}
AST_Specifiers * ast ;
} ;
2024-12-14 05:46:22 -08:00
struct CodeAttributes
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeAttributes ) ;
FORCEINLINE StrBuilder to_strbuilder ( ) { return attributes_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return attributes_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeAttributes ) ;
operator Code ( ) ;
AST_Attributes * operator - > ( ) ;
AST_Attributes * ast ;
2024-04-13 13:18:57 -07:00
} ;
// Define_CodeType( BaseClass );
2024-12-14 05:46:22 -08:00
struct CodeComment
{
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeComment ) ;
FORCEINLINE StrBuilder to_strbuilder ( ) { return comment_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return comment_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeComment ) ;
operator Code ( ) ;
AST_Comment * operator - > ( ) ;
AST_Comment * ast ;
} ;
2024-04-13 13:18:57 -07:00
struct CodeConstructor
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeConstructor ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return constructor_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) { return constructor_to_strbuilder_def ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) { return constructor_to_strbuilder_fwd ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeConstructor ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Constructor * operator - > ( ) ;
AST_Constructor * ast ;
} ;
struct CodeDefine
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeDefine ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return define_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return define_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeDefine ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Define * operator - > ( ) ;
AST_Define * ast ;
} ;
struct CodeDestructor
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeDestructor ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return destructor_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) { return destructor_to_strbuilder_def ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) { return destructor_to_strbuilder_fwd ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeDestructor ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Destructor * operator - > ( ) ;
AST_Destructor * ast ;
} ;
struct CodeEnum
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeEnum ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return enum_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) { return enum_to_strbuilder_def ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) { return enum_to_strbuilder_fwd ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_class_def ( StrBuilder & result ) { return enum_to_strbuilder_class_def ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_class_fwd ( StrBuilder & result ) { return enum_to_strbuilder_class_fwd ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeEnum ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Enum * operator - > ( ) ;
AST_Enum * ast ;
} ;
2024-12-14 05:46:22 -08:00
struct CodeExec
{
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeExec ) ;
FORCEINLINE StrBuilder to_strbuilder ( ) { return exec_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return exec_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeExec ) ;
operator Code ( ) ;
AST_Exec * operator - > ( ) ;
AST_Exec * ast ;
} ;
2024-04-13 13:18:57 -07:00
# if GEN_EXECUTION_EXPRESSION_SUPPORT
struct CodeExpr
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr * operator - > ( ) ;
AST_Expr * ast ;
} ;
struct CodeExpr_Assign
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Assign ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Assign * operator - > ( ) ;
AST_Expr_Assign * ast ;
} ;
struct CodeExpr_Alignof
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Alignof ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Alignof * operator - > ( ) ;
AST_Expr_Alignof * ast ;
} ;
struct CodeExpr_Binary
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Binary ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Binary * operator - > ( ) ;
AST_Expr_Binary * ast ;
} ;
struct CodeExpr_CStyleCast
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_CStyleCast ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_CStyleCast * operator - > ( ) ;
AST_Expr_CStyleCast * ast ;
} ;
struct CodeExpr_FunctionalCast
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_FunctionalCast ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_FunctionalCast * operator - > ( ) ;
AST_Expr_FunctionalCast * ast ;
} ;
struct CodeExpr_CppCast
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_CppCast ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_CppCast * operator - > ( ) ;
AST_Expr_CppCast * ast ;
} ;
struct CodeExpr_Element
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Element ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Element * operator - > ( ) ;
AST_Expr_Element * ast ;
} ;
struct CodeExpr_ProcCall
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_ProcCall ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_ProcCall * operator - > ( ) ;
AST_Expr_ProcCall * ast ;
} ;
struct CodeExpr_Decltype
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Decltype ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Decltype * operator - > ( ) ;
AST_Expr_Decltype * ast ;
} ;
struct CodeExpr_Comma
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Comma ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Comma * operator - > ( ) ;
AST_Expr_Comma * ast ;
} ;
struct CodeExpr_AMS
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_AMS ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_AMS * operator - > ( ) ;
AST_Expr_AMS * ast ;
} ;
struct CodeExpr_Sizeof
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Sizeof ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Sizeof * operator - > ( ) ;
AST_Expr_Sizeof * ast ;
} ;
struct CodeExpr_Subscript
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Subscript ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Subscript * operator - > ( ) ;
AST_Expr_Subscript * ast ;
} ;
struct CodeExpr_Ternary
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_Ternary ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_Ternary * operator - > ( ) ;
AST_Expr_Ternary * ast ;
} ;
struct CodeExpr_UnaryPrefix
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_UnaryPrefix ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_UnaryPrefix * operator - > ( ) ;
AST_Expr_UnaryPrefix * ast ;
} ;
struct CodeExpr_UnaryPostfix
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExpr_UnaryPostfix ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
AST * raw ( ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Expr_UnaryPostfix * operator - > ( ) ;
AST_Expr_UnaryPostfix * ast ;
} ;
# endif
struct CodeExtern
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeExtern ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return extern_to_strbuilder ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeExtern ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Extern * operator - > ( ) ;
AST_Extern * ast ;
} ;
struct CodeInclude
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeInclude ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return include_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return include_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeInclude ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Include * operator - > ( ) ;
AST_Include * ast ;
} ;
struct CodeFriend
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeFriend ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return friend_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return friend_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeFriend ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Friend * operator - > ( ) ;
AST_Friend * ast ;
} ;
struct CodeFn
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeFn ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return fn_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) { return fn_to_strbuilder_def ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) { return fn_to_strbuilder_fwd ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeFn ) ;
2024-04-13 13:18:57 -07:00
operator Code ( ) ;
2024-12-14 05:46:22 -08:00
AST_Fn * operator - > ( ) ;
AST_Fn * ast ;
2024-04-13 13:18:57 -07:00
} ;
struct CodeModule
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeModule ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return module_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return module_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeModule ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Module * operator - > ( ) ;
AST_Module * ast ;
} ;
struct CodeNS
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeNS ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return namespace_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return namespace_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeNS ) ;
2024-04-13 13:18:57 -07:00
operator Code ( ) ;
2024-12-14 05:46:22 -08:00
AST_NS * operator - > ( ) ;
AST_NS * ast ;
2024-04-13 13:18:57 -07:00
} ;
struct CodeOperator
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeOperator ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return code_op_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) { return code_op_to_strbuilder_def ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) { return code_op_to_strbuilder_fwd ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeOperator ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Operator * operator - > ( ) ;
AST_Operator * ast ;
} ;
struct CodeOpCast
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeOpCast ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return opcast_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) { return opcast_to_strbuilder_def ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) { return opcast_to_strbuilder_fwd ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeOpCast ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_OpCast * operator - > ( ) ;
AST_OpCast * ast ;
} ;
struct CodePragma
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodePragma ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return pragma_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return pragma_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodePragma ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Pragma * operator - > ( ) ;
AST_Pragma * ast ;
} ;
struct CodePreprocessCond
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodePreprocessCond ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return preprocess_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_if ( StrBuilder & result ) { return preprocess_to_strbuilder_if ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_ifdef ( StrBuilder & result ) { return preprocess_to_strbuilder_ifdef ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_ifndef ( StrBuilder & result ) { return preprocess_to_strbuilder_ifndef ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_elif ( StrBuilder & result ) { return preprocess_to_strbuilder_elif ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_else ( StrBuilder & result ) { return preprocess_to_strbuilder_else ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_endif ( StrBuilder & result ) { return preprocess_to_strbuilder_endif ( * this , & result ) ; }
# endif
Using_CodeOps ( CodePreprocessCond ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_PreprocessCond * operator - > ( ) ;
AST_PreprocessCond * ast ;
} ;
# if GEN_EXECUTION_EXPRESSION_SUPPORT
struct CodeStmt
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt * operator - > ( ) ;
AST_Stmt * ast ;
} ;
struct CodeStmt_Break
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Break ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Break * operator - > ( ) ;
AST_Stmt_Break * ast ;
} ;
struct CodeStmt_Case
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Case ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Case * operator - > ( ) ;
AST_Stmt_Case * ast ;
} ;
struct CodeStmt_Continue
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Continue ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Continue * operator - > ( ) ;
AST_Stmt_Continue * ast ;
} ;
struct CodeStmt_Decl
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Decl ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Decl * operator - > ( ) ;
AST_Stmt_Decl * ast ;
} ;
struct CodeStmt_Do
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Do ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Do * operator - > ( ) ;
AST_Stmt_Do * ast ;
} ;
struct CodeStmt_Expr
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Expr ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Expr * operator - > ( ) ;
AST_Stmt_Expr * ast ;
} ;
struct CodeStmt_Else
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Else ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Else * operator - > ( ) ;
AST_Stmt_Else * ast ;
} ;
struct CodeStmt_If
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_If ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_If * operator - > ( ) ;
AST_Stmt_If * ast ;
} ;
struct CodeStmt_For
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_For ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_For * operator - > ( ) ;
AST_Stmt_For * ast ;
} ;
struct CodeStmt_Goto
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Goto ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Goto * operator - > ( ) ;
AST_Stmt_Goto * ast ;
} ;
struct CodeStmt_Label
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Label ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Label * operator - > ( ) ;
AST_Stmt_Label * ast ;
} ;
struct CodeStmt_Switch
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_Switch ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_Switch * operator - > ( ) ;
AST_Stmt_Switch * ast ;
} ;
struct CodeStmt_While
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeStmt_While ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) ;
FORCEINLINE void to_strbuilder ( StrBuilder & result ) ;
# endif
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Stmt_While * operator - > ( ) ;
AST_Stmt_While * ast ;
} ;
# endif
struct CodeTemplate
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeTemplate ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return template_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return template_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeTemplate ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Template * operator - > ( ) ;
AST_Template * ast ;
} ;
2024-12-14 05:46:22 -08:00
struct CodeTypename
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeTypename ) ;
FORCEINLINE StrBuilder to_strbuilder ( ) { return typename_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return typename_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeTypename ) ;
operator Code ( ) ;
AST_Typename * operator - > ( ) ;
AST_Typename * ast ;
2024-04-13 13:18:57 -07:00
} ;
struct CodeTypedef
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeTypedef ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return typedef_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return typedef_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeTypedef ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Typedef * operator - > ( ) ;
AST_Typedef * ast ;
} ;
struct CodeUnion
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeUnion ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return union_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) { return union_to_strbuilder_def ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) { return union_to_strbuilder_fwd ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeUnion ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Union * operator - > ( ) ;
AST_Union * ast ;
} ;
struct CodeUsing
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeUsing ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return using_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return using_to_strbuilder_ref ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_ns ( StrBuilder & result ) { return using_to_strbuilder_ns ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeUsing ) ;
operator Code ( ) ;
2024-04-13 13:18:57 -07:00
AST_Using * operator - > ( ) ;
AST_Using * ast ;
} ;
struct CodeVar
{
2024-12-14 05:46:22 -08:00
# if ! GEN_C_LIKE_CPP
2024-04-13 13:18:57 -07:00
Using_Code ( CodeVar ) ;
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( ) { return var_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder ( StrBuilder & result ) { return var_to_strbuilder_ref ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeVar ) ;
2024-04-13 13:18:57 -07:00
operator Code ( ) ;
AST_Var * operator - > ( ) ;
AST_Var * ast ;
} ;
2024-12-14 05:46:22 -08:00
struct CodeStruct
{
# if ! GEN_C_LIKE_CPP
Using_Code ( CodeStruct ) ;
FORCEINLINE void add_interface ( CodeTypename interface ) { return struct_add_interface ( * this , interface ) ; }
FORCEINLINE StrBuilder to_strbuilder ( ) { return struct_to_strbuilder ( * this ) ; }
FORCEINLINE void to_strbuilder_fwd ( StrBuilder & result ) { return struct_to_strbuilder_fwd ( * this , & result ) ; }
FORCEINLINE void to_strbuilder_def ( StrBuilder & result ) { return struct_to_strbuilder_def ( * this , & result ) ; }
# endif
Using_CodeOps ( CodeStruct ) ;
FORCEINLINE operator Code ( ) { return * rcast ( Code * , this ) ; }
FORCEINLINE AST_Struct * operator - > ( ) {
GEN_ASSERT ( ast ) ;
return ast ;
}
AST_Struct * ast ;
} ;
2024-04-13 13:18:57 -07:00
# undef Define_CodeType
# undef Using_Code
2024-12-14 05:46:22 -08:00
# undef Using_CodeOps
# undef Verify_POD
struct InvalidCode_ImplictCaster
{
// operator CodeBaseClass() const;
operator Code ( ) const { return Code_Invalid ; }
operator CodeBody ( ) const { return cast ( CodeBody , Code_Invalid ) ; }
operator CodeAttributes ( ) const { return cast ( CodeAttributes , Code_Invalid ) ; }
operator CodeComment ( ) const { return cast ( CodeComment , Code_Invalid ) ; }
operator CodeClass ( ) const { return cast ( CodeClass , Code_Invalid ) ; }
operator CodeConstructor ( ) const { return cast ( CodeConstructor , Code_Invalid ) ; }
operator CodeDefine ( ) const { return cast ( CodeDefine , Code_Invalid ) ; }
2024-12-15 07:46:36 -08:00
operator CodeDefineParams ( ) const { return cast ( CodeDefineParams , Code_Invalid ) ; }
2024-12-14 05:46:22 -08:00
operator CodeDestructor ( ) const { return cast ( CodeDestructor , Code_Invalid ) ; }
operator CodeExec ( ) const { return cast ( CodeExec , Code_Invalid ) ; }
operator CodeEnum ( ) const { return cast ( CodeEnum , Code_Invalid ) ; }
operator CodeExtern ( ) const { return cast ( CodeExtern , Code_Invalid ) ; }
operator CodeInclude ( ) const { return cast ( CodeInclude , Code_Invalid ) ; }
operator CodeFriend ( ) const { return cast ( CodeFriend , Code_Invalid ) ; }
operator CodeFn ( ) const { return cast ( CodeFn , Code_Invalid ) ; }
operator CodeModule ( ) const { return cast ( CodeModule , Code_Invalid ) ; }
operator CodeNS ( ) const { return cast ( CodeNS , Code_Invalid ) ; }
operator CodeOperator ( ) const { return cast ( CodeOperator , Code_Invalid ) ; }
operator CodeOpCast ( ) const { return cast ( CodeOpCast , Code_Invalid ) ; }
operator CodeParams ( ) const { return cast ( CodeParams , Code_Invalid ) ; }
operator CodePragma ( ) const { return cast ( CodePragma , Code_Invalid ) ; }
operator CodePreprocessCond ( ) const { return cast ( CodePreprocessCond , Code_Invalid ) ; }
operator CodeSpecifiers ( ) const { return cast ( CodeSpecifiers , Code_Invalid ) ; }
operator CodeStruct ( ) const { return cast ( CodeStruct , Code_Invalid ) ; }
operator CodeTemplate ( ) const { return cast ( CodeTemplate , Code_Invalid ) ; }
operator CodeTypename ( ) const { return cast ( CodeTypename , Code_Invalid ) ; }
operator CodeTypedef ( ) const { return cast ( CodeTypedef , Code_Invalid ) ; }
operator CodeUnion ( ) const { return cast ( CodeUnion , Code_Invalid ) ; }
operator CodeUsing ( ) const { return cast ( CodeUsing , Code_Invalid ) ; }
operator CodeVar ( ) const { return cast ( CodeVar , Code_Invalid ) ; }
} ;
struct NullCode_ImplicitCaster
{
operator Code ( ) const { return { nullptr } ; }
operator CodeBody ( ) const { return { ( AST_Body * ) nullptr } ; }
operator CodeAttributes ( ) const { return { ( AST_Attributes * ) nullptr } ; }
operator CodeComment ( ) const { return { nullptr } ; }
operator CodeClass ( ) const { return { nullptr } ; }
operator CodeConstructor ( ) const { return { nullptr } ; }
operator CodeDefine ( ) const { return { nullptr } ; }
2024-12-15 07:46:36 -08:00
operator CodeDefineParams ( ) const { return { nullptr } ; }
2024-12-14 05:46:22 -08:00
operator CodeDestructor ( ) const { return { nullptr } ; }
operator CodeExec ( ) const { return { nullptr } ; }
operator CodeEnum ( ) const { return { nullptr } ; }
operator CodeExtern ( ) const { return { nullptr } ; }
operator CodeInclude ( ) const { return { nullptr } ; }
operator CodeFriend ( ) const { return { nullptr } ; }
operator CodeFn ( ) const { return { nullptr } ; }
operator CodeModule ( ) const { return { nullptr } ; }
operator CodeNS ( ) const { return { nullptr } ; }
operator CodeOperator ( ) const { return { nullptr } ; }
operator CodeOpCast ( ) const { return { nullptr } ; }
operator CodeParams ( ) const { return { nullptr } ; }
operator CodePragma ( ) const { return { nullptr } ; }
operator CodePreprocessCond ( ) const { return { nullptr } ; }
operator CodeSpecifiers ( ) const { return { nullptr } ; }
operator CodeStruct ( ) const { return { nullptr } ; }
operator CodeTemplate ( ) const { return { nullptr } ; }
operator CodeTypename ( ) const { return CodeTypename { ( AST_Typename * ) nullptr } ; }
operator CodeTypedef ( ) const { return { nullptr } ; }
operator CodeUnion ( ) const { return { nullptr } ; }
operator CodeUsing ( ) const { return { nullptr } ; }
operator CodeVar ( ) const { return { nullptr } ; }
} ;
FORCEINLINE Code begin ( CodeBody body ) { return begin_CodeBody ( body ) ; }
FORCEINLINE Code end ( CodeBody body ) { return end_CodeBody ( body ) ; }
FORCEINLINE Code next ( CodeBody body , Code entry_iter ) { return next_CodeBody ( body , entry_iter ) ; }
FORCEINLINE CodeParams begin ( CodeParams params ) { return begin_CodeParams ( params ) ; }
FORCEINLINE CodeParams end ( CodeParams params ) { return end_CodeParams ( params ) ; }
FORCEINLINE CodeParams next ( CodeParams params , CodeParams entry_iter ) { return next_CodeParams ( params , entry_iter ) ; }
FORCEINLINE Specifier * begin ( CodeSpecifiers specifiers ) { return begin_CodeSpecifiers ( specifiers ) ; }
FORCEINLINE Specifier * end ( CodeSpecifiers specifiers ) { return end_CodeSpecifiers ( specifiers ) ; }
FORCEINLINE Specifier * next ( CodeSpecifiers specifiers , Specifier & spec_iter ) { return next_CodeSpecifiers ( specifiers , & spec_iter ) ; }
# if ! GEN_C_LIKE_CPP
GEN_OPTIMIZE_MAPPINGS_BEGIN
FORCEINLINE void append ( CodeBody body , Code other ) { return body_append ( body , other ) ; }
FORCEINLINE void append ( CodeBody body , CodeBody other ) { return body_append_body ( body , other ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeBody body ) { return body_to_strbuilder ( body ) ; }
FORCEINLINE void to_strbuilder ( CodeBody body , StrBuilder & result ) { return body_to_strbuilder_ref ( body , & result ) ; }
FORCEINLINE void to_strbuilder_export ( CodeBody body , StrBuilder & result ) { return body_to_strbuilder_export ( body , & result ) ; }
FORCEINLINE void add_interface ( CodeClass self , CodeTypename interface ) { return class_add_interface ( self , interface ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeClass self ) { return class_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder_def ( CodeClass self , StrBuilder & result ) { return class_to_strbuilder_def ( self , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeClass self , StrBuilder & result ) { return class_to_strbuilder_fwd ( self , & result ) ; }
2024-12-15 07:46:36 -08:00
FORCEINLINE void append ( CodeDefineParams appendee , CodeDefineParams other ) { params_append ( cast ( CodeParams , appendee ) , cast ( CodeParams , other ) ) ; }
FORCEINLINE CodeDefineParams get ( CodeDefineParams params , s32 idx ) { return ( CodeDefineParams ) ( Code ) params_get ( cast ( CodeParams , params ) , idx ) ; }
FORCEINLINE bool has_entries ( CodeDefineParams params ) { return params_has_entries ( cast ( CodeParams , params ) ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeDefineParams params ) { return define_params_to_strbuilder ( params ) ; }
FORCEINLINE void to_strbuilder ( CodeDefineParams params , StrBuilder & result ) { return define_params_to_strbuilder_ref ( params , & result ) ; }
FORCEINLINE void append ( CodeParams appendee , CodeParams other ) { return params_append ( appendee , other ) ; }
FORCEINLINE CodeParams get ( CodeParams params , s32 idx ) { return params_get ( params , idx ) ; }
FORCEINLINE bool has_entries ( CodeParams params ) { return params_has_entries ( params ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeParams params ) { return params_to_strbuilder ( params ) ; }
FORCEINLINE void to_strbuilder ( CodeParams params , StrBuilder & result ) { return params_to_strbuilder_ref ( params , & result ) ; }
2024-12-14 05:46:22 -08:00
FORCEINLINE bool append ( CodeSpecifiers specifiers , Specifier spec ) { return specifiers_append ( specifiers , spec ) ; }
FORCEINLINE s32 has ( CodeSpecifiers specifiers , Specifier spec ) { return specifiers_has ( specifiers , spec ) ; }
FORCEINLINE s32 remove ( CodeSpecifiers specifiers , Specifier to_remove ) { return specifiers_remove ( specifiers , to_remove ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeSpecifiers specifiers ) { return specifiers_to_strbuilder ( specifiers ) ; }
2024-12-15 07:46:36 -08:00
FORCEINLINE void to_strbuilder ( CodeSpecifiers specifiers , StrBuilder & result ) { return specifiers_to_strbuilder_ref ( specifiers , & result ) ; }
2024-12-14 05:46:22 -08:00
FORCEINLINE void add_interface ( CodeStruct self , CodeTypename interface ) { return struct_add_interface ( self , interface ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeStruct self ) { return struct_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeStruct self , StrBuilder & result ) { return struct_to_strbuilder_fwd ( self , & result ) ; }
FORCEINLINE void to_strbuilder_def ( CodeStruct self , StrBuilder & result ) { return struct_to_strbuilder_def ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeAttributes attributes ) { return attributes_to_strbuilder ( attributes ) ; }
FORCEINLINE void to_strbuilder ( CodeAttributes attributes , StrBuilder & result ) { return attributes_to_strbuilder_ref ( attributes , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeComment comment ) { return comment_to_strbuilder ( comment ) ; }
FORCEINLINE void to_strbuilder ( CodeComment comment , StrBuilder & result ) { return comment_to_strbuilder_ref ( comment , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeConstructor constructor ) { return constructor_to_strbuilder ( constructor ) ; }
FORCEINLINE void to_strbuilder_def ( CodeConstructor constructor , StrBuilder & result ) { return constructor_to_strbuilder_def ( constructor , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeConstructor constructor , StrBuilder & result ) { return constructor_to_strbuilder_fwd ( constructor , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeDefine self ) { return define_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeDefine self , StrBuilder & result ) { return define_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeDestructor destructor ) { return destructor_to_strbuilder ( destructor ) ; }
FORCEINLINE void to_strbuilder_def ( CodeDestructor destructor , StrBuilder & result ) { return destructor_to_strbuilder_def ( destructor , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeDestructor destructor , StrBuilder & result ) { return destructor_to_strbuilder_fwd ( destructor , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeEnum self ) { return enum_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder_def ( CodeEnum self , StrBuilder & result ) { return enum_to_strbuilder_def ( self , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeEnum self , StrBuilder & result ) { return enum_to_strbuilder_fwd ( self , & result ) ; }
FORCEINLINE void to_strbuilder_class_def ( CodeEnum self , StrBuilder & result ) { return enum_to_strbuilder_class_def ( self , & result ) ; }
FORCEINLINE void to_strbuilder_class_fwd ( CodeEnum self , StrBuilder & result ) { return enum_to_strbuilder_class_fwd ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeExec exec ) { return exec_to_strbuilder ( exec ) ; }
FORCEINLINE void to_strbuilder ( CodeExec exec , StrBuilder & result ) { return exec_to_strbuilder_ref ( exec , & result ) ; }
FORCEINLINE void to_strbuilder ( CodeExtern self , StrBuilder & result ) { return extern_to_strbuilder ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeInclude self ) { return include_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeInclude self , StrBuilder & result ) { return include_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeFriend self ) { return friend_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeFriend self , StrBuilder & result ) { return friend_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeFn self ) { return fn_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder_def ( CodeFn self , StrBuilder & result ) { return fn_to_strbuilder_def ( self , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeFn self , StrBuilder & result ) { return fn_to_strbuilder_fwd ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeModule self ) { return module_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeModule self , StrBuilder & result ) { return module_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeNS self ) { return namespace_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeNS self , StrBuilder & result ) { return namespace_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeOperator self ) { return code_op_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeOperator self , StrBuilder & result ) { return code_op_to_strbuilder_fwd ( self , & result ) ; }
FORCEINLINE void to_strbuilder_def ( CodeOperator self , StrBuilder & result ) { return code_op_to_strbuilder_def ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeOpCast op_cast ) { return opcast_to_strbuilder ( op_cast ) ; }
FORCEINLINE void to_strbuilder_def ( CodeOpCast op_cast , StrBuilder & result ) { return opcast_to_strbuilder_def ( op_cast , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeOpCast op_cast , StrBuilder & result ) { return opcast_to_strbuilder_fwd ( op_cast , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodePragma self ) { return pragma_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodePragma self , StrBuilder & result ) { return pragma_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodePreprocessCond cond ) { return preprocess_to_strbuilder ( cond ) ; }
FORCEINLINE void to_strbuilder_if ( CodePreprocessCond cond , StrBuilder & result ) { return preprocess_to_strbuilder_if ( cond , & result ) ; }
FORCEINLINE void to_strbuilder_ifdef ( CodePreprocessCond cond , StrBuilder & result ) { return preprocess_to_strbuilder_ifdef ( cond , & result ) ; }
FORCEINLINE void to_strbuilder_ifndef ( CodePreprocessCond cond , StrBuilder & result ) { return preprocess_to_strbuilder_ifndef ( cond , & result ) ; }
FORCEINLINE void to_strbuilder_elif ( CodePreprocessCond cond , StrBuilder & result ) { return preprocess_to_strbuilder_elif ( cond , & result ) ; }
FORCEINLINE void to_strbuilder_else ( CodePreprocessCond cond , StrBuilder & result ) { return preprocess_to_strbuilder_else ( cond , & result ) ; }
FORCEINLINE void to_strbuilder_endif ( CodePreprocessCond cond , StrBuilder & result ) { return preprocess_to_strbuilder_endif ( cond , & result ) ; }
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
FORCEINLINE StrBuilder to_strbuilder ( CodeTemplate self ) { return template_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeTemplate self , StrBuilder & result ) { return template_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeTypename self ) { return typename_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeTypename self , StrBuilder & result ) { return typename_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeTypedef self ) { return typedef_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeTypedef self , StrBuilder & result ) { return typedef_to_strbuilder_ref ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeUnion self ) { return union_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder_def ( CodeUnion self , StrBuilder & result ) { return union_to_strbuilder_def ( self , & result ) ; }
FORCEINLINE void to_strbuilder_fwd ( CodeUnion self , StrBuilder & result ) { return union_to_strbuilder_fwd ( self , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeUsing op_cast ) { return using_to_strbuilder ( op_cast ) ; }
FORCEINLINE void to_strbuilder ( CodeUsing op_cast , StrBuilder & result ) { return using_to_strbuilder_ref ( op_cast , & result ) ; }
FORCEINLINE void to_strbuilder_ns ( CodeUsing op_cast , StrBuilder & result ) { return using_to_strbuilder_ns ( op_cast , & result ) ; }
FORCEINLINE StrBuilder to_strbuilder ( CodeVar self ) { return var_to_strbuilder ( self ) ; }
FORCEINLINE void to_strbuilder ( CodeVar self , StrBuilder & result ) { return var_to_strbuilder_ref ( self , & result ) ; }
GEN_OPITMIZE_MAPPINGS_END
# endif //if GEN_C_LIKE_CPP
# pragma endregion Code Types C++
# endif //if GEN_COMPILER_CPP
2024-04-13 13:18:57 -07:00
# pragma region AST Types
/*
2024-12-14 05:46:22 -08:00
______ ______ ________ ________
/ \ / \ | \ | \
| ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ __ __ ______ ______ _______
| ▓ ▓ __ | ▓ ▓ ▓ ▓ ___ \ ▓ ▓ | ▓ ▓ | ▓ ▓ | \ | \ / \ / \ / \
| ▓ ▓ ▓ ▓ \ ▓ ▓ \ | ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓
| ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ _ \ ▓ ▓ ▓ ▓ ▓ ▓ \ | ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \
| ▓ ▓ | ▓ ▓ \ __ | ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ __ / ▓ ▓ ▓ ▓ __ / ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ _ \ ▓ ▓ ▓ ▓ ▓ ▓ \
| ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓
\ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ _ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓
| \ __ | ▓ ▓ ▓ ▓
\ ▓ ▓ ▓ ▓ ▓ ▓
\ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓
*/
/*
Show only relevant members of the AST for its type .
AST * fields are replaced with Code types .
- Guards assignemnts to AST * fields to ensure the AST is duplicated if assigned to another parent .
2024-04-13 13:18:57 -07:00
*/
struct AST_Body
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
Code Front ;
Code Back ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) ] ;
s32 NumEntries ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Body ) = = sizeof ( AST ) , " ERROR: AST_Body is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
2024-12-15 11:13:44 -08:00
// TODO(Ed): Support chaining attributes (Use parameter linkage pattern)
2024-04-13 13:18:57 -07:00
struct AST_Attributes
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
StrCached Content ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-15 11:13:44 -08:00
StrCached Name ;
2024-12-14 05:46:22 -08:00
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Attributes ) = = sizeof ( AST ) , " ERROR: AST_Attributes is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
#if 0
struct AST_BaseClass
{
union {
2024-12-14 05:46:22 -08:00
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
2024-04-13 13:18:57 -07:00
Code Prev ;
Code Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
2024-04-13 13:18:57 -07:00
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
} ;
static_assert ( sizeof ( AST_BaseClass ) = = sizeof ( AST ) , " ERROR: AST_BaseClass is not the same size as AST " ) ;
# endif
struct AST_Comment
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
StrCached Content ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Comment ) = = sizeof ( AST ) , " ERROR: AST_Comment is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Class
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
CodeComment InlineCmt ; // Only supported by forward declarations
CodeAttributes Attributes ;
char _PAD_SPECS_ [ sizeof ( AST * ) ] ;
CodeTypename ParentType ;
char _PAD_PARAMS_ [ sizeof ( AST * ) ] ;
CodeBody Body ;
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
CodeTypename Prev ;
CodeTypename Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
AccessSpec ParentAccess ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Class ) = = sizeof ( AST ) , " ERROR: AST_Class is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Constructor
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
CodeComment InlineCmt ; // Only supported by forward declarations
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 1 ] ;
2024-04-13 13:18:57 -07:00
CodeSpecifiers Specs ;
Code InitializerList ;
2024-12-14 05:46:22 -08:00
CodeParams Params ;
2024-04-13 13:18:57 -07:00
Code Body ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) * 2 ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Constructor ) = = sizeof ( AST ) , " ERROR: AST_Constructor is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Define
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-12-15 07:46:36 -08:00
struct
{
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 4 ] ;
CodeDefineParams Params ;
Code Body ; // Should be completely serialized for now to a: StrCached Content.
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) * 1 ] ;
} ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-15 07:46:36 -08:00
StrCached Name ;
2024-12-14 05:46:22 -08:00
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Define ) = = sizeof ( AST ) , " ERROR: AST_Define is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
2024-12-15 07:46:36 -08:00
struct AST_DefineParams
{
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeDefineParams Last ;
CodeDefineParams Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) ] ;
s32 NumEntries ;
} ;
static_assert ( sizeof ( AST_DefineParams ) = = sizeof ( AST ) , " ERROR: AST_DefineParams is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Destructor
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
CodeComment InlineCmt ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 1 ] ;
2024-04-13 13:18:57 -07:00
CodeSpecifiers Specs ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) * 2 ] ;
2024-04-13 13:18:57 -07:00
Code Body ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_3_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Destructor ) = = sizeof ( AST ) , " ERROR: AST_Destructor is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Enum
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
CodeComment InlineCmt ;
CodeAttributes Attributes ;
2024-12-14 05:46:22 -08:00
char _PAD_SPEC_ [ sizeof ( AST * ) ] ;
CodeTypename UnderlyingType ;
Code UnderlyingTypeMacro ;
2024-04-13 13:18:57 -07:00
CodeBody Body ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Enum ) = = sizeof ( AST ) , " ERROR: AST_Enum is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Exec
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
StrCached Content ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Exec ) = = sizeof ( AST ) , " ERROR: AST_Exec is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
# if GEN_EXECUTION_EXPRESSION_SUPPORT
struct AST_Expr
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr ) = = sizeof ( AST ) , " ERROR: AST_Expr is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Assign
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Assign ) = = sizeof ( AST ) , " ERROR: AST_Expr_Assign is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Alignof
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Alignof ) = = sizeof ( AST ) , " ERROR: AST_Expr_Alignof is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Binary
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Binary ) = = sizeof ( AST ) , " ERROR: AST_Expr_Binary is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_CStyleCast
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_CStyleCast ) = = sizeof ( AST ) , " ERROR: AST_Expr_CStyleCast is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_FunctionalCast
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_FunctionalCast ) = = sizeof ( AST ) , " ERROR: AST_Expr_FunctionalCast is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_CppCast
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_CppCast ) = = sizeof ( AST ) , " ERROR: AST_Expr_CppCast is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_ProcCall
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_ProcCall ) = = sizeof ( AST ) , " ERROR: AST_Expr_Identifier is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Decltype
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Decltype ) = = sizeof ( AST ) , " ERROR: AST_Expr_Decltype is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Comma
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Comma ) = = sizeof ( AST ) , " ERROR: AST_Expr_Comma is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_AMS
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_AMS ) = = sizeof ( AST ) , " ERROR: AST_Expr_AMS is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Sizeof
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Sizeof ) = = sizeof ( AST ) , " ERROR: AST_Expr_Sizeof is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Subscript
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Subscript ) = = sizeof ( AST ) , " ERROR: AST_Expr_Subscript is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Ternary
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Ternary ) = = sizeof ( AST ) , " ERROR: AST_Expr_Ternary is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_UnaryPrefix
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_UnaryPrefix ) = = sizeof ( AST ) , " ERROR: AST_Expr_UnaryPrefix is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_UnaryPostfix
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_UnaryPostfix ) = = sizeof ( AST ) , " ERROR: AST_Expr_UnaryPostfix is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Expr_Element
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Expr_Element ) = = sizeof ( AST ) , " ERROR: AST_Expr_Element is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
# endif
struct AST_Extern
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 5 ] ;
CodeBody Body ;
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Extern ) = = sizeof ( AST ) , " ERROR: AST_Extern is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Include
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
StrCached Content ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Include ) = = sizeof ( AST ) , " ERROR: AST_Include is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Friend
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
CodeComment InlineCmt ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 4 ] ;
2024-04-13 13:18:57 -07:00
Code Declaration ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Friend ) = = sizeof ( AST ) , " ERROR: AST_Friend is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Fn
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
CodeComment InlineCmt ;
CodeAttributes Attributes ;
CodeSpecifiers Specs ;
CodeTypename ReturnType ;
CodeParams Params ;
CodeBody Body ;
char _PAD_PROPERTIES_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
char _PAD_UNUSED_ [ sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Fn ) = = sizeof ( AST ) , " ERROR: AST_Fn is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Module
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
char _PAD_UNUSED_ [ sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Module ) = = sizeof ( AST ) , " ERROR: AST_Module is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_NS
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
struct {
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 5 ] ;
CodeBody Body ;
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
char _PAD_UNUSED_ [ sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_NS ) = = sizeof ( AST ) , " ERROR: AST_NS is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Operator
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
CodeComment InlineCmt ;
CodeAttributes Attributes ;
CodeSpecifiers Specs ;
CodeTypename ReturnType ;
CodeParams Params ;
CodeBody Body ;
char _PAD_PROPERTIES_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
2024-04-13 13:18:57 -07:00
Code Prev ;
Code Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
2024-04-13 13:18:57 -07:00
ModuleFlag ModuleFlags ;
2024-12-14 05:46:22 -08:00
Operator Op ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Operator ) = = sizeof ( AST ) , " ERROR: AST_Operator is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_OpCast
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
CodeComment InlineCmt ;
char _PAD_PROPERTIES_ [ sizeof ( AST * ) ] ;
CodeSpecifiers Specs ;
CodeTypename ValueType ;
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
CodeBody Body ;
char _PAD_PROPERTIES_3_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_OpCast ) = = sizeof ( AST ) , " ERROR: AST_OpCast is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
struct AST_Params
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-15 07:46:36 -08:00
// TODO(Ed): Support attributes for parameters (Some prefix macros can be converted to that...)
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) * 3 ] ;
CodeTypename ValueType ;
Code Macro ;
Code Value ;
Code PostNameMacro ; // Thanks Unreal
// char _PAD_PROPERTIES_3_[sizeof( AST* )];
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-15 07:46:36 -08:00
StrCached Name ;
2024-12-14 05:46:22 -08:00
CodeParams Last ;
CodeParams Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) ] ;
s32 NumEntries ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Params ) = = sizeof ( AST ) , " ERROR: AST_Params is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Pragma
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
StrCached Content ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Pragma ) = = sizeof ( AST ) , " ERROR: AST_Pragma is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_PreprocessCond
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
StrCached Content ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_PreprocessCond ) = = sizeof ( AST ) , " ERROR: AST_PreprocessCond is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Specifiers
{
2024-12-14 05:46:22 -08:00
Specifier ArrSpecs [ AST_ArrSpecs_Cap ] ;
StrCached Name ;
CodeSpecifiers NextSpecs ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) ] ;
s32 NumEntries ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Specifiers ) = = sizeof ( AST ) , " ERROR: AST_Specifier is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
# if GEN_EXECUTION_EXPRESSION_SUPPORT
struct AST_Stmt
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt ) = = sizeof ( AST ) , " ERROR: AST_Stmt is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Break
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Break ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Break is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Case
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Case ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Case is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Continue
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Continue ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Continue is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Decl
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Decl ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Decl is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Do
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Do ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Do is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Expr
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Expr ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Expr is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Else
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Else ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Else is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_If
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_If ) = = sizeof ( AST ) , " ERROR: AST_Stmt_If is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_For
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_For ) = = sizeof ( AST ) , " ERROR: AST_Stmt_For is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Goto
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Goto ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Goto is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Label
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Label ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Label is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_Switch
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_Switch ) = = sizeof ( AST ) , " ERROR: AST_Stmt_Switch is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Stmt_While
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
} ;
StrCached Name ;
CodeExpr Prev ;
2024-04-13 13:18:57 -07:00
CodeExpr Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) + sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Stmt_While ) = = sizeof ( AST ) , " ERROR: AST_Stmt_While is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
# endif
struct AST_Struct
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
CodeComment InlineCmt ;
CodeAttributes Attributes ;
2024-12-14 05:46:22 -08:00
char _PAD_SPECS_ [ sizeof ( AST * ) ] ;
CodeTypename ParentType ;
char _PAD_PARAMS_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
CodeBody Body ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
CodeTypename Prev ;
CodeTypename Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
AccessSpec ParentAccess ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Struct ) = = sizeof ( AST ) , " ERROR: AST_Struct is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Template
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 4 ] ;
CodeParams Params ;
Code Declaration ;
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
char _PAD_UNUSED_ [ sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Template ) = = sizeof ( AST ) , " ERROR: AST_Template is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
#if 0
// WIP... The type ast is going to become more advanced and lead to a major change to AST design.
struct AST_Type
{
union {
2024-12-14 05:46:22 -08:00
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
char _PAD_INLINE_CMT_ [ sizeof ( AST * ) ] ;
2024-12-14 05:46:22 -08:00
CodeAttributes Attributes ;
CodeSpecifiers Specs ;
Code QualifierID ;
// CodeTypename ReturnType; // Only used for function signatures
// CodeParams Params; // Only used for function signatures
Code ArrExpr ;
2024-04-13 13:18:57 -07:00
// CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
2024-04-13 13:18:57 -07:00
Code Prev ;
Code Next ;
2024-12-14 05:46:22 -08:00
Token * Tok ;
2024-04-13 13:18:57 -07:00
Code Parent ;
2024-12-14 05:46:22 -08:00
CodeType Type ;
2024-04-13 13:18:57 -07:00
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) ] ;
b32 IsParamPack ;
} ;
static_assert ( sizeof ( AST_Type ) = = sizeof ( AST ) , " ERROR: AST_Type is not the same size as AST " ) ;
# endif
2024-12-14 05:46:22 -08:00
struct AST_Typename
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
char _PAD_INLINE_CMT_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
CodeAttributes Attributes ;
CodeSpecifiers Specs ;
2024-12-14 05:46:22 -08:00
CodeTypename ReturnType ; // Only used for function signatures
CodeParams Params ; // Only used for function signatures
2024-04-13 13:18:57 -07:00
Code ArrExpr ;
2024-12-14 05:46:22 -08:00
CodeSpecifiers SpecsFuncSuffix ; // Only used for function signatures
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
char _PAD_UNUSED_ [ sizeof ( ModuleFlag ) ] ;
struct {
b16 IsParamPack ; // Used by typename to know if type should be considered a parameter pack.
ETypenameTag TypeTag ; // Used by typename to keep track of explicitly declared tags for the identifier (enum, struct, union)
} ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Typename ) = = sizeof ( AST ) , " ERROR: AST_Type is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Typedef
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
CodeComment InlineCmt ;
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 2 ] ;
Code UnderlyingType ;
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) * 3 ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
b32 IsFunction ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Typedef ) = = sizeof ( AST ) , " ERROR: AST_Typedef is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Union
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
char _PAD_INLINE_CMT_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
CodeAttributes Attributes ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 3 ] ;
2024-04-13 13:18:57 -07:00
CodeBody Body ;
2024-12-14 05:46:22 -08:00
char _PAD_PROPERTIES_2_ [ sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
char _PAD_UNUSED_ [ sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Union ) = = sizeof ( AST ) , " ERROR: AST_Union is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Using
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
2024-12-14 05:46:22 -08:00
CodeComment InlineCmt ;
CodeAttributes Attributes ;
char _PAD_SPECS_ [ sizeof ( AST * ) ] ;
CodeTypename UnderlyingType ;
char _PAD_PROPERTIES_ [ sizeof ( AST * ) * 3 ] ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
char _PAD_UNUSED_ [ sizeof ( u32 ) ] ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Using ) = = sizeof ( AST ) , " ERROR: AST_Using is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
struct AST_Var
{
2024-12-14 05:46:22 -08:00
union {
char _PAD_ [ sizeof ( Specifier ) * AST_ArrSpecs_Cap + sizeof ( AST * ) ] ;
2024-04-13 13:18:57 -07:00
struct
{
CodeComment InlineCmt ;
CodeAttributes Attributes ;
CodeSpecifiers Specs ;
2024-12-14 05:46:22 -08:00
CodeTypename ValueType ;
2024-04-13 13:18:57 -07:00
Code BitfieldSize ;
Code Value ;
2024-12-14 05:46:22 -08:00
CodeVar NextVar ;
2024-04-13 13:18:57 -07:00
} ;
} ;
2024-12-14 05:46:22 -08:00
StrCached Name ;
Code Prev ;
Code Next ;
Token * Tok ;
Code Parent ;
CodeType Type ;
ModuleFlag ModuleFlags ;
s32 VarParenthesizedInit ;
2024-04-13 13:18:57 -07:00
} ;
2024-12-14 05:46:22 -08:00
static_assert ( sizeof ( AST_Var ) = = sizeof ( AST ) , " ERROR: AST_Var is not the same size as AST " ) ;
2024-04-13 13:18:57 -07:00
# pragma endregion AST Types
# pragma endregion AST
# pragma region Gen Interface
2024-12-14 05:46:22 -08:00
/*
/ \ | \ | \ / \
| ▓ ▓ ▓ ▓ ▓ ▓ \ ______ _______ \ ▓ ▓ ▓ ▓ ▓ ▓ _______ _ | ▓ ▓ _ ______ ______ | ▓ ▓ ▓ ▓ ▓ ▓ \ ______ _______ ______
| ▓ ▓ __ \ ▓ ▓ / \ | \ | ▓ ▓ | \ | ▓ ▓ \ / \ / \ | ▓ ▓ _ \ ▓ ▓ | \ / \ / \
| ▓ ▓ | \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ | ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ \ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \
| ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ | ▓ ▓ __ | ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ / ▓ ▓ ▓ ▓ | ▓ ▓ ▓ ▓
| ▓ ▓ __ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ _ | ▓ ▓ _ | ▓ ▓ | ▓ ▓ | ▓ ▓ | \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ | ▓ ▓ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ _____ | ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓
\ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ | ▓ ▓ | ▓ ▓ \ ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ | ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ \ \ ▓ ▓ \
\ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ \ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓ \ ▓ ▓ ▓ ▓ ▓ ▓ ▓
*/
#if 0
enum LogLevel : u32
{
Info ,
Warning ,
Panic ,
} ;
struct LogEntry
{
Str msg ;
u32 line_num ;
void * data ;
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
typedef void LoggerCallback ( LogEntry entry ) ;
# endif
// Note(Ed): This is subject to heavily change
// with upcoming changes to the library's fallback (default) allocations strategy;
// and major changes to lexer/parser context usage.
struct Context
{
// User Configuration
// Persistent Data Allocation
AllocatorInfo Allocator_DyanmicContainers ; // By default will use a genral slab allocator (TODO(Ed): Currently does not)
AllocatorInfo Allocator_Pool ; // By default will use the growing vmem reserve (TODO(Ed): Currently does not)
AllocatorInfo Allocator_StrCache ; // By default will use a dedicated slab allocator (TODO(Ed): Currently does not)
// Temporary Allocation
AllocatorInfo Allocator_Temp ;
// LoggerCallaback* log_callback; // TODO(Ed): Impl user logger callback as an option.
u32 Max_CommentLineLength ; // Used by def_comment
u32 Max_StrCacheLength ; // Any cached string longer than this is always allocated again.
u32 InitSize_BuilderBuffer ;
u32 InitSize_CodePoolsArray ;
u32 InitSize_StringArenasArray ;
u32 CodePool_NumBlocks ;
// TODO(Ed): Review these... (No longer needed if using the proper allocation strategy)
2024-12-15 07:46:36 -08:00
u32 InitSize_LexerTokens ;
2024-12-14 05:46:22 -08:00
u32 SizePer_StringArena ;
// TODO(Ed): Symbol Table
// Keep track of all resolved symbols (naemspaced identifiers)
// Parser
// Used by the lexer to persistently treat all these identifiers as preprocessor defines.
// Populate with strings via gen::cache_str.
// Functional defines must have format: id( ;at minimum to indicate that the define is only valid with arguments.
2024-12-15 07:46:36 -08:00
MacroTable Macros ;
2024-12-14 05:46:22 -08:00
// Backend
// The fallback allocator is utilized if any fo the three above allocators is not specified by the user.
u32 InitSize_Fallback_Allocator_Bucket_Size ;
Array ( Arena ) Fallback_AllocatorBuckets ;
// Array(Token) LexerTokens;
Array ( Pool ) CodePools ;
Array ( Arena ) StringArenas ;
StringTable StrCache ;
// TODO(Ed): This needs to be just handled by a parser context
Array ( Token ) Lexer_Tokens ;
// TODO(Ed): Active parse context vs a parse result need to be separated conceptually
ParseContext parser ;
} ;
// Initialize the library. There first ctx initialized must exist for lifetime of other contextes that come after as its the one that
GEN_API void init ( Context * ctx ) ;
2024-04-13 13:18:57 -07:00
// Currently manually free's the arenas, code for checking for leaks.
// However on Windows at least, it doesn't need to occur as the OS will clean up after the process.
2024-12-14 05:46:22 -08:00
GEN_API void deinit ( Context * ctx ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
// Clears the allocations, but doesn't free the memoery, then calls init() again.
2024-04-13 13:18:57 -07:00
// Ease of use.
2024-12-14 05:46:22 -08:00
GEN_API void reset ( Context * ctx ) ;
GEN_API void set_context ( Context * ctx ) ;
2024-12-15 07:46:36 -08:00
// Mostly intended for the parser
GEN_API Macro * lookup_macro ( Str Name ) ;
2024-12-14 05:46:22 -08:00
// Alternative way to add a preprocess define entry for the lexer & parser to utilize
// if the user doesn't want to use def_define
2024-12-15 07:46:36 -08:00
// Macros are tracked by name so if the name already exists the entry will be overwritten.
GEN_API void register_macro ( Macro macro ) ;
// Ease of use batch registration
GEN_API void register_macros ( s32 num , . . . ) ;
GEN_API void register_macros ( s32 num , Macro * macros ) ;
2024-04-13 13:18:57 -07:00
// Used internally to retrive or make string allocations.
// Strings are stored in a series of string arenas of fixed size (SizePer_StringArena)
2024-12-14 05:46:22 -08:00
GEN_API StrCached cache_str ( Str str ) ;
2024-04-13 13:18:57 -07:00
/*
2024-12-14 05:46:22 -08:00
This provides a fresh Code AST .
The gen interface use this as their method from getting a new AST object from the CodePool .
Use this if you want to make your own API for formatting the supported Code Types .
2024-04-13 13:18:57 -07:00
*/
2024-12-14 05:46:22 -08:00
GEN_API Code make_code ( ) ;
2024-04-13 13:18:57 -07:00
// Set these before calling gen's init() procedure.
# pragma region Upfront
2024-12-14 05:46:22 -08:00
GEN_API CodeAttributes def_attributes ( Str content ) ;
GEN_API CodeComment def_comment ( Str content ) ;
struct Opts_def_struct {
CodeBody body ;
CodeTypename parent ;
AccessSpec parent_access ;
CodeAttributes attributes ;
CodeTypename * interfaces ;
s32 num_interfaces ;
ModuleFlag mflags ;
} ;
GEN_API CodeClass def_class ( Str name , Opts_def_struct opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_constructor {
CodeParams params ;
Code initializer_list ;
Code body ;
} ;
GEN_API CodeConstructor def_constructor ( Opts_def_constructor opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_define {
2024-12-15 07:46:36 -08:00
CodeDefineParams params ;
Str content ;
MacroFlags flags ;
b32 dont_register_to_preprocess_macros ;
2024-12-14 05:46:22 -08:00
} ;
2024-12-15 07:46:36 -08:00
GEN_API CodeDefine def_define ( Str name , MacroType type , Opts_def_define opts GEN_PARAM_DEFAULT ) ;
2024-12-14 05:46:22 -08:00
struct Opts_def_destructor {
Code body ;
CodeSpecifiers specifiers ;
} ;
GEN_API CodeDestructor def_destructor ( Opts_def_destructor opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_enum {
CodeBody body ;
CodeTypename type ;
EnumT specifier ;
CodeAttributes attributes ;
ModuleFlag mflags ;
Code type_macro ;
} ;
GEN_API CodeEnum def_enum ( Str name , Opts_def_enum opts GEN_PARAM_DEFAULT ) ;
GEN_API CodeExec def_execution ( Str content ) ;
GEN_API CodeExtern def_extern_link ( Str name , CodeBody body ) ;
GEN_API CodeFriend def_friend ( Code symbol ) ;
struct Opts_def_function {
CodeParams params ;
CodeTypename ret_type ;
CodeBody body ;
CodeSpecifiers specs ;
CodeAttributes attrs ;
ModuleFlag mflags ;
} ;
GEN_API CodeFn def_function ( Str name , Opts_def_function opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_include { b32 foreign ; } ;
struct Opts_def_module { ModuleFlag mflags ; } ;
struct Opts_def_namespace { ModuleFlag mflags ; } ;
GEN_API CodeInclude def_include ( Str content , Opts_def_include opts GEN_PARAM_DEFAULT ) ;
GEN_API CodeModule def_module ( Str name , Opts_def_module opts GEN_PARAM_DEFAULT ) ;
GEN_API CodeNS def_namespace ( Str name , CodeBody body , Opts_def_namespace opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_operator {
CodeParams params ;
CodeTypename ret_type ;
CodeBody body ;
CodeSpecifiers specifiers ;
CodeAttributes attributes ;
ModuleFlag mflags ;
} ;
GEN_API CodeOperator def_operator ( Operator op , Str nspace , Opts_def_operator opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_operator_cast {
CodeBody body ;
CodeSpecifiers specs ;
} ;
GEN_API CodeOpCast def_operator_cast ( CodeTypename type , Opts_def_operator_cast opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_param { Code value ; } ;
GEN_API CodeParams def_param ( CodeTypename type , Str name , Opts_def_param opts GEN_PARAM_DEFAULT ) ;
GEN_API CodePragma def_pragma ( Str directive ) ;
GEN_API CodePreprocessCond def_preprocess_cond ( EPreprocessCond type , Str content ) ;
GEN_API CodeSpecifiers def_specifier ( Specifier specifier ) ;
GEN_API CodeStruct def_struct ( Str name , Opts_def_struct opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_template { ModuleFlag mflags ; } ;
GEN_API CodeTemplate def_template ( CodeParams params , Code definition , Opts_def_template opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_type {
ETypenameTag type_tag ;
Code arrayexpr ;
CodeSpecifiers specifiers ;
CodeAttributes attributes ;
} ;
GEN_API CodeTypename def_type ( Str name , Opts_def_type opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_typedef {
CodeAttributes attributes ;
ModuleFlag mflags ;
} ;
GEN_API CodeTypedef def_typedef ( Str name , Code type , Opts_def_typedef opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_union {
CodeAttributes attributes ;
ModuleFlag mflags ;
} ;
GEN_API CodeUnion def_union ( Str name , CodeBody body , Opts_def_union opts GEN_PARAM_DEFAULT ) ;
struct Opts_def_using {
CodeAttributes attributes ;
ModuleFlag mflags ;
} ;
GEN_API CodeUsing def_using ( Str name , CodeTypename type , Opts_def_using opts GEN_PARAM_DEFAULT ) ;
GEN_API CodeUsing def_using_namespace ( Str name ) ;
struct Opts_def_variable
{
Code value ;
CodeSpecifiers specifiers ;
CodeAttributes attributes ;
ModuleFlag mflags ;
} ;
GEN_API CodeVar def_variable ( CodeTypename type , Str name , Opts_def_variable opts GEN_PARAM_DEFAULT ) ;
2024-04-13 13:18:57 -07:00
// Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries.
2024-12-14 05:46:22 -08:00
GEN_API CodeBody def_body ( CodeType type ) ;
2024-04-13 13:18:57 -07:00
// There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num,
/// or provide as an array of Code objects.
2024-12-15 07:46:36 -08:00
GEN_API CodeBody def_class_body ( s32 num , . . . ) ;
GEN_API CodeBody def_class_body ( s32 num , Code * codes ) ;
GEN_API CodeDefineParams def_define_params ( s32 num , . . . ) ;
GEN_API CodeDefineParams def_define_params ( s32 num , CodeDefineParams * codes ) ;
GEN_API CodeBody def_enum_body ( s32 num , . . . ) ;
GEN_API CodeBody def_enum_body ( s32 num , Code * codes ) ;
GEN_API CodeBody def_export_body ( s32 num , . . . ) ;
GEN_API CodeBody def_export_body ( s32 num , Code * codes ) ;
GEN_API CodeBody def_extern_link_body ( s32 num , . . . ) ;
GEN_API CodeBody def_extern_link_body ( s32 num , Code * codes ) ;
GEN_API CodeBody def_function_body ( s32 num , . . . ) ;
GEN_API CodeBody def_function_body ( s32 num , Code * codes ) ;
GEN_API CodeBody def_global_body ( s32 num , . . . ) ;
GEN_API CodeBody def_global_body ( s32 num , Code * codes ) ;
GEN_API CodeBody def_namespace_body ( s32 num , . . . ) ;
GEN_API CodeBody def_namespace_body ( s32 num , Code * codes ) ;
GEN_API CodeParams def_params ( s32 num , . . . ) ;
GEN_API CodeParams def_params ( s32 num , CodeParams * params ) ;
GEN_API CodeSpecifiers def_specifiers ( s32 num , . . . ) ;
GEN_API CodeSpecifiers def_specifiers ( s32 num , Specifier * specs ) ;
GEN_API CodeBody def_struct_body ( s32 num , . . . ) ;
GEN_API CodeBody def_struct_body ( s32 num , Code * codes ) ;
GEN_API CodeBody def_union_body ( s32 num , . . . ) ;
GEN_API CodeBody def_union_body ( s32 num , Code * codes ) ;
2024-04-13 13:18:57 -07:00
# pragma endregion Upfront
# pragma region Parsing
// TODO(Ed) : Implmeent the new parser API design.
#if 0
2024-12-14 05:46:22 -08:00
struct StackNode
{
StackNode * Prev ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
Token Start ;
Token Name ; // The name of the AST node (if parsed)
Str FailedProc ; // The name of the procedure that failed
} ;
// Stack nodes are allocated the error's allocator
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
struct Error
{
StrBuilder message ;
StackNode * context_stack ;
} ;
2024-04-13 13:18:57 -07:00
struct ParseInfo
2024-12-14 05:46:22 -08:00
{
2024-04-13 13:18:57 -07:00
Arena FileMem ;
Arena TokMem ;
Arena CodeMem ;
2024-12-14 05:46:22 -08:00
FileContents FileContent ;
Array < Token > Tokens ;
Array < Error > Errors ;
2024-04-13 13:18:57 -07:00
// Errors are allocated to a dedicated general arena.
2024-12-14 05:46:22 -08:00
} ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
CodeBody parse_file ( Str path ) ;
2024-04-13 13:18:57 -07:00
# endif
2024-12-14 05:46:22 -08:00
GEN_API CodeClass parse_class ( Str class_def ) ;
GEN_API CodeConstructor parse_constructor ( Str constructor_def ) ;
2024-12-15 07:46:36 -08:00
GEN_API CodeDefine parse_define ( Str define_def ) ;
2024-12-14 05:46:22 -08:00
GEN_API CodeDestructor parse_destructor ( Str destructor_def ) ;
GEN_API CodeEnum parse_enum ( Str enum_def ) ;
GEN_API CodeBody parse_export_body ( Str export_def ) ;
GEN_API CodeExtern parse_extern_link ( Str exten_link_def ) ;
GEN_API CodeFriend parse_friend ( Str friend_def ) ;
GEN_API CodeFn parse_function ( Str fn_def ) ;
GEN_API CodeBody parse_global_body ( Str body_def ) ;
GEN_API CodeNS parse_namespace ( Str namespace_def ) ;
GEN_API CodeOperator parse_operator ( Str operator_def ) ;
GEN_API CodeOpCast parse_operator_cast ( Str operator_def ) ;
GEN_API CodeStruct parse_struct ( Str struct_def ) ;
GEN_API CodeTemplate parse_template ( Str template_def ) ;
GEN_API CodeTypename parse_type ( Str type_def ) ;
GEN_API CodeTypedef parse_typedef ( Str typedef_def ) ;
GEN_API CodeUnion parse_union ( Str union_def ) ;
GEN_API CodeUsing parse_using ( Str using_def ) ;
GEN_API CodeVar parse_variable ( Str var_def ) ;
2024-04-13 13:18:57 -07:00
# pragma endregion Parsing
# pragma region Untyped text
2024-12-14 05:46:22 -08:00
GEN_API ssize token_fmt_va ( char * buf , usize buf_size , s32 num_tokens , va_list va ) ;
2024-04-13 13:18:57 -07:00
//! Do not use directly. Use the token_fmt macro instead.
2024-12-14 05:46:22 -08:00
GEN_API Str token_fmt_impl ( ssize , . . . ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
GEN_API Code untyped_str ( Str content ) ;
GEN_API Code untyped_fmt ( char const * fmt , . . . ) ;
GEN_API Code untyped_token_fmt ( s32 num_tokens , char const * fmt , . . . ) ;
2024-04-13 13:18:57 -07:00
# pragma endregion Untyped text
2024-12-14 05:46:22 -08:00
# pragma region Macros
# ifndef gen_main
# define gen_main main
# endif
# ifndef name
// Convienence for defining any name used with the gen api.
// Lets you provide the length and string literal to the functions without the need for the DSL.
# define name( Id_ ) { stringize(Id_), sizeof(stringize( Id_ )) - 1 }
# endif
# ifndef code
// Same as name just used to indicate intention of literal for code instead of names.
# define code( ... ) { stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 }
# endif
# ifndef args
// Provides the number of arguments while passing args inplace.
# define args( ... ) num_args( __VA_ARGS__ ), __VA_ARGS__
# endif
# ifndef code_str
// Just wrappers over common untyped code definition constructions.
# define code_str( ... ) GEN_NS untyped_str( code( __VA_ARGS__ ) )
# endif
# ifndef code_fmt
# define code_fmt( ... ) GEN_NS untyped_str( token_fmt( __VA_ARGS__ ) )
# endif
# ifndef parse_fmt
# define parse_fmt( type, ... ) GEN_NS parse_##type( token_fmt( __VA_ARGS__ ) )
# endif
# ifndef token_fmt
/*
Takes a format string ( char const * ) and a list of tokens ( Str ) and returns a Str of the formatted string .
Tokens are provided in ' < ' identifier ' > ' format where ' < ' ' > ' are just angle brackets ( you can change it in token_fmt_va )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Example - A string with :
typedef < type > < name > < name > ;
Will have a token_fmt arguments populated with :
" type " , str_for_type ,
" name " , str_for_name ,
and :
stringize ( typedef < type > < name > < name > ; )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
So the full call for this example would be :
token_fmt (
" type " , str_for_type
, " name " , str_for_name
, stringize (
typedef < type > < name > < name >
) ) ;
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! Note : token_fmt_va is whitespace sensitive for the tokens .
! This can be alleviated by skipping whitespace between brackets but it was choosen to not have that implementation by default .
*/
# define token_fmt( ... ) GEN_NS token_fmt_impl( (num_args( __VA_ARGS__ ) + 1) / 2, __VA_ARGS__ )
# endif
# pragma endregion Macros
2024-04-13 13:18:57 -07:00
# pragma endregion Gen Interface
# pragma region Inlines
2024-12-14 05:46:22 -08:00
# pragma region Code
inline
void code_append ( Code self , Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( self ) ;
GEN_ASSERT ( other ) ;
GEN_ASSERT_MSG ( self ! = other , " Attempted to recursively append Code AST to itself. " ) ;
if ( other - > Parent ! = nullptr )
other = code_duplicate ( other ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
other - > Parent = self ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
if ( self - > Front = = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
self - > Front = other ;
self - > Back = other ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
self - > NumEntries + + ;
2024-04-13 13:18:57 -07:00
return ;
}
2024-12-14 05:46:22 -08:00
Code
Current = self - > Back ;
2024-04-13 13:18:57 -07:00
Current - > Next = other ;
other - > Prev = Current ;
2024-12-14 05:46:22 -08:00
self - > Back = other ;
self - > NumEntries + + ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline
bool code_is_body ( Code self )
{
GEN_ASSERT ( self ) ;
switch ( self - > Type )
{
case CT_Enum_Body :
case CT_Class_Body :
case CT_Union_Body :
case CT_Export_Body :
case CT_Global_Body :
case CT_Struct_Body :
case CT_Function_Body :
case CT_Namespace_Body :
case CT_Extern_Linkage_Body :
return true ;
}
return false ;
}
inline
Code * code_entry ( Code self , u32 idx )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( self ! = nullptr ) ;
Code * current = & self - > Front ;
2024-04-13 13:18:57 -07:00
while ( idx > = 0 & & current ! = nullptr )
{
if ( idx = = 0 )
2024-12-14 05:46:22 -08:00
return rcast ( Code * , current ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
current = & ( * current ) - > Next ;
2024-04-13 13:18:57 -07:00
idx - - ;
}
2024-12-14 05:46:22 -08:00
return rcast ( Code * , current ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE
bool code_is_valid ( Code self )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( self ) ;
return self ! = nullptr & & self - > Type ! = CT_Invalid ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE
bool code_has_entries ( AST * self )
{
GEN_ASSERT ( self ) ;
return self - > NumEntries > 0 ;
}
FORCEINLINE
void code_set_global ( Code self )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( self = = nullptr )
{
log_failure ( " Code::set_global: Cannot set code as global, AST is null! " ) ;
return ;
}
self - > Parent = Code_Global ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
# if GEN_COMPILER_CPP
FORCEINLINE
Code & Code : : operator + + ( )
{
if ( ast )
ast = ast - > Next . ast ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
return * this ;
}
# endif
FORCEINLINE
Str code_type_str ( Code self )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( self ! = nullptr ) ;
return codetype_to_str ( self - > Type ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
# pragma endregion Code
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# pragma region CodeBody
inline
void body_append ( CodeBody self , Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( self ) ;
GEN_ASSERT ( other ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
if ( code_is_body ( other ) ) {
body_append_body ( self , cast ( CodeBody , other ) ) ;
return ;
}
code_append ( cast ( Code , self ) , other ) ;
}
inline
void body_append_body ( CodeBody self , CodeBody body )
{
GEN_ASSERT ( self ) ;
GEN_ASSERT ( body ) ;
GEN_ASSERT_MSG ( self ! = body , " Attempted to append body to itself. " ) ;
for ( Code entry = begin_CodeBody ( body ) ; entry ! = end_CodeBody ( body ) ; entry = next_CodeBody ( body , entry ) ) {
body_append ( self , entry ) ;
}
}
inline
Code begin_CodeBody ( CodeBody body ) {
GEN_ASSERT ( body ) ;
if ( body ! = nullptr )
return body - > Front ;
return NullCode ;
}
FORCEINLINE
Code end_CodeBody ( CodeBody body ) {
GEN_ASSERT ( body ) ;
return body - > Back - > Next ;
}
inline
Code next_CodeBody ( CodeBody body , Code entry ) {
GEN_ASSERT ( body ) ;
GEN_ASSERT ( entry ) ;
return entry - > Next ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
# pragma endregion CodeBody
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# pragma region CodeClass
inline
void class_add_interface ( CodeClass self , CodeTypename type )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( self ) ;
GEN_ASSERT ( type ) ;
CodeTypename possible_slot = self - > ParentType ;
if ( possible_slot ! = nullptr )
2024-04-13 13:18:57 -07:00
{
// Were adding an interface to parent type, so we need to make sure the parent type is public.
2024-12-14 05:46:22 -08:00
self - > ParentAccess = AccessSpec_Public ;
2024-04-13 13:18:57 -07:00
// If your planning on adding a proper parent,
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
}
2024-12-14 05:46:22 -08:00
while ( possible_slot ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
possible_slot = cast ( CodeTypename , possible_slot - > Next ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
possible_slot = type ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
# pragma endregion CodeClass
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# pragma region CodeParams
inline
void params_append ( CodeParams appendee , CodeParams other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( appendee ) ;
GEN_ASSERT ( other ) ;
GEN_ASSERT_MSG ( appendee ! = other , " Attempted to append parameter to itself. " ) ;
Code self = cast ( Code , appendee ) ;
Code entry = cast ( Code , other ) ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
if ( entry - > Parent ! = nullptr )
entry = code_duplicate ( entry ) ;
2024-04-13 13:18:57 -07:00
entry - > Parent = self ;
if ( self - > Last = = nullptr )
{
self - > Last = entry ;
self - > Next = entry ;
self - > NumEntries + + ;
return ;
}
self - > Last - > Next = entry ;
self - > Last = entry ;
self - > NumEntries + + ;
}
2024-12-14 05:46:22 -08:00
inline
CodeParams params_get ( CodeParams self , s32 idx )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( self ) ;
CodeParams param = self ;
2024-04-13 13:18:57 -07:00
do
{
2024-12-14 05:46:22 -08:00
if ( + + param ! = nullptr )
return NullCode ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
param = cast ( CodeParams , cast ( Code , param ) - > Next ) ;
}
while ( - - idx ) ;
2024-04-13 13:18:57 -07:00
2024-10-25 02:04:11 -07:00
return param ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE
bool params_has_entries ( CodeParams self )
{
GEN_ASSERT ( self ) ;
return self - > NumEntries > 0 ;
}
# if GEN_COMPILER_CPP
FORCEINLINE
CodeParams & CodeParams : : operator + + ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
* this = ast - > Next ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
# endif
FORCEINLINE
CodeParams begin_CodeParams ( CodeParams params )
{
if ( params ! = nullptr )
return params ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
return NullCode ;
}
FORCEINLINE
CodeParams end_CodeParams ( CodeParams params )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
// return { (AST_Params*) rcast( AST*, ast)->Last };
return NullCode ;
}
FORCEINLINE
CodeParams next_CodeParams ( CodeParams params , CodeParams param_iter )
{
GEN_ASSERT ( param_iter ) ;
return param_iter - > Next ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
# pragma endregion CodeParams
2024-04-13 13:18:57 -07:00
2024-12-15 07:46:36 -08:00
# pragma region CodeDefineParams
FORCEINLINE void define_params_append ( CodeDefineParams appendee , CodeDefineParams other ) { params_append ( cast ( CodeParams , appendee ) , cast ( CodeParams , other ) ) ; }
FORCEINLINE CodeDefineParams define_params_get ( CodeDefineParams self , s32 idx ) { return ( CodeDefineParams ) ( Code ) params_get ( cast ( CodeParams , self ) , idx ) ; }
FORCEINLINE bool define_params_has_entries ( CodeDefineParams self ) { return params_has_entries ( cast ( CodeParams , self ) ) ; }
CodeDefineParams begin_CodeDefineParams ( CodeDefineParams params ) { return ( CodeDefineParams ) ( Code ) begin_CodeParams ( cast ( CodeParams , ( Code ) params ) ) ; }
CodeDefineParams end_CodeDefineParams ( CodeDefineParams params ) { return ( CodeDefineParams ) ( Code ) end_CodeParams ( cast ( CodeParams , ( Code ) params ) ) ; }
CodeDefineParams next_CodeDefineParams ( CodeDefineParams params , CodeDefineParams entry_iter ) { return ( CodeDefineParams ) ( Code ) next_CodeParams ( cast ( CodeParams , ( Code ) params ) , cast ( CodeParams , ( Code ) entry_iter ) ) ; }
# if GEN_COMPILER_CPP
FORCEINLINE
CodeDefineParams & CodeDefineParams : : operator + + ( )
{
* this = ast - > Next ;
return * this ;
}
# endif
# pragma endregion CodeDefineParams
2024-12-14 05:46:22 -08:00
# pragma region CodeSpecifiers
inline
bool specifiers_append ( CodeSpecifiers self , Specifier spec )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( self = = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
log_failure ( " CodeSpecifiers: Attempted to append to a null specifiers AST! " ) ;
return false ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
if ( self - > NumEntries = = AST_ArrSpecs_Cap )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
log_failure ( " CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST! " , AST_ArrSpecs_Cap ) ;
return false ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
self - > ArrSpecs [ self - > NumEntries ] = spec ;
self - > NumEntries + + ;
return true ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline
s32 specifiers_has ( CodeSpecifiers self , Specifier spec )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
GEN_ASSERT ( self ! = nullptr ) ;
for ( s32 idx = 0 ; idx < self - > NumEntries ; idx + + ) {
if ( self - > ArrSpecs [ idx ] = = spec )
return idx ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return - 1 ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline
s32 specifiers_remove ( CodeSpecifiers self , Specifier to_remove )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( self = = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
log_failure ( " CodeSpecifiers: Attempted to append to a null specifiers AST! " ) ;
return - 1 ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
if ( self - > NumEntries = = AST_ArrSpecs_Cap )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
log_failure ( " CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST! " , AST_ArrSpecs_Cap ) ;
return - 1 ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
s32 result = - 1 ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
s32 curr = 0 ;
s32 next = 0 ;
for ( ; next < self - > NumEntries ; + + curr , + + next )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
Specifier spec = self - > ArrSpecs [ next ] ;
if ( spec = = to_remove )
{
result = next ;
next + + ;
if ( next > = self - > NumEntries )
break ;
spec = self - > ArrSpecs [ next ] ;
}
self - > ArrSpecs [ curr ] = spec ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
if ( result > - 1 ) {
self - > NumEntries - - ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return result ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE
Specifier * begin_CodeSpecifiers ( CodeSpecifiers self )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( self ! = nullptr )
return & self - > ArrSpecs [ 0 ] ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE
Specifier * end_CodeSpecifiers ( CodeSpecifiers self )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return self - > ArrSpecs + self - > NumEntries ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE
Specifier * next_CodeSpecifiers ( CodeSpecifiers self , Specifier * spec_iter )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return spec_iter + 1 ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
# pragma endregion CodeSpecifiers
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# pragma region CodeStruct
inline
void struct_add_interface ( CodeStruct self , CodeTypename type )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
CodeTypename possible_slot = self - > ParentType ;
if ( possible_slot ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
// Were adding an interface to parent type, so we need to make sure the parent type is public.
self - > ParentAccess = AccessSpec_Public ;
// If your planning on adding a proper parent,
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
while ( possible_slot ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
possible_slot = cast ( CodeTypename , possible_slot - > Next ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
possible_slot = type ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
# pragma endregion Code
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
# pragma region Interface
inline
CodeBody def_body ( CodeType type )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
switch ( type )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
case CT_Class_Body :
case CT_Enum_Body :
case CT_Export_Body :
case CT_Extern_Linkage :
case CT_Function_Body :
case CT_Global_Body :
case CT_Namespace_Body :
case CT_Struct_Body :
case CT_Union_Body :
break ;
default :
log_failure ( " def_body: Invalid type %s " , codetype_to_str ( type ) . Ptr ) ;
return ( CodeBody ) Code_Invalid ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
Code
result = make_code ( ) ;
result - > Type = type ;
return ( CodeBody ) result ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline
Str token_fmt_impl ( ssize num , . . . )
{
local_persist thread_local
char buf [ GEN_PRINTF_MAXLEN ] = { 0 } ;
mem_set ( buf , 0 , GEN_PRINTF_MAXLEN ) ;
va_list va ;
va_start ( va , num ) ;
ssize result = token_fmt_va ( buf , GEN_PRINTF_MAXLEN , num , va ) ;
va_end ( va ) ;
Str str = { buf , result } ;
return str ;
}
# pragma endregion Interface
# pragma region generated code inline implementation
inline Code & Code : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline Code : : operator bool ( )
{
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeBody & CodeBody : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeBody : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeAttributes & CodeAttributes : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
{
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeAttributes : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeAttributes : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-12-14 05:46:22 -08:00
inline AST_Attributes * CodeAttributes : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
2024-12-14 05:46:22 -08:00
inline CodeComment & CodeComment : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeComment : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeComment : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Comment * CodeComment : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeConstructor & CodeConstructor : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeConstructor : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeConstructor : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Constructor * CodeConstructor : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeClass & CodeClass : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeClass : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeDefine & CodeDefine : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeDefine : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeDefine : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-12-14 05:46:22 -08:00
inline AST_Define * CodeDefine : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
2024-12-15 07:46:36 -08:00
inline CodeDefineParams & CodeDefineParams : : operator = ( Code other )
{
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
{
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
inline CodeDefineParams : : operator bool ( )
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeDestructor & CodeDestructor : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeDestructor : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeDestructor : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Destructor * CodeDestructor : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeEnum & CodeEnum : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeEnum : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeEnum : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-12-14 05:46:22 -08:00
inline AST_Enum * CodeEnum : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
2024-12-14 05:46:22 -08:00
inline CodeExec & CodeExec : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeExec : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeExec : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Exec * CodeExec : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeExtern & CodeExtern : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeExtern : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeExtern : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Extern * CodeExtern : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeFriend & CodeFriend : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
inline CodeFriend : : operator bool ( )
{
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeFriend : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Friend * CodeFriend : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeFn & CodeFn : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeFn : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeFn : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Fn * CodeFn : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeInclude & CodeInclude : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
inline CodeInclude : : operator bool ( )
{
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeInclude : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Include * CodeInclude : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeModule & CodeModule : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeModule : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeModule : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-12-14 05:46:22 -08:00
inline AST_Module * CodeModule : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
2024-12-14 05:46:22 -08:00
inline CodeNS & CodeNS : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeNS : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeNS : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_NS * CodeNS : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeOperator & CodeOperator : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeOperator : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeOperator : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-12-14 05:46:22 -08:00
inline AST_Operator * CodeOperator : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
2024-12-14 05:46:22 -08:00
inline CodeOpCast & CodeOpCast : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeOpCast : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeOpCast : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_OpCast * CodeOpCast : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeParams & CodeParams : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeParams : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodePragma & CodePragma : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
{
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodePragma : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodePragma : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-12-14 05:46:22 -08:00
inline AST_Pragma * CodePragma : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
2024-12-14 05:46:22 -08:00
inline CodePreprocessCond & CodePreprocessCond : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodePreprocessCond : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodePreprocessCond : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_PreprocessCond * CodePreprocessCond : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeSpecifiers & CodeSpecifiers : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeSpecifiers : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeStruct & CodeStruct : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
{
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeStruct : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-12-14 05:46:22 -08:00
inline CodeTemplate & CodeTemplate : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
{
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeTemplate : : operator bool ( )
{
return ast ! = nullptr ;
}
inline CodeTemplate : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-12-14 05:46:22 -08:00
inline AST_Template * CodeTemplate : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
2024-12-14 05:46:22 -08:00
inline CodeTypename & CodeTypename : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeTypename : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeTypename : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Typename * CodeTypename : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeTypedef & CodeTypedef : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-12-14 05:46:22 -08:00
inline CodeTypedef : : operator bool ( )
{
return ast ! = nullptr ;
}
inline CodeTypedef : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Typedef * CodeTypedef : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( ast = = nullptr )
{
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
}
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeUnion & CodeUnion : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
{
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeUnion : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeUnion : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-12-14 05:46:22 -08:00
inline AST_Union * CodeUnion : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
2024-12-14 05:46:22 -08:00
inline CodeUsing & CodeUsing : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeUsing : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return ast ! = nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline CodeUsing : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return * rcast ( Code * , this ) ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
inline AST_Using * CodeUsing : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
return nullptr ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
return ast ;
2024-04-13 13:18:57 -07:00
}
2024-10-25 02:04:11 -07:00
inline CodeVar & CodeVar : : operator = ( Code other )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
if ( other . ast ! = nullptr & & other - > Parent ! = nullptr )
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
ast = rcast ( decltype ( ast ) , code_duplicate ( other ) . ast ) ;
ast - > Parent = { nullptr } ;
2024-04-13 13:18:57 -07:00
}
ast = rcast ( decltype ( ast ) , other . ast ) ;
return * this ;
}
2024-10-25 02:04:11 -07:00
inline CodeVar : : operator bool ( )
2024-04-13 13:18:57 -07:00
{
return ast ! = nullptr ;
}
2024-10-25 02:04:11 -07:00
inline CodeVar : : operator Code ( )
2024-04-13 13:18:57 -07:00
{
return * rcast ( Code * , this ) ;
}
2024-10-25 02:04:11 -07:00
inline AST_Var * CodeVar : : operator - > ( )
2024-04-13 13:18:57 -07:00
{
if ( ast = = nullptr )
{
2024-12-14 05:46:22 -08:00
log_failure ( " Attempt to dereference a nullptr! \n " ) ;
2024-04-13 13:18:57 -07:00
return nullptr ;
}
return ast ;
}
# pragma endregion generated code inline implementation
# pragma region generated AST / Code cast implementation
2024-12-14 05:46:22 -08:00
GEN_OPTIMIZE_MAPPINGS_BEGIN
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeBody ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Body * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeAttributes ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Attributes * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeComment ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Comment * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeConstructor ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Constructor * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeClass ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Class * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeDefine ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Define * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-15 07:46:36 -08:00
FORCEINLINE Code : : operator CodeDefineParams ( ) const
{
return { ( AST_DefineParams * ) ast } ;
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeDestructor ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Destructor * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeEnum ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Enum * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeExec ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Exec * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeExtern ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Extern * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeFriend ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Friend * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeFn ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Fn * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeInclude ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Include * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeModule ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Module * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeNS ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_NS * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeOperator ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Operator * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeOpCast ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_OpCast * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeParams ( ) const
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return { ( AST_Params * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodePragma ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Pragma * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodePreprocessCond ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_PreprocessCond * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeSpecifiers ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Specifiers * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeStruct ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Struct * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeTemplate ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Template * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeTypename ( ) const
2024-04-13 13:18:57 -07:00
{
2024-12-14 05:46:22 -08:00
return { ( AST_Typename * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeTypedef ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Typedef * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeUnion ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Union * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeUsing ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Using * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
FORCEINLINE Code : : operator CodeVar ( ) const
2024-04-13 13:18:57 -07:00
{
2024-04-21 06:51:51 -07:00
return { ( AST_Var * ) ast } ;
2024-04-13 13:18:57 -07:00
}
2024-12-14 05:46:22 -08:00
GEN_OPITMIZE_MAPPINGS_END
2024-04-13 13:18:57 -07:00
# pragma endregion generated AST / Code cast implementation
# pragma endregion Inlines
# pragma region Constants
2024-12-15 07:46:36 -08:00
extern Macro enum_underlying_macro ;
2024-04-13 13:18:57 -07:00
extern Code access_public ;
extern Code access_protected ;
extern Code access_private ;
extern CodeAttributes attrib_api_export ;
extern CodeAttributes attrib_api_import ;
extern Code module_global_fragment ;
extern Code module_private_fragment ;
extern Code fmt_newline ;
extern CodePragma pragma_once ;
2024-12-14 05:46:22 -08:00
extern CodeParams param_varadic ;
2024-04-13 13:18:57 -07:00
extern CodePreprocessCond preprocess_else ;
extern CodePreprocessCond preprocess_endif ;
extern CodeSpecifiers spec_const ;
extern CodeSpecifiers spec_consteval ;
extern CodeSpecifiers spec_constexpr ;
extern CodeSpecifiers spec_constinit ;
extern CodeSpecifiers spec_extern_linkage ;
extern CodeSpecifiers spec_final ;
2024-04-21 15:56:57 -07:00
extern CodeSpecifiers spec_FORCEINLINE ;
2024-04-13 13:18:57 -07:00
extern CodeSpecifiers spec_global ;
extern CodeSpecifiers spec_inline ;
extern CodeSpecifiers spec_internal_linkage ;
extern CodeSpecifiers spec_local_persist ;
extern CodeSpecifiers spec_mutable ;
extern CodeSpecifiers spec_neverinline ;
extern CodeSpecifiers spec_noexcept ;
extern CodeSpecifiers spec_override ;
extern CodeSpecifiers spec_ptr ;
extern CodeSpecifiers spec_pure ;
extern CodeSpecifiers spec_ref ;
extern CodeSpecifiers spec_register ;
extern CodeSpecifiers spec_rvalue ;
extern CodeSpecifiers spec_static_member ;
extern CodeSpecifiers spec_thread_local ;
extern CodeSpecifiers spec_virtual ;
extern CodeSpecifiers spec_volatile ;
2024-12-14 05:46:22 -08:00
extern CodeTypename t_empty ; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance)
extern CodeTypename t_auto ;
extern CodeTypename t_void ;
extern CodeTypename t_int ;
extern CodeTypename t_bool ;
extern CodeTypename t_char ;
extern CodeTypename t_wchar_t ;
extern CodeTypename t_class ;
extern CodeTypename t_typename ;
2024-04-13 13:18:57 -07:00
# ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
2024-12-14 05:46:22 -08:00
// Predefined typename codes. Are set to readonly and are setup during gen::init()
extern Context * _ctx ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
extern CodeTypename t_b32 ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
extern CodeTypename t_s8 ;
extern CodeTypename t_s16 ;
extern CodeTypename t_s32 ;
extern CodeTypename t_s64 ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
extern CodeTypename t_u8 ;
extern CodeTypename t_u16 ;
extern CodeTypename t_u32 ;
extern CodeTypename t_u64 ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
extern CodeTypename t_ssize ;
extern CodeTypename t_usize ;
2024-04-13 13:18:57 -07:00
2024-12-14 05:46:22 -08:00
extern CodeTypename t_f32 ;
extern CodeTypename t_f64 ;
2024-04-13 13:18:57 -07:00
# endif
# pragma endregion Constants
GEN_NS_END
2024-10-25 02:04:11 -07:00
# ifdef __clang__
2024-12-14 05:46:22 -08:00
# pragma clang diagnostic pop
2024-04-13 13:18:57 -07:00
# endif
2024-10-25 02:04:11 -07:00
# ifdef __GNUC__
2024-12-14 05:46:22 -08:00
# pragma GCC diagnostic pop
2024-04-13 13:18:57 -07:00
# endif