]> Cypherpunks repositories - gostls13.git/commitdiff
change dotdotdot interfaces to be structs,
authorRuss Cox <rsc@golang.org>
Tue, 27 Jan 2009 23:05:25 +0000 (15:05 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 27 Jan 2009 23:05:25 +0000 (15:05 -0800)
not pointers to structs.

fix defered dotdotdot.

R=r,ken
DELTA=25  (7 added, 5 deleted, 13 changed)
OCL=23620
CL=23625

src/cmd/6g/obj.c
src/cmd/gc/subr.c
src/cmd/gc/walk.c
src/lib/fmt/print.go

index 85e668d668517be712509f561a0dcf74f993b181..cd44bd6f84f084c23aa821ab3356663ccae0de7a 100644 (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);
index 98e99ab3b358ad4bd317a117fcc849b43c89edd4..870a90167af55e027e2aa88946ba06d52766dfb2 100644 (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) {
index 5004a86f02de2b05f162187e4e9b53d568e51d40..1bab4b9cd04d4f4f02fc1c293b02ec61acfd3d21 100644 (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;
 }
index a75e0fff2593304f3f411c431e760677224e2891..99dfe761402416b2f9acd142c12f939271d32f1d 100644 (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];