org.erights.e.elang.interp
Class ImportLoader

java.lang.Object
  |
  +--org.erights.e.elib.serial.BaseLoader
        |
        +--org.erights.e.elang.interp.ImportLoader
All Implemented Interfaces:
Loader, Uncaller

class ImportLoader
extends BaseLoader

The Loader bound to import__uriGetter.

As explained in the superclass comment, this must be thread-safe.

Author:
Mark S. Miller, E. Dean Tribble

Field Summary
private  FlexMap myAlreadyImported
          The values in the slots are either EStaticWrappers on Class objects (for safe classes), PackageScopes (for packages), or whatever value a .emaker file evaluated to, when interpreted in the safeScope.
private  ClassLoader myOptLoader
          We assume that ClassLoaders are thread-safe
private  OuterScope mySafeScope
          The only thing we do with this is diverge from it, so diverge must be thread-safe, and it must be thread-safe to mutate each diverged scope in a separate thread.
 
Constructor Summary
(package private) ImportLoader(OuterScope safeScope)
          optLoader defaults to null.
private ImportLoader(OuterScope safeScope, ClassLoader optLoader)
           
 
Method Summary
 Object get(String name)
          Enabled: How modules (and other things) get imported.
 Slot getLocalSlot(String fqName)
          Must handle cyclic imports
private  StaticMaker getOptStaticMaker(String fqName)
          null if not found.
private  Object getValue(String fqName, boolean[] isConfinedPtr)
          Gets the value at fqName, and indicate whether it is itself DeepFrozen.
private  Twine optESource(String fqName)
          returns null if not found
private  URL optResource(String rName)
          returns null if not found
 Object[] optUncall(Object obj)
          XXX For now, this only need work for StaticMakers.
 String toString()
          Suppressed: Returns a string representation of the object.
 
Methods inherited from class org.erights.e.elib.serial.BaseLoader
getOptWrappingUncall, optUnget, ungetToUncall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mySafeScope

private final OuterScope mySafeScope
The only thing we do with this is diverge from it, so diverge must be thread-safe, and it must be thread-safe to mutate each diverged scope in a separate thread.


myOptLoader

private final ClassLoader myOptLoader
We assume that ClassLoaders are thread-safe


myAlreadyImported

private final FlexMap myAlreadyImported
The values in the slots are either EStaticWrappers on Class objects (for safe classes), PackageScopes (for packages), or whatever value a .emaker file evaluated to, when interpreted in the safeScope.

Must synchronize access to this

Constructor Detail

ImportLoader

private ImportLoader(OuterScope safeScope,
                     ClassLoader optLoader)

ImportLoader

ImportLoader(OuterScope safeScope)
optLoader defaults to null.

Method Detail

optResource

private URL optResource(String rName)
returns null if not found


optESource

private Twine optESource(String fqName)
returns null if not found


getOptStaticMaker

private StaticMaker getOptStaticMaker(String fqName)
null if not found. Thrown exception if found but unsafe.


getValue

private Object getValue(String fqName,
                        boolean[] isConfinedPtr)
Gets the value at fqName, and indicate whether it is itself DeepFrozen.

If not found, throws an exception. Sets isConfinedPtr[0] according to whether the result is itself DeepFrozen (transitively immutable & non-authority granting, or safe to treat as such).

TODO each load starts with a clean safe scope in which additional outers are not visible outside the loaded module.


get

public Object get(String name)
Description copied from interface: Loader
Enabled: How modules (and other things) get imported.

If this loader is called 'foo__uriGetter', then '' will expand to 'foo__uriGetter.get("name")'.


getLocalSlot

public Slot getLocalSlot(String fqName)
Must handle cyclic imports


optUncall

public Object[] optUncall(Object obj)
XXX For now, this only need work for StaticMakers.

Returns:
:nullOk([any, String, any[]]); either null or a 3-element list of
  • a receiver object whose reconstruction would receive the message
  • a String, which is the name of the message to call
  • a list of arguments, whose reconstruction are the actual arguments to the call.

toString

public String toString()
Description copied from class: Object
Suppressed: Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.


comments?