From 5df7f92e715ba764ee57f65d78e73111492bb64c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 20 Mar 2019 18:53:47 +0100 Subject: Add pub keyword, more import stuff, optimize hash map Hash map now stores hash of keys to reduce the number of hash operations. Positive: faster insert/get. Negative: more space required (to store usize hash). --- include/ast.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/ast.h') diff --git a/include/ast.h b/include/ast.h index e49ad08..7b16796 100644 --- a/include/ast.h +++ b/include/ast.h @@ -65,12 +65,12 @@ typedef struct { AstValue value; AstType type; AstResolveStatus resolve_status; - StructDecl *resolved_type; + LhsExpr *resolved_type; } Ast; struct Scope { Buffer ast_objects; - HashMap/*(key=BufferView, value=Ast)*/ named_objects; + HashMap/*(key=BufferView, value=Ast)*/ named_objects; Scope *parent; }; @@ -81,7 +81,6 @@ struct FileScopeReference { struct Variable { BufferView name; - Ast resolved_variable; }; struct FunctionDecl { @@ -104,6 +103,7 @@ struct StructField { }; struct LhsExpr { + bool is_pub; bool is_const; BufferView var_name; Variable type; @@ -149,7 +149,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_const, BufferView var_name); +void lhsexpr_init(LhsExpr *self, bool is_pub, bool is_const, BufferView var_name); 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