1 4 package net.sourceforge.pmd.dfa; 5 6 import net.sourceforge.pmd.ast.SimpleNode; 7 8 import java.util.LinkedList ; 9 import java.util.List ; 10 import java.util.Stack ; 11 12 13 19 public class Structure { 20 21 private LinkedList dataFlow = new LinkedList (); 22 private Stack braceStack = new Stack (); 23 private Stack continueBreakReturnStack = new Stack (); 24 25 31 public IDataFlowNode createNewNode(SimpleNode node) { 32 return new DataFlowNode(node, this.dataFlow); 33 } 34 35 public IDataFlowNode createStartNode(int line) { 36 return new StartOrEndDataFlowNode(this.dataFlow, line, true); 37 } 38 39 public IDataFlowNode createEndNode(int line) { 40 return new StartOrEndDataFlowNode(this.dataFlow, line, false); 41 } 42 43 public IDataFlowNode getLast() { 44 return (IDataFlowNode) this.dataFlow.getLast(); 45 } 46 47 public IDataFlowNode getFirst() { 48 return (IDataFlowNode) this.dataFlow.getFirst(); 49 } 50 51 54 59 protected void pushOnStack(int type, IDataFlowNode node) { 60 StackObject obj = new StackObject(type, node); 61 if (type == NodeType.RETURN_STATEMENT || type == NodeType.BREAK_STATEMENT || type == NodeType.CONTINUE_STATEMENT) { 62 continueBreakReturnStack.push(obj); 64 } else { 65 braceStack.push(obj); 66 } 67 ((DataFlowNode) node).setType(type); 68 } 69 70 public List getBraceStack() { 71 return braceStack; 72 } 73 74 public List getContinueBreakReturnStack() { 75 return continueBreakReturnStack; 76 } 77 78 } 79 | Popular Tags |