public String hackResultName(AFuncDeclIR func) throws AnalysisException { SourceNode x = func.getSourceNode(); if (x.getVdmNode() instanceof AImplicitFunctionDefinition) { AImplicitFunctionDefinition iFunc = (AImplicitFunctionDefinition) x.getVdmNode(); return iFunc.getResult().getPattern().toString(); } throw new AnalysisException("Expected AFuncDeclIR in implicit function source. Got: " + x.getVdmNode().getClass().toString()); }
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; }
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>>()); } }
public AExplicitFunctionDefinition getPostDefinition( AImplicitFunctionDefinition d) { List<List<PPattern>> parameters = getParamPatternList(d); parameters.get(0).add(d.getResult().getPattern().clone()); @SuppressWarnings("unchecked") AExplicitFunctionDefinition def = AstFactory.newAExplicitFunctionDefinition(d.getName().getPostName(d.getPostcondition().getLocation()), NameScope.GLOBAL, (List<ILexNameToken>) d.getTypeParams().clone(), af.createAFunctionTypeAssistant().getPostType((AFunctionType) d.getType()), parameters, d.getPostcondition(), null, null, false, null); def.setAccess(d.getAccess().clone()); def.setClassDefinition(d.getClassDefinition()); return def; }
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()); }
List<PExp> postArglist = new Vector<PExp>(arglist); if (func.getResult().getPattern() instanceof AIdentifierPattern) AIdentifierPattern ip = (AIdentifierPattern) func.getResult().getPattern().clone(); postArglist.add(patternToExp(func.getResult().getPattern())); existsExp.setBindList(getMultipleTypeBindList(func.getResult().getType().clone(), ip.getName())); } else
body = patternToExp(func.getResult().getPattern());
node.setActualResult(node.getBody().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers, node.getResult().getType(), null))); if (!question.assistantFactory.getTypeComparator().compatible(node.getResult().getType(), node.getActualResult())) TypeCheckerErrors.detail2("Actual", node.getActualResult(), "Expected", node.getResult().getType()); if (node.getResult() != null) List<PDefinition> postdefs = question.assistantFactory.createAPatternTypePairAssistant().getDefinitions(node.getResult()); FlatCheckedEnvironment post = new FlatCheckedEnvironment(question.assistantFactory, postdefs, local, NameScope.NAMES); post.setStatic(question.assistantFactory.createPAccessSpecifierAssistant().isStatic(node.getAccess()));