|
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
A RAC visitor class to translate JML expressions into Java source code. The generated code is a sequence of Java statements that evaluate the given expression and store the result into the given variable. The result variable is assumed to be declared in the outer scope that incorporates the code. Both the expression to be translated and the result variable is passed into as arguments of the constructors of this class.
Exceptions and Undefinedness A Java expression can throw an exception. In both mathematical and computational models, we must handle the undefinedness caused by exception. Ideally, we would like to deal with exceptions by having the evaluation of predicates substitute an arbitrary expressible value of the normal result type when an exception is thrown during evaluation [JML]. In practice, however, the runtime asserton checker must determine the definite value for top-level predicates to determine the truth of assertions, e.g., pre- and postcondition violations. There are at least threee possibilities to cope with this problem.
!E becomes true if
the boolean valued expression E throw an exception.
Nonexecutable Expressions A nonexecutable expression
poses a similar problem, and we take a similar approach. But in
this case, we take an angelic view. That is, a nonexecutable
subexpression is not interpreted if its result does not contribute
the truth of the top-level predicate. But if it does, it is
interpreted in such a way to making the truth of the top-level
predicate true. For example, a precondition of the form
"requires (* any informal description *);" is
interpreted as being satisfied.
| Nested Class Summary | |
static class |
TransExpression.DiagTerm
A class representing a term to be presented when an assertion is violated. |
private static class |
TransExpression.DynamicCallArg
A private data structure class for stroring information about arguments for dynamic calls. |
private static class |
TransExpression.StringAndNodePair
A private data structure class for stroring a pair of String and RacNode objects. |
| Field Summary | |
protected RacContext |
context
Current translation context. |
private Set |
diagTerms
The set of diagnostic terms. |
private static Object |
DT_RESULT
Special object to denote "\result" in the set of diagnostic terms. |
private static Object |
DT_THIS
Special object to denote "this" in the set of diagnostic terms. |
protected JExpression |
expression
Expression to translate. |
protected Stack |
paramStack
Stack for passing parameters to visitor methods. |
protected Stack |
resultStack
Stack for returning result from visitor methods. |
protected String |
resultVar
Variable to hold the reslt of the target expression. |
private boolean |
translated
Is the expression already translated? |
protected JTypeDeclarationType |
typeDecl
The type declaration within which this expression resides (the type of 'this'). |
protected VarGenerator |
varGen
Generator of unique variable names. |
| 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 | |
TransExpression(VarGenerator varGen,
RacContext ctx,
JExpression expr,
String resultVar,
JTypeDeclarationType typeDecl)
Constructs an instance and translates the given expression. |
|
| Method Summary | |
protected void |
addDiagTerm(Object term)
Adds the given term to the set of terms to be printed when the assertion is violated. |
protected void |
addDiagTermResult()
Adds "\result" to the set of terms to be printed when the assertion is violated. |
protected void |
addDiagTermThis()
Adds "this" to the set of terms to be printed when the assertion is violated. |
String |
applyArrayAccessExpression(String strVar,
CType typeAccessor,
CType typeNumber)
|
String |
applyCast(String v,
CType typeDest,
CType typeVar)
Returns a string that represents the Java code that casts v
of type typeVar to typeDest. |
static String |
applyOperator(String v1,
String v2,
String binOp,
CType type)
Returns a string that represents the Java code that applies the given operator, binOp, to the given operands, v1 and v2. |
static String |
applyOperator(String v,
String unaryOp,
CType type)
Returns a string that represents the Java code that applies the given operator, unaryOp, to the given operand v1. |
private TransExpression.DynamicCallArg |
argumentsForDynamicCall(JExpression[] args,
CSpecializedType[] ptypes)
Returns an object that contains information about translating arugments, args to a method call for making a
dynamic call. |
private TransExpression.StringAndNodePair |
argumentsForStaticCall(JExpression[] args,
String demvar,
String angvar)
Returns a pair of String and RacNode that is the translation of the given argument, args. |
protected void |
booleanNonExecutableExpression()
Translates a non-executable boolean expression. |
static boolean |
canMakeStaticCall(JClassFieldExpression expr,
String receiver)
Returns true if a static (non-dynamic) call can be made to the given field expression, expr. |
private RacNode |
checkUndefined(String demvar,
String angvar)
|
static String |
defaultValue(CType type)
Returns the default value of the type type. |
protected String |
diagTerms(String var)
Returns a string representation of Java statements that, if executed, prints the values of diagnostic terms accumulated so far and stores them to the given variable, var. |
protected String |
freshVar()
Returns a fresh variable name. |
protected String |
GET_ARGUMENT()
Returns the top element of the parameter stack. |
Object |
GET_RESULT()
Returns the top element of the result stack. |
protected RacNode |
guardUndefined(RacContext ctx,
RacNode stmt,
String var)
Returns a new RacNode that wraps the given
statement, stmt, inside a try-catch statement to
guard against undefinedness caused by runtime exceptions and
non-executable expression. |
private RacNode |
guardUndefined(RacContext ctx,
RacNode stmt,
CType restype,
String resvar,
String demvar,
String angvar)
|
protected boolean |
hasDiagTerms()
Returns true if there is any diagnostic terms accumulated. |
protected void |
initDiagTerms()
Initializes the set of terms to be printed when the assertion is violated. |
protected boolean |
isNonExecutableFieldReference(JClassFieldExpression expr)
Returns true if the referenced field (by the argument expression) is not executable. |
private static boolean |
isStatic(JClassFieldExpression expr)
Returns true if the given field expression refers to a static field. |
private static boolean |
isStatic(JMethodCallExpression expr)
Returns true if the given method call expression refers to a static method. |
private void |
needDynamicInvocationMethod()
Records that we need to generate the dynamic invocation method. |
protected void |
nonExecutableExpression()
Translates a non-executable non-boolean expression. |
private String |
optLHS(JMethodCallExpression expr,
String var)
Returns the optional left-hand-side of assignment statement to store the result of evaluation method call expression. |
protected String |
PEEK_ARGUMENT()
Peeks the top element of the parameter stack. |
protected void |
perform()
Translates the current expression into a sequence of Java statements that evaluate and store the result in the result variable. |
void |
PUT_ARGUMENT(Object obj)
Puts the given object to the parameter stack. |
private RacNode |
receiverForDynamicCall(JExpression expr)
Returns the receiver for executing the given expression, expr using a dynamic call. |
protected void |
RETURN_RESULT(Object obj)
Puts the given object to the result stack. |
static boolean |
specAccessorNeeded(long modifiers)
Returns true if the modifiers indicate that we need to generate specification-only accessor method. |
RacNode |
stmt()
Returns the result of translating the expression. |
protected String |
toString(CType type)
Returns the string representation of the given type. |
private RacNode |
transFieldReference(JClassFieldExpression self,
String resultVar,
String accPrefix)
Translates a class field expression that references a model, ghost, spec_public, or spec_protected field. |
protected RacNode |
translate(JPhylum node,
String var)
Translates an AST into Java statements. |
protected RacNode |
translate(JPhylum node,
String resvar,
String demvar,
String angvar)
Translates an AST into Java statements. |
void |
translateEquivalence(JmlRelationalExpression self)
Translates the given equivalence expression. |
void |
translateImplication(JmlRelationalExpression self)
Translates the given logical implication expression. |
void |
translateIsSubtypeOf(JmlRelationalExpression self)
Translates the given isSubtypeOf expression. |
private void |
translateNonExecutableFieldExpression(JClassFieldExpression expr)
Translates the given field expression that is determined to be non-executable. |
private RacNode |
translatePrimitiveType(CType type,
String var)
Translates the given primitive type. |
private void |
translateToDynamicCall(JMethodCallExpression expr,
boolean isModel)
Translates the given method call expression, expr, into a dynamic call expression. |
private void |
translateToDynamicNewObjectExpression(JNewObjectExpression expr,
boolean isSpecPublic)
Translates the given model, spec_public, or spec_protected constructor call expression, expr, which was
determined to be executed using a dynamic call. |
private void |
translateToNonexecutableCall(JMethodCallExpression expr)
Translates the given (model) method call into a non-executable method call. |
private void |
translateToStaticCall(JMethodCallExpression self,
long kind)
Translates the given method call expression into a static call. |
private void |
translateToStaticNewObjectExpression(JNewObjectExpression self,
boolean isSpecPublic)
Translates the given new object expression into a static call. |
private String |
transLocalVariable(JLocalVariableExpression self)
|
protected RacNode |
transPrefix(JExpression prefix,
String format)
Translates a prefix of a field or method call expression, build a RacNode using the given format, and return the
result. |
protected RacNode |
transPrefixSpec(JExpression prefix,
String format,
boolean addDelegee)
|
void |
visitAddExpression(JAddExpression self)
Translates an add expression. |
void |
visitArrayAccessExpression(JArrayAccessExpression self)
Translates a Java array access expression. |
void |
visitArrayDimsAndInit(JArrayDimsAndInits self)
visits an array dimension and initialization expression |
void |
visitArrayInitializer(JArrayInitializer self)
visits an array initializer expression |
void |
visitArrayLengthExpression(JArrayLengthExpression self)
Translates a Java array length expression. |
void |
visitAssignmentExpression(JAssignmentExpression self)
Translates a Java assignment expression. |
protected void |
visitBigintLiteral(long value)
Translates a \bigint literal. |
protected void |
visitBinaryExpression(JBinaryExpression self,
String oper)
Translates a binary expression of the given operator. |
void |
visitBitwiseExpression(JBitwiseExpression self)
Translates a Java bitwise AND, OR or XOR expression (|, & and ^). |
protected void |
visitBooleanBinaryExpression(JBinaryExpression self,
String oper)
Translates a binary expression of the given operator. |
void |
visitBooleanLiteral(JBooleanLiteral self)
Translates a boolean literal. |
protected void |
visitByteLiteral(byte value)
Translates a byte literal. |
void |
visitCastExpression(JCastExpression self)
Translates a Java cast expression. |
void |
visitCharLiteral(JCharLiteral self)
Translates a character literal. |
void |
visitClassExpression(JClassExpression self)
Translates a Java class expression. |
void |
visitCompoundAssignmentExpression(JAssignmentExpression self)
Translates a Java compound assignment expression. |
void |
visitConditionalAndExpression(JConditionalAndExpression self)
Translates a Java logical AND expression ( &&). |
void |
visitConditionalExpression(JConditionalExpression self)
Translates a Java conditional expression. |
void |
visitConditionalOrExpression(JConditionalOrExpression self)
Translates a Java logical OR expression ( ||). |
void |
visitDivideExpression(JDivideExpression self)
Translates a divide expression. |
protected void |
visitDoubleLiteral(double value)
Translates a double literal. |
void |
visitEqualityExpression(JEqualityExpression self)
Translates an equality expression. |
void |
visitExplicitConstructorInvocation(JExplicitConstructorInvocation self)
Translates an explicit constructor invocation |
void |
visitFieldExpression(JClassFieldExpression self)
Translates a Java field expression. |
protected void |
visitFloatLiteral(float value)
Translates a float literal. |
void |
visitInstanceofExpression(JInstanceofExpression self)
Translates a Java instanceof expression. |
protected void |
visitIntLiteral(int value)
Translates a int literal. |
void |
visitJmlElemTypeExpression(JmlElemTypeExpression self)
Translates the given JML \elemtype expression. |
void |
visitJmlFreshExpression(JmlFreshExpression self)
Translates a JML \fresh expression. |
void |
visitJmlInformalExpression(JmlInformalExpression self)
Translates a JML informal description expression. |
void |
visitJmlInvariantForExpression(JmlInvariantForExpression self)
Translates a JML invariant_for expression. |
void |
visitJmlIsInitializedExpression(JmlIsInitializedExpression self)
Translates a JML \is_initialized expression. |
void |
visitJmlLabelExpression(JmlLabelExpression self)
Translates a JML label expression. |
void |
visitJmlLockSetExpression(JmlLockSetExpression self)
Translates a JML \lockset expression. |
void |
visitJmlMaxExpression(JmlMaxExpression self)
|
void |
visitJmlNonNullElementsExpression(JmlNonNullElementsExpression self)
Translates a JML \nonnullelements expression. |
void |
visitJmlNotAssignedExpression(JmlNotAssignedExpression self)
Translates a JML \not_assigned expression. |
void |
visitJmlNotModifiedExpression(JmlNotModifiedExpression self)
Translates a JML \not_modified expression. |
void |
visitJmlOldExpression(JmlOldExpression self)
Translates a JML \old expression. |
void |
visitJmlPredicate(JmlPredicate self)
Translates the given JML predicate. |
void |
visitJmlPreExpression(JmlPreExpression self)
Translates a JML \pre expression. |
void |
visitJmlReachExpression(JmlReachExpression self)
Translates a JML \reach expression. |
void |
visitJmlRelationalExpression(JmlRelationalExpression self)
Translates a JML relational expression. |
void |
visitJmlResultExpression(JmlResultExpression self)
Translates a JML \result expression. |
void |
visitJmlSetComprehension(JmlSetComprehension self)
Translates a JML set comprehension expression. |
void |
visitJmlSpecExpression(JmlSpecExpression self)
Translates a JML specification expression. |
void |
visitJmlSpecQuantifiedExpression(JmlSpecQuantifiedExpression self)
Translates a JML quantified expression. |
void |
visitJmlTypeExpression(JmlTypeExpression self)
Translates a JML \type expression. |
void |
visitJmlTypeOfExpression(JmlTypeOfExpression self)
Translates a JML \typeof expression. |
void |
visitLocalVariableExpression(JLocalVariableExpression self)
Translates a Java local variable expression. |
protected void |
visitLongLiteral(long value)
Translates a long literal. |
void |
visitMethodCallExpression(JMethodCallExpression self)
Translates a Java method call expression. |
void |
visitMinusExpression(JMinusExpression self)
Translates a minus expression. |
void |
visitModuloExpression(JModuloExpression self)
Translates a modulo division expression. |
void |
visitMultExpression(JMultExpression self)
Translates a multiplication expression. |
void |
visitNameExpression(JNameExpression self)
Translates a Java name expression. |
void |
visitNewAnonymousClassExpression(JNewAnonymousClassExpression self)
Translates an object allocator expression for an anonymous class. |
void |
visitNewArrayExpression(JNewArrayExpression self)
Translates an array allocator expression. |
void |
visitNewObjectExpression(JNewObjectExpression self)
Translates a Java object allocator expression. |
void |
visitNullLiteral(JNullLiteral self)
Translates a null literal. |
void |
visitOrdinalLiteral(JOrdinalLiteral self)
Translates an ordinal literal. |
void |
visitParenthesedExpression(JParenthesedExpression self)
Translates a Java parenthesized expression. |
void |
visitPostfixExpression(JPostfixExpression self)
Translates a Java postfix expression. |
void |
visitPrefixExpression(JPrefixExpression self)
Translates a Java prefix expression. |
void |
visitRacPredicate(RacPredicate self)
Translates the given RAC predicate, a refinement of JML predicate. |
void |
visitRealLiteral(JRealLiteral self)
Translates a real literal. |
void |
visitRelationalExpression(JRelationalExpression self)
Translates a Java relational expression (<, <=, >, or >=). |
void |
visitShiftExpression(JShiftExpression self)
Translates a shift expression. |
protected void |
visitShortLiteral(short value)
Translates a short literal. |
void |
visitStringLiteral(JStringLiteral self)
Translates a string literal. |
void |
visitSuperExpression(JSuperExpression self)
Translates a Java super expression. |
void |
visitThisExpression(JThisExpression self)
Translates a Java this expression. |
void |
visitTypeNameExpression(JTypeNameExpression self)
Translates a Java type name expression |
void |
visitUnaryExpression(JUnaryExpression self)
Translates a Java unary expression. |
void |
visitUnaryPromoteExpression(JUnaryPromote self)
Translates a Java unary promotion expression. |
static void |
warn(TokenReference tref,
MessageDescription description,
Object obj)
Produce a warning message with the given token reference, message description, and argument to message description. |
protected RacNode |
wrapBooleanResult(RacNode argEval,
String stmt,
String resVar,
String demVar,
String angVar)
|
protected RacNode |
wrapBooleanResultTC(RacNode argEval,
String stmt,
String resVar,
String demVar,
String angVar)
|
RacNode |
wrappedStmt(String eval,
String nval)
Returns the result of translating the expression wrapped in a try-catch statement to assign the given default values if an exception or non-executability happens while evaluating the 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 Set diagTerms
private invariant (\forall Object o; diagTerms.contains(o); (o instanceof JFormalParameter) || (o instanceof String) || (o instanceof JmlVariableDefinition) || o == DT_THIS || o == DT_RESULT);
private static final Object DT_THIS
private static final Object DT_RESULT
protected VarGenerator varGen
protected String resultVar
protected Stack paramStack
protected Stack resultStack
protected RacContext context
protected JExpression expression
protected JTypeDeclarationType typeDecl
private boolean translated
| Constructor Detail |
public TransExpression(VarGenerator varGen,
RacContext ctx,
JExpression expr,
String resultVar,
JTypeDeclarationType typeDecl)
varGen - variable generator to be used for generating
fresh variable names necessary in the translated code.expr - expression to be translated.resultVar - variable to store the result. In the translated code,
the result of the expression is stored in the variable whose
name given by this parameter.| Method Detail |
public RacNode stmt()
normal_behavior assignable translated; ensures \fresh(\result) && \result != null && (* \result is the translation result *);
#wrappedStmt()
public RacNode wrappedStmt(String eval,
String nval)
try {
[[E, r]]
} catch (JMLNonExecutableException e) {
r = nval;
} catch (Exception e) {
r = eval;
}
where E is the target expression to translate and
r is the variable to hold the result of the expression.
normal_behavior assignable translated; ensures \fresh(\result) && \result != null && (* \result is a try-catch statement wrapping translation result *);
eval - default value for exceptions.
If the given expression (or one of its subexpressions) throws an
exception during evaluation, the value given by this parameter
is used as the result.nval - default value for non-executable expressions.
stmt()protected void perform()
requires !translated; assignable translated; ensures translated && (* translation is performed *); also requires translated; ensures (* no translation is performed *);
public void visitRacPredicate(RacPredicate self)
[[P, r]] =
[[expr(P), r]]
if (!r) {
VN_ERROR_SET.add(loc(P));
}
where expr(P) denotes the unwrapped JML
specification expression of P,
VN_ERROR_SET is a variable name for keeping track
of violated assertions and loc(P) denotes the
location that the predicate P appears in the
source file.
visitRacPredicate in interface RacVisitorvisitRacPredicate in class RacAbstractVisitorpublic void visitJmlPredicate(JmlPredicate self)
[[P, r]] = [[expr(P), r]]where
expr(P) denotes the unwrapped JML
specification expression of P.
visitJmlPredicate in interface JmlVisitorvisitJmlPredicate in class JmlAbstractVisitorpublic void visitJmlSpecExpression(JmlSpecExpression self)
[[E, r]] = [[expr(E), r]]where
expr(E) denotes the unwrapped Java
expression of E.
visitJmlSpecExpression in interface JmlVisitorvisitJmlSpecExpression in class JmlAbstractVisitorpublic void visitJmlNonNullElementsExpression(JmlNonNullElementsExpression self)
\nonnullelements expression. The
translation rule for this expression is defined as follows.
[[\nonnullelements(E), r]] =
T_E v = d_T_E;
[[E, v]]
r = v != null;
if (r) {
for (int i = 0; r && i < v.length; i++) {
r = v[i] != null;
}
}
where T_E is the type of expression E
and d_T_E is the default value of the type
T_E.
visitJmlNonNullElementsExpression in interface JmlVisitorvisitJmlNonNullElementsExpression in class JmlAbstractVisitorpublic void visitJmlElemTypeExpression(JmlElemTypeExpression self)
\elemtype expression. The
translation rule for this expression is defined as follows
(thanks to Erik Poll) - adjusted DRC.
[[\elemtype(E)), r]] =
r = [[E]].getComponentType();
visitJmlElemTypeExpression in interface JmlVisitorvisitJmlElemTypeExpression in class JmlAbstractVisitorpublic void visitJmlNotModifiedExpression(JmlNotModifiedExpression self)
\not_modified expression. The
translation rules for this expression is defined as follows.
[[\not_modified(E)), r]] = \not_executable
visitJmlNotModifiedExpression in interface JmlVisitorvisitJmlNotModifiedExpression in class JmlAbstractVisitorpublic void visitJmlNotAssignedExpression(JmlNotAssignedExpression self)
\not_assigned expression. The
translation rules for this expression is defined as follows.
[[\not_assigned(E)), r]] = \not_executable
visitJmlNotAssignedExpression in interface JmlVisitorvisitJmlNotAssignedExpression in class JmlAbstractVisitorpublic void visitJmlFreshExpression(JmlFreshExpression self)
\fresh expression. The translation
rules for this expression is defined as follows.
[[\fresh(E)), r]] = \not_executable
visitJmlFreshExpression in interface JmlVisitorvisitJmlFreshExpression in class JmlAbstractVisitorpublic void visitJmlInformalExpression(JmlInformalExpression self)
[[(* ... *), r]] = \not_executable
visitJmlInformalExpression in interface JmlVisitorvisitJmlInformalExpression in class JmlAbstractVisitorpublic void visitJmlInvariantForExpression(JmlInvariantForExpression self)
invariant_for expression. The
translation rules for this expression is defined as follows.
[[\invariant_for(E), r]] =
T_E v = d_T_E;
[[E, v]]
r = v.inv();
where inv() is the invariant method of type
T_E. A special treatment is required if
v is null.
visitJmlInvariantForExpression in interface JmlVisitorvisitJmlInvariantForExpression in class JmlAbstractVisitorpublic void visitJmlIsInitializedExpression(JmlIsInitializedExpression self)
\is_initialized expression. The
translation rules for this expression is defined as follows.
[[\is_initialized(T), r]] =
try {
r = T.class.getDeclaredField(VN_RAC_COMPILED).getBoolean(null);
} catch (Exception e) {
r = true;
}
visitJmlIsInitializedExpression in interface JmlVisitorvisitJmlIsInitializedExpression in class JmlAbstractVisitorpublic void visitJmlLabelExpression(JmlLabelExpression self)
[[(\lblneg n E), r]] = [[E, r]] [[(\lblpos n E), r]] = [[E, r]]Though not shown in the translation rule, the label of the given expression is added to VN_ERROR_SET if the expression does not (or does) hold depending on the kind of label.
visitJmlLabelExpression in interface JmlVisitorvisitJmlLabelExpression in class JmlAbstractVisitorpublic void visitJmlLockSetExpression(JmlLockSetExpression self)
\lockset expression. The
translation rules for this expression is defined as follows.
[[\lockset, r]] = \not_executable
visitJmlLockSetExpression in interface JmlVisitorvisitJmlLockSetExpression in class JmlAbstractVisitorpublic void visitJmlOldExpression(JmlOldExpression self)
\old expression. The translation
rules for this expression is defined as follows.
[[\old(E), r]] =
r = v;
with an insertion of T_E v = d_T_E; [[E, v]]
into the method prolog.
visitJmlOldExpression in interface JmlVisitorvisitJmlOldExpression in class JmlAbstractVisitorTransPostcondition,
TransOldExpressionpublic void visitJmlPreExpression(JmlPreExpression self)
\pre expression. The translation
rules for this expression is defined as follows.
[[\pre(E), r]] =
r = v;
with an insertion of T_E v = d_T_E; [[E, v]]
into the method prolog.
visitJmlPreExpression in interface JmlVisitorvisitJmlPreExpression in class JmlAbstractVisitorTransPostcondition,
TransOldExpressionpublic void visitJmlReachExpression(JmlReachExpression self)
\reach expression. The
translation rules for this expression is defined as follows.
[[\reach(E), r]] = \not_executable
visitJmlReachExpression in interface JmlVisitorvisitJmlReachExpression in class JmlAbstractVisitorpublic void visitJmlResultExpression(JmlResultExpression self)
\result expression. The translation
rules for this expression is defined as follows.
[[\result, r]] =
r = result;
where the variable result is used to capture the
return value of the method. The statement T result =
d_T; gets inserted into the method prolog, where
T is the return type of the method.
visitJmlResultExpression in interface JmlVisitorvisitJmlResultExpression in class JmlAbstractVisitorTransPostconditionpublic void visitJmlSetComprehension(JmlSetComprehension self)
[[new S { T x | E.has(x) && P}, r]] =
T_E c = null;
[[E, c]]
r = new S();
Iterator iter = c.iterator();
for (iter.hasNext()) {
T x = iter.next();
boolean b = false;
[[P, b]]
if (b) {
r.add(x);
}
}
visitJmlSetComprehension in interface JmlVisitorvisitJmlSetComprehension in class JmlAbstractVisitorpublic void visitJmlSpecQuantifiedExpression(JmlSpecQuantifiedExpression self)
[[(\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]]
}
}
visitJmlSpecQuantifiedExpression in interface JmlVisitorvisitJmlSpecQuantifiedExpression in class JmlAbstractVisitorpublic void visitJmlTypeExpression(JmlTypeExpression self)
\type expression. If the
expression is of primitive types, the result is the Java
predefined Class object representing the primitive
type, e.g., Integer.TYPE for int.
Otherwise, the following translation rule is applied.
[[\type(E), r]] =
r = E.class;
visitJmlTypeExpression in interface JmlVisitorvisitJmlTypeExpression in class JmlAbstractVisitor
private RacNode translatePrimitiveType(CType type,
String var)
int, the result is "var = Integer.TYPE;".
requires type != null && type.isPrimitive() && var != null; ensures \result != null;
public void visitJmlTypeOfExpression(JmlTypeOfExpression self)
\typeof expression. If the
expression is of primitive types, the result is the Java
predefined Class object representing the primitive
type, e.g., Integer.TYPE for int.
Otherwise, the following translation rule is applied.
[[\typeof(E), r]] =
T v;
[[E, v]]
if (v == null)
r = java.lang.Object; // !FIXME!\typeof(null)
else
r = v.getClass();
visitJmlTypeOfExpression in interface JmlVisitorvisitJmlTypeOfExpression in class JmlAbstractVisitorpublic void visitJmlMaxExpression(JmlMaxExpression self)
visitJmlMaxExpression in interface JmlVisitorvisitJmlMaxExpression in class JmlAbstractVisitorpublic void visitAssignmentExpression(JAssignmentExpression self)
visitAssignmentExpression in interface MjcVisitorvisitAssignmentExpression in class JmlAbstractVisitorpublic void visitCompoundAssignmentExpression(JAssignmentExpression self)
public void visitConditionalExpression(JConditionalExpression self)
[[E1 ? E2 : E3, r]] =
boolean v = false;
[[E1, v]]
if (v1) {
[[E2, r]]
}
else {
[[E3, r]]
}
visitConditionalExpression in interface MjcVisitorvisitConditionalExpression in class JmlAbstractVisitorpublic void visitJmlRelationalExpression(JmlRelationalExpression self)
[[E1 <: E2, r]] =
Class v1 = null;
Class v2 = null;
[[E1, v1]]
[[E2, v2]]
r = v2.isisAssignableFrom(v1);
Otherwise (i.e., for <==>, <=!=>,
==>, and <==, the following
translation rule is used.
[[E1 op E2, r]] =
boolean v1 = false;
boolean v2 = false;
[[E1, v1]]
[[E2, v2]]
r = [[v1,v2,op]];
where the translation [[v1,v2,op]] is defined as
follow.
v1 <==> v2 = v1 == v2 v1 <=!=> v2 = v1 != v2 v1 ==> v2 = v1 ? v2 : true v1 <== v2 = v2 ? v1 : trueNote: there is also the case of comparing locks with < or <=
visitJmlRelationalExpression in interface JmlVisitorvisitJmlRelationalExpression in class JmlAbstractVisitorpublic void translateIsSubtypeOf(JmlRelationalExpression self)
requires self.isSubtypeOf();
protected RacNode wrapBooleanResult(RacNode argEval,
String stmt,
String resVar,
String demVar,
String angVar)
protected RacNode wrapBooleanResultTC(RacNode argEval,
String stmt,
String resVar,
String demVar,
String angVar)
public void translateImplication(JmlRelationalExpression self)
requires self.isImplication() || self.isBackwardImplication();
public void translateEquivalence(JmlRelationalExpression self)
requires self.isEquivalence() || self.isNonEquivalence();
public void visitConditionalAndExpression(JConditionalAndExpression self)
&&). The
translation rule for the logical AND expression is defined as
follow.
[[E1 && E2, r]] =
[[E1, r]]
if (r) {
[[E2, r]]
}
visitConditionalAndExpression in interface MjcVisitorvisitConditionalAndExpression in class JmlAbstractVisitor
private RacNode checkUndefined(String demvar,
String angvar)
public void visitConditionalOrExpression(JConditionalOrExpression self)
||). The
translation rule for the logical OR expression is defined as
follow.
[[E1 || E2, r]] =
[[E1, r]]
if (!r) {
[[E2, r]]
}
visitConditionalOrExpression in interface MjcVisitorvisitConditionalOrExpression in class JmlAbstractVisitorpublic void visitBitwiseExpression(JBitwiseExpression self)
[[E1 opr E2, r]] =
T_E1 v1 = d_T_E1;
T_E2 v2 = d_T_E2;
[[E1, v1]]
[[E2, v2]]
r = v1 opr v2;
visitBitwiseExpression in interface MjcVisitorvisitBitwiseExpression in class JmlAbstractVisitorpublic void visitEqualityExpression(JEqualityExpression self)
[[E1 opr E2, r]] =
T_E1 v1 = d_T_E1;
T_E2 v2 = d_T_E2;
[[E1, v1]]
[[E2, v2]]
r = v1 opr v2;
visitEqualityExpression in interface MjcVisitorvisitEqualityExpression in class JmlAbstractVisitor
public static String applyOperator(String v1,
String v2,
String binOp,
CType type)
binOp, to the given operands, v1 and v2. This
method handles both relational and arithmetic operators. When
type is not Bigint this is simple: e.g. with "+", "1" and
"2" as values for binOp, v1 and v2 respectively, the return value will
be "1 + 2". Special treatment is done to appropriately handle Bigint
expressions -- e.g. for addition the equivalent of "v1.add(v2)" is
returned.
visitBinaryExpression(org.multijava.mjc.JBinaryExpression, java.lang.String)public void visitRelationalExpression(JRelationalExpression self)
[[E1 opr E2, r]] =
try {
T_E1 v1 = d_T_E1;
T_E2 v2 = d_T_E2;
[[E1, v1]]
[[E2, v2]]
r = v1 opr v2;
}
catch (Exception e) {
r = false;
}
visitRelationalExpression in interface MjcVisitorvisitRelationalExpression in class JmlAbstractVisitorpublic void visitInstanceofExpression(JInstanceofExpression self)
[[E1 instanceof T, r]] =
try {
T_E1 v = d_T_E1;
[[E1, v]]
r = v instanceof T;
}
catch (Exception e) {
r = false;
}
visitInstanceofExpression in interface MjcVisitorvisitInstanceofExpression in class JmlAbstractVisitor
protected void visitBinaryExpression(JBinaryExpression self,
String oper)
visitBinaryExpression in class JmlAbstractVisitor
protected void visitBooleanBinaryExpression(JBinaryExpression self,
String oper)
public void visitAddExpression(JAddExpression self)
visitAddExpression in interface MjcVisitorvisitAddExpression in class JmlAbstractVisitorpublic void visitMinusExpression(JMinusExpression self)
visitMinusExpression in interface MjcVisitorvisitMinusExpression in class JmlAbstractVisitorpublic void visitMultExpression(JMultExpression self)
visitMultExpression in interface MjcVisitorvisitMultExpression in class JmlAbstractVisitorpublic void visitDivideExpression(JDivideExpression self)
visitDivideExpression in interface MjcVisitorvisitDivideExpression in class JmlAbstractVisitorpublic void visitModuloExpression(JModuloExpression self)
visitModuloExpression in interface MjcVisitorvisitModuloExpression in class JmlAbstractVisitorpublic void visitShiftExpression(JShiftExpression self)
visitShiftExpression in interface MjcVisitorvisitShiftExpression in class JmlAbstractVisitorpublic void visitPrefixExpression(JPrefixExpression self)
visitPrefixExpression in interface MjcVisitorvisitPrefixExpression in class JmlAbstractVisitorpublic void visitPostfixExpression(JPostfixExpression self)
visitPostfixExpression in interface MjcVisitorvisitPostfixExpression in class JmlAbstractVisitorpublic void visitUnaryExpression(JUnaryExpression self)
+,
-, ~, and !. The
translation rules for this expression is defined as follows.
[[opr E, r]] =
[[E, r]]
r = opr r;
We need a special treatment for the operator ! to change
the default return value used if there occurrs an exception while
evaluating a subexpression.
- Specified by:
visitUnaryExpression in interface MjcVisitor- Overrides:
visitUnaryExpression in class JmlAbstractVisitor
public static String applyOperator(String v,
String unaryOp,
CType type)
unaryOp, to the given operand v1.
TransExpression#applyOperator(String v1, String v2, String
binOp, CType type),
visitUnaryExpression(org.multijava.mjc.JUnaryExpression)public void visitCastExpression(JCastExpression self)
[[(T) E, r]] =
T_E v = d_T_E;
[[E, v]]
r = (T) v;
visitCastExpression in interface MjcVisitorvisitCastExpression in class JmlAbstractVisitor
public String applyCast(String v,
CType typeDest,
CType typeVar)
v
of type typeVar to typeDest.
visitCastExpression(org.multijava.mjc.JCastExpression)public void visitUnaryPromoteExpression(JUnaryPromote self)
visitUnaryPromoteExpression in interface MjcVisitorvisitUnaryPromoteExpression in class JmlAbstractVisitorpublic void visitMethodCallExpression(JMethodCallExpression self)
[[E0.m(E1, ..., En), r]] =
T_E0 v0 = d_T_E0;
T_E1 v1 = d_T_E1;
...
T_En vn = d_T_En;
[[E0, v0]]
[[E1, v1]]
...
[[En, vn]]
r = v0.m(v1, ..., vn);
If the referenced method, m, is an effectively
model method (including the ones declared in model types),
there are three possibilities. If the method is not executable
(i.e., has no body), then the method call expression is
translated into an angelic undefinedness. Otherwise, the
expression is translated into either a static or dynamic call
to the model method. If the model method is declared in the
same class or interface where the assertion being translated in
specified, then static call is used; otherwise, dynamic call is
used.
A spec_public or spec_protected method call expression is always executable, and is translated into either a dynamic or static call.
visitMethodCallExpression in interface MjcVisitorvisitMethodCallExpression in class JmlAbstractVisitorTransType.dynamicCallNeeded(CClass),
translateToDynamicCall(JMethodCallExpression, boolean),
translateToNonexecutableCall(JMethodCallExpression),
#tranlateToStaticCall(JMethodCallExpression, int),
addDiagTermThis(),
visitNewObjectExpression(JNewObjectExpression)private void translateToNonexecutableCall(JMethodCallExpression expr)
visitMethodCallExpression(JMethodCallExpression)
private void translateToStaticCall(JMethodCallExpression self,
long kind)
kind, is ACC_MODEL, the
given expression is assumed to be a model method call
expression that can be translated into a static call (e.g.,
called in the same type where the method is declared). In such
a case, the expression is translated into a call to the
appropriate surrogate object if the called model method is
declared in an interface. If the argument, kind,
is ACC_SPEC_PUBLIC, the given expression is assumed to be a
spec_public method call expression, for which we have to call
the corresponding access method. Otherwise, it is assumed to be
a regular method call expression.
requires self != null; requires kind == ACC_MODEL || kind == ACC_SPEC_PUBLIC || kind == 0;
visitMethodCallExpression(JMethodCallExpression)
private RacNode guardUndefined(RacContext ctx,
RacNode stmt,
CType restype,
String resvar,
String demvar,
String angvar)
private String optLHS(JMethodCallExpression expr,
String var)
var + " = " is
returned.
private TransExpression.StringAndNodePair argumentsForStaticCall(JExpression[] args,
String demvar,
String angvar)
args. The string of the pair
has the form: "(v1, v2, ..., vn)", and the node
has the form: T1 v1 = E1; ...; Tn vn = En;, where
Ei is the i-th element of the argument
args. The variable vi is a fresh new
variable. If the argument, args, is null or an
empty array, the string of the pair is "()" and
the node is null. The result is always non-null.
ensures \result != null;
protected RacNode transPrefix(JExpression prefix,
String format)
RacNode using the given format, and return the
result. The returned code has the following form:
T v = T_init; [[code for eval prefix and assigning to v]] format[v/$0]
requires prefix != null && format != null; ensures \result != null;
prefix - the prefix to be translated.format - the format to build the return value out of
the translated prefix; it is usually of the form:
"r = $0.m(x1, ..., xn);" or
"r = $0.f;.visitMethodCallExpression(org.multijava.mjc.JMethodCallExpression),
visitFieldExpression(org.multijava.mjc.JClassFieldExpression),
#transPrefix(JExpression, String, CClass, isModel)
protected RacNode transPrefixSpec(JExpression prefix,
String format,
boolean addDelegee)
private void translateToDynamicCall(JMethodCallExpression expr,
boolean isModel)
expr, into a dynamic call expression. If the
argument, isModel, is true, it is treated as a
call to a model method, thus; otherwise, it is treated as a
call to a spec_public or spec_protected method. This flag is
used to determine appropriate access methods.
visitMethodCallExpression(JMethodCallExpression)
private TransExpression.DynamicCallArg argumentsForDynamicCall(JExpression[] args,
CSpecializedType[] ptypes)
args to a method call for making a
dynamic call. The argument, ptypes, is supposed to
be the parameter types of the called method. The field
node of the returned object has code of the form:
T1 v1 = E1; ...; Tn vn = En;, where
Ei is the i-th element of the argument
args. The field types has the form: "
"new Class[] { T1, ..., Tn }", where
Ti is the i-th parameter type, and the field
args has the form: "new Object[] { v1, ...,
vn }"."(v1, v2, ..., vn)". The variable vi
is a fresh new variable. If the argument, args, is
null or an empty array, the node field becomes null and the
other two fields become "new Class[] {}" and
"new Object[] {}" respectively. The result is
always non-null.
ensures \result != null;
translateToDynamicCall(JMethodCallExpression, boolean),
translateToDynamicNewObjectExpression(JNewObjectExpression,boolean),
#DynamicCallArgprivate RacNode receiverForDynamicCall(JExpression expr)
expr using a dynamic call. The argument is
supposed to be either a non-static JClassFieldExpression
referring to a model, ghost, spec_public, or spec_protected
field or a non-static JMethodCallExpression calling a
spec_public or spec_protected method. If the receiver is
"this", a null value is returned; otherwise, the returned
source code, if executed, evaluates the receiver and assign it
to the fresh variable whose name is given by the name field of
RacNode.
requires expr != null && expr instanceof JMethodCallExpression && expr instanceof JClassFieldExpression;
public void visitTypeNameExpression(JTypeNameExpression self)
visitTypeNameExpression in interface MjcVisitorvisitTypeNameExpression in class JmlAbstractVisitorpublic void visitThisExpression(JThisExpression self)
[[E.this, r]] =
r = E.this;
In an interface, however, "this" is translated into the private
delegee field of the surrogate class.
visitThisExpression in interface MjcVisitorvisitThisExpression in class JmlAbstractVisitorpublic void visitSuperExpression(JSuperExpression self)
[[super, r]] =
r = super;
visitSuperExpression in interface MjcVisitorvisitSuperExpression in class JmlAbstractVisitorpublic void visitClassExpression(JClassExpression self)
[[T.class, r]] =
r = T.class;
visitClassExpression in interface MjcVisitorvisitClassExpression in class JmlAbstractVisitorpublic void visitExplicitConstructorInvocation(JExplicitConstructorInvocation self)
visitExplicitConstructorInvocation in interface MjcVisitorvisitExplicitConstructorInvocation in class JmlAbstractVisitorpublic void visitArrayLengthExpression(JArrayLengthExpression self)
[[E.length, r]] =
T_E v = d_T_E;
[[E, v]]
r = v.length;
visitArrayLengthExpression in interface MjcVisitorvisitArrayLengthExpression in class JmlAbstractVisitorpublic void visitArrayAccessExpression(JArrayAccessExpression self)
[[E1[E2], r]] =
T_E1 v1 = d_T_E1;
T_E2 v2 = d_T_E2;
[[E1, v1]]
[[E2, v2]]
r = v1[v2];
visitArrayAccessExpression in interface MjcVisitorvisitArrayAccessExpression in class JmlAbstractVisitor
public String applyArrayAccessExpression(String strVar,
CType typeAccessor,
CType typeNumber)
public void visitNameExpression(JNameExpression self)
[[n, r]] =
r = n;
visitNameExpression in interface MjcVisitorvisitNameExpression in class JmlAbstractVisitorpublic void visitLocalVariableExpression(JLocalVariableExpression self)
[[x, r]] =
r = x;
visitLocalVariableExpression in interface MjcVisitorvisitLocalVariableExpression in class JmlAbstractVisitorprivate String transLocalVariable(JLocalVariableExpression self)
public void visitParenthesedExpression(JParenthesedExpression self)
[[(E), r]] = [[E, r]]
visitParenthesedExpression in interface MjcVisitorvisitParenthesedExpression in class JmlAbstractVisitorpublic void visitNewObjectExpression(JNewObjectExpression self)
[[new T(E1, ..., En), r]] =
T_E1 v1 = d_T_E1;
...
T_En vn = d_T_En;
[[E1, v1]]
...
[[En, vn]]
r = new T(v1, ..., vn);
If the referenced constructor is effectively model (including
constructors declared in model types), there are three
possibilities. If the constructor is not executable (i.e., has
no body), then the expression is translated into an angelic
undefinedness. Otherwise, the expression is translated into
either a static or dynamic call to the model constructor. If
the model constructor comes from the same class or interface
where the assertion being translated in specified, then static
call is used; otherwise, dynamic call is used.
A spec_public or spec_protected constructor is always executable, and is translated into either a dynamic or static call.
visitNewObjectExpression in interface MjcVisitorvisitNewObjectExpression in class JmlAbstractVisitorTransType.dynamicCallNeeded(CClass),
nonExecutableExpression(),
translateToStaticNewObjectExpression(JNewObjectExpression,boolean),
translateToDynamicNewObjectExpression(JNewObjectExpression,boolean),
visitMethodCallExpression(JMethodCallExpression)
private void translateToStaticNewObjectExpression(JNewObjectExpression self,
boolean isSpecPublic)
isSpecPublic, is false, the
translated code has the form:
T1 v1 = E1; ...; Tn vn = En; result = new T(v1, ..., vn);Otherwise, the translated code has the following form:
T1 v1 = E1; ...; Tn vn = En; result = MN_SPEC_PUBLIC$T(v1, ..., vn);
private void translateToDynamicNewObjectExpression(JNewObjectExpression expr,
boolean isSpecPublic)
expr, which was
determined to be executed using a dynamic call. If the
argument, isSpecPublic, is true, the new
expression is for a spec_public or spec_protected constructor;
otherwise, it is for a model constructor.
public void visitNewAnonymousClassExpression(JNewAnonymousClassExpression self)
visitNewAnonymousClassExpression in interface MjcVisitorvisitNewAnonymousClassExpression in class JmlAbstractVisitorpublic void visitNewArrayExpression(JNewArrayExpression self)
visitNewArrayExpression in interface MjcVisitorvisitNewArrayExpression in class JmlAbstractVisitorpublic void visitArrayDimsAndInit(JArrayDimsAndInits self)
MjcVisitor
visitArrayDimsAndInit in interface MjcVisitorvisitArrayDimsAndInit in class JmlAbstractVisitorpublic void visitArrayInitializer(JArrayInitializer self)
MjcVisitor
visitArrayInitializer in interface MjcVisitorvisitArrayInitializer in class JmlAbstractVisitorpublic void visitFieldExpression(JClassFieldExpression self)
[[E.x, r]] =
T_E v = d_T_E;
[[E, v]]
r = v;
If the referenced field is a model field, generates a model
method call instead.
visitFieldExpression in interface MjcVisitorvisitFieldExpression in class JmlAbstractVisitortransPrefix(org.multijava.mjc.JExpression, java.lang.String)protected boolean isNonExecutableFieldReference(JClassFieldExpression expr)
private void translateNonExecutableFieldExpression(JClassFieldExpression expr)
private RacNode transFieldReference(JClassFieldExpression self,
String resultVar,
String accPrefix)
[[e.x, r]] ==
T_e v = init_T_e;
[[e, v]]
Object o = rac$invoke(C, v, x$C, null, null);
if (o == null) {
throw new JMLNonExecutableException();
}
r = (T)o;
where C is the name of class where x is
declared and T is the type of x.
requires self != null && resultVar != null;
public static boolean canMakeStaticCall(JClassFieldExpression expr,
String receiver)
expr. The given expression
is assumed to be a reference to a model, ghost, spec_public, or
spec_protected field.
private static boolean isStatic(JClassFieldExpression expr)
private static boolean isStatic(JMethodCallExpression expr)
public void visitBooleanLiteral(JBooleanLiteral self)
visitBooleanLiteral in interface MjcVisitorvisitBooleanLiteral in class JmlAbstractVisitorpublic void visitCharLiteral(JCharLiteral self)
visitCharLiteral in interface MjcVisitorvisitCharLiteral in class JmlAbstractVisitorpublic void visitOrdinalLiteral(JOrdinalLiteral self)
visitOrdinalLiteral in interface MjcVisitorvisitOrdinalLiteral in class JmlAbstractVisitorprotected void visitByteLiteral(byte value)
visitByteLiteral in class JmlAbstractVisitorprotected void visitIntLiteral(int value)
visitIntLiteral in class JmlAbstractVisitorprotected void visitLongLiteral(long value)
visitLongLiteral in class JmlAbstractVisitorprotected void visitBigintLiteral(long value)
protected void visitShortLiteral(short value)
visitShortLiteral in class JmlAbstractVisitorpublic void visitRealLiteral(JRealLiteral self)
visitRealLiteral in interface MjcVisitorvisitRealLiteral in class JmlAbstractVisitorprotected void visitDoubleLiteral(double value)
visitDoubleLiteral in class JmlAbstractVisitorprotected void visitFloatLiteral(float value)
visitFloatLiteral in class JmlAbstractVisitorpublic void visitStringLiteral(JStringLiteral self)
visitStringLiteral in interface MjcVisitorvisitStringLiteral in class JmlAbstractVisitorpublic void visitNullLiteral(JNullLiteral self)
visitNullLiteral in interface MjcVisitorvisitNullLiteral in class JmlAbstractVisitorprotected void nonExecutableExpression()
throw new JMLNonExectutableException();. The
result variable is popped from the parameter stack and the
generated RacNode object is pushed ont the result
stack.
protected void booleanNonExecutableExpression()
true or
false depending on the current polarity of
translation. The result variable is popped from the parameter
stack and the generated RacNode object is pushed
ont the result stack.
private void needDynamicInvocationMethod()
public static boolean specAccessorNeeded(long modifiers)
ensures \result == (hasFlag(modifiers, ACC_PRIVATE) && (hasFlag(modifiers, ACC_SPEC_PUBLIC) || hasFlag(modifiers, ACC_SPEC_PROTECTED)));
protected RacNode translate(JPhylum node,
String var)
protected RacNode translate(JPhylum node,
String resvar,
String demvar,
String angvar)
protected RacNode guardUndefined(RacContext ctx,
RacNode stmt,
String var)
RacNode that wraps the given
statement, stmt, inside a try-catch statement to
guard against undefinedness caused by runtime exceptions and
non-executable expression. The statement is supposed to store
some value to the variable named var.
public static String defaultValue(CType type)
type.
protected String toString(CType type)
JmlStdType.TYPE, the result is
"java.lang.Class"; otherwise it is
value.toString().
TransUtils.toString(CType)protected String freshVar()
protected String GET_ARGUMENT()
protected String PEEK_ARGUMENT()
public void PUT_ARGUMENT(Object obj)
public Object GET_RESULT()
protected void RETURN_RESULT(Object obj)
public static void warn(TokenReference tref,
MessageDescription description,
Object obj)
protected void initDiagTerms()
protected void addDiagTerm(Object term)
protected void addDiagTermThis()
protected void addDiagTermResult()
protected boolean hasDiagTerms()
protected String diagTerms(String var)
var. The returned statements also declares the
variable var. If there is no diagnostic terms
accumulated so far, then an empty string is returned.
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||