diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-03-19 16:59:11 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-03-19 16:59:11 +0000 |
| commit | 5562364a98f01a0c0221a70345656d45de0d2009 (patch) | |
| tree | 3ea4409ec3fcd1b7469c96d0e6ff03b437f8f823 /src/checker.c | |
| parent | 32150e401e39bd68f9882c3983829e744603dac1 (diff) | |
Add branch labels for loops; using list
Diffstat (limited to 'src/checker.c')
| -rw-r--r-- | src/checker.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/checker.c b/src/checker.c index 881e86c8b..4cd8e7ae9 100644 --- a/src/checker.c +++ b/src/checker.c @@ -98,7 +98,7 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = { // {STR_LIT("ptr_offset"), 2, false, Expr_Expr}, // {STR_LIT("ptr_sub"), 2, false, Expr_Expr}, - {STR_LIT("slice_ptr"), 2, false, Expr_Expr}, + {STR_LIT("slice_ptr"), 2, true, Expr_Expr}, {STR_LIT("slice_to_bytes"), 1, false, Expr_Stmt}, {STR_LIT("min"), 2, false, Expr_Expr}, @@ -163,6 +163,11 @@ bool is_operand_nil(Operand o) { } +typedef struct BlockLabel { + String name; + AstNode *label; // AstNode_Label +} BlockLabel; + // DeclInfo is used to store information of certain declarations to allow for "any order" usage typedef struct DeclInfo { Scope *scope; @@ -175,16 +180,19 @@ typedef struct DeclInfo { AstNode *proc_lit; // AstNode_ProcLit MapBool deps; // Key: Entity * + Array(BlockLabel) labels; } DeclInfo; // ProcedureInfo stores the information needed for checking a procedure + + typedef struct ProcedureInfo { - AstFile * file; - Token token; - DeclInfo *decl; - Type * type; // Type_Procedure - AstNode * body; // AstNode_BlockStmt - u32 tags; + AstFile * file; + Token token; + DeclInfo * decl; + Type * type; // Type_Procedure + AstNode * body; // AstNode_BlockStmt + u32 tags; } ProcedureInfo; // ExprInfo stores information used for "untyped" expressions @@ -320,6 +328,7 @@ typedef Array(DelayedEntity) DelayedEntities; void init_declaration_info(DeclInfo *d, Scope *scope) { d->scope = scope; map_bool_init(&d->deps, heap_allocator()); + array_init(&d->labels, heap_allocator()); } DeclInfo *make_declaration_info(gbAllocator a, Scope *scope) { @@ -455,6 +464,9 @@ void scope_lookup_parent_entity(Scope *scope, String name, Scope **scope_, Entit if (found) { Entity *e = *found; if (gone_thru_proc) { + if (e->kind == Entity_Label) { + continue; + } if (e->kind == Entity_Variable && !e->scope->is_file && !e->scope->is_global) { |