changeset 314:d4df33596e7d

Make modules in earlier module directories take precedence over ones in later directories
author Michael Pavone <pavone@retrodev.com>
date Sat, 14 Mar 2015 12:10:40 -0700
parents f2aff12d8e87
children f987bb2a1911
files compiler.js interp.js
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/compiler.js	Sat Mar 14 12:09:43 2015 -0700
+++ b/compiler.js	Sat Mar 14 12:10:40 2015 -0700
@@ -78,7 +78,10 @@
 			for (var i in results) {
 				var tpidx = results[i].indexOf('.tp')
 				if (tpidx > 0 && tpidx == results[i].length - 3) {
-					this.names[results[i].substr(0, tpidx)] = new modulefile(moduledirs[dirnum], results[i]);
+					var moduleName = results[i].substr(0, tpidx);
+					if (!(moduleName in this.names)) {
+						this.names[moduleName] = new modulefile(moduledirs[dirnum], results[i]);
+					}
 				}
 			}
 		}
@@ -402,7 +405,7 @@
 		if (this.args[0] instanceof symbol || this.args[0] instanceof strlit) {
 			if (this.args[1] instanceof lambda) {
 				if (this.args[2] instanceof lambda) {
-					
+
 					symbols.defineMsg(this.args[0].name, this.args[2]);
 					isll = true;
 				} else {
--- a/interp.js	Sat Mar 14 12:09:43 2015 -0700
+++ b/interp.js	Sat Mar 14 12:10:40 2015 -0700
@@ -88,7 +88,10 @@
 		for (var i in results) {
 			var tpidx = results[i].indexOf('.tp')
 			if (tpidx > 0 && tpidx == results[i].length - 3) {
-				this.names[results[i].substr(0, tpidx)] = moduledirs[dirnum] + "/" + results[i];
+				var moduleName = results[i].substr(0, tpidx);
+				if (!(moduleName in this.names)) {
+					this.names[moduleName] = moduledirs[dirnum] + "/" + results[i];
+				}
 			}
 		}
 	}