mirror of https://github.com/golang/go.git
parent
2119294af9
commit
d01a1ec260
|
|
@ -666,6 +666,8 @@ void doimport9(Sym*, Node*);
|
|||
/*
|
||||
* walk.c
|
||||
*/
|
||||
void addtotop(Node*);
|
||||
void gettype(Node*, Node*);
|
||||
void walk(Node*);
|
||||
void walkstate(Node*);
|
||||
void walktype(Node*, int);
|
||||
|
|
|
|||
|
|
@ -247,20 +247,22 @@ Bvardcl:
|
|||
dodclvar($$, $2);
|
||||
|
||||
$$ = nod(OAS, $$, $4);
|
||||
addtotop($$);
|
||||
}
|
||||
| new_name '=' expr
|
||||
{
|
||||
gettype($3);
|
||||
$$ = nod(OAS, $1, N);
|
||||
gettype($3, $$);
|
||||
defaultlit($3);
|
||||
dodclvar($1, $3->type);
|
||||
$$ = nod(OAS, $1, $3);
|
||||
$$->right = $3;
|
||||
}
|
||||
|
||||
constdcl:
|
||||
new_name type '=' expr
|
||||
{
|
||||
Node *c = treecopy($4);
|
||||
gettype(c);
|
||||
gettype(c, N);
|
||||
convlit(c, $2);
|
||||
dodclconst($1, c);
|
||||
|
||||
|
|
@ -270,7 +272,7 @@ constdcl:
|
|||
| new_name '=' expr
|
||||
{
|
||||
Node *c = treecopy($3);
|
||||
gettype(c);
|
||||
gettype(c, N);
|
||||
dodclconst($1, c);
|
||||
|
||||
lastconst = $3;
|
||||
|
|
@ -282,7 +284,7 @@ constdcl1:
|
|||
| new_name type
|
||||
{
|
||||
Node *c = treecopy(lastconst);
|
||||
gettype(c);
|
||||
gettype(c, N);
|
||||
convlit(c, $2);
|
||||
dodclconst($1, c);
|
||||
|
||||
|
|
@ -291,7 +293,7 @@ constdcl1:
|
|||
| new_name
|
||||
{
|
||||
Node *c = treecopy(lastconst);
|
||||
gettype(c);
|
||||
gettype(c, N);
|
||||
dodclconst($1, c);
|
||||
|
||||
iota += 1;
|
||||
|
|
|
|||
|
|
@ -76,12 +76,14 @@ addtotop(Node *n)
|
|||
}
|
||||
|
||||
void
|
||||
gettype(Node *n)
|
||||
gettype(Node *n, Node *a)
|
||||
{
|
||||
if(debug['W'])
|
||||
dump("\nbefore gettype", n);
|
||||
walktype(n, Erv);
|
||||
addtotop(n);
|
||||
if(a == N && addtop != N)
|
||||
fatal("gettype: addtop");
|
||||
addtotop(a);
|
||||
if(debug['W'])
|
||||
dump("after gettype", n);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue