| java.lang.Object pnuts.lang.SymbolTable pnuts.lang.Package
Constructor Summary | |
public | Package() Creates a package that is not visible from other packages. | public | Package(String name) Creates a package and register it in a static hashtable. | public | Package(String name, Package parent) Creates a package and register it in a static hashtable. | protected | Package(String name, Package parent, Package root) Creates a package and register it in a static hashtable. |
Method Summary | |
protected void | addPackage(Package pkg, Context context) | public Map | asMap() | public void | autoload(String name, String file, Context context) Registers an autoload script for the name. | public void | autoload(String name, AutoloadHook hook) Registers an AutoloadHook for the name. | public void | clear(String symbol, Context context) Deletes a symbol from the package. | public Object | clone() Returns a clone package. | public boolean | defined(String name, Context context) Checks if the specified name is already defined in this package. | public Enumeration | elements() | public void | export(String name) | void | exportFunction(String sym, Object value) | void | exportFunctions() | public static Package | find(String pkg) Find a named package.
Parameters: pkg - a name of package to look. | public static Package | find(String pkg, Context context) Find a named package.
Parameters: pkg - a name of package to look. | public Object | get(String symbol, Context context) Get the value of a symbol in the package. | public static Package | getGlobalPackage() | String | getInitScript() | static String | getInitScript(String name, String delimiter) | static Package | getInstance(String name, Package parent, Context context) | public String | getName() | public static Package | getPackage(String pkg) If package "pkg" exists returns the package, otherwise creates and
returns it. | public static Package | getPackage(String pkg, Context context) If package "pkg" exists returns the package, otherwise creates and
returns it. | public Package | getParent() Returns the parent package. | protected synchronized void | init(Context context) This method is called when the package become the current package with
package() function. | protected synchronized void | initializeModule() Starts using this package as a module. | public NamedValue | lookup(String symbol, Context context) Looks up a symbol in this package. | NamedValue | lookupExportedSymbol(String symbol, Context context) | protected NamedValue | lookupRecursively(String symbol, Context context) Lookup the symbol in the package. | public Package | newInstance(String name) Creates an uninitialized instance of a Package subclass When a
sub-package is created, this method is called. | public static void | remove(String name) Removes the specified package. | public static void | remove(String name, Context context) Removes the specified package. | protected void | removePackage(Package pkg, Context context) | public void | set(String symbol, Object obj, Context context) Set a value of a symbol in the package. | public String | toString() | public static Package | wrap(Map map) |
exports | protected boolean exports(Code) | | |
globalPackage | final public static Package globalPackage(Code) | | The package with name "".
|
initialized | protected boolean initialized(Code) | | |
moduleIntializationLock | transient Object moduleIntializationLock(Code) | | |
packages | protected transient Hashtable packages(Code) | | All packages with a non-null name
|
providedModuleNames | protected Vector providedModuleNames(Code) | | |
requiredModuleNames | protected Vector requiredModuleNames(Code) | | |
serialVersionUID | final static long serialVersionUID(Code) | | |
usedAsModule | protected boolean usedAsModule(Code) | | |
Package | public Package()(Code) | | Creates a package that is not visible from other packages.
|
Package | public Package(String name)(Code) | | Creates a package and register it in a static hashtable.
Parameters: name - the name of the package |
Package | public Package(String name, Package parent)(Code) | | Creates a package and register it in a static hashtable. The method
get() tries to find a symbol in this package and then consult
the parent package. Other instance methods, such as
set(), defined(), operates on this package only. Other
constructors implicitly specify the global package as the parent package.
Parameters: name - the name of the package Parameters: parent - the parent package. |
Package | protected Package(String name, Package parent, Package root)(Code) | | Creates a package and register it in a static hashtable. The method
get() tries to find a symbol in this package and then consult
the parent package. Other instance methods, such as
set(), defined(), operates on this package only. Other
constructors implicitly specify the global package as the parent package.
Parameters: name - the name of the package Parameters: parent - the parent package. Parameters: root - the root package. |
asMap | public Map asMap()(Code) | | Returns a Map object that wraps this package
|
autoload | public void autoload(String name, String file, Context context)(Code) | | Registers an autoload script for the name. If name
is not defined when accessed, the registerred file is loaded.
Parameters: name - variable name Parameters: file - the file Parameters: context - the context |
autoload | public void autoload(String name, AutoloadHook hook)(Code) | | Registers an AutoloadHook for the name. If name is
not defined when accessed, the registerred AutoloadHook is executed.
Parameters: name - variable name Parameters: hook - the AutoloadHook |
clear | public void clear(String symbol, Context context)(Code) | | Deletes a symbol from the package.
Parameters: symbol - a name of variable to be deleted |
defined | public boolean defined(String name, Context context)(Code) | | Checks if the specified name is already defined in this package.
true if name is defined in the package. |
export | public void export(String name)(Code) | | Exports a symbol of the module
Parameters: name - the symbol exception: IllegalStateException - when the package is not used as a module. |
exportFunctions | void exportFunctions()(Code) | | |
find | public static Package find(String pkg)(Code) | | Find a named package.
Parameters: pkg - a name of package to look. a package with name "pkg" if it exits. |
find | public static Package find(String pkg, Context context)(Code) | | Find a named package.
Parameters: pkg - a name of package to look. a package with name "pkg" if it exits. |
get | public Object get(String symbol, Context context)(Code) | | Get the value of a symbol in the package. When the symbol is not defined
in the package, first, the associated autoloading hook is invoked if any,
second, get the value in the parent package.
Parameters: symbol - an interned name in the package Parameters: context - the context in which the symbol is referenced. null means "notspecified". the value of specified variable in the package. |
getGlobalPackage | public static Package getGlobalPackage()(Code) | | the global package |
getName | public String getName()(Code) | | the name of the package. |
getPackage | public static Package getPackage(String pkg)(Code) | | If package "pkg" exists returns the package, otherwise creates and
returns it.
|
getPackage | public static Package getPackage(String pkg, Context context)(Code) | | If package "pkg" exists returns the package, otherwise creates and
returns it.
|
getParent | public Package getParent()(Code) | | Returns the parent package.
|
init | protected synchronized void init(Context context)(Code) | | This method is called when the package become the current package with
package() function. This method in a subclass must call
super.init(context) first.
|
initializeModule | protected synchronized void initializeModule()(Code) | | Starts using this package as a module.
|
lookup | public NamedValue lookup(String symbol, Context context)(Code) | | Looks up a symbol in this package. If not defined, the associated
autoloading hook is invoked if any.
Parameters: symbol - an interned String Parameters: context - the context a NamedValue |
lookupRecursively | protected NamedValue lookupRecursively(String symbol, Context context)(Code) | | Lookup the symbol in the package. When the symbol is not defined in the
package and this.parent is not null, lookup the symbol in the parent
package.
Resulting value is an instance of NamedValue.
Parameters: symbol - intern'ed string |
newInstance | public Package newInstance(String name)(Code) | | Creates an uninitialized instance of a Package subclass When a
sub-package is created, this method is called.
Parameters: name - the package name a Package object |
remove | public static void remove(String name)(Code) | | Removes the specified package.
|
remove | public static void remove(String name, Context context)(Code) | | Removes the specified package.
|
set | public void set(String symbol, Object obj, Context context)(Code) | | Set a value of a symbol in the package. If this package is "used" in the
specified context, and if the target object is either a Class object or a
function whose name matches the symbol, then the symbol is imported to
the context.
Parameters: symbol - an interned name of variable Parameters: obj - the value of the variable |
wrap | public static Package wrap(Map map)(Code) | | Returns a Package object that wrap the specified Map
|
|
|