1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 import java.io.*; 57 import com.sun.org.apache.bcel.internal.util.ByteSequence; 58 59 67 public class RET extends Instruction implements IndexedInstruction, TypedInstruction { 68 private boolean wide; 69 private int index; 71 75 RET() {} 76 77 public RET(int index) { 78 super(com.sun.org.apache.bcel.internal.Constants.RET, (short)2); 79 setIndex(index); } 81 82 86 public void dump(DataOutputStream out) throws IOException { 87 if(wide) 88 out.writeByte(com.sun.org.apache.bcel.internal.Constants.WIDE); 89 90 out.writeByte(opcode); 91 92 if(wide) 93 out.writeShort(index); 94 else 95 out.writeByte(index); 96 } 97 98 private final void setWide() { 99 if(wide = index > com.sun.org.apache.bcel.internal.Constants.MAX_BYTE) 100 length = 4; else 102 length = 2; 103 } 104 105 108 protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException 109 { 110 this.wide = wide; 111 112 if(wide) { 113 index = bytes.readUnsignedShort(); 114 length = 4; 115 } else { 116 index = bytes.readUnsignedByte(); 117 length = 2; 118 } 119 } 120 121 124 public final int getIndex() { return index; } 125 126 129 public final void setIndex(int n) { 130 if(n < 0) 131 throw new ClassGenException("Negative index value: " + n); 132 133 index = n; 134 setWide(); 135 } 136 137 140 public String toString(boolean verbose) { 141 return super.toString(verbose) + " " + index; 142 } 143 144 146 public Type getType(ConstantPoolGen cp) { 147 return ReturnaddressType.NO_TARGET; 148 } 149 150 158 public void accept(Visitor v) { 159 v.visitRET(this); 160 } 161 } 162 | Popular Tags |