changeset 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 7856f0916549
children 1417f13f219c
files compiler.js
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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;