Commit 963753d3 authored by Ken Thompson's avatar Ken Thompson

tweaks to init

rand using init

SVN=128142
parent f24f8ffa
...@@ -917,7 +917,7 @@ void ...@@ -917,7 +917,7 @@ void
fninit(Node *n) fninit(Node *n)
{ {
Node *done, *any; Node *done, *any;
Node *a, *b, *r; Node *a, *fn, *r;
Iter iter; Iter iter;
ulong h; ulong h;
Sym *s; Sym *s;
...@@ -941,10 +941,10 @@ fninit(Node *n) ...@@ -941,10 +941,10 @@ fninit(Node *n)
if(strcmp(package, "main") == 0) if(strcmp(package, "main") == 0)
snprint(namebuf, sizeof(namebuf), "init_function"); snprint(namebuf, sizeof(namebuf), "init_function");
b = nod(ODCLFUNC, N, N); fn = nod(ODCLFUNC, N, N);
b->nname = newname(lookup(namebuf)); fn->nname = newname(lookup(namebuf));
b->type = functype(N, N, N); fn->type = functype(N, N, N);
funchdr(b); funchdr(fn);
// (3) // (3)
a = nod(OIF, N, N); a = nod(OIF, N, N);
...@@ -968,6 +968,7 @@ fninit(Node *n) ...@@ -968,6 +968,7 @@ fninit(Node *n)
if(s->oname == N) if(s->oname == N)
continue; continue;
// could check that it is fn of no args/returns
a = nod(OCALL, s->oname, N); a = nod(OCALL, s->oname, N);
r = list(r, a); r = list(r, a);
} }
...@@ -976,6 +977,7 @@ fninit(Node *n) ...@@ -976,6 +977,7 @@ fninit(Node *n)
r = list(r, n); r = list(r, n);
// (7) // (7)
// could check that it is fn of no args/returns
snprint(namebuf, sizeof(namebuf), "init_%s", filename); snprint(namebuf, sizeof(namebuf), "init_%s", filename);
s = lookup(namebuf); s = lookup(namebuf);
if(s->oname != N) { if(s->oname != N) {
...@@ -989,13 +991,13 @@ fninit(Node *n) ...@@ -989,13 +991,13 @@ fninit(Node *n)
// (9) // (9)
a = nod(OEXPORT, N, N); a = nod(OEXPORT, N, N);
a->sym = b->nname->sym; a->sym = fn->nname->sym;
markexport(a); markexport(a);
b->nbody = rev(r); fn->nbody = rev(r);
//dump("b", b); //dump("b", fn);
//dump("r", b->nbody); //dump("r", fn->nbody);
popdcl(); popdcl();
compile(b); compile(fn);
} }
This diff is collapsed.
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