diff options
| author | Ginger Bill <bill@gingerbill.org> | 2016-09-19 21:33:52 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2016-09-19 21:33:52 +0100 |
| commit | 9561dc33cef4c5881034d429524a0498331a740e (patch) | |
| tree | 23820f1575123ad38d0ecdfa5bad9d8fecf92629 /src/checker/checker.cpp | |
| parent | bbc9739f5c1f6fa4dc8ad36aed7bcb1cba2eadea (diff) | |
enum_to_string
Diffstat (limited to 'src/checker/checker.cpp')
| -rw-r--r-- | src/checker/checker.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/checker/checker.cpp b/src/checker/checker.cpp index cc7099e96..483b6c0ef 100644 --- a/src/checker/checker.cpp +++ b/src/checker/checker.cpp @@ -159,6 +159,8 @@ enum BuiltinProcId { BuiltinProc_max, BuiltinProc_abs, + BuiltinProc_enum_to_string, + BuiltinProc_Count, }; @@ -200,6 +202,8 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = { {STR_LIT("max"), 2, false, Expr_Expr}, {STR_LIT("abs"), 1, false, Expr_Expr}, + {STR_LIT("enum_to_string"), 1, false, Expr_Expr}, + }; struct CheckerContext { @@ -358,6 +362,9 @@ void scope_lookup_parent_entity(Scope *scope, String name, Scope **scope_, Entit // Do not return imported entities even #load ones continue; } + if (!is_entity_exported(e)) { + continue; + } if (entity_) *entity_ = e; if (scope_) *scope_ = shared; return; @@ -409,7 +416,7 @@ Entity *scope_insert_entity(Scope *s, Entity *entity) { void check_scope_usage(Checker *c, Scope *scope) { // TODO(bill): Use this? -#if 0 +#if 1 gb_for_array(i, scope->elements.entries) { auto *entry = scope->elements.entries + i; Entity *e = entry->value; @@ -445,7 +452,7 @@ void add_global_entity(Entity *entity) { return; // NOTE(bill): `untyped thing` } if (scope_insert_entity(universal_scope, entity)) { - GB_PANIC("Compiler error: double declaration"); + compiler_error("double declaration"); } } @@ -492,10 +499,6 @@ void init_universal_scope(void) { entity->Builtin.id = id; add_global_entity(entity); } - -// Custom Runtime Types - { - } } @@ -1112,12 +1115,27 @@ void check_parsed_files(Checker *c) { ExpressionInfo *info = &entry->value; if (info != NULL && expr != NULL) { if (is_type_typed(info->type)) { - GB_PANIC("%s (type %s) is typed!", expr_to_string(expr), info->type); + compiler_error("%s (type %s) is typed!", expr_to_string(expr), info->type); } add_type_and_value(&c->info, expr, info->mode, info->type, info->value); } } #endif + + gb_for_array(i, c->parser->files) { + AstFile *f = &c->parser->files[i]; + Scope *scope = f->scope; + gb_for_array(j, scope->elements.entries) { + Entity *e = scope->elements.entries[j].value; + switch (e->kind) { + case Entity_ImportName: { + if (!e->ImportName.used) { + warning(e->token, "Unused import name: %.*s", LIT(e->ImportName.name)); + } + } break; + } + } + } } |