@Override public void caseAModuleDeclIR(AModuleDeclIR node) throws AnalysisException { result = new AModuleDeclIR(); result.setExports(node.getExports()); result.setImport(node.getImport()); result.setIsDLModule(node.getIsDLModule()); result.setIsFlat(node.getIsFlat()); result.setMetaData(node.getMetaData()); result.setName(node.getName()); result.setSourceNode(node.getSourceNode()); result.setTag(node.getTag()); result.setDecls(node.getDecls()); filterFunctions(node.getDecls()); calcDependencies(); }
/** * Creates a new tree field only constructor {@code AModuleDeclIR TAG=module} 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 String} node for the {@code name} child of this {@link AModuleDeclIR} node * @param import_ the {@link AModuleImportsIR} node for the {@code import} child of this {@link AModuleDeclIR} node * @param exports_ the {@link AModuleExportsIR} node for the {@code exports} child of this {@link AModuleDeclIR} node * @param decls_ the {@link NodeList} node for the {@code decls} child of this {@link AModuleDeclIR} node * @param isFlat_ the {@link Boolean} node for the {@code isFlat} child of this {@link AModuleDeclIR} node * @param isDLModule_ the {@link Boolean} node for the {@code isDLModule} child of this {@link AModuleDeclIR} node */ public AModuleDeclIR(String name_, AModuleImportsIR import_, AModuleExportsIR exports_, List<? extends SDeclIR> decls_, Boolean isFlat_, Boolean isDLModule_) { super(null,null,null); this.setName(name_); this.setImport(import_); this.setExports(exports_); this.setDecls(decls_); this.setIsFlat(isFlat_); this.setIsDLModule(isDLModule_); }
/** * Returns a deep clone of this {@link AModuleDeclIR} node. * @return a deep clone of this {@link AModuleDeclIR} node */ public AModuleDeclIR clone() { return new AModuleDeclIR( _sourceNode, _tag, _metaData, _name, cloneNode(_import), cloneNode(_exports), cloneList(_decls), _isFlat, _isDLModule ); }
Boolean isFlat = node.getIsFlat(); AModuleDeclIR moduleCg = new AModuleDeclIR(); moduleCg.setName(name); moduleCg.setImport((AModuleImportsIR) importsCg); } else moduleCg.setExports((AModuleExportsIR) exportsCg); } else moduleCg.setIsDLModule(isDlModule); moduleCg.setIsFlat(isFlat); || declCg instanceof AFieldDeclIR) moduleCg.getDecls().add(declCg); } else
/** * Called by the {@link AModuleDeclIR} node from {@link AModuleDeclIR#apply(IIsaAnalysis)}. * @param node the calling {@link AModuleDeclIR} node */ public void caseAModuleDeclIR(AModuleDeclIR node) throws AnalysisException { _visitedNodes.add(node); inAModuleDeclIR(node); if(node.getImport() != null && !_visitedNodes.contains(node.getImport())) { node.getImport().apply(this); } if(node.getExports() != null && !_visitedNodes.contains(node.getExports())) { node.getExports().apply(this); } { List<SDeclIR> copy = new ArrayList<SDeclIR>(node.getDecls()); for( SDeclIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAModuleDeclIR(node); }
clazz.setSourceNode(node.getSourceNode()); clazz.setAccess(IRConstants.PUBLIC); clazz.setName(node.getName()); AMethodDeclIR privConstructor = info.getDeclAssistant().consDefaultContructor(node.getName()); privConstructor.setAccess(IRConstants.PRIVATE); clazz.getMethods().add(privConstructor); handleImports(node.getImport(), clazz); for (SDeclIR decl : new LinkedList<>(node.getDecls())) info.removeModule(node.getName()); info.addClass(clazz);
public AStateDeclIR getStateDecl(AModuleDeclIR module) { for (SDeclIR decl : module.getDecls()) { if (decl instanceof AStateDeclIR) { return (AStateDeclIR) decl; } } return null; }
@SuppressWarnings("unused") private AFieldDeclIR getValue(String fieldName, String moduleName) { for (AModuleDeclIR module : allModules) { if (module.getName().equals(moduleName)) { for (SDeclIR decl : module.getDecls()) { if (decl instanceof AFieldDeclIR) { AFieldDeclIR fieldDecl = (AFieldDeclIR) decl; if (fieldDecl.getName().equals(fieldName)) { return fieldDecl; } } } } } log.error("Could not find field " + fieldName + " in module " + moduleName); return null; }
public void removeModule(String name) { AModuleDeclIR moduleToRemove = null; for (AModuleDeclIR module : modules) { if (module.getName().equals(name)) { moduleToRemove = module; break; } } if (moduleToRemove != null) { modules.remove(moduleToRemove); } }
/** * Creates a new complete constructor {@code AModuleDeclIR} 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 String} node for the {@code name} child of this {@link AModuleDeclIR} node * @param import_ the {@link AModuleImportsIR} node for the {@code import} child of this {@link AModuleDeclIR} node * @param exports_ the {@link AModuleExportsIR} node for the {@code exports} child of this {@link AModuleDeclIR} node * @param decls_ the {@link NodeList} node for the {@code decls} child of this {@link AModuleDeclIR} node * @param isFlat_ the {@link Boolean} node for the {@code isFlat} child of this {@link AModuleDeclIR} node * @param isDLModule_ the {@link Boolean} node for the {@code isDLModule} child of this {@link AModuleDeclIR} node */ public AModuleDeclIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, String name_, AModuleImportsIR import_, AModuleExportsIR exports_, List<? extends SDeclIR> decls_, Boolean isFlat_, Boolean isDLModule_) { super(sourceNode_,tag_,metaData_); this.setName(name_); this.setImport(import_); this.setExports(exports_); this.setDecls(decls_); this.setIsFlat(isFlat_); this.setIsDLModule(isDLModule_); }
/** * Called by the {@link AModuleDeclIR} node from {@link AModuleDeclIR#apply(IAnalysis)}. * @param node the calling {@link AModuleDeclIR} node */ public void caseAModuleDeclIR(AModuleDeclIR node) throws AnalysisException { _visitedNodes.add(node); inAModuleDeclIR(node); if(node.getImport() != null && !_visitedNodes.contains(node.getImport())) { node.getImport().apply(this); } if(node.getExports() != null && !_visitedNodes.contains(node.getExports())) { node.getExports().apply(this); } { List<SDeclIR> copy = new ArrayList<SDeclIR>(node.getDecls()); for( SDeclIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAModuleDeclIR(node); }
/** * Creates a deep clone of this {@link AModuleDeclIR} 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 AModuleDeclIR} node */ public AModuleDeclIR clone(Map<INode,INode> oldToNewMap) { AModuleDeclIR node = new AModuleDeclIR( _sourceNode, _tag, _metaData, _name, cloneNode(_import, oldToNewMap), cloneNode(_exports, oldToNewMap), cloneList(_decls, oldToNewMap), _isFlat, _isDLModule ); oldToNewMap.put(this, node); return node; }
public String getEnclosingModuleName(AStateDeclIR stateDecl) { AModuleDeclIR module = stateDecl.getAncestor(AModuleDeclIR.class); if (module != null) { return module.getName(); } else { log.error("Could not find enclosing module name of state declaration " + stateDecl.getName()); return null; } }
/** * Called by the {@link AModuleDeclIR} node from {@link AModuleDeclIR#apply(IAnalysis)}. * @param node the calling {@link AModuleDeclIR} node */ public void caseAModuleDeclIR(AModuleDeclIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAModuleDeclIR(node, question); if(node.getImport() != null && !_visitedNodes.contains(node.getImport())) { node.getImport().apply(this, question); } if(node.getExports() != null && !_visitedNodes.contains(node.getExports())) { node.getExports().apply(this, question); } { List<SDeclIR> copy = new ArrayList<SDeclIR>(node.getDecls()); for( SDeclIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } outAModuleDeclIR(node, question); }
private void groupDeps() { StrongConnectivityInspector<AFuncDeclIR, DefaultEdge> visitor = new StrongConnectivityInspector<>(deps); for (Set<AFuncDeclIR> scs : visitor.stronglyConnectedSets()) { if (scs.size() > 1) { AMrFuncGroupDeclIR aux = new AMrFuncGroupDeclIR(); aux.setFuncs(new LinkedList<>(scs)); // this line also removes the function from the functions block result.getDecls().add(aux); } } }
/** * Called by the {@link AModuleDeclIR} node from {@link AModuleDeclIR#apply(IAnalysis)}. * @param node the calling {@link AModuleDeclIR} node */ public A caseAModuleDeclIR(AModuleDeclIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAModuleDeclIR(node, question)); if(node.getImport() != null && !_visitedNodes.contains(node.getImport())) { mergeReturns(retVal,node.getImport().apply(this, question)); } if(node.getExports() != null && !_visitedNodes.contains(node.getExports())) { mergeReturns(retVal,node.getExports().apply(this, question)); } { List<SDeclIR> copy = new ArrayList<SDeclIR>(node.getDecls()); for( SDeclIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } mergeReturns(retVal,outAModuleDeclIR(node, question)); return retVal; }
@Override public void caseAStateDeclIR(AStateDeclIR node) throws AnalysisException { if (node.getInitDecl() != null) { AMethodDeclIR initOp; if (node.getExecutable()) { initOp = makeExecutableInit(node); } else { initOp = info.getDeclAssistant().funcToMethod(node.getInitDecl()); } AModuleDeclIR module = node.getAncestor(AModuleDeclIR.class); module.getDecls().add(initOp); node.setInitDecl(null); } }
/** * Called by the {@link AModuleDeclIR} node from {@link AModuleDeclIR#apply(IAnalysis)}. * @param node the calling {@link AModuleDeclIR} node */ public A caseAModuleDeclIR(AModuleDeclIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAModuleDeclIR(node)); if(node.getImport() != null && !_visitedNodes.contains(node.getImport())) { mergeReturns(retVal,node.getImport().apply(this)); } if(node.getExports() != null && !_visitedNodes.contains(node.getExports())) { mergeReturns(retVal,node.getExports().apply(this)); } { List<SDeclIR> copy = new ArrayList<SDeclIR>(node.getDecls()); for( SDeclIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this)); } } } mergeReturns(retVal,outAModuleDeclIR(node)); return retVal; }
for (SDeclIR d : m.getIrNode().getDecls())