Mercurial Hosting > luan
comparison 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 |
comparison
equal
deleted
inserted
replaced
85:b2551f00bc51 | 86:6db8f286fa6c |
---|---|
1 package luan.interp; | 1 package luan.interp; |
2 | 2 |
3 import luan.DeepCloner; | 3 import luan.DeepCloner; |
4 import luan.DeepCloneable; | 4 import luan.DeepCloneable; |
5 import luan.LuanException; | |
5 | 6 |
6 | 7 |
7 final class UpValue implements DeepCloneable<UpValue> { | 8 final class UpValue implements DeepCloneable<UpValue> { |
8 private Object[] stack; | 9 private Object[] stack; |
9 private int index; | 10 private int index; |
53 isClosed = true; | 54 isClosed = true; |
54 stack = null; | 55 stack = null; |
55 } | 56 } |
56 | 57 |
57 static interface Getter { | 58 static interface Getter { |
58 public UpValue get(LuanStateImpl luan); | 59 public UpValue get(LuanStateImpl luan) throws LuanException; |
59 } | 60 } |
60 | 61 |
61 static final class StackGetter implements Getter { | 62 static final class StackGetter implements Getter { |
62 private final int index; | 63 private final int index; |
63 | 64 |
80 public UpValue get(LuanStateImpl luan) { | 81 public UpValue get(LuanStateImpl luan) { |
81 return luan.closure().upValues()[index]; | 82 return luan.closure().upValues()[index]; |
82 } | 83 } |
83 } | 84 } |
84 | 85 |
85 static final Getter globalGetter = new Getter() { | 86 static final class EnvGetter implements Getter { |
87 | |
88 public UpValue get(LuanStateImpl luan) throws LuanException { | |
89 return luan.getUpValue(this); | |
90 } | |
91 } | |
92 | |
93 static final class ValueGetter implements Getter { | |
94 private final UpValue upValue; | |
95 | |
96 ValueGetter(Object value) { | |
97 this.upValue = new UpValue(value); | |
98 } | |
99 | |
86 public UpValue get(LuanStateImpl luan) { | 100 public UpValue get(LuanStateImpl luan) { |
87 return new UpValue(luan.global()); | 101 return upValue; |
88 } | 102 } |
89 }; | 103 } |
90 | 104 |
91 } | 105 } |