diff compiler.js @ 38:e7be612fd3ae

Very basic array support
author Mike Pavone <pavone@retrodev.com>
date Tue, 10 Jul 2012 23:09:44 -0700
parents 3b0503a67165
children 4e983fe32047
line wrap: on
line diff
--- a/compiler.js	Tue Jul 10 22:09:21 2012 -0700
+++ b/compiler.js	Tue Jul 10 23:09:44 2012 -0700
@@ -107,6 +107,7 @@
 	this.parent = parent;
 	this.names = {};
 	this.closedover = {};
+	this.declared = {};
 	this.needsSelfVar = false;
 	this.passthruenv = false;
 	this.envtype = 'void';
@@ -130,7 +131,8 @@
 		}
 		return {
 			type: 'local',
-			def: this.names[name]
+			def: this.names[name],
+			isdeclared: (name in this.declared)
 		};
 	} else if(this.parent) {
 		var ret = this.parent.find(name, true);
@@ -153,6 +155,9 @@
 lsymbols.prototype.defineVar = function(name, def) {
 	this.names[name] = def;
 };
+lsymbols.prototype.declareVar = function(name) {
+	this.declared[name] = true;
+}
 lsymbols.prototype.selfVar = function() {
 	if (this.parent && this.parent instanceof lsymbols) {
 		this.parent.needsSelf();
@@ -221,9 +226,15 @@
 }
 
 listlit.prototype.populateSymbols = function(symbols) {
-	each(this.val, function(i,el) {
-		el.populateSymbols(symbols);
-	});
+	for (var i = 0; i < this.val.length; i++) {
+		this.val[i].populateSymbols(symbols);
+	}
+}
+
+arraylit.prototype.populateSymbols = function(symbols) {
+	for (var i = 0; i < this.val.length; i++) {
+		this.val[i].populateSymbols(symbols);
+	}
 }
 
 funcall.prototype.populateSymbols = function(symbols) {