Commit 80038494 authored by Ken Thompson's avatar Ken Thompson

parameter declartions in func literals

SVN=127678
parent 0e67654f
...@@ -102,11 +102,12 @@ allocparams(void) ...@@ -102,11 +102,12 @@ allocparams(void)
* parameters, is the offset in the * parameters, is the offset in the
* parameter list. * parameter list.
*/ */
d = autodcl; d = paramdcl->forw;;
t = funcfirst(&list, curfn->type); t = funcfirst(&list, curfn->type);
while(t != T) { while(t != T) {
if(d == D) if(d == D)
fatal("allocparams: this & in nil"); fatal("allocparams: this & in nil");
if(d->op != ONAME) { if(d->op != ONAME) {
d = d->forw; d = d->forw;
continue; continue;
...@@ -114,7 +115,7 @@ allocparams(void) ...@@ -114,7 +115,7 @@ allocparams(void)
n = d->dnode; n = d->dnode;
if(n->class != PPARAM) if(n->class != PPARAM)
fatal("allocparams: this & in class"); fatal("allocparams: this & in class %N %d", n, n->class);
n->xoffset = t->width; n->xoffset = t->width;
d = d->forw; d = d->forw;
...@@ -133,7 +134,7 @@ allocparams(void) ...@@ -133,7 +134,7 @@ allocparams(void)
n = d->dnode; n = d->dnode;
if(n->class != PPARAM) if(n->class != PPARAM)
fatal("allocparams: out class"); fatal("allocparams: out class %N %d", n, n->class);
n->xoffset = t->width; n->xoffset = t->width;
d = d->forw; d = d->forw;
......
...@@ -370,6 +370,8 @@ funcargs(Type *t) ...@@ -370,6 +370,8 @@ funcargs(Type *t)
Iter save; Iter save;
int all; int all;
paramdcl = autodcl->back; // base of arguments - see allocparams in gen.c
// declare the this/in arguments // declare the this/in arguments
n1 = funcfirst(&save, t); n1 = funcfirst(&save, t);
while(n1 != T) { while(n1 != T) {
...@@ -601,6 +603,30 @@ markdclstack(void) ...@@ -601,6 +603,30 @@ markdclstack(void)
} }
} }
void
dumpdcl(char *st)
{
Sym *s, *d;
int i;
print("\ndumpdcl: %s %p\n", st, b0stack);
i = 0;
for(d=dclstack; d!=S; d=d->link) {
i++;
print(" %.2d %p", i, d);
if(d == b0stack)
print(" (b0)");
if(d->name == nil) {
print("\n");
continue;
}
print(" '%s'", d->name);
s = pkglookup(d->name, d->package);
print(" %lS\n", s);
}
}
void void
testdclstack(void) testdclstack(void)
{ {
......
...@@ -385,6 +385,7 @@ EXTERN vlong minintval[NTYPE]; ...@@ -385,6 +385,7 @@ EXTERN vlong minintval[NTYPE];
EXTERN vlong maxintval[NTYPE]; EXTERN vlong maxintval[NTYPE];
EXTERN Dcl* autodcl; EXTERN Dcl* autodcl;
EXTERN Dcl* paramdcl;
EXTERN Dcl* externdcl; EXTERN Dcl* externdcl;
EXTERN Dcl* exportlist; EXTERN Dcl* exportlist;
EXTERN int dclcontext; // PEXTERN/PAUTO EXTERN int dclcontext; // PEXTERN/PAUTO
...@@ -529,6 +530,7 @@ Type* sortinter(Type*); ...@@ -529,6 +530,7 @@ Type* sortinter(Type*);
void markdcl(void); void markdcl(void);
void popdcl(void); void popdcl(void);
void poptodcl(void); void poptodcl(void);
void dumpdcl(char*);
void markdclstack(void); void markdclstack(void);
void testdclstack(void); void testdclstack(void);
Sym* pushdcl(Sym*); Sym* pushdcl(Sym*);
......
...@@ -1024,7 +1024,6 @@ fnliteral: ...@@ -1024,7 +1024,6 @@ fnliteral:
$$ = newname(lookup(namebuf)); $$ = newname(lookup(namebuf));
addvar($$, $1, PEXTERN); addvar($$, $1, PEXTERN);
dump("lit1", $$);
{ {
Node *n; Node *n;
...@@ -1035,13 +1034,10 @@ dump("lit1", $$); ...@@ -1035,13 +1034,10 @@ dump("lit1", $$);
n->nbody = $3; n->nbody = $3;
if(n->nbody == N) if(n->nbody == N)
n->nbody = nod(ORETURN, N, N); n->nbody = nod(ORETURN, N, N);
dump("comp1", n);
compile(n); compile(n);
dump("comp2", n);
} }
$$ = nod(OADDR, $$, N); $$ = nod(OADDR, $$, N);
dump("lit2", $$);
} }
fnbody: fnbody:
......
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