changeset 280:23b52d2d05a0

Don't try to replace self in a macro expansion since it's unlikely to be the desired behavior. A more explicit means of specifying what variables should be replaced in a quote expression is needed.
author Michael Pavone <pavone@retrodev.com>
date Mon, 21 Jul 2014 19:30:23 -0700
parents eb83863fd33e
children f6dfb85e80e5
files interp.js
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/interp.js	Mon Jul 21 19:11:15 2014 -0700
+++ b/interp.js	Mon Jul 21 19:30:23 2014 -0700
@@ -306,16 +306,18 @@
 };
 
 symbol.prototype.quote = function(env) {
-	var val = env.find(this.name);
-	if (val !== null) {
-		var newnode = makeASTNode(val);
-		if (!newnode) {
-			throw new Error(this.name + ' contains a value ' + val + ' that could not be converted to an AST node');
+	if (this.cleanName() != 'self') {
+		var val = env.find(this.name);
+		if (val !== null) {
+			var newnode = makeASTNode(val);
+			if (!newnode) {
+				throw new Error(this.name + ' contains a value ' + val + ' that could not be converted to an AST node');
+			}
+			return newnode;
+		} else {
+			this.dirty = true;
+			return this;
 		}
-		return newnode;
-	} else {
-		this.dirty = true;
-		return this;
 	}
 };
 
@@ -347,15 +349,15 @@
 
 intlit.prototype.isconstant =
 	floatlit.prototype.isconstant =
-	strlit.prototype.isconstant = 
+	strlit.prototype.isconstant =
 	lambda.prototype.isconstant = function() {
 	return true;
 };
 
 object.prototype.isconstant =
 	symbol.prototype.isconstant =
-	funcall.prototype.isconstant = 
-	op.prototype.isconstant = 
+	funcall.prototype.isconstant =
+	op.prototype.isconstant =
 	assignment.prototype.isconstant = function() {
 	return false;
 }