1
0
mirror of https://github.com/golang/go synced 2024-11-22 05:24:39 -07:00

parameter in fn literals

SVN=127695
This commit is contained in:
Ken Thompson 2008-07-16 18:31:01 -07:00
parent 8003849498
commit 814320c8b4
4 changed files with 20 additions and 19 deletions

View File

@ -102,7 +102,7 @@ allocparams(void)
* parameters, is the offset in the
* parameter list.
*/
d = paramdcl->forw;;
d = curfn->type->param->forw;
t = funcfirst(&list, curfn->type);
while(t != T) {
if(d == D)
@ -117,6 +117,7 @@ allocparams(void)
if(n->class != PPARAM)
fatal("allocparams: this & in class %N %d", n, n->class);
//print("assign %S %ld\n", n->sym, t->width);
n->xoffset = t->width;
d = d->forw;
t = funcnext(&list);
@ -127,6 +128,7 @@ allocparams(void)
if(t->nname != N && t->nname->sym->name[0] != '_') {
if(d == D)
fatal("allocparams: out nil");
if(d->op != ONAME) {
d = d->forw;
continue;

View File

@ -364,39 +364,39 @@ funchdr(Node *n)
}
void
funcargs(Type *t)
funcargs(Type *ft)
{
Type *n1;
Type *t;
Iter save;
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
n1 = funcfirst(&save, t);
while(n1 != T) {
if(n1->nname != N)
addvar(n1->nname, n1->type, PPARAM);
n1 = funcnext(&save);
t = funcfirst(&save, ft);
while(t != T) {
if(t->nname != N)
addvar(t->nname, t->type, PPARAM);
t = funcnext(&save);
}
// declare the outgoing arguments
all = 0;
n1 = structfirst(&save, getoutarg(t));
while(n1 != T) {
if(n1->nname != N && n1->nname->sym->name[0] != '_') {
addvar(n1->nname, n1->type, PPARAM);
t = structfirst(&save, getoutarg(ft));
while(t != T) {
if(t->nname != N && t->nname->sym->name[0] != '_') {
addvar(t->nname, t->type, PPARAM);
all |= 1;
} else
all |= 2;
n1 = structnext(&save);
t = structnext(&save);
}
if(all == 3)
yyerror("output parameters are all named or not named");
t->outnamed = 0;
ft->outnamed = 0;
if(all == 1)
t->outnamed = 1;
ft->outnamed = 1;
}
/*

View File

@ -68,6 +68,7 @@ struct Val
typedef struct Sym Sym;
typedef struct Node Node;
typedef struct Type Type;
typedef struct Dcl Dcl;
struct Type
{
@ -84,6 +85,7 @@ struct Type
Sym* sym;
long vargen; // unique name for OTYPE/ONAME
Dcl* param;
// most nodes
Type* type;
@ -173,7 +175,6 @@ struct Sym
};
#define S ((Sym*)0)
typedef struct Dcl Dcl;
struct Dcl
{
uchar op;

View File

@ -1179,8 +1179,6 @@ prcompat(Node *n)
loop:
if(l == N) {
if(r == N)
return nod(OBAD, N, N);
walktype(r, Etop);
return r;
}