Commit 814320c8 authored by Ken Thompson's avatar Ken Thompson

parameter in fn literals

SVN=127695
parent 80038494
...@@ -102,7 +102,7 @@ allocparams(void) ...@@ -102,7 +102,7 @@ allocparams(void)
* parameters, is the offset in the * parameters, is the offset in the
* parameter list. * parameter list.
*/ */
d = paramdcl->forw;; d = curfn->type->param->forw;
t = funcfirst(&list, curfn->type); t = funcfirst(&list, curfn->type);
while(t != T) { while(t != T) {
if(d == D) if(d == D)
...@@ -117,6 +117,7 @@ allocparams(void) ...@@ -117,6 +117,7 @@ allocparams(void)
if(n->class != PPARAM) if(n->class != PPARAM)
fatal("allocparams: this & in class %N %d", n, n->class); fatal("allocparams: this & in class %N %d", n, n->class);
//print("assign %S %ld\n", n->sym, t->width);
n->xoffset = t->width; n->xoffset = t->width;
d = d->forw; d = d->forw;
t = funcnext(&list); t = funcnext(&list);
...@@ -127,6 +128,7 @@ allocparams(void) ...@@ -127,6 +128,7 @@ allocparams(void)
if(t->nname != N && t->nname->sym->name[0] != '_') { if(t->nname != N && t->nname->sym->name[0] != '_') {
if(d == D) if(d == D)
fatal("allocparams: out nil"); fatal("allocparams: out nil");
if(d->op != ONAME) { if(d->op != ONAME) {
d = d->forw; d = d->forw;
continue; continue;
......
...@@ -364,39 +364,39 @@ funchdr(Node *n) ...@@ -364,39 +364,39 @@ funchdr(Node *n)
} }
void void
funcargs(Type *t) funcargs(Type *ft)
{ {
Type *n1; Type *t;
Iter save; Iter save;
int all; int all;
paramdcl = autodcl->back; // base of arguments - see allocparams in gen.c ft->param = autodcl->back; // base of arguments - see allocparams in gen.c
// declare the this/in arguments // declare the this/in arguments
n1 = funcfirst(&save, t); t = funcfirst(&save, ft);
while(n1 != T) { while(t != T) {
if(n1->nname != N) if(t->nname != N)
addvar(n1->nname, n1->type, PPARAM); addvar(t->nname, t->type, PPARAM);
n1 = funcnext(&save); t = funcnext(&save);
} }
// declare the outgoing arguments // declare the outgoing arguments
all = 0; all = 0;
n1 = structfirst(&save, getoutarg(t)); t = structfirst(&save, getoutarg(ft));
while(n1 != T) { while(t != T) {
if(n1->nname != N && n1->nname->sym->name[0] != '_') { if(t->nname != N && t->nname->sym->name[0] != '_') {
addvar(n1->nname, n1->type, PPARAM); addvar(t->nname, t->type, PPARAM);
all |= 1; all |= 1;
} else } else
all |= 2; all |= 2;
n1 = structnext(&save); t = structnext(&save);
} }
if(all == 3) if(all == 3)
yyerror("output parameters are all named or not named"); yyerror("output parameters are all named or not named");
t->outnamed = 0; ft->outnamed = 0;
if(all == 1) if(all == 1)
t->outnamed = 1; ft->outnamed = 1;
} }
/* /*
......
...@@ -68,6 +68,7 @@ struct Val ...@@ -68,6 +68,7 @@ struct Val
typedef struct Sym Sym; typedef struct Sym Sym;
typedef struct Node Node; typedef struct Node Node;
typedef struct Type Type; typedef struct Type Type;
typedef struct Dcl Dcl;
struct Type struct Type
{ {
...@@ -84,6 +85,7 @@ struct Type ...@@ -84,6 +85,7 @@ struct Type
Sym* sym; Sym* sym;
long vargen; // unique name for OTYPE/ONAME long vargen; // unique name for OTYPE/ONAME
Dcl* param;
// most nodes // most nodes
Type* type; Type* type;
...@@ -173,7 +175,6 @@ struct Sym ...@@ -173,7 +175,6 @@ struct Sym
}; };
#define S ((Sym*)0) #define S ((Sym*)0)
typedef struct Dcl Dcl;
struct Dcl struct Dcl
{ {
uchar op; uchar op;
......
...@@ -1179,8 +1179,6 @@ prcompat(Node *n) ...@@ -1179,8 +1179,6 @@ prcompat(Node *n)
loop: loop:
if(l == N) { if(l == N) {
if(r == N)
return nod(OBAD, N, N);
walktype(r, Etop); walktype(r, Etop);
return r; return r;
} }
......
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