/** * Called by the {@link APatternTypePair} node from {@link APatternTypePair#apply(IPOFAnalysis)}. * @param node the calling {@link APatternTypePair} node */ public void caseAPatternTypePair(APatternTypePair node) throws AnalysisException { _visitedNodes.add(node); inAPatternTypePair(node); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { node.getPattern().apply(this); } if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } outAPatternTypePair(node); }
public void typeResolve(APatternTypePair result, IQuestionAnswer<TypeCheckInfo, PType> rootVisitor, TypeCheckInfo question) { if (result.getResolved()) { return; } else { result.setResolved(true); } result.setType(af.createPTypeAssistant().typeResolve(result.getType(), null, rootVisitor, question)); }
public static APatternTypePair newAPatternTypePair(PPattern pattern, PType type) { APatternTypePair result = new APatternTypePair(); result.setResolved(false); result.setPattern(pattern); result.setType(type); return result; }
/** * Returns a deep clone of this {@link APatternTypePair} node. * @return a deep clone of this {@link APatternTypePair} node */ public APatternTypePair clone() { return new APatternTypePair( _resolved, cloneNode(_pattern), _type ); }
/** * Creates a new complete constructor {@code APatternTypePair} 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 pattern_ the {@link PPattern} node for the {@code pattern} child of this {@link APatternTypePair} node * @param type_ the {@link PType} <b>graph</a> node for the {@code type} child of this {@link APatternTypePair} node. * <i>The parent of this {@code type } will not be changed by adding it to this node.</i> */ public APatternTypePair(Boolean resolved_, PPattern pattern_, PType type_) { super(resolved_); this.setPattern(pattern_); this.setType(type_); }
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()); }
node.getResult().apply(this);
AFunctionType type = AstFactory.newAFunctionType(result.getLocation(), false, ptypes, resultPattern.getType()); type.setInstantiated(typeParams == null || typeParams.isEmpty() ? null : false);
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)); }
node.getResult().apply(this, question);
public static AImplicitOperationDefinition newAImplicitOperationDefinition( ILexNameToken name, List<APatternListTypePair> parameterPatterns, APatternTypePair resultPattern, PStm body, ASpecificationStm spec) { AImplicitOperationDefinition result = new AImplicitOperationDefinition(); // Definition initialization initDefinition(result, Pass.DEFS, name.getLocation(), name, NameScope.GLOBAL); result.setParameterPatterns(parameterPatterns); result.setResult(resultPattern); result.setBody(body); result.setExternals(spec.getExternals()); result.setPrecondition(spec.getPrecondition()); result.setPostcondition(spec.getPostcondition()); result.setErrors(spec.getErrors()); result.setIsConstructor(false); List<PType> ptypes = new Vector<PType>(); for (APatternListTypePair ptp : parameterPatterns) { ptypes.addAll(getTypeList(ptp)); } AOperationType operationType = AstFactory.newAOperationType(result.getLocation(), ptypes, result.getResult() == null ? AstFactory.newAVoidType(name.getLocation()) : result.getResult().getType()); result.setType(operationType); return result; }
/** * Creates a deep clone of this {@link APatternTypePair} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link APatternTypePair} node */ public APatternTypePair clone(Map<INode,INode> oldToNewMap) { APatternTypePair node = new APatternTypePair( _resolved, cloneNode(_pattern, oldToNewMap), _type ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link APatternTypePair} node from {@link APatternTypePair#apply(IAnalysis)}. * @param node the calling {@link APatternTypePair} node */ public void caseAPatternTypePair(APatternTypePair node) throws AnalysisException { _visitedNodes.add(node); inAPatternTypePair(node); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { node.getPattern().apply(this); } if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } outAPatternTypePair(node); }
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; }
node.getResult().apply(this);
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());
/** * Called by the {@link APatternTypePair} node from {@link APatternTypePair#apply(IAnalysis)}. * @param node the calling {@link APatternTypePair} node */ public void caseAPatternTypePair(APatternTypePair node, Q question) throws AnalysisException { _visitedNodes.add(node); inAPatternTypePair(node, question); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { node.getPattern().apply(this, question); } if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } outAPatternTypePair(node, question); }
plist.add(d.getResult().getPattern().clone());
node.getResult().apply(this, question);
public List<PDefinition> getDefinitions(APatternTypePair result) { return af.createPPatternAssistant().getDefinitions(result.getPattern(), result.getType(), NameScope.LOCAL); }