1 20 21 package soot.dava; 22 23 24 import java.io.BufferedWriter ; 25 import java.io.FileNotFoundException ; 26 import java.io.FileOutputStream ; 27 import java.io.IOException ; 28 import java.io.OutputStreamWriter ; 29 import java.io.PrintStream ; 30 import java.io.UnsupportedEncodingException ; 31 import java.io.Writer ; 32 33 import soot.Body; 34 import soot.CompilationDeathException; 35 import soot.G; 36 import soot.Local; 37 import soot.Singletons; 38 import soot.SootMethod; 39 import soot.Type; 40 import soot.jimple.Jimple; 41 import soot.util.IterableSet; 42 43 44 45 public class Dava 46 { 47 public Dava( Singletons.Global g ) {} 48 public static Dava v() { return G.v().soot_dava_Dava(); } 49 private static final String LOG_TO_FILE = null; 50 private static final PrintStream LOG_TO_SCREEN = null; 51 52 private Writer iOut = null; 53 private IterableSet currentPackageContext = null; 54 private String currentPackage; 55 56 public void set_CurrentPackage( String cp) 57 { 58 currentPackage = cp; 59 } 60 61 public String get_CurrentPackage() 62 { 63 return currentPackage; 64 } 65 66 public void set_CurrentPackageContext( IterableSet cpc) 67 { 68 currentPackageContext = cpc; 69 } 70 71 public IterableSet get_CurrentPackageContext() 72 { 73 return currentPackageContext; 74 } 75 76 public DavaBody newBody(SootMethod m) 77 { 78 return new DavaBody( m); 79 } 80 81 82 public DavaBody newBody(Body b) 83 { 84 return new DavaBody(b); 85 } 86 87 public Local newLocal(String name, Type t) 88 { 89 return Jimple.v().newLocal(name, t); 90 } 91 92 public void log( String s) 93 { 94 if (LOG_TO_SCREEN != null) { 95 LOG_TO_SCREEN.println( s); 96 LOG_TO_SCREEN.flush(); 97 } 98 99 if (LOG_TO_FILE != null) { 100 if (iOut == null) 101 try { 102 iOut = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( LOG_TO_FILE), "US-ASCII")); 103 } 104 catch (FileNotFoundException fnfe) { 105 G.v().out.println( "Unable to open " + LOG_TO_FILE); 106 fnfe.printStackTrace(); 107 throw new CompilationDeathException(CompilationDeathException.COMPILATION_ABORTED); 108 } 109 catch (UnsupportedEncodingException uee) { 110 G.v().out.println( "This system doesn't support US-ASCII encoding!!"); 111 uee.printStackTrace(); 112 throw new CompilationDeathException(CompilationDeathException.COMPILATION_ABORTED); 113 } 114 115 try { 116 iOut.write( s); 117 iOut.write( "\n"); 118 iOut.flush(); 119 } 120 catch (IOException ioe) { 121 G.v().out.println( "Unable to write to " + LOG_TO_FILE); 122 ioe.printStackTrace(); 123 throw new CompilationDeathException(CompilationDeathException.COMPILATION_ABORTED); 124 } 125 } 126 } 127 } 128 129 130 131 132 133 134 | Popular Tags |