|
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.jmlrac.TransUtils
org.jmlspecs.jmlrac.WrapperMethod
org.jmlspecs.jmlrac.ConstructorWrapper
A class for generating constructor wrappers. A constructor wrapper is a constructor that wraps a constructor with assertion check methods such as pre and postcondition check methods. The constructor under wrapping becomes a private method and called by the wrapper.
TransConstructor| Field Summary |
| Fields inherited from class org.jmlspecs.jmlrac.WrapperMethod |
args, ident, isHelper, isStatic, methodDecl, postArgs, returnType, typeName, xpostArgs |
| Fields inherited from class org.jmlspecs.jmlrac.TransUtils |
typeDecl |
| 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 | |
ConstructorWrapper(String typeName,
JmlConstructorDeclaration mdecl)
Construct a new instance. |
|
| Method Summary | |
private JBlock |
buildWrapperBody(JExpression explicitSuper)
Returns a body for the constructor wrapper being built. |
protected String |
callOriginalMethod()
Returns code for invoking the now-renamed original constructor. |
protected String |
checkConstraint()
Returns code for checking history constraints. |
protected String |
checkPostcondition()
Returns code for checking normal postcondition. |
protected String |
checkPostInstanceInvariant()
Returns code for checking instance invariant in the post-state. |
protected String |
checkPostInvariant()
Returns code for checking invariant in the post-state. |
protected String |
checkPostStaticInvariant()
Returns code for checking static invariant in the post-state. |
protected String |
checkPrecondition()
Returns code for checking precondition. |
protected String |
checkPreInvariant()
Returns code for checking invariant in the pre-state. |
protected String |
checkXPostcondition()
Returns code for checking exceptional postcondition. |
protected String |
evalOldInConstraint()
Returns code for evaluating old expressions in static constraint. |
JMethodDeclarationType |
generate()
Returns a constructor wrapper for the given constructor declaration. |
protected String |
identification(String state)
Returns a string that identifies the method being translated. |
protected String |
isActive(String type)
Returns a string representation of the condition that tests if the given type of assertion is active. |
protected String |
nocheckDuringInit()
Returns code for bypassing assertion checks during the class and instance initialization. |
| Methods inherited from class org.jmlspecs.jmlrac.WrapperMethod |
buildArguments, buildWrapperBody, constraintCallArg, mandatoryReturn, optionalReturn, racMethodName, resultVarDecl, wrap, wrap2, wrap3 |
| 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 |
| Constructor Detail |
public ConstructorWrapper(String typeName,
JmlConstructorDeclaration mdecl)
requires typeName != null && mdecl != null;
mdecl - constructor to be wrapped| Method Detail |
public JMethodDeclarationType generate()
C(T1 x1, ..., Tn xn) {
checkPre(x1, ..., xn);
try {
internal(x1, ..., xn);
checkPost(x1, ..., xn);
}
catch (JMLEntryPreconditionError e) {
throw new JMLInternalPreconditionError(e);
}
catch (JMLAssertionError e) {
throw e;
}
catch (Throwable e) {
checkXPost(x1, ..., xn, e);
}
finally {
checkInv(x1, ..., xn);
}
also modifies methodDecl.*; accessible methodDecl; ensures \result != null;
generate in class WrapperMethodprivate JBlock buildWrapperBody(JExpression explicitSuper)
generate() for the structure of the
constructor body.
assignable args, postArgs, xpostArgs; accessible methodDecl; ensures \result != null;
explicitSuper - explicit super/this call to be added
as the first statement of the body to be built;
if null, no such call is added.generate(),
WrapperMethod.buildWrapperBody()protected String nocheckDuringInit()
if (!VN_CLASS_INIT || !VN_INIT) {
T(x1, ..., xn);
return;
}
nocheckDuringInit in class WrapperMethodprotected String checkPrecondition()
// check precondition
if (JMLChecker.isActive(JMLChecker.PRECONDITION)) {
JMLChecker.enter();
checkPre$$init$$T(x1,...,xn);
JMLChecker.exit();
}
where T is the name of target type.
checkPrecondition in class WrapperMethodWrapperMethod.checkPrecondition()protected String checkPreInvariant()
// check static invariant
if (JMLChecker.isActive(JMLChecker.INVARIANT) && rac$constructed()) {
JMLChecker.enter();
checkInv$static();
JMLChecker.exit();
}
where T is the name of type being translated.
checkPreInvariant in class WrapperMethodprotected String checkPostInvariant()
// check static invariant
if (JMLChecker.isActive(JMLChecker.INVARIANT) && rac$constructed()) {
JMLChecker.enter();
checkInv$static();
JMLChecker.exit();
}
// check instance invariant
if (JMLChecker.isActive(JMLChecker.INVARIANT) && rac$constructed()) {
JMLChecker.enter();
checkInv$instance$T();
JMLChecker.exit();
}
where T is the name of type being translated.
checkPostInvariant in class WrapperMethodprotected String checkPostInstanceInvariant()
// check instance invariant
if (JMLChecker.isActive(JMLChecker.INVARIANT) && rac$constructed()) {
JMLChecker.enter();
checkInv$instance$T();
JMLChecker.exit();
}
where T is the name of type being translated.
protected String checkPostStaticInvariant()
// check static invariant
if (JMLChecker.isActive(JMLChecker.INVARIANT) && rac$constructed()) {
JMLChecker.enter();
checkInv$static();
JMLChecker.exit();
}
protected String evalOldInConstraint()
// eval old exprs in static constraint
if (JMLChecker.isActive(JMLChecker.CONSTRAINT)) {
JMLChecker.enter();
evalOldExprInHC$satic();
JMLChecker.exit();
}
where T is the name of type being translated.
evalOldInConstraint in class WrapperMethodprotected String checkConstraint()
// check static constraint
if (JMLChecker.isActive(JMLChecker.CONSTRAINT)) {
JMLChecker.enter();
checkHC$static();
JMLChecker.exit();
}
where T is the name of type being translated.
checkConstraint in class WrapperMethodprotected String callOriginalMethod()
internal$m(x1,...,xn);.
callOriginalMethod in class WrapperMethodprotected String checkPostcondition()
// check normal postcondition
if (JMLChecker.isActive(JMLChecker.POSTCONDITION)
&& rac$constructed()) {
JMLChecker.enter();
checkPost$$init$$T(x1,...,xn);
JMLChecker.exit();
}
where T is the name of the target type.
checkPostcondition in class WrapperMethodprotected String checkXPostcondition()
// check exceptional postcondition
if (JMLChecker.isActive(JMLChecker.POSTCONDITION)
&& rac$constructed()) {
JMLChecker.enter();
checkXPost$$init$T(x1,...,xn,e);
JMLChecker.exit();
}
where T is the name of the target type.
checkXPostcondition in class WrapperMethodprotected String isActive(String type)
isActive in class WrapperMethodprotected String identification(String state)
identification in class WrapperMethod
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||