aboutsummaryrefslogtreecommitdiff
path: root/include/ast.h
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-03-22 20:48:40 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit4f308829ad0e81a59971e172284c018cf2bdca3d (patch)
treeeb11a69a471e31aa7be8e46bce6d1b3ded28e056 /include/ast.h
parent5df7f92e715ba764ee57f65d78e73111492bb64c (diff)
Add mutex for lhs expr, add error for missing lhs expr for func, struct
TODO: Use mutex in lhs expr and set resolved_type
Diffstat (limited to 'include/ast.h')
-rw-r--r--include/ast.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/ast.h b/include/ast.h
index 7b16796..25d9034 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -2,6 +2,7 @@
#define AMALGAM_AST_H
#include "defs.h"
+#include "std/defs.h"
#include "std/buffer_view.h"
#include "std/buffer.h"
#include "std/misc.h"
@@ -108,6 +109,13 @@ struct LhsExpr {
BufferView var_name;
Variable type;
Ast rhs_expr;
+ /*
+ A mutex is only available if the LhsExpr is public, because other threads (files)
+ can access it. It's used to prevent usage of unresolved data and also to decide which
+ thread has responsibility of resolving data.
+ TODO: Find a better way to store this. This most likely will use too much memory.
+ */
+ amal_mutex *mutex;
};
struct Import {
@@ -149,7 +157,7 @@ CHECK_RESULT int funcdecl_init(FunctionDecl *self, Scope *parent, ScopedAllocato
CHECK_RESULT int funccall_init(FunctionCall *self, BufferView name, ScopedAllocator *allocator);
CHECK_RESULT int structdecl_init(StructDecl *self, Scope *parent, ScopedAllocator *allocator);
void structfield_init(StructField *self, BufferView name, BufferView type_name);
-void lhsexpr_init(LhsExpr *self, bool is_pub, bool is_const, BufferView var_name);
+CHECK_RESULT int lhsexpr_init(LhsExpr *self, bool is_pub, bool is_const, BufferView var_name, ScopedAllocator *allocator);
void import_init(Import *self, BufferView path);
CHECK_RESULT int string_init(String *self, BufferView str);
void number_init(Number *self, i64 value, bool is_integer);