demacro AST and Code forwards/typedefs

This commit is contained in:
Edward R. Gonzalez 2024-12-10 10:24:48 -05:00
parent a4143b537d
commit abdad1a436

View File

@ -85,84 +85,149 @@ struct AST_Union;
struct AST_Using; struct AST_Using;
struct AST_Var; struct AST_Var;
#if GEN_COMPILER_C
#define Define_Code(Type) typedef AST_##Type* Code##Type
#else
#define Define_Code(Type) struct Code##Type
#endif
#if GEN_COMPILER_C #if GEN_COMPILER_C
typedef AST* Code; typedef AST* Code;
#else #else
struct Code; struct Code;
#endif #endif
Define_Code(Body); #if GEN_COMPILER_C
// These are to offer ease of use and optionally strong type safety for the AST. typdef AST_Body* CodeBody;
Define_Code(Attributes); typdef AST_Attributes* CodeAttributes;
// struct CodeBaseClass; typdef AST_Comment* CodeComment;
Define_Code(Comment); typdef AST_Class* CodeClass;
Define_Code(Class); typdef AST_Constructor* CodeConstructor;
Define_Code(Constructor); typdef AST_Define* CodeDefine;
Define_Code(Define); typdef AST_Destructor* CodeDestructor;
Define_Code(Destructor); typdef AST_Enum* CodeEnum;
Define_Code(Enum); typdef AST_Exec* CodeExec;
Define_Code(Exec); typdef AST_Extern* CodeExtern;
Define_Code(Extern); typdef AST_Include* CodeInclude;
Define_Code(Include); typdef AST_Friend* CodeFriend;
Define_Code(Friend); typdef AST_Fn* CodeFn;
Define_Code(Fn); typdef AST_Module* CodeModule;
Define_Code(Module); typdef AST_NS* CodeNS;
Define_Code(NS); typdef AST_Operator* CodeOperator;
Define_Code(Operator); typdef AST_OpCast* CodeOpCast;
Define_Code(OpCast); typdef AST_Param* CodeParam;
Define_Code(Param); typdef AST_PreprocessCond* CodePreprocessCond;
Define_Code(PreprocessCond); typdef AST_Pragma* CodePragma;
Define_Code(Pragma); typdef AST_Specifiers* CodeSpecifiers;
Define_Code(Specifiers); #else
struct CodeBody;
#if GEN_EXECUTION_EXPRESSION_SUPPORT struct CodeAttributes;
Define_Code(Expr); struct CodeComment;
Define_Code(Expr_Assign); struct CodeClass;
Define_Code(Expr_Alignof); struct CodeConstructor;
Define_Code(Expr_Binary); struct CodeDefine;
Define_Code(Expr_CStyleCast); struct CodeDestructor;
Define_Code(Expr_FunctionalCast); struct CodeEnum;
Define_Code(Expr_CppCast); struct CodeExec;
Define_Code(Expr_Element); struct CodeExtern;
Define_Code(Expr_ProcCall); struct CodeInclude;
Define_Code(Expr_Decltype); struct CodeFriend;
Define_Code(Expr_Comma); struct CodeFn;
Define_Code(Expr_AMS); // Access Member Symbol struct CodeModule;
Define_Code(Expr_Sizeof); struct CodeNS;
Define_Code(Expr_Subscript); struct CodeOperator;
Define_Code(Expr_Ternary); struct CodeOpCast;
Define_Code(Expr_UnaryPrefix); struct CodeParam;
Define_Code(Expr_UnaryPostfix); struct CodePreprocessCond;
struct CodePragma;
Define_Code(Stmt); struct CodeSpecifiers;
Define_Code(Stmt_Break);
Define_Code(Stmt_Case);
Define_Code(Stmt_Continue);
Define_Code(Stmt_Decl);
Define_Code(Stmt_Do);
Define_Code(Stmt_Expr);
Define_Code(Stmt_Else);
Define_Code(Stmt_If);
Define_Code(Stmt_For);
Define_Code(Stmt_Goto);
Define_Code(Stmt_Label);
Define_Code(Stmt_Switch);
Define_Code(Stmt_While);
#endif #endif
Define_Code(Struct); #if GEN_EXECUTION_EXPRESSION_SUPPORT
Define_Code(Template);
Define_Code(Typename); #if GEN_COMPILER_C
Define_Code(Typedef); typedef AST_Expr* CodeExpr;
Define_Code(Union); typedef AST_Expr_Assign* CodeExpr_Assign;
Define_Code(Using); typedef AST_Expr_Alignof* CodeExpr_Alignof;
Define_Code(Var); typedef AST_Expr_Binary* CodeExpr_Binary;
typedef AST_Expr_CStyleCast* CodeExpr_CStyleCast;
typedef AST_Expr_FunctionalCast* CodeExpr_FunctionalCast;
typedef AST_Expr_CppCast* CodeExpr_CppCast;
typedef AST_Expr_Element* CodeExpr_Element;
typedef AST_Expr_ProcCall* CodeExpr_ProcCall;
typedef AST_Expr_Decltype* CodeExpr_Decltype;
typedef AST_Expr_Comma* CodeExpr_Comma;
typedef AST_Expr_AMS* CodeExpr_AMS; // Access Member Symbol
typedef AST_Expr_Sizeof* CodeExpr_Sizeof;
typedef AST_Expr_Subscript* CodeExpr_Subscript;
typedef AST_Expr_Ternary* CodeExpr_Ternary;
typedef AST_Expr_UnaryPrefix* CodeExpr_UnaryPrefix;
typedef AST_Expr_UnaryPostfix* CodeExpr_UnaryPostfix;
#else
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;
#endif
#if GEN_COMPILER_C
typedef AST_Stmt* CodeStmt;
typedef AST_Stmt_Break* CodeStmt_Break;
typedef AST_Stmt_Case* CodeStmt_Case;
typedef AST_Stmt_Continue* CodeStmt_Continue;
typedef AST_Stmt_Decl* CodeStmt_Decl;
typedef AST_Stmt_Do* CodeStmt_Do;
typedef AST_Stmt_Expr* CodeStmt_Expr;
typedef AST_Stmt_Else* CodeStmt_Else;
typedef AST_Stmt_If* CodeStmt_If;
typedef AST_Stmt_For* CodeStmt_For;
typedef AST_Stmt_Goto* CodeStmt_Goto;
typedef AST_Stmt_Label* CodeStmt_Label;
typedef AST_Stmt_Switch* CodeStmt_Switch;
typedef AST_Stmt_While* CodeStmt_While;
#else
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
#endif
#if GEN_COMPILER_C
typedef AST_Struct* CodeStruct;
typedef AST_Template* CodeTemplate;
typedef AST_Typename* CodeTypename;
typedef AST_Typedef* CodeTypedef;
typedef AST_Union* CodeUnion;
typedef AST_Using* CodeUsing;
typedef AST_Var* CodeVar;
#else
struct CodeStruct;
struct CodeTemplate;
struct CodeTypename;
struct CodeTypedef;
struct CodeUnion;
struct CodeUsing;
struct CodeVar;
#endif
#undef Define_Code #undef Define_Code