|
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.AssertionMethod
org.jmlspecs.jmlrac.InvariantLikeMethod
org.jmlspecs.jmlrac.ConstraintMethod
org.jmlspecs.jmlrac.LocalConstraintMethod
A class for generating constaint check methods that check locally
specified type constraints without inheriting any constraints from
supertypes. Two kinds of constraint check methods can be generated:
instance constraint check methods and static constraint check
methods. For details on constraint check methods, refer to the class
ConstraintMethod.
The class implements a variant of the Template Pattern
[GoF95], prescribed in the class AssertionMethod.
AssertionMethod,
ConstraintMethod,
generate(RacNode)| Field Summary | |
private JmlMethodName[] |
names
The names of methods to which the generated constraint check method is applicable; it is null if the constraint is applicable to all methods. |
private VarGenerator |
varGen
The variable generator to be used in the translation. |
| Fields inherited from class org.jmlspecs.jmlrac.AssertionMethod |
exceptionToThrow, isStatic, javadoc, methodIdentification, methodName, prefix, typeDecl |
| Fields inherited from class org.jmlspecs.jmlrac.TransUtils |
|
| 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 | |
LocalConstraintMethod(VarGenerator varGen,
boolean isStatic,
JmlTypeDeclaration typeDecl,
JmlMethodName[] names,
int suffix)
Construct a new instance. |
|
| Method Summary | |
protected boolean |
canInherit()
Indicates whether the generated assertion method should try to dynamically inherit the corresponding assertion method of the superclass or interfaces. |
JMethodDeclarationType |
generate(RacNode stmt)
Generates a constrain check method by using the given block of code, stmt, as the main body. |
private String |
isApplicable(JmlMethodName name,
String var)
Returns code that tests if the given JML method name, name, is applicable to the method name given as a
parameter (rac$name and rac$params)
to the constraint check method. |
private RacNode |
isApplicable(JmlMethodName[] names)
Returns code that tests if the given JML method name, name, is applicable to the method name given as a
parameter (rac$name and rac$params)
to the constraint check method. |
private String |
nameMatched(JmlMethodName name,
String var)
Returns code that compares the given JML method name, name, with the method name given as a
parameter (rac$name) to the constraint check
method. |
private String |
paramMatched(JmlMethodName name,
String var)
Returns code that compares the foraml parameter types of the given JML method, name, with those of the
constraint check method. |
static String |
postfix(boolean isStatic,
JmlTypeDeclaration typeDecl,
int suffix)
Returns the postfix to be used for constraint check method's name. |
private String |
simpleName(JmlName[] subnames)
Returns a simplied method name of the given JML names, that can be compared with the method name given as a parameter of the constraint check method. |
| Methods inherited from class org.jmlspecs.jmlrac.ConstraintMethod |
formalParameters, inheritCallArgs, inheritCallArgTypes |
| Methods inherited from class org.jmlspecs.jmlrac.InvariantLikeMethod |
buildHeader, inheritAssertion, inheritFrom, nonReflectiveCall, reflectiveCall |
| Methods inherited from class org.jmlspecs.jmlrac.AssertionMethod |
checker, hasExplicitSuperClass |
| 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 final VarGenerator varGen
private JmlMethodName[] names
| Constructor Detail |
public LocalConstraintMethod(VarGenerator varGen,
boolean isStatic,
JmlTypeDeclaration typeDecl,
JmlMethodName[] names,
int suffix)
isStatic - the kind of constraint method to generate;
true for static and false for
non-static (instance) constraint method.typeDecl - the target type declaration whose constraint methods
are to be generated.names - method names that the generated constraint check
method is applicable to.suffix - a unique sequence number to be used as the suffix of the
constraint check method's name.| Method Detail |
public static String postfix(boolean isStatic,
JmlTypeDeclaration typeDecl,
int suffix)
public JMethodDeclarationType generate(RacNode stmt)
stmt, as the main body. This method prefixes
the body with the code that tests if the constraint is
applicable to the argument method and appends the code to throw
a constraint violation error. Thus, the returned method has the
following structure.
public void checkHC$instance1$Constraint1(String rac$msg,
String rac$name, java.lang.Class[] rac$params) {
boolean b = false;
b = ...; // test if applicable to method
if (!b) {
return;
}
stmt
if (!constraint_hold) {
throw new JMLHistoryConstraintError(...);
}
}
generate in class InvariantLikeMethodstmt - code to evaluate the constraint; the result is supposed
to be stored in the variable VN_ASSERTION.
A null value means that no assertion is
specified or the assertion is not executable.private RacNode isApplicable(JmlMethodName[] names)
name, is applicable to the method name given as a
parameter (rac$name and rac$params)
to the constraint check method.
private String isApplicable(JmlMethodName name,
String var)
name, is applicable to the method name given as a
parameter (rac$name and rac$params)
to the constraint check method. The code sets the given boolean
variable, var to the result.
private String nameMatched(JmlMethodName name,
String var)
name, with the method name given as a
parameter (rac$name) to the constraint check
method. The code sets the given boolean variable,
var to the result of the comparison.
private String paramMatched(JmlMethodName name,
String var)
name, with those of the
constraint check method. The code sets the given boolean
variable, var to the result of the comparison.
private String simpleName(JmlName[] subnames)
protected boolean canInherit()
also protected normal_behavior ensures \result == false;
canInherit in class InvariantLikeMethod
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||