|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jmlspecs.jml4.rac.quantifiedexpression.QuantifiedExpressionTranslator
public class QuantifiedExpressionTranslator
An abstract class for translating JML quantified expressions into Java source code. The translation rules for the JML universal/existential quantified expressions are defined as follows.
[[(\forall T x; P; Q), r]] =
Collection c = null;
[[S, c]] // S is the qset of P ==> Q
r = c != null;
if (r) {
Iterator iter = c.iterator();
for (r && iter.hasNext()) {
T x = iter.next();
[[P ==> Q, r]]
}
}
[[(\exists T x; P; Q), r]] =
Collection c = null;
[[S, c]] // S is the qset of P && Q
r = c == null;
if (!r) {
Iterator iter = c.iterator();
for (!r && iter.hasNext()) {
T x = iter.next();
[[P && Q, r]]
}
}
The translation rules for other quantifiers are defined in a
similar way.
| Field Summary | |
|---|---|
PostStateExpressionTranslator |
transExp
translator for translating subexpressions |
| Constructor Summary | |
|---|---|
QuantifiedExpressionTranslator(VariableGenerator varGen,
RacContext context,
JmlQuantifiedExpression expr,
java.lang.String resultVar,
PostStateExpressionTranslator transExp,
RacResult racResult,
SourceTypeBinding typeBinding)
Constructs a new instance. |
|
| Method Summary | |
|---|---|
java.lang.String |
generateLoop(ASTNode node)
Tanslates a JML quantified expression into Java source code that, if executed, evaluates the given statement, node for each combination of bound variables of
the quantified expression. |
java.lang.String |
getLocalBindings()
|
java.lang.String |
getLocalVariables()
|
void |
getLocalVariablesInQuantifiedExpression(java.lang.String evaluatorPUse)
Fetches local variables in quantified expression. |
void |
setLocalBindings(java.lang.String str)
|
void |
setLocalVariables(java.lang.String str)
|
java.lang.String |
translate()
Translates a JML quantified expression into Java source code and return the translated code. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public PostStateExpressionTranslator transExp
| Constructor Detail |
|---|
public QuantifiedExpressionTranslator(VariableGenerator varGen,
RacContext context,
JmlQuantifiedExpression expr,
java.lang.String resultVar,
PostStateExpressionTranslator transExp,
RacResult racResult,
SourceTypeBinding typeBinding)
varGen - variable generator to be used during translation to
generate unique local variables.expr - quantified expression to be translated.resultVar - variable name to have the value of quantified
expression in the translated code.transExp - translator to use for translating subexpressions of
the quantified expression.racResult - data structure to store rac resultstypeBinding - SourceType| Method Detail |
|---|
public java.lang.String translate()
QuantifiedExpressionTranslator for the format of the generated
code.
if - the quantified expression is not executable.
public java.lang.String generateLoop(ASTNode node)
throws NonExecutableQuantifierException
node for each combination of bound variables of
the quantified expression. For example, given a quantified expression
(\forall int i;
i >= 0 && i < this.v.length;
this.v[i] >= \old(this.v[i]))
this method generates the following code:
int i = 0;
int l = this.v.length;
while (i < l) {
[[code for argument node]]
i = i + 1;
}
where l is a unique local variable generated by
the runtime assertion checker compiler.
This method is used in translating old expressions contained in
quantified expressions.
if - the quantified expression is not executable.
NonExecutableQuantifierExceptionTransPostcondition#visitJmlOldExpression(JmlOldExpression),
TransPostcondition#oldExpressionInQuantifiers(JmlOldExpression)public void getLocalVariablesInQuantifiedExpression(java.lang.String evaluatorPUse)
evaluatorPUse, and its binding is
LocalVariable type.
public void setLocalVariables(java.lang.String str)
public void setLocalBindings(java.lang.String str)
public java.lang.String getLocalVariables()
public java.lang.String getLocalBindings()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||