Commit 07d344e4 authored by Russ Cox's avatar Russ Cox

remove export name-list statement.

make package local the default.
warn about name case not matching export keyword.

R=ken
OCL=22881
CL=22886
parent b54133d2
...@@ -543,7 +543,6 @@ gmove(Node *f, Node *t) ...@@ -543,7 +543,6 @@ gmove(Node *f, Node *t)
dump("gmove", t); dump("gmove", t);
fatal("gmove t %O class %d reg %R", t->op, t->class, t->val.u.reg); fatal("gmove t %O class %d reg %R", t->op, t->class, t->val.u.reg);
case PEXTERN: case PEXTERN:
case PSTATIC:
goto refcount; goto refcount;
break; break;
case PAUTO: case PAUTO:
...@@ -1072,9 +1071,6 @@ naddr(Node *n, Addr *a) ...@@ -1072,9 +1071,6 @@ naddr(Node *n, Addr *a)
case PPARAM: case PPARAM:
a->type = D_PARAM; a->type = D_PARAM;
break; break;
case PSTATIC:
a->type = D_STATIC;
break;
} }
break; break;
......
...@@ -35,8 +35,7 @@ dodclvar(Node *n, Type *t) ...@@ -35,8 +35,7 @@ dodclvar(Node *n, Type *t)
t = typ(TFORW); t = typ(TFORW);
addvar(n, t, dclcontext); addvar(n, t, dclcontext);
if(dcladj) autoexport(n->sym);
dcladj(n->sym);
} }
void void
...@@ -49,8 +48,7 @@ dodclconst(Node *n, Node *e) ...@@ -49,8 +48,7 @@ dodclconst(Node *n, Node *e)
dodclconst(n, e); dodclconst(n, e);
addconst(n, e, dclcontext); addconst(n, e, dclcontext);
if(dcladj) autoexport(n->sym);
dcladj(n->sym);
} }
/* /*
...@@ -79,8 +77,7 @@ dodcltype(Type *n) ...@@ -79,8 +77,7 @@ dodcltype(Type *n)
found: found:
n->local = 1; n->local = 1;
if(dcladj) autoexport(n->sym);
dcladj(n->sym);
return n; return n;
} }
......
...@@ -53,6 +53,32 @@ packagesym(Sym *s) ...@@ -53,6 +53,32 @@ packagesym(Sym *s)
addexportsym(s); addexportsym(s);
} }
int
exportname(char *s)
{
Rune r;
if((uchar)s[0] < Runeself)
return 'A' <= s[0] && s[0] <= 'Z';
chartorune(&r, s);
return isupperrune(r);
}
void
autoexport(Sym *s)
{
if(s == S)
return;
if(dclcontext != PEXTERN)
return;
if(exportname(s->name)) {
if(dcladj != exportsym)
warn("uppercase missing export");
exportsym(s);
} else
packagesym(s);
}
void void
dumpprereq(Type *t) dumpprereq(Type *t)
{ {
...@@ -330,6 +356,7 @@ importconst(int export, Node *ss, Type *t, Val *v) ...@@ -330,6 +356,7 @@ importconst(int export, Node *ss, Type *t, Val *v)
Node *n; Node *n;
Sym *s; Sym *s;
export = exportname(ss->sym->name);
if(export == 2 && !mypackage(ss)) if(export == 2 && !mypackage(ss))
return; return;
...@@ -337,14 +364,18 @@ importconst(int export, Node *ss, Type *t, Val *v) ...@@ -337,14 +364,18 @@ importconst(int export, Node *ss, Type *t, Val *v)
n->val = *v; n->val = *v;
n->type = t; n->type = t;
s = importsym(export, ss, LNAME); s = importsym(export, ss, LACONST);
if(s->oconst != N) { if(s->oconst != N) {
// TODO: check if already the same. // TODO: check if already the same.
return; return;
} }
// fake out export vs upper checks until transition is over
if(export == 1) dcladj = exportsym;
dodclconst(newname(s), n); dodclconst(newname(s), n);
dcladj = nil;
if(debug['e']) if(debug['e'])
print("import const %S\n", s); print("import const %S\n", s);
} }
......
...@@ -180,7 +180,7 @@ struct Node ...@@ -180,7 +180,7 @@ struct Node
uchar addable; // type of addressability - 0 is not addressable uchar addable; // type of addressability - 0 is not addressable
uchar trecur; // to detect loops uchar trecur; // to detect loops
uchar etype; // op for OASOP, etype for OTYPE, exclam for export uchar etype; // op for OASOP, etype for OTYPE, exclam for export
uchar class; // PPARAM, PAUTO, PEXTERN, PSTATIC uchar class; // PPARAM, PAUTO, PEXTERN
uchar method; // OCALLMETH name uchar method; // OCALLMETH name
uchar iota; // OLITERAL made from iota uchar iota; // OLITERAL made from iota
uchar embedded; // ODCLFIELD embedded type uchar embedded; // ODCLFIELD embedded type
...@@ -404,7 +404,6 @@ enum ...@@ -404,7 +404,6 @@ enum
PEXTERN, // declaration context PEXTERN, // declaration context
PAUTO, PAUTO,
PPARAM, PPARAM,
PSTATIC,
}; };
enum enum
...@@ -741,6 +740,7 @@ void constiter(Node*, Type*, Node*); ...@@ -741,6 +740,7 @@ void constiter(Node*, Type*, Node*);
* export.c * export.c
*/ */
void renamepkg(Node*); void renamepkg(Node*);
void autoexport(Sym*);
void exportsym(Sym*); void exportsym(Sym*);
void packagesym(Sym*); void packagesym(Sym*);
void dumpe(Sym*); void dumpe(Sym*);
......
...@@ -188,20 +188,15 @@ xdcl: ...@@ -188,20 +188,15 @@ xdcl:
{ {
$$ = N; $$ = N;
} }
| LEXPORT export_list_r
{
$$ = N;
}
| LEXPORT { dcladj = exportsym; stksize = initstksize; } common_dcl | LEXPORT { dcladj = exportsym; stksize = initstksize; } common_dcl
{ {
$$ = $3; $$ = $3;
dcladj = 0; dcladj = 0;
initstksize = stksize; initstksize = stksize;
} }
| LPACKAGE { dcladj = packagesym; stksize = initstksize; } common_dcl | LPACKAGE { warn("package is gone"); stksize = initstksize; } common_dcl
{ {
$$ = $3; $$ = $3;
dcladj = 0;
initstksize = stksize; initstksize = stksize;
} }
| LEXPORT '(' export_list_r ')' | LEXPORT '(' export_list_r ')'
...@@ -214,10 +209,10 @@ xdcl: ...@@ -214,10 +209,10 @@ xdcl:
exportsym($2->nname->sym); exportsym($2->nname->sym);
$$ = N; $$ = N;
} }
| LPACKAGE xfndcl | LPACKAGE { warn("package is gone"); } xfndcl
{ {
if($2 != N && $2->nname != N) if($3 != N && $3->nname != N)
packagesym($2->nname->sym); packagesym($3->nname->sym);
$$ = N; $$ = N;
} }
| ';' | ';'
......
...@@ -52,11 +52,11 @@ time make ...@@ -52,11 +52,11 @@ time make
make smoketest make smoketest
) || exit $? ) || exit $?
(xcd ../usr/gri/gosrc # (xcd ../usr/gri/gosrc
make clean # make clean
time make # time make
# make test # # make test
) || exit $? # ) || exit $?
(xcd ../doc/progs (xcd ../doc/progs
time ./run time ./run
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment