Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

MethodInfo.java

00001 package gov.nasa.arc.ase.jpf.jvm;
00002 
00003 import de.fub.bytecode.classfile.*;
00004 import de.fub.bytecode.generic.*;
00005 import gov.nasa.arc.ase.jpf.*;
00006 import gov.nasa.arc.ase.util.Debug;
00007 
00008 public class MethodInfo {
00009 
00010   // Name of the method (string)
00011   private String              method_name;
00012   // "Better" represnetation of a Method's information (from JavaClass)
00013   private MethodGen           mg;
00014   // All instructions in method
00015   private InstructionHandle[] ihs;
00016   // All ExceptionHandlers in method
00017   private CodeExceptionGen[] exceptions;
00018   // Constant pool for resolution
00019   private ConstantPoolGen     cpg;
00020   // Class information for class this method is part of
00021   private ClassInfo           ci;
00022   // Table of line numbers for this method
00023   private LineNumberTable     linenumbers;
00024   // Table of line numbers for this method
00025   private LocalVariableTable   localVars;
00026   // unique id
00027   int id;
00028 
00029   public MethodInfo(Method m, 
00030       ClassInfo ci, 
00031       ConstantPoolGen cpg) {
00032     InstructionList     il;
00033     this.cpg = cpg;
00034     this.ci = ci;
00035     id = IDS.method_id; IDS.method_id++;
00036     mg  = new MethodGen(m,ci.getClassData().getClassName(),cpg);
00037     exceptions = mg.getExceptionHandlers();
00038     linenumbers = mg.getLineNumberTable(cpg);
00039     localVars   = mg.getLocalVariableTable(cpg);
00040     method_name = mg.getMethodName();
00041 // ifdef DEBUG
00042 
00043 //#endif DEBUG
00044     il  = mg.getInstructionList();   
00045     if (il != null) {
00046 // ifdef DEBUG
00047 
00048 //#endif DEBUG
00049       ihs = il.getInstructionHandles();      
00050     }
00051 // ifdef DEBUG
00052 
00053 
00054 //#endif DEBUG
00055   }  
00056   public int getArgumentSize() {
00057     Type[] args = mg.getArgTypes();
00058     int sum;
00059 
00060     if(mg.isStatic())
00061       sum = 0;
00062     else
00063       sum = 1;  // this reference
00064 
00065     int n = args.length;
00066     for (int i = 0; i < n; i++)
00067       sum += args[i].getSize();
00068 
00069     return sum;
00070   }  
00071   public ClassInfo getClassInfo() {
00072     return ci;
00073   }  
00074   public ConstantPoolGen getConstantPool() {
00075     return cpg;
00076   }  
00077   public CodeExceptionGen[] getExceptions() {
00078     return exceptions;
00079   }  
00080   public InstructionHandle getFirstInstruction() {
00081     if(ihs == null) return null;
00082     return ihs[0];
00083   }  
00084   public String getFullName() {
00085     return ci.getClassName() + "." + method_name + mg.getMethodSignature();
00086   }  
00087   public InstructionHandle getInstructionHandle(int i) {
00088     return ihs[i];
00089   }  
00090   public int getInstructionNumber(InstructionHandle pc) {
00091     for(int i = 0, s = ihs.length; i < s; i++)
00092       if(ihs[i] == pc) return i;
00093 
00094     return -1;
00095   }  
00096   public LineNumberTable getLineNumbers() {
00097     return linenumbers;
00098   }  
00099   public MethodGen getMethodGen() {
00100     return mg;
00101   }  
00102   public String getMethodName() {
00103     return method_name;
00104   }  
00105 }

Generated at Thu Feb 7 06:50:25 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001