# HG changeset patch # User Mike Pavone # Date 1377664689 25200 # Node ID 228df5004ab56160f44fa6edfe5b48ad13619f86 # Parent 7856f09165495284955ac97df22bc954a36383db Define methods in an object before running populate symbols on those methods to avoid a bug in which self was not properly marked as closed over due to a method not being defined when a symbol search was done diff -r 7856f0916549 -r 228df5004ab5 compiler.js --- a/compiler.js Mon Aug 26 21:04:44 2013 -0700 +++ b/compiler.js Tue Aug 27 21:38:09 2013 -0700 @@ -229,7 +229,8 @@ def: this.names[name] }; } else { - if (nestedcall) { + if (nestedcall && !(name in this.closedover)) { + debugprint('//symbol', name, 'is now closed over'); this.closedover[name] = true; this.passthruenv = false; } @@ -414,6 +415,9 @@ } } +funcall.prototype.defineSymbolsObject = function(symbols) { +} + funcall.prototype.populateSymbolsObject = function(symbols) { this.populateSymbols(symbols); } @@ -421,6 +425,9 @@ object.prototype.populateSymbols = function(symbols) { var symbols = new osymbols(symbols); for (var i in this.messages) { + this.messages[i].defineSymbolsObject(symbols); + } + for (var i in this.messages) { this.messages[i].populateSymbolsObject(symbols); } this.symbols = symbols; @@ -456,7 +463,7 @@ this.expression.populateSymbols(symbols); this.symbols = symbols; }; -assignment.prototype.populateSymbolsObject = function(symbols) { +assignment.prototype.defineSymbolsObject = function(symbols) { debugprint('//messagedef', this.symbol.name, 'populateSymbols'); if (this.expression instanceof lambda || (this.expression instanceof funcall & this.expression.name == 'foreign:')) { symbols.defineMsg(this.symbol.name, this.expression); @@ -464,6 +471,8 @@ symbols.defineMsg(this.symbol.name, new getter(null)); symbols.defineMsg(this.symbol.name + '!', new setter(null)); } +}; +assignment.prototype.populateSymbolsObject = function(symbols) { this.symbol.populateSymbols(symbols); this.expression.populateSymbols(symbols, true); this.symbols = symbols;