diff src/luan/interp/UpValue.java @ 86:6db8f286fa6c

_ENV is per module, not global git-svn-id: https://luan-java.googlecode.com/svn/trunk@87 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 27 Feb 2013 08:03:51 +0000
parents 7c08b611125d
children 3c404a296995
line wrap: on
line diff
--- a/src/luan/interp/UpValue.java	Mon Feb 25 03:53:54 2013 +0000
+++ b/src/luan/interp/UpValue.java	Wed Feb 27 08:03:51 2013 +0000
@@ -2,6 +2,7 @@
 
 import luan.DeepCloner;
 import luan.DeepCloneable;
+import luan.LuanException;
 
 
 final class UpValue implements DeepCloneable<UpValue> {
@@ -55,7 +56,7 @@
 	}
 
 	static interface Getter {
-		public UpValue get(LuanStateImpl luan);
+		public UpValue get(LuanStateImpl luan) throws LuanException;
 	}
 
 	static final class StackGetter implements Getter {
@@ -82,10 +83,23 @@
 		}
 	}
 
-	static final Getter globalGetter = new Getter() {
+	static final class EnvGetter implements Getter {
+
+		public UpValue get(LuanStateImpl luan) throws LuanException {
+			return luan.getUpValue(this);
+		}
+	}
+
+	static final class ValueGetter implements Getter {
+		private final UpValue upValue;
+
+		ValueGetter(Object value) {
+			this.upValue = new UpValue(value);
+		}
+
 		public UpValue get(LuanStateImpl luan) {
-			return new UpValue(luan.global());
+			return upValue;
 		}
-	};
+	}
 
 }