summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-04-08 01:17:34 -0700
committerOri Bernstein <ori@eigenstate.org>2018-04-08 01:17:34 -0700
commitc80d62a29435e75e476a93f0d7da3deb20e1204a (patch)
tree821f070f49620700c376360351708eaebadfd366
parentf9f93d1e447873ca3e5fa6c542eb34e8dd8d4b71 (diff)
downloadmc-c80d62a29435e75e476a93f0d7da3deb20e1204a.tar.gz
Add support for `-T` option to compile in test mode.
Tests can now access hidden declarations.
-rw-r--r--6/main.c6
-rw-r--r--doc/6m.19
-rw-r--r--mbld/deps.myr1
-rw-r--r--parse/infer.c4
-rw-r--r--parse/parse.h1
5 files changed, 19 insertions, 2 deletions
diff --git a/6/main.c b/6/main.c
index a153b8b..b770222 100644
--- a/6/main.c
+++ b/6/main.c
@@ -41,6 +41,7 @@ usage(char *prog)
printf("\t-o\tOutput to outfile\n");
printf("\t-O dir\tOutput to dir\n");
printf("\t-S\tGenerate assembly source alongside object code\n");
+ printf("\t-T\tCompile in test mode\n");
printf("\t-c\tEnable additional (possibly flaky) checking\n");
printf("\t-I path\tAdd 'path' to use search path\n");
printf("\t-d\tPrint debug dumps. Recognized options: f r p i\n");
@@ -200,7 +201,7 @@ main(int argc, char **argv)
outfile = NULL;
- optinit(&ctx, "cd:?hSo:I:9G:O:", argv, argc);
+ optinit(&ctx, "cd:?hSo:I:9G:O:T", argv, argc);
asmsyntax = Defaultasm;
sizefn = size;
while (!optdone(&ctx)) {
@@ -240,6 +241,9 @@ main(int argc, char **argv)
case 'I':
lappend(&incpaths, &nincpaths, ctx.optarg);
break;
+ case 'T':
+ allowhidden++;
+ break;
default:
usage(argv[0]);
exit(0);
diff --git a/doc/6m.1 b/doc/6m.1
index f04090c..5605d84 100644
--- a/doc/6m.1
+++ b/doc/6m.1
@@ -65,6 +65,15 @@ Generate assembly code along with the object file.
Generate assembly in the Gnu As syntax.
.TP
+.B -O out
+Output code to output path 'out'
+
+.TP
+.B -T
+Compile in test mode. This implies that pkglocal functions are
+available.
+
+.TP
.B -9
Generate assembly in the Plan 9 syntax.
diff --git a/mbld/deps.myr b/mbld/deps.myr
index 71dae29..53b5a8f 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -483,6 +483,7 @@ const myrcmd = {b, n, mt, src, istest
pushopt(&n.cmd, "-I", inc)
;;
if istest
+ std.slpush(&n.cmd, "-T")
for (dir, _, _) : mt.tstdeps
pushopt(&n.cmd, "-I", std.pathcat(opt_objdir, dir))
;;
diff --git a/parse/infer.c b/parse/infer.c
index e0ca86e..2e99e40 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -29,6 +29,7 @@ struct Traitmap {
size_t nfiltertr;
};
+int allowhidden;
static void infernode(Node **np, Type *ret, int *sawret);
static void inferexpr(Node **np, Type *ret, int *sawret);
@@ -70,6 +71,7 @@ static Stab **specializationscope;
static size_t nspecializationscope;
static Traitmap *traitmap;
+
static void
ctxstrcall(char *buf, size_t sz, Node *n)
{
@@ -1320,7 +1322,7 @@ initvar(Node *n, Node *s)
Type *t, *param;
Tysubst *subst;
- if (s->decl.ishidden)
+ if (s->decl.ishidden && !allowhidden)
fatal(n, "attempting to refer to hidden decl %s", ctxstr(n));
param = n->expr.param;
diff --git a/parse/parse.h b/parse/parse.h
index 52946a9..61cff0e 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -377,6 +377,7 @@ extern Node **nodes; /* node id -> node map */
extern size_t ndecls;
extern Node **exportimpls;
extern size_t nexportimpls;
+extern int allowhidden;
/* property tables */
extern int opispure[];