comparison compiler.js @ 207:60eff5f81d9a

Basic implementation of macros is now working
author Mike Pavone <pavone@retrodev.com>
date Tue, 19 Nov 2013 22:02:11 -0800
parents d2e0664ba73e
children 2557ce4e671f
comparison
equal deleted inserted replaced
206:b4a9d4e405c5 207:60eff5f81d9a
11 this.file = file; 11 this.file = file;
12 } 12 }
13 13
14 modulefile.prototype.populateSymbols = function (toplevel) { 14 modulefile.prototype.populateSymbols = function (toplevel) {
15 if (!this.ast) { 15 if (!this.ast) {
16 this.ast = parseFile(this.path + '/' + this.file); 16 this.ast = parseFile(this.path + '/' + this.file).macroexpand(new topenv(toplevel.moduledirs));
17 this.ast.populateSymbols(toplevel); 17 this.ast.populateSymbols(toplevel);
18 } 18 }
19 }; 19 };
20 20
21 modulefile.prototype.popuplateSymbolsAsync = function(toplevel, whenDone) { 21 modulefile.prototype.popuplateSymbolsAsync = function(toplevel, whenDone) {
22 if (!this.ast) { 22 if (!this.ast) {
23 var self = this; 23 var self = this;
24 get(this.path + '/' + this.file, function(data) { 24 get(this.path + '/' + this.file, function(data) {
25 //TODO: macro expand in the async case
25 self.ast = parser.parse(data.responseText); 26 self.ast = parser.parse(data.responseText);
26 self.ast.populateSymbols(toplevel); 27 self.ast.populateSymbols(toplevel);
27 whenDone(); 28 whenDone();
28 }); 29 });
29 } else { 30 } else {
46 } 47 }
47 48
48 var toplevel = new topsymbols([]); 49 var toplevel = new topsymbols([]);
49 function topsymbols(moduledirs) 50 function topsymbols(moduledirs)
50 { 51 {
52 this.moduledirs = moduledirs;
51 this.names = null; 53 this.names = null;
52 this.used = {}; 54 this.used = {};
53 this.nextmodulenum = 0; 55 this.nextmodulenum = 0;
54 this.onready = null; 56 this.onready = null;
55 var self = this; 57 var self = this;