org.erights.e.elang.interp
Class LazyEvalSlot
java.lang.Object
|
+--org.erights.e.elang.interp.LazyEvalSlot
- All Implemented Interfaces:
- Slot
- public class LazyEvalSlot
- extends Object
- implements Slot
Untamed: Exists to allow delaying the work of really importing during
ScopeSetup, while also allowing the imported things to be in the
scope they are defining.
For example, rx__quasiParser is in the safe scope, but is obtained lazily
from
. For this
import to work, it needs to provide the safe scope to the
evaluation of this module. Laziness allows the safe scope to
effectively include things that can't be defined until the safe
scope exists.
Must be made thread-safe for the same reasons as org.erights.e.elib.serial.Loader
.
- Author:
- Mark S. Miller
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
myLock
private final Object myLock
myOptScope
private Object myOptScope
- only meaningful when myOptSource != null
myOptSource
private Twine myOptSource
- to be evaluated in myOptScope
myOptValue
private Object myOptValue
- only meaningful when myOptSource == null
LazyEvalSlot
LazyEvalSlot(Object scope,
Twine source)
- Parameters:
scope
- The scope in which to evaluate the source text. It's
declared as an Object rather than Scope so that it can be
a promise for a Scope. This promise must become fulfilled
before the first getValue() happens.source
- The source text to be evaluated in the promised scope
at the time of the first getValue().
getValue
public Object getValue()
- Enabled: Returns the result of evaluating my source text in my scope.
This evaluation only happens the first time, after which the value is
cached and returned for later requests. If the value isn't
DeepPassByCopy, this has security implications, so be careful how you
use this class!
- Specified by:
getValue
in interface Slot
setValue
public void setValue(Object newValue)
- Enabled: Complains that the variable is immutable
- Specified by:
setValue
in interface Slot
__printOn
public void __printOn(TextWriter out)
throws IOException
- Enabled:
IOException
comments?