@Override public String caseAOperationType(AOperationType type) throws AnalysisException { List<PType> parameters = type.getParameters(); String params = parameters.isEmpty() ? "()" : Utils.listToString(parameters, " * "); return "(" + params + " ==> " + type.getResult() + ")"; }
public static AOperationType newAOperationType(ILexLocation location, List<PType> parameters, PType resultType) { AOperationType result = new AOperationType(); initType(result, location); result.setParameters(parameters); result.setResult(resultType); result.setPure(false); // Set explicitly where needed return result; }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) List<PType> copy = new ArrayList<PType>(node.getParameters()); for( PType e : copy) if(node.getResult() != null && !_visitedNodes.contains(node.getResult())) node.getResult().apply(this);
/** * Creates a new complete constructor {@code AOperationType} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param parameters_ the {@link GraphNodeList} <b>graph</a> node for the {@code parameters} child of this {@link AOperationType} node. * <i>The parent of this {@code parameters } will not be changed by adding it to this node.</i> * @param result_ the {@link PType} <b>graph</a> node for the {@code result} child of this {@link AOperationType} node. * <i>The parent of this {@code result } will not be changed by adding it to this node.</i> * @param pure_ the {@link Boolean} <b>graph</a> node for the {@code pure} child of this {@link AOperationType} node. * <i>The parent of this {@code pure } will not be changed by adding it to this node.</i> */ public AOperationType(ILexLocation location_, Boolean resolved_, List<? extends PDefinition> definitions_, List<? extends PType> parameters_, PType result_, Boolean pure_) { super(location_,resolved_,definitions_); this.setParameters(parameters_); this.setResult(result_); this.setPure(pure_); }
throws AnalysisException if (type.getResolved()) type.setResolved(true); TypeCheckException problem = null; for (PType ot : type.getParameters()) fixed.add(AstFactory.newAUnknownType(type.getLocation())); type.setParameters(fixed); type.setResult(af.createPTypeAssistant().typeResolve(type.getResult(), question.root, question.rootVisitor, question.question)); fixed.add(AstFactory.newAUnknownType(type.getLocation())); type.apply(af.getTypeUnresolver()); throw problem;
protected boolean anyBinds() { return !deftype.getParameters().isEmpty(); }
Iterator<PType> typeIter = type.getParameters().iterator(); NameValuePairMap args = new NameValuePairMap(); if (Settings.release == Release.VDM_10 && !type.getPure() && ctxt.threadState.isPure()) } else rv = rv.convertTo(type.getResult(), argContext);
@Override public void caseAOperationType(AOperationType type) throws AnalysisException { if (!type.getResolved()) { return; } else { type.setResolved(false); } for (PType ot : type.getParameters()) { ot.apply(THIS); } type.getResult().apply(THIS); }
PDefinition encl = question.env.getEnclosingDefinition(); if (encl != null && encl.getAccess().getPure() && !optype.getPure()) optype.apply(THIS, question); node.getField().setTypeQualifier(optype.getParameters()); checkArgTypes(type, optype.getParameters(), atypes, question); // Not node.setType(optype.getResult()); return question.assistantFactory.createPTypeAssistant().checkReturnType(question.returnType, node.getType(), node.getLocation()); } else if (question.assistantFactory.createPTypeAssistant().isFunction(type))
@SuppressWarnings("unchecked") public AFunctionType getPostType(AOperationType type, AStateDefinition state, SClassDefinition classname, boolean isStatic) { PTypeList params = new PTypeList(); params.addAll((LinkedList<PType>) type.getParameters().clone()); if (!(type.getResult() instanceof AVoidType)) { params.add(type.getResult().clone()); } if (state != null) { params.add(AstFactory.newAUnresolvedType(state.getName())); params.add(AstFactory.newAUnresolvedType(state.getName())); } else if (classname != null) { AMapMapType map = AstFactory.newAMapMapType(type.getLocation(), AstFactory.newASeqSeqType(type.getLocation(), AstFactory.newACharBasicType(type.getLocation())), AstFactory.newAUnknownType(type.getLocation())); params.add(map); if (!isStatic) { params.add(AstFactory.newAUnresolvedType(classname.getName())); } } return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); }
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)); }
optype.setPure(access.get(synthname).getPure()); ptype = optype; newname = synthname.getModifiedName(optype.getParameters());
@SuppressWarnings("unchecked") public AFunctionType getPreType(AOperationType type, AStateDefinition state, SClassDefinition classname, boolean isStatic) { if (state != null) { PTypeList params = new PTypeList(); params.addAll((LinkedList<PType>) type.getParameters().clone()); params.add(AstFactory.newAUnresolvedType(state.getName())); return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); } else if (classname != null && !isStatic) { PTypeList params = new PTypeList(); params.addAll((Collection<? extends PType>) type.getParameters().clone()); params.add(AstFactory.newAUnresolvedType(classname.getName())); return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); } else { return AstFactory.newAFunctionType(type.getLocation(), false, (List<PType>) type.getParameters().clone(), AstFactory.newABooleanBasicType(type.getLocation())); } }
private AExplicitOperationDefinition getInvDefinition(SClassDefinition d) { List<PDefinition> invdefs = getInvDefs(d); if (invdefs.isEmpty()) { return null; } // Location of last local invariant ILexLocation invloc = invdefs.get(invdefs.size() - 1).getLocation(); AOperationType type = AstFactory.newAOperationType(invloc, new Vector<PType>(), AstFactory.newABooleanBasicType(invloc)); type.setPure(true); LexNameToken invname = new LexNameToken(d.getName().getName(), "inv_" + d.getName().getName(), invloc); PStm body = AstFactory.newAClassInvariantStm(invname, invdefs); return AstFactory.newAExplicitOperationDefinition(invname, type, new Vector<PPattern>(), null, null, body); }
@Override public String toString() { return type.toString(); }
if (!deftype.getParameters().isEmpty()) Iterator<PType> types = deftype.getParameters().iterator();
PDefinition encl = question.env.getEnclosingDefinition(); if (encl != null && encl.getAccess().getPure() && !optype.getPure()) node.getName().setTypeQualifier(optype.getParameters()); checkArgTypes(node, optype, optype.getParameters(), atypes, question); node.setType(optype.getResult()); return question.assistantFactory.createPTypeAssistant().checkReturnType(question.returnType, optype.getResult(), node.getLocation()); } else if (question.assistantFactory.createPTypeAssistant().isFunction(type))
private TypeCompatibilityObligation(AImplicitOperationDefinition def, PType actualResult, IPOContextStack ctxt, IPogAssistantFactory assistantFactory) throws AnalysisException { super(def, POType.TYPE_COMP, ctxt, def.getLocation(), assistantFactory); this.assistantFactory = assistantFactory; PExp result = null; if (def.getResult().getPattern() instanceof AIdentifierPattern) { AIdentifierPattern ip = (AIdentifierPattern) def.getResult().getPattern(); result = AstFactory.newAVariableExp(ip.getName()); } else { ATuplePattern tp = (ATuplePattern) def.getResult().getPattern(); List<PExp> args = new ArrayList<PExp>(); for (PPattern p : tp.getPlist()) { AIdentifierPattern ip = (AIdentifierPattern) p; args.add(AstFactory.newAVariableExp(ip.getName())); } result = AstFactory.newATupleExp(def.getLocation(), args); } stitch = oneType(false, result, ((AOperationType) def.getType()).getResult().clone(), actualResult.clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
PDefinition def = readOperationDefinition(); def.setAccess(access); ((AOperationType)def.getType()).setPure(access.getPure()); list.add(def);