annotate tpc.js @ 377:93c28eee141e default tip

Merge
author Michael Pavone <pavone@retrodev.com>
date Sat, 15 Aug 2015 22:45:33 -0700
parents 2557ce4e671f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
3b0503a67165 Add scripts for building programs via C using d8 rather than a browser
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 var module = {exports: {}};
128
5e34563f90ae Get javascript backend working from the command line compiler again
Mike Pavone <pavone@retrodev.com>
parents: 95
diff changeset
2 var console = {log: function(text){}};
36
3b0503a67165 Add scripts for building programs via C using d8 rather than a browser
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 var PEG;
3b0503a67165 Add scripts for building programs via C using d8 rather than a browser
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
5 var file = null;
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
6 var argtype = 'normal';
66
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
7 var includes = ['.'];
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
8 var basedir = '';
54
976a0924e1d4 Fix closure over self var
Mike Pavone <pavone@retrodev.com>
parents: 50
diff changeset
9 var debugmode = false;
90
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
10 var backend = 'C';
216
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
11 var macroonly = false;
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
12 for (var i = 0; i < arguments.length; i++) {
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
13 switch (argtype) {
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
14 case 'normal':
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
15 switch (arguments[i]) {
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
16 case '-basedir':
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
17 case '-i':
90
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
18 case '-backend':
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
19 argtype = arguments[i];
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
20 break;
54
976a0924e1d4 Fix closure over self var
Mike Pavone <pavone@retrodev.com>
parents: 50
diff changeset
21 case '-compilerdebug':
976a0924e1d4 Fix closure over self var
Mike Pavone <pavone@retrodev.com>
parents: 50
diff changeset
22 debugmode = true;
976a0924e1d4 Fix closure over self var
Mike Pavone <pavone@retrodev.com>
parents: 50
diff changeset
23 break;
216
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
24 case '-m':
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
25 macroonly = true;
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
26 break;
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
27 default:
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
28 if (arguments[i].charAt(0) == '-') {
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
29 print("unrecognized switch", arguments[i]);
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
30 quit(1);
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
31 }
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
32 file = arguments[i];
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
33 }
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
34 break;
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
35 case '-basedir':
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
36 if (basedir == '') {
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
37 basedir = arguments[i];
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
38 argtype = 'normal';
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
39 } else {
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
40 print("only one -basedir option allowed");
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
41 quit(1);
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
42 }
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
43 break;
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
44 case '-i':
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
45 includes.push(arguments[i]);
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
46 argtype = 'normal';
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
47 break;
90
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
48 case '-backend':
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
49 backend = arguments[i];
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
50 argtype = 'normal';
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
51 break;
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
52 }
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
53 }
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
54 if (argtype != 'normal') {
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
55 print("switch", argtype, "expects a parameter");
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
56 quit(1);
36
3b0503a67165 Add scripts for building programs via C using d8 rather than a browser
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 }
3b0503a67165 Add scripts for building programs via C using d8 rather than a browser
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
59 if (!file) {
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
60 print('usage: d8 tpc.js -- filename');
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
61 quit(1);
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
62 }
68
3a169ebb3224 Change strategy for handling true and false to avoid some initialization order problems and improve performance. Add support for negative integer literals. Update samples to reflect true/false change.
Mike Pavone <pavone@retrodev.com>
parents: 66
diff changeset
63 includes.push(basedir + 'modules');
90
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
64 compileFile(file, basedir, includes, debugmode, backend);
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
65
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
66
66
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
67 function parseFile(filename)
36
3b0503a67165 Add scripts for building programs via C using d8 rather than a browser
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
68 {
68
3a169ebb3224 Change strategy for handling true and false to avoid some initialization order problems and improve performance. Add support for negative integer literals. Update samples to reflect true/false change.
Mike Pavone <pavone@retrodev.com>
parents: 66
diff changeset
69 debugprint('//parsing', filename);
36
3b0503a67165 Add scripts for building programs via C using d8 rather than a browser
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70 var text = read(filename);
43
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents: 36
diff changeset
71 try {
128
5e34563f90ae Get javascript backend working from the command line compiler again
Mike Pavone <pavone@retrodev.com>
parents: 95
diff changeset
72 var parsed = parser.parse(text);
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
73 } catch (error) {
44
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
74 print('SyntaxError on at', error.line, ',', error.column, ':', error.message);
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
75 var lines = text.split('\n');
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
76 print(lines[error.line-1]);
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
77 var spacer = '';
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
78 for (var i = 1; i < error.column; i++) {
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
79 if (lines[error.line-1].charAt(i-1) == '\t') {
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
80 spacer += ' ';
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
81 } else {
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
82 spacer += ' ';
43
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents: 36
diff changeset
83 }
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents: 36
diff changeset
84 }
44
9dd370530f69 Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
85 print(spacer + '^');
50
3e8d2a91102c Improve tpc.js compiler driver with some nice swithc handling and fix a small bug in syntax error reporting.
Mike Pavone <pavone@retrodev.com>
parents: 45
diff changeset
86 quit(1);
43
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents: 36
diff changeset
87 }
66
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
88 return parsed;
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
89 }
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
90
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
91
90
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
92 function compileFile(filename, basedir, includes, debugmode, backend)
66
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
93 {
128
5e34563f90ae Get javascript backend working from the command line compiler again
Mike Pavone <pavone@retrodev.com>
parents: 95
diff changeset
94 load(basedir + 'mquery.js');
66
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
95 load(basedir + 'peg.js');
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
96 PEG = module.exports;
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
97 load(basedir + 'parser.js');
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
98 load(basedir + 'compiler.js');
207
60eff5f81d9a Basic implementation of macros is now working
Mike Pavone <pavone@retrodev.com>
parents: 205
diff changeset
99 load(basedir + 'interp.js');
90
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
100 if (backend == 'C') {
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
101 load(basedir + 'cbackend.js');
205
6fe9343b1400 Some minor work on creating an IL backend based on the C backend
Mike Pavone <pavone@retrodev.com>
parents: 128
diff changeset
102 } else if (backend == 'IL') {
6fe9343b1400 Some minor work on creating an IL backend based on the C backend
Mike Pavone <pavone@retrodev.com>
parents: 128
diff changeset
103 load(basedir + 'ilbackend.js');
90
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
104 } else {
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
105 load(basedir + 'jsbackend.js');
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
106 }
128
5e34563f90ae Get javascript backend working from the command line compiler again
Mike Pavone <pavone@retrodev.com>
parents: 95
diff changeset
107
66
25b697c91629 Finish implementation of external module access
Mike Pavone <pavone@retrodev.com>
parents: 54
diff changeset
108 var parsed = parseFile(filename);
54
976a0924e1d4 Fix closure over self var
Mike Pavone <pavone@retrodev.com>
parents: 50
diff changeset
109 if (debugmode) {
976a0924e1d4 Fix closure over self var
Mike Pavone <pavone@retrodev.com>
parents: 50
diff changeset
110 debugprint = print;
976a0924e1d4 Fix closure over self var
Mike Pavone <pavone@retrodev.com>
parents: 50
diff changeset
111 }
251
2557ce4e671f Fix a couple of compiler bugs. topenv was getting initialized in multiple places. This resulted in multiple copies of modules getting created which caused problems for macro expansion. Additionally, arguments were not being marked as declared during code generation so assigning to an argument that was not closed over generated invalid C code.
Michael Pavone <pavone@retrodev.com>
parents: 216
diff changeset
112 var top = new topenv(includes);
2557ce4e671f Fix a couple of compiler bugs. topenv was getting initialized in multiple places. This resulted in multiple copies of modules getting created which caused problems for macro expansion. Additionally, arguments were not being marked as declared during code generation so assigning to an argument that was not closed over generated invalid C code.
Michael Pavone <pavone@retrodev.com>
parents: 216
diff changeset
113 parsed = parsed.macroexpand(top);
216
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
114 if (macroonly) {
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
115 print(''+parsed);
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
116 } else {
251
2557ce4e671f Fix a couple of compiler bugs. topenv was getting initialized in multiple places. This resulted in multiple copies of modules getting created which caused problems for macro expansion. Additionally, arguments were not being marked as declared during code generation so assigning to an argument that was not closed over generated invalid C code.
Michael Pavone <pavone@retrodev.com>
parents: 216
diff changeset
117 toplevel = new topsymbols(includes, top);
216
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
118 switch(backend)
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
119 {
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
120 case 'C':
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
121 var c = parsed.toCModule();
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
122 break;
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
123 case 'IL':
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
124 var c = parsed.toILModule();
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
125 case 'JS':
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
126 var c = makeJSProg(parsed);
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
127 break;
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
128 default:
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
129 print('Backend', backend, ' not recognized');
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
130 quit(1);
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
131 }
2dac67e9d18b Add -m flag to compiler driver to select macro expansion only
Michael Pavone <pavone@retrodev.com>
parents: 207
diff changeset
132 print(c);
90
b5152f5ac138 Add backend selection to tpc.js compiler driver
Mike Pavone <pavone@retrodev.com>
parents: 68
diff changeset
133 }
36
3b0503a67165 Add scripts for building programs via C using d8 rather than a browser
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
134 }