Commit f821e3c7 authored by Russ Cox's avatar Russ Cox

6g tweaks

	* byteastring is no longer used
	* do not generate ODCL, OAS for globals
	  (wasn't generating any code but might
	  save one or two init functions)
	* do not call self from Init function

R=ken
OCL=28309
CL=28309
parent b8dd218e
......@@ -18,7 +18,6 @@ char *sysimport =
"func sys.slicestring (? string, ? int, ? int) (? string)\n"
"func sys.indexstring (? string, ? int) (? uint8)\n"
"func sys.intstring (? int64) (? string)\n"
"func sys.byteastring (? *uint8, ? int) (? string)\n"
"func sys.arraystring (? []uint8) (? string)\n"
"func sys.stringiter (? string, ? int) (? int)\n"
"func sys.stringiter2 (? string, ? int) (retk int, retv int)\n"
......
......@@ -38,7 +38,8 @@ dodclvar(Node *n, Type *t)
addvar(n, t, dclcontext);
autoexport(n->sym);
addtop = list(addtop, nod(ODCL, n, N));
if(funcdepth > 0)
addtop = list(addtop, nod(ODCL, n, N));
}
void
......@@ -1299,7 +1300,7 @@ fninit(Node *n)
Node *done;
Node *a, *fn, *r;
uint32 h;
Sym *s;
Sym *s, *initsym;
if(strcmp(package, "PACKAGE") == 0) {
// sys.go or unsafe.go during compiler build
......@@ -1329,7 +1330,8 @@ fninit(Node *n)
snprint(namebuf, sizeof(namebuf), "init");
fn = nod(ODCLFUNC, N, N);
fn->nname = newname(lookup(namebuf));
initsym = lookup(namebuf);
fn->nname = newname(initsym);
fn->type = functype(N, N, N);
funchdr(fn);
......@@ -1350,6 +1352,8 @@ fninit(Node *n)
continue;
if(s->oname == N)
continue;
if(s == initsym)
continue;
// could check that it is fn of no args/returns
a = nod(OCALL, s->oname, N);
......
......@@ -299,8 +299,12 @@ Avardcl:
$$ = rev($1);
dodclvar($$, $2);
$$ = nod(OAS, $$, N);
addtotop($$);
if(funcdepth == 0) {
$$ = N;
} else {
$$ = nod(OAS, $$, N);
addtotop($$);
}
}
Bvardcl:
......@@ -309,8 +313,12 @@ Bvardcl:
$$ = rev($1);
dodclvar($$, $2);
$$ = nod(OAS, $$, N);
addtotop($$);
if(funcdepth == 0) {
$$ = N;
} else {
$$ = nod(OAS, $$, N);
addtotop($$);
}
}
| new_name_list_r type '=' expr_list
{
......
......@@ -27,7 +27,6 @@ func cmpstring(string, string) int;
func slicestring(string, int, int) string;
func indexstring(string, int) byte;
func intstring(int64) string;
func byteastring(*byte, int) string;
func arraystring([]byte) string;
func stringiter(string, int) int;
func stringiter2(string, int) (retk int, retv int);
......
......@@ -173,14 +173,6 @@ sys·intstring(int64 v, String s)
FLUSH(&s);
}
void
sys·byteastring(byte *a, int32 l, String s)
{
s = gostringsize(l);
mcpy(s.str, a, l);
FLUSH(&s);
}
void
sys·arraystring(Array b, String s)
{
......
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