|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jmlspecs.jmlrac.qexpr.QInterval
A class for static approximations of the intervals for quantified
variables of integeral types. For example, the static approximation of
the interval for a quantified variable x with respect to
an expression x <= 0 && x >= 10 is
the interval between 0 and 10 including
both ends.
| Nested Class Summary | |
private static class |
QInterval.Bound
A class for representing tuples of JExpression objects
and int values. |
private static class |
QInterval.CheckRecursion
A class to check an appearance of local variables in an expression. |
| Field Summary | |
private List |
lower
a list of Bound objects representing the lower bound. |
private CType |
type
The type of the quantified variable. |
private List |
upper
a list of Bound objects representing the upper bound. |
private String |
var
the quantified variable name |
private Collection |
xvars
names of excluded variables |
| 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 | |
QInterval(JExpression expr,
String var,
Collection xvars,
CType type)
Construct a QInterval object representing the quantifed
interval for a (quantified) variable var with respect
to the expression expr. |
|
| Method Summary | |
private void |
calculate(JExpression expr)
Calculate the quantified interval with respect to the given expression. |
private static boolean |
isLocalVariable(JExpression expr,
String var)
Is the expression expr a local variable expression
consisting of variable named var? |
private RacNode |
transBound(VarGenerator varGen,
String var,
AbstractExpressionTranslator transExp,
QInterval.Bound bound,
int opr)
Returns code that evaluates the given lower or upper bound. |
RacNode |
translate(VarGenerator varGen,
String lowerVar,
String upperVar,
AbstractExpressionTranslator transExp)
Return Java source code that, if executed, evaluates the quantfied interval, i.e., its lower and upper bound values. |
private RacNode |
transLBound(VarGenerator varGen,
String var,
AbstractExpressionTranslator transExpr,
QInterval.Bound bound)
Returns code that evaluates the given lower bound. |
private RacNode |
transUBound(VarGenerator varGen,
String var,
AbstractExpressionTranslator transExpr,
QInterval.Bound bound)
Returns code that evaluates the given upper bound. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private List lower
Bound objects representing the lower bound.
private invariant (\forall Bound b; lower.contains(b); b.oper == OPE_LT || b.oper == OPE_LE);
private List upper
Bound objects representing the upper bound.
private invariant (\forall Bound b; upper.contains(b); b.oper == OPE_GT || b.oper == OPE_GE);
private String var
xvarsprivate Collection xvars
private invariant xvars.contains(var);
private CType type
| Constructor Detail |
public QInterval(JExpression expr,
String var,
Collection xvars,
CType type)
QInterval object representing the quantifed
interval for a (quantified) variable var with respect
to the expression expr.
The variables in xvars can't appear in the expressions
defining the interval for var.
requires xvars.contains(var);
| Method Detail |
private void calculate(JExpression expr)
modifies lower, upper;
private static boolean isLocalVariable(JExpression expr,
String var)
expr a local variable expression
consisting of variable named var?
private RacNode transLBound(VarGenerator varGen,
String var,
AbstractExpressionTranslator transExpr,
QInterval.Bound bound)
[T tvar = 0;] [[bound.expr, tvar]] [var = (T_of_var) tvar;] var = var + 1; // if bound.oper is <
private RacNode transUBound(VarGenerator varGen,
String var,
AbstractExpressionTranslator transExpr,
QInterval.Bound bound)
[T tvar = 0;] [[bound.expr, tvar]] [var = (T_of_var) tvar;] var = var + 1; // if bound.oper is >=
private RacNode transBound(VarGenerator varGen,
String var,
AbstractExpressionTranslator transExp,
QInterval.Bound bound,
int opr)
[T tvar = 0;] [[bound.expr, tvar]] [var = (T_of_var) tvar;] var = var + 1; // if bound.oper is opr
public RacNode translate(VarGenerator varGen,
String lowerVar,
String upperVar,
AbstractExpressionTranslator transExp)
throws NonExecutableQuantifierException
varGen - the variable generator to be used in the translation for
generating unique local variables.lowerVar - the variable name to refer to the lower bound value
in the translated code.upperVar - the variable name to refer to the upper bound value
in the translated code.transExp - the translator to use for translating JML expressions.
NonExecutableQuantifierException - if no interval
is found.
The translated code has the following form
(lowerVar <= qvar < upperVar):
[[l1, lowerVar]] lowerVar = lowerVar + 1; // if l1.oper is < T v = 0; [[li, v]] // for i=2, ..., n v = v + 1; // if li.oper is < lowerVar = Math.max(lowerVar, v); [[u1, upperVar]] upperVar = upperVar + 1; // if u1.oper is >= [[ui, v]] // for i=2, ..., n v = v + 1; // if ui.oper is >= upperVar = Math.min(upperVar, v);where li and ui are lower and upper bounds accumlated.
NonExecutableQuantifierException
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||