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

cleanup toward eliminating package global name space

* 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
This commit is contained in:
Russ Cox 2010-01-19 21:34:44 -08:00
parent 0365b989a4
commit a6736fa4ff
19 changed files with 225 additions and 189 deletions

View File

@ -33,18 +33,11 @@
void void
zname(Biobuf *b, Sym *s, int t) zname(Biobuf *b, Sym *s, int t)
{ {
char *n;
Bputc(b, ANAME); /* as */ Bputc(b, ANAME); /* as */
Bputc(b, t); /* type */ Bputc(b, t); /* type */
Bputc(b, s->sym); /* sym */ Bputc(b, s->sym); /* sym */
for(n=s->package; *n; n++) Bputname(b, s);
Bputc(b, *n);
Bputdot(b);
for(n=s->name; *n; n++)
Bputc(b, *n);
Bputc(b, 0);
} }
void void

View File

@ -128,7 +128,7 @@ noops(void)
Bflush(&bso); Bflush(&bso);
pmorestack = P; pmorestack = P;
symmorestack = lookup("runtime·morestack", 0); symmorestack = lookup("runtime.morestack", 0);
if(symmorestack->type == STEXT) if(symmorestack->type == STEXT)
for(p = firstp; p != P; p = p->link) { for(p = firstp; p != P; p = p->link) {
@ -361,7 +361,7 @@ noops(void)
// MOVW.LO $autosize, R1 // MOVW.LO $autosize, R1
// MOVW.LO $args, R2 // MOVW.LO $args, R2
// MOVW.LO R14, R3 // MOVW.LO R14, R3
// BL.LO runtime·morestack(SB) // modifies LR // BL.LO runtime.morestack(SB) // modifies LR
// MOVW.W R14,$-autosize(SP) // MOVW.W R14,$-autosize(SP)
// TODO(kaib): add more trampolines // TODO(kaib): add more trampolines
@ -412,7 +412,7 @@ noops(void)
p->to.type = D_REG; p->to.type = D_REG;
p->to.reg = 3; p->to.reg = 3;
// BL.LO runtime·morestack(SB) // modifies LR // BL.LO runtime.morestack(SB) // modifies LR
p = appendp(p); p = appendp(p);
p->as = ABL; p->as = ABL;
p->scond = C_SCOND_LO; p->scond = C_SCOND_LO;
@ -433,7 +433,7 @@ noops(void)
// MOVW $autosize, R1 // MOVW $autosize, R1
// MOVW $args, R2 // MOVW $args, R2
// MOVW R14, R3 // MOVW R14, R3
// BL runtime·morestack(SB) // modifies LR // BL runtime.morestack(SB) // modifies LR
// MOVW.W R14,$-autosize(SP) // MOVW.W R14,$-autosize(SP)
// MOVW $autosize, R1 // MOVW $autosize, R1
@ -461,7 +461,7 @@ noops(void)
p->to.type = D_REG; p->to.type = D_REG;
p->to.reg = 3; p->to.reg = 3;
// BL runtime·morestack(SB) // modifies LR // BL runtime.morestack(SB) // modifies LR
p = appendp(p); p = appendp(p);
p->as = ABL; p->as = ABL;
p->to.type = D_BRANCH; p->to.type = D_BRANCH;

View File

@ -74,7 +74,7 @@ isobjfile(char *f)
static char* static char*
linkername[] = linkername[] =
{ {
"runtime·softfloat", "runtime.softfloat",
}; };
void void

View File

@ -33,19 +33,12 @@
void void
zname(Biobuf *b, Sym *s, int t) zname(Biobuf *b, Sym *s, int t)
{ {
char *n;
Bputc(b, ANAME); /* as */ Bputc(b, ANAME); /* as */
Bputc(b, ANAME>>8); /* as */ Bputc(b, ANAME>>8); /* as */
Bputc(b, t); /* type */ Bputc(b, t); /* type */
Bputc(b, s->sym); /* sym */ Bputc(b, s->sym); /* sym */
for(n=s->package; *n; n++) Bputname(b, s);
Bputc(b, *n);
Bputdot(b);
for(n=s->name; *n; n++)
Bputc(b, *n);
Bputc(b, 0);
} }
void void

View File

@ -513,17 +513,17 @@ brloop(Prog *p)
static char* static char*
morename[] = morename[] =
{ {
"runtime·morestack00", "runtime.morestack00",
"runtime·morestack10", "runtime.morestack10",
"runtime·morestack01", "runtime.morestack01",
"runtime·morestack11", "runtime.morestack11",
"runtime·morestack8", "runtime.morestack8",
"runtime·morestack16", "runtime.morestack16",
"runtime·morestack24", "runtime.morestack24",
"runtime·morestack32", "runtime.morestack32",
"runtime·morestack40", "runtime.morestack40",
"runtime·morestack48", "runtime.morestack48",
}; };
Prog* pmorestack[nelem(morename)]; Prog* pmorestack[nelem(morename)];
Sym* symmorestack[nelem(morename)]; Sym* symmorestack[nelem(morename)];

View File

@ -33,19 +33,12 @@
void void
zname(Biobuf *b, Sym *s, int t) zname(Biobuf *b, Sym *s, int t)
{ {
char *n;
Bputc(b, ANAME); /* as */ Bputc(b, ANAME); /* as */
Bputc(b, ANAME>>8); /* as */ Bputc(b, ANAME>>8); /* as */
Bputc(b, t); /* type */ Bputc(b, t); /* type */
Bputc(b, s->sym); /* sym */ Bputc(b, s->sym); /* sym */
for(n=s->package; *n; n++) Bputname(b, s);
Bputc(b, *n);
Bputdot(b);
for(n=s->name; *n; n++)
Bputc(b, *n);
Bputc(b, 0);
} }
void void

View File

@ -498,7 +498,7 @@ dostkoff(void)
Sym *symmorestack; Sym *symmorestack;
pmorestack = P; pmorestack = P;
symmorestack = lookup("runtime·morestack", 0); symmorestack = lookup("runtime.morestack", 0);
if(symmorestack->type == STEXT) if(symmorestack->type == STEXT)
for(p = firstp; p != P; p = p->link) { for(p = firstp; p != P; p = p->link) {
@ -511,7 +511,7 @@ dostkoff(void)
} }
} }
if(pmorestack == P) if(pmorestack == P)
diag("runtime·morestack not defined"); diag("runtime.morestack not defined");
curframe = 0; curframe = 0;
curbecome = 0; curbecome = 0;

View File

@ -403,6 +403,17 @@ lookup(void)
uint32 h; uint32 h;
char *p; char *p;
int c, n; 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; h = 0;
for(p=symb; *p;) { for(p=symb; *p;) {

View File

@ -221,6 +221,17 @@ lookup(void)
int32 h; int32 h;
char *p; char *p;
int c, l; 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; h = 0;
for(p=symb; c = *p; p++) for(p=symb; c = *p; p++)

View File

@ -1,92 +1,92 @@
char *runtimeimport = char *runtimeimport =
"package runtime\n" "package runtime\n"
"func runtime.mal (? int32) (? *any)\n" "func \"runtime\".mal (? int32) (? *any)\n"
"func runtime.throwindex ()\n" "func \"runtime\".throwindex ()\n"
"func runtime.throwreturn ()\n" "func \"runtime\".throwreturn ()\n"
"func runtime.throwinit ()\n" "func \"runtime\".throwinit ()\n"
"func runtime.panicl ()\n" "func \"runtime\".panicl ()\n"
"func runtime.printbool (? bool)\n" "func \"runtime\".printbool (? bool)\n"
"func runtime.printfloat (? float64)\n" "func \"runtime\".printfloat (? float64)\n"
"func runtime.printint (? int64)\n" "func \"runtime\".printint (? int64)\n"
"func runtime.printuint (? uint64)\n" "func \"runtime\".printuint (? uint64)\n"
"func runtime.printstring (? string)\n" "func \"runtime\".printstring (? string)\n"
"func runtime.printpointer (? any)\n" "func \"runtime\".printpointer (? any)\n"
"func runtime.printiface (? any)\n" "func \"runtime\".printiface (? any)\n"
"func runtime.printeface (? any)\n" "func \"runtime\".printeface (? any)\n"
"func runtime.printslice (? any)\n" "func \"runtime\".printslice (? any)\n"
"func runtime.printnl ()\n" "func \"runtime\".printnl ()\n"
"func runtime.printsp ()\n" "func \"runtime\".printsp ()\n"
"func runtime.catstring (? string, ? string) (? string)\n" "func \"runtime\".catstring (? string, ? string) (? string)\n"
"func runtime.cmpstring (? string, ? string) (? int)\n" "func \"runtime\".cmpstring (? string, ? string) (? int)\n"
"func runtime.slicestring (? string, ? int, ? int) (? string)\n" "func \"runtime\".slicestring (? string, ? int, ? int) (? string)\n"
"func runtime.slicestring1 (? string, ? int) (? string)\n" "func \"runtime\".slicestring1 (? string, ? int) (? string)\n"
"func runtime.indexstring (? string, ? int) (? uint8)\n" "func \"runtime\".indexstring (? string, ? int) (? uint8)\n"
"func runtime.intstring (? int64) (? string)\n" "func \"runtime\".intstring (? int64) (? string)\n"
"func runtime.slicebytetostring (? []uint8) (? string)\n" "func \"runtime\".slicebytetostring (? []uint8) (? string)\n"
"func runtime.sliceinttostring (? []int) (? string)\n" "func \"runtime\".sliceinttostring (? []int) (? string)\n"
"func runtime.stringiter (? string, ? int) (? int)\n" "func \"runtime\".stringiter (? string, ? int) (? int)\n"
"func runtime.stringiter2 (? string, ? int) (retk int, retv 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\".slicecopy (to any, fr any, wid uint32) (? int)\n"
"func runtime.ifaceI2E (iface any) (ret any)\n" "func \"runtime\".ifaceI2E (iface any) (ret any)\n"
"func runtime.ifaceE2I (typ *uint8, 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\".ifaceT2E (typ *uint8, elem any) (ret any)\n"
"func runtime.ifaceE2T (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\".ifaceE2I2 (typ *uint8, iface any) (ret any, ok bool)\n"
"func runtime.ifaceE2T2 (typ *uint8, elem 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\".ifaceT2I (typ1 *uint8, typ2 *uint8, elem any) (ret any)\n"
"func runtime.ifaceI2T (typ *uint8, iface 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\".ifaceI2T2 (typ *uint8, iface any) (ret any, ok bool)\n"
"func runtime.ifaceI2I (typ *uint8, iface any) (ret any)\n" "func \"runtime\".ifaceI2I (typ *uint8, iface any) (ret any)\n"
"func runtime.ifaceI2Ix (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\".ifaceI2I2 (typ *uint8, iface any) (ret any, ok bool)\n"
"func runtime.ifaceeq (i1 any, i2 any) (ret bool)\n" "func \"runtime\".ifaceeq (i1 any, i2 any) (ret bool)\n"
"func runtime.efaceeq (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\".ifacethash (i1 any) (ret uint32)\n"
"func runtime.efacethash (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\".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\".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\".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\".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\".mapassign2 (hmap map[any] any, key any, val any, pres bool)\n"
"func runtime.mapiterinit (hmap map[any] any, hiter *any)\n" "func \"runtime\".mapiterinit (hmap map[any] any, hiter *any)\n"
"func runtime.mapiternext (hiter *any)\n" "func \"runtime\".mapiternext (hiter *any)\n"
"func runtime.mapiter1 (hiter *any) (key any)\n" "func \"runtime\".mapiter1 (hiter *any) (key any)\n"
"func runtime.mapiter2 (hiter *any) (key any, val 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\".makechan (elem *uint8, hint int) (hchan chan any)\n"
"func runtime.chanrecv1 (hchan <-chan any) (elem any)\n" "func \"runtime\".chanrecv1 (hchan <-chan any) (elem any)\n"
"func runtime.chanrecv2 (hchan <-chan any) (elem any, pres bool)\n" "func \"runtime\".chanrecv2 (hchan <-chan any) (elem any, pres bool)\n"
"func runtime.chansend1 (hchan chan<- any, elem any)\n" "func \"runtime\".chansend1 (hchan chan<- any, elem any)\n"
"func runtime.chansend2 (hchan chan<- any, elem any) (pres bool)\n" "func \"runtime\".chansend2 (hchan chan<- any, elem any) (pres bool)\n"
"func runtime.closechan (hchan any)\n" "func \"runtime\".closechan (hchan any)\n"
"func runtime.closedchan (hchan any) (? bool)\n" "func \"runtime\".closedchan (hchan any) (? bool)\n"
"func runtime.newselect (size int) (sel *uint8)\n" "func \"runtime\".newselect (size int) (sel *uint8)\n"
"func runtime.selectsend (sel *uint8, hchan chan<- any, elem any) (selected bool)\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\".selectrecv (sel *uint8, hchan <-chan any, elem *any) (selected bool)\n"
"func runtime.selectdefault (sel *uint8) (selected bool)\n" "func \"runtime\".selectdefault (sel *uint8) (selected bool)\n"
"func runtime.selectgo (sel *uint8)\n" "func \"runtime\".selectgo (sel *uint8)\n"
"func runtime.makeslice (typ *uint8, nel int, cap int) (ary []any)\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\".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\".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\".slicearray (old *any, nel int, lb int, hb int, width int) (ary []any)\n"
"func runtime.closure ()\n" "func \"runtime\".closure ()\n"
"func runtime.int64div (? int64, ? int64) (? int64)\n" "func \"runtime\".int64div (? int64, ? int64) (? int64)\n"
"func runtime.uint64div (? uint64, ? uint64) (? uint64)\n" "func \"runtime\".uint64div (? uint64, ? uint64) (? uint64)\n"
"func runtime.int64mod (? int64, ? int64) (? int64)\n" "func \"runtime\".int64mod (? int64, ? int64) (? int64)\n"
"func runtime.uint64mod (? uint64, ? uint64) (? uint64)\n" "func \"runtime\".uint64mod (? uint64, ? uint64) (? uint64)\n"
"func runtime.float64toint64 (? float64) (? int64)\n" "func \"runtime\".float64toint64 (? float64) (? int64)\n"
"func runtime.int64tofloat64 (? int64) (? float64)\n" "func \"runtime\".int64tofloat64 (? int64) (? float64)\n"
"\n" "\n"
"$$\n"; "$$\n";
char *unsafeimport = char *unsafeimport =
"package unsafe\n" "package unsafe\n"
"type unsafe.Pointer *any\n" "type \"unsafe\".Pointer *any\n"
"func unsafe.Offsetof (? any) (? int)\n" "func \"unsafe\".Offsetof (? any) (? int)\n"
"func unsafe.Sizeof (? any) (? int)\n" "func \"unsafe\".Sizeof (? any) (? int)\n"
"func unsafe.Alignof (? any) (? int)\n" "func \"unsafe\".Alignof (? any) (? int)\n"
"func unsafe.Typeof (i interface { }) (typ interface { })\n" "func \"unsafe\".Typeof (i interface { }) (typ interface { })\n"
"func unsafe.Reflect (i interface { }) (typ interface { }, addr unsafe.Pointer)\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\".Unreflect (typ interface { }, addr \"unsafe\".Pointer) (ret interface { })\n"
"func unsafe.New (typ interface { }) (? unsafe.Pointer)\n" "func \"unsafe\".New (typ interface { }) (? \"unsafe\".Pointer)\n"
"func unsafe.NewArray (typ interface { }, n int) (? unsafe.Pointer)\n" "func \"unsafe\".NewArray (typ interface { }, n int) (? \"unsafe\".Pointer)\n"
"\n" "\n"
"$$\n"; "$$\n";

View File

@ -27,6 +27,7 @@ static Sym* dclstack;
void void
dcopy(Sym *a, Sym *b) dcopy(Sym *a, Sym *b)
{ {
a->packagename = b->packagename;
a->package = b->package; a->package = b->package;
a->name = b->name; a->name = b->name;
a->def = b->def; a->def = b->def;

View File

@ -226,6 +226,7 @@ dumpexport(void)
lno = lineno; lno = lineno;
packagequotes = 1;
Bprint(bout, " import\n"); Bprint(bout, " import\n");
Bprint(bout, "\n$$ // exports\n"); Bprint(bout, "\n$$ // exports\n");
@ -244,6 +245,7 @@ dumpexport(void)
} }
Bprint(bout, "\n$$\n"); Bprint(bout, "\n$$\n");
packagequotes = 0;
lineno = lno; lineno = lno;
} }

View File

@ -291,7 +291,8 @@ struct Sym
Sym* link; Sym* link;
// saved and restored by dcopy // saved and restored by dcopy
char* package; // package name char* packagename; // package name
char* package; // import path
char* name; // variable name char* name; // variable name
Node* def; // definition: ONAME OTYPE OPACK or OLITERAL Node* def; // definition: ONAME OTYPE OPACK or OLITERAL
int32 block; // blocknumber to catch redeclaration int32 block; // blocknumber to catch redeclaration
@ -712,6 +713,7 @@ EXTERN int noargnames;
EXTERN int funcdepth; EXTERN int funcdepth;
EXTERN int typecheckok; EXTERN int typecheckok;
EXTERN int packagequotes;
/* /*
* y.tab.c * y.tab.c
@ -913,6 +915,8 @@ void umagic(Magic*);
void redeclare(Sym*, char*); void redeclare(Sym*, char*);
Sym* ngotype(Node*); Sym* ngotype(Node*);
char* toimportpath(Strlit*);
/* /*
* dcl.c * dcl.c
*/ */
@ -1144,7 +1148,7 @@ Plist* newplist(void);
/* /*
* obj.c * obj.c
*/ */
void Bputdot(Biobuf *b); void Bputname(Biobuf*, Sym*);
void dumpglobls(void); void dumpglobls(void);
void dumpobj(void); void dumpobj(void);
void ieeedtod(uint64 *ieee, double native); void ieeedtod(uint64 *ieee, double native);

View File

@ -142,7 +142,10 @@ package:
*/ */
loadsys: 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_package
import_there import_there
@ -1546,8 +1549,17 @@ oliteral:
* an output package * an output package
*/ */
hidden_import: hidden_import:
LPACKAGE sym ';' LIMPORT sym LLITERAL
/* variables */ {
// 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 ';' | LVAR hidden_pkg_importsym hidden_type ';'
{ {
importvar($2, $3, PEXTERN); importvar($2, $3, PEXTERN);
@ -1753,9 +1765,9 @@ hidden_constant:
} }
hidden_importsym: hidden_importsym:
sym '.' sym LLITERAL '.' sym
{ {
$$ = pkglookup($3->name, $1->name); $$ = pkglookup($3->name, toimportpath($1.u.sval));
} }
hidden_pkg_importsym: hidden_pkg_importsym:

View File

@ -10,6 +10,8 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
void esc(char*);
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
@ -61,12 +63,13 @@ begin:
printf("\t\""); printf("\t\"");
while(q = strstr(p, "PACKAGE")) { while(q = strstr(p, "PACKAGE")) {
*q = 0; *q = 0;
printf("%s", p); // up to the substitution esc(p); // up to the substitution
printf("%s", name); // the sub name printf("%s", name); // the sub name
p = q+7; // continue with rest 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"); fprintf(stderr, "did not find end of imports\n");
exit(1); exit(1);
@ -75,3 +78,13 @@ end:
printf("\t\"$$\\n\";\n"); printf("\t\"$$\\n\";\n");
return 0; return 0;
} }
void
esc(char *p)
{
for(; *p; p++) {
if(*p == '\\' || *p == '\"')
printf("\\");
putchar(*p);
}
}

View File

@ -61,11 +61,13 @@ dumpglobls(void)
} }
void void
Bputdot(Biobuf *b) Bputname(Biobuf *b, Sym *s)
{ {
// put out middle dot · // PGNS: Uncomment next line.
Bputc(b, 0xc2); // if(strcmp(s->package, package) != 0)
Bputc(b, 0xb7); Bwrite(b, s->package, strlen(s->package));
Bputc(b, '.');
Bwrite(b, s->name, strlen(s->name)+1);
} }
void void

View File

@ -254,34 +254,9 @@ stringhash(char *p)
} }
Sym* Sym*
lookup(char *p) lookup(char *name)
{ {
Sym *s; return pkglookup(name, package);
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;
} }
Sym* Sym*
@ -306,8 +281,14 @@ pkglookup(char *name, char *pkg)
strcpy(s->name, name); strcpy(s->name, name);
// botch - should probably try to reuse the pkg string // botch - should probably try to reuse the pkg string
s->package = mal(strlen(pkg)+1); if(pkg == package)
strcpy(s->package, pkg); s->package = package;
else {
s->package = mal(strlen(pkg)+1);
strcpy(s->package, pkg);
}
s->packagename = s->package;
s->link = hash[h]; s->link = hash[h];
hash[h] = s; hash[h] = s;
@ -1013,15 +994,22 @@ Sconv(Fmt *fp)
pkg = "<nil>"; pkg = "<nil>";
nam = pkg; nam = pkg;
if(s->package != nil) if(s->packagename != nil)
pkg = s->package; pkg = s->packagename;
else
abort();
if(s->name != nil) if(s->name != nil)
nam = s->name; nam = s->name;
if(!(fp->flags & FmtShort)) if(!(fp->flags & FmtShort)) {
if(strcmp(pkg, package) != 0 || (fp->flags & FmtLong)) { if((fp->flags & FmtLong) && packagequotes) {
fmtprint(fp, "%s.%s", pkg, nam); fmtprint(fp, "\"%s\".%s", s->package, nam);
return 0; return 0;
}
if((fp->flags & FmtLong) || strcmp(s->package, package) != 0) {
fmtprint(fp, "%s.%s", pkg, nam);
return 0;
}
} }
fmtstrcpy(fp, nam); fmtstrcpy(fp, nam);
return 0; return 0;
@ -3390,3 +3378,16 @@ ngotype(Node *n)
return typename(n->type)->left->sym; return typename(n->type)->left->sym;
return S; 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;
}

View File

@ -8,7 +8,7 @@
# tests. # tests.
# If files are named on the command line, use them instead of test*.go. # 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. # in ordinary C mode instead of what the current language is.
unset LANG unset LANG
export LC_ALL=C export LC_ALL=C
@ -115,14 +115,14 @@ importpath=$("$GOBIN"/gomake -s importpath)
# the grep -v eliminates methods and other special names # the grep -v eliminates methods and other special names
# that have multiple dots. # that have multiple dots.
pattern='Test([^a-z].*)?' 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 if [ "x$tests" = x ]; then
echo 'gotest: error: no tests matching '$pattern in _test/$importpath.a $xofile 1>&2 echo 'gotest: error: no tests matching '$pattern in _test/$importpath.a $xofile 1>&2
exit 2 exit 2
fi fi
# benchmarks are named BenchmarkFoo. # benchmarks are named BenchmarkFoo.
pattern='Benchmark([^a-z].*)?' 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 # package spec
echo 'package main' echo 'package main'

View File

@ -454,20 +454,20 @@ sweeplist(Prog **first, Prog **last)
static char* static char*
morename[] = morename[] =
{ {
"runtime·morestack", "runtime.morestack",
"runtime·morestackx", "runtime.morestackx",
"runtime·morestack00", "runtime.morestack00",
"runtime·morestack10", "runtime.morestack10",
"runtime·morestack01", "runtime.morestack01",
"runtime·morestack11", "runtime.morestack11",
"runtime·morestack8", "runtime.morestack8",
"runtime·morestack16", "runtime.morestack16",
"runtime·morestack24", "runtime.morestack24",
"runtime·morestack32", "runtime.morestack32",
"runtime·morestack40", "runtime.morestack40",
"runtime·morestack48", "runtime.morestack48",
}; };
void void