org.omegahat.Environment.Interpreter
Interface Evaluator

All Known Subinterfaces:
ManagedEvaluatorInt

public interface Evaluator

A basic interface that an object implements to be considered an evaluator in the current Omegahat language. At present, the evaluator hieararchy is relatively linear and so the methods are inherited from BasicEvaluator. The methods control


Field Summary
static java.lang.String ThisVariableName
           
 
Method Summary
 int addEvaluationListener(EvaluationListener l)
          Register an object to be notified of evaluation events such as the beginning and end of a top-level task, an error, and the start of the evaluation of a sub-expression within the expression tree of a task.
 int addFunctionTable(java.lang.Object source)
          Add the specified object to the list of elements that are searched when a function-like call is evaluated and no function is found.
 boolean addMethod(Method method, Name name)
           
 boolean allowUnrestrictedAccess()
          Indicate whether access to methods and fields that are not usually accessible (non-public classes and/or methods and fields) are tolerated.
 java.lang.Object asObject(Name n)
           
 java.lang.String asObjectName(Name n)
           
 java.lang.Class asPrimitiveClass(java.lang.String name)
          Return the primitive class (that is, double, int, etc.) corresponding the specified string of the form "double", etc.
 boolean assign(java.lang.String name, java.lang.Object value)
           
 boolean assign(java.lang.String name, java.lang.Object value, Database db)
           
 AttachedDatabase attach(Database db)
           
 AttachedDatabase attach(Database db, int position)
           
 java.lang.Object convertPrimitive(java.lang.Object value, java.lang.Class target)
          Convert an object to a primitive object such as an Integer to a Double or vice-versa.
 ExpressionInt currentExpression()
          Retrieve the current sub-expression being evaluated.
 ExpressionInt currentExpression(ExpressionInt expr)
          Set the current sub-expression being evaluated.
 boolean Debug()
           
 boolean Debug(java.lang.Object src)
           
 Database defaultDatabase()
          Retrieve the database into which assignments are made by default (i.e.
 Database defaultDatabase(Database db)
          Set the database to which assignments are made by default.
 int detach(Database db)
           
 int detach(int which)
           
 java.lang.Exception error(java.lang.String msg)
          Signal an error, using the error message to indicate why.
 java.lang.Exception error(java.lang.Throwable e, java.lang.String msg)
          Raise an error based on the exception that was caught during the evaluation of the current top-level task.
 java.lang.Object evaluate(ExpressionInt expression)
           
 java.lang.Object evaluate(java.lang.String input)
           
 boolean exists(java.lang.String name)
           
 void exit(int value)
          Terminate the session as quickly as possibly
 java.lang.Class findClass(Name name)
          Find the Class object corresponding to a multi-component Name object.
 java.lang.Class findClass(java.lang.String name)
          Locate a Class object with the given name, using incomplete matching such as Vector or util.Vector to resolve Vector.
 Evaluable findFunctionOrMethod(java.lang.String name)
           
 OrderedTable functionTableList()
          Retrieve a list of all the potential sources of methods that are invokable as functions.
 java.lang.Object get(java.lang.String name)
           
 java.lang.Object get(java.lang.String name, java.lang.Class type)
           
 Database newDatabase(java.lang.String name)
           
 java.lang.String[] objects(int which)
           
 Options options()
          Get the current Options object in effect for this evaluator.
 Options options(Options opts)
          Set the Options object for the evaluator.
 ExpressionInt parse(java.lang.String input)
           
 boolean q()
           
 boolean remove(java.lang.String name)
           
 boolean removeFunctionTable(java.lang.Object o)
          Remove the specified object from the list of internal function tables used to resolve function-like calls.
 SearchPath searchPath()
           
 SearchPath searchPath(SearchPath path)
           
 java.lang.Object source(java.io.File f)
          Read and evaluate task inputs from a file.
 java.lang.Object source(java.lang.Object o)
          Read evaluable input from an arbitrary object in a manner suitable for its class (including throwing an exception).
 java.lang.Object source(java.lang.String src)
          Read and evaluate input from a string, by attempting to treat it as a URL, a File and then an expression.
 java.lang.Object source(java.net.URL u)
          Read and evaluate input from a URL.
 java.util.Stack sourceStack()
          Retrieve the stack detailing the ordered list of input sources currently active.
 java.io.PrintWriter stderr()
          Return the current error output device.
 java.io.PrintWriter stdout()
          Return the current output device.
 ExpressionInt toplevelExpression()
          Retrieve the current top-level task expression being evaluated.
 void warning(java.lang.String msg)
          Register the specified warning message to be displayed at a suitable time, usually when the active task has been completed.
 void warning(java.lang.String msg, boolean immediate)
           
 void warning(java.lang.Throwable e, java.lang.String msg)
          Issue a warning about the exception that was caught at some point in the evaluation of the current task.
 Database[] where(java.lang.String name)
           
 Database which(java.lang.String name)
          Identifies the first database in the evaluator's search path in which a variable with this name can be found
 

Field Detail

ThisVariableName

public static final java.lang.String ThisVariableName
Method Detail

searchPath

public SearchPath searchPath()

searchPath

public SearchPath searchPath(SearchPath path)

attach

public AttachedDatabase attach(Database db)

attach

public AttachedDatabase attach(Database db,
                               int position)

detach

public int detach(int which)

detach

public int detach(Database db)

assign

public boolean assign(java.lang.String name,
                      java.lang.Object value)
               throws java.lang.Exception

assign

public boolean assign(java.lang.String name,
                      java.lang.Object value,
                      Database db)
               throws java.lang.Exception

addMethod

public boolean addMethod(Method method,
                         Name name)

get

public java.lang.Object get(java.lang.String name)
                     throws ObjectNotFoundException

objects

public java.lang.String[] objects(int which)
                           throws java.lang.Exception

remove

public boolean remove(java.lang.String name)

exists

public boolean exists(java.lang.String name)

where

public Database[] where(java.lang.String name)

get

public java.lang.Object get(java.lang.String name,
                            java.lang.Class type)
                     throws ObjectNotFoundException

asObject

public java.lang.Object asObject(Name n)
                          throws java.lang.Throwable

evaluate

public java.lang.Object evaluate(java.lang.String input)

evaluate

public java.lang.Object evaluate(ExpressionInt expression)
                          throws java.lang.Throwable

parse

public ExpressionInt parse(java.lang.String input)
                    throws java.lang.Exception

newDatabase

public Database newDatabase(java.lang.String name)

q

public boolean q()

exit

public void exit(int value)
Terminate the session as quickly as possibly

addEvaluationListener

public int addEvaluationListener(EvaluationListener l)
Register an object to be notified of evaluation events such as the beginning and end of a top-level task, an error, and the start of the evaluation of a sub-expression within the expression tree of a task. These events are adequate to provide all the necessary information to allow an external object control the evaluation and act as a debugger.

defaultDatabase

public Database defaultDatabase()
Retrieve the database into which assignments are made by default (i.e. those that have no explicit database identifier).
See Also:
assign(java.lang.String, java.lang.Object)

defaultDatabase

public Database defaultDatabase(Database db)
Set the database to which assignments are made by default.

which

public Database which(java.lang.String name)
Identifies the first database in the evaluator's search path in which a variable with this name can be found

findFunctionOrMethod

public Evaluable findFunctionOrMethod(java.lang.String name)
                               throws ObjectNotFoundException

asObjectName

public java.lang.String asObjectName(Name n)

options

public Options options()
Get the current Options object in effect for this evaluator.

options

public Options options(Options opts)
Set the Options object for the evaluator.

currentExpression

public ExpressionInt currentExpression()
Retrieve the current sub-expression being evaluated.

currentExpression

public ExpressionInt currentExpression(ExpressionInt expr)
Set the current sub-expression being evaluated.

toplevelExpression

public ExpressionInt toplevelExpression()
Retrieve the current top-level task expression being evaluated.

sourceStack

public java.util.Stack sourceStack()
Retrieve the stack detailing the ordered list of input sources currently active.

Debug

public boolean Debug()

Debug

public boolean Debug(java.lang.Object src)

error

public java.lang.Exception error(java.lang.String msg)
Signal an error, using the error message to indicate why.

error

public java.lang.Exception error(java.lang.Throwable e,
                                 java.lang.String msg)
Raise an error based on the exception that was caught during the evaluation of the current top-level task.

warning

public void warning(java.lang.Throwable e,
                    java.lang.String msg)
Issue a warning about the exception that was caught at some point in the evaluation of the current task.

warning

public void warning(java.lang.String msg)
Register the specified warning message to be displayed at a suitable time, usually when the active task has been completed.

warning

public void warning(java.lang.String msg,
                    boolean immediate)
Parameters:
msg - the message text
immediate - whether to print the message now or wait until the other warnings are issued (e.g. at the end of the task).

findClass

public java.lang.Class findClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Locate a Class object with the given name, using incomplete matching such as Vector or util.Vector to resolve Vector.

findClass

public java.lang.Class findClass(Name name)
                          throws java.lang.ClassNotFoundException
Find the Class object corresponding to a multi-component Name object.

asPrimitiveClass

public java.lang.Class asPrimitiveClass(java.lang.String name)
Return the primitive class (that is, double, int, etc.) corresponding the specified string of the form "double", etc.

convertPrimitive

public java.lang.Object convertPrimitive(java.lang.Object value,
                                         java.lang.Class target)
Convert an object to a primitive object such as an Integer to a Double or vice-versa. Used when matching methods and converting

source

public java.lang.Object source(java.lang.Object o)
                        throws java.lang.Throwable
Read evaluable input from an arbitrary object in a manner suitable for its class (including throwing an exception).

source

public java.lang.Object source(java.io.File f)
                        throws java.lang.Throwable
Read and evaluate task inputs from a file.

source

public java.lang.Object source(java.net.URL u)
                        throws java.lang.Throwable
Read and evaluate input from a URL.

source

public java.lang.Object source(java.lang.String src)
                        throws java.lang.Throwable
Read and evaluate input from a string, by attempting to treat it as a URL, a File and then an expression.

stderr

public java.io.PrintWriter stderr()
Return the current error output device.

stdout

public java.io.PrintWriter stdout()
Return the current output device.

addFunctionTable

public int addFunctionTable(java.lang.Object source)
Add the specified object to the list of elements that are searched when a function-like call is evaluated and no function is found. These act like internal or compiled functions.
Parameters:
source - a regular Object or a Class whose static methods are available.

removeFunctionTable

public boolean removeFunctionTable(java.lang.Object o)
Remove the specified object from the list of internal function tables used to resolve function-like calls.

functionTableList

public OrderedTable functionTableList()
Retrieve a list of all the potential sources of methods that are invokable as functions.

allowUnrestrictedAccess

public boolean allowUnrestrictedAccess()
Indicate whether access to methods and fields that are not usually accessible (non-public classes and/or methods and fields) are tolerated. Used by MethodCall to change the permission when invoking methods.