diff options
Diffstat (limited to 'include/ast.h')
-rw-r--r-- | include/ast.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/include/ast.h b/include/ast.h index 25d9034..56795cd 100644 --- a/include/ast.h +++ b/include/ast.h @@ -43,7 +43,6 @@ typedef union { } AstValue; typedef enum { - AST_NONE, AST_FUNCTION_DECL, AST_FUNCTION_CALL, AST_STRUCT_DECL, @@ -63,15 +62,19 @@ typedef enum { } AstResolveStatus; typedef struct { + LhsExpr *type; + AstResolveStatus status; +} AstResolveData; + +typedef struct { AstValue value; AstType type; - AstResolveStatus resolve_status; - LhsExpr *resolved_type; + AstResolveData resolve_data; } Ast; struct Scope { - Buffer ast_objects; - HashMap/*(key=BufferView, value=Ast<LhsExpr>)*/ named_objects; + Buffer/*<Ast*>*/ ast_objects; + HashMap/*(key=BufferView, value=Ast<LhsExpr>*)*/ named_objects; Scope *parent; }; @@ -91,7 +94,7 @@ struct FunctionDecl { struct FunctionCall { Variable func; - Buffer/*Ast*/ args; + Buffer/*<Ast*>*/ args; }; struct StructDecl { @@ -108,7 +111,7 @@ struct LhsExpr { bool is_const; BufferView var_name; Variable type; - Ast rhs_expr; + 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 @@ -136,8 +139,8 @@ struct Number { }; struct Binop { - Ast lhs; - Ast rhs; + Ast *lhs; + Ast *rhs; BinopType type; /* Is the binop already ordered - no need to reorder it */ bool grouped; @@ -149,8 +152,7 @@ typedef struct { Scope *scope; } AstCompilerContext; -Ast ast_none(); -void ast_init(Ast *self, void *value, AstType type); +CHECK_RESULT int ast_create(ScopedAllocator *allocator, void *value, AstType type, Ast **result); BufferView ast_get_name(Ast *self); CHECK_RESULT int funcdecl_init(FunctionDecl *self, Scope *parent, ScopedAllocator *allocator); |