public FunctionValue(AImplicitFunctionDefinition def, FunctionValue precondition, FunctionValue postcondition, Context freeVariables) { this.location = def.getLocation(); this.name = def.getName().getName(); this.typeValues = null; this.type = (AFunctionType) def.getType(); this.paramPatternList = new Vector<List<PPattern>>(); PatternListTC plist = Interpreter.getInstance().getAssistantFactory().createPatternList(); for (APatternListTypePair ptp : def.getParamPatterns()) { plist.addAll(ptp.getPatterns()); } this.paramPatternList.add(plist); this.body = def.getBody(); this.result = def.getResult(); this.precondition = precondition; this.postcondition = postcondition; this.freeVariables = freeVariables; this.checkInvariants = true; this.classdef = def.getClassDefinition(); if (Settings.measureChecks && def.getMeasureName() != null) { measureName = def.getMeasureName(); measureValues = Collections.synchronizedMap(new HashMap<Long, Stack<Value>>()); } }
AFunctionType type = AstFactory.newAFunctionType(result.getLocation(), false, ptypes, resultPattern.getType()); type.setInstantiated(typeParams == null || typeParams.isEmpty() ? null : false);
private TypeCompatibilityObligation(AImplicitFunctionDefinition func, PType etype, PType atype, IPOContextStack ctxt, IPogAssistantFactory assistantFactory) throws AnalysisException { super(func, POType.TYPE_COMP, ctxt, func.getLocation(), assistantFactory); this.assistantFactory = assistantFactory; PExp body = null; if (func.getBody() instanceof ANotYetSpecifiedExp || func.getBody() instanceof ASubclassResponsibilityExp) { // We have to say "f(a)" because we have no body PExp root = AstFactory.newAVariableExp(func.getName()); List<PExp> args = new ArrayList<PExp>(); for (APatternListTypePair pltp : func.getParamPatterns()) { for (PPattern p : pltp.getPatterns()) { args.add(patternToExp(p)); } } body = AstFactory.newAApplyExp(root, args); } else { body = func.getBody().clone(); } stitch = oneType(false, body, etype.clone(), atype.clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
public ParameterPatternObligation(AImplicitFunctionDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.FUNC_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; stitch = generate(def.getPredef(), cloneListPatternList(assistantFactory.createAImplicitFunctionDefinitionAssistant().getParamPatternList(def)), cloneListType(((AFunctionType) def.getType()).getParameters()), ((AFunctionType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
throws AnalysisException super(func, POType.FUNC_POST_CONDITION, ctxt, func.getLocation(), assistantFactory);
throws AnalysisException super(func, POType.FUNC_SATISFIABILITY, ctxt, func.getLocation(), af);
ABooleanBasicType expected = AstFactory.newABooleanBasicType(node.getLocation()); TypeCheckerErrors.report(3018, "Precondition returns unexpected type", node.getLocation(), node); TypeCheckerErrors.detail2("Actual", b, "Expected", expected); TypeCheckerErrors.report(3029, "Function returns unexpected type", node.getLocation(), node); TypeCheckerErrors.detail2("Actual", node.getActualResult(), "Expected", node.getResult().getType()); TypeCheckerErrors.report(3030, "Function parameter visibility less than function definition", node.getLocation(), node); && node.getBody() instanceof ASubclassResponsibilityExp) TypeCheckerErrors.report(3329, "Abstract function/operation must be public or protected", node.getLocation(), node); ABooleanBasicType expected = AstFactory.newABooleanBasicType(node.getLocation()); TypeCheckerErrors.report(3018, "Postcondition returns unexpected type", node.getLocation(), node); TypeCheckerErrors.detail2("Actual", b, "Expected", expected); TypeCheckerErrors.warning(5012, "Recursive function has no measure", node.getLocation(), node);