aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.js
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-20 18:59:15 -0700
committeralon@honor <none@none>2010-09-20 18:59:15 -0700
commitfea809cb090c648f58f11561f7f25ce813d9944f (patch)
tree355bc25d3bab157799caf339f6917683aca9ac41 /src/compiler.js
parent9e66429fa4154058798be6cc554408697cc6bfc8 (diff)
refactor into files
--HG-- rename : src/parser.js => src/compiler.js
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))));
+