diff options
| author | gingerBill <bill@gingerbill.org> | 2018-06-11 17:34:57 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-06-11 17:34:57 +0100 |
| commit | 0a99595efe0cbe8fd02d5628420d2692e1640709 (patch) | |
| tree | 9a54c3b022798e6ea90cf154eadc77d54f7aaf4e /src/check_stmt.cpp | |
| parent | 268491b224ac07edc50d314c071b19970cf157d0 (diff) | |
Remove `using in` stuff
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index f4fd658db..42495d682 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1601,153 +1601,6 @@ void check_stmt_internal(CheckerContext *ctx, AstNode *node, u32 flags) { } case_end; - case_ast_node(uis, UsingInStmt, node); - if (uis->list.count == 0) { - error(node, "Empty 'using' list"); - return; - } - AstNode *expr = uis->expr; - Entity *e = nullptr; - Operand o = {}; - if (expr->kind == AstNode_Ident) { - e = check_ident(ctx, &o, expr, nullptr, nullptr, true); - } else if (expr->kind == AstNode_SelectorExpr) { - e = check_selector(ctx, &o, expr, nullptr); - } - if (e == nullptr) { - error(expr, "'using' applied to an unknown entity"); - return; - } - add_entity_use(ctx, expr, e); - - - switch (e->kind) { - case Entity_TypeName: { - Type *t = base_type(e->type); - if (t->kind == Type_Enum) { - GB_ASSERT(t->Enum.scope != nullptr); - for_array(list_index, uis->list) { - AstNode *node = uis->list[list_index]; - ast_node(ident, Ident, node); - String name = ident->token.string; - Entity *f = scope_lookup(t->Enum.scope, name); - - if (f == nullptr || !is_entity_exported(f)) { - if (is_blank_ident(name)) { - error(node, "'_' cannot be used as a value"); - } else { - error(node, "Undeclared name in this enumeration: '%.*s'", LIT(name)); - } - continue; - } - - add_entity_use(ctx, node, f); - add_entity(ctx->checker, ctx->scope, node, f); - } - } else { - error(node, "'using' can be only applied to enum type entities"); - } - - break; - } - - case Entity_ImportName: { - Scope *scope = e->ImportName.scope; - for_array(list_index, uis->list) { - AstNode *node = uis->list[list_index]; - ast_node(ident, Ident, node); - String name = ident->token.string; - - Entity *f = scope_lookup(scope, name); - if (f == nullptr) { - if (is_blank_ident(name)) { - error(node, "'_' cannot be used as a value"); - } else { - error(node, "Undeclared name in this import name: '%.*s'", LIT(name)); - } - continue; - } - - bool implicit_is_found = ptr_set_exists(&scope->implicit, f); - if (is_entity_exported(f) && !implicit_is_found) { - add_entity_use(ctx, node, f); - add_entity(ctx->checker, ctx->scope, node, f); - } else { - error(node, "'%.*s' is exported from '%.*s'", LIT(f->token.string), LIT(e->token.string)); - continue; - } - } - - break; - } - - case Entity_Variable: { - Type *t = base_type(type_deref(e->type)); - if (t->kind == Type_Struct) { - // TODO(bill): Make it work for unions too - Scope *found = scope_of_node(t->Struct.node); - for_array(list_index, uis->list) { - AstNode *node = uis->list[list_index]; - ast_node(ident, Ident, node); - String name = ident->token.string; - - Entity *f = scope_lookup(found, name); - if (f == nullptr || f->kind != Entity_Variable) { - if (is_blank_ident(name)) { - error(node, "'_' cannot be used as a value"); - } else { - error(node, "Undeclared name in this variable: '%.*s'", LIT(name)); - } - continue; - } - - Entity *uvar = alloc_entity_using_variable(e, f->token, f->type); - uvar->using_expr = expr; - Entity *prev = scope_insert(ctx->scope, uvar); - if (prev != nullptr) { - gbString expr_str = expr_to_string(expr); - error(node, "Namespace collision while using '%s' of: '%.*s'", expr_str, LIT(prev->token.string)); - gb_string_free(expr_str); - continue; - } - } - } else { - error(node, "'using' can only be applied to variables of type `struct`"); - return; - } - - break; - } - - case Entity_Constant: - error(node, "'using' cannot be applied to a constant"); - break; - - case Entity_Procedure: - case Entity_ProcGroup: - case Entity_Builtin: - error(node, "'using' cannot be applied to a procedure"); - break; - - case Entity_Nil: - error(node, "'using' cannot be applied to 'nil'"); - break; - - case Entity_Label: - error(node, "'using' cannot be applied to a label"); - break; - - case Entity_Invalid: - error(node, "'using' cannot be applied to an invalid entity"); - break; - - default: - GB_PANIC("TODO(bill): 'using' other expressions?"); - } - case_end; - - - case_ast_node(pa, PushContext, node); Operand op = {}; check_expr(ctx, &op, pa->expr); |