aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.js
blob: b4e9530a833353b50fcd2a8bd0bbd4d5a51051f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// 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, can be overridden by commandline

load('settings.js');

var settings = JSON.parse(readline());
for (setting in settings) {
  this[setting] = settings[setting];
}
var CONSTANTS = { 'QUANTUM_SIZE': QUANTUM_SIZE };

// Load compiler code

load('utility.js');
load('framework.js');
load('parseTools.js');
load('intertyper.js');
load('analyzer.js');
load('jsifier.js');
load('runtime.js');

//===============================
// Main
//===============================

// Read llvm

var lines = [];
var line;
do {
  line = readline();
  if (line == null) break;
  lines.push(line);
} while(true);

// Do it

print(JSify(analyzer(intertyper(lines))));