]> Cypherpunks repositories - gostls13.git/commitdiff
fixed export sort for methods
authorKen Thompson <ken@golang.org>
Tue, 23 Sep 2008 19:48:52 +0000 (12:48 -0700)
committerKen Thompson <ken@golang.org>
Tue, 23 Sep 2008 19:48:52 +0000 (12:48 -0700)
R=r
OCL=15699
CL=15699

src/cmd/gc/export.c

index 0fef1144e9e5d452312f9f2cb322a9d6de614a2b..57b1f31e8a37088c08cc677ccaa1bc9a3bf11bf8 100644 (file)
@@ -236,13 +236,6 @@ dumpexporttype(Sym *s)
                Bprint(bout, "%lS %d %lS\n", s, t->chan, t->type->sym);
                break;
        }
-
-       for(f=t->method; f!=T; f=f->down) {
-               if(f->etype != TFIELD)
-                       fatal("dumpexporttype: method not field: %lT", f);
-               reexport(f->type);
-               Bprint(bout, "\tfunc %S %lS\n", f->sym, f->type->sym);
-       }
 }
 
 void
@@ -268,6 +261,34 @@ dumpe(Sym *s)
        }
 }
 
+void
+dumpm(Sym *s)
+{
+       Type *t, *f;
+
+       switch(s->lexical) {
+       default:
+               return;
+
+       case LATYPE:
+       case LBASETYPE:
+               break;
+       }
+
+       t = s->otype;
+       if(t == T) {
+               yyerror("type exported but not defined: %S", s);
+               return;
+       }
+
+       for(f=t->method; f!=T; f=f->down) {
+               if(f->etype != TFIELD)
+                       fatal("dumpexporttype: method not field: %lT", f);
+               reexport(f->type);
+               Bprint(bout, "\tfunc %S %lS\n", f->sym, f->type->sym);
+       }
+}
+
 void
 dumpexport(void)
 {
@@ -281,12 +302,18 @@ dumpexport(void)
 
        Bprint(bout, "    package %s\n", package);
 
-       // print it depth first
+       // first pass dump vars/types depth first
        for(d=exportlist->forw; d!=D; d=d->forw) {
                lineno = d->lineno;
                dumpe(d->dsym);
        }
 
+       // second pass dump methods
+       for(d=exportlist->forw; d!=D; d=d->forw) {
+               lineno = d->lineno;
+               dumpm(d->dsym);
+       }
+
        Bprint(bout, "   ))\n");
 
        lineno = lno;