org.millscript.millscript.vm
Class Engine

java.lang.Object
  extended by org.millscript.millscript.vm.Engine
Direct Known Subclasses:
StandardEngine

public class Engine
extends java.lang.Object

This class represents a MillScript engine.


Constructor Summary
Engine(Configuration conf)
          Constructs a new engine with a default package.
 
Method Summary
 void addInventory(org.millscript.commons.vfs.VFolder f)
          Adds the specified location as an inventory.
 void addLoader(java.lang.String extension, Loader loader)
          Adds the specified loader for the specified file extension.
 void addPackage(Package p)
          Adds the specified package to this engine.
 void callBinary0(Function f, java.lang.Object x, java.lang.Object y)
          Calls the specified function with the two specified arguments, returning no results.
 java.lang.Object callBinary1(Function f, java.lang.Object x, java.lang.Object y)
          Calls the specified function with the two specified arguments, returning a single result.
 void callNullary0(Function f)
          Calls the specified function with no arguments, returning no results.
 java.lang.Object callNullary1(Function f)
          Calls the specified function with no arguments, returning a single result.
 void callTrinary0(Function f, java.lang.Object x, java.lang.Object y, java.lang.Object z)
          Calls the specified function with the three specified arguments, returning no results.
 java.lang.Object callTrinary1(Function f, java.lang.Object x, java.lang.Object y, java.lang.Object z)
          Calls the specified function with the three specified arguments, returning a single result.
 void callUnary0(Function f, java.lang.Object x)
          Calls the specified function with the single specified argument, returning no results.
 java.lang.Object callUnary1(Function f, java.lang.Object x)
          Calls the specified function with the single specified argument, returning a single result.
 Package fetchPackage(java.lang.String fqn)
          Returns the requested package, loading it from an inventory if it hasn't been already.
 Configuration getConfig()
          Returns this engines configuration.
 Machine getMachine()
          Returns this engines machine, to execute code on.
 Package getPackage(java.lang.String fqn)
          Gets the requested package.
 FunctionCall newFunctionCall()
          Returns a new function call object for this engine.
 FunctionCall newFunctionCall(Function f)
          Returns a new function call object, to invoke the specified functoin on this engine.
 FunctionCall newFunctionCall(Package p, java.lang.String sym)
          Returns a new function call object, to invoke the specified functoin on this engine.
 Package newPackage(java.lang.String fqn)
          Returns a package for the specified fully qualified name and nick-name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Engine

public Engine(Configuration conf)
Constructs a new engine with a default package.

Parameters:
conf - the configuration for this engine
Method Detail

addInventory

public void addInventory(org.millscript.commons.vfs.VFolder f)
Adds the specified location as an inventory.

Parameters:
f - the location of an inventory for this engine.

addLoader

public void addLoader(java.lang.String extension,
                      Loader loader)
Adds the specified loader for the specified file extension.

Parameters:
extension - the file extension this loader handles.
loader - the loader for the specified file extension.

addPackage

public void addPackage(Package p)
Adds the specified package to this engine.

Parameters:
p - the package to add to this engine.

callBinary0

public void callBinary0(Function f,
                        java.lang.Object x,
                        java.lang.Object y)
Calls the specified function with the two specified arguments, returning no results.

Parameters:
f - the function to call
x - the functions first argument
y - the functions second argument

callBinary1

public java.lang.Object callBinary1(Function f,
                                    java.lang.Object x,
                                    java.lang.Object y)
Calls the specified function with the two specified arguments, returning a single result.

Parameters:
f - the function to call
x - the functions first argument
y - the functions second argument
Returns:
the functions single result

callNullary0

public void callNullary0(Function f)
Calls the specified function with no arguments, returning no results.

Parameters:
f - the function to call

callNullary1

public java.lang.Object callNullary1(Function f)
Calls the specified function with no arguments, returning a single result.

Parameters:
f - the function to call
Returns:
the functions single result

callTrinary0

public void callTrinary0(Function f,
                         java.lang.Object x,
                         java.lang.Object y,
                         java.lang.Object z)
Calls the specified function with the three specified arguments, returning no results.

Parameters:
f - the function to call
x - the functions first argument
y - the functions second argument
z - the functions third argument

callTrinary1

public java.lang.Object callTrinary1(Function f,
                                     java.lang.Object x,
                                     java.lang.Object y,
                                     java.lang.Object z)
Calls the specified function with the three specified arguments, returning a single result.

Parameters:
f - the function to call
x - the functions first argument
y - the functions second argument
z - the functions third argument
Returns:
the functions single result

callUnary0

public void callUnary0(Function f,
                       java.lang.Object x)
Calls the specified function with the single specified argument, returning no results.

Parameters:
f - the function to call
x - the functions single argument

callUnary1

public java.lang.Object callUnary1(Function f,
                                   java.lang.Object x)
Calls the specified function with the single specified argument, returning a single result.

Parameters:
f - the function to call
x - the functions single argument
Returns:
the functions single result

fetchPackage

public Package fetchPackage(java.lang.String fqn)
Returns the requested package, loading it from an inventory if it hasn't been already. If the requested package cannot be found, a new one will be created.

Parameters:
fqn - the fully qualified name of the package to fetch
Returns:
the requested package

getConfig

public Configuration getConfig()
Returns this engines configuration.

Returns:
this engines configuration

getMachine

public Machine getMachine()
Returns this engines machine, to execute code on.

Returns:
the machine for this engine

getPackage

public Package getPackage(java.lang.String fqn)
Gets the requested package. The package is specified by it's fully qualified and nick-name. If the package has already been loaded from an available location, the same object will be returned, otherwise the package will be loaded automatically.

Parameters:
fqn - the fully qualified name for the package.
Returns:
the package object for the requested package.

newFunctionCall

public FunctionCall newFunctionCall()
Returns a new function call object for this engine.

Returns:
a new FunctionCall object for this engine.

newFunctionCall

public FunctionCall newFunctionCall(Function f)
Returns a new function call object, to invoke the specified functoin on this engine.

Parameters:
f - the function we want to invoke.
Returns:
a FunctionCall object to invoke the specified function on this machine.

newFunctionCall

public FunctionCall newFunctionCall(Package p,
                                    java.lang.String sym)
Returns a new function call object, to invoke the specified functoin on this engine.

Parameters:
p - the package which contains the function.
sym - the symbol of the function to invoke.
Returns:
a FunctionCall object to invoke the specified function on this machine.

newPackage

public Package newPackage(java.lang.String fqn)
Returns a package for the specified fully qualified name and nick-name. If a package already exists with the specified name, that package will be returned, otherwise a new empty package is created.

Parameters:
fqn - the fully qualified name for the new package.
Returns:
a new package, or the existing one, for the specified name.


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