private List<PType> calculateTypes(AFunctionType ftype, boolean curried) { List<PType> r = new LinkedList<PType>(); for (PType t : ftype.getParameters()) { r.add(t.clone()); } if (curried) { r.addAll(handleCurries(ftype.getResult())); } return r; }
private Collection<? extends PType> handleCurries(PType result) { List<PType> r = new LinkedList<PType>(); if (result instanceof AFunctionType) { AFunctionType ft = (AFunctionType) result; for (PType p : ft.getParameters()) { r.add(p.clone()); } r.addAll(handleCurries(ft.getResult())); } return r; }
public static List<PMultipleBind> bindListFromPattern(PPattern pattern, PType type) { List<PMultipleBind> bindList = new LinkedList<PMultipleBind>(); ATypeMultipleBind tmBind = new ATypeMultipleBind(); List<PPattern> plist = new LinkedList<PPattern>(); plist.add(pattern.clone()); tmBind.setPlist(plist); tmBind.setType(type.clone()); bindList.add(tmBind); return bindList; }
protected AApplyExp getApplyExp(PExp root, PType type, PExp... arglist) { AApplyExp exp = getApplyExp(root, arglist); exp.setType(type.clone()); return exp; }
@Override public List<PMultipleBind> caseATypeBind(ATypeBind bind) throws AnalysisException { List<PPattern> plist = new Vector<PPattern>(); plist.add(bind.getPattern().clone()); List<PMultipleBind> mblist = new Vector<PMultipleBind>(); mblist.add(AstFactory.newATypeMultipleBind(plist, bind.getType().clone())); return mblist; }
/** * Generate a Var Exp with associated type. */ protected AVariableExp getVarExp(ILexNameToken name, PType type) { AVariableExp var = getVarExp(name); var.setType(type.clone()); return var; }
public POForAllContext(ALambdaExp exp) { this.bindings = new Vector<PMultipleBind>(); for (ATypeBind tb : exp.getBindList()) { List<PPattern> pl = new ArrayList<PPattern>(); pl.add(tb.getPattern().clone()); ATypeMultipleBind mtb = AstFactory.newATypeMultipleBind(pl, tb.getType().clone()); bindings.add(mtb); } }
private List<PMultipleBind> getInvBinds(AStateDefinition node) { List<PMultipleBind> r = new Vector<PMultipleBind>(); for (AFieldField f : node.getFields()) { r.add(getMultipleTypeBind(f.getType().clone(), f.getTagname().clone())); } return r; }
protected List<PMultipleBind> stateInvBinds(AClassInvariantDefinition node) { List<PMultipleBind> binds = new LinkedList<PMultipleBind>(); for (PDefinition p : node.getClassDefinition().getDefinitions()) { if (p instanceof AInstanceVariableDefinition) { binds.add(getMultipleTypeBind(p.getType().clone(), p.getName().clone())); } } return binds; }
public static AMkTypeExp newAMkTypeExp(ILexNameToken typeName, PType type, List<PExp> arglist) { AMkTypeExp mktype = new AMkTypeExp(); mktype.setType(type); if (type instanceof ARecordInvariantType) { mktype.setRecordType((ARecordInvariantType) type.clone()); } mktype.setTypeName(typeName); mktype.setArgs(arglist); return mktype; }
private TypeCompatibilityObligation(AExplicitOperationDefinition def, PType actualResult, IPOContextStack ctxt, IPogAssistantFactory assistantFactory) throws AnalysisException { super(def, POType.TYPE_COMP, ctxt, def.getLocation(), assistantFactory); this.assistantFactory = assistantFactory; AVariableExp result = AstFactory.newAVariableExp(new LexNameToken(def.getName().getModule(), "RESULT", def.getLocation())); stitch = oneType(false, result, ((AOperationType) def.getType()).getResult().clone(), actualResult.clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
@SuppressWarnings("unchecked") public AFunctionType getPostType(AFunctionType t) { List<PType> params = new PTypeList(); params.addAll((List<PType>) t.getParameters().clone()); params.add(t.getResult().clone()); AFunctionType type = AstFactory.newAFunctionType(t.getLocation(), false, params, AstFactory.newABooleanBasicType(t.getLocation())); type.setDefinitions((List<? extends PDefinition>) t.getDefinitions().clone()); type.setInstantiated(null); return type; }
public PExp caseAMapletPatternMaplet(AMapletPatternMaplet node) throws AnalysisException { AMapletExp maplet = new AMapletExp(); PExp from = node.getFrom().apply(this).clone(); maplet.setLeft(from); PExp to = node.getTo().apply(this).clone(); maplet.setRight(to); maplet.setType(AstFactory.newAMapMapType(null, from.getType().clone(), to.getType().clone())); return maplet; }
private AValueDefinition buildValueDef(PExp exp, String name) { AValueDefinition valDef = new AValueDefinition(); valDef.setType(exp.getType().clone()); valDef.setExpression(exp.clone()); AIdentifierPattern pattern = new AIdentifierPattern(); pattern.setName(new LexNameToken(null, name, null)); valDef.setPattern(pattern); return valDef; }
public ParameterPatternObligation(AExplicitFunctionDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.FUNC_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; // valuetree.setContext(ctxt.getContextNodeList()); // cannot clone getPredef as it can be null. We protect the ast in // the generate method where it's used stitch = generate(def.getPredef(), cloneListPatternList(def.getParamPatternList()), cloneListType(((AFunctionType) def.getType()).getParameters()), ((AFunctionType) def.getType()).getResult().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)); }
public ParameterPatternObligation(AExplicitOperationDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.OPERATION_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; stitch = generate(def.getPredef(), cloneListPatternList(assistantFactory.createAExplicitOperationDefinitionAssistant().getParamPatternList(def)), cloneListType(((AOperationType) def.getType()).getParameters()), ((AOperationType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
public ParameterPatternObligation(AImplicitOperationDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.OPERATION_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; stitch = generate(def.getPredef(), cloneListPatternList(assistantFactory.createAImplicitOperationDefinitionAssistant().getListParamPatternList(def)), cloneListType(((AOperationType) def.getType()).getParameters()), ((AOperationType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
public POFunctionResultContext(AExplicitFunctionDefinition definition) { this.name = definition.getName(); this.deftype = (AFunctionType) definition.getType(); this.precondition = definition.getPrecondition(); this.body = definition.getBody(); this.implicit = false; this.result = AstFactory.newAPatternTypePair(AstFactory.newAIdentifierPattern(new LexNameToken(definition.getName().getModule(), "RESULT", definition.getLocation())), ((AFunctionType) definition.getType()).getResult().clone()); this.function = definition.clone(); function.setLocation(null); }