ref: 9220a5e91430f73453e50cc48ffee026587e0e53
parent: 4cbf921e4eb323a3c8817e1471632fd25021a2a1
author: Ori Bernstein <[email protected]>
date: Thu Jun 7 13:53:43 EDT 2012
Add in stub for muse.
--- a/8/reduce.c
+++ b/8/reduce.c
@@ -382,10 +382,10 @@
r = mkexpr(-1, Olit, mkint(-1, size(args[0])), NULL);
break;
case Oslice:
- args[1] = rval(s, args[1]);
- args[2] = rval(s, args[2]);
- t = mkexpr(-1, Osub, args[2], args[1], NULL);
- args[0] = slicebase(s, args[0], t);
+ /* normalize to '(base + off)[0,len]' */
+ args[0] = slicebase(s, args[0], args[1]);
+ args[2] = mkexpr(-1, Osub, args[2], args[1], NULL);
+ args[1] = mkexpr(-1, Olit, mkint(-1, 0), NULL);
r = n;
break;
case Oidx:
--- /dev/null
+++ b/muse/Makefile
@@ -1,0 +1,8 @@
+BIN=muse
+OBJ=main.o
+
+CFLAGS+=-I../parse
+LDFLAGS+=-L../parse -lparse
+EXTRADEP=../parse/libparse.a
+
+include ../mk/c.mk
--- /dev/null
+++ b/muse/main.c
@@ -1,0 +1,66 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "parse.h"
+
+Node *file;
+static char *outfile;
+int debug;
+
+static void usage(char *prog)
+{
+ printf("%s [-h] [-o outfile] inputs\n", prog);
+ printf("\t-h\tPrint this help\n");
+ printf("\t-d\tPrint debug dumps\n");
+ printf("\t-o\tOutput to outfile\n");
+}
+
+int main(int argc, char **argv)
+{
+ int opt;
+ int i;
+ Stab *globls;
+
+ while ((opt = getopt(argc, argv, "dho:")) != -1) {
+ switch (opt) {
+ case 'o':
+ outfile = optarg;
+ break;
+ case 'h':
+ case 'd':
+ debug++;
+ break;
+ default:
+ usage(argv[0]);
+ exit(0);
+ break;
+ }
+ }
+
+ for (i = optind; i < argc; i++) {
+ globls = mkstab();
+ tyinit(globls);
+ tokinit(argv[i]);
+ file = mkfile(argv[i]);
+ file->file.exports = mkstab();
+ file->file.globls = globls;
+ yyparse();
+
+ if (debug) {
+ /* before we do anything to the parse */
+ dump(file, stdout);
+ }
+ infer(file);
+ die("FIXME: IMPLEMENT ME!");
+ }
+
+ return 0;
+}