diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-03-20 18:53:47 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | 5df7f92e715ba764ee57f65d78e73111492bb64c (patch) | |
tree | 87e25089674432d43d1ed8edad5c4c6ca3fd72b1 /include | |
parent | 071bdd4d6facb8786f089882d53c127e6163e3ce (diff) |
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).
Diffstat (limited to 'include')
-rw-r--r-- | include/ast.h | 8 | ||||
-rw-r--r-- | include/tokenizer.h | 3 |
2 files changed, 6 insertions, 5 deletions
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<LhsExpr>)*/ 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); diff --git a/include/tokenizer.h b/include/tokenizer.h index c4c3725..3944ed1 100644 --- a/include/tokenizer.h +++ b/include/tokenizer.h @@ -30,7 +30,8 @@ typedef enum { TOK_NUMBER, TOK_SEMICOLON, TOK_COLON, - TOK_BINOP + TOK_BINOP, + TOK_PUB } Token; typedef struct { |