diff options
author | Ken Thompson <ken@golang.org> | 2010-03-09 17:51:30 -0800 |
---|---|---|
committer | Ken Thompson <ken@golang.org> | 2010-03-09 17:51:30 -0800 |
commit | 05da857f354ad32072c3f7d897e1f43001e650b4 (patch) | |
tree | 02d22e4424d71c0d52b0e6e93dbaadaca0eacd2c /src | |
parent | 943040a11c0d0499bb48b9ca3e49b561cd2d6843 (diff) | |
download | go-05da857f354ad32072c3f7d897e1f43001e650b4.tar.gz |
1. decommit complex(float) conversion
2. add complex algorithm for map/chan
3. test for use of complex in
array, slice, field, chan, map,
field, pointer.
R=rsc
CC=golang-dev
http://codereview.appspot.com/384041
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/gc/const.c | 4 | ||||
-rw-r--r-- | src/cmd/gc/cplx.c | 12 | ||||
-rw-r--r-- | src/cmd/gc/subr.c | 4 | ||||
-rw-r--r-- | src/cmd/gc/typecheck.c | 11 |
4 files changed, 13 insertions, 18 deletions
diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c index 7debb3708..be351def6 100644 --- a/src/cmd/gc/const.c +++ b/src/cmd/gc/const.c @@ -76,14 +76,12 @@ convlit1(Node **np, Type *t, int explicit) if(!explicit && !isideal(n->type)) return; -//dump("convlit1", n); if(n->op == OLITERAL) { nn = nod(OXXX, N, N); *nn = *n; n = nn; *np = n; } -//dump("convlit2", n); switch(n->op) { default: @@ -203,6 +201,8 @@ convlit1(Node **np, Type *t, int explicit) goto bad; case CTFLT: case CTINT: + if(explicit) + goto bad; n->val = tocplx(n->val); break; case CTCPLX: diff --git a/src/cmd/gc/cplx.c b/src/cmd/gc/cplx.c index 7538a432a..d7f29d837 100644 --- a/src/cmd/gc/cplx.c +++ b/src/cmd/gc/cplx.c @@ -58,18 +58,6 @@ complexmove(Node *f, Node *t) cgen(&n1, &n3); cgen(&n2, &n4); break; - - // these are depricated - case CASE(TFLOAT32,TCOMPLEX64): - case CASE(TFLOAT32,TCOMPLEX128): - case CASE(TFLOAT64,TCOMPLEX64): - case CASE(TFLOAT64,TCOMPLEX128): - // float to complex goes to real part - - subnode(&n1, &n2, t); - cgen(f, &n1); - zero(&n2); - break; } } diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c index 97bb60d2e..0c01e728c 100644 --- a/src/cmd/gc/subr.c +++ b/src/cmd/gc/subr.c @@ -458,7 +458,8 @@ algtype(Type *t) { int a; - if(issimple[t->etype] || isptr[t->etype] || t->etype == TCHAN || t->etype == TFUNC || t->etype == TMAP) + if(issimple[t->etype] || isptr[t->etype] || iscomplex[t->etype] || + t->etype == TCHAN || t->etype == TFUNC || t->etype == TMAP) a = AMEM; // just bytes (int, ptr, etc) else if(t->etype == TSTRING) a = ASTRING; // string @@ -476,6 +477,7 @@ maptype(Type *key, Type *val) { Type *t; + if(key != nil && key->etype != TANY && algtype(key) == ANOEQ) { if(key->etype == TFORW) { // map[key] used during definition of key. diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 654e72b5f..4e5b5bbcd 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -1449,9 +1449,14 @@ checkconv(Type *nt, Type *t, int explicit, int *op, int *et, char *desc) return 1; } - // simple fix-float-complex - if(isint[t->etype] || isfloat[t->etype] || iscomplex[t->etype]) - if(isint[nt->etype] || isfloat[nt->etype] || iscomplex[nt->etype]) + // simple fix-float + if(isint[t->etype] || isfloat[t->etype]) + if(isint[nt->etype] || isfloat[nt->etype]) + return 1; + + // simple complex-complex + if(iscomplex[t->etype]) + if(iscomplex[nt->etype]) return 1; // to string |