2023-08-28 20:46:50 -07:00
|
|
|
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
2023-08-21 17:30:13 -07:00
|
|
|
#pragma once
|
2023-08-21 20:02:20 -07:00
|
|
|
#include "types.hpp"
|
2023-08-21 20:28:39 -07:00
|
|
|
#include "gen/ecode.hpp"
|
|
|
|
#include "gen/eoperator.hpp"
|
|
|
|
#include "gen/especifier.hpp"
|
2023-08-28 20:46:50 -07:00
|
|
|
#endif
|
2023-08-21 17:30:13 -07:00
|
|
|
|
2023-08-03 08:01:43 -07:00
|
|
|
struct AST;
|
|
|
|
struct AST_Body;
|
|
|
|
struct AST_Attributes;
|
|
|
|
struct AST_Comment;
|
2023-08-07 00:10:45 -07:00
|
|
|
struct AST_Constructor;
|
2023-11-21 20:36:56 -08:00
|
|
|
// struct AST_BaseClass;
|
2023-08-03 08:01:43 -07:00
|
|
|
struct AST_Class;
|
|
|
|
struct AST_Define;
|
2023-08-07 00:10:45 -07:00
|
|
|
struct AST_Destructor;
|
2023-08-03 08:01:43 -07:00
|
|
|
struct AST_Enum;
|
|
|
|
struct AST_Exec;
|
|
|
|
struct AST_Extern;
|
|
|
|
struct AST_Include;
|
|
|
|
struct AST_Friend;
|
|
|
|
struct AST_Fn;
|
|
|
|
struct AST_Module;
|
2023-08-06 11:58:43 -07:00
|
|
|
struct AST_NS;
|
2023-08-03 08:01:43 -07:00
|
|
|
struct AST_Operator;
|
|
|
|
struct AST_OpCast;
|
|
|
|
struct AST_Param;
|
|
|
|
struct AST_Pragma;
|
|
|
|
struct AST_PreprocessCond;
|
|
|
|
struct AST_Specifiers;
|
2023-11-21 17:07:49 -08:00
|
|
|
|
|
|
|
#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;
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
struct AST_Stmt_Expr; // TODO(Ed) : Is this distinction needed? (Should it be a flag instead?)
|
|
|
|
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
|
|
|
|
|
2023-08-03 08:01:43 -07:00
|
|
|
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;
|
2023-11-21 20:36:56 -08:00
|
|
|
// struct CodeBaseClass;
|
2023-08-03 08:01:43 -07:00
|
|
|
struct CodeComment;
|
|
|
|
struct CodeClass;
|
2023-09-11 20:22:53 -07:00
|
|
|
struct CodeConstructor;
|
2023-08-03 08:01:43 -07:00
|
|
|
struct CodeDefine;
|
2023-09-11 20:22:53 -07:00
|
|
|
struct CodeDestructor;
|
2023-08-03 08:01:43 -07:00
|
|
|
struct CodeEnum;
|
|
|
|
struct CodeExec;
|
|
|
|
struct CodeExtern;
|
|
|
|
struct CodeInclude;
|
|
|
|
struct CodeFriend;
|
|
|
|
struct CodeFn;
|
|
|
|
struct CodeModule;
|
2023-08-06 11:58:43 -07:00
|
|
|
struct CodeNS;
|
2023-08-03 08:01:43 -07:00
|
|
|
struct CodeOperator;
|
|
|
|
struct CodeOpCast;
|
|
|
|
struct CodeParam;
|
|
|
|
struct CodePreprocessCond;
|
|
|
|
struct CodePragma;
|
|
|
|
struct CodeSpecifiers;
|
2023-11-21 17:07:49 -08:00
|
|
|
|
|
|
|
#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;
|
|
|
|
struct CodeExpr_AMS; // Access Member Symbol
|
|
|
|
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
|
|
|
|
|
2023-08-03 08:01:43 -07:00
|
|
|
struct CodeStruct;
|
|
|
|
struct CodeTemplate;
|
|
|
|
struct CodeType;
|
|
|
|
struct CodeTypedef;
|
|
|
|
struct CodeUnion;
|
|
|
|
struct CodeUsing;
|
|
|
|
struct CodeVar;
|
|
|
|
|
2023-11-21 17:07:49 -08:00
|
|
|
namespace parser
|
2023-09-25 13:42:29 -07:00
|
|
|
{
|
|
|
|
struct Token;
|
|
|
|
}
|
2023-09-25 09:12:11 -07:00
|
|
|
|
2023-08-03 08:01:43 -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).
|
|
|
|
*/
|
|
|
|
struct Code
|
|
|
|
{
|
|
|
|
# pragma region Statics
|
|
|
|
// Used to identify ASTs that should always be duplicated. (Global constant ASTs)
|
|
|
|
static Code Global;
|
|
|
|
|
|
|
|
// Used to identify invalid generated code.
|
|
|
|
static Code Invalid;
|
|
|
|
# pragma endregion Statics
|
|
|
|
|
2023-09-25 09:12:11 -07:00
|
|
|
# define Using_Code( Typename ) \
|
2023-08-03 08:01:43 -07:00
|
|
|
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 ); \
|
|
|
|
operator bool();
|
|
|
|
|
|
|
|
Using_Code( Code );
|
|
|
|
|
|
|
|
template< class Type >
|
2023-11-19 17:34:46 -08:00
|
|
|
forceinline Type cast()
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
|
|
|
return * rcast( Type*, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
AST* operator ->()
|
|
|
|
{
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
Code& operator ++();
|
2023-11-20 12:09:01 -08:00
|
|
|
|
2023-11-19 17:34:46 -08:00
|
|
|
// TODO(Ed) : Remove this overload.
|
2023-11-20 12:09:01 -08:00
|
|
|
auto& operator*()
|
|
|
|
{
|
|
|
|
local_persist thread_local
|
|
|
|
Code NullRef = { nullptr };
|
|
|
|
|
|
|
|
if ( ast == nullptr )
|
|
|
|
return NullRef;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2023-08-03 08:01:43 -07:00
|
|
|
|
|
|
|
AST* ast;
|
|
|
|
|
|
|
|
#ifdef GEN_ENFORCE_STRONG_CODE_TYPES
|
|
|
|
# define operator explicit operator
|
|
|
|
#endif
|
2023-11-21 20:36:56 -08:00
|
|
|
operator CodeBody() const;
|
2023-08-03 08:01:43 -07:00
|
|
|
operator CodeAttributes() const;
|
2023-11-21 20:36:56 -08:00
|
|
|
// operator CodeBaseClass() const;
|
2023-08-03 08:01:43 -07:00
|
|
|
operator CodeComment() const;
|
|
|
|
operator CodeClass() const;
|
2023-11-21 20:36:56 -08:00
|
|
|
operator CodeConstructor() const;
|
2023-08-03 08:01:43 -07:00
|
|
|
operator CodeDefine() const;
|
2023-11-21 20:36:56 -08:00
|
|
|
operator CodeDestructor() const;
|
2023-08-03 08:01:43 -07:00
|
|
|
operator CodeExec() const;
|
|
|
|
operator CodeEnum() const;
|
|
|
|
operator CodeExtern() const;
|
|
|
|
operator CodeInclude() const;
|
|
|
|
operator CodeFriend() const;
|
|
|
|
operator CodeFn() const;
|
|
|
|
operator CodeModule() const;
|
2023-08-06 11:58:43 -07:00
|
|
|
operator CodeNS() const;
|
2023-08-03 08:01:43 -07:00
|
|
|
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;
|
|
|
|
#undef operator
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Code_POD
|
|
|
|
{
|
|
|
|
AST* ast;
|
|
|
|
};
|
|
|
|
|
|
|
|
static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" );
|
|
|
|
|
|
|
|
// Desired width of the AST data structure.
|
2023-09-25 13:42:29 -07:00
|
|
|
constexpr int const AST_POD_Size = 128;
|
2023-08-03 08:01:43 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
Simple AST POD with functionality to seralize into C++ syntax.
|
|
|
|
*/
|
|
|
|
struct AST
|
|
|
|
{
|
|
|
|
# pragma region Member Functions
|
|
|
|
void append ( AST* other );
|
|
|
|
char const* debug_str ();
|
|
|
|
AST* duplicate ();
|
|
|
|
Code& entry ( u32 idx );
|
|
|
|
bool has_entries();
|
|
|
|
bool is_equal ( AST* other );
|
|
|
|
char const* type_str();
|
|
|
|
bool validate_body();
|
|
|
|
|
2023-11-20 12:09:01 -08:00
|
|
|
String to_string();
|
|
|
|
|
|
|
|
neverinline
|
|
|
|
void to_string( String& result );
|
2023-08-21 17:30:13 -07:00
|
|
|
|
2023-08-03 08:01:43 -07:00
|
|
|
template< class Type >
|
2023-11-19 17:34:46 -08:00
|
|
|
forceinline Type cast()
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
|
|
|
return * this;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator Code();
|
|
|
|
operator CodeBody();
|
|
|
|
operator CodeAttributes();
|
2023-11-21 20:36:56 -08:00
|
|
|
// operator CodeBaseClass();
|
2023-08-03 08:01:43 -07:00
|
|
|
operator CodeComment();
|
2023-08-07 00:10:45 -07:00
|
|
|
operator CodeConstructor();
|
|
|
|
operator CodeDestructor();
|
2023-08-03 08:01:43 -07:00
|
|
|
operator CodeClass();
|
|
|
|
operator CodeDefine();
|
|
|
|
operator CodeEnum();
|
|
|
|
operator CodeExec();
|
|
|
|
operator CodeExtern();
|
|
|
|
operator CodeInclude();
|
|
|
|
operator CodeFriend();
|
|
|
|
operator CodeFn();
|
|
|
|
operator CodeModule();
|
2023-08-06 11:58:43 -07:00
|
|
|
operator CodeNS();
|
2023-08-03 08:01:43 -07:00
|
|
|
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();
|
|
|
|
# pragma endregion Member Functions
|
|
|
|
|
|
|
|
constexpr static
|
2023-09-25 09:12:11 -07:00
|
|
|
int ArrSpecs_Cap =
|
2023-08-03 08:01:43 -07:00
|
|
|
(
|
|
|
|
AST_POD_Size
|
2023-09-25 13:42:29 -07:00
|
|
|
- sizeof(AST*) * 3
|
2023-11-21 17:07:49 -08:00
|
|
|
- sizeof(parser::Token*)
|
2023-09-25 13:42:29 -07:00
|
|
|
- sizeof(AST*)
|
|
|
|
- sizeof(StringCached)
|
|
|
|
- sizeof(CodeT)
|
2023-08-03 08:01:43 -07:00
|
|
|
- sizeof(ModuleFlag)
|
2023-09-25 09:12:11 -07:00
|
|
|
- sizeof(int)
|
2023-08-03 08:01:43 -07:00
|
|
|
)
|
2023-09-25 13:42:29 -07:00
|
|
|
/ sizeof(int) - 1; // -1 for 4 extra bytes
|
2023-08-03 08:01:43 -07:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct
|
|
|
|
{
|
2023-09-06 00:06:30 -07:00
|
|
|
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
2023-09-04 22:44:04 -07:00
|
|
|
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
|
|
|
AST* Specs; // Destructor, Function, Operator, Typename, Variable
|
2023-08-03 08:01:43 -07:00
|
|
|
union {
|
2023-08-22 21:05:58 -07:00
|
|
|
AST* InitializerList; // Constructor
|
2023-09-04 22:44:04 -07:00
|
|
|
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
2023-09-06 00:06:30 -07:00
|
|
|
AST* ReturnType; // Function, Operator, Typename
|
2023-08-07 00:10:45 -07:00
|
|
|
AST* UnderlyingType; // Enum, Typedef
|
|
|
|
AST* ValueType; // Parameter, Variable
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
|
|
|
union {
|
2024-04-17 14:40:32 -07:00
|
|
|
AST* Macro; // Parameter
|
2023-09-06 00:06:30 -07:00
|
|
|
AST* BitfieldSize; // Variable (Class/Struct Data Member)
|
|
|
|
AST* Params; // Constructor, Function, Operator, Template, Typename
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
|
|
|
union {
|
2023-09-04 22:44:04 -07:00
|
|
|
AST* ArrExpr; // Typename
|
2024-04-17 14:40:32 -07:00
|
|
|
AST* Body; // Class, Constructr, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
2023-09-04 22:44:04 -07:00
|
|
|
AST* Declaration; // Friend, Template
|
|
|
|
AST* Value; // Parameter, Variable
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
2023-09-06 00:06:30 -07:00
|
|
|
union {
|
|
|
|
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
2023-09-25 14:48:16 -07:00
|
|
|
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
2023-09-06 00:06:30 -07:00
|
|
|
};
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
2023-09-04 22:44:04 -07:00
|
|
|
StringCached Content; // Attributes, Comment, Execution, Include
|
2023-09-11 20:22:53 -07:00
|
|
|
struct {
|
2023-09-25 13:42:29 -07:00
|
|
|
SpecifierT ArrSpecs[ArrSpecs_Cap]; // Specifiers
|
2023-11-19 17:34:46 -08:00
|
|
|
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
2023-09-11 20:22:53 -07:00
|
|
|
};
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
|
|
|
union {
|
|
|
|
AST* Prev;
|
|
|
|
AST* Front;
|
|
|
|
AST* Last;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
AST* Next;
|
|
|
|
AST* Back;
|
|
|
|
};
|
2023-11-21 17:07:49 -08:00
|
|
|
parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
2023-08-03 08:01:43 -07:00
|
|
|
AST* Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2023-11-20 12:09:01 -08:00
|
|
|
// CodeFlag CodeFlags;
|
2023-08-03 08:01:43 -07:00
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
union {
|
2023-08-23 08:05:49 -07:00
|
|
|
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.
|
2023-08-03 08:01:43 -07:00
|
|
|
OperatorT Op;
|
|
|
|
AccessSpec ParentAccess;
|
|
|
|
s32 NumEntries;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AST_POD
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
struct
|
|
|
|
{
|
2023-09-06 00:06:30 -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
|
2023-08-03 08:01:43 -07:00
|
|
|
union {
|
2023-08-22 21:05:58 -07:00
|
|
|
AST* InitializerList; // Constructor
|
2023-09-04 22:44:04 -07:00
|
|
|
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
2023-09-06 00:06:30 -07:00
|
|
|
AST* ReturnType; // Function, Operator, Typename
|
2023-08-07 00:10:45 -07:00
|
|
|
AST* UnderlyingType; // Enum, Typedef
|
|
|
|
AST* ValueType; // Parameter, Variable
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
|
|
|
union {
|
2024-04-17 14:40:32 -07:00
|
|
|
AST* Macro; // Parameter
|
2023-09-06 00:06:30 -07:00
|
|
|
AST* BitfieldSize; // Variable (Class/Struct Data Member)
|
|
|
|
AST* Params; // Constructor, Function, Operator, Template, Typename
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
AST* ArrExpr; // Typename
|
2024-04-17 14:40:32 -07:00
|
|
|
AST* Body; // Class, Constructr, Destructor, Enum, Friend, Function, Namespace, Struct, Union
|
2023-09-06 00:06:30 -07:00
|
|
|
AST* Declaration; // Friend, Template
|
|
|
|
AST* Value; // Parameter, Variable
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
|
|
|
union {
|
2023-09-06 00:06:30 -07:00
|
|
|
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
2023-09-25 14:48:16 -07:00
|
|
|
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
|
|
|
};
|
2023-09-11 20:22:53 -07:00
|
|
|
StringCached Content; // Attributes, Comment, Execution, Include
|
|
|
|
struct {
|
|
|
|
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
|
2023-09-25 09:12:11 -07:00
|
|
|
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
2023-09-11 20:22:53 -07:00
|
|
|
};
|
2023-08-03 08:01:43 -07:00
|
|
|
};
|
|
|
|
union {
|
|
|
|
AST* Prev;
|
|
|
|
AST* Front;
|
|
|
|
AST* Last;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
AST* Next;
|
|
|
|
AST* Back;
|
|
|
|
};
|
2023-11-21 17:07:49 -08:00
|
|
|
parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
2023-08-03 08:01:43 -07:00
|
|
|
AST* Parent;
|
|
|
|
StringCached Name;
|
|
|
|
CodeT Type;
|
2023-11-20 12:09:01 -08:00
|
|
|
CodeFlag CodeFlags;
|
2023-08-03 08:01:43 -07:00
|
|
|
ModuleFlag ModuleFlags;
|
|
|
|
union {
|
2023-08-23 08:05:49 -07:00
|
|
|
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.
|
2023-08-03 08:01:43 -07:00
|
|
|
OperatorT Op;
|
|
|
|
AccessSpec ParentAccess;
|
|
|
|
s32 NumEntries;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-25 13:42:29 -07:00
|
|
|
struct test {
|
|
|
|
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
|
2023-11-19 17:34:46 -08:00
|
|
|
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
|
2023-09-25 13:42:29 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
constexpr int pls = sizeof(test);
|
2023-09-25 09:12:11 -07:00
|
|
|
|
2023-08-03 08:01:43 -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.
|
|
|
|
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" );
|
|
|
|
|
|
|
|
// Used when the its desired when omission is allowed in a definition.
|
|
|
|
#define NoCode { nullptr }
|
|
|
|
#define CodeInvalid (* Code::Invalid.ast) // Uses an implicitly overloaded cast from the AST to the desired code type.
|