1 20 21 package soot.dava.internal.AST; 22 23 import soot.*; 24 import java.util.*; 25 import soot.dava.toolkits.base.AST.*; 26 import soot.dava.toolkits.base.AST.analysis.*; 27 28 public abstract class ASTNode extends AbstractUnit 29 { 30 public static final String 31 TAB = " ", 32 NEWLINE = "\n"; 33 34 protected List subBodies; 35 36 public ASTNode() 37 { 38 subBodies = new ArrayList(); 39 } 40 41 public abstract void toString( UnitPrinter up ); 42 43 protected void body_toString( UnitPrinter up, List body ) 44 { 45 Iterator it = body.iterator(); 46 while (it.hasNext()) { 47 ((ASTNode) it.next()).toString( up ); 48 49 if (it.hasNext()) 50 up.newline(); 51 } 52 } 53 54 protected String body_toString(List body) 55 { 56 StringBuffer b = new StringBuffer (); 57 58 Iterator it = body.iterator(); 59 while (it.hasNext()) { 60 b.append( ((ASTNode) it.next()).toString()); 61 62 if (it.hasNext()) 63 b.append( NEWLINE); 64 } 65 66 return b.toString(); 67 } 68 69 public List get_SubBodies() 70 { 71 return subBodies; 72 } 73 74 75 public abstract void perform_Analysis( ASTAnalysis a); 76 77 protected void perform_AnalysisOnSubBodies( ASTAnalysis a) 78 { 79 Iterator sbit = subBodies.iterator(); 80 while (sbit.hasNext()) { 81 Object subBody = sbit.next(); 82 Iterator it = null; 83 84 if (this instanceof ASTTryNode) 85 it = ((List) ((ASTTryNode.container) subBody).o).iterator(); 86 else 87 it = ((List) subBody).iterator(); 88 89 while (it.hasNext()) 90 ((ASTNode) it.next()).perform_Analysis( a); 91 } 92 93 a.analyseASTNode( this); 94 } 95 96 public boolean fallsThrough() 97 { 98 return false; 99 } 100 101 public boolean branches() 102 { 103 return false; 104 } 105 106 111 public void apply(Analysis a){ 112 throw new RuntimeException ("Analysis invoked apply method on ASTNode"); 113 } 114 115 } 116 | Popular Tags |