aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.js')
-rw-r--r--src/compiler.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/compiler.js b/src/compiler.js
new file mode 100644
index 00000000..6f514f89
--- /dev/null
+++ b/src/compiler.js
@@ -0,0 +1,44 @@
+// LLVM => JavaScript compiler, main entry point
+
+// Prep - allow this to run in both SpiderMonkey and V8
+if (!this['load']) {
+ load = function(f) { eval(snarf(f)) }
+}
+if (!this['read']) {
+ read = function(f) { snarf(f) }
+}
+
+load('settings.js');
+if (LABEL_DEBUG && RELOOP) throw "Cannot debug labels if they have been relooped!";
+
+load('utility.js');
+load('enzymatic.js');
+load('snippets.js');
+load('parseTools.js');
+load('intertyper.js');
+load('analyzer.js');
+load('jsifier.js');
+
+//===============================
+// Main
+//===============================
+
+// Override settings.js
+var settings = JSON.parse(readline());
+for (setting in settings) {
+ this[setting] = settings[setting];
+}
+
+// Read llvm
+var lines = [];
+var line;
+do {
+ line = readline();
+ if (line == null) break;
+ lines.push(line);
+} while(true);
+var data = lines.join("\n");
+
+// Do it
+print(JSify(analyzer(intertyper(data))));
+