aboutsummaryrefslogtreecommitdiff
path: root/src/checker/expr.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-09-28 21:25:14 +0100
committerGinger Bill <bill@gingerbill.org>2016-09-28 21:25:14 +0100
commit6e39a42c8a090d6e32231872cc292c90de6b304e (patch)
tree09d9375b92af5caf5cd6a5062e2b1422ab7e461d /src/checker/expr.cpp
parent5f6b0942f405f5595787ba3436e2e5410268e71e (diff)
Demo 004
Diffstat (limited to 'src/checker/expr.cpp')
-rw-r--r--src/checker/expr.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/checker/expr.cpp b/src/checker/expr.cpp
index 658584ba4..964e268fa 100644
--- a/src/checker/expr.cpp
+++ b/src/checker/expr.cpp
@@ -796,7 +796,7 @@ void check_procedure_type(Checker *c, Type *type, AstNode *proc_type_node) {
}
-void check_identifier(Checker *c, Operand *o, AstNode *n, Type *named_type, CycleChecker *cycle_checker = NULL) {
+void check_identifier(Checker *c, Operand *o, AstNode *n, Type *named_type, CycleChecker *cycle_checker) {
GB_ASSERT(n->kind == AstNode_Ident);
o->mode = Addressing_Invalid;
o->expr = n;
@@ -816,13 +816,13 @@ void check_identifier(Checker *c, Operand *o, AstNode *n, Type *named_type, Cycl
}
add_entity_use(c, n, e);
- CycleChecker local_cycle_checker = {};
- if (cycle_checker == NULL) {
- cycle_checker = &local_cycle_checker;
- }
- defer (if (local_cycle_checker.path != NULL) {
- gb_array_free(local_cycle_checker.path);
- });
+ // CycleChecker local_cycle_checker = {};
+ // if (cycle_checker == NULL) {
+ // cycle_checker = &local_cycle_checker;
+ // }
+ // defer (if (local_cycle_checker.path != NULL) {
+ // gb_array_free(local_cycle_checker.path);
+ // });
check_entity_decl(c, e, NULL, named_type, cycle_checker);
@@ -857,17 +857,19 @@ void check_identifier(Checker *c, Operand *o, AstNode *n, Type *named_type, Cycl
o->mode = Addressing_Type;
#if 0
// TODO(bill): Fix cyclical dependancy checker
- gb_for_array(i, cycle_checker->path) {
- Entity *prev = cycle_checker->path[i];
- if (prev == e) {
- error(e->token, "Illegal declaration cycle for %.*s", LIT(e->token.string));
- for (isize j = i; j < gb_array_count(cycle_checker->path); j++) {
- Entity *ref = cycle_checker->path[j];
- error(ref->token, "\t%.*s refers to", LIT(ref->token.string));
+ if (cycle_checker != NULL) {
+ gb_for_array(i, cycle_checker->path) {
+ Entity *prev = cycle_checker->path[i];
+ if (prev == e) {
+ error(e->token, "Illegal declaration cycle for %.*s", LIT(e->token.string));
+ for (isize j = i; j < gb_array_count(cycle_checker->path); j++) {
+ Entity *ref = cycle_checker->path[j];
+ error(ref->token, "\t%.*s refers to", LIT(ref->token.string));
+ }
+ error(e->token, "\t%.*s", LIT(e->token.string));
+ type = t_invalid;
+ break;
}
- error(e->token, "\t%.*s", LIT(e->token.string));
- type = t_invalid;
- break;
}
}
#endif
@@ -3170,7 +3172,7 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint
case_end;
case_ast_node(i, Ident, node);
- check_identifier(c, o, node, type_hint);
+ check_identifier(c, o, node, type_hint, NULL);
case_end;
case_ast_node(bl, BasicLit, node);