]> Cypherpunks repositories - gostls13.git/commitdiff
cleanup toward eliminating package global name space
authorRuss Cox <rsc@golang.org>
Wed, 20 Jan 2010 05:34:44 +0000 (21:34 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 20 Jan 2010 05:34:44 +0000 (21:34 -0800)
  * switch to real dot (.) instead of center dot (·) everywhere in object files.
    before it was half and half depending on where in the name it appeared.
  * in 6c/6a/etc identifiers, · can still be used but turns into . immediately.
  * in export metadata, replace package identifiers with quoted strings
    (still package names, not paths).

R=ken2, r
CC=golang-dev
https://golang.org/cl/190076

19 files changed:
src/cmd/5g/gobj.c
src/cmd/5l/noop.c
src/cmd/5l/obj.c
src/cmd/6g/gobj.c
src/cmd/6l/pass.c
src/cmd/8g/gobj.c
src/cmd/8l/pass.c
src/cmd/cc/lex.c
src/cmd/cc/lexbody
src/cmd/gc/builtin.c.boot
src/cmd/gc/dcl.c
src/cmd/gc/export.c
src/cmd/gc/go.h
src/cmd/gc/go.y
src/cmd/gc/mkbuiltin1.c
src/cmd/gc/obj.c
src/cmd/gc/subr.c
src/cmd/gotest/gotest
src/cmd/ld/go.c

index bc29ba28bf1e11185b86fda7f559cce754edaf9c..33cd123a4ce789b08efb2d9863a8556580711092 100644 (file)
 void
 zname(Biobuf *b, Sym *s, int t)
 {
-       char *n;
-
        Bputc(b, ANAME);        /* as */
        Bputc(b, t);            /* type */
        Bputc(b, s->sym);       /* sym */
 
-       for(n=s->package; *n; n++)
-               Bputc(b, *n);
-       Bputdot(b);
-       for(n=s->name; *n; n++)
-               Bputc(b, *n);
-       Bputc(b, 0);
+       Bputname(b, s);
 }
 
 void
index f67deb821ff93e8677481ff851880b0e3fb56901..bcc48e1117cbfd2c833c5400a6c2b81a7665829c 100644 (file)
@@ -128,7 +128,7 @@ noops(void)
        Bflush(&bso);
 
        pmorestack = P;
-       symmorestack = lookup("runtime·morestack", 0);
+       symmorestack = lookup("runtime.morestack", 0);
 
        if(symmorestack->type == STEXT)
        for(p = firstp; p != P; p = p->link) {
@@ -361,7 +361,7 @@ noops(void)
                                // MOVW.LO              $autosize, R1
                                // MOVW.LO              $args, R2
                                // MOVW.LO              R14, R3
-                               // BL.LO                        runtime·morestack(SB) // modifies LR
+                               // BL.LO                        runtime.morestack(SB) // modifies LR
                                // MOVW.W               R14,$-autosize(SP)
 
                                // TODO(kaib): add more trampolines
@@ -412,7 +412,7 @@ noops(void)
                                p->to.type = D_REG;
                                p->to.reg = 3;
 
-                               // BL.LO                runtime·morestack(SB) // modifies LR
+                               // BL.LO                runtime.morestack(SB) // modifies LR
                                p = appendp(p);
                                p->as = ABL;
                                p->scond = C_SCOND_LO;
@@ -433,7 +433,7 @@ noops(void)
                                // MOVW         $autosize, R1
                                // MOVW         $args, R2
                                // MOVW         R14, R3
-                               // BL                   runtime·morestack(SB) // modifies LR
+                               // BL                   runtime.morestack(SB) // modifies LR
                                // MOVW.W               R14,$-autosize(SP)
 
                                // MOVW         $autosize, R1
@@ -461,7 +461,7 @@ noops(void)
                                p->to.type = D_REG;
                                p->to.reg = 3;
 
-                               // BL           runtime·morestack(SB) // modifies LR
+                               // BL           runtime.morestack(SB) // modifies LR
                                p = appendp(p);
                                p->as = ABL;
                                p->to.type = D_BRANCH;
index 8fd39c29193139976aefead3902cd5f7fbaddf39..c1fdc7731bfef2eedd38d8765c3d8cc2d06835cb 100644 (file)
@@ -74,7 +74,7 @@ isobjfile(char *f)
 static char*
 linkername[] =
 {
-       "runtime·softfloat",
+       "runtime.softfloat",
 };
 
 void
index 337cbb9566f105aae5217faf593e75aec336dc97..ead0def1bcaee6affce6460e859b33c18a1ddaf2 100644 (file)
 void
 zname(Biobuf *b, Sym *s, int t)
 {
-       char *n;
-
        Bputc(b, ANAME);        /* as */
        Bputc(b, ANAME>>8);     /* as */
        Bputc(b, t);            /* type */
        Bputc(b, s->sym);       /* sym */
 
-       for(n=s->package; *n; n++)
-               Bputc(b, *n);
-       Bputdot(b);
-       for(n=s->name; *n; n++)
-               Bputc(b, *n);
-       Bputc(b, 0);
+       Bputname(b, s);
 }
 
 void
index 4a7f66af31ae76a6249d25fd14db5a08426a0cc6..44dcb07100bdb8a8924452b9b2bd91cea4203d83 100644 (file)
@@ -513,17 +513,17 @@ brloop(Prog *p)
 static char*
 morename[] =
 {
-       "runtime·morestack00",
-       "runtime·morestack10",
-       "runtime·morestack01",
-       "runtime·morestack11",
-
-       "runtime·morestack8",
-       "runtime·morestack16",
-       "runtime·morestack24",
-       "runtime·morestack32",
-       "runtime·morestack40",
-       "runtime·morestack48",
+       "runtime.morestack00",
+       "runtime.morestack10",
+       "runtime.morestack01",
+       "runtime.morestack11",
+
+       "runtime.morestack8",
+       "runtime.morestack16",
+       "runtime.morestack24",
+       "runtime.morestack32",
+       "runtime.morestack40",
+       "runtime.morestack48",
 };
 Prog*  pmorestack[nelem(morename)];
 Sym*   symmorestack[nelem(morename)];
index 2a96d96fe2461b6849442fff163615ae8838e210..698ebeeb6d91cc290e8b83a94a4ada0ea10865fa 100644 (file)
 void
 zname(Biobuf *b, Sym *s, int t)
 {
-       char *n;
-
        Bputc(b, ANAME);        /* as */
        Bputc(b, ANAME>>8);     /* as */
        Bputc(b, t);            /* type */
        Bputc(b, s->sym);       /* sym */
 
-       for(n=s->package; *n; n++)
-               Bputc(b, *n);
-       Bputdot(b);
-       for(n=s->name; *n; n++)
-               Bputc(b, *n);
-       Bputc(b, 0);
+       Bputname(b, s);
 }
 
 void
index 6cf2f5d9a83463be0d5b990008ee0e0cbee49afc..9c42c3ded86045bb569e1200045563732d5faea4 100644 (file)
@@ -498,7 +498,7 @@ dostkoff(void)
        Sym *symmorestack;
 
        pmorestack = P;
-       symmorestack = lookup("runtime·morestack", 0);
+       symmorestack = lookup("runtime.morestack", 0);
 
        if(symmorestack->type == STEXT)
        for(p = firstp; p != P; p = p->link) {
@@ -511,7 +511,7 @@ dostkoff(void)
                }
        }
        if(pmorestack == P)
-               diag("runtime·morestack not defined");
+               diag("runtime.morestack not defined");
 
        curframe = 0;
        curbecome = 0;
index e357d07c475f49f78c50a9c232f76b850aec7c33..5a5651852037eb6003e4fc47cbbb533d272fec45 100644 (file)
@@ -403,6 +403,17 @@ lookup(void)
        uint32 h;
        char *p;
        int c, n;
+       char *r, *w;
+
+       // turn · into .
+       for(r=w=symb; *r; r++) {
+               if((uchar)*r == 0xc2 && (uchar)*(r+1) == 0xb7) {
+                       *w++ = '.';
+                       r++;
+               }else
+                       *w++ = *r;
+       }
+       *w = '\0';
 
        h = 0;
        for(p=symb; *p;) {
index ba5eda8242f470e3c800dadb435f9b3f34892ce4..c3b2d452946c4af8c38644a50fd820b5cd0216d7 100644 (file)
@@ -221,6 +221,17 @@ lookup(void)
        int32 h;
        char *p;
        int c, l;
+       char *r, *w;
+
+       // turn · into .
+       for(r=w=symb; *r; r++) {
+               if((uchar)*r == 0xc2 && (uchar)*(r+1) == 0xb7) {
+                       *w++ = '.';
+                       r++;
+               }else
+                       *w++ = *r;
+       }
+       *w = '\0';
 
        h = 0;
        for(p=symb; c = *p; p++)
index 4324c890faebb8702c56d412e91f0e25b4c624a0..d2aec4e2afbbe7a547bf4e51f9f60c84ed0c1b67 100644 (file)
@@ -1,92 +1,92 @@
 char *runtimeimport =
        "package runtime\n"
-       "func runtime.mal (? int32) (? *any)\n"
-       "func runtime.throwindex ()\n"
-       "func runtime.throwreturn ()\n"
-       "func runtime.throwinit ()\n"
-       "func runtime.panicl ()\n"
-       "func runtime.printbool (? bool)\n"
-       "func runtime.printfloat (? float64)\n"
-       "func runtime.printint (? int64)\n"
-       "func runtime.printuint (? uint64)\n"
-       "func runtime.printstring (? string)\n"
-       "func runtime.printpointer (? any)\n"
-       "func runtime.printiface (? any)\n"
-       "func runtime.printeface (? any)\n"
-       "func runtime.printslice (? any)\n"
-       "func runtime.printnl ()\n"
-       "func runtime.printsp ()\n"
-       "func runtime.catstring (? string, ? string) (? string)\n"
-       "func runtime.cmpstring (? string, ? string) (? int)\n"
-       "func runtime.slicestring (? string, ? int, ? int) (? string)\n"
-       "func runtime.slicestring1 (? string, ? int) (? string)\n"
-       "func runtime.indexstring (? string, ? int) (? uint8)\n"
-       "func runtime.intstring (? int64) (? string)\n"
-       "func runtime.slicebytetostring (? []uint8) (? string)\n"
-       "func runtime.sliceinttostring (? []int) (? string)\n"
-       "func runtime.stringiter (? string, ? int) (? int)\n"
-       "func runtime.stringiter2 (? string, ? int) (retk int, retv int)\n"
-       "func runtime.slicecopy (to any, fr any, wid uint32) (? int)\n"
-       "func runtime.ifaceI2E (iface any) (ret any)\n"
-       "func runtime.ifaceE2I (typ *uint8, iface any) (ret any)\n"
-       "func runtime.ifaceT2E (typ *uint8, elem any) (ret any)\n"
-       "func runtime.ifaceE2T (typ *uint8, elem any) (ret any)\n"
-       "func runtime.ifaceE2I2 (typ *uint8, iface any) (ret any, ok bool)\n"
-       "func runtime.ifaceE2T2 (typ *uint8, elem any) (ret any, ok bool)\n"
-       "func runtime.ifaceT2I (typ1 *uint8, typ2 *uint8, elem any) (ret any)\n"
-       "func runtime.ifaceI2T (typ *uint8, iface any) (ret any)\n"
-       "func runtime.ifaceI2T2 (typ *uint8, iface any) (ret any, ok bool)\n"
-       "func runtime.ifaceI2I (typ *uint8, iface any) (ret any)\n"
-       "func runtime.ifaceI2Ix (typ *uint8, iface any) (ret any)\n"
-       "func runtime.ifaceI2I2 (typ *uint8, iface any) (ret any, ok bool)\n"
-       "func runtime.ifaceeq (i1 any, i2 any) (ret bool)\n"
-       "func runtime.efaceeq (i1 any, i2 any) (ret bool)\n"
-       "func runtime.ifacethash (i1 any) (ret uint32)\n"
-       "func runtime.efacethash (i1 any) (ret uint32)\n"
-       "func runtime.makemap (key *uint8, val *uint8, hint int) (hmap map[any] any)\n"
-       "func runtime.mapaccess1 (hmap map[any] any, key any) (val any)\n"
-       "func runtime.mapaccess2 (hmap map[any] any, key any) (val any, pres bool)\n"
-       "func runtime.mapassign1 (hmap map[any] any, key any, val any)\n"
-       "func runtime.mapassign2 (hmap map[any] any, key any, val any, pres bool)\n"
-       "func runtime.mapiterinit (hmap map[any] any, hiter *any)\n"
-       "func runtime.mapiternext (hiter *any)\n"
-       "func runtime.mapiter1 (hiter *any) (key any)\n"
-       "func runtime.mapiter2 (hiter *any) (key any, val any)\n"
-       "func runtime.makechan (elem *uint8, hint int) (hchan chan any)\n"
-       "func runtime.chanrecv1 (hchan <-chan any) (elem any)\n"
-       "func runtime.chanrecv2 (hchan <-chan any) (elem any, pres bool)\n"
-       "func runtime.chansend1 (hchan chan<- any, elem any)\n"
-       "func runtime.chansend2 (hchan chan<- any, elem any) (pres bool)\n"
-       "func runtime.closechan (hchan any)\n"
-       "func runtime.closedchan (hchan any) (? bool)\n"
-       "func runtime.newselect (size int) (sel *uint8)\n"
-       "func runtime.selectsend (sel *uint8, hchan chan<- any, elem any) (selected bool)\n"
-       "func runtime.selectrecv (sel *uint8, hchan <-chan any, elem *any) (selected bool)\n"
-       "func runtime.selectdefault (sel *uint8) (selected bool)\n"
-       "func runtime.selectgo (sel *uint8)\n"
-       "func runtime.makeslice (typ *uint8, nel int, cap int) (ary []any)\n"
-       "func runtime.sliceslice1 (old []any, lb int, width int) (ary []any)\n"
-       "func runtime.sliceslice (old []any, lb int, hb int, width int) (ary []any)\n"
-       "func runtime.slicearray (old *any, nel int, lb int, hb int, width int) (ary []any)\n"
-       "func runtime.closure ()\n"
-       "func runtime.int64div (? int64, ? int64) (? int64)\n"
-       "func runtime.uint64div (? uint64, ? uint64) (? uint64)\n"
-       "func runtime.int64mod (? int64, ? int64) (? int64)\n"
-       "func runtime.uint64mod (? uint64, ? uint64) (? uint64)\n"
-       "func runtime.float64toint64 (? float64) (? int64)\n"
-       "func runtime.int64tofloat64 (? int64) (? float64)\n"
+       "func \"runtime\".mal (? int32) (? *any)\n"
+       "func \"runtime\".throwindex ()\n"
+       "func \"runtime\".throwreturn ()\n"
+       "func \"runtime\".throwinit ()\n"
+       "func \"runtime\".panicl ()\n"
+       "func \"runtime\".printbool (? bool)\n"
+       "func \"runtime\".printfloat (? float64)\n"
+       "func \"runtime\".printint (? int64)\n"
+       "func \"runtime\".printuint (? uint64)\n"
+       "func \"runtime\".printstring (? string)\n"
+       "func \"runtime\".printpointer (? any)\n"
+       "func \"runtime\".printiface (? any)\n"
+       "func \"runtime\".printeface (? any)\n"
+       "func \"runtime\".printslice (? any)\n"
+       "func \"runtime\".printnl ()\n"
+       "func \"runtime\".printsp ()\n"
+       "func \"runtime\".catstring (? string, ? string) (? string)\n"
+       "func \"runtime\".cmpstring (? string, ? string) (? int)\n"
+       "func \"runtime\".slicestring (? string, ? int, ? int) (? string)\n"
+       "func \"runtime\".slicestring1 (? string, ? int) (? string)\n"
+       "func \"runtime\".indexstring (? string, ? int) (? uint8)\n"
+       "func \"runtime\".intstring (? int64) (? string)\n"
+       "func \"runtime\".slicebytetostring (? []uint8) (? string)\n"
+       "func \"runtime\".sliceinttostring (? []int) (? string)\n"
+       "func \"runtime\".stringiter (? string, ? int) (? int)\n"
+       "func \"runtime\".stringiter2 (? string, ? int) (retk int, retv int)\n"
+       "func \"runtime\".slicecopy (to any, fr any, wid uint32) (? int)\n"
+       "func \"runtime\".ifaceI2E (iface any) (ret any)\n"
+       "func \"runtime\".ifaceE2I (typ *uint8, iface any) (ret any)\n"
+       "func \"runtime\".ifaceT2E (typ *uint8, elem any) (ret any)\n"
+       "func \"runtime\".ifaceE2T (typ *uint8, elem any) (ret any)\n"
+       "func \"runtime\".ifaceE2I2 (typ *uint8, iface any) (ret any, ok bool)\n"
+       "func \"runtime\".ifaceE2T2 (typ *uint8, elem any) (ret any, ok bool)\n"
+       "func \"runtime\".ifaceT2I (typ1 *uint8, typ2 *uint8, elem any) (ret any)\n"
+       "func \"runtime\".ifaceI2T (typ *uint8, iface any) (ret any)\n"
+       "func \"runtime\".ifaceI2T2 (typ *uint8, iface any) (ret any, ok bool)\n"
+       "func \"runtime\".ifaceI2I (typ *uint8, iface any) (ret any)\n"
+       "func \"runtime\".ifaceI2Ix (typ *uint8, iface any) (ret any)\n"
+       "func \"runtime\".ifaceI2I2 (typ *uint8, iface any) (ret any, ok bool)\n"
+       "func \"runtime\".ifaceeq (i1 any, i2 any) (ret bool)\n"
+       "func \"runtime\".efaceeq (i1 any, i2 any) (ret bool)\n"
+       "func \"runtime\".ifacethash (i1 any) (ret uint32)\n"
+       "func \"runtime\".efacethash (i1 any) (ret uint32)\n"
+       "func \"runtime\".makemap (key *uint8, val *uint8, hint int) (hmap map[any] any)\n"
+       "func \"runtime\".mapaccess1 (hmap map[any] any, key any) (val any)\n"
+       "func \"runtime\".mapaccess2 (hmap map[any] any, key any) (val any, pres bool)\n"
+       "func \"runtime\".mapassign1 (hmap map[any] any, key any, val any)\n"
+       "func \"runtime\".mapassign2 (hmap map[any] any, key any, val any, pres bool)\n"
+       "func \"runtime\".mapiterinit (hmap map[any] any, hiter *any)\n"
+       "func \"runtime\".mapiternext (hiter *any)\n"
+       "func \"runtime\".mapiter1 (hiter *any) (key any)\n"
+       "func \"runtime\".mapiter2 (hiter *any) (key any, val any)\n"
+       "func \"runtime\".makechan (elem *uint8, hint int) (hchan chan any)\n"
+       "func \"runtime\".chanrecv1 (hchan <-chan any) (elem any)\n"
+       "func \"runtime\".chanrecv2 (hchan <-chan any) (elem any, pres bool)\n"
+       "func \"runtime\".chansend1 (hchan chan<- any, elem any)\n"
+       "func \"runtime\".chansend2 (hchan chan<- any, elem any) (pres bool)\n"
+       "func \"runtime\".closechan (hchan any)\n"
+       "func \"runtime\".closedchan (hchan any) (? bool)\n"
+       "func \"runtime\".newselect (size int) (sel *uint8)\n"
+       "func \"runtime\".selectsend (sel *uint8, hchan chan<- any, elem any) (selected bool)\n"
+       "func \"runtime\".selectrecv (sel *uint8, hchan <-chan any, elem *any) (selected bool)\n"
+       "func \"runtime\".selectdefault (sel *uint8) (selected bool)\n"
+       "func \"runtime\".selectgo (sel *uint8)\n"
+       "func \"runtime\".makeslice (typ *uint8, nel int, cap int) (ary []any)\n"
+       "func \"runtime\".sliceslice1 (old []any, lb int, width int) (ary []any)\n"
+       "func \"runtime\".sliceslice (old []any, lb int, hb int, width int) (ary []any)\n"
+       "func \"runtime\".slicearray (old *any, nel int, lb int, hb int, width int) (ary []any)\n"
+       "func \"runtime\".closure ()\n"
+       "func \"runtime\".int64div (? int64, ? int64) (? int64)\n"
+       "func \"runtime\".uint64div (? uint64, ? uint64) (? uint64)\n"
+       "func \"runtime\".int64mod (? int64, ? int64) (? int64)\n"
+       "func \"runtime\".uint64mod (? uint64, ? uint64) (? uint64)\n"
+       "func \"runtime\".float64toint64 (? float64) (? int64)\n"
+       "func \"runtime\".int64tofloat64 (? int64) (? float64)\n"
        "\n"
        "$$\n";
 char *unsafeimport =
        "package unsafe\n"
-       "type unsafe.Pointer *any\n"
-       "func unsafe.Offsetof (? any) (? int)\n"
-       "func unsafe.Sizeof (? any) (? int)\n"
-       "func unsafe.Alignof (? any) (? int)\n"
-       "func unsafe.Typeof (i interface { }) (typ interface { })\n"
-       "func unsafe.Reflect (i interface { }) (typ interface { }, addr unsafe.Pointer)\n"
-       "func unsafe.Unreflect (typ interface { }, addr unsafe.Pointer) (ret interface { })\n"
-       "func unsafe.New (typ interface { }) (? unsafe.Pointer)\n"
-       "func unsafe.NewArray (typ interface { }, n int) (? unsafe.Pointer)\n"
+       "type \"unsafe\".Pointer *any\n"
+       "func \"unsafe\".Offsetof (? any) (? int)\n"
+       "func \"unsafe\".Sizeof (? any) (? int)\n"
+       "func \"unsafe\".Alignof (? any) (? int)\n"
+       "func \"unsafe\".Typeof (i interface { }) (typ interface { })\n"
+       "func \"unsafe\".Reflect (i interface { }) (typ interface { }, addr \"unsafe\".Pointer)\n"
+       "func \"unsafe\".Unreflect (typ interface { }, addr \"unsafe\".Pointer) (ret interface { })\n"
+       "func \"unsafe\".New (typ interface { }) (? \"unsafe\".Pointer)\n"
+       "func \"unsafe\".NewArray (typ interface { }, n int) (? \"unsafe\".Pointer)\n"
        "\n"
        "$$\n";
index e8ca1f1f72c19710f212e9dfa325fc76c345fead..24c28b1f18e828082f419cfb4b80aa8277412e40 100644 (file)
@@ -27,6 +27,7 @@ static        Sym*    dclstack;
 void
 dcopy(Sym *a, Sym *b)
 {
+       a->packagename = b->packagename;
        a->package = b->package;
        a->name = b->name;
        a->def = b->def;
index de27091cd5e2b8a4e3f2985ca77c67c4a7c34059..ad013ed66708227ee4567fcf746774ba65ff5856 100644 (file)
@@ -226,6 +226,7 @@ dumpexport(void)
 
        lno = lineno;
 
+       packagequotes = 1;
        Bprint(bout, "   import\n");
        Bprint(bout, "\n$$  // exports\n");
 
@@ -244,6 +245,7 @@ dumpexport(void)
        }
 
        Bprint(bout, "\n$$\n");
+       packagequotes = 0;
 
        lineno = lno;
 }
index 0f5e13355a3e85c8bf30b1cf5e13043e70fc958b..fea438fd132958e2eed61cb207cb2e6856803768 100644 (file)
@@ -291,7 +291,8 @@ struct      Sym
        Sym*    link;
 
        // saved and restored by dcopy
-       char*   package;        // package name
+       char*   packagename;    // package name
+       char*   package;        // import path
        char*   name;           // variable name
        Node*   def;            // definition: ONAME OTYPE OPACK or OLITERAL
        int32   block;          // blocknumber to catch redeclaration
@@ -712,6 +713,7 @@ EXTERN      int     noargnames;
 
 EXTERN int     funcdepth;
 EXTERN int     typecheckok;
+EXTERN int     packagequotes;
 
 /*
  *     y.tab.c
@@ -913,6 +915,8 @@ void        umagic(Magic*);
 void   redeclare(Sym*, char*);
 Sym*   ngotype(Node*);
 
+char*  toimportpath(Strlit*);
+
 /*
  *     dcl.c
  */
@@ -1144,7 +1148,7 @@ Plist*    newplist(void);
 /*
  *     obj.c
  */
-void   Bputdot(Biobuf *b);
+void   Bputname(Biobuf*, Sym*);
 void   dumpglobls(void);
 void   dumpobj(void);
 void   ieeedtod(uint64 *ieee, double native);
index 35e7742d96869dae4a96f2fe7752dfa584e04bfb..93adf1c1afa9b263f86bbe951cda44c96c99081f 100644 (file)
@@ -142,7 +142,10 @@ package:
  */
 loadsys:
        {
-               cannedimports("runtime.builtin", runtimeimport);
+               if(debug['A'])
+                       cannedimports("runtime.builtin", "package runtime\n\n$$\n\n");
+               else
+                       cannedimports("runtime.builtin", runtimeimport);
        }
        import_package
        import_there
@@ -1546,8 +1549,17 @@ oliteral:
  * an output package
  */
 hidden_import:
-       LPACKAGE sym ';'
-       /* variables */
+       LIMPORT sym LLITERAL
+       {
+               // Informational: record package name
+               // associated with import path, for use in
+               // human-readable messages.
+
+               Sym *s;
+
+               s = pkglookup("", toimportpath($3.u.sval));
+               s->packagename = $2->name;
+       }
 |      LVAR hidden_pkg_importsym hidden_type ';'
        {
                importvar($2, $3, PEXTERN);
@@ -1753,9 +1765,9 @@ hidden_constant:
        }
 
 hidden_importsym:
-       sym '.' sym
+       LLITERAL '.' sym
        {
-               $$ = pkglookup($3->name, $1->name);
+               $$ = pkglookup($3->name, toimportpath($1.u.sval));
        }
 
 hidden_pkg_importsym:
index 80bccf4896d5cce03352e242b2a8f65a37655230..aa28e295befbcdd0392549e230612e0b05c6fe9e 100644 (file)
@@ -10,6 +10,8 @@
 #include <ctype.h>
 #include <errno.h>
 
+void esc(char*);
+
 int
 main(int argc, char **argv)
 {
@@ -61,12 +63,13 @@ begin:
                printf("\t\"");
                while(q = strstr(p, "PACKAGE")) {
                        *q = 0;
-                       printf("%s", p);        // up to the substitution
+                       esc(p); // up to the substitution
                        printf("%s", name);     // the sub name
                        p = q+7;                // continue with rest
                }
 
-               printf("%s\\n\"\n", p);
+               esc(p);
+               printf("\\n\"\n", p);
        }
        fprintf(stderr, "did not find end of imports\n");
        exit(1);
@@ -75,3 +78,13 @@ end:
        printf("\t\"$$\\n\";\n");
        return 0;
 }
+
+void
+esc(char *p)
+{
+       for(; *p; p++) {
+               if(*p == '\\' || *p == '\"')
+                       printf("\\");
+               putchar(*p);
+       }
+}
index 5b6bb1bf3825e53cf2d54aecdbda21d6fe3f340e..e2343021b189cf23052ffdd18bbb32211585278f 100644 (file)
@@ -61,11 +61,13 @@ dumpglobls(void)
 }
 
 void
-Bputdot(Biobuf *b)
+Bputname(Biobuf *b, Sym *s)
 {
-       // put out middle dot ·
-       Bputc(b, 0xc2);
-       Bputc(b, 0xb7);
+// PGNS: Uncomment next line.
+//     if(strcmp(s->package, package) != 0)
+               Bwrite(b, s->package, strlen(s->package));
+       Bputc(b, '.');
+       Bwrite(b, s->name, strlen(s->name)+1);
 }
 
 void
index f7abc0357e3cbf3a64dad837cc98b996917963de..411000b0c4ed773fbe7d1af3dd728c7abf12ad0f 100644 (file)
@@ -254,34 +254,9 @@ stringhash(char *p)
 }
 
 Sym*
-lookup(char *p)
+lookup(char *name)
 {
-       Sym *s;
-       uint32 h;
-       int c;
-
-       h = stringhash(p) % NHASH;
-       c = p[0];
-
-       for(s = hash[h]; s != S; s = s->link) {
-               if(s->name[0] != c)
-                       continue;
-               if(strcmp(s->name, p) == 0)
-                       if(s->package && strcmp(s->package, package) == 0)
-                               return s;
-       }
-
-       s = mal(sizeof(*s));
-       s->name = mal(strlen(p)+1);
-       s->package = package;
-       s->lexical = LNAME;
-
-       strcpy(s->name, p);
-
-       s->link = hash[h];
-       hash[h] = s;
-
-       return s;
+       return pkglookup(name, package);
 }
 
 Sym*
@@ -306,8 +281,14 @@ pkglookup(char *name, char *pkg)
        strcpy(s->name, name);
 
        // botch - should probably try to reuse the pkg string
-       s->package = mal(strlen(pkg)+1);
-       strcpy(s->package, pkg);
+       if(pkg == package)
+               s->package = package;
+       else {
+               s->package = mal(strlen(pkg)+1);
+               strcpy(s->package, pkg);
+       }
+
+       s->packagename = s->package;
 
        s->link = hash[h];
        hash[h] = s;
@@ -1013,15 +994,22 @@ Sconv(Fmt *fp)
        pkg = "<nil>";
        nam = pkg;
 
-       if(s->package != nil)
-               pkg = s->package;
+       if(s->packagename != nil)
+               pkg = s->packagename;
+       else
+               abort();
        if(s->name != nil)
                nam = s->name;
 
-       if(!(fp->flags & FmtShort))
-       if(strcmp(pkg, package) != 0 || (fp->flags & FmtLong)) {
-               fmtprint(fp, "%s.%s", pkg, nam);
-               return 0;
+       if(!(fp->flags & FmtShort)) {
+               if((fp->flags & FmtLong) && packagequotes) {
+                       fmtprint(fp, "\"%s\".%s", s->package, nam);
+                       return 0;
+               }
+               if((fp->flags & FmtLong) || strcmp(s->package, package) != 0) {
+                       fmtprint(fp, "%s.%s", pkg, nam);
+                       return 0;
+               }
        }
        fmtstrcpy(fp, nam);
        return 0;
@@ -3390,3 +3378,16 @@ ngotype(Node *n)
                return typename(n->type)->left->sym;
        return S;
 }
+
+char*
+toimportpath(Strlit *s)
+{
+       char *p;
+
+//PGNS: Do better once these are import paths
+// rather than package names in disguise.
+       p = mal(s->len+1);
+       memmove(p, s->s, s->len);
+       p[s->len] = '\0';
+       return p;
+}
index b2e4330945049b7b5182fb392c144cb4994edc9c..cb0a2cdd9abdb9c304f48f30838186ba518d7968 100755 (executable)
@@ -8,7 +8,7 @@
 # tests.
 # If files are named on the command line, use them instead of test*.go.
 
-# Makes egrep,grep work better with · if we put them
+# Makes egrep,grep work better in general if we put them
 # in ordinary C mode instead of what the current language is.
 unset LANG
 export LC_ALL=C
@@ -115,14 +115,14 @@ importpath=$("$GOBIN"/gomake -s importpath)
        # the grep -v eliminates methods and other special names
        # that have multiple dots.
        pattern='Test([^a-z].*)?'
-       tests=$("$GOBIN"/6nm -s _test/$importpath.a $xofile | egrep ' T .*·'$pattern'$' | grep -v '·.*[.·]' | sed 's/.* //; s/·/./')
+       tests=$("$GOBIN"/6nm -s _test/$importpath.a $xofile | egrep ' T .*\.'$pattern'$' | sed 's/.* //; /\..*\./d')
        if [ "x$tests" = x ]; then
                echo 'gotest: error: no tests matching '$pattern in _test/$importpath.a $xofile 1>&2
                exit 2
        fi
        # benchmarks are named BenchmarkFoo.
        pattern='Benchmark([^a-z].*)?'
-       benchmarks=$("$GOBIN"/6nm -s _test/$importpath.a $xofile | egrep ' T .*·'$pattern'$' | grep -v '·.*[.·]' | sed 's/.* //; s/·/./')
+       benchmarks=$("$GOBIN"/6nm -s _test/$importpath.a $xofile | egrep ' T .*\.'$pattern'$' | sed 's/.* //; /\..*\./d')
 
        # package spec
        echo 'package main'
index 9a9346c1f272c3f6841501e9268e9d32879c032b..8f9d198bc2adcd7cd9b997c630015c561c13d741 100644 (file)
@@ -454,20 +454,20 @@ sweeplist(Prog **first, Prog **last)
 static char*
 morename[] =
 {
-       "runtime·morestack",
-       "runtime·morestackx",
-
-       "runtime·morestack00",
-       "runtime·morestack10",
-       "runtime·morestack01",
-       "runtime·morestack11",
-
-       "runtime·morestack8",
-       "runtime·morestack16",
-       "runtime·morestack24",
-       "runtime·morestack32",
-       "runtime·morestack40",
-       "runtime·morestack48",
+       "runtime.morestack",
+       "runtime.morestackx",
+
+       "runtime.morestack00",
+       "runtime.morestack10",
+       "runtime.morestack01",
+       "runtime.morestack11",
+
+       "runtime.morestack8",
+       "runtime.morestack16",
+       "runtime.morestack24",
+       "runtime.morestack32",
+       "runtime.morestack40",
+       "runtime.morestack48",
 };
 
 void