1
0
mirror of https://github.com/golang/go synced 2024-11-12 06:40:22 -07:00

change dotdotdot interfaces to be structs,

not pointers to structs.

fix defered dotdotdot.

R=r,ken
DELTA=25  (7 added, 5 deleted, 13 changed)
OCL=23620
CL=23625
This commit is contained in:
Russ Cox 2009-01-27 15:05:25 -08:00
parent 7471eab96f
commit 743ac07cc3
4 changed files with 20 additions and 18 deletions

View File

@ -941,7 +941,7 @@ dumpsignatures(void)
s->siggen = 1; s->siggen = 1;
// interface is easy // interface is easy
if(et == TINTER) { if(et == TINTER || et == TDDD) {
if(t->sym && !t->local) if(t->sym && !t->local)
continue; continue;
dumpsigi(t, s); dumpsigi(t, s);

View File

@ -1609,7 +1609,7 @@ signame(Type *t)
goto bad; goto bad;
e = "sigt"; e = "sigt";
if(t->etype == TINTER) if(t->etype == TINTER || t->etype == TDDD)
e = "sigi"; e = "sigi";
// name is exported name, like *[]byte or *Struct or Interface // name is exported name, like *[]byte or *Struct or Interface
@ -1620,6 +1620,10 @@ signame(Type *t)
// so that it can be referred to by the runtime. // so that it can be referred to by the runtime.
if(strcmp(buf, "interface { }") == 0) if(strcmp(buf, "interface { }") == 0)
strcpy(buf, "empty"); strcpy(buf, "empty");
// special case: sigi.... is just too hard to read in assembly.
if(strcmp(buf, "...") == 0)
strcpy(buf, "dotdotdot");
ss = pkglookup(buf, e); ss = pkglookup(buf, e);
if(ss->oname == N) { if(ss->oname == N) {

View File

@ -348,7 +348,7 @@ loop:
case OPROC: case OPROC:
if(top != Etop) if(top != Etop)
goto nottop; goto nottop;
walkstate(n->left); walktype(n->left, Etop);
goto ret; goto ret;
case OCALLMETH: case OCALLMETH:
@ -1820,7 +1820,10 @@ mkdotargs(Node *r, Node *rr, Iter *saver, Node *nn, Type *l, int fp)
var = nod(OXXX, N, N); var = nod(OXXX, N, N);
tempname(var, st); tempname(var, st);
// assign the fields to the struct // assign the fields to the struct.
// use addtop so that reorder1 doesn't reorder
// these assignments after the interface conversion
// below.
n = rev(n); n = rev(n);
r = listfirst(&saven, &n); r = listfirst(&saven, &n);
t = st->type; t = st->type;
@ -1829,7 +1832,7 @@ mkdotargs(Node *r, Node *rr, Iter *saver, Node *nn, Type *l, int fp)
*r->left = *var; *r->left = *var;
r->left->type = r->right->type; r->left->type = r->right->type;
r->left->xoffset += t->width; r->left->xoffset += t->width;
nn = list(r, nn); addtop = list(addtop, r);
r = listnext(&saven); r = listnext(&saven);
t = t->down; t = t->down;
} }
@ -1837,13 +1840,8 @@ mkdotargs(Node *r, Node *rr, Iter *saver, Node *nn, Type *l, int fp)
// last thing is to put assignment // last thing is to put assignment
// of a pointer to the structure to // of a pointer to the structure to
// the DDD parameter // the DDD parameter
a = nod(OAS, nodarg(l, fp), var);
a = nod(OADDR, var, N); nn = list(convas(a), nn);
a->type = ptrto(st);
a = nod(OAS, nodarg(l, fp), a);
a = convas(a);
nn = list(a, nn);
return nn; return nn;
} }

View File

@ -130,7 +130,7 @@ func (p *pp) doprint(v reflect.StructValue, addspace, addnewline bool);
// These routines end in 'f' and take a format string. // These routines end in 'f' and take a format string.
func Fprintf(w io.Write, format string, a ...) (n int, error *os.Error) { func Fprintf(w io.Write, format string, a ...) (n int, error *os.Error) {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue); v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter(); p := newPrinter();
p.doprintf(format, v); p.doprintf(format, v);
n, error = w.Write(p.buf[0:p.n]); n, error = w.Write(p.buf[0:p.n]);
@ -143,7 +143,7 @@ func Printf(format string, v ...) (n int, errno *os.Error) {
} }
func Sprintf(format string, a ...) string { func Sprintf(format string, a ...) string {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue); v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter(); p := newPrinter();
p.doprintf(format, v); p.doprintf(format, v);
s := string(p.buf)[0 : p.n]; s := string(p.buf)[0 : p.n];
@ -154,7 +154,7 @@ func Sprintf(format string, a ...) string {
// when the operand on neither side is a string. // when the operand on neither side is a string.
func Fprint(w io.Write, a ...) (n int, error *os.Error) { func Fprint(w io.Write, a ...) (n int, error *os.Error) {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue); v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter(); p := newPrinter();
p.doprint(v, false, false); p.doprint(v, false, false);
n, error = w.Write(p.buf[0:p.n]); n, error = w.Write(p.buf[0:p.n]);
@ -167,7 +167,7 @@ func Print(v ...) (n int, errno *os.Error) {
} }
func Sprint(a ...) string { func Sprint(a ...) string {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue); v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter(); p := newPrinter();
p.doprint(v, false, false); p.doprint(v, false, false);
s := string(p.buf)[0 : p.n]; s := string(p.buf)[0 : p.n];
@ -179,7 +179,7 @@ func Sprint(a ...) string {
// after the last operand. // after the last operand.
func Fprintln(w io.Write, a ...) (n int, error *os.Error) { func Fprintln(w io.Write, a ...) (n int, error *os.Error) {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue); v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter(); p := newPrinter();
p.doprint(v, true, true); p.doprint(v, true, true);
n, error = w.Write(p.buf[0:p.n]); n, error = w.Write(p.buf[0:p.n]);
@ -192,7 +192,7 @@ func Println(v ...) (n int, errno *os.Error) {
} }
func Sprintln(a ...) string { func Sprintln(a ...) string {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue); v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter(); p := newPrinter();
p.doprint(v, true, true); p.doprint(v, true, true);
s := string(p.buf)[0 : p.n]; s := string(p.buf)[0 : p.n];