Commit 1423bf3d authored by Ken Thompson's avatar Ken Thompson

structure literals

R=r
OCL=14735
CL=14735
parent 30aa83ca
......@@ -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
......
......@@ -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)
{
......
......@@ -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);
......
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