org.millscript.millscript.vm
Class Package

java.lang.Object
  extended by org.millscript.millscript.vm.Package
Direct Known Subclasses:
ConfigurationPackage

public class Package
extends java.lang.Object

This class represents a MillScript Package.


Constructor Summary
Package(Engine e, java.lang.String fqn, boolean b)
          Constructs a new package with the given fully qualified name and nickname.
 
Method Summary
 void addInventory(org.millscript.commons.vfs.VFolder dir)
          Adds the contents of the specified Inventory to the set of autoloadable variables.
 void autoload(java.lang.String sym)
          Autoloads the bindings for the specified symbol.
 org.millscript.commons.util.MapIterator<java.lang.String,Loader> autoloadablesIterator()
          Returns an iterator over all the autoloadable symbols in this package.
 GlobalIdent bind(java.lang.String sym, java.lang.Object obj)
          Makes a binding in this package from the specified symbol to the specified object.
 void bindConst(java.lang.String sym, java.lang.Object obj)
          Makes a binding in this package from the specified symbol to the specified object.
 org.millscript.commons.util.MapIterator<java.lang.String,GlobalIdent> bindingsIterator()
          Returns an iterator over all the bindings in this package.
 void bindProtectedConst(java.lang.String sym, java.lang.Object obj)
          Makes a binding in this package from the specified symbol to the specified object.
 void bindProtectedVar(java.lang.String sym, java.lang.Object obj)
          Makes a binding in this package from the specified symbol to the specified object.
protected  GlobalIdent bindRef(java.lang.String sym, Ref ref)
          Makes a binding in this package from the specified symbol to the specifed reference.
 void bindVar(java.lang.String sym, java.lang.Object obj)
          Makes a binding in this package from the specified symbol to the specified object.
 GlobalIdent declareGlobal(java.lang.String sym)
          Declares the specified symbol as a global symbol.
 GlobalIdent findIdentFor(java.lang.String nn, java.lang.String sym)
          Returns the ident for the specified global symbol.
 CompilerState getCompilerState()
          Returns a new compiler state for this package.
 Configuration getConfig()
          Returns this packages configuration.
 java.lang.String getFullyQualifiedPackageName()
          Returns this packages fully qualified name.
 boolean getIsProtected(java.lang.String sym)
          Returns true if the specified symbol is protected.
 boolean hasBindingFor(java.lang.String sym)
          Returns true if the supplied symbol has a binding in this package.
 Package hasPervasiveImport(java.lang.String sym)
          Looks to see if the specified symbol is already imported in a pervasive package.
 void importPackage(java.lang.String nn, Package p)
          Imports the specified package object into this package, with the given nickname.
 void importPackage(java.lang.String nn, java.lang.String fqn)
          Imports the specified fully qualified package into this package, with the given nickname.
 void interpret(java.lang.String origin, java.io.Reader r)
          Interprets the characters returned by the specified reader into this package.
 void interpret(java.lang.String origin, java.lang.String s)
          Interprets the contents of the specified string into this package.
 void interpret(org.millscript.commons.vfs.VFile f)
          Interprets the bytes returned from reading the specified file as UTF-8 text, into this package.
 void loadConf(Source source)
          Loads the specified configuration for this package.
 void loadConf(java.lang.String origin, java.io.Reader r)
          Loads the specified configuration for this package.
 void loadConf(org.millscript.commons.vfs.VFile packageConf)
          Loads the specified configuration for this package.
 Loader makeLoaderFor(org.millscript.commons.vfs.VEntry e)
          Returns the relevant loader for the specified virtual entry, if one is available.
 java.lang.Object valueOf(java.lang.String sym)
          Returns the reference associated with the specified symbol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Package

public Package(Engine e,
               java.lang.String fqn,
               boolean b)
Constructs a new package with the given fully qualified name and nickname.

Parameters:
e - the engine this package is associated with
fqn - the new packages fully qualified name
b - a boolean indicating if this package is pervasive
Method Detail

addInventory

public void addInventory(org.millscript.commons.vfs.VFolder dir)
Adds the contents of the specified Inventory to the set of autoloadable variables.

Parameters:
dir - the inventory to add

autoload

public void autoload(java.lang.String sym)
Autoloads the bindings for the specified symbol.

Parameters:
sym - the symbol to load bindings for

autoloadablesIterator

public org.millscript.commons.util.MapIterator<java.lang.String,Loader> autoloadablesIterator()
Returns an iterator over all the autoloadable symbols in this package.

Returns:
an iterator over all the autoloadable symbols in this package.

bind

public GlobalIdent bind(java.lang.String sym,
                        java.lang.Object obj)
Makes a binding in this package from the specified symbol to the specified object.

Parameters:
sym - the symbol to bind the object to.
obj - the object to bind to the specified symbol.
Returns:
the GlobalIdent for the new global variable

bindConst

public void bindConst(java.lang.String sym,
                      java.lang.Object obj)
Makes a binding in this package from the specified symbol to the specified object. The bound symbol is a const.

Parameters:
sym - the symbol to bind the object to.
obj - the object to bind to the specified symbol.

bindVar

public void bindVar(java.lang.String sym,
                    java.lang.Object obj)
Makes a binding in this package from the specified symbol to the specified object. The bound symbol is a variable.

Parameters:
sym - the symbol to bind the object to.
obj - the object to bind to the specified symbol.

bindProtectedConst

public void bindProtectedConst(java.lang.String sym,
                               java.lang.Object obj)
Makes a binding in this package from the specified symbol to the specified object. The bound symbol is a const.

Parameters:
sym - the symbol to bind the object to.
obj - the object to bind to the specified symbol.

bindProtectedVar

public void bindProtectedVar(java.lang.String sym,
                             java.lang.Object obj)
Makes a binding in this package from the specified symbol to the specified object. The bound symbol is a variable.

Parameters:
sym - the symbol to bind the object to.
obj - the object to bind to the specified symbol.

bindRef

protected GlobalIdent bindRef(java.lang.String sym,
                              Ref ref)
Makes a binding in this package from the specified symbol to the specifed reference.

Parameters:
sym - the symbol to bind the reference to.
ref - the reference to bind to the specified symbol.
Returns:
the GlobalIdent for the new global variable

bindingsIterator

public org.millscript.commons.util.MapIterator<java.lang.String,GlobalIdent> bindingsIterator()
Returns an iterator over all the bindings in this package.

Returns:
an iterator over all the bindings in this package.

declareGlobal

public GlobalIdent declareGlobal(java.lang.String sym)
Declares the specified symbol as a global symbol. The symbol will be bound to a null reference. This method is

Parameters:
sym - the symbol to declare as a global variable
Returns:
the GlobalIdent for the new global variable

findIdentFor

public GlobalIdent findIdentFor(java.lang.String nn,
                                java.lang.String sym)
Returns the ident for the specified global symbol. The package which the symbol was imported with can be specified by the optional nickname.

Parameters:
nn - the nickname of the package the request symbol was imported with
sym - the symbol you wish to find.
Returns:
the Ident for the specified symbol.

getCompilerState

public CompilerState getCompilerState()
Returns a new compiler state for this package.

Returns:
a new compiler state for this package.

getConfig

public Configuration getConfig()
Returns this packages configuration.

Returns:
this packages configuration

getFullyQualifiedPackageName

public java.lang.String getFullyQualifiedPackageName()
Returns this packages fully qualified name.

Returns:
this packages fully qualified name

getIsProtected

public boolean getIsProtected(java.lang.String sym)
Returns true if the specified symbol is protected.

Parameters:
sym - the symbol to test protected status for
Returns:
true if the symbol is protected.

hasBindingFor

public boolean hasBindingFor(java.lang.String sym)
Returns true if the supplied symbol has a binding in this package.

Parameters:
sym - the symbol to test for
Returns:
true if the symbol has a binding and false otherwise.

hasPervasiveImport

public final Package hasPervasiveImport(java.lang.String sym)
Looks to see if the specified symbol is already imported in a pervasive package.

Parameters:
sym - the symbol to look for.
Returns:
the pervasive Package defining the symbol or null

importPackage

public void importPackage(java.lang.String nn,
                          java.lang.String fqn)
Imports the specified fully qualified package into this package, with the given nickname.

Parameters:
nn - the nickname for the imported package
fqn - the fully qualified name of the package to import.

importPackage

public void importPackage(java.lang.String nn,
                          Package p)
Imports the specified package object into this package, with the given nickname.

Parameters:
nn - the nickname for the imported package
p - the package object to import.

interpret

public void interpret(org.millscript.commons.vfs.VFile f)
Interprets the bytes returned from reading the specified file as UTF-8 text, into this package.

Parameters:
f - the File to read from.

interpret

public void interpret(java.lang.String origin,
                      java.io.Reader r)
Interprets the characters returned by the specified reader into this package. This may result in new variables being declared in this, or other packages.

Parameters:
origin - the origin message for the reader
r - the reader to interpret characters from.

interpret

public void interpret(java.lang.String origin,
                      java.lang.String s)
Interprets the contents of the specified string into this package. This may result in new variables being declared in this, or other packages.

Parameters:
origin - the origin message for the reader
s - the string to interpret.

loadConf

public void loadConf(java.lang.String origin,
                     java.io.Reader r)
Loads the specified configuration for this package.

Parameters:
origin - the origin message for the configuration
r - a reader to read the configuration from

loadConf

public void loadConf(org.millscript.commons.vfs.VFile packageConf)
Loads the specified configuration for this package.

Parameters:
packageConf - a File specifying the configuration file for this package.

loadConf

public void loadConf(Source source)
Loads the specified configuration for this package.

Parameters:
source - a Source to read configuration from

makeLoaderFor

public Loader makeLoaderFor(org.millscript.commons.vfs.VEntry e)
Returns the relevant loader for the specified virtual entry, if one is available.

Parameters:
e - the VEntry to make a loader for.
Returns:
a loader for the specified file or null

valueOf

public java.lang.Object valueOf(java.lang.String sym)
Returns the reference associated with the specified symbol.

Parameters:
sym - the symbol to find a value for.
Returns:
the reference associated with the specified symbol.


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.