summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-05-04 10:02:28 -0700
committerOri Bernstein <ori@eigenstate.org>2015-05-04 10:02:28 -0700
commitd621aba39611ad76a69efff7d7628d56894b0d9d (patch)
treee667a6464adac6adc86792ffbe063e5ea078d6ef
parent4926b4adbe014b44c483c8f65daf6fe6f914de44 (diff)
downloadmc-d621aba39611ad76a69efff7d7628d56894b0d9d.tar.gz
Make fsel code more generic.
-rw-r--r--mbld/fsel.myr32
-rw-r--r--mbld/main.myr5
-rw-r--r--mbld/parse.myr17
-rw-r--r--mbld/types.myr2
-rw-r--r--parse/stab.c3
5 files changed, 33 insertions, 26 deletions
diff --git a/mbld/fsel.myr b/mbld/fsel.myr
index ea45b4f..bdd0103 100644
--- a/mbld/fsel.myr
+++ b/mbld/fsel.myr
@@ -3,23 +3,23 @@ use std
use "opts.use"
pkg bld =
- type fsel = struct
- filematch : std.htab(byte[:], int)#
- filebest : std.htab(byte[:], byte[:])#
+ type syssel(@a) = struct
sysattrs : std.htab(byte[:], bool)#
+ _match : std.htab(byte[:], int)#
+ _best : std.htab(byte[:], @a)#
;;
- const mkfsel : (-> fsel#)
- const fseladd : (fsel : fsel#, file : byte[:] -> void)
- const fselfin : (fsel : fsel# -> byte[:][:])
+ const mkfsel : (-> syssel(byte[:])#)
+ const fseladd : (fsel : syssel(byte[:])#, file : byte[:] -> void)
+ const fselfin : (fsel : syssel(byte[:])# -> byte[:][:])
;;
const mkfsel = {
var fsel
fsel = std.alloc()
- fsel.filematch = std.mkht(std.strhash, std.streq)
- fsel.filebest = std.mkht(std.strhash, std.streq)
+ fsel._match = std.mkht(std.strhash, std.streq)
+ fsel._best = std.mkht(std.strhash, std.streq)
fsel.sysattrs = std.mkht(std.strhash, std.streq)
addsysattrs(fsel.sysattrs)
-> fsel
@@ -57,27 +57,27 @@ const fseladd = {fsel, f
;;
;;
std.slfree(attrlist)
- curbest = std.htgetv(fsel.filematch, basename, -1)
+ curbest = std.htgetv(fsel._match, basename, -1)
if curbest < nmatch
- std.htput(fsel.filematch, basename, nmatch)
- std.htput(fsel.filebest, basename, f)
+ std.htput(fsel._match, basename, nmatch)
+ std.htput(fsel._best, basename, f)
;;
}
const fselfin = {fsel
var keys, nmatch, ret
- keys = std.htkeys(fsel.filematch)
+ keys = std.htkeys(fsel._match)
ret = [][:]
for k in keys
- nmatch = std.htgetv(fsel.filematch, k, -1)
+ nmatch = std.htgetv(fsel._match, k, -1)
if nmatch == -1
std.fatal(1, "no applicable file for '%s'\n", k)
;;
- ret = std.slpush(ret, std.htgetv(fsel.filebest, k, ""))
+ ret = std.slpush(ret, std.htgetv(fsel._best, k, ""))
;;
- std.htfree(fsel.filematch)
- std.htfree(fsel.filebest)
+ std.htfree(fsel._match)
+ std.htfree(fsel._best)
std.htfree(fsel.sysattrs)
-> ret
}
diff --git a/mbld/main.myr b/mbld/main.myr
index 9a215d1..b553035 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -26,6 +26,9 @@ const main = {args : byte[:][:]
.argdesc = "[inputs...]",
.opts = [
[.opt='t', .desc="list all available targets"],
+ [.opt='S', .desc="generate assembly when building"],
+ [.opt='d', .desc="dump debugging information for mbld"],
+
[.opt='I', .arg="inc", .desc="add 'inc' to your include path"],
[.opt='R', .arg="root", .desc="install into 'root'"],
[.opt='b', .arg="bin", .desc="compile binary named 'bin' from inputs"],
@@ -33,8 +36,6 @@ const main = {args : byte[:][:]
[.opt='r', .arg="rt", .desc="link against runtime 'rt' instead of default"],
[.opt='C', .arg="mc", .desc="compile with 'mc' instead of the default compiler"],
[.opt='M', .arg="mu", .desc="merge uses with 'mu' instead of the default muse"],
- [.opt='S', .desc="generate assembly when building"],
- [.opt='d', .desc="dump debugging information for mbld"],
][:]
])
bld.initopts()
diff --git a/mbld/parse.myr b/mbld/parse.myr
index 5877f2e..7bd10d7 100644
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -224,7 +224,7 @@ const subtarget = {b, p
/* gentarget: wordlist {attrs} = wordlist ;; */
const cmdtarget = {b, p, cmd, iscmd
- var outlist, deplist, cmdlist
+ var outlist, deplist, cmdlist, systags
var durable
var attrs
var gt
@@ -268,9 +268,12 @@ const cmdtarget = {b, p, cmd, iscmd
for elt in attrs
match elt
| ("durable", ""): durable = true
- | ("durable", val): failparse(p, "durable attr does not take argument\n")
| ("dep", depname): deplist = std.slpush(deplist, depname)
- | (attrname, val): failparse(p, "attribute %s not valid on %s targets\n", attrname, cmd)
+ | ("sys", tags): systags = std.slpush(systags, tags)
+ | (attr, ""):
+ failparse(p, "attribute %s not valid on %s targets\n", attr, cmd)
+ | (attr, val):
+ failparse(p, "attribute %s=%s not valid on %s targets\n", attr, val, cmd)
;;
;;
@@ -279,7 +282,8 @@ const cmdtarget = {b, p, cmd, iscmd
.out=outlist,
.durable=durable,
.deps=deplist,
- .cmd=cmdlist
+ .cmd=cmdlist,
+ .systags=systags,
])
for o in outlist
if iscmd
@@ -296,7 +300,7 @@ myrtarget: name '=' inputlist ';;'
| name attrlist = inputlist ';;'
*/
const myrtarget = {p, targ
- var ldscript, runtime, inst, incpath
+ var ldscript, runtime, inst, incpath, systags
var name, inputs, libdeps, attrs
var fsel
@@ -347,7 +351,7 @@ const myrtarget = {p, targ
| ("runtime", rt): runtime = std.sldup(rt)
| ("inc", path): incpath = std.slpush(incpath, std.sldup(path))
| ("noinst", ""): inst = false
- | ("noinst", val): failparse(p, "noinst attr does not take argument\n")
+ | ("sys", tags): systags = std.slpush(systags, tags)
| (invalid, _):
std.fatal(1, "%s: got invalid attr '%s'\n", targ, invalid)
;;
@@ -363,6 +367,7 @@ const myrtarget = {p, targ
.libdeps=libdeps,
.islib=false,
/* attrs */
+ .systags=systags,
.install=inst,
.ldscript=ldscript,
.runtime=runtime,
diff --git a/mbld/types.myr b/mbld/types.myr
index dbe4689..cdc80d6 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -36,6 +36,7 @@ pkg bld =
install : bool
runtime : byte[:]
incpath : byte[:][:]
+ systags : byte[:][:]
ldscript : byte[:]
;;
@@ -44,6 +45,7 @@ pkg bld =
out : byte[:][:]
cmd : byte[:][:]
deps : byte[:][:]
+ systags : byte[:][:]
durable : bool
/* we can have multiple outputs, but we only want to run once for each */
done : bool
diff --git a/parse/stab.c b/parse/stab.c
index ca68d63..3aea2af 100644
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -304,7 +304,6 @@ void puttype(Stab *st, Node *n, Type *t)
Tydefn *td;
Type *ty;
- assert(t != NULL);
if (st->name)
setns(n, st->name);
if (st->name && t && t->name)
@@ -312,7 +311,7 @@ void puttype(Stab *st, Node *n, Type *t)
ty = gettype(st, n);
if (!ty) {
- if (hastype(st, n)) {
+ if (t && hastype(st, n)) {
t->vis = Visexport;
updatetype(st, n, t);
} else {