1 11 package org.eclipse.jdt.internal.compiler.codegen; 12 13 import org.eclipse.jdt.core.compiler.CharOperation; 14 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; 15 16 public class ExceptionLabel extends Label { 17 18 public int ranges[] = {POS_NOT_SET,POS_NOT_SET}; 19 public int count = 0; public TypeBinding exceptionType; 21 22 public ExceptionLabel(CodeStream codeStream, TypeBinding exceptionType) { 23 super(codeStream); 24 this.exceptionType = exceptionType; 25 } 26 27 public void place() { 28 codeStream.registerExceptionHandler(this); 30 if (CodeStream.DEBUG) System.out.println("\t\t\t\t<place at: "+codeStream.position+" - "+ this); this.position = codeStream.getPosition(); 32 } 33 34 public void placeEnd() { 35 int endPosition = codeStream.position; 36 if (this.ranges[this.count-1] == endPosition) { this.count--; 39 } else { 40 this.ranges[this.count++] = endPosition; 41 } 42 } 43 44 public void placeStart() { 45 int startPosition = codeStream.position; 46 if (this.count > 0 && this.ranges[this.count-1] == startPosition) { this.count--; 49 return; 50 } 51 int length; 53 if (this.count == (length = this.ranges.length)) { 54 System.arraycopy(this.ranges, 0, this.ranges = new int[length*2], 0, length); 55 } 56 this.ranges[this.count++] = startPosition; 57 } 58 public String toString() { 59 String basic = getClass().getName(); 60 basic = basic.substring(basic.lastIndexOf('.')+1); 61 StringBuffer buffer = new StringBuffer (basic); 62 buffer.append('@').append(Integer.toHexString(hashCode())); 63 buffer.append("(type=").append(this.exceptionType == null ? CharOperation.NO_CHAR : this.exceptionType.readableName()); buffer.append(", position=").append(position); buffer.append(", ranges = "); if (this.count == 0) { 67 buffer.append("[]"); } else { 69 for (int i = 0; i < this.count; i++) { 70 if ((i & 1) == 0) { 71 buffer.append("[").append(ranges[i]); } else { 73 buffer.append(",").append(ranges[i]).append("]"); } 75 } 76 if ((this.count & 1) == 1) { 77 buffer.append(",?]"); } 79 } 80 buffer.append(')'); 81 return buffer.toString(); 82 } 83 } 84 | Popular Tags |