|
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.TransExpression2
org.jmlspecs.jmlrac.TransPostExpression2
A RAC visitor class to translate JML expressions into Java source code.
TransExpression2| Nested Class Summary | |
private class |
TransPostExpression2.QVarChecker
A class to check whether an expression has any references to quantified variables. |
| 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 static Stack |
quantifiers
The set of quantifiers that enclose the old expression currently being translated. |
| Fields inherited from class org.jmlspecs.jmlrac.TransExpression2 |
context, errorType, evaluatorPDef, evaluatorPUse, expression, isInner, prebuiltStatementsStack, reportedException, resultVar, thisIs, 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 | |
TransPostExpression2(VarGenerator varGen,
RacContext ctx,
VarGenerator oldVarGen,
boolean forStatic,
JExpression pred,
String resultVar,
JTypeDeclarationType typeDecl,
String errorType)
Constructs a new instance and translates the given post-expression. |
|
| Method Summary | |
private String |
buildKey()
Returns a key for retrieving the value of old expression currently being translated. |
protected void |
handleExceptionalTranslation(PositionnedExpressionException e)
|
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.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 static Stack quantifiers
private invariant (\forall Object o; quantifiers.contains(o); o instanceof JmlSpecQuantifiedExpression);
| Constructor Detail |
public TransPostExpression2(VarGenerator varGen,
RacContext ctx,
VarGenerator oldVarGen,
boolean forStatic,
JExpression pred,
String resultVar,
JTypeDeclarationType typeDecl,
String errorType)
resultVar - variable to store the result| Method Detail |
protected void handleExceptionalTranslation(PositionnedExpressionException e)
handleExceptionalTranslation in class TransExpression2public 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.
public void visitJmlPreExpression(JmlPreExpression self)
visitJmlPreExpression in interface JmlVisitorvisitJmlPreExpression in class TransExpression2public void visitJmlOldExpression(JmlOldExpression self)
visitJmlOldExpression in interface JmlVisitorvisitJmlOldExpression in class TransExpression2public void transPreExpression(JmlSpecExpressionWrapper self)
public void visitJmlSpecQuantifiedExpression(JmlSpecQuantifiedExpression self)
visitJmlSpecQuantifiedExpression in interface JmlVisitorvisitJmlSpecQuantifiedExpression in class TransExpression2visitJmlPreExpression(JmlPreExpression),
visitJmlOldExpression(JmlOldExpression)public void visitJmlResultExpression(JmlResultExpression self)
visitJmlResultExpression in interface JmlVisitorvisitJmlResultExpression in class TransExpression2private 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;
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 | ||||||||||