summaryrefslogtreecommitdiff
path: root/src/cmd/gc/lex.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-06-12 11:17:24 -0700
committerRuss Cox <rsc@golang.org>2010-06-12 11:17:24 -0700
commit171e56e8ce55c0937e4f4fe0487c0e69ddac2f74 (patch)
tree791790d4d7d3f5aabc0cf1235a9ff2a4e40c0e66 /src/cmd/gc/lex.c
parent5cc45168f9d5aa01db50aa19ce69e39fc4967541 (diff)
downloadgolang-171e56e8ce55c0937e4f4fe0487c0e69ddac2f74.tar.gz
gc: less aggressive name binding, for better line numbers in errors
Cleans up a few other corner cases too. R=ken2 CC=golang-dev http://codereview.appspot.com/1592045
Diffstat (limited to 'src/cmd/gc/lex.c')
-rw-r--r--src/cmd/gc/lex.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c
index b08100993..791686caf 100644
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -1444,11 +1444,6 @@ lexinit(void)
}
}
- s = lookup("iota");
- s->def = nod(ONONAME, N, N);
- s->def->iota = 1;
- s->def->sym = s;
-
// logically, the type of a string literal.
// types[TSTRING] is the named type string
// (the type of x in var x string or var x = "hello").
@@ -1491,13 +1486,12 @@ lexfini(void)
s->lexical = lex;
etype = syms[i].etype;
- if(etype != Txxx && (etype != TANY || debug['A']))
- if(s->def != N && s->def->op == ONONAME)
- *s->def = *typenod(types[etype]);
+ if(etype != Txxx && (etype != TANY || debug['A']) && s->def == N)
+ s->def = typenod(types[etype]);
etype = syms[i].op;
- if(etype != OXXX && s->def != N && s->def->op == ONONAME) {
- s->def->op = ONAME;
+ if(etype != OXXX && s->def == N) {
+ s->def = nod(ONAME, N, N);
s->def->sym = s;
s->def->etype = etype;
s->def->builtin = 1;
@@ -1506,29 +1500,35 @@ lexfini(void)
for(i=0; typedefs[i].name; i++) {
s = lookup(typedefs[i].name);
- if(s->def != N && s->def->op == ONONAME)
- *s->def = *typenod(types[typedefs[i].etype]);
+ if(s->def == N)
+ s->def = typenod(types[typedefs[i].etype]);
}
// there's only so much table-driven we can handle.
// these are special cases.
types[TNIL] = typ(TNIL);
s = lookup("nil");
- if(s->def != N && s->def->op == ONONAME) {
+ if(s->def == N) {
v.ctype = CTNIL;
- *s->def = *nodlit(v);
+ s->def = nodlit(v);
+ s->def->sym = s;
+ }
+
+ s = lookup("iota");
+ if(s->def == N) {
+ s->def = nod(OIOTA, N, N);
s->def->sym = s;
}
s = lookup("true");
- if(s->def != N && s->def->op == ONONAME) {
- *s->def = *nodbool(1);
+ if(s->def == N) {
+ s->def = nodbool(1);
s->def->sym = s;
}
s = lookup("false");
- if(s->def != N && s->def->op == ONONAME) {
- *s->def = *nodbool(0);
+ if(s->def == N) {
+ s->def = nodbool(0);
s->def->sym = s;
}