/** * Collect all nodes from a given ControlFlowGraph * @param graph The ControlFlowGraph * @return The collected nodes */ public static LinkedList<Node> collectNodes(ControlFlowGraph graph) { NodeCollector collector = new NodeCollector(); graph.accept(collector); return collector.nodes; }
/** * Returns all AssignmentNode variables including their colors * @param graph The graph * @return A map of the variables to their colors */ public static HashMap<String, Color> getColors(ControlFlowGraph graph) { ColorEvaluater evaluater = new ColorEvaluater(); graph.accept(evaluater); return evaluater.colors; }
/** * Counts the macrocalls in a control flow graph * @param graph The graph * @return The number of macrocalls in the given graph */ public static int countMacroCallsInGraph(ControlFlowGraph graph) { MacroCallCounter counter = new MacroCallCounter(); graph.accept(counter); return counter.count; }
/** * Replaces divisions with constants with multiplications * @param graph The graph */ public static void transform(ControlFlowGraph graph) { ConstantDivisionTransformer transformer = new ConstantDivisionTransformer(); graph.accept(transformer); }
public static void print(ControlFlowGraph graph, OutputStream output) { CFGExtendedPrinter printer = new CFGExtendedPrinter(output); graph.accept(printer); try { output.flush(); } catch (IOException ex) { Logger.getLogger(CFGExtendedPrinter.class.getName()).log(Level.SEVERE, null, ex); } }
public static HashMap<String, double[]> evaluateValues(ControlFlowGraph graph) { ValueEvaluater valueEvaluater = new ValueEvaluater(); graph.accept(valueEvaluater); return valueEvaluater.values; }
/** * Returns all AssignmentNode variables including their colors * @param graph The graph * @return A map of the variables to their colors */ public static HashMap<String, Color> getColors(ControlFlowGraph graph) { ColorEvaluater evaluater = new ColorEvaluater(); graph.accept(evaluater); return evaluater.colors; }
/** * Should be called to notify the graph builder that the parsing process has finished. If needed, post-processing of * the graph can be performed here. */ public void finish() { //Check, if the cluscript contains at least one '?'-mark is moved to algebra plugin, //because of problems in macros.clu parsing in algebra plugin SetCallerVisitor visitor = new SetCallerVisitor(); graph.accept(visitor); SetLocalAndInputVariables inputFinder = new SetLocalAndInputVariables(); graph.accept(inputFinder); }
/** * Collects the names of all output variables in a control flow graph and returns the list * @param graph The control flow graph * @return The names of all output variables in the given control flow graph */ public static LinkedList<String> getVariableNames(ControlFlowGraph graph) { FindOutputVariableNames findOutputVariableNames = new FindOutputVariableNames(); graph.accept(findOutputVariableNames); return findOutputVariableNames.variableNames; }
/** * Collects all macros in a given ControlFlowGraph and stores them in a new Map * @param graph The ControlFlowGraph * @return The new Map */ public static HashMap<StringIntContainer, Macro> getAllMacros(ControlFlowGraph graph) { MacrosVisitor visitor = new MacrosVisitor(); visitor.macrosMap = new HashMap<StringIntContainer, Macro>(); graph.accept(visitor); return visitor.macrosMap; }
/** * Collects all macros in a given ControlFlowGraph and adds them to a Map * @param graph The ControlFlowGraph * @param mapToUse The map to use for adding */ public static void getAllMacros(ControlFlowGraph graph, HashMap<StringIntContainer, Macro> mapToUse) { MacrosVisitor visitor = new MacrosVisitor(); visitor.macrosMap = mapToUse; graph.accept(visitor); }
@Override //cfg public void visit(EndNode node) { System.out.println("CSE Collection erfolgreich beendet ---> Starte CSE Replacement"); cfg.accept(new CSE_Replacer(opstor)); opstor.printSummary(); } private boolean isSquare(Exponentiation exponentiation) {
/** * Generates source code for a control dataflow graph. * * @param in * @return */ private String generateCode(ControlFlowGraph in) { CfgVisitor visitor = new CfgVisitor(suffix); in.accept(visitor); return visitor.getCode(); }
public static void inline(ControlFlowGraph graph, HashMap<StringIntContainer, Macro> macros) { Inliner inliner = new Inliner(macros, graph); while (!inliner.error && MacroCallCounter.countMacroCallsInGraph(graph)>0) graph.accept(inliner); }
@Override public boolean transform(ControlFlowGraph graph, UseAlgebra usedAlgebra) { ConstantPropagation propagation = new ConstantPropagation(); graph.accept(propagation); return propagation.isGraphModified(); } }
/** * Returns a variable, which has multiple assignments in a given ControlFlowGraph * @param graph The ControlFlowGraph * @return The variable, which has multiple assignments in a given ControlFlowGraph, null if there are no multiple assignments */ public static Variable getMulipleAssignments(ControlFlowGraph graph) { GetMultipleAssignments g = new GetMultipleAssignments(); graph.accept(g); return g.getMultipleAssignmentsVariable(); }
/** * Removes the DefVars statement from a given Control Flow Graph * @param graph The Control Flow Graph */ public static void removeDefVars(ControlFlowGraph graph) { RemoveDefVars visitor = new RemoveDefVars(); graph.accept(visitor); for (SequentialNode node: visitor.toRemove) graph.removeNode(node); }
/** * Updates the LocalVariable-set in a graph * @param graph The graph */ public static void updateVariableSets(ControlFlowGraph graph) { VariablesCollector collector = new VariablesCollector(); graph.accept(collector); LinkedList<Variable> vars = new LinkedList<Variable>(graph.getLocalVariables()); for (Variable v: vars) if (!collector.getVariables().contains(v.getName())) graph.removeLocalVariable(v); }
/** * Generates source code for a control dataflow graph. * * @param in * @return */ private String generateCode(ControlFlowGraph in) { CppVisitor visitor = new CppVisitor(plugin.getVariableType()); in.accept(visitor); return visitor.getCode(); }
public VerilogDFG(ControlFlowGraph in) { this.setCfg(in); originalstart = in.getStartNode(); originalend = in.getEndNode(); this.startnode= new VerilogNode(this) ; this.endnode = new VerilogNode(this); irvisit = new VerilogIRConverterVisitorCookies(this); in.accept(irvisit); // TODO Auto-generated constructor stub }