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-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __clang__
|
2024-10-27 18:44:34 -07: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"
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2024-10-27 18:44:34 -07: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-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
/*
|
2024-10-27 18:44:34 -07:00
|
|
|
gencpp: An attempt at "simple" staged metaprogramming for c/c++.
|
2024-10-25 02:04:11 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
See Readme.md for more information from the project repository.
|
2024-10-25 02:04:11 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
Public Address:
|
|
|
|
https://github.com/Ed94/gencpp
|
2024-10-25 02:04:11 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
This is a variant intended for use with Unreal Engine 5
|
2024-10-25 02:04:11 -07:00
|
|
|
*/
|
2024-10-27 18:44:34 -07:00
|
|
|
#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
|
|
|
|
# error Gen.hpp : GEN_TIME not defined
|
2024-10-25 02:04:11 -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-10-27 18:44:34 -07:00
|
|
|
# include "gen.dep.hpp"
|
2024-10-25 02:04:11 -07:00
|
|
|
#endif
|
|
|
|
|
2024-10-21 19:39:40 -07:00
|
|
|
#ifndef GEN_NS_BEGIN
|
2024-10-27 18:44:34 -07: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-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
GEN_NS_BEGIN
|
|
|
|
|
|
|
|
#pragma region Types
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
using LogFailType = ssize(*)(char const*, ...);
|
2024-10-21 19:39:40 -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-10-27 18:44:34 -07:00
|
|
|
#define log_failure log_fmt
|
2024-10-21 19:39:40 -07:00
|
|
|
#else
|
2024-10-27 18:44:34 -07:00
|
|
|
#define log_failure GEN_FATAL
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
enum class AccessSpec : u32
|
|
|
|
{
|
|
|
|
Default,
|
|
|
|
Private,
|
|
|
|
Protected,
|
|
|
|
Public,
|
|
|
|
|
|
|
|
Num_AccessSpec,
|
|
|
|
Invalid,
|
|
|
|
};
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
char const* to_str( AccessSpec type )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
local_persist
|
|
|
|
char const* lookup[ (u32)AccessSpec::Num_AccessSpec ] = {
|
2024-10-21 19:39:40 -07:00
|
|
|
"",
|
|
|
|
"private",
|
|
|
|
"protected",
|
|
|
|
"public",
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( type > AccessSpec::Public )
|
|
|
|
return "Invalid";
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
return lookup[ (u32)type ];
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
|
2024-10-21 19:39:40 -07:00
|
|
|
enum CodeFlag : u32
|
|
|
|
{
|
|
|
|
None = 0,
|
2024-10-27 18:44:34 -07:00
|
|
|
FunctionType = bit(0),
|
|
|
|
ParamPack = bit(1),
|
|
|
|
Module_Export = bit(2),
|
|
|
|
Module_Import = bit(3),
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// Used to indicate if enum definitoin is an enum class or regular enum.
|
|
|
|
enum class EnumT : u8
|
|
|
|
{
|
|
|
|
Regular,
|
|
|
|
Class
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr EnumT EnumClass = EnumT::Class;
|
|
|
|
constexpr EnumT EnumRegular = EnumT::Regular;
|
|
|
|
|
|
|
|
enum class ModuleFlag : u32
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
None = 0,
|
|
|
|
Export = bit(0),
|
|
|
|
Import = bit(1),
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
Num_ModuleFlags,
|
|
|
|
Invalid,
|
|
|
|
};
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
StrC to_str( ModuleFlag flag )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
local_persist
|
|
|
|
StrC lookup[ (u32)ModuleFlag::Num_ModuleFlags ] = {
|
|
|
|
{ sizeof("__none__"), "__none__" },
|
|
|
|
{ sizeof("export"), "export" },
|
|
|
|
{ sizeof("import"), "import" },
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
if ( flag > ModuleFlag::Import )
|
2024-10-27 18:44:34 -07:00
|
|
|
return { sizeof("invalid"), "invalid" };
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
return lookup[ (u32)flag ];
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
ModuleFlag operator|( ModuleFlag A, ModuleFlag B)
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (ModuleFlag)( (u32)A | (u32)B );
|
|
|
|
}
|
|
|
|
|
|
|
|
enum class EPreprocessCond : u32
|
|
|
|
{
|
|
|
|
If,
|
|
|
|
IfDef,
|
|
|
|
IfNotDef,
|
|
|
|
ElIf
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr EPreprocessCond PreprocessCond_If = EPreprocessCond::If;
|
|
|
|
constexpr EPreprocessCond PreprocessCond_IfDef = EPreprocessCond::IfDef;
|
|
|
|
constexpr EPreprocessCond PreprocessCond_IfNotDef = EPreprocessCond::IfNotDef;
|
|
|
|
constexpr EPreprocessCond PreprocessCond_ElIf = EPreprocessCond::ElIf;
|
|
|
|
|
|
|
|
namespace ECode
|
|
|
|
{
|
|
|
|
enum Type : u32
|
|
|
|
{
|
|
|
|
Invalid,
|
|
|
|
Untyped,
|
|
|
|
NewLine,
|
|
|
|
Comment,
|
|
|
|
Access_Private,
|
|
|
|
Access_Protected,
|
|
|
|
Access_Public,
|
|
|
|
PlatformAttributes,
|
|
|
|
Class,
|
|
|
|
Class_Fwd,
|
|
|
|
Class_Body,
|
|
|
|
Constructor,
|
|
|
|
Constructor_Fwd,
|
|
|
|
Destructor,
|
|
|
|
Destructor_Fwd,
|
|
|
|
Enum,
|
|
|
|
Enum_Fwd,
|
|
|
|
Enum_Body,
|
|
|
|
Enum_Class,
|
|
|
|
Enum_Class_Fwd,
|
|
|
|
Execution,
|
|
|
|
Export_Body,
|
|
|
|
Extern_Linkage,
|
|
|
|
Extern_Linkage_Body,
|
|
|
|
Friend,
|
|
|
|
Function,
|
|
|
|
Function_Fwd,
|
|
|
|
Function_Body,
|
|
|
|
Global_Body,
|
|
|
|
Module,
|
|
|
|
Namespace,
|
|
|
|
Namespace_Body,
|
|
|
|
Operator,
|
|
|
|
Operator_Fwd,
|
|
|
|
Operator_Member,
|
|
|
|
Operator_Member_Fwd,
|
|
|
|
Operator_Cast,
|
|
|
|
Operator_Cast_Fwd,
|
|
|
|
Parameters,
|
|
|
|
Preprocess_Define,
|
|
|
|
Preprocess_Include,
|
|
|
|
Preprocess_If,
|
|
|
|
Preprocess_IfDef,
|
|
|
|
Preprocess_IfNotDef,
|
|
|
|
Preprocess_ElIf,
|
|
|
|
Preprocess_Else,
|
|
|
|
Preprocess_EndIf,
|
|
|
|
Preprocess_Pragma,
|
|
|
|
Specifiers,
|
|
|
|
Struct,
|
|
|
|
Struct_Fwd,
|
|
|
|
Struct_Body,
|
|
|
|
Template,
|
|
|
|
Typedef,
|
|
|
|
Typename,
|
|
|
|
Union,
|
|
|
|
Union_Body,
|
|
|
|
Using,
|
|
|
|
Using_Namespace,
|
|
|
|
Variable,
|
|
|
|
NumTypes
|
|
|
|
};
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline StrC to_str( Type type )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
local_persist StrC lookup[] {
|
|
|
|
{ sizeof( "Invalid" ), "Invalid" },
|
|
|
|
{ sizeof( "Untyped" ), "Untyped" },
|
|
|
|
{ sizeof( "NewLine" ), "NewLine" },
|
|
|
|
{ sizeof( "Comment" ), "Comment" },
|
|
|
|
{ sizeof( "Access_Private" ), "Access_Private" },
|
|
|
|
{ sizeof( "Access_Protected" ), "Access_Protected" },
|
|
|
|
{ sizeof( "Access_Public" ), "Access_Public" },
|
|
|
|
{ sizeof( "PlatformAttributes" ), "PlatformAttributes" },
|
|
|
|
{ sizeof( "Class" ), "Class" },
|
|
|
|
{ sizeof( "Class_Fwd" ), "Class_Fwd" },
|
|
|
|
{ sizeof( "Class_Body" ), "Class_Body" },
|
|
|
|
{ sizeof( "Constructor" ), "Constructor" },
|
|
|
|
{ sizeof( "Constructor_Fwd" ), "Constructor_Fwd" },
|
|
|
|
{ sizeof( "Destructor" ), "Destructor" },
|
|
|
|
{ sizeof( "Destructor_Fwd" ), "Destructor_Fwd" },
|
|
|
|
{ sizeof( "Enum" ), "Enum" },
|
|
|
|
{ sizeof( "Enum_Fwd" ), "Enum_Fwd" },
|
|
|
|
{ sizeof( "Enum_Body" ), "Enum_Body" },
|
|
|
|
{ sizeof( "Enum_Class" ), "Enum_Class" },
|
|
|
|
{ sizeof( "Enum_Class_Fwd" ), "Enum_Class_Fwd" },
|
|
|
|
{ sizeof( "Execution" ), "Execution" },
|
|
|
|
{ sizeof( "Export_Body" ), "Export_Body" },
|
|
|
|
{ sizeof( "Extern_Linkage" ), "Extern_Linkage" },
|
|
|
|
{ sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" },
|
|
|
|
{ sizeof( "Friend" ), "Friend" },
|
|
|
|
{ sizeof( "Function" ), "Function" },
|
|
|
|
{ sizeof( "Function_Fwd" ), "Function_Fwd" },
|
|
|
|
{ sizeof( "Function_Body" ), "Function_Body" },
|
|
|
|
{ sizeof( "Global_Body" ), "Global_Body" },
|
|
|
|
{ sizeof( "Module" ), "Module" },
|
|
|
|
{ sizeof( "Namespace" ), "Namespace" },
|
|
|
|
{ sizeof( "Namespace_Body" ), "Namespace_Body" },
|
|
|
|
{ sizeof( "Operator" ), "Operator" },
|
|
|
|
{ sizeof( "Operator_Fwd" ), "Operator_Fwd" },
|
|
|
|
{ sizeof( "Operator_Member" ), "Operator_Member" },
|
|
|
|
{ sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" },
|
|
|
|
{ sizeof( "Operator_Cast" ), "Operator_Cast" },
|
|
|
|
{ sizeof( "Operator_Cast_Fwd" ), "Operator_Cast_Fwd" },
|
|
|
|
{ sizeof( "Parameters" ), "Parameters" },
|
|
|
|
{ sizeof( "Preprocess_Define" ), "Preprocess_Define" },
|
|
|
|
{ sizeof( "Preprocess_Include" ), "Preprocess_Include" },
|
|
|
|
{ sizeof( "Preprocess_If" ), "Preprocess_If" },
|
|
|
|
{ sizeof( "Preprocess_IfDef" ), "Preprocess_IfDef" },
|
|
|
|
{ sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" },
|
|
|
|
{ sizeof( "Preprocess_ElIf" ), "Preprocess_ElIf" },
|
|
|
|
{ sizeof( "Preprocess_Else" ), "Preprocess_Else" },
|
|
|
|
{ sizeof( "Preprocess_EndIf" ), "Preprocess_EndIf" },
|
|
|
|
{ sizeof( "Preprocess_Pragma" ), "Preprocess_Pragma" },
|
|
|
|
{ sizeof( "Specifiers" ), "Specifiers" },
|
|
|
|
{ sizeof( "Struct" ), "Struct" },
|
|
|
|
{ sizeof( "Struct_Fwd" ), "Struct_Fwd" },
|
|
|
|
{ sizeof( "Struct_Body" ), "Struct_Body" },
|
|
|
|
{ sizeof( "Template" ), "Template" },
|
|
|
|
{ sizeof( "Typedef" ), "Typedef" },
|
|
|
|
{ sizeof( "Typename" ), "Typename" },
|
|
|
|
{ sizeof( "Union" ), "Union" },
|
|
|
|
{ sizeof( "Union_Body" ), "Union_Body" },
|
|
|
|
{ sizeof( "Using" ), "Using" },
|
|
|
|
{ sizeof( "Using_Namespace" ), "Using_Namespace" },
|
|
|
|
{ sizeof( "Variable" ), "Variable" },
|
|
|
|
};
|
|
|
|
return lookup[type];
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ECode
|
|
|
|
|
|
|
|
using CodeT = ECode::Type;
|
|
|
|
|
|
|
|
namespace EOperator
|
|
|
|
{
|
|
|
|
enum Type : u32
|
|
|
|
{
|
|
|
|
Invalid,
|
|
|
|
Assign,
|
|
|
|
Assign_Add,
|
|
|
|
Assign_Subtract,
|
|
|
|
Assign_Multiply,
|
|
|
|
Assign_Divide,
|
|
|
|
Assign_Modulo,
|
|
|
|
Assign_BAnd,
|
|
|
|
Assign_BOr,
|
|
|
|
Assign_BXOr,
|
|
|
|
Assign_LShift,
|
|
|
|
Assign_RShift,
|
|
|
|
Increment,
|
|
|
|
Decrement,
|
|
|
|
Unary_Plus,
|
|
|
|
Unary_Minus,
|
|
|
|
UnaryNot,
|
|
|
|
Add,
|
|
|
|
Subtract,
|
|
|
|
Multiply,
|
|
|
|
Divide,
|
|
|
|
Modulo,
|
|
|
|
BNot,
|
|
|
|
BAnd,
|
|
|
|
BOr,
|
|
|
|
BXOr,
|
|
|
|
LShift,
|
|
|
|
RShift,
|
|
|
|
LAnd,
|
|
|
|
LOr,
|
|
|
|
LEqual,
|
|
|
|
LNot,
|
|
|
|
Lesser,
|
|
|
|
Greater,
|
|
|
|
LesserEqual,
|
|
|
|
GreaterEqual,
|
|
|
|
Subscript,
|
|
|
|
Indirection,
|
|
|
|
AddressOf,
|
|
|
|
MemberOfPointer,
|
|
|
|
PtrToMemOfPtr,
|
|
|
|
FunctionCall,
|
|
|
|
Comma,
|
|
|
|
New,
|
|
|
|
NewArray,
|
|
|
|
Delete,
|
|
|
|
DeleteArray,
|
|
|
|
NumOps
|
|
|
|
};
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline StrC to_str( Type op )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
local_persist StrC lookup[] {
|
|
|
|
{ sizeof( "INVALID" ), "INVALID" },
|
|
|
|
{ sizeof( "=" ), "=" },
|
|
|
|
{ sizeof( "+=" ), "+=" },
|
|
|
|
{ sizeof( "-=" ), "-=" },
|
|
|
|
{ sizeof( "*=" ), "*=" },
|
|
|
|
{ sizeof( "/=" ), "/=" },
|
|
|
|
{ sizeof( "%=" ), "%=" },
|
|
|
|
{ sizeof( "&=" ), "&=" },
|
|
|
|
{ sizeof( "|=" ), "|=" },
|
|
|
|
{ sizeof( "^=" ), "^=" },
|
|
|
|
{ sizeof( "<<=" ), "<<=" },
|
|
|
|
{ sizeof( ">>=" ), ">>=" },
|
|
|
|
{ sizeof( "++" ), "++" },
|
|
|
|
{ sizeof( "--" ), "--" },
|
|
|
|
{ sizeof( "+" ), "+" },
|
|
|
|
{ sizeof( "-" ), "-" },
|
|
|
|
{ sizeof( "!" ), "!" },
|
|
|
|
{ sizeof( "+" ), "+" },
|
|
|
|
{ sizeof( "-" ), "-" },
|
|
|
|
{ sizeof( "*" ), "*" },
|
|
|
|
{ sizeof( "/" ), "/" },
|
|
|
|
{ sizeof( "%" ), "%" },
|
|
|
|
{ sizeof( "~" ), "~" },
|
|
|
|
{ sizeof( "&" ), "&" },
|
|
|
|
{ sizeof( "|" ), "|" },
|
|
|
|
{ sizeof( "^" ), "^" },
|
|
|
|
{ sizeof( "<<" ), "<<" },
|
|
|
|
{ sizeof( ">>" ), ">>" },
|
|
|
|
{ sizeof( "&&" ), "&&" },
|
|
|
|
{ sizeof( "||" ), "||" },
|
|
|
|
{ sizeof( "==" ), "==" },
|
|
|
|
{ sizeof( "!=" ), "!=" },
|
|
|
|
{ sizeof( "<" ), "<" },
|
|
|
|
{ sizeof( ">" ), ">" },
|
|
|
|
{ sizeof( "<=" ), "<=" },
|
|
|
|
{ sizeof( ">=" ), ">=" },
|
|
|
|
{ sizeof( "[]" ), "[]" },
|
|
|
|
{ sizeof( "*" ), "*" },
|
|
|
|
{ sizeof( "&" ), "&" },
|
|
|
|
{ sizeof( "->" ), "->" },
|
|
|
|
{ sizeof( "->*" ), "->*" },
|
|
|
|
{ sizeof( "()" ), "()" },
|
|
|
|
{ sizeof( "," ), "," },
|
|
|
|
{ sizeof( "new" ), "new" },
|
|
|
|
{ sizeof( "new[]" ), "new[]" },
|
|
|
|
{ sizeof( "delete" ), "delete" },
|
|
|
|
{ sizeof( "delete[]" ), "delete[]" },
|
|
|
|
};
|
|
|
|
return lookup[op];
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace EOperator
|
|
|
|
|
|
|
|
using OperatorT = EOperator::Type;
|
|
|
|
|
|
|
|
namespace ESpecifier
|
|
|
|
{
|
|
|
|
enum Type : u32
|
|
|
|
{
|
|
|
|
Invalid,
|
|
|
|
Consteval,
|
|
|
|
Constexpr,
|
|
|
|
Constinit,
|
|
|
|
Explicit,
|
|
|
|
External_Linkage,
|
|
|
|
ForceInline,
|
|
|
|
Global,
|
|
|
|
Inline,
|
|
|
|
Internal_Linkage,
|
|
|
|
Local_Persist,
|
|
|
|
Mutable,
|
|
|
|
NeverInline,
|
|
|
|
Ptr,
|
|
|
|
Ref,
|
|
|
|
Register,
|
|
|
|
RValue,
|
|
|
|
Static,
|
|
|
|
Thread_Local,
|
|
|
|
Virtual,
|
|
|
|
Const,
|
|
|
|
Final,
|
|
|
|
NoExceptions,
|
|
|
|
Override,
|
|
|
|
Pure,
|
|
|
|
Volatile,
|
|
|
|
NumSpecifiers
|
|
|
|
};
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool is_trailing( Type specifier )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return specifier > Virtual;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline StrC to_str( Type type )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
local_persist StrC lookup[] {
|
|
|
|
{ sizeof( "INVALID" ), "INVALID" },
|
|
|
|
{ sizeof( "consteval" ), "consteval" },
|
|
|
|
{ sizeof( "constexpr" ), "constexpr" },
|
|
|
|
{ sizeof( "constinit" ), "constinit" },
|
|
|
|
{ sizeof( "explicit" ), "explicit" },
|
|
|
|
{ sizeof( "extern" ), "extern" },
|
|
|
|
{ sizeof( "FORCEINLINE" ), "FORCEINLINE" },
|
|
|
|
{ sizeof( "global" ), "global" },
|
|
|
|
{ sizeof( "inline" ), "inline" },
|
|
|
|
{ sizeof( "internal" ), "internal" },
|
|
|
|
{ sizeof( "local_persist" ), "local_persist" },
|
|
|
|
{ sizeof( "mutable" ), "mutable" },
|
|
|
|
{ sizeof( "neverinline" ), "neverinline" },
|
|
|
|
{ sizeof( "*" ), "*" },
|
|
|
|
{ sizeof( "&" ), "&" },
|
|
|
|
{ sizeof( "register" ), "register" },
|
|
|
|
{ sizeof( "&&" ), "&&" },
|
|
|
|
{ sizeof( "static" ), "static" },
|
|
|
|
{ sizeof( "thread_local" ), "thread_local" },
|
|
|
|
{ sizeof( "virtual" ), "virtual" },
|
|
|
|
{ sizeof( "const" ), "const" },
|
|
|
|
{ sizeof( "final" ), "final" },
|
|
|
|
{ sizeof( "noexcept" ), "noexcept" },
|
|
|
|
{ sizeof( "override" ), "override" },
|
|
|
|
{ sizeof( "= 0" ), "= 0" },
|
|
|
|
{ sizeof( "volatile" ), "volatile" },
|
|
|
|
};
|
|
|
|
return lookup[type];
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Type to_type( StrC str )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
local_persist u32 keymap[NumSpecifiers];
|
|
|
|
do_once_start for ( u32 index = 0; index < NumSpecifiers; index++ )
|
|
|
|
{
|
|
|
|
StrC enum_str = to_str( (Type)index );
|
|
|
|
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
|
|
|
}
|
|
|
|
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
|
|
|
for ( u32 index = 0; index < NumSpecifiers; index++ )
|
|
|
|
{
|
|
|
|
if ( keymap[index] == hash )
|
|
|
|
return (Type)index;
|
|
|
|
}
|
|
|
|
return Invalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ESpecifier
|
|
|
|
|
|
|
|
using SpecifierT = ESpecifier::Type;
|
|
|
|
|
|
|
|
#pragma endregion Types
|
|
|
|
|
|
|
|
#pragma region AST
|
|
|
|
|
|
|
|
struct AST;
|
|
|
|
struct AST_Body;
|
|
|
|
struct AST_Attributes;
|
|
|
|
struct AST_Comment;
|
|
|
|
struct AST_Constructor;
|
|
|
|
// struct AST_BaseClass;
|
|
|
|
struct AST_Class;
|
|
|
|
struct AST_Define;
|
|
|
|
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;
|
|
|
|
struct AST_Param;
|
|
|
|
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-10-27 18:44:34 -07: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-10-21 19:39:40 -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-10-27 18:44:34 -07:00
|
|
|
struct AST_Stmt_Expr; // TODO(Ed) : Is this distinction needed? (Should it be a flag instead?)
|
2024-10-21 19:39:40 -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;
|
|
|
|
struct AST_Type;
|
|
|
|
struct AST_Typedef;
|
|
|
|
struct AST_Union;
|
|
|
|
struct AST_Using;
|
|
|
|
struct AST_Var;
|
|
|
|
|
|
|
|
struct Code;
|
|
|
|
struct CodeBody;
|
|
|
|
// These are to offer ease of use and optionally strong type safety for the AST.
|
|
|
|
struct CodeAttributes;
|
|
|
|
// struct CodeBaseClass;
|
|
|
|
struct CodeComment;
|
|
|
|
struct CodeClass;
|
|
|
|
struct CodeConstructor;
|
|
|
|
struct CodeDefine;
|
|
|
|
struct CodeDestructor;
|
|
|
|
struct CodeEnum;
|
|
|
|
struct CodeExec;
|
|
|
|
struct CodeExtern;
|
|
|
|
struct CodeInclude;
|
|
|
|
struct CodeFriend;
|
|
|
|
struct CodeFn;
|
|
|
|
struct CodeModule;
|
|
|
|
struct CodeNS;
|
|
|
|
struct CodeOperator;
|
|
|
|
struct CodeOpCast;
|
|
|
|
struct CodeParam;
|
|
|
|
struct CodePreprocessCond;
|
|
|
|
struct CodePragma;
|
|
|
|
struct CodeSpecifiers;
|
|
|
|
|
|
|
|
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
|
|
|
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-10-27 18:44:34 -07:00
|
|
|
struct CodeExpr_AMS; // Access Member Symbol
|
2024-10-21 19:39:40 -07:00
|
|
|
struct CodeExpr_Sizeof;
|
|
|
|
struct CodeExpr_Subscript;
|
|
|
|
struct CodeExpr_Ternary;
|
|
|
|
struct CodeExpr_UnaryPrefix;
|
|
|
|
struct CodeExpr_UnaryPostfix;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
struct CodeStruct;
|
|
|
|
struct CodeTemplate;
|
|
|
|
struct CodeType;
|
|
|
|
struct CodeTypedef;
|
|
|
|
struct CodeUnion;
|
|
|
|
struct CodeUsing;
|
|
|
|
struct CodeVar;
|
|
|
|
|
|
|
|
namespace parser
|
|
|
|
{
|
|
|
|
struct Token;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2024-10-27 18:44:34 -07: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-10-21 19:39:40 -07:00
|
|
|
*/
|
|
|
|
struct Code
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma region Statics
|
2024-10-21 19:39:40 -07:00
|
|
|
// Used to identify ASTs that should always be duplicated. (Global constant ASTs)
|
|
|
|
static Code Global;
|
|
|
|
|
|
|
|
// Used to identify invalid generated code.
|
|
|
|
static Code Invalid;
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma endregion Statics
|
|
|
|
|
|
|
|
# define Using_Code( Typename ) \
|
|
|
|
char const* debug_str(); \
|
|
|
|
Code duplicate(); \
|
|
|
|
bool is_equal( Code other ); \
|
|
|
|
bool is_valid(); \
|
|
|
|
void set_global(); \
|
|
|
|
String to_string(); \
|
|
|
|
Typename& operator = ( AST* other ); \
|
|
|
|
Typename& operator = ( Code other ); \
|
|
|
|
bool operator ==( Code other ); \
|
|
|
|
bool operator !=( Code other ); \
|
2024-10-21 19:39:40 -07:00
|
|
|
operator bool();
|
|
|
|
|
|
|
|
Using_Code( Code );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
template< class Type >
|
2024-10-21 19:39:40 -07:00
|
|
|
FORCEINLINE Type cast()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
return * rcast( Type*, this );
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* operator ->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast;
|
|
|
|
}
|
2024-10-27 18:44:34 -07:00
|
|
|
Code& operator ++();
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
// TODO(Ed) : Remove this overload.
|
|
|
|
auto& operator*()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
local_persist thread_local
|
|
|
|
Code NullRef = { nullptr };
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return NullRef;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST* ast;
|
|
|
|
|
|
|
|
#ifdef GEN_ENFORCE_STRONG_CODE_TYPES
|
2024-10-27 18:44:34 -07:00
|
|
|
# define operator explicit operator
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
operator CodeBody() const;
|
|
|
|
operator CodeAttributes() const;
|
|
|
|
// operator CodeBaseClass() const;
|
|
|
|
operator CodeComment() const;
|
|
|
|
operator CodeClass() const;
|
|
|
|
operator CodeConstructor() const;
|
|
|
|
operator CodeDefine() const;
|
|
|
|
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;
|
|
|
|
operator CodeParam() const;
|
|
|
|
operator CodePragma() const;
|
|
|
|
operator CodePreprocessCond() const;
|
|
|
|
operator CodeSpecifiers() const;
|
|
|
|
operator CodeStruct() const;
|
|
|
|
operator CodeTemplate() const;
|
|
|
|
operator CodeType() const;
|
|
|
|
operator CodeTypedef() const;
|
|
|
|
operator CodeUnion() const;
|
|
|
|
operator CodeUsing() const;
|
|
|
|
operator CodeVar() const;
|
2024-10-27 18:44:34 -07:00
|
|
|
#undef operator
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_POD
|
|
|
|
{
|
|
|
|
AST* ast;
|
|
|
|
};
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
// Desired width of the AST data structure.
|
|
|
|
constexpr int const AST_POD_Size = 128;
|
|
|
|
|
|
|
|
/*
|
2024-10-27 18:44:34 -07:00
|
|
|
Simple AST POD with functionality to seralize into C++ syntax.
|
2024-10-21 19:39:40 -07:00
|
|
|
*/
|
|
|
|
struct AST
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma region Member Functions
|
|
|
|
void append ( AST* other );
|
|
|
|
char const* debug_str ();
|
|
|
|
AST* duplicate ();
|
|
|
|
Code& entry ( u32 idx );
|
2024-10-21 19:39:40 -07:00
|
|
|
bool has_entries();
|
2024-10-27 18:44:34 -07:00
|
|
|
bool is_equal ( AST* other );
|
2024-10-21 19:39:40 -07:00
|
|
|
char const* type_str();
|
|
|
|
bool validate_body();
|
|
|
|
|
|
|
|
String to_string();
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
neverinline
|
|
|
|
void to_string( String& result );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
template< class Type >
|
2024-10-21 19:39:40 -07:00
|
|
|
FORCEINLINE Type cast()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
return * this;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
operator Code();
|
|
|
|
operator CodeBody();
|
|
|
|
operator CodeAttributes();
|
|
|
|
// operator CodeBaseClass();
|
|
|
|
operator CodeComment();
|
|
|
|
operator CodeConstructor();
|
|
|
|
operator CodeDestructor();
|
|
|
|
operator CodeClass();
|
|
|
|
operator CodeDefine();
|
|
|
|
operator CodeEnum();
|
|
|
|
operator CodeExec();
|
|
|
|
operator CodeExtern();
|
|
|
|
operator CodeInclude();
|
|
|
|
operator CodeFriend();
|
|
|
|
operator CodeFn();
|
|
|
|
operator CodeModule();
|
|
|
|
operator CodeNS();
|
|
|
|
operator CodeOperator();
|
|
|
|
operator CodeOpCast();
|
|
|
|
operator CodeParam();
|
|
|
|
operator CodePragma();
|
|
|
|
operator CodePreprocessCond();
|
|
|
|
operator CodeSpecifiers();
|
|
|
|
operator CodeStruct();
|
|
|
|
operator CodeTemplate();
|
|
|
|
operator CodeType();
|
|
|
|
operator CodeTypedef();
|
|
|
|
operator CodeUnion();
|
|
|
|
operator CodeUsing();
|
|
|
|
operator CodeVar();
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma endregion Member Functions
|
|
|
|
|
|
|
|
constexpr static
|
|
|
|
int ArrSpecs_Cap =
|
|
|
|
(
|
|
|
|
AST_POD_Size
|
|
|
|
- sizeof(AST*) * 3
|
|
|
|
- sizeof(parser::Token*)
|
|
|
|
- sizeof(AST*)
|
|
|
|
- sizeof(StringCached)
|
|
|
|
- sizeof(CodeT)
|
|
|
|
- sizeof(ModuleFlag)
|
|
|
|
- sizeof(int)
|
|
|
|
)
|
|
|
|
/ sizeof(int) - 1; // -1 for 4 extra bytes
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
|
|
|
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
|
|
|
AST* Specs; // Destructor, Function, Operator, Typename, Variable
|
|
|
|
union {
|
|
|
|
AST* InitializerList; // Constructor
|
|
|
|
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
|
|
|
AST* ReturnType; // Function, Operator, Typename
|
|
|
|
AST* UnderlyingType; // Enum, Typedef
|
|
|
|
AST* ValueType; // Parameter, Variable
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
AST* Macro; // Parameter
|
|
|
|
AST* BitfieldSize; // Variable (Class/Struct Data Member)
|
|
|
|
AST* Params; // Constructor, Function, Operator, Template, Typename
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
AST* ArrExpr; // Typename
|
|
|
|
AST* Body; // Class, Constructor, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
|
|
|
AST* Declaration; // Friend, Template
|
|
|
|
AST* Value; // Parameter, Variable
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
|
|
|
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
|
|
|
AST* PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
StringCached Content; // Attributes, Comment, Execution, Include
|
|
|
|
struct {
|
|
|
|
SpecifierT ArrSpecs[ArrSpecs_Cap]; // Specifiers
|
|
|
|
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
2024-10-21 19:39:40 -07:00
|
|
|
AST* Prev;
|
|
|
|
AST* Front;
|
|
|
|
AST* Last;
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
2024-10-21 19:39:40 -07:00
|
|
|
AST* Next;
|
|
|
|
AST* Back;
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
|
|
|
AST* Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
// CodeFlag CodeFlags;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
union {
|
|
|
|
b32 IsFunction; // Used by typedef to not serialize the name field.
|
|
|
|
b32 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
|
|
|
|
OperatorT Op;
|
|
|
|
AccessSpec ParentAccess;
|
|
|
|
s32 NumEntries;
|
|
|
|
s32 VarConstructorInit; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AST_POD
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
|
|
|
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
|
|
|
AST* Specs; // Destructor, Function, Operator, Typename, Variable
|
|
|
|
union {
|
|
|
|
AST* InitializerList; // Constructor
|
|
|
|
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
|
|
|
AST* ReturnType; // Function, Operator, Typename
|
|
|
|
AST* UnderlyingType; // Enum, Typedef
|
|
|
|
AST* ValueType; // Parameter, Variable
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
AST* Macro; // Parameter
|
|
|
|
AST* BitfieldSize; // Variable (Class/Struct Data Member)
|
|
|
|
AST* Params; // Constructor, Function, Operator, Template, Typename
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
AST* ArrExpr; // Typename
|
|
|
|
AST* Body; // Class, Constructr, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
|
|
|
AST* Declaration; // Friend, Template
|
|
|
|
AST* Value; // Parameter, Variable
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
|
|
|
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
|
|
|
AST* PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
StringCached Content; // Attributes, Comment, Execution, Include
|
|
|
|
struct {
|
|
|
|
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
|
|
|
|
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
2024-10-21 19:39:40 -07:00
|
|
|
AST* Prev;
|
|
|
|
AST* Front;
|
|
|
|
AST* Last;
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
2024-10-21 19:39:40 -07:00
|
|
|
AST* Next;
|
|
|
|
AST* Back;
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
|
|
|
AST* Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
CodeFlag CodeFlags;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
union {
|
|
|
|
b32 IsFunction; // Used by typedef to not serialize the name field.
|
|
|
|
b32 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
|
|
|
|
OperatorT Op;
|
|
|
|
AccessSpec ParentAccess;
|
|
|
|
s32 NumEntries;
|
|
|
|
s32 VarConstructorInit; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
struct test {
|
|
|
|
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
|
|
|
|
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
constexpr int pls = sizeof(test);
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
// Its intended for the AST to have equivalent size to its POD.
|
|
|
|
// All extra functionality within the AST namespace should just be syntatic sugar.
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST) == sizeof(AST_POD), "ERROR: AST IS NOT POD" );
|
|
|
|
static_assert( sizeof(AST_POD) == AST_POD_Size, "ERROR: AST POD is not size of AST_POD_Size" );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
// Used when the its desired when omission is allowed in a definition.
|
2024-10-27 18:44:34 -07:00
|
|
|
#define NoCode { nullptr }
|
|
|
|
#define CodeInvalid (* Code::Invalid.ast) // Uses an implicitly overloaded cast from the AST to the desired code type.
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#pragma region Code Types
|
|
|
|
|
|
|
|
struct CodeBody
|
|
|
|
{
|
|
|
|
Using_Code( CodeBody );
|
|
|
|
|
|
|
|
void append( Code other )
|
|
|
|
{
|
|
|
|
raw()->append( other.ast );
|
|
|
|
}
|
|
|
|
void append( CodeBody body )
|
|
|
|
{
|
|
|
|
for ( Code entry : body )
|
|
|
|
{
|
|
|
|
append( entry );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool has_entries()
|
|
|
|
{
|
|
|
|
return rcast( AST*, ast )->has_entries();
|
|
|
|
}
|
|
|
|
void to_string( String& result );
|
|
|
|
void to_string_export( String& result );
|
|
|
|
AST* raw()
|
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
AST_Body* operator->()
|
|
|
|
{
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
operator Code()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
return * rcast( Code*, this );
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
#pragma region Iterator
|
|
|
|
Code begin()
|
|
|
|
{
|
|
|
|
if ( ast )
|
2024-10-27 18:44:34 -07:00
|
|
|
return { rcast( AST*, ast)->Front };
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
return { nullptr };
|
|
|
|
}
|
|
|
|
Code end()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
return { rcast(AST*, ast)->Back->Next };
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
#pragma endregion Iterator
|
|
|
|
|
|
|
|
AST_Body* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeClass
|
|
|
|
{
|
|
|
|
Using_Code( CodeClass );
|
|
|
|
|
|
|
|
void add_interface( CodeType interface );
|
|
|
|
|
|
|
|
void to_string_def( String& result );
|
|
|
|
void to_string_fwd( String& result );
|
|
|
|
|
|
|
|
AST* raw()
|
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
operator Code()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
return * rcast( Code*, this );
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
AST_Class* operator->()
|
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
log_failure("Attempt to dereference a nullptr");
|
2024-10-21 19:39:40 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
AST_Class* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeParam
|
|
|
|
{
|
|
|
|
Using_Code( CodeParam );
|
|
|
|
|
|
|
|
void append( CodeParam other );
|
|
|
|
|
|
|
|
CodeParam get( s32 idx );
|
2024-10-27 18:44:34 -07:00
|
|
|
bool has_entries();
|
|
|
|
void to_string( String& result );
|
2024-10-21 19:39:40 -07:00
|
|
|
AST* raw()
|
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
AST_Param* operator->()
|
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
log_failure("Attempt to dereference a nullptr!");
|
2024-10-21 19:39:40 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
operator Code()
|
|
|
|
{
|
|
|
|
return { (AST*)ast };
|
|
|
|
}
|
|
|
|
#pragma region Iterator
|
|
|
|
CodeParam begin()
|
|
|
|
{
|
|
|
|
if ( ast )
|
|
|
|
return { ast };
|
|
|
|
|
|
|
|
return { nullptr };
|
|
|
|
}
|
|
|
|
CodeParam end()
|
|
|
|
{
|
|
|
|
// return { (AST_Param*) rcast( AST*, ast)->Last };
|
|
|
|
return { nullptr };
|
|
|
|
}
|
|
|
|
CodeParam& operator++();
|
|
|
|
CodeParam operator*()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
return * this;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
#pragma endregion Iterator
|
|
|
|
|
|
|
|
AST_Param* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeSpecifiers
|
|
|
|
{
|
|
|
|
Using_Code( CodeSpecifiers );
|
|
|
|
|
|
|
|
bool append( SpecifierT spec )
|
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
2024-10-21 19:39:40 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( raw()->NumEntries == AST::ArrSpecs_Cap )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST::ArrSpecs_Cap );
|
2024-10-21 19:39:40 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
raw()->ArrSpecs[ raw()->NumEntries ] = spec;
|
2024-10-21 19:39:40 -07:00
|
|
|
raw()->NumEntries++;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
s32 has( SpecifierT spec )
|
|
|
|
{
|
|
|
|
for ( s32 idx = 0; idx < raw()->NumEntries; idx++ )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
if ( raw()->ArrSpecs[ idx ] == spec )
|
2024-10-21 19:39:40 -07:00
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
void to_string( String& result );
|
|
|
|
AST* raw()
|
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
AST_Specifiers* operator->()
|
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
log_failure("Attempt to dereference a nullptr!");
|
2024-10-21 19:39:40 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
operator Code()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
return { (AST*) ast };
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
#pragma region Iterator
|
|
|
|
SpecifierT* begin()
|
|
|
|
{
|
|
|
|
if ( ast )
|
2024-10-27 18:44:34 -07:00
|
|
|
return & raw()->ArrSpecs[0];
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
SpecifierT* end()
|
|
|
|
{
|
|
|
|
return raw()->ArrSpecs + raw()->NumEntries;
|
|
|
|
}
|
|
|
|
#pragma endregion Iterator
|
|
|
|
|
|
|
|
AST_Specifiers* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStruct
|
|
|
|
{
|
|
|
|
Using_Code( CodeStruct );
|
|
|
|
|
|
|
|
void add_interface( CodeType interface );
|
|
|
|
|
|
|
|
void to_string_def( String& result );
|
|
|
|
void to_string_fwd( String& result );
|
|
|
|
|
|
|
|
AST* raw()
|
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
operator Code()
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
return * rcast( Code*, this );
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
AST_Struct* operator->()
|
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
log_failure("Attempt to dereference a nullptr");
|
2024-10-21 19:39:40 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
AST_Struct* ast;
|
|
|
|
};
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
#define Define_CodeType( Typename ) \
|
|
|
|
struct Code##Typename \
|
|
|
|
{ \
|
|
|
|
Using_Code( Code ## Typename ); \
|
|
|
|
AST* raw(); \
|
|
|
|
operator Code(); \
|
|
|
|
AST_##Typename* operator->(); \
|
|
|
|
AST_##Typename* ast; \
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Define_CodeType( Attributes );
|
|
|
|
// Define_CodeType( BaseClass );
|
|
|
|
Define_CodeType( Comment );
|
|
|
|
|
|
|
|
struct CodeConstructor
|
|
|
|
{
|
|
|
|
Using_Code( CodeConstructor );
|
|
|
|
|
|
|
|
void to_string_def( String& result );
|
|
|
|
void to_string_fwd( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Constructor* operator->();
|
|
|
|
AST_Constructor* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeDefine
|
|
|
|
{
|
|
|
|
Using_Code( CodeDefine );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Define* operator->();
|
|
|
|
AST_Define* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeDestructor
|
|
|
|
{
|
|
|
|
Using_Code( CodeDestructor );
|
|
|
|
|
|
|
|
void to_string_def( String& result );
|
|
|
|
void to_string_fwd( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Destructor* operator->();
|
|
|
|
AST_Destructor* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeEnum
|
|
|
|
{
|
|
|
|
Using_Code( CodeEnum );
|
|
|
|
|
|
|
|
void to_string_def( String& result );
|
|
|
|
void to_string_fwd( String& result );
|
|
|
|
void to_string_class_def( String& result );
|
|
|
|
void to_string_class_fwd( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Enum* operator->();
|
|
|
|
AST_Enum* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
Define_CodeType( Exec );
|
|
|
|
|
|
|
|
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
|
|
|
struct CodeExpr
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr* operator->();
|
|
|
|
AST_Expr* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Assign
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Assign );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Assign* operator->();
|
|
|
|
AST_Expr_Assign* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Alignof
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Alignof );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Alignof* operator->();
|
|
|
|
AST_Expr_Alignof* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Binary
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Binary );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Binary* operator->();
|
|
|
|
AST_Expr_Binary* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_CStyleCast
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_CStyleCast );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_CStyleCast* operator->();
|
|
|
|
AST_Expr_CStyleCast* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_FunctionalCast
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_FunctionalCast );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_FunctionalCast* operator->();
|
|
|
|
AST_Expr_FunctionalCast* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_CppCast
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_CppCast );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_CppCast* operator->();
|
|
|
|
AST_Expr_CppCast* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Element
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Element );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Element* operator->();
|
|
|
|
AST_Expr_Element* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_ProcCall
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_ProcCall );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_ProcCall* operator->();
|
|
|
|
AST_Expr_ProcCall* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Decltype
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Decltype );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Decltype* operator->();
|
|
|
|
AST_Expr_Decltype* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Comma
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Comma );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Comma* operator->();
|
|
|
|
AST_Expr_Comma* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_AMS
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_AMS );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_AMS* operator->();
|
|
|
|
AST_Expr_AMS* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Sizeof
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Sizeof );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Sizeof* operator->();
|
|
|
|
AST_Expr_Sizeof* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Subscript
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Subscript );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Subscript* operator->();
|
|
|
|
AST_Expr_Subscript* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_Ternary
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_Ternary );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_Ternary* operator->();
|
|
|
|
AST_Expr_Ternary* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_UnaryPrefix
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_UnaryPrefix );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_UnaryPrefix* operator->();
|
|
|
|
AST_Expr_UnaryPrefix* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeExpr_UnaryPostfix
|
|
|
|
{
|
|
|
|
Using_Code( CodeExpr_UnaryPostfix );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Expr_UnaryPostfix* operator->();
|
|
|
|
AST_Expr_UnaryPostfix* ast;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct CodeExtern
|
|
|
|
{
|
|
|
|
Using_Code( CodeExtern );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Extern* operator->();
|
|
|
|
AST_Extern* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeInclude
|
|
|
|
{
|
|
|
|
Using_Code( CodeInclude );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Include* operator->();
|
|
|
|
AST_Include* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeFriend
|
|
|
|
{
|
|
|
|
Using_Code( CodeFriend );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Friend* operator->();
|
|
|
|
AST_Friend* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeFn
|
|
|
|
{
|
|
|
|
Using_Code( CodeFn );
|
|
|
|
|
|
|
|
void to_string_def( String& result );
|
|
|
|
void to_string_fwd( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
2024-10-21 19:39:40 -07:00
|
|
|
operator Code();
|
2024-10-27 18:44:34 -07:00
|
|
|
AST_Fn* operator->();
|
|
|
|
AST_Fn* ast;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeModule
|
|
|
|
{
|
|
|
|
Using_Code( CodeModule );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Module* operator->();
|
|
|
|
AST_Module* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeNS
|
|
|
|
{
|
|
|
|
Using_Code( CodeNS );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
2024-10-21 19:39:40 -07:00
|
|
|
operator Code();
|
2024-10-27 18:44:34 -07:00
|
|
|
AST_NS* operator->();
|
|
|
|
AST_NS* ast;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeOperator
|
|
|
|
{
|
|
|
|
Using_Code( CodeOperator );
|
|
|
|
|
|
|
|
void to_string_def( String& result );
|
|
|
|
void to_string_fwd( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Operator* operator->();
|
|
|
|
AST_Operator* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeOpCast
|
|
|
|
{
|
|
|
|
Using_Code( CodeOpCast );
|
|
|
|
|
|
|
|
void to_string_def( String& result );
|
|
|
|
void to_string_fwd( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_OpCast* operator->();
|
|
|
|
AST_OpCast* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodePragma
|
|
|
|
{
|
|
|
|
Using_Code( CodePragma );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Pragma* operator->();
|
|
|
|
AST_Pragma* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodePreprocessCond
|
|
|
|
{
|
|
|
|
Using_Code( CodePreprocessCond );
|
|
|
|
|
|
|
|
void to_string_if( String& result );
|
|
|
|
void to_string_ifdef( String& result );
|
|
|
|
void to_string_ifndef( String& result );
|
|
|
|
void to_string_elif( String& result );
|
|
|
|
void to_string_else( String& result );
|
|
|
|
void to_string_endif( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_PreprocessCond* operator->();
|
|
|
|
AST_PreprocessCond* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
|
|
|
struct CodeStmt
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt* operator->();
|
|
|
|
AST_Stmt* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Break
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Break );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Break* operator->();
|
|
|
|
AST_Stmt_Break* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Case
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Case );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Case* operator->();
|
|
|
|
AST_Stmt_Case* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Continue
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Continue );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Continue* operator->();
|
|
|
|
AST_Stmt_Continue* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Decl
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Decl );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Decl* operator->();
|
|
|
|
AST_Stmt_Decl* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Do
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Do );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Do* operator->();
|
|
|
|
AST_Stmt_Do* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Expr
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Expr );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Expr* operator->();
|
|
|
|
AST_Stmt_Expr* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Else
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Else );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Else* operator->();
|
|
|
|
AST_Stmt_Else* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_If
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_If );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_If* operator->();
|
|
|
|
AST_Stmt_If* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_For
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_For );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_For* operator->();
|
|
|
|
AST_Stmt_For* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Goto
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Goto );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Goto* operator->();
|
|
|
|
AST_Stmt_Goto* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Label
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Label );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Label* operator->();
|
|
|
|
AST_Stmt_Label* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_Switch
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_Switch );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_Switch* operator->();
|
|
|
|
AST_Stmt_Switch* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeStmt_While
|
|
|
|
{
|
|
|
|
Using_Code( CodeStmt_While );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Stmt_While* operator->();
|
|
|
|
AST_Stmt_While* ast;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct CodeTemplate
|
|
|
|
{
|
|
|
|
Using_Code( CodeTemplate );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Template* operator->();
|
|
|
|
AST_Template* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeType
|
|
|
|
{
|
|
|
|
Using_Code( CodeType );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Type* operator->();
|
|
|
|
AST_Type* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeTypedef
|
|
|
|
{
|
|
|
|
Using_Code( CodeTypedef );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Typedef* operator->();
|
|
|
|
AST_Typedef* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeUnion
|
|
|
|
{
|
|
|
|
Using_Code( CodeUnion );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Union* operator->();
|
|
|
|
AST_Union* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeUsing
|
|
|
|
{
|
|
|
|
Using_Code( CodeUsing );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
void to_string_ns( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
|
|
|
operator Code();
|
2024-10-21 19:39:40 -07:00
|
|
|
AST_Using* operator->();
|
|
|
|
AST_Using* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CodeVar
|
|
|
|
{
|
|
|
|
Using_Code( CodeVar );
|
|
|
|
|
|
|
|
void to_string( String& result );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* raw();
|
2024-10-21 19:39:40 -07:00
|
|
|
operator Code();
|
|
|
|
AST_Var* operator->();
|
|
|
|
AST_Var* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef Define_CodeType
|
|
|
|
#undef Using_Code
|
|
|
|
|
|
|
|
#pragma endregion Code Types
|
|
|
|
|
|
|
|
#pragma region AST Types
|
|
|
|
/*
|
2024-10-27 18:44:34 -07: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-10-21 19:39:40 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct AST_Body
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
Code Front;
|
|
|
|
Code Back;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
|
|
|
s32 NumEntries;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Attributes
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
StringCached Content;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
struct AST_BaseClass
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
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-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
StringCached Content;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Class
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeComment InlineCmt; // Only supported by forward declarations
|
|
|
|
CodeAttributes Attributes;
|
|
|
|
char _PAD_SPECS_ [ sizeof(AST*) ];
|
|
|
|
CodeType ParentType;
|
|
|
|
char _PAD_PARAMS_[ sizeof(AST*) ];
|
|
|
|
CodeBody Body;
|
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeType Prev;
|
|
|
|
CodeType Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
AccessSpec ParentAccess;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Class) == sizeof(AST), "ERROR: AST_Class is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Constructor
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeComment InlineCmt; // Only supported by forward declarations
|
|
|
|
char _PAD_PROPERTIES_ [ sizeof(AST*) * 1 ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeSpecifiers Specs;
|
|
|
|
Code InitializerList;
|
|
|
|
CodeParam Params;
|
|
|
|
Code Body;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Define
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
StringCached Content;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Destructor
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CodeComment InlineCmt;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_ [ sizeof(AST*) * 1 ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeSpecifiers Specs;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
|
2024-10-21 19:39:40 -07:00
|
|
|
Code Body;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_3_ [ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Enum
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CodeComment InlineCmt;
|
|
|
|
CodeAttributes Attributes;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_SPEC_ [ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeType UnderlyingType;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PARAMS_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeBody Body;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
char _PAD_UNUSED_[ sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Exec
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
StringCached Content;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
|
|
|
struct AST_Expr
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr) == sizeof(AST), "ERROR: AST_Expr is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Assign
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Assign) == sizeof(AST), "ERROR: AST_Expr_Assign is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Alignof
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Alignof) == sizeof(AST), "ERROR: AST_Expr_Alignof is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Binary
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Binary) == sizeof(AST), "ERROR: AST_Expr_Binary is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_CStyleCast
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_CStyleCast) == sizeof(AST), "ERROR: AST_Expr_CStyleCast is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_FunctionalCast
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_FunctionalCast) == sizeof(AST), "ERROR: AST_Expr_FunctionalCast is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_CppCast
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_CppCast) == sizeof(AST), "ERROR: AST_Expr_CppCast is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_ProcCall
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_ProcCall) == sizeof(AST), "ERROR: AST_Expr_Identifier is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Decltype
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Decltype) == sizeof(AST), "ERROR: AST_Expr_Decltype is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Comma
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Comma) == sizeof(AST), "ERROR: AST_Expr_Comma is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_AMS
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_AMS) == sizeof(AST), "ERROR: AST_Expr_AMS is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Sizeof
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Sizeof) == sizeof(AST), "ERROR: AST_Expr_Sizeof is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Subscript
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Subscript) == sizeof(AST), "ERROR: AST_Expr_Subscript is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Ternary
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Ternary) == sizeof(AST), "ERROR: AST_Expr_Ternary is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_UnaryPrefix
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_UnaryPrefix) == sizeof(AST), "ERROR: AST_Expr_UnaryPrefix is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_UnaryPostfix
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_UnaryPostfix) == sizeof(AST), "ERROR: AST_Expr_UnaryPostfix is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Expr_Element
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Expr_Element) == sizeof(AST), "ERROR: AST_Expr_Element is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct AST_Extern
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
|
|
|
|
CodeBody Body;
|
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Include
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
StringCached Content;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Friend
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CodeComment InlineCmt;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
|
2024-10-21 19:39:40 -07:00
|
|
|
Code Declaration;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Fn
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeComment InlineCmt;
|
|
|
|
CodeAttributes Attributes;
|
|
|
|
CodeSpecifiers Specs;
|
|
|
|
CodeType ReturnType;
|
|
|
|
CodeParam Params;
|
|
|
|
CodeBody Body;
|
|
|
|
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
char _PAD_UNUSED_[ sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Module
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
char _PAD_UNUSED_[ sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_NS
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
struct {
|
|
|
|
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
|
|
|
|
CodeBody Body;
|
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
char _PAD_UNUSED_[ sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Operator
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeComment InlineCmt;
|
|
|
|
CodeAttributes Attributes;
|
|
|
|
CodeSpecifiers Specs;
|
|
|
|
CodeType ReturnType;
|
|
|
|
CodeParam Params;
|
|
|
|
CodeBody Body;
|
|
|
|
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
OperatorT Op;
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_OpCast
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CodeComment InlineCmt;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeSpecifiers Specs;
|
|
|
|
CodeType ValueType;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeBody Body;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Param
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
|
|
|
|
CodeType ValueType;
|
|
|
|
Code Macro;
|
|
|
|
Code Value;
|
|
|
|
Code PostNameMacro; // Thanks Unreal
|
|
|
|
// char _PAD_PROPERTIES_3_[sizeof( AST* )];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeParam Last;
|
|
|
|
CodeParam Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
|
|
|
s32 NumEntries;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
struct AST_Pragma
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
StringCached Content;
|
|
|
|
};
|
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
|
|
|
};
|
|
|
|
static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_PreprocessCond
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
StringCached Content;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_PreprocessCond is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Specifiers
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
SpecifierT ArrSpecs[ AST::ArrSpecs_Cap ];
|
|
|
|
CodeSpecifiers NextSpecs;
|
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
|
|
|
s32 NumEntries;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Specifiers) == sizeof(AST), "ERROR: AST_Specifier is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#if GEN_EXECUTION_EXPRESSION_SUPPORT
|
|
|
|
struct AST_Stmt
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt) == sizeof(AST), "ERROR: AST_Stmt is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Break
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Break) == sizeof(AST), "ERROR: AST_Stmt_Break is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Case
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Case) == sizeof(AST), "ERROR: AST_Stmt_Case is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Continue
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Continue) == sizeof(AST), "ERROR: AST_Stmt_Continue is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Decl
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Decl) == sizeof(AST), "ERROR: AST_Stmt_Decl is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Do
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Do) == sizeof(AST), "ERROR: AST_Stmt_Do is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Expr
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Expr) == sizeof(AST), "ERROR: AST_Stmt_Expr is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Else
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Else) == sizeof(AST), "ERROR: AST_Stmt_Else is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_If
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_If) == sizeof(AST), "ERROR: AST_Stmt_If is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_For
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_For) == sizeof(AST), "ERROR: AST_Stmt_For is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Goto
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Goto) == sizeof(AST), "ERROR: AST_Stmt_Goto is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Label
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Label) == sizeof(AST), "ERROR: AST_Stmt_Label is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_Switch
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_Switch) == sizeof(AST), "ERROR: AST_Stmt_Switch is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Stmt_While
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
};
|
|
|
|
CodeExpr Prev;
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExpr Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Stmt_While) == sizeof(AST), "ERROR: AST_Stmt_While is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct AST_Struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CodeComment InlineCmt;
|
|
|
|
CodeAttributes Attributes;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_SPECS_ [ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeType ParentType;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PARAMS_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeBody Body;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeType Prev;
|
|
|
|
CodeType Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
AccessSpec ParentAccess;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Struct) == sizeof(AST), "ERROR: AST_Struct is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Template
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
|
|
|
|
CodeParam Params;
|
|
|
|
Code Declaration;
|
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
char _PAD_UNUSED_[ sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not the same size as AST");
|
2024-10-21 19:39:40 -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 {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char _PAD_INLINE_CMT_[ sizeof(AST*) ];
|
|
|
|
CodeAttributes Attributes;
|
|
|
|
CodeSpecifiers Specs;
|
|
|
|
Code QualifierID;
|
|
|
|
// CodeType ReturnType; // Only used for function signatures
|
|
|
|
// CodeParam Params; // Only used for function signatures
|
|
|
|
Code ArrExpr;
|
|
|
|
// CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
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
|
|
|
|
|
|
|
|
struct AST_Type
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_INLINE_CMT_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeAttributes Attributes;
|
|
|
|
CodeSpecifiers Specs;
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeType ReturnType; // Only used for function signatures
|
|
|
|
CodeParam Params; // Only used for function signatures
|
2024-10-21 19:39:40 -07:00
|
|
|
Code ArrExpr;
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
|
|
|
|
b32 IsParamPack;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Typedef
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeComment InlineCmt;
|
|
|
|
char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ];
|
|
|
|
Code UnderlyingType;
|
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
b32 IsFunction;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Typedef) == sizeof(AST), "ERROR: AST_Typedef is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Union
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_INLINE_CMT_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeAttributes Attributes;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeBody Body;
|
2024-10-27 18:44:34 -07:00
|
|
|
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
char _PAD_UNUSED_[ sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Using
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeComment InlineCmt;
|
|
|
|
CodeAttributes Attributes;
|
|
|
|
char _PAD_SPECS_ [ sizeof(AST*) ];
|
|
|
|
CodeType UnderlyingType;
|
|
|
|
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
char _PAD_UNUSED_[ sizeof(u32) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
struct AST_Var
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
union {
|
|
|
|
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
|
2024-10-21 19:39:40 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CodeComment InlineCmt;
|
|
|
|
CodeAttributes Attributes;
|
|
|
|
CodeSpecifiers Specs;
|
|
|
|
CodeType ValueType;
|
|
|
|
Code BitfieldSize;
|
|
|
|
Code Value;
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeVar NextVar;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
Code Prev;
|
|
|
|
Code Next;
|
|
|
|
parser::Token* Tok;
|
|
|
|
Code Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
s32 VarConstructorInit;
|
2024-10-21 19:39:40 -07:00
|
|
|
};
|
2024-10-27 18:44:34 -07:00
|
|
|
static_assert( sizeof(AST_Var) == sizeof(AST), "ERROR: AST_Var is not the same size as AST");
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#pragma endregion AST Types
|
|
|
|
|
|
|
|
#pragma endregion AST
|
|
|
|
|
|
|
|
#pragma region Gen Interface
|
|
|
|
|
|
|
|
// Initialize the library.
|
|
|
|
// This currently just initializes the CodePool.
|
|
|
|
void init();
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
void deinit();
|
|
|
|
|
|
|
|
// Clears the allocations, but doesn't return to the heap, the calls init() again.
|
|
|
|
// Ease of use.
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
// Used internally to retrive or make string allocations.
|
|
|
|
// Strings are stored in a series of string arenas of fixed size (SizePer_StringArena)
|
|
|
|
StringCached get_cached_string( StrC str );
|
|
|
|
|
|
|
|
/*
|
2024-10-27 18:44:34 -07: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-10-21 19:39:40 -07:00
|
|
|
*/
|
|
|
|
Code make_code();
|
|
|
|
|
|
|
|
// Set these before calling gen's init() procedure.
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
void set_allocator_data_arrays ( AllocatorInfo data_array_allocator );
|
|
|
|
void set_allocator_code_pool ( AllocatorInfo pool_allocator );
|
|
|
|
void set_allocator_lexer ( AllocatorInfo lex_allocator );
|
2024-10-21 19:39:40 -07:00
|
|
|
void set_allocator_string_arena( AllocatorInfo string_allocator );
|
|
|
|
void set_allocator_string_table( AllocatorInfo string_allocator );
|
2024-10-27 18:44:34 -07:00
|
|
|
void set_allocator_type_table ( AllocatorInfo type_reg_allocator );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#pragma region Upfront
|
|
|
|
|
|
|
|
CodeAttributes def_attributes( StrC content );
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeComment def_comment ( StrC content );
|
|
|
|
|
|
|
|
CodeClass def_class( StrC name
|
|
|
|
, Code body = NoCode
|
|
|
|
, CodeType parent = NoCode, AccessSpec access = AccessSpec::Default
|
|
|
|
, CodeAttributes attributes = NoCode
|
|
|
|
, ModuleFlag mflags = ModuleFlag::None
|
|
|
|
, CodeType* interfaces = nullptr, s32 num_interfaces = 0 );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
CodeConstructor def_constructor( CodeParam params = NoCode, Code initializer_list = NoCode, Code body = NoCode );
|
|
|
|
|
|
|
|
CodeDefine def_define( StrC name, StrC content );
|
|
|
|
|
|
|
|
CodeDestructor def_destructor( Code body = NoCode, CodeSpecifiers specifiers = NoCode );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeEnum def_enum( StrC name
|
|
|
|
, Code body = NoCode, CodeType type = NoCode
|
|
|
|
, EnumT specifier = EnumRegular, CodeAttributes attributes = NoCode
|
|
|
|
, ModuleFlag mflags = ModuleFlag::None );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeExec def_execution ( StrC content );
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeExtern def_extern_link( StrC name, Code body );
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeFriend def_friend ( Code symbol );
|
|
|
|
|
|
|
|
CodeFn def_function( StrC name
|
|
|
|
, CodeParam params = NoCode, CodeType ret_type = NoCode, Code body = NoCode
|
|
|
|
, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode
|
|
|
|
, ModuleFlag mflags = ModuleFlag::None );
|
|
|
|
|
|
|
|
CodeInclude def_include ( StrC content, bool foreign = false );
|
|
|
|
CodeModule def_module ( StrC name, ModuleFlag mflags = ModuleFlag::None );
|
|
|
|
CodeNS def_namespace( StrC name, Code body, ModuleFlag mflags = ModuleFlag::None );
|
|
|
|
|
|
|
|
CodeOperator def_operator( OperatorT op, StrC nspace
|
|
|
|
, CodeParam params = NoCode, CodeType ret_type = NoCode, Code body = NoCode
|
|
|
|
, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode
|
|
|
|
, ModuleFlag mflags = ModuleFlag::None );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
CodeOpCast def_operator_cast( CodeType type, Code body = NoCode, CodeSpecifiers specs = NoCode );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeParam def_param ( CodeType type, StrC name, Code value = NoCode );
|
2024-10-21 19:39:40 -07:00
|
|
|
CodePragma def_pragma( StrC directive );
|
|
|
|
|
|
|
|
CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content );
|
|
|
|
|
|
|
|
CodeSpecifiers def_specifier( SpecifierT specifier );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeStruct def_struct( StrC name
|
|
|
|
, Code body = NoCode
|
|
|
|
, CodeType parent = NoCode, AccessSpec access = AccessSpec::Default
|
|
|
|
, CodeAttributes attributes = NoCode
|
|
|
|
, ModuleFlag mflags = ModuleFlag::None
|
|
|
|
, CodeType* interfaces = nullptr, s32 num_interfaces = 0 );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
CodeTemplate def_template( CodeParam params, Code definition, ModuleFlag mflags = ModuleFlag::None );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeType def_type ( StrC name, Code arrayexpr = NoCode, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode );
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes = NoCode, ModuleFlag mflags = ModuleFlag::None );
|
|
|
|
|
|
|
|
CodeUnion def_union( StrC name, Code body, CodeAttributes attributes = NoCode, ModuleFlag mflags = ModuleFlag::None );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeUsing def_using( StrC name, CodeType type = NoCode
|
|
|
|
, CodeAttributes attributess = NoCode
|
|
|
|
, ModuleFlag mflags = ModuleFlag::None );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
CodeUsing def_using_namespace( StrC name );
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeVar def_variable( CodeType type, StrC name, Code value = NoCode
|
|
|
|
, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode
|
|
|
|
, ModuleFlag mflags = ModuleFlag::None );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
// Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries.
|
|
|
|
CodeBody def_body( CodeT type );
|
|
|
|
|
|
|
|
// There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num,
|
|
|
|
/// or provide as an array of Code objects.
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeBody def_class_body ( s32 num, ... );
|
|
|
|
CodeBody def_class_body ( s32 num, Code* codes );
|
|
|
|
CodeBody def_enum_body ( s32 num, ... );
|
|
|
|
CodeBody def_enum_body ( s32 num, Code* codes );
|
|
|
|
CodeBody def_export_body ( s32 num, ... );
|
|
|
|
CodeBody def_export_body ( s32 num, Code* codes);
|
2024-10-21 19:39:40 -07:00
|
|
|
CodeBody def_extern_link_body( s32 num, ... );
|
|
|
|
CodeBody def_extern_link_body( s32 num, Code* codes );
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeBody def_function_body ( s32 num, ... );
|
|
|
|
CodeBody def_function_body ( s32 num, Code* codes );
|
|
|
|
CodeBody def_global_body ( s32 num, ... );
|
|
|
|
CodeBody def_global_body ( s32 num, Code* codes );
|
|
|
|
CodeBody def_namespace_body ( s32 num, ... );
|
|
|
|
CodeBody def_namespace_body ( s32 num, Code* codes );
|
|
|
|
CodeParam def_params ( s32 num, ... );
|
|
|
|
CodeParam def_params ( s32 num, CodeParam* params );
|
|
|
|
CodeSpecifiers def_specifiers ( s32 num, ... );
|
|
|
|
CodeSpecifiers def_specifiers ( s32 num, SpecifierT* specs );
|
|
|
|
CodeBody def_struct_body ( s32 num, ... );
|
|
|
|
CodeBody def_struct_body ( s32 num, Code* codes );
|
|
|
|
CodeBody def_union_body ( s32 num, ... );
|
|
|
|
CodeBody def_union_body ( s32 num, Code* codes );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#pragma endregion Upfront
|
|
|
|
|
|
|
|
#pragma region Parsing
|
|
|
|
|
|
|
|
// TODO(Ed) : Implmeent the new parser API design.
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
namespace parser {
|
|
|
|
struct StackNode
|
|
|
|
{
|
|
|
|
StackNode* Prev;
|
|
|
|
|
|
|
|
Token Start;
|
|
|
|
Token Name; // The name of the AST node (if parsed)
|
|
|
|
StrC FailedProc; // The name of the procedure that failed
|
|
|
|
};
|
|
|
|
// Stack nodes are allocated the error's allocator
|
|
|
|
|
|
|
|
struct Error
|
|
|
|
{
|
|
|
|
String message;
|
|
|
|
StackNode* context_stack;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ParseInfo
|
2024-10-27 18:44:34 -07:00
|
|
|
{
|
2024-10-21 19:39:40 -07:00
|
|
|
Arena FileMem;
|
|
|
|
Arena TokMem;
|
|
|
|
Arena CodeMem;
|
|
|
|
|
|
|
|
FileContents FileContent;
|
|
|
|
Array<parser::Token> Tokens;
|
|
|
|
Array<parser::Error> Errors;
|
|
|
|
// Errors are allocated to a dedicated general arena.
|
2024-10-27 18:44:34 -07:00
|
|
|
};
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
CodeBody parse_file( StrC path );
|
|
|
|
#endif
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
CodeClass parse_class ( StrC class_def );
|
|
|
|
CodeConstructor parse_constructor ( StrC constructor_def );
|
|
|
|
CodeDestructor parse_destructor ( StrC destructor_def );
|
|
|
|
CodeEnum parse_enum ( StrC enum_def );
|
|
|
|
CodeBody parse_export_body ( StrC export_def );
|
|
|
|
CodeExtern parse_extern_link ( StrC exten_link_def );
|
|
|
|
CodeFriend parse_friend ( StrC friend_def );
|
|
|
|
CodeFn parse_function ( StrC fn_def );
|
|
|
|
CodeBody parse_global_body ( StrC body_def );
|
|
|
|
CodeNS parse_namespace ( StrC namespace_def );
|
|
|
|
CodeOperator parse_operator ( StrC operator_def );
|
|
|
|
CodeOpCast parse_operator_cast( StrC operator_def );
|
|
|
|
CodeStruct parse_struct ( StrC struct_def );
|
|
|
|
CodeTemplate parse_template ( StrC template_def );
|
|
|
|
CodeType parse_type ( StrC type_def );
|
|
|
|
CodeTypedef parse_typedef ( StrC typedef_def );
|
|
|
|
CodeUnion parse_union ( StrC union_def );
|
|
|
|
CodeUsing parse_using ( StrC using_def );
|
|
|
|
CodeVar parse_variable ( StrC var_def );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#pragma endregion Parsing
|
|
|
|
|
|
|
|
#pragma region Untyped text
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va );
|
2024-10-21 19:39:40 -07:00
|
|
|
//! Do not use directly. Use the token_fmt macro instead.
|
2024-10-27 18:44:34 -07:00
|
|
|
StrC token_fmt_impl( ssize, ... );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
Code untyped_str ( StrC content);
|
|
|
|
Code untyped_fmt ( char const* fmt, ... );
|
2024-10-21 19:39:40 -07:00
|
|
|
Code untyped_token_fmt( char const* fmt, s32 num_tokens, ... );
|
|
|
|
|
|
|
|
#pragma endregion Untyped text
|
|
|
|
|
|
|
|
#pragma endregion Gen Interface
|
|
|
|
|
|
|
|
#pragma region Inlines
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
void AST::append( AST* other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other->Parent )
|
|
|
|
other = other->duplicate();
|
|
|
|
|
|
|
|
other->Parent = this;
|
|
|
|
|
|
|
|
if ( Front == nullptr )
|
|
|
|
{
|
|
|
|
Front = other;
|
|
|
|
Back = other;
|
|
|
|
|
|
|
|
NumEntries++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
AST*
|
|
|
|
Current = Back;
|
2024-10-21 19:39:40 -07:00
|
|
|
Current->Next = other;
|
|
|
|
other->Prev = Current;
|
|
|
|
Back = other;
|
|
|
|
NumEntries++;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
Code& AST::entry( u32 idx )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
AST** current = & Front;
|
2024-10-21 19:39:40 -07:00
|
|
|
while ( idx >= 0 && current != nullptr )
|
|
|
|
{
|
|
|
|
if ( idx == 0 )
|
2024-10-27 18:44:34 -07:00
|
|
|
return * rcast( Code*, current);
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
current = & ( * current )->Next;
|
2024-10-21 19:39:40 -07:00
|
|
|
idx--;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
return * rcast( Code*, current);
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
bool AST::has_entries()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return NumEntries > 0;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
char const* AST::type_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ECode::to_str( Type );
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
AST::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { this };
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
Code& Code::operator ++()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast )
|
|
|
|
ast = ast->Next;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
void CodeClass::add_interface( CodeType type )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
CodeType possible_slot = ast->ParentType;
|
|
|
|
if ( possible_slot.ast )
|
|
|
|
{
|
|
|
|
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
|
|
|
ast->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.
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( possible_slot.ast != nullptr )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
possible_slot.ast = (AST_Type*) possible_slot->Next.ast;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
possible_slot.ast = type.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
void CodeParam::append( CodeParam other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
AST* self = (AST*) ast;
|
|
|
|
AST* entry = (AST*) other.ast;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
if ( entry->Parent )
|
|
|
|
entry = entry->duplicate();
|
|
|
|
|
|
|
|
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-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
CodeParam CodeParam::get( s32 idx )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
CodeParam param = *this;
|
|
|
|
do
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
if ( ! ++ param )
|
2024-10-21 19:39:40 -07:00
|
|
|
return { nullptr };
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
param = { (AST_Param*) param.raw()->Next };
|
|
|
|
}
|
|
|
|
while ( --idx );
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
return param;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
bool CodeParam::has_entries()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast->NumEntries > 0;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
CodeParam& CodeParam::operator ++()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
ast = ast->Next.ast;
|
2024-10-27 18:44:34 -07:00
|
|
|
return * this;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
void CodeStruct::add_interface( CodeType type )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
CodeType possible_slot = ast->ParentType;
|
|
|
|
if ( possible_slot.ast )
|
|
|
|
{
|
|
|
|
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
|
|
|
ast->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.
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( possible_slot.ast != nullptr )
|
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
possible_slot.ast = (AST_Type*) possible_slot->Next.ast;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
possible_slot.ast = type.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
CodeBody def_body( CodeT type )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
using namespace ECode;
|
2024-10-27 18:44:34 -07:00
|
|
|
case Class_Body:
|
|
|
|
case Enum_Body:
|
|
|
|
case Export_Body:
|
|
|
|
case Extern_Linkage:
|
|
|
|
case Function_Body:
|
|
|
|
case Global_Body:
|
|
|
|
case Namespace_Body:
|
|
|
|
case Struct_Body:
|
|
|
|
case Union_Body:
|
2024-10-21 19:39:40 -07:00
|
|
|
break;
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
default:
|
|
|
|
log_failure( "def_body: Invalid type %s", (char const*)ECode::to_str(type) );
|
2024-10-21 19:39:40 -07:00
|
|
|
return (CodeBody)Code::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
Code
|
|
|
|
result = make_code();
|
2024-10-21 19:39:40 -07:00
|
|
|
result->Type = type;
|
|
|
|
return (CodeBody)result;
|
|
|
|
}
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
inline
|
|
|
|
StrC token_fmt_impl( ssize num, ... )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
2024-10-27 18:44:34 -07:00
|
|
|
local_persist thread_local
|
|
|
|
char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
2024-10-21 19:39:40 -07:00
|
|
|
mem_set( buf, 0, GEN_PRINTF_MAXLEN );
|
|
|
|
|
|
|
|
va_list va;
|
2024-10-27 18:44:34 -07:00
|
|
|
va_start(va, num );
|
|
|
|
ssize result = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num, va);
|
|
|
|
va_end(va);
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
return { result, buf };
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma region generated code inline implementation
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* Code::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code Code::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool Code::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool Code::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void Code::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Code& Code::operator=( Code other )
|
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Code::operator==( Code other )
|
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Code::operator!=( Code other )
|
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Code::operator bool()
|
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline char const* CodeBody::debug_str()
|
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Code CodeBody::duplicate()
|
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeBody::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeBody::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeBody::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeBody& CodeBody::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeBody::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeBody::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeBody::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeAttributes::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeAttributes::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeAttributes::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeAttributes::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeAttributes::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeAttributes& CodeAttributes::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeAttributes::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeAttributes::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeAttributes::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeAttributes::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeAttributes::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Attributes* CodeAttributes::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeComment::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeComment::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeComment::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeComment::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeComment::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeComment& CodeComment::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeComment::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeComment::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeComment::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeComment::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeComment::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Comment* CodeComment::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeConstructor::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeConstructor::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeConstructor::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeConstructor::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeConstructor::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeConstructor& CodeConstructor::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeConstructor::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeConstructor::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeConstructor::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeConstructor::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeConstructor::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Constructor* CodeConstructor::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeClass::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeClass::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeClass::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeClass::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeClass::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeClass& CodeClass::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeClass::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeClass::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeClass::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeDefine::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeDefine::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeDefine::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeDefine::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeDefine::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeDefine& CodeDefine::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeDefine::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeDefine::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeDefine::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeDefine::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeDefine::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Define* CodeDefine::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeDestructor::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeDestructor::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeDestructor::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeDestructor::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeDestructor::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeDestructor& CodeDestructor::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeDestructor::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeDestructor::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeDestructor::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeDestructor::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeDestructor::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Destructor* CodeDestructor::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeEnum::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeEnum::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeEnum::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeEnum::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeEnum::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeEnum& CodeEnum::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeEnum::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeEnum::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeEnum::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeEnum::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeEnum::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Enum* CodeEnum::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeExec::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeExec::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeExec::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeExec::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeExec::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeExec& CodeExec::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeExec::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeExec::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeExec::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeExec::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeExec::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Exec* CodeExec::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeExtern::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeExtern::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeExtern::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeExtern::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeExtern::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeExtern& CodeExtern::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeExtern::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeExtern::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeExtern::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeExtern::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeExtern::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Extern* CodeExtern::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeFriend::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeFriend::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeFriend::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeFriend::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeFriend::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeFriend& CodeFriend::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeFriend::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeFriend::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeFriend::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeFriend::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeFriend::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Friend* CodeFriend::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeFn::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeFn::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeFn::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeFn::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeFn::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeFn& CodeFn::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeFn::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeFn::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeFn::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeFn::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeFn::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Fn* CodeFn::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeInclude::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeInclude::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeInclude::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeInclude::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeInclude::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeInclude& CodeInclude::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeInclude::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeInclude::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeInclude::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeInclude::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeInclude::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Include* CodeInclude::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeModule::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeModule::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeModule::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeModule::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeModule::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeModule& CodeModule::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeModule::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeModule::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeModule::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeModule::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeModule::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Module* CodeModule::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeNS::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeNS::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeNS::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeNS::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeNS::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeNS& CodeNS::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeNS::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeNS::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeNS::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeNS::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeNS::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_NS* CodeNS::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeOperator::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeOperator::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeOperator::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeOperator::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeOperator::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeOperator& CodeOperator::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeOperator::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeOperator::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeOperator::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeOperator::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeOperator::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Operator* CodeOperator::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeOpCast::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeOpCast::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeOpCast::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeOpCast::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeOpCast::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeOpCast& CodeOpCast::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeOpCast::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeOpCast::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeOpCast::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeOpCast::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeOpCast::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_OpCast* CodeOpCast::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeParam::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeParam::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeParam::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeParam::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeParam::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeParam& CodeParam::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeParam::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeParam::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeParam::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodePragma::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodePragma::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodePragma::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodePragma::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodePragma::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodePragma& CodePragma::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodePragma::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodePragma::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodePragma::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodePragma::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodePragma::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Pragma* CodePragma::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodePreprocessCond::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodePreprocessCond::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodePreprocessCond::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodePreprocessCond::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodePreprocessCond::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodePreprocessCond& CodePreprocessCond::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodePreprocessCond::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodePreprocessCond::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodePreprocessCond::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodePreprocessCond::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodePreprocessCond::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_PreprocessCond* CodePreprocessCond::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeSpecifiers::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeSpecifiers::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeSpecifiers::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeSpecifiers::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeSpecifiers::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeSpecifiers& CodeSpecifiers::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeSpecifiers::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeSpecifiers::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeSpecifiers::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeStruct::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeStruct::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeStruct::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeStruct::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeStruct::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeStruct& CodeStruct::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeStruct::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeStruct::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeStruct::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeTemplate::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeTemplate::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeTemplate::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeTemplate::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeTemplate::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeTemplate& CodeTemplate::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeTemplate::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeTemplate::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeTemplate::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeTemplate::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeTemplate::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Template* CodeTemplate::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeType::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeType::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeType::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeType::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeType::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeType& CodeType::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeType::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeType::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeType::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeType::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeType::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Type* CodeType::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeTypedef::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeTypedef::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeTypedef::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeTypedef::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeTypedef::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeTypedef& CodeTypedef::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeTypedef::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeTypedef::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeTypedef::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeTypedef::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeTypedef::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Typedef* CodeTypedef::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeUnion::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeUnion::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeUnion::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeUnion::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeUnion::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeUnion& CodeUnion::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeUnion::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeUnion::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeUnion::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeUnion::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeUnion::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Union* CodeUnion::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeUsing::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeUsing::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeUsing::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeUsing::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeUsing::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeUsing& CodeUsing::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeUsing::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeUsing::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeUsing::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeUsing::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeUsing::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Using* CodeUsing::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline char const* CodeVar::debug_str()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return "Code::debug_str: AST is null!";
|
|
|
|
return rcast( AST*, ast )->debug_str();
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code CodeVar::duplicate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::duplicate: Cannot duplicate code, AST is null!" );
|
|
|
|
return Code::Invalid;
|
|
|
|
}
|
|
|
|
return { rcast( AST*, ast )->duplicate() };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeVar::is_equal( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr || other.ast == nullptr )
|
|
|
|
{
|
2024-10-25 02:04:11 -07:00
|
|
|
return ast == nullptr && other.ast == nullptr;
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
return rcast( AST*, ast )->is_equal( other.ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeVar::is_valid()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != nullptr && rcast( AST*, ast )->Type != CodeT::Invalid;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline void CodeVar::set_global()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Code::set_global: Cannot set code as global, AST is null!" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rcast( AST*, ast )->Parent = Code::Global.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeVar& CodeVar::operator=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( other.ast && other->Parent )
|
|
|
|
{
|
|
|
|
ast = rcast( decltype( ast ), other.ast->duplicate() );
|
|
|
|
rcast( AST*, ast )->Parent = nullptr;
|
|
|
|
}
|
|
|
|
ast = rcast( decltype( ast ), other.ast );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeVar::operator==( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast == other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline bool CodeVar::operator!=( Code other )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return (AST*)ast != other.ast;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeVar::operator bool()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return ast != nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST* CodeVar::raw()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return rcast( AST*, ast );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline CodeVar::operator Code()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return *rcast( Code*, this );
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST_Var* CodeVar::operator->()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
if ( ast == nullptr )
|
|
|
|
{
|
|
|
|
log_failure( "Attempt to dereference a nullptr!" );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma endregion generated code inline implementation
|
|
|
|
|
|
|
|
#pragma region generated AST/Code cast implementation
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeBody()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Body*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeBody() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Body*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeAttributes()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Attributes*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeAttributes() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Attributes*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeComment()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Comment*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeComment() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Comment*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeConstructor()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Constructor*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeConstructor() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Constructor*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeClass()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Class*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeClass() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Class*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeDefine()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Define*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeDefine() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Define*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeDestructor()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Destructor*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeDestructor() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Destructor*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeEnum()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Enum*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeEnum() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Enum*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeExec()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Exec*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeExec() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Exec*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeExtern()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Extern*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeExtern() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Extern*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeFriend()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Friend*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeFriend() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Friend*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeFn()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Fn*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeFn() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Fn*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeInclude()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Include*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeInclude() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Include*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeModule()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Module*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeModule() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Module*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeNS()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_NS*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeNS() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_NS*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeOperator()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Operator*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeOperator() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Operator*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeOpCast()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_OpCast*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeOpCast() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_OpCast*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeParam()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Param*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeParam() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Param*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodePragma()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Pragma*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodePragma() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Pragma*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodePreprocessCond()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_PreprocessCond*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodePreprocessCond() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_PreprocessCond*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeSpecifiers()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Specifiers*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeSpecifiers() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Specifiers*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeStruct()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Struct*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeStruct() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Struct*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeTemplate()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Template*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeTemplate() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Template*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeType()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Type*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeType() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Type*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeTypedef()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Typedef*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeTypedef() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Typedef*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeUnion()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Union*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeUnion() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Union*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeUsing()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Using*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeUsing() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Using*)ast };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline AST::operator CodeVar()
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { rcast( AST_Var*, this ) };
|
|
|
|
}
|
|
|
|
|
2024-10-25 02:04:11 -07:00
|
|
|
inline Code::operator CodeVar() const
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
return { (AST_Var*)ast };
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma endregion generated AST / Code cast implementation
|
|
|
|
|
|
|
|
#pragma endregion Inlines
|
|
|
|
|
|
|
|
#pragma region Constants
|
|
|
|
|
|
|
|
#ifndef GEN_GLOBAL_BUCKET_SIZE
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_GLOBAL_BUCKET_SIZE megabytes(8)
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
#ifndef GEN_CODEPOOL_NUM_BLOCKS
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_CODEPOOL_NUM_BLOCKS kilobytes(16)
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
#ifndef GEN_SIZE_PER_STRING_ARENA
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_SIZE_PER_STRING_ARENA megabytes(1)
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
#ifndef GEN_MAX_COMMENT_LINE_LENGTH
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_MAX_COMMENT_LINE_LENGTH 1024
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
#ifndef GEN_MAX_NAME_LENGTH
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_MAX_NAME_LENGTH 128
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
#ifndef GEN_MAX_UNTYPED_STR_LENGTH
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_MAX_UNTYPED_STR_LENGTH megabytes(1)
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
#ifndef GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE kilobytes(4)
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
#ifndef GEN_LEX_ALLOCATOR_SIZE
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_LEX_ALLOCATOR_SIZE megabytes(4)
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
#ifndef GEN_BUILDER_STR_BUFFER_RESERVE
|
2024-10-27 18:44:34 -07:00
|
|
|
# define GEN_BUILDER_STR_BUFFER_RESERVE megabytes(2)
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// These constexprs are used for allocation behavior of data structures
|
|
|
|
// or string handling while constructing or serializing.
|
|
|
|
// Change them to suit your needs.
|
|
|
|
|
|
|
|
constexpr s32 InitSize_DataArrays = 16;
|
|
|
|
|
|
|
|
// NOTE: This limits the maximum size of an allocation
|
|
|
|
// If you are generating a string larger than this, increase the size of the bucket here.
|
2024-10-27 18:44:34 -07:00
|
|
|
constexpr usize Global_BucketSize = GEN_GLOBAL_BUCKET_SIZE;
|
2024-10-21 19:39:40 -07:00
|
|
|
constexpr s32 CodePool_NumBlocks = GEN_CODEPOOL_NUM_BLOCKS;
|
|
|
|
constexpr s32 SizePer_StringArena = GEN_SIZE_PER_STRING_ARENA;
|
|
|
|
|
|
|
|
constexpr s32 MaxCommentLineLength = GEN_MAX_COMMENT_LINE_LENGTH;
|
|
|
|
constexpr s32 MaxNameLength = GEN_MAX_NAME_LENGTH;
|
|
|
|
constexpr s32 MaxUntypedStrLength = GEN_MAX_UNTYPED_STR_LENGTH;
|
2024-10-27 18:44:34 -07:00
|
|
|
constexpr s32 TokenFmt_TokenMap_MemSize = GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE;
|
2024-10-21 19:39:40 -07:00
|
|
|
constexpr s32 LexAllocator_Size = GEN_LEX_ALLOCATOR_SIZE;
|
|
|
|
constexpr s32 Builder_StrBufferReserve = GEN_BUILDER_STR_BUFFER_RESERVE;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
extern CodeParam param_varadic;
|
|
|
|
|
|
|
|
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;
|
|
|
|
extern CodeSpecifiers spec_FORCEINLINE;
|
|
|
|
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-10-27 18:44:34 -07:00
|
|
|
extern CodeType t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance)
|
2024-10-21 19:39:40 -07:00
|
|
|
extern CodeType t_auto;
|
|
|
|
extern CodeType t_void;
|
|
|
|
extern CodeType t_int;
|
|
|
|
extern CodeType t_bool;
|
|
|
|
extern CodeType t_char;
|
|
|
|
extern CodeType t_wchar_t;
|
|
|
|
extern CodeType t_class;
|
|
|
|
extern CodeType t_typename;
|
|
|
|
|
|
|
|
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
2024-10-27 18:44:34 -07:00
|
|
|
// Predefined typename codes. Are set to readonly and are setup during gen::init()
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern CodeType t_b32;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern CodeType t_s8;
|
|
|
|
extern CodeType t_s16;
|
|
|
|
extern CodeType t_s32;
|
|
|
|
extern CodeType t_s64;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern CodeType t_u8;
|
|
|
|
extern CodeType t_u16;
|
|
|
|
extern CodeType t_u32;
|
|
|
|
extern CodeType t_u64;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern CodeType t_ssize;
|
|
|
|
extern CodeType t_usize;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern CodeType t_f32;
|
|
|
|
extern CodeType t_f64;
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#pragma endregion Constants
|
|
|
|
|
|
|
|
#pragma region Macros
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
# define gen_main main
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
# define __ NoCode
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
// 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_ ) { sizeof(stringize( Id_ )) - 1, stringize(Id_) }
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
// Same as name just used to indicate intention of literal for code instead of names.
|
|
|
|
# define code( ... ) { sizeof(stringize(__VA_ARGS__)) - 1, stringize( __VA_ARGS__ ) }
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
# define args( ... ) num_args( __VA_ARGS__ ), __VA_ARGS__
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
# define code_str( ... ) GEN_NS untyped_str( code( __VA_ARGS__ ) )
|
|
|
|
# define code_fmt( ... ) GEN_NS untyped_str( token_fmt( __VA_ARGS__ ) )
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
// Takes a format string (char const*) and a list of tokens (StrC) and returns a StrC of the formatted string.
|
|
|
|
# define token_fmt( ... ) GEN_NS token_fmt_impl( (num_args( __VA_ARGS__ ) + 1) / 2, __VA_ARGS__ )
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#pragma endregion Macros
|
|
|
|
|
|
|
|
// Used by the lexer to persistently treat all these identifiers as preprocessor defines.
|
|
|
|
// Populate with strings via gen::get_cached_string.
|
|
|
|
// Functional defines must have format: id( ;at minimum to indicate that the define is only valid with arguments.
|
2024-10-27 18:44:34 -07:00
|
|
|
extern Array< StringCached > PreprocessorDefines;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#ifdef GEN_EXPOSE_BACKEND
|
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
// Global allocator used for data with process lifetime.
|
|
|
|
extern AllocatorInfo GlobalAllocator;
|
|
|
|
extern Array< Arena > Global_AllocatorBuckets;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern Array< Pool > CodePools;
|
|
|
|
extern Array< Arena > StringArenas;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern StringTable StringCache;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern Arena LexArena;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-10-27 18:44:34 -07:00
|
|
|
extern AllocatorInfo Allocator_DataArrays;
|
|
|
|
extern AllocatorInfo Allocator_CodePool;
|
|
|
|
extern AllocatorInfo Allocator_Lexer;
|
|
|
|
extern AllocatorInfo Allocator_StringArena;
|
|
|
|
extern AllocatorInfo Allocator_StringTable;
|
|
|
|
extern AllocatorInfo Allocator_TypeTable;
|
2024-10-21 19:39:40 -07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
GEN_NS_END
|
|
|
|
|
|
|
|
#ifdef __clang__
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma clang diagnostic pop
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2024-10-27 18:44:34 -07:00
|
|
|
# pragma GCC diagnostic pop
|
2024-10-21 19:39:40 -07:00
|
|
|
#endif
|