aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.c
diff options
context:
space:
mode:
authorzhiayang <zhiayang@gmail.com>2017-02-02 04:21:42 +0800
committerzhiayang <zhiayang@gmail.com>2017-02-02 04:21:42 +0800
commit5516e80ab775d1100beca7847e10520eae4b151c (patch)
treefd080deab099e74ec5f50841c6a8b5b5b8b5c3c4 /src/check_expr.c
parent864310e3da059371ac7345ee3bf900a6055f26b4 (diff)
parent4e7082a68dd5261c3c36eccf92a62a0ce84995a8 (diff)
Merge branch 'master' of https://github.com/zhiayang/Odin
Diffstat (limited to 'src/check_expr.c')
-rw-r--r--src/check_expr.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/check_expr.c b/src/check_expr.c
index ca4a0baed..6b09c3a82 100644
--- a/src/check_expr.c
+++ b/src/check_expr.c
@@ -880,6 +880,7 @@ void check_identifier(Checker *c, Operand *o, AstNode *n, Type *named_type, Type
o->mode = Addressing_Invalid;
o->expr = n;
String name = n->Ident.string;
+
Entity *e = scope_lookup_entity(c->context.scope, name);
if (e == NULL) {
if (str_eq(name, str_lit("_"))) {
@@ -3991,6 +3992,23 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint
goto error;
case_end;
+ case_ast_node(i, Implicit, node)
+ switch (i->kind) {
+ case Token_context:
+ if (c->context.proc_name.len == 0) {
+ error_node(node, "`context` is only allowed within procedures");
+ goto error;
+ }
+
+ o->mode = Addressing_Value;
+ o->type = t_context;
+ break;
+ default:
+ error_node(node, "Illegal implicit name `%.*s`", LIT(i->string));
+ goto error;
+ }
+ case_end;
+
case_ast_node(i, Ident, node);
check_identifier(c, o, node, NULL, type_hint);
case_end;