comparison compiler.js @ 24:fe3533494ce9

Display symbols order first by depth. Eliminate extraneous setter symbols
author Mike Pavone <pavone@retrodev.com>
date Tue, 27 Mar 2012 00:39:32 -0700
parents 068d63627b16
children 4d87c38404d6
comparison
equal deleted inserted replaced
23:068d63627b16 24:fe3533494ce9
43 if (!this.parent) { 43 if (!this.parent) {
44 return 'null'; 44 return 'null';
45 } 45 }
46 return 'this'; 46 return 'this';
47 } 47 }
48 osymbols.prototype.allSymbols = function() { 48 osymbols.prototype.allSymbols = function(curlist, cursyms) {
49 var start = this.parent ? this.parent.allSymbols() : {}; 49 if (curlist === undefined) {
50 for (var key in this.names) { 50 curlist = [];
51 start[key] = this.names[key]; 51 cursyms = {};
52 } 52 }
53 return start; 53 var keys = Object.keys(this.names).sort();
54 for (var i in keys) {
55 if (!(keys[i] in cursyms)) {
56 curlist.push(keys[i]);
57 cursyms[keys[i]] = true;
58 }
59 }
60 if (this.parent) {
61 return this.parent.allSymbols(curlist, cursyms);
62 }
63 return curlist;
54 } 64 }
55 65
56 function lsymbols(parent) 66 function lsymbols(parent)
57 { 67 {
58 this.parent = parent; 68 this.parent = parent;
200 this.symbol.populateSymbols(symbols); 210 this.symbol.populateSymbols(symbols);
201 this.expression.populateSymbols(symbols); 211 this.expression.populateSymbols(symbols);
202 this.symbols = symbols; 212 this.symbols = symbols;
203 }; 213 };
204 assignment.prototype.populateSymbolsObject = function(symbols) { 214 assignment.prototype.populateSymbolsObject = function(symbols) {
205 console.log('populateSymbolsObject for assignment to ' + this.symbol.name)
206 symbols.defineMsg(this.symbol.name, this.expression); 215 symbols.defineMsg(this.symbol.name, this.expression);
207 if (!(this.expression instanceof lambda)) { 216 if (!(this.expression instanceof lambda) && !(this.expression instanceof funcall && this.expression.name == 'foreign:')) {
208 symbols.defineMsg(this.symbol.name + '!', new setter(null)); 217 symbols.defineMsg(this.symbol.name + '!', new setter(null));
209 } 218 }
210 this.symbol.populateSymbols(symbols); 219 this.symbol.populateSymbols(symbols);
211 this.expression.populateSymbols(symbols); 220 this.expression.populateSymbols(symbols);
212 this.symbols = symbols; 221 this.symbols = symbols;