@Override public void caseAIdentifierPattern(AIdentifierPattern node) throws AnalysisException { if (proceed(node)) { if (node.getName().equals(name)) { idOccurences.add(node); } } } }
private PPattern makePattern(ILexNameToken name) { AIdentifierPattern pattern = new AIdentifierPattern(); pattern.setName(name); return pattern; }
/** * Called by the {@link AIdentifierPattern} node from {@link AIdentifierPattern#apply(IPOFAnalysis)}. * @param node the calling {@link AIdentifierPattern} node */ public void caseAIdentifierPattern(AIdentifierPattern node) throws AnalysisException { _visitedNodes.add(node); inAIdentifierPattern(node); { List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getName() != null ) { node.getName().apply(this); } outAIdentifierPattern(node); }
/** * Creates a new complete constructor {@code AIdentifierPattern} 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 name_ the {@link ILexNameToken} node for the {@code name} child of this {@link AIdentifierPattern} node * @param constrained_ the {@link Boolean} node for the {@code constrained} child of this {@link AIdentifierPattern} node */ public AIdentifierPattern(ILexLocation location_, List<? extends PDefinition> definitions_, Boolean resolved_, ILexNameToken name_, Boolean constrained_) { super(location_,definitions_,resolved_); this.setName(name_); this.setConstrained(constrained_); }
/** * Returns a deep clone of this {@link AIdentifierPattern} node. * @return a deep clone of this {@link AIdentifierPattern} node */ public AIdentifierPattern clone() { return new AIdentifierPattern( _location, cloneList(_definitions), _resolved, cloneNode(_name), _constrained ); }
AIdentifierPattern idPat = new AIdentifierPattern(); idPat.setName(gen.getUnique(var.getName().getName())); pats.add(idPat); newVar.setName(idPat.getName().clone()); newVar.setOriginal(idPat.getName().getFullName());
public static AIdentifierPattern newAIdentifierPattern(ILexNameToken token) { AIdentifierPattern result = new AIdentifierPattern(); initPattern(result, token.getLocation()); result.setLocation(token.getLocation()); result.setName(token); result.setConstrained(false); return result; }
public NameValuePairList getNamedValues(PPattern p, Value expval, Context ctxt) throws AnalysisException { List<AIdentifierPattern> ids = af.createPPatternAssistant().findIdentifiers(p); // Go through the list of IDs, marking duplicate names as constrained. This is // because we have to permute sets that contain duplicate variables, so that // we catch permutations that match constrained values of the variable from // elsewhere in the pattern. int count = ids.size(); for (int i = 0; i < count; i++) { ILexNameToken iname = ids.get(i).getName(); for (int j = i + 1; j < count; j++) { if (iname.equals(ids.get(j).getName())) { ids.get(i).setConstrained(true); ids.get(j).setConstrained(true); } } } List<NameValuePairList> all = getAllNamedValues(p, expval, ctxt); return all.get(0); // loose choice here! }
@Override public List<PDefinition> caseAIdentifierPattern(AIdentifierPattern pattern, NewQuestion question) throws AnalysisException { List<PDefinition> defs = new ArrayList<PDefinition>(); defs.add(AstFactory.newALocalDefinition(pattern.getLocation(), pattern.getName().clone(), question.scope, question.ptype)); return defs; }
/** * Creates a deep clone of this {@link AIdentifierPattern} 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 AIdentifierPattern} node */ public AIdentifierPattern clone(Map<INode,INode> oldToNewMap) { AIdentifierPattern node = new AIdentifierPattern( _location, cloneList(_definitions, oldToNewMap), _resolved, cloneNode(_name, oldToNewMap), _constrained ); oldToNewMap.put(this, node); return node; }
@Override public List<NameValuePairList> caseAIdentifierPattern( AIdentifierPattern pattern, Newquestion question) throws AnalysisException { List<NameValuePairList> result = new Vector<NameValuePairList>(); NameValuePairList list = new NameValuePairList(); list.add(new NameValuePair(pattern.getName(), question.expval)); result.add(list); return result; }
/** * Called by the {@link AIdentifierPattern} node from {@link AIdentifierPattern#apply(IAnalysis)}. * @param node the calling {@link AIdentifierPattern} node */ public void caseAIdentifierPattern(AIdentifierPattern node) throws AnalysisException { _visitedNodes.add(node); inAIdentifierPattern(node); { List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getName() != null ) { node.getName().apply(this); } outAIdentifierPattern(node); }
/** * Create a multiple type bind with a varargs list of pattern variables, like a,b,c:T. This is used by several * obligations. */ protected PMultipleBind getMultipleTypeBind(PType patternType, ILexNameToken... patternNames) { ATypeMultipleBind typeBind = new ATypeMultipleBind(); List<PPattern> patternList = new Vector<PPattern>(); for (ILexNameToken patternName : patternNames) { AIdentifierPattern pattern = new AIdentifierPattern(); pattern.setName(patternName.clone()); patternList.add(pattern); } typeBind.setPlist(patternList); typeBind.setType(patternType.clone()); return typeBind; }
@Override public LexNameList caseAIdentifierPattern(AIdentifierPattern pattern) throws AnalysisException { LexNameList list = new LexNameList(); list.add(pattern.getName()); return list; }
/** * Called by the {@link AIdentifierPattern} node from {@link AIdentifierPattern#apply(IAnalysis)}. * @param node the calling {@link AIdentifierPattern} node */ public void caseAIdentifierPattern(AIdentifierPattern node, Q question) throws AnalysisException { _visitedNodes.add(node); inAIdentifierPattern(node, question); { List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } if(node.getName() != null ) { node.getName().apply(this, question); } outAIdentifierPattern(node, question); }
/** * Create a multiple set bind with a varargs list of pattern variables, like a,b,c in set S. This is used by several * obligations. */ protected PMultipleBind getMultipleSetBind(PExp setExp, ILexNameToken... patternNames) { ASetMultipleBind setBind = new ASetMultipleBind(); List<PPattern> patternList = new Vector<PPattern>(); for (ILexNameToken patternName : patternNames) { AIdentifierPattern pattern = new AIdentifierPattern(); pattern.setName(patternName.clone()); patternList.add(pattern); } setBind.setPlist(patternList); setBind.setSet(setExp.clone()); return setBind; }
@Override public Boolean caseAValueDefinition(AValueDefinition node) throws AnalysisException { if (!(node.getPattern() != null && node.getPattern() instanceof AIdentifierPattern && isValidName(((AIdentifierPattern) node.getPattern()).getName()))) { invalidNodes.add(node); return false; } return true; }
/** * Called by the {@link AIdentifierPattern} node from {@link AIdentifierPattern#apply(IAnalysis)}. * @param node the calling {@link AIdentifierPattern} node */ public A caseAIdentifierPattern(AIdentifierPattern node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAIdentifierPattern(node, question)); { List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } if(node.getName() != null ) { mergeReturns(retVal,node.getName().apply(this, question)); } mergeReturns(retVal,outAIdentifierPattern(node, question)); return retVal; }
protected void addStateBinds(LinkedList<PMultipleBind> r) { if (stateDefinition != null) { ATypeMultipleBind tmBind2 = new ATypeMultipleBind(); AIdentifierPattern pattern = new AIdentifierPattern(); if (stateDefinition instanceof AStateDefinition) { AStateDefinition def = (AStateDefinition) stateDefinition; tmBind2.setType(def.getRecordType().clone()); pattern.setName(OLD_STATE_ARG.clone()); } else { SClassDefinition def = (SClassDefinition) stateDefinition; tmBind2.setType(def.getClasstype().clone()); pattern.setName(OLD_SELF_ARG.clone()); } List<PPattern> plist = new LinkedList<PPattern>(); plist.add(pattern); tmBind2.setPlist(plist); r.add(tmBind2); } }
@Override public SPatternIR caseAIdentifierPattern(AIdentifierPattern node, IRInfo question) throws AnalysisException { String name = node.getName().getName(); AIdentifierPatternIR idCg = new AIdentifierPatternIR(); idCg.setName(name); return idCg; }