From 4f308829ad0e81a59971e172284c018cf2bdca3d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 22 Mar 2019 20:48:40 +0100 Subject: Add mutex for lhs expr, add error for missing lhs expr for func, struct TODO: Use mutex in lhs expr and set resolved_type --- include/ast.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include/ast.h') 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); -- cgit v1.2.3