View Javadoc

1   // jq_TryCatchBC.java, created Mon Feb  5 23:23:20 2001 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Class;
5   
6   import joeq.Runtime.TypeCheck;
7   
8   /*
9    * @author  John Whaley <jwhaley@alum.mit.edu>
10   * @version $Id: jq_TryCatchBC.java 1456 2004-03-09 22:01:46Z jwhaley $
11   */
12  public class jq_TryCatchBC {
13  
14      // NOTE: startPC is inclusive, endPC is exclusive
15      private char startPC, endPC, handlerPC;
16      private jq_Class exType;
17  
18      public jq_TryCatchBC(char startPC, char endPC, char handlerPC, jq_Class exType) {
19          this.startPC = startPC;
20          this.endPC = endPC;
21          this.handlerPC = handlerPC;
22          this.exType = exType;
23      }
24  
25      public boolean catches(int pc, jq_Class t) {
26          t.prepare();
27          if (pc < startPC) return false;
28          if (pc >= endPC) return false;
29          if (exType != null && !TypeCheck.isAssignable(t, exType)) return false;
30          return true;
31      }
32      
33      public char getStartPC() { return startPC; }
34      public char getEndPC() { return endPC; }
35      public char getHandlerPC() { return handlerPC; }
36      public jq_Class getExceptionType() { return exType; }
37      
38      public String toString() {
39          return "(start="+(int)startPC+",end="+(int)endPC+",handler="+(int)handlerPC+",type="+exType+")";
40      }
41  }