ref: ad4d1397fb08b0d205e623f9a7c74fa19afb1c8c
parent: 0205329e24d0e078a8150020843586cbd12613c8
	author: Ori Bernstein <ori@eigenstate.org>
	date: Tue Feb  2 06:30:24 EST 2016
	
Make slpush take an address.
--- a/lib/regex/compile.myr
+++ b/lib/regex/compile.myr
@@ -194,8 +194,8 @@
n = rt.ranges.len
if n == 0
- rt.ranges = std.slpush(rt.ranges, (lo[0], hi[0]))
- rt.link = std.slpush(rt.link, std.zalloc())
+ std.slpush(&rt.ranges, (lo[0], hi[0]))
+ std.slpush(&rt.link, std.zalloc())
else
/*
this is a safe way to compare because we know that ranges
@@ -204,8 +204,8 @@
*/
(a, b) = rt.ranges[n - 1]
if a != lo[0] || b != hi[0]
- rt.ranges = std.slpush(rt.ranges, (lo[0], hi[0]))
- rt.link = std.slpush(rt.link, std.zalloc())
+ std.slpush(&rt.ranges, (lo[0], hi[0]))
+ std.slpush(&rt.link, std.zalloc())
;;
;;
@@ -551,7 +551,7 @@
| '+': -> `Fail `Badrep '+'
| '?': -> `Fail `Badrep '?'
| '[': -> chrclass(re)
- | '.': getc(re); ret = std.mk(`Ranges std.slpush([][:], [0, std.Maxcharval]))
+ | '.': getc(re); ret = std.mk(`Ranges std.sldup([[0, std.Maxcharval]][:]))
| '^': getc(re); ret = std.mk(`Bol)
| '$': getc(re); ret = std.mk(`Eol)
 	| '(':	@@ -719,12 +719,12 @@
if matchc(re, '-')
hi = getc(re)
if lo <= hi
- -> std.slpush(sl, [lo, hi])
+ -> std.slpush(&sl, [lo, hi])
else
- -> std.slpush(sl, [hi, lo])
+ -> std.slpush(&sl, [hi, lo])
;;
else
- -> std.slpush(sl, [lo, lo])
+ -> std.slpush(&sl, [lo, lo])
;;
}
@@ -737,10 +737,10 @@
next = 0 /* if we have no ranges */
for r in rng
(end, next) = (r[0], r[1])
- neg = std.slpush(neg, [start, end - 1])
+ std.slpush(&neg, [start, end - 1])
start = next + 1
;;
- neg = std.slpush(neg, [next + 1, std.Maxcharval])
+ std.slpush(&neg, [next + 1, std.Maxcharval])
-> neg
}
@@ -760,12 +760,12 @@
if r[0] <= hi + 1
hi = r[1]
else
- ret = std.slpush(ret, [lo, hi])
+ std.slpush(&ret, [lo, hi])
lo = r[0]
hi = r[1]
;;
;;
- -> std.slpush(ret, [lo, hi])
+ -> std.slpush(&ret, [lo, hi])
}
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -79,9 +79,9 @@
a.sign = 1
;;
val = v castto(uint64)
- a.dig = slpush([][:], val castto(uint32))
+ slpush(&a.dig, val castto(uint32))
if val > Base
- a.dig = slpush(a.dig, (val/Base) castto(uint32))
+ slpush(&a.dig, (val/Base) castto(uint32))
;;
-> trim(a)
}
--- a/lib/std/bld.sub
+++ b/lib/std/bld.sub
@@ -7,6 +7,7 @@
bigint.myr
bitset.myr
blat.myr
+ byzip.myr
chartype.myr
clear.myr
cmp.myr
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -229,7 +229,7 @@
;;
ha = hasarg
if ha == gotarg
- opts = std.slpush(opts, (o, a))
+ std.slpush(&opts, (o, a))
else
 				std.fatal("invalid option {}", o);;
--- a/lib/std/hashfuncs.myr
+++ b/lib/std/hashfuncs.myr
@@ -64,7 +64,7 @@
chars = [][:]
while s.len != 0
(c, s) = std.strstep(s)
- chars = std.slpush(chars, c)
+ std.slpush(&chars, c)
;;
h = murmurhash2(slbytes(chars), Seed)
slfree(chars)
--- a/lib/std/optparse.myr
+++ b/lib/std/optparse.myr
@@ -64,7 +64,7 @@
]
optinit(&ctx, args, def)
while !optdone(&ctx)
- parsed.opts = slpush(parsed.opts, optnext(&ctx))
+ slpush(&parsed.opts, optnext(&ctx))
;;
if ctx.args.len < def.minargs
 		put("error: expected at least {} args, got {}\n", def.minargs, ctx.args.len)@@ -164,7 +164,7 @@
goto foundopt
;;
else
- ctx.args = slpush(ctx.args, ctx.optargs[i])
+ slpush(&ctx.args, ctx.optargs[i])
;;
;;
:finishedopt
--- a/lib/std/resolve+posixy.myr
+++ b/lib/std/resolve+posixy.myr
@@ -78,7 +78,7 @@
 const resolverec = {host, tmatch hostfind(host)
| `Some hinf:
- -> `Ok slpush([][:], hinf)
+ -> `Ok sldup([hinf][:])
| `None:
-> dnsresolve(host, rectype(`DnsA))
;;
@@ -186,7 +186,7 @@
| `Some (name, _):
match ipparse(name)
| `Some addr:
- nameservers = slpush(nameservers, addr)
+ slpush(&nameservers, addr)
| `None:
/* nothing */
;;
--- a/lib/std/slpush.myr
+++ b/lib/std/slpush.myr
@@ -2,7 +2,7 @@
use "alloc"
pkg std =
- generic slpush : (sl : @a[:], elt : @a -> @a[:])
+ generic slpush : (sl : @a[:]#, elt : @a -> @a[:])
;;
 generic slpush = {sl, elt@@ -14,7 +14,7 @@
a bucket boundary, this is effectively
growing the slice by powers of two.
*/
- sl = slgrow(sl, sl.len + 1)
- sl[sl.len - 1] = elt
- -> sl
+ sl# = slgrow(sl#, sl#.len + 1)
+ sl#[sl#.len - 1] = elt
+ -> sl#
}
--- a/lib/std/strsplit.myr
+++ b/lib/std/strsplit.myr
@@ -27,7 +27,7 @@
while true
match strfind(s, delim)
| `Some i:
- sp = slpush(sp, s[:i])
+ slpush(&sp, s[:i])
s = s[i + delim.len:]
| `None:
goto donesplit
@@ -34,7 +34,7 @@
;;
;;
:donesplit
- sp = slpush(sp, s[:])
+ slpush(&sp, s[:])
-> sp
}
@@ -53,7 +53,7 @@
j++
;;
if i != j
- toks = slpush(toks, s[i:j])
+ slpush(&toks, s[i:j])
;;
i = j
;;
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -134,7 +134,7 @@
incs = std.sldup(targ.incpath)
if opt_instbase.len > 0 && !std.sleq(opt_instbase, "none")
libpath = std.pathcat(bld.opt_instbase, config.Libpath)
- incs = std.slpush(incs, libpath)
+ std.slpush(&incs, libpath)
;;
linkbin(dg, targ.name, src, targ.ldscript, targ.runtime, incs, targ.libdeps)
std.slfree(incs)
@@ -247,36 +247,36 @@
cmd = [][:]
if std.hassuffix(src, ".myr")
- cmd = std.slpush(cmd, opt_mc)
+ std.slpush(&cmd, opt_mc)
for inc in incs
- cmd = std.slpush(cmd, "-I")
- cmd = std.slpush(cmd, inc)
+ std.slpush(&cmd, "-I")
+ std.slpush(&cmd, inc)
;;
if opt_genasm
- cmd = std.slpush(cmd, "-S")
+ std.slpush(&cmd, "-S")
;;
- cmd = std.slpush(cmd, src)
+ std.slpush(&cmd, src)
run(cmd)
std.slfree(cmd)
elif std.hassuffix(src, ".s")
o = srcswapsuffix(src, config.Objsuffix)
for c in config.Ascmd
- cmd = std.slpush(cmd, c)
+ std.slpush(&cmd, c)
;;
- cmd = std.slpush(cmd,"-o")
- cmd = std.slpush(cmd, o)
- cmd = std.slpush(cmd, src)
+ std.slpush(&cmd,"-o")
+ std.slpush(&cmd, o)
+ std.slpush(&cmd, src)
run(cmd)
std.slfree(o)
elif std.hassuffix(src, ".glue.c")
o = srcswapsuffix(src, config.Objsuffix)
- cmd = std.slpush(cmd, "cc")
- cmd = std.slpush(cmd,"-c")
- cmd = std.slpush(cmd,"-o")
- cmd = std.slpush(cmd, o)
- cmd = std.slpush(cmd, src)
+ std.slpush(&cmd, "cc")
+ std.slpush(&cmd,"-c")
+ std.slpush(&cmd,"-o")
+ std.slpush(&cmd, o)
+ std.slpush(&cmd, src)
for flg in std.htgetv(dg.cflags, src, [][:])
- cmd = std.slpush(cmd, flg)
+ std.slpush(&cmd, flg)
;;
run(cmd)
else
@@ -291,27 +291,27 @@
/* ld -o bin */
for c in config.Linkcmd
- cmd = std.slpush(cmd, std.sldup(c))
+ std.slpush(&cmd, std.sldup(c))
;;
- cmd = std.slpush(cmd, std.sldup(bin))
+ std.slpush(&cmd, std.sldup(bin))
/* [-T script] */
if ldscript.len > 0
-		cmd = std.slpush(cmd, std.sldup("-T"))- cmd = std.slpush(cmd, std.sldup(ldscript))
+		std.slpush(&cmd, std.sldup("-T"))+ std.slpush(&cmd, std.sldup(ldscript))
;;
if rt.len != 0
if !std.sleq(rt, "none")
- cmd = std.slpush(cmd, std.sldup(rt))
+ std.slpush(&cmd, std.sldup(rt))
;;
else
- cmd = std.slpush(cmd, std.sldup(opt_runtime))
+ std.slpush(&cmd, std.sldup(opt_runtime))
;;
/* input.o list.o... */
for f in srcfiles
- cmd = std.slpush(cmd, srcswapsuffix(f, config.Objsuffix))
+ std.slpush(&cmd, srcswapsuffix(f, config.Objsuffix))
;;
/* -L path -l lib... */
@@ -320,16 +320,16 @@
/* add extra libs */
for l in dg.extlibs
-		cmd = std.slpush(cmd, std.fmt("-l{}", l))+		std.slpush(&cmd, std.fmt("-l{}", l));;
/* special for OSX: it warns if we don't add this */
if std.sleq(opt_sys, "osx")
-		cmd = std.slpush(cmd, std.sldup("-macosx_version_min"))-		cmd = std.slpush(cmd, std.sldup("10.6"))+		std.slpush(&cmd, std.sldup("-macosx_version_min"))+		std.slpush(&cmd, std.sldup("10.6"))elif std.sleq(opt_sys, "linux") && dg.dynamic
-		cmd = std.slpush(cmd, std.sldup("-dynamic-linker"))-		cmd = std.slpush(cmd, std.sldup("/lib64/ld-linux-x86-64.so.2"))+		std.slpush(&cmd, std.sldup("-dynamic-linker"))+		std.slpush(&cmd, std.sldup("/lib64/ld-linux-x86-64.so.2"));;
run(cmd)
@@ -342,12 +342,12 @@
cmd = [][:]
for c in config.Arcmd
- cmd = std.slpush(cmd, std.sldup(c))
+ std.slpush(&cmd, std.sldup(c))
;;
-	cmd = std.slpush(cmd, std.fmt("lib{}.a", lib))+	std.slpush(&cmd, std.fmt("lib{}.a", lib))for f in files
obj = srcswapsuffix(f, config.Objsuffix)
- cmd = std.slpush(cmd, obj)
+ std.slpush(&cmd, obj)
;;
run(cmd)
strlistfree(cmd)
@@ -357,18 +357,18 @@
var cmd
cmd = [][:]
- cmd = std.slpush(cmd, std.sldup(opt_muse))
-	cmd = std.slpush(cmd, std.sldup("-o"))- cmd = std.slpush(cmd, std.sldup(lib))
+ std.slpush(&cmd, std.sldup(opt_muse))
+	std.slpush(&cmd, std.sldup("-o"))+ std.slpush(&cmd, std.sldup(lib))
for f in files
if std.hassuffix(f, ".myr")
- cmd = std.slpush(cmd, srcswapsuffix(f, ".use"))
+ std.slpush(&cmd, srcswapsuffix(f, ".use"))
elif !std.hassuffix(f, ".s") && !std.hassuffix(f, ".glue.c")
 			std.fatal("unknown file type for {}\n", f);;
;;
for l in dg.extlibs
-		cmd = std.slpush(cmd, std.fmt("-l{}", l))+		std.slpush(&cmd, std.fmt("-l{}", l));;
run(cmd)
strlistfree(cmd)
@@ -383,7 +383,7 @@
/* -L incpath... */
if !config.Directlib
for inc in incs
-			cmd = std.slpush(cmd, std.fmt("-L{}", inc))+			std.slpush(&cmd, std.fmt("-L{}", inc));;
;;
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -112,7 +112,7 @@
sl = [][:]
for s in srcs
- sl = std.slpush(sl, srcswapsuffix(s, suff))
+ std.slpush(&sl, srcswapsuffix(s, suff))
;;
-> sl
}
@@ -140,7 +140,7 @@
-> void
;;
- ds.depstk = std.slpush(ds.depstk, path)
+ std.slpush(&ds.depstk, path)
if std.htgetv(g.seen, path, false)
 		std.fput(1, "dependency loop involving {}:\n", path)for d in ds.depstk
@@ -234,7 +234,7 @@
| `std.Some m:
flags = std.strtok(m[1])
for fl in flags
- cflags = std.slpush(cflags, std.sldup(fl))
+ std.slpush(&cflags, std.sldup(fl))
;;
std.slfree(flags)
regex.matchfree(m)
@@ -245,7 +245,7 @@
| `std.Some m:
flags = std.strtok(m[1])
for fl in flags
- libs = std.slpush(libs, std.sldup(fl))
+ std.slpush(&libs, std.sldup(fl))
;;
std.slfree(flags)
regex.matchfree(m)
@@ -297,9 +297,9 @@
match regex.exec(usepat, ln)
| `std.Some uses:
if uses[2].len > 0
- deps = std.slpush(deps, `Lib (std.sldup(uses[2]), lnum))
+ std.slpush(&deps, `Lib (std.sldup(uses[2]), lnum))
else
- deps = std.slpush(deps, `Local (std.sldup(uses[3]), lnum))
+ std.slpush(&deps, `Local (std.sldup(uses[3]), lnum))
;;
regex.matchfree(uses)
| `std.None:
@@ -343,10 +343,10 @@
match bio.getc(f)
| `bio.Ok 'L':
d = rdstr(f)
- deps = std.slpush(deps, d)
+ std.slpush(&deps, d)
| `bio.Ok 'X':
d = rdstr(f)
- dg.extlibs = std.slpush(dg.extlibs, d)
+ std.slpush(&dg.extlibs, d)
| `bio.Ok _: done = true
| `bio.Eof: done = true
 		| `bio.Err e:	std.fatal("io error reading {}: {}", lib, e)@@ -389,7 +389,7 @@
 		std.put("{} <= {}\n", dst, src);;
sl = std.htgetv(dg.deps, dst, [][:])
- sl = std.slpush(sl, src)
+ std.slpush(&sl, src)
std.htput(dg.deps, dst, sl)
}
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -58,9 +58,9 @@
 		| ('T', ""):	dumponly = true 		| ('S', ""):	bld.opt_genasm = true 		| ('c', ""):	cleanfirst = true-		| ('I', arg):	bld.opt_incpaths = std.slpush(bld.opt_incpaths, arg)+		| ('I', arg):	std.slpush(&bld.opt_incpaths, arg) 		| ('B', arg):	bld.opt_instbase = arg-		| ('t', tag):	tags = std.slpush(tags, tag)+		| ('t', tag):	std.slpush(&tags, tag) 		| ('R', arg):	runsrc = arg 		| ('b', arg):targname = arg
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -39,7 +39,7 @@
targs = sysselfin(sel)
for (name, targ) in targs
- b.all = std.slpush(b.all, name)
+ std.slpush(&b.all, name)
std.htput(b.targs, name, targ)
;;
@@ -121,7 +121,7 @@
match gettarg(b.targs, dep)
| `Bin _: all = visit(all, b, "all", dep, looped, marked)
| `Lib _: all = visit(all, b, "all", dep, looped, marked)
- | targ: all = std.slpush(all, dep)
+ | targ: std.slpush(&all, dep)
;;
;;
std.slfree(b.all)
@@ -142,7 +142,7 @@
;;
std.htdel(looped, targ)
std.htput(marked, targ, true)
- -> std.slpush(all, targ)
+ -> std.slpush(&all, targ)
}
 const getdeps = {b, parent, targname@@ -280,7 +280,7 @@
subs = anontarget(p, "sub")
for s in subs
- p.subdirs = std.slpush(p.subdirs, std.pathcat(p.fdir, s))
+ std.slpush(&p.subdirs, std.pathcat(p.fdir, s))
;;
}
@@ -334,8 +334,8 @@
 		| ("durable", ""):	durable = true 		| ("test", ""):		istest = true 		| ("notest", ""):	istest = false-		| ("dep", depname):	deplist = std.slpush(deplist, depname)-		| ("tag", tag):	tags = std.slpush(tags, tag)+		| ("dep", depname):	std.slpush(&deplist, depname)+		| ("tag", tag):	std.slpush(&tags, tag)| (attr, ""):
 			failparse(p, "attribute {} not valid on {} targets\n", attr, cmd)| (attr, val):
@@ -415,7 +415,7 @@
ldscript = p.ldscript
incpath = [][:]
for path in p.incpath
- incpath = std.slpush(incpath, path)
+ std.slpush(&incpath, path)
;;
tags = [][:]
for elt in attrs
@@ -422,8 +422,8 @@
match elt
 		| ("ldscript", lds):	ldscript = std.sldup(lds) 		| ("runtime", rt):	runtime = std.sldup(rt)-		| ("inc", path):	incpath = std.slpush(incpath, std.sldup(path))-		| ("tag", tag):		tags = std.slpush(tags, tag)+		| ("inc", path):	std.slpush(&incpath, std.sldup(path))+		| ("tag", tag):		std.slpush(&tags, tag) 		| ("inst", ""):		install = true 		| ("noinst", ""):	install = false 		| ("test", ""):		istest = true@@ -435,7 +435,7 @@
;;
;;
for inc in bld.opt_incpaths
- incpath = std.slpush(incpath, std.sldup(inc))
+ std.slpush(&incpath, std.sldup(inc))
;;
-> std.mk([
/* target */
@@ -492,7 +492,7 @@
tags = [][:]
for elt in attrs
match elt
-		| ("tag", tag):		tags = std.slpush(tags, tag)+		| ("tag", tag):		std.slpush(&tags, tag) 		| ("path", pathdir):	path = pathdir| (invalid, ""):
 			std.fatal("{}: got invalid attr '{}'\n", targ, invalid)@@ -551,12 +551,12 @@
if matchc(p, '=')
match word(p)
| `std.Some v:
- al = std.slpush(al, (k, v))
+ std.slpush(&al, (k, v))
| `std.None:
failparse(p, "invalid attr in attribute list\n")
;;
else
- al = std.slpush(al, (k, [][:]))
+ std.slpush(&al, (k, [][:]))
;;
if !matchc(p, ',')
break
@@ -593,11 +593,11 @@
match word(p)
| `std.Some l:
(dir, lib, targ) = libpath(p, l)
- libs = std.slpush(libs, (dir, lib, targ))
+ std.slpush(&libs, (dir, lib, targ))
| `std.None:
failparse(p, "expected lib name after 'lib'\n")
;;
- | `std.Some w: wl = std.slpush(wl, w)
+ | `std.Some w: std.slpush(&wl, w)
| `std.None: break
;;
;;
@@ -615,7 +615,7 @@
wl = [][:]
while true
match word(p)
- | `std.Some w: wl = std.slpush(wl, w)
+ | `std.Some w: std.slpush(&wl, w)
| `std.None: break
;;
;;
--- a/mbld/syssel.myr
+++ b/mbld/syssel.myr
@@ -88,7 +88,7 @@
if nmatch == -1
 			std.fatal("{}:{}: target {}, no applicable file for '{}'\n", syssel.file, syssel.line, syssel.targ, k);;
- ret = std.slpush(ret, std.get(std.htget(syssel._best, k)))
+ std.slpush(&ret, std.get(std.htget(syssel._best, k)))
;;
std.htfree(syssel._match)
std.htfree(syssel._best)
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -41,12 +41,12 @@
;;
buildbin(b, t, false)
 			bincmd = std.sldup([std.strcat("./", t.name)][:])- tests = std.slpush(tests, (bincmd, std.sldup(t.dir)))
+ std.slpush(&tests, (bincmd, std.sldup(t.dir)))
| `Cmd t:
if !t.istest
continue
;;
- tests = std.slpush(tests, (dupcmd(t.cmd), std.sldup(t.dir)))
+ std.slpush(&tests, (dupcmd(t.cmd), std.sldup(t.dir)))
| _:
/* skip */
;;
@@ -59,7 +59,7 @@
if !runtest(b, c)
ok = false
p = std.pathcat(b.curdir, c[0])
- failed = std.slpush(failed, p)
+ std.slpush(&failed, p)
;;
;;
@@ -101,7 +101,7 @@
ret = [][:]
for c in cmd
- ret = std.slpush(ret, std.sldup(c))
+ std.slpush(&ret, std.sldup(c))
;;
-> ret
}
@@ -135,7 +135,7 @@
buildbin(b, &tt, true)
 			cmd = std.sldup([std.strcat("./", bin)][:])- tests = std.slpush(tests, (cmd, std.sldup(targ.dir)))
+ std.slpush(&tests, (cmd, std.sldup(targ.dir)))
std.slfree(tt.libdeps)
std.slfree(tt.incpath)
std.slfree(path)
--
⑨