// Statement ea = new EmptyStm(v, s.getOrigin()); // initialisation value for the global var
// graph.addNode(ea);
// graph.addEntry(ea);
}
// add use edge
graph.addEdge(join, s, new VariableFilter(v));
// remove the variable from the outflow of the statement
for (Edge<Statement,VariableFilter> edge : graph.getOutEdges(s))
edge.getData().removeVariable(v);
}
}
public void visitAnalyzeStm(AnalyzeStm s) {
use(s.getBase(), s);
}
public void visitConcatStm(ConcatStm s) {
use(s.getXMLSource(), s);
}
public void visitConstStm(ConstStm s) {
// do nothing
}
public void visitCopyStm(CopyStm s) {
use(s.getBase(), s);
if (s.getFirstChild() != null)
use(s.getFirstChild(), s);
if (s.getFirstAttr() != null)
use(s.getFirstAttr(), s);
if (s.getNextNode() != null)
use(s.getNextNode(), s);
}
public void visitCastStm(CastStm s) {
use(s.getBase(), s);
}
public void visitCheckStm(CheckStm s) {
if (s.getBase() != null)
use(s.getBase(), s);
}
public void visitEmptyStm(EmptyStm s) {
// do nothing
}
public void visitGapifyStm(GapifyStm s) {
use(s.getBase(), s);
}
public void visitGetStm(GetStm s) {
use(s.getBase(), s);
}
public void visitInsertStm(InsertStm s) {
use(s.getBase(), s);
if (s.getXMLSource() != null)
use(s.getXMLSource(), s);
}
public void visitNodeStm(NodeStm s) {
if (s.getFirstChild() != null)
use(s.getFirstChild(), s);
if (s.getFirstAttr() != null)
use(s.getFirstAttr(), s);
if (s.getNextNode() != null)
use(s.getNextNode(), s);
}
public void visitNopStm(NopStm s) {
// do nothing
}
public void visitPlugStm(PlugStm s) {
use(s.getBase(), s);
if (s.getXMLSource() != null)
use(s.getXMLSource(), s);
}
public void visitRemoveStm(RemoveStm s) {
use(s.getBase(), s);
}
public void visitSetStm(SetStm s) {
use(s.getBase(), s);
if (s.getXMLSource() != null)
use(s.getXMLSource(), s);
}
public void visitUnknownStm(UnknownStm s) {
// do nothing
}
public void visitValidateStm(ValidateStm s) {
if (s.getBase() != null)
use(s.getBase(), s);
}
public void visitVarStm(VarStm s) {
use(s.getSource(), s);
}
// not in this phase
public void visitArrayReadStm(ArrayReadStm s) {
}
public void visitArrayWriteStm(ArrayWriteStm s) {
}
public void visitArrayWriteStringStm(ArrayWriteStringStm s) {
}
public void visitCallStm(CallStm s) {
}
public void visitEscapeStm(EscapeStm s) {
}
});
// insert edges from definitions to single global use
for (Statement s : new LinkedHashSet<Statement>(graph.getNodes()))
if (s instanceof Assignment) {
Variable v = ((Assignment)s).getDest();
if (v.isGlobal()) {
Debug.println(6, true, "Redirecting join flow edge for " + v + " (assigned in " + s + ")");
// remove the variable from the outflow of the statement
for (Edge<Statement,VariableFilter> edge : graph.getOutEdges(s))
edge.getData().removeVariable(v);
// insert new edge to the single global use (which only exists if it is used somewhere)
if (global_use.containsKey(v)) {
graph.addEdge(s, global_use.get(v), new VariableFilter(v));
}
}
}
}