1
0
mirror of https://github.com/golang/go synced 2024-11-18 20:14:43 -07:00

structure literals

R=r
OCL=14735
CL=14735
This commit is contained in:
Ken Thompson 2008-09-02 19:11:25 -07:00
parent 30aa83ca6e
commit 1423bf3dc4
3 changed files with 22 additions and 26 deletions

View File

@ -137,6 +137,9 @@ gen(Node *n, Label *labloop)
loop:
if(n == N)
goto ret;
if(n->ninit)
gen(n->ninit, L);
setlineno(n);
switch(n->op) {
@ -234,7 +237,6 @@ loop:
break;
case OFOR:
gen(n->ninit, L); // init
p1 = gbranch(AJMP, T); // goto test
sbreak = breakpc;
breakpc = gbranch(AJMP, T); // break: goto done
@ -256,7 +258,6 @@ loop:
break;
case OIF:
gen(n->ninit, L); // init
p1 = gbranch(AJMP, T); // goto test
p2 = gbranch(AJMP, T); // p2: goto else
patch(p1, pc); // test:
@ -269,7 +270,6 @@ loop:
break;
case OSWITCH:
gen(n->ninit, L); // init
p1 = gbranch(AJMP, T); // goto test
sbreak = breakpc;
breakpc = gbranch(AJMP, T); // break: goto done
@ -284,7 +284,6 @@ loop:
break;
case OSELECT:
gen(n->ninit, L);
sbreak = breakpc;
p1 = gbranch(AJMP, T); // goto test
breakpc = gbranch(AJMP, T); // break: goto done

View File

@ -1220,6 +1220,23 @@ isptrdarray(Type *t)
return 0;
}
int
isselect(Node *n)
{
Sym *s;
if(n == N)
return 0;
n = n->left;
s = pkglookup("selectsend", "sys");
if(s == n->sym)
return 1;
s = pkglookup("selectrecv", "sys");
if(s == n->sym)
return 1;
return 0;
}
int
isinter(Type *t)
{

View File

@ -21,23 +21,6 @@ walk(Node *fn)
dump("fn", fn->nbody);
}
int
isselect(Node *n)
{
Sym *s;
if(n == N)
return 0;
n = n->left;
s = pkglookup("selectsend", "sys");
if(s == n->sym)
return 1;
s = pkglookup("selectrecv", "sys");
if(s == n->sym)
return 1;
return 0;
}
void
walktype1(Node *n, int top)
{
@ -396,8 +379,6 @@ loop:
goto ret;
convlit(l, t);
if(l->type == T)
goto ret;
// nil conversion
if(eqtype(t, l->type, 0)) {
@ -415,6 +396,7 @@ loop:
}
// to string
if(l->type != T)
if(isptrto(t, TSTRING)) {
if(isint[l->type->etype]) {
*n = *stringop(n, top);
@ -2331,7 +2313,7 @@ walktype(Node *n, int top)
r = addtop;
addtop = N;
walktype1(r, top);
n->ninit = list(r, n->ninit);
n->ninit = list(n->ninit, r);
}
}
@ -2830,8 +2812,6 @@ structlit(Node *n)
if(t->etype != TSTRUCT)
fatal("structlit: not struct");
print("\nstruct lit %lT\n", t);
var = nod(OXXX, N, N);
tempname(var, t);