changeset 312:8511aac1ce82

Fix module references in macros
author Michael Pavone <pavone@retrodev.com>
date Fri, 05 Sep 2014 09:56:22 -0700
parents dfd204c82849
children f2aff12d8e87
files interp.js
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/interp.js	Fri Aug 01 18:56:50 2014 -0700
+++ b/interp.js	Fri Sep 05 09:56:22 2014 -0700
@@ -123,6 +123,7 @@
 			if (typeof ret == 'function') {
 				ret = ret();
 			}
+			ret.ismodule = true;
 			this.modules[name] = ret;
 			return ret;
 		}
@@ -309,11 +310,15 @@
 	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');
+			if (val.ismodule) {
+				return this;
+				} else {
+				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;
 			}
-			return newnode;
 		} else {
 			this.dirty = true;
 			return this;