|
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.JmlContext
org.jmlspecs.checker.JmlExpressionContext
A class for representing the context in which JML expressions are typechecked. This is a subclass of the CExpressionContextType class to encode the JML expression-specific contextual information. For example, the JML \result expression is allowed only in the normal postcondition. To typecheck the expressions such as \result, we pass to them the fact whether they are being typechecked in the normal postcondition or not as contexutal information. In JML, there are seven context(state)-sensitive expression constructs: \fresh, \not_modified, \old, \result, \duration, \working_space, and \space. The typechecking rules for these constructs are defined as follows. In the table, the entry with O means that a particular construct is allowed in that particular context, and the X marks prohibition.
--------------------------------------------------------
\not_
\fresh modified \old \result others
-------------------------------------------------------
pre X X X X O
post (N) O O O O O
post (E) O O O X O
internal O O O X O
old X X X X O
intra X X X X O
inter O O O X O
working_space O O O O O
duration O O O O O
------------------------------------------------------
where the precondition is over a single, visible, definite
(determined) state (i.e., the pre-state); the normal or exceptional
postcondition is over a pair of visible, definite states
(i.e., the pre/post-states); the internal condition is over
a pair of a pre-state and an invisible (internal, intermediate),
definite state (e.g., assert clause);
the old condition is for the \old expression and should
denote the pre-state, but we have separated them here for the future
extention;
the intracondition is over a single, visible, indefinite
(undetermined) state (i.e., some pre or post-state);
the intercondition is over a pair of a pair of visible,
undetermined states (i.e., some pre/post-states).
Both the intra- and intercondition are for class-level specifications
such as invariants (intracondition) and history constrainsts
(intercondition).
The working_space is for the clause of the same name,
as is the duration context; both of these are assertions
over pairs of states, a pre-state and a post-state
| Field Summary | |
protected MJMathMode |
arithmeticMode
|
private static int |
CTX_DURATION
|
private static int |
CTX_EXCEPTIONAL_POSTCONDITION
|
private static int |
CTX_INTERCONDITION
|
private static int |
CTX_INTERNAL_CONDITION
|
private static int |
CTX_INTRACONDITION
|
private static int |
CTX_OLD_EXPRESSION
|
private static int |
CTX_POSTCONDITION
|
private static int |
CTX_PRECONDITION
|
private static int |
CTX_WORKING_SPACE
|
private int |
kind
|
| Fields inherited from class org.jmlspecs.checker.JmlContext |
cunit, delegee, parent |
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Fields inherited from interface org.multijava.mjc.Constants |
ACC_PURE, AMID_JAVA_MATH, AMID_MAX, AMID_SAFE_MATH, CMP_VERSION, JAV_ASSERTION_ERROR, JAV_CLASS, JAV_CLASSLOADER, JAV_CLASSNOTFOUND_EXCEPTION, JAV_CLONE, JAV_CLONEABLE, JAV_CONSTRUCTOR, JAV_ERROR, JAV_EXCEPTION, JAV_INIT, JAV_LENGTH, JAV_NAME_SEPARATOR, JAV_NOCLASSDEFFOUND_ERROR, JAV_OBJECT, JAV_OUTER_THIS, JAV_RMJ_RUNTIME_EXCEPTION, JAV_RUNTIME, JAV_RUNTIME_EXCEPTION, JAV_SERIALIZABLE, JAV_STATIC_INIT, JAV_STRING, JAV_STRINGBUFFER, JAV_SUPER, JAV_THIS, JAV_THROWABLE, MJ_ANCHOR, OPE_BAND, OPE_BNOT, OPE_BOR, OPE_BSR, OPE_BXOR, OPE_EQ, OPE_GE, OPE_GT, OPE_LAND, OPE_LE, OPE_LNOT, OPE_LOR, OPE_LT, OPE_MINUS, OPE_NE, OPE_PERCENT, OPE_PLUS, OPE_POSTDEC, OPE_POSTINC, OPE_PREDEC, OPE_PREINC, OPE_SIMPLE, OPE_SL, OPE_SLASH, OPE_SR, OPE_STAR, TID_ARRAY, TID_BOOLEAN, TID_BYTE, TID_CHAR, TID_CLASS, TID_DOUBLE, TID_FLOAT, TID_INT, TID_LONG, TID_MAX, TID_SHORT, TID_VOID, UNIV_ARRAY_TMP, UNIV_TMP |
| Constructor Summary | |
private |
JmlExpressionContext(CFlowControlContextType parent,
int kind)
|
| Method Summary | |
MJMathMode |
arithmeticMode()
Indicates the integral arithmetic mode that should be used. |
static JmlExpressionContext |
createDuration(CFlowControlContextType parent)
Create and return a duration context. |
static JmlExpressionContext |
createExceptionalPostcondition(CFlowControlContextType parent)
Create and return an exceptional postcondition context. |
static JmlExpressionContext |
createIntercondition(CFlowControlContextType parent)
Create and return an intercondition context. |
static JmlExpressionContext |
createInternalCondition(CFlowControlContextType parent)
Create and return an internal condition context. |
static JmlExpressionContext |
createIntracondition(CFlowControlContextType parent)
Create and return an intracondition context. |
static JmlExpressionContext |
createOldExpression(CFlowControlContextType parent)
Create and return an old expression context. |
static JmlExpressionContext |
createPostcondition(CFlowControlContextType parent)
Create and return a normal postcondition context. |
static JmlExpressionContext |
createPrecondition(CFlowControlContextType parent)
Create and return a precondition context. |
static JmlExpressionContext |
createSameKind(CFlowControlContextType parent,
JmlExpressionContext ctx)
Return a new JmlExpressionContext of the same kind as the given argument ctx. |
static JmlExpressionContext |
createWorkingSpace(CFlowControlContextType parent)
Create and return a working_space context. |
boolean |
discardValue()
|
boolean |
freshOk()
Return true if \fresh is allowed in this context |
boolean |
isIncDec()
|
boolean |
isLeftSide()
|
CFieldAccessor |
lookupField(String ident)
searches for a field with the given identifier |
CFieldAccessor |
lookupOuterField(String ident)
Searches for a field of the given name in the context surrounding the current lexical contour. |
boolean |
notModifiedOk()
Return true if \not_modified is allowed in this context |
boolean |
oldOk()
Return true if \old expression is allowed in this context |
boolean |
resultOk()
Return true if \result is allowed in this context |
void |
setArithmeticMode(byte mode)
|
void |
setDiscardValue(boolean discardValue)
set this context as a discarded value so result is ignored |
void |
setIncDec(boolean incDec)
Set this context as an increment or decrement expression, so we can generate appropriate getters and setters if necessary (and also generate proper code in the future). |
void |
setLeftSide(boolean leftSide)
Set this context as a left side in an assignment, so access to vars may be uninitialized |
| 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 int kind
private static final int CTX_PRECONDITION
private static final int CTX_POSTCONDITION
private static final int CTX_EXCEPTIONAL_POSTCONDITION
private static final int CTX_INTERNAL_CONDITION
private static final int CTX_OLD_EXPRESSION
private static final int CTX_INTRACONDITION
private static final int CTX_INTERCONDITION
private static final int CTX_WORKING_SPACE
private static final int CTX_DURATION
protected MJMathMode arithmeticMode
| Constructor Detail |
private JmlExpressionContext(CFlowControlContextType parent,
int kind)
| Method Detail |
public static JmlExpressionContext createPrecondition(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createPostcondition(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createExceptionalPostcondition(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createWorkingSpace(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createDuration(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createInternalCondition(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createOldExpression(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createIntracondition(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createIntercondition(CFlowControlContextType parent)
parent - the parent context
public static JmlExpressionContext createSameKind(CFlowControlContextType parent,
JmlExpressionContext ctx)
parent - the parent context
public CFieldAccessor lookupField(String ident)
throws UnpositionedError
lookupField in interface CContextTypelookupField in class JmlContextUnpositionedError - this error will be positioned soon
public CFieldAccessor lookupOuterField(String ident)
throws UnpositionedError
lookupOuterField in interface CContextTypelookupOuterField in class JmlContextident - the name of the field
UnpositionedError - this error will be positioned soonpublic void setIncDec(boolean incDec)
setIncDec in interface CExpressionContextTypeincDec - public boolean isIncDec()
isIncDec in interface CExpressionContextTypepublic void setLeftSide(boolean leftSide)
setLeftSide in interface CExpressionContextTypeleftSide - set the side of current code flowpublic boolean isLeftSide()
isLeftSide in interface CExpressionContextTypepublic void setDiscardValue(boolean discardValue)
setDiscardValue in interface CExpressionContextTypediscardValue - is the value of this expression in
this context discarded?public boolean discardValue()
discardValue in interface CExpressionContextTypepublic boolean freshOk()
public boolean notModifiedOk()
public boolean oldOk()
public boolean resultOk()
public MJMathMode arithmeticMode()
CContextType
arithmeticMode in interface CContextTypearithmeticMode in class JmlContextpublic void setArithmeticMode(byte mode)
setArithmeticMode in interface CExpressionContextType
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||