comparison compiler.js @ 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.
author Michael Pavone <pavone@retrodev.com>
date Fri, 11 Apr 2014 22:29:32 -0700
parents 60eff5f81d9a
children d6a4c9e7716e
comparison
equal deleted inserted replaced
250:c58e17f5c0f6 251:2557ce4e671f
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).macroexpand(new topenv(toplevel.moduledirs)); 16 this.ast = parseFile(this.path + '/' + this.file).macroexpand(toplevel.topenv);
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) {
44 names[modname] = new modulefile(path, modname + '.tp'); 44 names[modname] = new modulefile(path, modname + '.tp');
45 } 45 }
46 }); 46 });
47 } 47 }
48 48
49 var toplevel = new topsymbols([]); 49 var toplevel = null;//new topsymbols([]);
50 function topsymbols(moduledirs) 50 function topsymbols(moduledirs, top)
51 { 51 {
52 this.moduledirs = moduledirs; 52 if (!top) {
53 top = new topenv(moduledirs);
54 }
55 this.topenv = top;
56 this.moduledirs = moduledirs;
53 this.names = null; 57 this.names = null;
54 this.used = {}; 58 this.used = {};
55 this.nextmodulenum = 0; 59 this.nextmodulenum = 0;
56 this.onready = null; 60 this.onready = null;
57 var self = this; 61 var self = this;