1 19 20 package soot.dava.internal.SET; 21 22 import soot.*; 23 import soot.util.*; 24 import java.util.*; 25 import soot.dava.*; 26 import soot.jimple.*; 27 import soot.dava.internal.asg.*; 28 import soot.dava.internal.AST.*; 29 import soot.dava.internal.javaRep.*; 30 31 public class SETStatementSequenceNode extends SETNode 32 { 33 private DavaBody davaBody; 34 private boolean hasContinue; 35 36 public SETStatementSequenceNode( IterableSet body, DavaBody davaBody) 37 { 38 super( body); 39 add_SubBody( body); 40 41 this.davaBody = davaBody; 42 43 hasContinue = false; 44 } 45 46 public SETStatementSequenceNode( IterableSet body) 47 { 48 this( body, null); 49 } 50 51 public boolean has_Continue() 52 { 53 return hasContinue; 54 } 55 56 public IterableSet get_NaturalExits() 57 { 58 IterableSet c = new IterableSet(); 59 AugmentedStmt last = (AugmentedStmt) get_Body().getLast(); 60 61 if ((last.csuccs != null) && (last.csuccs.isEmpty() == false)) 62 c.add( last); 63 64 return c; 65 } 66 67 public ASTNode emit_AST() 68 { 69 List l = new LinkedList(); 70 71 boolean isStaticInitializer = davaBody.getMethod().getName().equals( SootMethod.staticInitializerName); 72 73 Iterator it = get_Body().iterator(); 74 while (it.hasNext()) { 75 AugmentedStmt as = (AugmentedStmt) it.next(); 76 Stmt s = as.get_Stmt(); 77 78 if (davaBody != null) { 79 80 if ((s instanceof ReturnVoidStmt) && (isStaticInitializer)) 81 continue; 82 83 if (s instanceof GotoStmt) 84 continue; 85 86 if (s instanceof MonitorStmt) 87 continue; 88 89 95 if (s == davaBody.get_ConstructorUnit()){ 96 } 99 100 101 102 if (s instanceof IdentityStmt) { 103 IdentityStmt ids = (IdentityStmt) s; 104 105 Value 106 rightOp = ids.getRightOp(), 107 leftOp = ids.getLeftOp(); 108 109 if (davaBody.get_ThisLocals().contains( leftOp)) 110 continue; 111 112 if (rightOp instanceof ParameterRef) 113 continue; 114 115 if (rightOp instanceof CaughtExceptionRef) 116 continue; 117 } 118 } 119 120 l.add( as); 121 } 122 123 if (l.isEmpty()) 124 return null; 125 else 126 return new ASTStatementSequenceNode( l); 127 } 128 129 public AugmentedStmt get_EntryStmt() 130 { 131 return (AugmentedStmt) get_Body().getFirst(); 132 } 133 134 135 public void insert_AbruptStmt( DAbruptStmt stmt) 136 { 137 if (hasContinue) 138 return; 139 140 get_Body().addLast( new AugmentedStmt( stmt)); 141 hasContinue = stmt.is_Continue(); 142 } 143 144 protected boolean resolve( SETNode parent) 145 { 146 throw new RuntimeException ( "Attempting auto-nest a SETStatementSequenceNode."); 147 } 148 } 149 | Popular Tags |