diff compiler.js @ 57:08ae75d90dc2

Add != operator. Fix more closure bugs.
author Mike Pavone <pavone@retrodev.com>
date Sat, 14 Jul 2012 00:00:24 -0700
parents 93ddb4ad6fcb
children 0fd06e077afe
line wrap: on
line diff
--- a/compiler.js	Fri Jul 13 21:28:37 2012 -0700
+++ b/compiler.js	Sat Jul 14 00:00:24 2012 -0700
@@ -66,6 +66,7 @@
 	this.parent = parent;
 	this.names = {};
 	this.needsenv = false;
+	this.typename = null;
 }
 osymbols.prototype.find = function(name, nestedcall) {
 	debugprint('//osymbols.find', name + ', exists?:', name in this.names, ', nested?:', nestedcall);
@@ -79,6 +80,7 @@
 		var ret = {
 			type: 'self',
 			def: this.names[name],
+			selftype: this.typename
 		};
 	} else if(this.parent) {
 		var ret = this.parent.find(name, nestedcall);
@@ -140,6 +142,7 @@
 	this.needsSelfVar = false;
 	this.passthruenv = false;
 	this.envtype = 'void';
+	this.needsParentEnv = false;
 }
 lsymbols.prototype.find = function(name, nestedcall) {
 	debugprint('//lsymbols.find', name + ', exists?:', name in this.names, ', nested?:', nestedcall);
@@ -177,18 +180,22 @@
 			if (ret.type == 'upvar') {
 				if (Object.keys(this.closedover).length) {
 					ret.depth++;
+					ret.startdepth = 1;
+					this.needsParentEnv = true;
 				} else {
 					this.passthruenv = true;
-					if (ret.depth == 0) {
+					ret.startdepth = 0;
+					/*if (ret.depth == 0) {
 						ret.depth = 1;
-					}
+					}*/
 				}
 			}
 		}
 	} else {
 		return null;
 	}
-	debugprint('\t//symbol type:', ret ? ret.type : 'null');
+	var type = ret ? ret.type : 'null';
+	debugprint('\t//symbol type:', type , type == 'upvar' ? 'depth: ' + ret.depth : '');
 	return ret;
 };
 lsymbols.prototype.defineVar = function(name, def) {
@@ -261,7 +268,7 @@
 symbol.prototype.populateSymbols = function(symbols) {
 	this.symbols = symbols;
 	var ret = symbols.find(this.cleanName());
-	if (ret.type == 'self') {
+	if (ret && ret.type == 'self') {
 		symbols.find('self');
 	}
 }