Mercurial > repos > tabletprog
comparison compiler.js @ 196:228df5004ab5
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
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 27 Aug 2013 21:38:09 -0700 |
parents | 869399ff7faa |
children | d2e0664ba73e |
comparison
equal
deleted
inserted
replaced
195:7856f0916549 | 196:228df5004ab5 |
---|---|
227 var ret = { | 227 var ret = { |
228 type: 'foreign', | 228 type: 'foreign', |
229 def: this.names[name] | 229 def: this.names[name] |
230 }; | 230 }; |
231 } else { | 231 } else { |
232 if (nestedcall) { | 232 if (nestedcall && !(name in this.closedover)) { |
233 debugprint('//symbol', name, 'is now closed over'); | |
233 this.closedover[name] = true; | 234 this.closedover[name] = true; |
234 this.passthruenv = false; | 235 this.passthruenv = false; |
235 } | 236 } |
236 if (name in this.closedover) { | 237 if (name in this.closedover) { |
237 var ret = { | 238 var ret = { |
412 if (this.receiver) { | 413 if (this.receiver) { |
413 this.receiver.populateSymbols(symbols, undefined, isll); | 414 this.receiver.populateSymbols(symbols, undefined, isll); |
414 } | 415 } |
415 } | 416 } |
416 | 417 |
418 funcall.prototype.defineSymbolsObject = function(symbols) { | |
419 } | |
420 | |
417 funcall.prototype.populateSymbolsObject = function(symbols) { | 421 funcall.prototype.populateSymbolsObject = function(symbols) { |
418 this.populateSymbols(symbols); | 422 this.populateSymbols(symbols); |
419 } | 423 } |
420 | 424 |
421 object.prototype.populateSymbols = function(symbols) { | 425 object.prototype.populateSymbols = function(symbols) { |
422 var symbols = new osymbols(symbols); | 426 var symbols = new osymbols(symbols); |
427 for (var i in this.messages) { | |
428 this.messages[i].defineSymbolsObject(symbols); | |
429 } | |
423 for (var i in this.messages) { | 430 for (var i in this.messages) { |
424 this.messages[i].populateSymbolsObject(symbols); | 431 this.messages[i].populateSymbolsObject(symbols); |
425 } | 432 } |
426 this.symbols = symbols; | 433 this.symbols = symbols; |
427 } | 434 } |
454 } | 461 } |
455 this.symbol.populateSymbols(symbols); | 462 this.symbol.populateSymbols(symbols); |
456 this.expression.populateSymbols(symbols); | 463 this.expression.populateSymbols(symbols); |
457 this.symbols = symbols; | 464 this.symbols = symbols; |
458 }; | 465 }; |
459 assignment.prototype.populateSymbolsObject = function(symbols) { | 466 assignment.prototype.defineSymbolsObject = function(symbols) { |
460 debugprint('//messagedef', this.symbol.name, 'populateSymbols'); | 467 debugprint('//messagedef', this.symbol.name, 'populateSymbols'); |
461 if (this.expression instanceof lambda || (this.expression instanceof funcall & this.expression.name == 'foreign:')) { | 468 if (this.expression instanceof lambda || (this.expression instanceof funcall & this.expression.name == 'foreign:')) { |
462 symbols.defineMsg(this.symbol.name, this.expression); | 469 symbols.defineMsg(this.symbol.name, this.expression); |
463 } else { | 470 } else { |
464 symbols.defineMsg(this.symbol.name, new getter(null)); | 471 symbols.defineMsg(this.symbol.name, new getter(null)); |
465 symbols.defineMsg(this.symbol.name + '!', new setter(null)); | 472 symbols.defineMsg(this.symbol.name + '!', new setter(null)); |
466 } | 473 } |
474 }; | |
475 assignment.prototype.populateSymbolsObject = function(symbols) { | |
467 this.symbol.populateSymbols(symbols); | 476 this.symbol.populateSymbols(symbols); |
468 this.expression.populateSymbols(symbols, true); | 477 this.expression.populateSymbols(symbols, true); |
469 this.symbols = symbols; | 478 this.symbols = symbols; |
470 }; | 479 }; |
471 | 480 |