diff compiler.js @ 156:d6e79885bd3b

Fix compiler bug involving referencing a self method in a method defined before the referenced method
author Mike Pavone <pavone@retrodev.com>
date Sat, 10 Aug 2013 14:50:38 -0700
parents d715fb3c39ab
children 869399ff7faa
line wrap: on
line diff
--- a/compiler.js	Sat Aug 10 14:19:38 2013 -0700
+++ b/compiler.js	Sat Aug 10 14:50:38 2013 -0700
@@ -230,9 +230,12 @@
 			};
 		} else {
 			if (nestedcall) {
-				this.closedover[name] = true;
-				this.passthruenv = false;
-			} 
+				if (!(name in this.closedover)) {
+					debugprint('//' + name + ' is now closed over');
+					this.closedover[name] = true;
+					this.passthruenv = false;
+				}
+			}
 			if (name in this.closedover) {
 				var ret = {
 					type: 'closedover',
@@ -414,13 +417,19 @@
 	}
 }
 
+funcall.prototype.predefSymbolsObject = function(symbols) {
+};
+
 funcall.prototype.populateSymbolsObject = function(symbols) {
 	this.populateSymbols(symbols);
-}
+};
 
 object.prototype.populateSymbols = function(symbols) {
 	var symbols = new osymbols(symbols);
 	for (var i in this.messages) {
+		this.messages[i].predefSymbolsObject(symbols);
+	}
+	for (var i in this.messages) {
 		this.messages[i].populateSymbolsObject(symbols);
 	}
 	this.symbols = symbols;
@@ -456,14 +465,17 @@
 	this.expression.populateSymbols(symbols);
 	this.symbols = symbols;
 };
-assignment.prototype.populateSymbolsObject = function(symbols) {
-	debugprint('//messagedef', this.symbol.name, 'populateSymbols');
+assignment.prototype.predefSymbolsObject = function(symbols) {
+	debugprint('//messagedef', this.symbol.name, 'predefSymbolsObject');
 	if (this.expression instanceof lambda || (this.expression instanceof funcall & this.expression.name == 'foreign:')) {
 		symbols.defineMsg(this.symbol.name, this.expression);
 	} else {
 		symbols.defineMsg(this.symbol.name, new getter(null));
 		symbols.defineMsg(this.symbol.name + '!', new setter(null));
 	}
+};
+assignment.prototype.populateSymbolsObject = function(symbols) {
+	debugprint('//messagedef', this.symbol.name, 'populateSymbols');
 	this.symbol.populateSymbols(symbols);
 	this.expression.populateSymbols(symbols, true);
 	this.symbols = symbols;