|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.multijava.util.Utils
org.jmlspecs.checker.JmlAbstractVisitor
org.jmlspecs.jmlrac.RacAbstractVisitor
org.jmlspecs.jmlrac.AbstractExpressionTranslator
org.jmlspecs.jmlrac.TransExpression
org.jmlspecs.jmlrac.TransPredicate
org.jmlspecs.jmlrac.TransPostcondition
A RAC visitor class for transforming JML postconditions into Java source code. The generated code is a sequence of Java statements that evaluate and store the boolean result in the given variable. The boolean result variable is assumed to be declared in the outer scope that incorporates the code.
TransExpression,
TransPredicate| Nested Class Summary | |
private class |
TransPostcondition.QVarChecker
A class to check whether an expression has any references to quantified variables. |
| Nested classes inherited from class org.jmlspecs.jmlrac.TransExpression |
TransExpression.DiagTerm |
| Field Summary | |
private boolean |
forStatic
Indicates whether this translation is for a static method declaration. |
private List |
oldExprs
A list of RacNode's representing old expressions that
must be executed in the pre-state. |
private VarGenerator |
oldVarGen
Variable generator to be used in the translation of old expression. |
private Stack |
quantifiers
The set of quantifiers that enclose the old expression currently being translated. |
| Fields inherited from class org.jmlspecs.jmlrac.TransExpression |
context, expression, paramStack, resultStack, resultVar, typeDecl, varGen |
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Fields inherited from interface org.jmlspecs.jmlrac.RacConstants |
MN_CHECK_HC, MN_CHECK_INV, MN_CHECK_POST, MN_CHECK_PRE, MN_CHECK_XPOST, MN_EVAL_OLD, MN_GHOST, MN_INIT, MN_INTERNAL, MN_MODEL, MN_MODEL_PUBLIC, MN_RESTORE_FROM, MN_SAVE_TO, MN_SPEC, MN_SPEC_PUBLIC, TN_JMLCHECKABLE, TN_JMLSURROGATE, TN_JMLUNIT_TEST_POSTFIX, TN_JMLUNIT_TESTDATA_POSTFIX, TN_JMLVALUE, TN_SURROGATE, VN_ASSERTION, VN_CATCH_VAR, VN_CLASS_INIT, VN_CONSTRUCTED, VN_DELEGEE, VN_ERROR_SET, VN_EXCEPTION, VN_FREE_VAR, VN_INIT, VN_OLD_VAR, VN_POST_VAR, VN_PRE_VAR, VN_PRECOND, VN_RAC_COMPILED, VN_RAC_LEVEL, VN_RESULT, VN_STACK_VAR, VN_XRESULT |
| Constructor Summary | |
TransPostcondition(VarGenerator varGen,
RacContext ctx,
VarGenerator oldVarGen,
boolean forStatic,
JExpression pred,
String resultVar,
JTypeDeclarationType typeDecl)
Constructs a new instance and translates the given postcondition, pred. |
|
| Method Summary | |
private String |
buildKey()
Returns a key for retrieving the value of old expression currently being translated. |
private boolean |
hasQuantifiedVar(JmlSpecExpressionWrapper expr)
Does the given old or pre expression, expr, have any
free quantified variables? |
private void |
oldExpressionInQuantifiers(JmlSpecExpressionWrapper self)
Translates a JML old expression, self, enclosed in
quantifiers. |
List |
oldExprs()
Returns a list of old expressions (as RacNode) that
must be executed in the pre-state. |
void |
transPreExpression(JmlSpecExpressionWrapper self)
|
void |
visitJmlOldExpression(JmlOldExpression self)
Translates a JML old expression. |
void |
visitJmlPreExpression(JmlPreExpression self)
Translates a JML pre expression. |
void |
visitJmlResultExpression(JmlResultExpression self)
Translates a JML result expression. |
void |
visitJmlSpecQuantifiedExpression(JmlSpecQuantifiedExpression self)
Translates the given JML quantified expression. |
| Methods inherited from class org.jmlspecs.jmlrac.TransPredicate |
wrappedStmt |
| Methods inherited from class org.jmlspecs.jmlrac.RacAbstractVisitor |
visitRacNode |
| Methods inherited from class org.multijava.util.Utils |
assertTrue, assertTrue, combineArrays, escapeString, escapeString, fail, fail, getFilePath, hasFlag, hasOtherFlags, parsePathParts, relativePathTo, splitQualifiedName, splitQualifiedName, stripJavaModifiers, stripNonJavaModifiers, stripPrivateModifier, unescapeString, vectorToArray, vectorToIntArray |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private boolean forStatic
private List oldExprs
RacNode's representing old expressions that
must be executed in the pre-state.
private VarGenerator oldVarGen
private Stack quantifiers
private invariant (\forall Object o; quantifiers.contains(o); o instanceof JmlSpecQuantifiedExpression);
| Constructor Detail |
public TransPostcondition(VarGenerator varGen,
RacContext ctx,
VarGenerator oldVarGen,
boolean forStatic,
JExpression pred,
String resultVar,
JTypeDeclarationType typeDecl)
pred. The translated Java source
code can be accessed by such accessor methods as
stmt() and wrappedStmt.
resultVar - variable to store the result| Method Detail |
public List oldExprs()
RacNode) that
must be executed in the pre-state. The declaration of a local
variable to hold the result of the expression is stored in the
name field of class RacNode. This method
must be called after translation.
normal_behavior assignable translated; ensures \result != null && \result == oldExprs;
public void visitJmlPreExpression(JmlPreExpression self)
[[\pre(E), r]] =
r = v;
with the addition of a field declaration
private T_E v = d_T_E; to the target class, and the
insertion of evaluation [[E, v]] into the method
prolog.
visitJmlPreExpression in interface JmlVisitorvisitJmlPreExpression in class TransExpressionTransOldExpressionpublic void visitJmlOldExpression(JmlOldExpression self)
[[\old(E), r]] =
r = v;
with the addition of a field declaration
private T_E v = d_T_E; to the target class, and the
insertion of evaluation [[E, v]] into the method
prolog.
visitJmlOldExpression in interface JmlVisitorvisitJmlOldExpression in class TransExpressionTransOldExpressionpublic void transPreExpression(JmlSpecExpressionWrapper self)
public void visitJmlSpecQuantifiedExpression(JmlSpecQuantifiedExpression self)
visitJmlSpecQuantifiedExpression in interface JmlVisitorvisitJmlSpecQuantifiedExpression in class TransExpressionvisitJmlPreExpression(JmlPreExpression),
visitJmlOldExpression(JmlOldExpression)public void visitJmlResultExpression(JmlResultExpression self)
[[\result, r]] =
r = VN_RESULT;
with the insertion of a variable declaration
T VN_RESULT = d_T; into the method proglog, where
T is the return type of the method.
The variable VN_RESULT is used to capture the return
value of the method.
visitJmlResultExpression in interface JmlVisitorvisitJmlResultExpression in class TransExpressionprivate boolean hasQuantifiedVar(JmlSpecExpressionWrapper expr)
expr, have any
free quantified variables?
private void oldExpressionInQuantifiers(JmlSpecExpressionWrapper self)
self, enclosed in
quantifiers. The translation generates code that evaluates the
old expression for each combination of bound variables of
quantifiers and stores the result to a private cache. The original
old expression is replaced with cache lookup code.
requires !quantifiers.isEmpty(); assignable oldExprs, resultStack;
private String buildKey()
x1, x2, ..., xn, the key
is new Object[] { x1, x2, ..., xn }, where
xi is wrapped if necessary.
requires !quantifiers.isEmpty(); ensures \result != null;
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||