1 23 24 25 package com.sun.jdo.api.persistence.enhancer.classfile; 26 27 30 31 class InsnReadEnv { 32 33 34 private CodeEnv codeEnv; 35 36 37 private byte[] byteCodes; 38 39 40 private int currPc; 41 42 45 InsnReadEnv(byte[] bytes, CodeEnv codeEnv) { 46 this.byteCodes = bytes; 47 this.currPc = 0; 48 this.codeEnv = codeEnv; 49 } 50 51 54 int currentPC() { 55 return currPc; 56 } 57 58 61 boolean more() { 62 return currPc < byteCodes.length; 63 } 64 65 68 byte getByte() { 69 if (!more()) 70 throw new InsnError("out of byte codes"); 72 return byteCodes[currPc++]; 73 } 74 75 78 int getUByte() { 79 return getByte() & 0xff; 80 } 81 82 85 int getShort() { 86 byte byte1 = byteCodes[currPc++]; 87 byte byte2 = byteCodes[currPc++]; 88 return (byte1 << 8) | (byte2 & 0xff); 89 } 90 91 94 int getUShort() { 95 return getShort() & 0xffff; 96 } 97 98 101 int getInt() { 102 byte byte1 = byteCodes[currPc++]; 103 byte byte2 = byteCodes[currPc++]; 104 byte byte3 = byteCodes[currPc++]; 105 byte byte4 = byteCodes[currPc++]; 106 return (byte1 << 24) | ((byte2 & 0xff) << 16) | 107 ((byte3 & 0xff) << 8) | (byte4 & 0xff); 108 } 109 110 113 ConstantPool pool() { 114 return codeEnv.pool(); 115 } 116 117 121 InsnTarget getTarget(int targ) { 122 return codeEnv.getTarget(targ); 123 } 124 } 125 | Popular Tags |