aboutsummaryrefslogtreecommitdiff
path: root/src/parser.hpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-11-14 15:22:40 +0000
committergingerBill <bill@gingerbill.org>2021-11-14 15:22:40 +0000
commitf47311f2f6c59856efd64c56101cc004d1b15bc2 (patch)
tree11fb70eb39f725c82f8e013ac2a922b22cb63355 /src/parser.hpp
parent3f038428a7f282468011415db76da4bf08ddb67c (diff)
Remove `scope` field from `Ast`
Diffstat (limited to 'src/parser.hpp')
-rw-r--r--src/parser.hpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/parser.hpp b/src/parser.hpp
index 76ae33b21..b1518533e 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -424,11 +424,13 @@ AST_KIND(_StmtBegin, "", bool) \
}) \
AST_KIND(_ComplexStmtBegin, "", bool) \
AST_KIND(BlockStmt, "block statement", struct { \
+ Scope *scope; \
Slice<Ast *> stmts; \
Ast *label; \
Token open, close; \
}) \
AST_KIND(IfStmt, "if statement", struct { \
+ Scope *scope; \
Token token; \
Ast *label; \
Ast * init; \
@@ -449,6 +451,7 @@ AST_KIND(_ComplexStmtBegin, "", bool) \
Slice<Ast *> results; \
}) \
AST_KIND(ForStmt, "for statement", struct { \
+ Scope *scope; \
Token token; \
Ast *label; \
Ast *init; \
@@ -457,6 +460,7 @@ AST_KIND(_ComplexStmtBegin, "", bool) \
Ast *body; \
}) \
AST_KIND(RangeStmt, "range statement", struct { \
+ Scope *scope; \
Token token; \
Ast *label; \
Slice<Ast *> vals; \
@@ -465,6 +469,7 @@ AST_KIND(_ComplexStmtBegin, "", bool) \
Ast *body; \
}) \
AST_KIND(UnrollRangeStmt, "#unroll range statement", struct { \
+ Scope *scope; \
Token unroll_token; \
Token for_token; \
Ast *val0; \
@@ -474,12 +479,14 @@ AST_KIND(_ComplexStmtBegin, "", bool) \
Ast *body; \
}) \
AST_KIND(CaseClause, "case clause", struct { \
+ Scope *scope; \
Token token; \
Slice<Ast *> list; \
Slice<Ast *> stmts; \
Entity *implicit_entity; \
}) \
AST_KIND(SwitchStmt, "switch statement", struct { \
+ Scope *scope; \
Token token; \
Ast *label; \
Ast *init; \
@@ -488,6 +495,7 @@ AST_KIND(_ComplexStmtBegin, "", bool) \
bool partial; \
}) \
AST_KIND(TypeSwitchStmt, "type switch statement", struct { \
+ Scope *scope; \
Token token; \
Ast *label; \
Ast *tag; \
@@ -589,6 +597,7 @@ AST_KIND(_TypeBegin, "", bool) \
Ast * specialization; \
}) \
AST_KIND(ProcType, "procedure type", struct { \
+ Scope *scope; \
Token token; \
Ast *params; \
Ast *results; \
@@ -621,6 +630,7 @@ AST_KIND(_TypeBegin, "", bool) \
Ast *tag; \
}) \
AST_KIND(StructType, "struct type", struct { \
+ Scope *scope; \
Token token; \
Slice<Ast *> fields; \
isize field_count; \
@@ -632,6 +642,7 @@ AST_KIND(_TypeBegin, "", bool) \
bool is_raw_union; \
}) \
AST_KIND(UnionType, "union type", struct { \
+ Scope *scope; \
Token token; \
Slice<Ast *> variants; \
Ast *polymorphic_params; \
@@ -642,6 +653,7 @@ AST_KIND(_TypeBegin, "", bool) \
Slice<Ast *> where_clauses; \
}) \
AST_KIND(EnumType, "enum type", struct { \
+ Scope *scope; \
Token token; \
Ast * base_type; \
Slice<Ast *> fields; /* FieldValue */ \
@@ -695,21 +707,19 @@ isize const ast_variant_sizes[] = {
};
struct AstCommonStuff {
- AstKind kind;
+ AstKind kind; // u16
u8 state_flags;
u8 viral_state_flags;
i32 file_id;
- Scope * scope;
- TypeAndValue tav; // TODO(bill): Make this a pointer to minimize pointer size
+ TypeAndValue tav; // TODO(bill): Make this a pointer to minimize 'Ast' size
};
struct Ast {
- AstKind kind;
+ AstKind kind; // u16
u8 state_flags;
u8 viral_state_flags;
i32 file_id;
- Scope * scope;
- TypeAndValue tav; // TODO(bill): Make this a pointer to minimize pointer size
+ TypeAndValue tav; // TODO(bill): Make this a pointer to minimize 'Ast' size
// IMPORTANT NOTE(bill): This must be at the end since the AST is allocated to be size of the variant
union {