Added AST & Code definitions segemnted code defs to separate file

For upcoming statements & expression types, just beginning to lay things out for the future.
This commit is contained in:
Edward R. Gonzalez 2023-11-21 20:07:49 -05:00
parent a0ee683f82
commit be023325a9
6 changed files with 1490 additions and 543 deletions

View File

@ -112,6 +112,7 @@ int gen_main()
Code types = scan_file( "components/types.hpp" ); Code types = scan_file( "components/types.hpp" );
Code ast = scan_file( "components/ast.hpp" ); Code ast = scan_file( "components/ast.hpp" );
Code ast_types = scan_file( "components/ast_types.hpp" ); Code ast_types = scan_file( "components/ast_types.hpp" );
Code code_types = scan_file( "components/code_types.hpp" );
Code interface = scan_file( "components/interface.hpp" ); Code interface = scan_file( "components/interface.hpp" );
Code inlines = scan_file( "components/inlines.hpp" ); Code inlines = scan_file( "components/inlines.hpp" );
Code header_end = scan_file( "components/header_end.hpp" ); Code header_end = scan_file( "components/header_end.hpp" );
@ -138,6 +139,7 @@ int gen_main()
header.print_fmt( "#pragma region AST\n" ); header.print_fmt( "#pragma region AST\n" );
header.print( ast ); header.print( ast );
header.print( code_types );
header.print( ast_types ); header.print( ast_types );
header.print_fmt( "\n#pragma endregion AST\n" ); header.print_fmt( "\n#pragma endregion AST\n" );

View File

@ -28,6 +28,42 @@ struct AST_Param;
struct AST_Pragma; struct AST_Pragma;
struct AST_PreprocessCond; struct AST_PreprocessCond;
struct AST_Specifiers; 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;
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
struct AST_Struct; struct AST_Struct;
struct AST_Template; struct AST_Template;
struct AST_Type; struct AST_Type;
@ -59,6 +95,42 @@ struct CodeParam;
struct CodePreprocessCond; struct CodePreprocessCond;
struct CodePragma; struct CodePragma;
struct CodeSpecifiers; 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;
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
struct CodeStruct; struct CodeStruct;
struct CodeTemplate; struct CodeTemplate;
struct CodeType; struct CodeType;
@ -67,7 +139,7 @@ struct CodeUnion;
struct CodeUsing; struct CodeUsing;
struct CodeVar; struct CodeVar;
namespace Parser namespace parser
{ {
struct Token; struct Token;
} }
@ -114,7 +186,6 @@ struct Code
} }
Code& operator ++(); Code& operator ++();
// TODO(Ed) : Remove this overload. // TODO(Ed) : Remove this overload.
auto& operator*() auto& operator*()
{ {
@ -235,7 +306,7 @@ struct AST
( (
AST_POD_Size AST_POD_Size
- sizeof(AST*) * 3 - sizeof(AST*) * 3
- sizeof(Parser::Token*) - sizeof(parser::Token*)
- sizeof(AST*) - sizeof(AST*)
- sizeof(StringCached) - sizeof(StringCached)
- sizeof(CodeT) - sizeof(CodeT)
@ -287,7 +358,7 @@ struct AST
AST* Next; AST* Next;
AST* Back; AST* Back;
}; };
Parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing. parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
AST* Parent; AST* Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -347,7 +418,7 @@ struct AST_POD
AST* Next; AST* Next;
AST* Back; AST* Back;
}; };
Parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing. parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
AST* Parent; AST* Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -377,511 +448,3 @@ static_assert( sizeof(AST_POD) == AST_POD_Size, "ERROR: AST POD is not size o
// Used when the its desired when omission is allowed in a definition. // Used when the its desired when omission is allowed in a definition.
#define NoCode { nullptr } #define NoCode { nullptr }
#define CodeInvalid (* Code::Invalid.ast) // Uses an implicitly overloaded cast from the AST to the desired code type. #define CodeInvalid (* Code::Invalid.ast) // Uses an implicitly overloaded cast from the AST to the desired code type.
#pragma region Code Types
// struct CodeIterator
// {
// Code begin()
// {
// }
// };
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()
{
return * rcast( Code*, this );
}
#pragma region Iterator
Code begin()
{
if ( ast )
return { rcast( AST*, ast)->Front };
return { nullptr };
}
Code end()
{
return { rcast(AST*, ast)->Back->Next };
}
#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()
{
return * rcast( Code*, this );
}
AST_Class* operator->()
{
if ( ast == nullptr )
{
log_failure("Attempt to dereference a nullptr");
return nullptr;
}
return ast;
}
AST_Class* ast;
};
struct CodeParam
{
Using_Code( CodeParam );
void append( CodeParam other );
CodeParam get( s32 idx );
bool has_entries();
void to_string( String& result );
AST* raw()
{
return rcast( AST*, ast );
}
AST_Param* operator->()
{
if ( ast == nullptr )
{
log_failure("Attempt to dereference a nullptr!");
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*()
{
return * this;
}
#pragma endregion Iterator
AST_Param* ast;
};
struct CodeSpecifiers
{
Using_Code( CodeSpecifiers );
bool append( SpecifierT spec )
{
if ( ast == nullptr )
{
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
return false;
}
if ( raw()->NumEntries == AST::ArrSpecs_Cap )
{
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST::ArrSpecs_Cap );
return false;
}
raw()->ArrSpecs[ raw()->NumEntries ] = spec;
raw()->NumEntries++;
return true;
}
s32 has( SpecifierT spec )
{
for ( s32 idx = 0; idx < raw()->NumEntries; idx++ )
{
if ( raw()->ArrSpecs[ raw()->NumEntries ] == spec )
return idx;
}
return -1;
}
void to_string( String& result );
AST* raw()
{
return rcast( AST*, ast );
}
AST_Specifiers* operator->()
{
if ( ast == nullptr )
{
log_failure("Attempt to dereference a nullptr!");
return nullptr;
}
return ast;
}
operator Code()
{
return { (AST*) ast };
}
#pragma region Iterator
SpecifierT* begin()
{
if ( ast )
return & raw()->ArrSpecs[0];
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()
{
return * rcast( Code*, this );
}
AST_Struct* operator->()
{
if ( ast == nullptr )
{
log_failure("Attempt to dereference a nullptr");
return nullptr;
}
return ast;
}
AST_Struct* ast;
};
#define Define_CodeType( Typename ) \
struct Code##Typename \
{ \
Using_Code( Code ## Typename ); \
AST* raw(); \
operator Code(); \
AST_##Typename* operator->(); \
AST_##Typename* ast; \
}
Define_CodeType( Attributes );
Define_CodeType( Comment );
struct CodeConstructor
{
Using_Code( CodeConstructor );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
AST_Constructor* operator->();
AST_Constructor* ast;
};
struct CodeDefine
{
Using_Code( CodeDefine );
void to_string( String& result );
AST* raw();
operator Code();
AST_Define* operator->();
AST_Define* ast;
};
struct CodeDestructor
{
Using_Code( CodeDestructor );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
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 );
AST* raw();
operator Code();
AST_Enum* operator->();
AST_Enum* ast;
};
Define_CodeType( Exec );
struct CodeExtern
{
Using_Code( CodeExtern );
void to_string( String& result );
AST* raw();
operator Code();
AST_Extern* operator->();
AST_Extern* ast;
};
struct CodeInclude
{
Using_Code( CodeInclude );
void to_string( String& result );
AST* raw();
operator Code();
AST_Include* operator->();
AST_Include* ast;
};
struct CodeFriend
{
Using_Code( CodeFriend );
void to_string( String& result );
AST* raw();
operator Code();
AST_Friend* operator->();
AST_Friend* ast;
};
struct CodeFn
{
Using_Code( CodeFn );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
AST_Fn* operator->();
AST_Fn* ast;
};
struct CodeModule
{
Using_Code( CodeModule );
void to_string( String& result );
AST* raw();
operator Code();
AST_Module* operator->();
AST_Module* ast;
};
struct CodeNS
{
Using_Code( CodeNS );
void to_string( String& result );
AST* raw();
operator Code();
AST_NS* operator->();
AST_NS* ast;
};
struct CodeOperator
{
Using_Code( CodeOperator );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
AST_Operator* operator->();
AST_Operator* ast;
};
struct CodeOpCast
{
Using_Code( CodeOpCast );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
AST_OpCast* operator->();
AST_OpCast* ast;
};
struct CodePragma
{
Using_Code( CodePragma );
void to_string( String& result );
AST* raw();
operator Code();
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 );
AST* raw();
operator Code();
AST_PreprocessCond* operator->();
AST_PreprocessCond* ast;
};
struct CodeTemplate
{
Using_Code( CodeTemplate );
void to_string( String& result );
AST* raw();
operator Code();
AST_Template* operator->();
AST_Template* ast;
};
struct CodeType
{
Using_Code( CodeType );
void to_string( String& result );
AST* raw();
operator Code();
AST_Type* operator->();
AST_Type* ast;
};
struct CodeTypedef
{
Using_Code( CodeTypedef );
void to_string( String& result );
AST* raw();
operator Code();
AST_Typedef* operator->();
AST_Typedef* ast;
};
struct CodeUnion
{
Using_Code( CodeUnion );
void to_string( String& result );
AST* raw();
operator Code();
AST_Union* operator->();
AST_Union* ast;
};
struct CodeUsing
{
Using_Code( CodeUsing );
void to_string( String& result );
void to_string_ns( String& result );
AST* raw();
operator Code();
AST_Using* operator->();
AST_Using* ast;
};
struct CodeVar
{
Using_Code( CodeVar );
void to_string( String& result );
AST* raw();
operator Code();
AST_Var* operator->();
AST_Var* ast;
};
#undef Define_CodeType
#undef Using_Code
#pragma endregion Code Types

View File

@ -1,6 +1,6 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "ast.hpp" # include "code_types.hpp"
#endif #endif
#pragma region AST Types #pragma region AST Types
@ -15,7 +15,7 @@ struct AST_Body
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
Code Front; Code Front;
Code Back; Code Back;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -32,7 +32,7 @@ struct AST_Attributes
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -48,7 +48,7 @@ struct AST_Comment
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -73,7 +73,7 @@ struct AST_Class
}; };
CodeType Prev; CodeType Prev;
CodeType Next; CodeType Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -99,7 +99,7 @@ struct AST_Constructor
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
char _PAD_NAME_[ sizeof(StringCached) ]; char _PAD_NAME_[ sizeof(StringCached) ];
CodeT Type; CodeT Type;
@ -115,7 +115,7 @@ struct AST_Define
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -139,7 +139,7 @@ struct AST_Destructor
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
char _PAD_NAME_[ sizeof(StringCached) ]; char _PAD_NAME_[ sizeof(StringCached) ];
CodeT Type; CodeT Type;
@ -164,7 +164,7 @@ struct AST_Enum
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -181,7 +181,7 @@ struct AST_Exec
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -189,6 +189,263 @@ struct AST_Exec
}; };
static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST"); static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST");
#if GEN_EXECUTION_EXPRESSION_SUPPORT
struct AST_Expr
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr) == sizeof(AST), "ERROR: AST_Expr is not the same size as AST");
struct AST_Expr_Assign
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Assign) == sizeof(AST), "ERROR: AST_Expr_Assign is not the same size as AST");
struct AST_Expr_Alignof
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Alignof) == sizeof(AST), "ERROR: AST_Expr_Alignof is not the same size as AST");
struct AST_Expr_Binary
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Binary) == sizeof(AST), "ERROR: AST_Expr_Binary is not the same size as AST");
struct AST_Expr_CStyleCast
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_CStyleCast) == sizeof(AST), "ERROR: AST_Expr_CStyleCast is not the same size as AST");
struct AST_Expr_FunctionalCast
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_FunctionalCast) == sizeof(AST), "ERROR: AST_Expr_FunctionalCast is not the same size as AST");
struct AST_Expr_CppCast
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_CppCast) == sizeof(AST), "ERROR: AST_Expr_CppCast is not the same size as AST");
struct AST_Expr_ProcCall
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_ProcCall) == sizeof(AST), "ERROR: AST_Expr_Identifier is not the same size as AST");
struct AST_Expr_Decltype
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Decltype) == sizeof(AST), "ERROR: AST_Expr_Decltype is not the same size as AST");
struct AST_Expr_Comma
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Comma) == sizeof(AST), "ERROR: AST_Expr_Comma is not the same size as AST");
struct AST_Expr_AMS
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_AMS) == sizeof(AST), "ERROR: AST_Expr_AMS is not the same size as AST");
struct AST_Expr_Sizeof
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Sizeof) == sizeof(AST), "ERROR: AST_Expr_Sizeof is not the same size as AST");
struct AST_Expr_Subscript
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Subscript) == sizeof(AST), "ERROR: AST_Expr_Subscript is not the same size as AST");
struct AST_Expr_Ternary
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Ternary) == sizeof(AST), "ERROR: AST_Expr_Ternary is not the same size as AST");
struct AST_Expr_UnaryPrefix
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_UnaryPrefix) == sizeof(AST), "ERROR: AST_Expr_UnaryPrefix is not the same size as AST");
struct AST_Expr_UnaryPostfix
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_UnaryPostfix) == sizeof(AST), "ERROR: AST_Expr_UnaryPostfix is not the same size as AST");
struct AST_Expr_Element
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Expr_Element) == sizeof(AST), "ERROR: AST_Expr_Element is not the same size as AST");
#endif
struct AST_Extern struct AST_Extern
{ {
union { union {
@ -202,7 +459,7 @@ struct AST_Extern
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -218,7 +475,7 @@ struct AST_Include
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -240,7 +497,7 @@ struct AST_Friend
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -265,7 +522,7 @@ struct AST_Fn
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -279,7 +536,7 @@ struct AST_Module
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -300,7 +557,7 @@ struct AST_NS
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -326,7 +583,7 @@ struct AST_Operator
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -352,7 +609,7 @@ struct AST_OpCast
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -375,7 +632,7 @@ struct AST_Param
}; };
CodeParam Last; CodeParam Last;
CodeParam Next; CodeParam Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -392,7 +649,7 @@ struct AST_Pragma
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -408,7 +665,7 @@ struct AST_PreprocessCond
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -422,14 +679,226 @@ struct AST_Specifiers
CodeSpecifiers NextSpecs; CodeSpecifiers NextSpecs;
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ]; char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries; s32 NumEntries;
}; };
static_assert( sizeof(AST_Specifiers) == sizeof(AST), "ERROR: AST_Specifier is not the same size as AST"); static_assert( sizeof(AST_Specifiers) == sizeof(AST), "ERROR: AST_Specifier is not the same size as AST");
#if GEN_EXECUTION_EXPRESSION_SUPPORT
struct AST_Stmt
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt) == sizeof(AST), "ERROR: AST_Stmt is not the same size as AST");
struct AST_Stmt_Break
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Break) == sizeof(AST), "ERROR: AST_Stmt_Break is not the same size as AST");
struct AST_Stmt_Case
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Case) == sizeof(AST), "ERROR: AST_Stmt_Case is not the same size as AST");
struct AST_Stmt_Continue
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Continue) == sizeof(AST), "ERROR: AST_Stmt_Continue is not the same size as AST");
struct AST_Stmt_Decl
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Decl) == sizeof(AST), "ERROR: AST_Stmt_Decl is not the same size as AST");
struct AST_Stmt_Do
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Do) == sizeof(AST), "ERROR: AST_Stmt_Do is not the same size as AST");
struct AST_Stmt_Expr
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Expr) == sizeof(AST), "ERROR: AST_Stmt_Expr is not the same size as AST");
struct AST_Stmt_Else
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Else) == sizeof(AST), "ERROR: AST_Stmt_Else is not the same size as AST");
struct AST_Stmt_If
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_If) == sizeof(AST), "ERROR: AST_Stmt_If is not the same size as AST");
struct AST_Stmt_For
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_For) == sizeof(AST), "ERROR: AST_Stmt_For is not the same size as AST");
struct AST_Stmt_Goto
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Goto) == sizeof(AST), "ERROR: AST_Stmt_Goto is not the same size as AST");
struct AST_Stmt_Label
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Label) == sizeof(AST), "ERROR: AST_Stmt_Label is not the same size as AST");
struct AST_Stmt_Switch
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_Switch) == sizeof(AST), "ERROR: AST_Stmt_Switch is not the same size as AST");
struct AST_Stmt_While
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
}
CodeExpr Prev;
CodeExpr Next;
parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Stmt_While) == sizeof(AST), "ERROR: AST_Stmt_While is not the same size as AST");
#endif
struct AST_Struct struct AST_Struct
{ {
@ -448,7 +917,7 @@ struct AST_Struct
}; };
CodeType Prev; CodeType Prev;
CodeType Next; CodeType Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -471,7 +940,7 @@ struct AST_Template
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -480,6 +949,36 @@ struct AST_Template
}; };
static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not the same size as AST"); static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not the same size as AST");
#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* Token;
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 struct AST_Type
{ {
union { union {
@ -497,7 +996,7 @@ struct AST_Type
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -520,7 +1019,7 @@ struct AST_Typedef
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Token;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -544,7 +1043,7 @@ struct AST_Union
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -568,7 +1067,7 @@ struct AST_Using
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;
@ -594,7 +1093,7 @@ struct AST_Var
}; };
Code Prev; Code Prev;
Code Next; Code Next;
Parser::Token* Token; parser::Token* Tok;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
CodeT Type; CodeT Type;

View File

@ -0,0 +1,880 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "ast.hpp"
#endif
#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()
{
return * rcast( Code*, this );
}
#pragma region Iterator
Code begin()
{
if ( ast )
return { rcast( AST*, ast)->Front };
return { nullptr };
}
Code end()
{
return { rcast(AST*, ast)->Back->Next };
}
#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()
{
return * rcast( Code*, this );
}
AST_Class* operator->()
{
if ( ast == nullptr )
{
log_failure("Attempt to dereference a nullptr");
return nullptr;
}
return ast;
}
AST_Class* ast;
};
struct CodeParam
{
Using_Code( CodeParam );
void append( CodeParam other );
CodeParam get( s32 idx );
bool has_entries();
void to_string( String& result );
AST* raw()
{
return rcast( AST*, ast );
}
AST_Param* operator->()
{
if ( ast == nullptr )
{
log_failure("Attempt to dereference a nullptr!");
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*()
{
return * this;
}
#pragma endregion Iterator
AST_Param* ast;
};
struct CodeSpecifiers
{
Using_Code( CodeSpecifiers );
bool append( SpecifierT spec )
{
if ( ast == nullptr )
{
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
return false;
}
if ( raw()->NumEntries == AST::ArrSpecs_Cap )
{
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST::ArrSpecs_Cap );
return false;
}
raw()->ArrSpecs[ raw()->NumEntries ] = spec;
raw()->NumEntries++;
return true;
}
s32 has( SpecifierT spec )
{
for ( s32 idx = 0; idx < raw()->NumEntries; idx++ )
{
if ( raw()->ArrSpecs[ raw()->NumEntries ] == spec )
return idx;
}
return -1;
}
void to_string( String& result );
AST* raw()
{
return rcast( AST*, ast );
}
AST_Specifiers* operator->()
{
if ( ast == nullptr )
{
log_failure("Attempt to dereference a nullptr!");
return nullptr;
}
return ast;
}
operator Code()
{
return { (AST*) ast };
}
#pragma region Iterator
SpecifierT* begin()
{
if ( ast )
return & raw()->ArrSpecs[0];
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()
{
return * rcast( Code*, this );
}
AST_Struct* operator->()
{
if ( ast == nullptr )
{
log_failure("Attempt to dereference a nullptr");
return nullptr;
}
return ast;
}
AST_Struct* ast;
};
#define Define_CodeType( Typename ) \
struct Code##Typename \
{ \
Using_Code( Code ## Typename ); \
AST* raw(); \
operator Code(); \
AST_##Typename* operator->(); \
AST_##Typename* ast; \
}
Define_CodeType( Attributes );
Define_CodeType( Comment );
struct CodeConstructor
{
Using_Code( CodeConstructor );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
AST_Constructor* operator->();
AST_Constructor* ast;
};
struct CodeDefine
{
Using_Code( CodeDefine );
void to_string( String& result );
AST* raw();
operator Code();
AST_Define* operator->();
AST_Define* ast;
};
struct CodeDestructor
{
Using_Code( CodeDestructor );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
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 );
AST* raw();
operator Code();
AST_Enum* operator->();
AST_Enum* ast;
};
Define_CodeType( Exec );
#if GEN_EXECUTION_EXPRESSION_SUPPORT
struct CodeExpr
{
Using_Code( CodeExpr );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr* operator->();
AST_Expr* ast;
};
struct CodeExpr_Assign
{
Using_Code( CodeExpr_Assign );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Assign* operator->();
AST_Expr_Assign* ast;
};
struct CodeExpr_Alignof
{
Using_Code( CodeExpr_Alignof );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Alignof* operator->();
AST_Expr_Alignof* ast;
};
struct CodeExpr_Binary
{
Using_Code( CodeExpr_Binary );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Binary* operator->();
AST_Expr_Binary* ast;
};
struct CodeExpr_CStyleCast
{
Using_Code( CodeExpr_CStyleCast );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_CStyleCast* operator->();
AST_Expr_CStyleCast* ast;
};
struct CodeExpr_FunctionalCast
{
Using_Code( CodeExpr_FunctionalCast );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_FunctionalCast* operator->();
AST_Expr_FunctionalCast* ast;
};
struct CodeExpr_CppCast
{
Using_Code( CodeExpr_CppCast );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_CppCast* operator->();
AST_Expr_CppCast* ast;
};
struct CodeExpr_Element
{
Using_Code( CodeExpr_Element );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Element* operator->();
AST_Expr_Element* ast;
};
struct CodeExpr_ProcCall
{
Using_Code( CodeExpr_ProcCall );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_ProcCall* operator->();
AST_Expr_ProcCall* ast;
};
struct CodeExpr_Decltype
{
Using_Code( CodeExpr_Decltype );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Decltype* operator->();
AST_Expr_Decltype* ast;
};
struct CodeExpr_Comma
{
Using_Code( CodeExpr_Comma );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Comma* operator->();
AST_Expr_Comma* ast;
};
struct CodeExpr_AMS
{
Using_Code( CodeExpr_AMS );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_AMS* operator->();
AST_Expr_AMS* ast;
};
struct CodeExpr_Sizeof
{
Using_Code( CodeExpr_Sizeof );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Sizeof* operator->();
AST_Expr_Sizeof* ast;
};
struct CodeExpr_Subscript
{
Using_Code( CodeExpr_Subscript );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Subscript* operator->();
AST_Expr_Subscript* ast;
};
struct CodeExpr_Ternary
{
Using_Code( CodeExpr_Ternary );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_Ternary* operator->();
AST_Expr_Ternary* ast;
};
struct CodeExpr_UnaryPrefix
{
Using_Code( CodeExpr_UnaryPrefix );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_UnaryPrefix* operator->();
AST_Expr_UnaryPrefix* ast;
};
struct CodeExpr_UnaryPostfix
{
Using_Code( CodeExpr_UnaryPostfix );
void to_string( String& result );
AST* raw();
operator Code();
AST_Expr_UnaryPostfix* operator->();
AST_Expr_UnaryPostfix* ast;
};
#endif
struct CodeExtern
{
Using_Code( CodeExtern );
void to_string( String& result );
AST* raw();
operator Code();
AST_Extern* operator->();
AST_Extern* ast;
};
struct CodeInclude
{
Using_Code( CodeInclude );
void to_string( String& result );
AST* raw();
operator Code();
AST_Include* operator->();
AST_Include* ast;
};
struct CodeFriend
{
Using_Code( CodeFriend );
void to_string( String& result );
AST* raw();
operator Code();
AST_Friend* operator->();
AST_Friend* ast;
};
struct CodeFn
{
Using_Code( CodeFn );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
AST_Fn* operator->();
AST_Fn* ast;
};
struct CodeModule
{
Using_Code( CodeModule );
void to_string( String& result );
AST* raw();
operator Code();
AST_Module* operator->();
AST_Module* ast;
};
struct CodeNS
{
Using_Code( CodeNS );
void to_string( String& result );
AST* raw();
operator Code();
AST_NS* operator->();
AST_NS* ast;
};
struct CodeOperator
{
Using_Code( CodeOperator );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
AST_Operator* operator->();
AST_Operator* ast;
};
struct CodeOpCast
{
Using_Code( CodeOpCast );
void to_string_def( String& result );
void to_string_fwd( String& result );
AST* raw();
operator Code();
AST_OpCast* operator->();
AST_OpCast* ast;
};
struct CodePragma
{
Using_Code( CodePragma );
void to_string( String& result );
AST* raw();
operator Code();
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 );
AST* raw();
operator Code();
AST_PreprocessCond* operator->();
AST_PreprocessCond* ast;
};
#if GEN_EXECUTION_EXPRESSION_SUPPORT
struct CodeStmt
{
Using_Code( CodeStmt );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt* operator->();
AST_Stmt* ast;
};
struct CodeStmt_Break
{
Using_Code( CodeStmt_Break );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Break* operator->();
AST_Stmt_Break* ast;
};
struct CodeStmt_Case
{
Using_Code( CodeStmt_Case );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Case* operator->();
AST_Stmt_Case* ast;
};
struct CodeStmt_Continue
{
Using_Code( CodeStmt_Continue );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Continue* operator->();
AST_Stmt_Continue* ast;
};
struct CodeStmt_Decl
{
Using_Code( CodeStmt_Decl );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Decl* operator->();
AST_Stmt_Decl* ast;
};
struct CodeStmt_Do
{
Using_Code( CodeStmt_Do );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Do* operator->();
AST_Stmt_Do* ast;
};
struct CodeStmt_Expr
{
Using_Code( CodeStmt_Expr );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Expr* operator->();
AST_Stmt_Expr* ast;
};
struct CodeStmt_Else
{
Using_Code( CodeStmt_Else );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Else* operator->();
AST_Stmt_Else* ast;
};
struct CodeStmt_If
{
Using_Code( CodeStmt_If );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_If* operator->();
AST_Stmt_If* ast;
};
struct CodeStmt_For
{
Using_Code( CodeStmt_For );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_For* operator->();
AST_Stmt_For* ast;
};
struct CodeStmt_Goto
{
Using_Code( CodeStmt_Goto );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Goto* operator->();
AST_Stmt_Goto* ast;
};
struct CodeStmt_Label
{
Using_Code( CodeStmt_Label );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Label* operator->();
AST_Stmt_Label* ast;
};
struct CodeStmt_Switch
{
Using_Code( CodeStmt_Switch );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_Switch* operator->();
AST_Stmt_Switch* ast;
};
struct CodeStmt_While
{
Using_Code( CodeStmt_While );
void to_string( String& result );
AST* raw();
operator Code();
AST_Stmt_While* operator->();
AST_Stmt_While* ast;
};
#endif
struct CodeTemplate
{
Using_Code( CodeTemplate );
void to_string( String& result );
AST* raw();
operator Code();
AST_Template* operator->();
AST_Template* ast;
};
struct CodeType
{
Using_Code( CodeType );
void to_string( String& result );
AST* raw();
operator Code();
AST_Type* operator->();
AST_Type* ast;
};
struct CodeTypedef
{
Using_Code( CodeTypedef );
void to_string( String& result );
AST* raw();
operator Code();
AST_Typedef* operator->();
AST_Typedef* ast;
};
struct CodeUnion
{
Using_Code( CodeUnion );
void to_string( String& result );
AST* raw();
operator Code();
AST_Union* operator->();
AST_Union* ast;
};
struct CodeUsing
{
Using_Code( CodeUsing );
void to_string( String& result );
void to_string_ns( String& result );
AST* raw();
operator Code();
AST_Using* operator->();
AST_Using* ast;
};
struct CodeVar
{
Using_Code( CodeVar );
void to_string( String& result );
AST* raw();
operator Code();
AST_Var* operator->();
AST_Var* ast;
};
#undef Define_CodeType
#undef Using_Code
#pragma endregion Code Types

View File

@ -19,6 +19,7 @@ GEN_NS_BEGIN
#include "components/gen/especifier.hpp" #include "components/gen/especifier.hpp"
#include "components/ast.hpp" #include "components/ast.hpp"
#include "components/code_types.hpp"
#include "components/ast_types.hpp" #include "components/ast_types.hpp"
#include "components/interface.hpp" #include "components/interface.hpp"

View File

@ -113,6 +113,7 @@ int gen_main()
Code types = scan_file( project_dir "components/types.hpp" ); Code types = scan_file( project_dir "components/types.hpp" );
Code ast = scan_file( project_dir "components/ast.hpp" ); Code ast = scan_file( project_dir "components/ast.hpp" );
Code ast_types = scan_file( project_dir "components/ast_types.hpp" ); Code ast_types = scan_file( project_dir "components/ast_types.hpp" );
Code code_types = scan_file( project_dir "components/code_types.hpp" );
Code interface = scan_file( project_dir "components/interface.hpp" ); Code interface = scan_file( project_dir "components/interface.hpp" );
Code inlines = scan_file( project_dir "components/inlines.hpp" ); Code inlines = scan_file( project_dir "components/inlines.hpp" );
Code header_end = scan_file( project_dir "components/header_end.hpp" ); Code header_end = scan_file( project_dir "components/header_end.hpp" );
@ -133,6 +134,7 @@ int gen_main()
header.print_fmt("#pragma region AST\n"); header.print_fmt("#pragma region AST\n");
header.print( ast ); header.print( ast );
header.print( code_types );
header.print( ast_types ); header.print( ast_types );
header.print_fmt("\n#pragma endregion AST\n"); header.print_fmt("\n#pragma endregion AST\n");