1 20 21 package soot.dava.internal.AST; 22 23 import soot.*; 24 import java.util.*; 25 import soot.jimple.*; 26 import soot.dava.internal.SET.*; 27 import soot.dava.toolkits.base.AST.*; 28 import soot.dava.toolkits.base.AST.analysis.*; 29 30 public class ASTIfNode extends ASTControlFlowNode 31 { 32 private List body; 33 34 public ASTIfNode( SETNodeLabel label, ConditionExpr condition, List body) 35 { 36 super( label, condition); 37 this.body = body; 38 39 subBodies.add( body); 40 } 41 42 43 48 public ASTIfNode( SETNodeLabel label, ASTCondition condition, List body) 49 { 50 super( label, condition); 51 this.body = body; 52 53 subBodies.add( body); 54 } 55 56 57 61 public List getIfBody(){ 62 return body; 63 } 64 65 public Object clone() 66 { 67 return new ASTIfNode( get_Label(), get_Condition(), body); 68 } 69 70 74 public void replace(SETNodeLabel label,ASTCondition condition, List body){ 75 this.body=body; 76 subBodies= new ArrayList(); 77 subBodies.add(body); 78 set_Condition(condition); 79 set_Label(label); 80 } 81 82 83 87 public void replaceBody(List body){ 88 this.body=body; 89 subBodies=new ArrayList(); 90 subBodies.add(body); 91 } 92 93 94 public void toString(UnitPrinter up) 95 { 96 label_toString(up); 97 98 up.literal( "if" ); 99 up.literal( " " ); 100 up.literal( "(" ); 101 condition.toString( up ); 102 up.literal( ")"); 103 up.newline(); 104 105 up.literal( "{" ); 106 up.newline(); 107 108 up.incIndent(); 109 body_toString( up, body ); 110 up.decIndent(); 111 112 up.literal( "}" ); 113 up.newline(); 114 } 115 public String toString() 116 { 117 StringBuffer b = new StringBuffer (); 118 119 b.append( label_toString()); 120 121 b.append( "if ("); 122 b.append( get_Condition().toString()); 123 b.append( ")"); 124 b.append( NEWLINE); 125 126 b.append( "{"); 127 b.append( NEWLINE); 128 129 b.append( body_toString(body)); 130 131 b.append( "}"); 132 b.append( NEWLINE); 133 134 return b.toString(); 135 } 136 137 138 139 144 public void apply(Analysis a){ 145 a.caseASTIfNode(this); 146 } 147 } 148 | Popular Tags |