use of org.checkerframework.framework.util.ContractsUtils in project checker-framework by typetools.
the class CFAbstractTransfer method processPostconditions.
/**
* Add information based on all postconditions of method {@code n} with tree {@code tree} and
* element {@code method} to the store {@code store}.
*/
protected void processPostconditions(MethodInvocationNode n, S store, ExecutableElement methodElement, Tree tree) {
ContractsUtils contracts = ContractsUtils.getInstance(analysis.atypeFactory);
Set<Postcondition> postconditions = contracts.getPostconditions(methodElement);
processPostconditionsAndConditionalPostconditions(n, tree, store, null, postconditions);
}
use of org.checkerframework.framework.util.ContractsUtils in project checker-framework by typetools.
the class CFAbstractTransfer method processConditionalPostconditions.
/**
* Add information based on all conditional postconditions of method {@code n} with tree {@code
* tree} and element {@code method} to the appropriate store.
*/
protected void processConditionalPostconditions(MethodInvocationNode n, ExecutableElement methodElement, Tree tree, S thenStore, S elseStore) {
ContractsUtils contracts = ContractsUtils.getInstance(analysis.atypeFactory);
Set<ConditionalPostcondition> conditionalPostconditions = contracts.getConditionalPostconditions(methodElement);
processPostconditionsAndConditionalPostconditions(n, tree, thenStore, elseStore, conditionalPostconditions);
}
use of org.checkerframework.framework.util.ContractsUtils in project checker-framework by typetools.
the class CFAbstractTransfer method addInformationFromPreconditions.
/**
* Add the information from all the preconditions of the method {@code method} with
* corresponding tree {@code methodTree} to the store {@code info}.
*/
protected void addInformationFromPreconditions(S info, AnnotatedTypeFactory factory, CFGMethod method, MethodTree methodTree, ExecutableElement methodElement) {
ContractsUtils contracts = ContractsUtils.getInstance(analysis.atypeFactory);
FlowExpressionContext flowExprContext = null;
Set<Precondition> preconditions = contracts.getPreconditions(methodElement);
for (Precondition p : preconditions) {
String expression = p.expression;
AnnotationMirror annotation = p.annotation;
if (flowExprContext == null) {
flowExprContext = FlowExpressionContext.buildContextForMethodDeclaration(methodTree, method.getClassTree(), analysis.checker.getContext());
}
TreePath localScope = analysis.atypeFactory.getPath(methodTree);
annotation = standardizeAnnotationFromContract(annotation, flowExprContext, localScope);
try {
// TODO: currently, these expressions are parsed at the
// declaration (i.e. here) and for every use. this could
// be optimized to store the result the first time.
// (same for other annotations)
FlowExpressions.Receiver expr = FlowExpressionParseUtil.parse(expression, flowExprContext, localScope, false);
info.insertValue(expr, annotation);
} catch (FlowExpressionParseException e) {
// Errors are reported by BaseTypeVisitor.checkContractsAtMethodDeclaration()
}
}
}
Aggregations