stop using filename for disambiguation within a package.

R=ken
OCL=34339
CL=34341
This commit is contained in:
Russ Cox 2009-09-03 15:23:21 -07:00
parent a18208fb60
commit 107d404378
5 changed files with 5 additions and 35 deletions

View File

@ -152,7 +152,7 @@ walkclosure(Node *func, NodeList **init)
// create the function
xfunc = nod(ODCLFUNC, N, N);
snprint(namebuf, sizeof namebuf, "_f%.3ld·%s", ++closgen, filename);
snprint(namebuf, sizeof namebuf, "_f%.3ld", ++closgen);
xfunc->nname = newname(lookup(namebuf));
xfunc->nname->ntype = xtype;
declare(xfunc->nname, PFUNC);

View File

@ -617,7 +617,6 @@ EXTERN Sym* pkgimportname; // package name from imported package
EXTERN int tptr; // either TPTR32 or TPTR64
extern char* sysimport;
extern char* unsafeimport;
EXTERN char* filename; // name to uniqify names
EXTERN Idir* idirs;
EXTERN Type* types[NTYPE];
@ -696,7 +695,6 @@ int yyparse(void);
/*
* lex.c
*/
void setfilename(char*);
void addidir(char*);
void importfile(Val*);
void cannedimports(char*, char*);

View File

@ -9,7 +9,7 @@
* it is called by the initialization before
* main is run. to make it unique within a
* package and also uncallable, the name,
* normally "pkg.init", is altered to "pkg.init·filename".
* normally "pkg.init", is altered to "pkg.init·1".
*/
Node*
renameinit(Node *n)

View File

@ -76,8 +76,6 @@ main(int argc, char *argv[])
lexlineno = 1;
for(i=0; i<argc; i++) {
if(i == 0)
setfilename(argv[i]);
infile = argv[i];
linehist(infile, 0, 0);
@ -149,29 +147,6 @@ usage:
return 0;
}
void
setfilename(char *file)
{
char *p;
int c;
p = strrchr(file, '/');
if(p != nil)
file = p+1;
strncpy(namebuf, file, sizeof(namebuf));
p = strrchr(namebuf, '.');
if(p != nil && strcmp(p, ".go") == 0)
*p = 0;
filename = strdup(namebuf);
// turn invalid identifier chars into _
for(p=filename; *p; p++) {
c = *p & 0xFF;
if(c < 0x80 && !isalpha(c) && !isdigit(c) && c != '_')
*p = '_';
}
}
int
arsize(Biobuf *b, char *name)
{

View File

@ -973,11 +973,8 @@ Tpretty(Fmt *fp, Type *t)
return 0;
if(s->flags & SymImported)
return 0;
if(t->vargen || !(s->flags & (SymExport|SymPackage))) {
fmtprint(fp, "·%s", filename);
if(t->vargen)
fmtprint(fp, "·%d", t->vargen);
}
if(t->vargen)
fmtprint(fp, "·%d", t->vargen);
return 0;
}
return fmtprint(fp, "%S", s);
@ -2227,7 +2224,7 @@ staticname(Type *t)
{
Node *n;
snprint(namebuf, sizeof(namebuf), "statictmp_%.4d·%s", statuniqgen, filename);
snprint(namebuf, sizeof(namebuf), "statictmp_%.4d", statuniqgen);
statuniqgen++;
n = newname(lookup(namebuf));
addvar(n, t, PEXTERN);