1
0
mirror of https://github.com/golang/go synced 2024-11-21 19:54:41 -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;
// interface is easy
if(et == TINTER) {
if(et == TINTER || et == TDDD) {
if(t->sym && !t->local)
continue;
dumpsigi(t, s);

View File

@ -1609,7 +1609,7 @@ signame(Type *t)
goto bad;
e = "sigt";
if(t->etype == TINTER)
if(t->etype == TINTER || t->etype == TDDD)
e = "sigi";
// 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.
if(strcmp(buf, "interface { }") == 0)
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);
if(ss->oname == N) {

View File

@ -348,7 +348,7 @@ loop:
case OPROC:
if(top != Etop)
goto nottop;
walkstate(n->left);
walktype(n->left, Etop);
goto ret;
case OCALLMETH:
@ -1820,7 +1820,10 @@ mkdotargs(Node *r, Node *rr, Iter *saver, Node *nn, Type *l, int fp)
var = nod(OXXX, N, N);
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);
r = listfirst(&saven, &n);
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->type = r->right->type;
r->left->xoffset += t->width;
nn = list(r, nn);
addtop = list(addtop, r);
r = listnext(&saven);
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
// of a pointer to the structure to
// the DDD parameter
a = nod(OADDR, var, N);
a->type = ptrto(st);
a = nod(OAS, nodarg(l, fp), a);
a = convas(a);
nn = list(a, nn);
a = nod(OAS, nodarg(l, fp), var);
nn = list(convas(a), 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.
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.doprintf(format, v);
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 {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter();
p.doprintf(format, v);
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.
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.doprint(v, false, false);
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 {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter();
p.doprint(v, false, false);
s := string(p.buf)[0 : p.n];
@ -179,7 +179,7 @@ func Sprint(a ...) string {
// after the last operand.
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.doprint(v, true, true);
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 {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
v := reflect.NewValue(a).(reflect.StructValue);
p := newPrinter();
p.doprint(v, true, true);
s := string(p.buf)[0 : p.n];