mirror of
https://github.com/golang/go
synced 2024-11-12 07:00:21 -07:00
convert walkexpr to take Node**; drop indir
R=ken OCL=32421 CL=32421
This commit is contained in:
parent
8f694f6661
commit
056940d84b
@ -528,7 +528,7 @@ funclit0(Node *t)
|
||||
autodcl = dcl();
|
||||
autodcl->back = autodcl;
|
||||
|
||||
walkexpr(t, Etype, &t->ninit);
|
||||
walkexpr(&t, Etype, &t->ninit);
|
||||
funcargs(t->type);
|
||||
return t;
|
||||
}
|
||||
@ -703,7 +703,7 @@ stotype(NodeList *l, int et, Type **t)
|
||||
if(n->op != ODCLFIELD)
|
||||
fatal("stotype: oops %N\n", n);
|
||||
if(n->right != N) {
|
||||
walkexpr(n->right, Etype, &init);
|
||||
walkexpr(&n->right, Etype, &init);
|
||||
n->type = n->right->type;
|
||||
n->right = N;
|
||||
if(n->embedded && n->type != T) {
|
||||
@ -1298,7 +1298,7 @@ xanondcl(Node *nt)
|
||||
Node *n;
|
||||
Type *t;
|
||||
|
||||
walkexpr(nt, Etype, &nt->ninit);
|
||||
walkexpr(&nt, Etype, &nt->ninit);
|
||||
t = nt->type;
|
||||
if(nt->op != OTYPE) {
|
||||
yyerror("%S is not a type", nt->sym);
|
||||
@ -1318,7 +1318,7 @@ namedcl(Node *nn, Node *nt)
|
||||
if(nn->op == OKEY)
|
||||
nn = nn->left;
|
||||
if(nn->sym == S) {
|
||||
walkexpr(nn, Etype, &nn->ninit);
|
||||
walkexpr(&nn, Etype, &nn->ninit);
|
||||
yyerror("cannot mix anonymous %T with named arguments", nn->type);
|
||||
return xanondcl(nn);
|
||||
}
|
||||
@ -1326,7 +1326,7 @@ namedcl(Node *nn, Node *nt)
|
||||
if(nt == N)
|
||||
yyerror("missing type for argument %S", nn->sym);
|
||||
else {
|
||||
walkexpr(nt, Etype, &nt->ninit);
|
||||
walkexpr(&nt, Etype, &nt->ninit);
|
||||
if(nt->op != OTYPE)
|
||||
yyerror("%S is not a type", nt->sym);
|
||||
else
|
||||
@ -1650,7 +1650,7 @@ variter(NodeList *vl, Node *nt, NodeList *el)
|
||||
|
||||
t = T;
|
||||
if(nt) {
|
||||
walkexpr(nt, Etype, &nt->ninit);
|
||||
walkexpr(&nt, Etype, &nt->ninit);
|
||||
t = nt->type;
|
||||
}
|
||||
|
||||
@ -1668,15 +1668,15 @@ variter(NodeList *vl, Node *nt, NodeList *el)
|
||||
e = N;
|
||||
|
||||
v = vl->n;
|
||||
a = N;
|
||||
if(e != N || funcdepth > 0)
|
||||
a = nod(OAS, v, e);
|
||||
tv = t;
|
||||
if(t == T) {
|
||||
gettype(e, &r);
|
||||
gettype(&e, &r);
|
||||
defaultlit(&e, T);
|
||||
tv = e->type;
|
||||
}
|
||||
a = N;
|
||||
if(e != N || funcdepth > 0)
|
||||
a = nod(OAS, v, e);
|
||||
dodclvar(v, tv, &r);
|
||||
if(a != N)
|
||||
r = list(r, a);
|
||||
@ -1763,7 +1763,7 @@ unsafenmagic(Node *fn, NodeList *args)
|
||||
|
||||
n = nod(OLITERAL, N, N);
|
||||
if(strcmp(s->name, "Sizeof") == 0) {
|
||||
walkexpr(r, Erv, &n->ninit);
|
||||
walkexpr(&r, Erv, &n->ninit);
|
||||
tr = r->type;
|
||||
if(r->op == OLITERAL && r->val.ctype == CTSTR)
|
||||
tr = types[TSTRING];
|
||||
@ -1775,12 +1775,12 @@ unsafenmagic(Node *fn, NodeList *args)
|
||||
if(strcmp(s->name, "Offsetof") == 0) {
|
||||
if(r->op != ODOT && r->op != ODOTPTR)
|
||||
goto no;
|
||||
walkexpr(r, Erv, &n->ninit);
|
||||
walkexpr(&r, Erv, &n->ninit);
|
||||
v = r->xoffset;
|
||||
goto yes;
|
||||
}
|
||||
if(strcmp(s->name, "Alignof") == 0) {
|
||||
walkexpr(r, Erv, &n->ninit);
|
||||
walkexpr(&r, Erv, &n->ninit);
|
||||
tr = r->type;
|
||||
if(r->op == OLITERAL && r->val.ctype == CTSTR)
|
||||
tr = types[TSTRING];
|
||||
|
@ -194,6 +194,7 @@ struct Node
|
||||
uchar noescape; // ONAME never move to heap
|
||||
uchar funcdepth;
|
||||
uchar builtin; // built-in name, like len or close
|
||||
uchar walkdef;
|
||||
|
||||
// most nodes
|
||||
Node* left;
|
||||
@ -926,13 +927,13 @@ Type* pkgtype(Sym*);
|
||||
/*
|
||||
* walk.c
|
||||
*/
|
||||
void gettype(Node*, NodeList**);
|
||||
void gettype(Node**, NodeList**);
|
||||
void walk(Node*);
|
||||
void walkstmt(Node*);
|
||||
void walkstmt(Node**);
|
||||
void walkstmtlist(NodeList*);
|
||||
void walkexpr(Node*, int, NodeList**);
|
||||
void walkexpr(Node**, int, NodeList**);
|
||||
void walkexprlist(NodeList*, int, NodeList**);
|
||||
void walkconv(Node*, NodeList**);
|
||||
void walkconv(Node**, NodeList**);
|
||||
void walkdottype(Node*, NodeList**);
|
||||
void walkas(Node*);
|
||||
void walkbool(Node**);
|
||||
|
@ -400,7 +400,7 @@ typedclname:
|
||||
typedcl:
|
||||
typedclname ntype
|
||||
{
|
||||
walkexpr($2, Etype, &$2->ninit);
|
||||
walkexpr(&$2, Etype, &$2->ninit);
|
||||
updatetype($1, $2->type);
|
||||
resumecheckwidth();
|
||||
}
|
||||
@ -484,7 +484,7 @@ case:
|
||||
|
||||
// TODO: move
|
||||
e = nerrors;
|
||||
walkexpr(n, Etype | Erv, &$$->ninit);
|
||||
walkexpr(&n, Etype | Erv, &$$->ninit);
|
||||
if(n->op == OTYPE) {
|
||||
n = old2new(typeswvar->right, n->type, &$$->ninit);
|
||||
$$->list = list1(nod(OTYPESW, n, N));
|
||||
@ -1143,7 +1143,7 @@ fndcl:
|
||||
n = nod(OTFUNC, N, N);
|
||||
n->list = $3;
|
||||
n->rlist = $5;
|
||||
walkexpr(n, Etype, &n->ninit);
|
||||
walkexpr(&n, Etype, &n->ninit);
|
||||
$$->type = n->type;
|
||||
funchdr($$);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ mapindex(Node *n)
|
||||
b = nod(OAS, b, val);
|
||||
|
||||
r = liststmt(list(list1(a), b));
|
||||
walkstmt(r);
|
||||
walkstmt(&r);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ aindex(Node *b, Type *t)
|
||||
|
||||
bound = -1; // open bound
|
||||
init = nil;
|
||||
walkexpr(b, Erv, &init);
|
||||
walkexpr(&b, Erv, &init);
|
||||
if(b != nil) {
|
||||
switch(consttype(b)) {
|
||||
default:
|
||||
@ -2391,7 +2391,7 @@ saferef(Node *n, NodeList **init)
|
||||
r = nod(OXXX, N, N);
|
||||
*r = *n;
|
||||
r->left = l;
|
||||
walkexpr(r, Elv, init);
|
||||
walkexpr(&r, Elv, init);
|
||||
return r;
|
||||
|
||||
case OINDEX:
|
||||
@ -2400,10 +2400,10 @@ saferef(Node *n, NodeList **init)
|
||||
l = nod(OXXX, N, N);
|
||||
tempname(l, ptrto(n->type));
|
||||
a = nod(OAS, l, nod(OADDR, n, N));
|
||||
walkexpr(a, Etop, init);
|
||||
walkexpr(&a, Etop, init);
|
||||
*init = list(*init, a);
|
||||
r = nod(OIND, l, N);
|
||||
walkexpr(r, Elv, init);
|
||||
walkexpr(&r, Elv, init);
|
||||
return r;
|
||||
}
|
||||
fatal("saferef %N", n);
|
||||
@ -2563,7 +2563,7 @@ adddot(Node *n)
|
||||
int c, d;
|
||||
|
||||
init = nil;
|
||||
walkexpr(n->left, Erv, &init);
|
||||
walkexpr(&n->left, Erv, &init);
|
||||
t = n->left->type;
|
||||
if(t == T)
|
||||
goto ret;
|
||||
|
@ -250,7 +250,7 @@ sw0(Node **cp, Type *place, int arg)
|
||||
yyerror("inappropriate case for a type switch");
|
||||
return T;
|
||||
}
|
||||
walkexpr(c, Erv, nil);
|
||||
walkexpr(cp, Erv, nil);
|
||||
break;
|
||||
case OTYPESW:
|
||||
if(arg != Stype)
|
||||
@ -592,7 +592,7 @@ exprswitch(Node *sw)
|
||||
if(sw->ntest->val.u.bval == 0)
|
||||
arg = Sfalse;
|
||||
}
|
||||
walkexpr(sw->ntest, Erv, &sw->ninit);
|
||||
walkexpr(&sw->ntest, Erv, &sw->ninit);
|
||||
|
||||
/*
|
||||
* pass 0,1,2,3
|
||||
@ -771,7 +771,7 @@ typeswitch(Node *sw)
|
||||
yyerror("type switch must have an assignment");
|
||||
return;
|
||||
}
|
||||
walkexpr(sw->ntest->right, Erv, &sw->ninit);
|
||||
walkexpr(&sw->ntest->right, Erv, &sw->ninit);
|
||||
if(!istype(sw->ntest->right->type, TINTER)) {
|
||||
yyerror("type switch must be on an interface");
|
||||
return;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user