public AMethodDeclIR getInvMethod(ATypeDeclIR typeDecl) { if (typeDecl.getInv() instanceof AMethodDeclIR) { return (AMethodDeclIR) typeDecl.getInv(); } else if (typeDecl.getInv() != null) { log.error("Expected named type invariant function " + "to be a method declaration at this point. Got: " + typeDecl.getDecl()); } return null; }
/** * Creates a new tree field only constructor {@code ATypeDeclIR TAG=type} 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 access_ the {@link String} node for the {@code access} child of this {@link ATypeDeclIR} node * @param inv_ the {@link SDeclIR} node for the {@code inv} child of this {@link ATypeDeclIR} node * @param decl_ the {@link SDeclIR} node for the {@code decl} child of this {@link ATypeDeclIR} node */ public ATypeDeclIR(String access_, SDeclIR inv_, SDeclIR decl_) { super(null,null,null); this.setAccess(access_); this.setInv(inv_); this.setDecl(decl_); }
/** * Returns a deep clone of this {@link ATypeDeclIR} node. * @return a deep clone of this {@link ATypeDeclIR} node */ public ATypeDeclIR clone() { return new ATypeDeclIR( _sourceNode, _tag, _metaData, _access, cloneNode(_inv), cloneNode(_decl) ); }
public boolean genDecl(ATypeDeclIR node) { return !(node.getDecl() instanceof ANamedTypeDeclIR); }
@Override public SDeclIR caseATypeDefinition(ATypeDefinition node, IRInfo question) throws AnalysisException { String access = node.getAccess().getAccess().toString(); PType type = node.getType(); SDeclIR declCg = type.apply(question.getDeclVisitor(), question); SDeclIR invCg = question.getSettings().generateInvariants() && node.getInvdef() != null ? node.getInvdef().apply(question.getDeclVisitor(), question) : null; ATypeDeclIR typeDecl = new ATypeDeclIR(); typeDecl.setAccess(access); typeDecl.setDecl(declCg); typeDecl.setInv(invCg); return typeDecl; }
/** * Called by the {@link ATypeImportIR} node from {@link ATypeImportIR#apply(IAnalysis)}. * @param node the calling {@link ATypeImportIR} node */ public void caseATypeImportIR(ATypeImportIR node) throws AnalysisException { _visitedNodes.add(node); inATypeImportIR(node); if(node.getDecl() != null && !_visitedNodes.contains(node.getDecl())) { node.getDecl().apply(this); } outATypeImportIR(node); }
typeDecl.setAccess(IRConstants.PUBLIC); ATypeDeclIR typeDecl = new ATypeDeclIR(); typeDecl.setAccess(IRConstants.PUBLIC); typeDecl.setDecl(record);
public String hackInv(ANamedTypeDeclIR type) { ATypeDeclIR tDecl = (ATypeDeclIR) type.parent(); if (tDecl.getInv() != null) { AFuncDeclIR invFunc = (AFuncDeclIR) tDecl.getInv(); StringBuilder sb = new StringBuilder(); sb.append("inv "); sb.append(invFunc.getFormalParams().get(0).getPattern().toString()); sb.append(" == "); sb.append(invFunc.getName()); sb.append("("); sb.append("&"); sb.append(invFunc.getFormalParams().get(0).getPattern().toString()); sb.append(")"); return sb.toString(); } return ""; }
public boolean isRecordDecl(ATypeDeclIR node) { return (node.getDecl() instanceof ARecordDeclIR); } }
/** * Called by the {@link ATypeImportIR} node from {@link ATypeImportIR#apply(IIsaAnalysis)}. * @param node the calling {@link ATypeImportIR} node */ public void caseATypeImportIR(ATypeImportIR node) throws AnalysisException { _visitedNodes.add(node); inATypeImportIR(node); if(node.getDecl() != null && !_visitedNodes.contains(node.getDecl())) { node.getDecl().apply(this); } outATypeImportIR(node); }
/** * Called by the {@link ATypeDeclIR} node from {@link ATypeDeclIR#apply(IAnalysis)}. * @param node the calling {@link ATypeDeclIR} node */ public void caseATypeDeclIR(ATypeDeclIR node) throws AnalysisException { _visitedNodes.add(node); inATypeDeclIR(node); if(node.getInv() != null && !_visitedNodes.contains(node.getInv())) { node.getInv().apply(this); } if(node.getDecl() != null && !_visitedNodes.contains(node.getDecl())) { node.getDecl().apply(this); } outATypeDeclIR(node); }
public List<ARecordDeclIR> getRecords(SClassDeclIR definingClass) { List<ARecordDeclIR> records = new LinkedList<ARecordDeclIR>(); for (ATypeDeclIR typeDecl : definingClass.getTypeDecls()) { SDeclIR decl = typeDecl.getDecl(); if (!(decl instanceof ARecordDeclIR)) { continue; } ARecordDeclIR recordDecl = (ARecordDeclIR) decl; records.add(recordDecl); } return records; }
/** * Called by the {@link ATypeImportIR} node from {@link ATypeImportIR#apply(IAnalysis)}. * @param node the calling {@link ATypeImportIR} node */ public void caseATypeImportIR(ATypeImportIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inATypeImportIR(node, question); if(node.getDecl() != null && !_visitedNodes.contains(node.getDecl())) { node.getDecl().apply(this, question); } outATypeImportIR(node, question); }
/** * Creates a new complete constructor {@code ATypeDeclIR} 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 access_ the {@link String} node for the {@code access} child of this {@link ATypeDeclIR} node * @param inv_ the {@link SDeclIR} node for the {@code inv} child of this {@link ATypeDeclIR} node * @param decl_ the {@link SDeclIR} node for the {@code decl} child of this {@link ATypeDeclIR} node */ public ATypeDeclIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, String access_, SDeclIR inv_, SDeclIR decl_) { super(sourceNode_,tag_,metaData_); this.setAccess(access_); this.setInv(inv_); this.setDecl(decl_); }
/** * Creates a deep clone of this {@link ATypeDeclIR} 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 ATypeDeclIR} node */ public ATypeDeclIR clone(Map<INode,INode> oldToNewMap) { ATypeDeclIR node = new ATypeDeclIR( _sourceNode, _tag, _metaData, _access, cloneNode(_inv, oldToNewMap), cloneNode(_decl, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ATypeDeclIR} node from {@link ATypeDeclIR#apply(IIsaAnalysis)}. * @param node the calling {@link ATypeDeclIR} node */ public void caseATypeDeclIR(ATypeDeclIR node) throws AnalysisException { _visitedNodes.add(node); inATypeDeclIR(node); if(node.getInv() != null && !_visitedNodes.contains(node.getInv())) { node.getInv().apply(this); } if(node.getDecl() != null && !_visitedNodes.contains(node.getDecl())) { node.getDecl().apply(this); } outATypeDeclIR(node); }
public List<ARecordDeclIR> getRecords(List<IRStatus<PIR>> ast) { List<ARecordDeclIR> records = new LinkedList<ARecordDeclIR>(); for (IRStatus<ADefaultClassDeclIR> classStatus : IRStatus.extract(ast, ADefaultClassDeclIR.class)) { for (ATypeDeclIR typeDecl : classStatus.getIrNode().getTypeDecls()) { if (typeDecl.getDecl() instanceof ARecordDeclIR) { records.add((ARecordDeclIR) typeDecl.getDecl()); } } } return records; }
/** * Called by the {@link ATypeImportIR} node from {@link ATypeImportIR#apply(IAnalysis)}. * @param node the calling {@link ATypeImportIR} node */ public A caseATypeImportIR(ATypeImportIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inATypeImportIR(node, question)); if(node.getDecl() != null && !_visitedNodes.contains(node.getDecl())) { mergeReturns(retVal,node.getDecl().apply(this, question)); } mergeReturns(retVal,outATypeImportIR(node, question)); return retVal; }