|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--edu.mit.ai.psg.jevaES.EvalMethods
Centralized static methods for evaluating nodes while catching exceptions.
Top level: evaluate(IExpressionNode) verifies type consistency before
evaluating.
To evaluate subnodes, nodes call EvalMethods.eval(node, env)
rather than calling the subnode eval method directly, so that
when an error is thrown, this will wrap error in an
EvaluatingError which
identifies what node and env was being evaluated at the time. Similarly,
nodes call EvalMethods.getType(IExpressionNode, IEnv) and
EvalMethods.verifyTypes(IStatementNode, IEnv) rather than
calling subnode methods directly so that when an error is thrown, this
will wrap the error in a VerifyingError
identifying node and env.
Evaluation may also throw other exceptions:
AbruptCompletionException:
exceptions used during correct operation of program, e.g., for throws,
returns, breaks, continues. These should generally be caught only by
nodes which receive the transfer of control (e.g., catch a throw), or
at top level.
ThrowException:
a valid exception generated at runtime according
to JavaLangSpec1.0, e.g., via a throw statement.
ReturnException:
evaluated node executed a return statement.
BreakException:
evaluated node executed a break statement.
ContinueException:
evaluated node executed a continue statement.
VerifyingException:
subclasses for non-continueable problems,
a "compile-time error" in Java Language Specificiation 1.0.
IllegalTypeException:
an incompatible type was encountered.
IllegalNameException:
an undefined, ambiguous, or conflicting name was encountered.
IllegalConstructException:
a Java construct was improperly formed, or used in an improper
context
EvaluatingError:
An error occured while evaluating, due to a bug.
VerifyingError:
An error occurred while verifying, due to a bug.
VerifyingException,
IllegalTypeException,
IllegalNameException,
IllegalConstructException,
AbruptCompletionException,
ThrowException,
ReturnException,
BreakException,
ContinueException,
VerifyingError,
EvaluatingError| Field Summary | |
static IEnv |
defaultEnv
|
| Method Summary | |
static Object |
eval(IExpressionNode node)
return the value of previously verified expression in root env. |
static Object |
eval(IExpressionNode enode,
IEnv env)
return the value of this previously verified expression in given env. |
static IEnv |
eval(IStatementNode node)
return IEnv, extended by previously verified statement. |
static IEnv |
eval(IStatementNode snode,
IEnv env)
return env extended by this previously verified statement in given env. |
static IStore |
evalToStore(IExpressionStoreNode node)
return IStore for getting or setting the location denoted by this previously verified expression in root env. |
static IStore |
evalToStore(IExpressionStoreNode esnode,
IEnv env)
return an IStore to get or set the location denoted
by this previously verified expression in the given env. |
static Object |
evaluate(IExpressionNode node)
verify types then evaluate node with default env |
static Object |
evaluate(IExpressionNode node,
IEnv env)
verify types then evaluate node with given env |
static IEnv |
evaluate(IStatementNode node)
verify types then evaluate node with default env |
static IEnv |
evaluate(IStatementNode node,
IEnv env)
verify types then evaluate node with given env |
static Class |
getType(IExpressionNode node)
return the Class representing the Java type of this expression in default env, after type checking subexpressions. |
static Class |
getType(IExpressionNode node,
IEnv env)
return Class representing Java type of this expression in given env after type checking subexpressions. |
static boolean |
isConstant(IExpressionNode node)
return true if this expression has constant value in root env. |
static boolean |
isConstant(IExpressionNode node,
IEnv env)
return true if this expression has constant value in given env. |
static Error |
shouldNotHappen(String explain)
prints stack trace of thread on System.err, returns new Error |
static Error |
shouldNotHappen(String explain,
Throwable e)
prints stack trace of e on System.err, returns new Error |
static Error |
shouldNotHappen(Throwable e)
prints stack trace of e on System.err, returns new Error |
static IEnv |
verifyTypes(IStatementNode node)
|
static IEnv |
verifyTypes(IStatementNode node,
IEnv env)
return IEnv, extended by this statement if it is a local declaration but without evaluating initializers, after verifying types. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static IEnv defaultEnv
| Method Detail |
public static Object evaluate(IExpressionNode node)
throws VerifyingException,
ThrowException
public static IEnv evaluate(IStatementNode node)
throws VerifyingException,
AbruptCompletionException
public static Object evaluate(IExpressionNode node,
IEnv env)
throws VerifyingException,
ThrowException
public static IEnv evaluate(IStatementNode node,
IEnv env)
throws VerifyingException,
AbruptCompletionException
public static Class getType(IExpressionNode node)
throws VerifyingException
public static boolean isConstant(IExpressionNode node)
throws VerifyingException
public static IEnv verifyTypes(IStatementNode node)
throws VerifyingException
public static Object eval(IExpressionNode node)
throws ThrowException
previously - verified expression
public static IEnv eval(IStatementNode node)
throws AbruptCompletionException
previously - verified statement
public static IStore evalToStore(IExpressionStoreNode node)
throws ThrowException
previously - verified storable expression
public static Class getType(IExpressionNode node,
IEnv env)
throws VerifyingException
public static boolean isConstant(IExpressionNode node,
IEnv env)
throws VerifyingException
public static IEnv verifyTypes(IStatementNode node,
IEnv env)
throws VerifyingException
public static Object eval(IExpressionNode enode,
IEnv env)
throws ThrowException
public static IEnv eval(IStatementNode snode,
IEnv env)
throws AbruptCompletionException
public static IStore evalToStore(IExpressionStoreNode esnode,
IEnv env)
throws ThrowException
IStore to get or set the location denoted
by this previously verified expression in the given env.
public static Error shouldNotHappen(String explain,
Throwable e)
public static Error shouldNotHappen(Throwable e)
public static Error shouldNotHappen(String explain)
|
Copyright (c) 1996-1999 Massachusetts Institute of Technology Feedback: jeva-feedback@ai.mit.edu |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||