aboutsummaryrefslogtreecommitdiff
path: root/src/ast.h
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-03 21:01:03 -0500
committerMustafa Quraish <[email protected]>2022-02-03 21:01:03 -0500
commit9f3edcbeea51dd8841b9d89fa7ef98f11682a1c7 (patch)
treeb2a4b6fa51ad558b36facde2cf952a6af5a25669 /src/ast.h
parentAdd automatic type inference for initialized variable declarations (diff)
downloadcup-9f3edcbeea51dd8841b9d89fa7ef98f11682a1c7.tar.xz
cup-9f3edcbeea51dd8841b9d89fa7ef98f11682a1c7.zip
Add support for basic structs
Structs for now (and probably for the near future) are not allowed to be passed by value, and instead you just pass a pointer to it. Nested structs can also be defined, and they can be either anonymous, or named (in which case only the members can access the type).
Diffstat (limited to 'src/ast.h')
-rw-r--r--src/ast.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ast.h b/src/ast.h
index d1e904c..af7ef65 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -26,6 +26,7 @@
F(OP_GT, ">") \
F(OP_GEQ, ">=") \
F(OP_ASSIGN, "=") \
+ F(OP_MEMBER, ".") \
F(AST_LITERAL, "literal") \
F(AST_FUNCCALL, "Function call") \
F(AST_CONDITIONAL, "conditional expression") \
@@ -143,6 +144,12 @@ typedef struct ast_node {
Node **args;
int num_args;
} call;
+
+ struct {
+ i64 offset;
+ Node *expr;
+ bool is_ptr;
+ } member;
};
} Node;