1
2
3
4 package joeq.Class;
5
6 import joeq.Runtime.Debug;
7 import joeq.Runtime.TypeCheck;
8 import jwutil.strings.Strings;
9
10
11
12
13
14 public class jq_TryCatch {
15
16 public static final boolean DEBUG = false;
17
18
19
20
21 private int startPC, endPC, handlerPC;
22 private jq_Class exType;
23
24 private int exceptionOffset;
25
26 public jq_TryCatch(int startPC, int endPC, int handlerPC, jq_Class exType, int exceptionOffset) {
27 this.startPC = startPC;
28 this.endPC = endPC;
29 this.handlerPC = handlerPC;
30 this.exType = exType;
31 this.exceptionOffset = exceptionOffset;
32 }
33
34
35 public boolean catches(int offset, jq_Class t) {
36 if (DEBUG) Debug.writeln(this+": checking "+Strings.hex(offset)+" "+t);
37 if (offset <= startPC) return false;
38 if (offset > endPC) return false;
39 if (exType != null) {
40 exType.prepare();
41 if (!TypeCheck.isAssignable(t, exType)) return false;
42 }
43 return true;
44 }
45
46 public int getStart() { return startPC; }
47 public int getEnd() { return endPC; }
48 public int getHandlerEntry() { return handlerPC; }
49 public jq_Class getExceptionType() { return exType; }
50 public int getExceptionOffset() { return exceptionOffset; }
51
52 public String toString() {
53 return "(start="+Strings.hex(startPC)+",end="+Strings.hex(endPC)+",handler="+Strings.hex(handlerPC)+",type="+exType+",offset="+Strings.shex(exceptionOffset)+")";
54 }
55
56 }