public POFunctionResultContext(AImplicitFunctionDefinition definition) { this.name = definition.getName(); this.deftype = (AFunctionType) definition.getType(); this.precondition = definition.getPrecondition(); this.body = definition.getBody(); this.implicit = true; this.result = definition.getResult(); this.function = definition; }
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)); }
@Override public PExp caseAImplicitFunctionDefinition( AImplicitFunctionDefinition def, Integer lineno) throws AnalysisException { if (def.getPredef() != null) { PExp found = def.getPredef().apply(THIS, lineno); if (found != null) { return found; } } if (def.getPostdef() != null) { PExp found = def.getPostdef().apply(THIS, lineno); if (found != null) { return found; } } return def.getBody() == null ? null : af.createPExpAssistant().findExpression(def.getBody(), lineno); }
public boolean isSubclassResponsibility(PDefinition d) { while (d instanceof AInheritedDefinition) { AInheritedDefinition aid = (AInheritedDefinition) d; d = aid.getSuperdef(); } if (d instanceof AExplicitOperationDefinition) { AExplicitOperationDefinition op = (AExplicitOperationDefinition) d; return op.getBody() instanceof ASubclassResponsibilityStm; } else if (d instanceof AImplicitOperationDefinition) { AImplicitOperationDefinition op = (AImplicitOperationDefinition) d; return op.getBody() instanceof ASubclassResponsibilityStm; } else if (d instanceof AExplicitFunctionDefinition) { AExplicitFunctionDefinition fn = (AExplicitFunctionDefinition) d; return fn.getBody() instanceof ASubclassResponsibilityExp; } else if (d instanceof AImplicitFunctionDefinition) { AImplicitFunctionDefinition fn = (AImplicitFunctionDefinition) d; return fn.getBody() instanceof ASubclassResponsibilityExp; } return false; }
public static String getImplicitFunctionString(AImplicitFunctionDefinition d) { return d.getAccess() + " " + d.getName().getName() + (d.getTypeParams().isEmpty() ? "" : "[" + getTypeListString(d.getTypeParams()) + "]") + Utils.listToString("(", getString(d.getParamPatterns()), ", ", ")") + d.getResult() + (d.getBody() == null ? "" : " ==\n\t" + d.getBody()) + (d.getPrecondition() == null ? "" : "\n\tpre " + d.getPrecondition()) + (d.getPostcondition() == null ? "" : "\n\tpost " + d.getPostcondition()); }
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>>()); } }
if (node.getBody() != null) node.setActualResult(node.getBody().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers, node.getResult().getType(), null))); && node.getBody() instanceof ASubclassResponsibilityExp) if (node.getMeasure() != null && node.getBody() == null) if (!(node.getBody() instanceof ANotYetSpecifiedExp) && !(node.getBody() instanceof ASubclassResponsibilityExp))