diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-01-27 12:43:01 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-01-27 12:43:01 +0000 |
| commit | d3d3bfd4557c23da58a33066c4a7e5042435829d (patch) | |
| tree | 1c9be3f5fdc3930d3933c46cca796502c5b4ca2f /src/check_expr.c | |
| parent | ce3582fd898508719a38e4d59e97aa7f868f89af (diff) | |
Fix utf8 stuff, Allow _ in numbers, Begin writing next demo code.
Diffstat (limited to 'src/check_expr.c')
| -rw-r--r-- | src/check_expr.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/check_expr.c b/src/check_expr.c index 039795fae..273f237fb 100644 --- a/src/check_expr.c +++ b/src/check_expr.c @@ -3892,6 +3892,16 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint } else if (str_eq(bd->name, str_lit("line"))) { o->type = t_untyped_integer; o->value = make_exact_value_integer(bd->token.pos.line); + } else if (str_eq(bd->name, str_lit("procedure"))) { + if (c->proc_stack.count == 0) { + error_node(node, "#procedure may only be used within procedures"); + o->type = t_untyped_string; + o->value = make_exact_value_string(str_lit("")); + } else { + o->type = t_untyped_string; + o->value = make_exact_value_string(c->context.proc_name); + } + } else { GB_PANIC("Unknown basic basic directive"); } @@ -3962,9 +3972,11 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint goto error; } else if (operands.count == 1) { Operand operand = operands.e[0]; - if (type_hint != NULL) { - convert_to_typed(c, &operand, type_hint, 0); + Type *th = type_hint != NULL ? type_hint : c->context.type_hint; + if (th != NULL) { + convert_to_typed(c, &operand, th, 0); } + // IMPORTANT NOTE(bill): This type could be untyped!!! o->type = default_type(operand.type); o->mode = Addressing_Value; } else { @@ -4012,10 +4024,14 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint goto error; } + CheckerContext prev_context = c->context; + c->context.type_hint = type_hint; check_open_scope(c, node); check_stmt_list(c, be->stmts, Stmt_GiveAllowed); check_close_scope(c); + c->context = prev_context; + AstNode *give_node = NULL; if (!check_is_giving(node, &give_node) || give_node == NULL) { error_node(node, "Missing give statement at end of block expression"); |