diff options
-rw-r--r-- | test.toc | 8 | ||||
-rw-r--r-- | types.c | 1 | ||||
-rw-r--r-- | types.h | 11 |
3 files changed, 17 insertions, 3 deletions
@@ -1,6 +1,8 @@ -#include "std/mem.toc"; +Point ::= struct { + x, y: int; +} main ::= fn() { - thing := new(int); - del(thing); + p: Point; + use p; } @@ -3480,6 +3480,7 @@ static Status types_stmt(Typer *tr, Statement *s) { } static void typer_create(Typer *tr, Evaluator *ev, ErrCtx *err_ctx, Allocator *allocr, Identifiers *idents) { + tr->used = NULL; tr->block = NULL; tr->blocks = NULL; tr->fn = NULL; @@ -1033,6 +1033,16 @@ typedef struct Evaluator { ForeignFnManager ffmgr; } Evaluator; +/* +Keeps track of use stmts. +We need to keep track of the block so that +it can be removed when we exit the block. +*/ +typedef struct { + Statement *stmt; + Block *scope; +} UsedExpr; + typedef struct Typer { Allocator *allocr; Evaluator *evalr; @@ -1046,6 +1056,7 @@ typedef struct Typer { ParsedFile *parsed_file; Namespace *nms; StrHashTable included_files; /* maps to IncludedFile */ + UsedExpr *used; /* things which are currently being `use`d */ } Typer; typedef struct CGenerator { |