diff compiler.js @ 30:608eb70fe261

Fix some compiler bugs and do initial work on module import
author Mike Pavone <pavone@retrodev.com>
date Thu, 19 Apr 2012 19:20:21 -0700
parents 4d87c38404d6
children 668f533e5284
line wrap: on
line diff
--- a/compiler.js	Thu Apr 05 21:06:43 2012 -0700
+++ b/compiler.js	Thu Apr 19 19:20:21 2012 -0700
@@ -3,11 +3,27 @@
 	return str.split('\n').join('\n\t');
 }
 
+function topsymbols()
+{
+	this.names = null;
+}
+topsymbols.prototype.find = function(name) {
+	if (!this.names) {
+		
+	}
+	if (name in this.names) {
+		return {
+			type: 'toplevel',
+			def: null
+		};
+	}
+	return null;
+}
+
 function osymbols(parent)
 {
 	this.parent = parent;
 	this.names = {};
-	this.lastname = null;
 }
 osymbols.prototype.find = function(name) {
 	if (name in this.names) {
@@ -36,7 +52,6 @@
 	return null;
 };
 osymbols.prototype.defineMsg = function(name, def) {
-	this.lastname = name;
 	this.names[name] = def;
 }
 osymbols.prototype.parentObject = function() {
@@ -67,7 +82,6 @@
 {
 	this.parent = parent;
 	this.names = {};
-	this.lastname = null;
 	this.needsSelfVar = false;
 }
 lsymbols.prototype.find = function(name) {
@@ -92,7 +106,6 @@
 	return null;
 };
 lsymbols.prototype.defineVar = function(name, def) {
-	this.lastname = name;
 	this.names[name] = def;
 };
 lsymbols.prototype.selfVar = function() {
@@ -210,8 +223,10 @@
 	this.symbols = symbols;
 };
 assignment.prototype.populateSymbolsObject = function(symbols) {
-	symbols.defineMsg(this.symbol.name, this.expression);
-	if (!(this.expression instanceof lambda) && !(this.expression instanceof funcall && this.expression.name == 'foreign:')) {
+	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));
 	}
 	this.symbol.populateSymbols(symbols);
@@ -223,9 +238,9 @@
 {
 	this.fun = fun;
 }
-
+setter.prototype.args = [new symbol('self'), new symbol('newval')];
 function getter(fun)
 {
 	this.fun = fun;
 }
-
+getter.prototype.args = [new symbol('self')];