@Override public LexNameList caseAImplicitFunctionDefinition( AImplicitFunctionDefinition node) throws AnalysisException { return new LexNameList(node.getName()); }
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 POFunctionDefinitionContext(AImplicitFunctionDefinition definition, boolean precond, IPogAssistantFactory assistantFactory) { this.name = definition.getName(); this.deftype = (AFunctionType) definition.getType(); this.addPrecond = precond; this.paramPatternList = assistantFactory .createAImplicitFunctionDefinitionAssistant() .getParamPatternList(definition); this.precondition = definition.getPrecondition(); this.argtypes = calculateTypes(deftype, false); }
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()); }
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)); }
} else if (fie.getImpdef() != null) fname = fie.getImpdef().getName();
public AExplicitFunctionDefinition getPreDefinition( AImplicitFunctionDefinition d) { @SuppressWarnings("unchecked") AExplicitFunctionDefinition def = AstFactory.newAExplicitFunctionDefinition(d.getName().getPreName(d.getPrecondition().getLocation()), NameScope.GLOBAL, (List<ILexNameToken>) d.getTypeParams().clone(), af.createAFunctionTypeAssistant().getPreType((AFunctionType) d.getType()), getParamPatternList(d), d.getPrecondition(), null, null, false, null); def.setAccess(d.getAccess().clone()); def.setClassDefinition(d.getClassDefinition()); return def; }
func.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess()); func.uninstantiated = !def.getTypeParams().isEmpty(); nvl.add(new NameValuePair(def.getName(), func));
AVariableExp varExp = getVarExp(func.getName().clone(), func.clone(), func.getType().clone()); applyExp.setRoot(varExp); body = applyExp;
String funcNameCg = node.getName().getName();
node.getName().setTypeQualifier(fType.getParameters());