shithub: mc

Download patch

ref: c80d62a29435e75e476a93f0d7da3deb20e1204a
parent: f9f93d1e447873ca3e5fa6c542eb34e8dd8d4b71
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Apr 7 21:17:34 EDT 2018

Add support for `-T` option to compile in test mode.

	Tests can now access hidden declarations.

--- a/6/main.c
+++ b/6/main.c
@@ -41,6 +41,7 @@
 	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 @@
 
 	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)) {
@@ -239,6 +240,9 @@
 			break;
 		case 'I':
 			lappend(&incpaths, &nincpaths, ctx.optarg);
+			break;
+		case 'T':
+			allowhidden++;
 			break;
 		default:
 			usage(argv[0]);
--- a/doc/6m.1
+++ b/doc/6m.1
@@ -65,6 +65,15 @@
 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.
 
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -483,6 +483,7 @@
 		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))
 		;;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -29,6 +29,7 @@
 	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 size_t nspecializationscope;
 static Traitmap *traitmap;
 
+
 static void
 ctxstrcall(char *buf, size_t sz, Node *n)
 {
@@ -1320,7 +1322,7 @@
 	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;
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -377,6 +377,7 @@
 extern size_t ndecls;
 extern Node **exportimpls;
 extern size_t nexportimpls;
+extern int allowhidden;
 
 /* property tables */
 extern int opispure[];