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 66 public class TABLESWITCH extends Select { 67 71 TABLESWITCH() {} 72 73 79 public TABLESWITCH(int[] match, InstructionHandle[] targets, 80 InstructionHandle target) { 81 super(com.sun.org.apache.bcel.internal.Constants.TABLESWITCH, match, targets, target); 82 83 length = (short)(13 + match_length * 4); 85 fixed_length = length; 86 } 87 88 92 public void dump(DataOutputStream out) throws IOException { 93 super.dump(out); 94 95 int low = (match_length > 0)? match[0] : 0; 96 out.writeInt(low); 97 98 int high = (match_length > 0)? match[match_length - 1] : 0; 99 out.writeInt(high); 100 101 for(int i=0; i < match_length; i++) out.writeInt(indices[i] = getTargetOffset(targets[i])); 103 } 104 105 108 protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException 109 { 110 super.initFromFile(bytes, wide); 111 112 int low = bytes.readInt(); 113 int high = bytes.readInt(); 114 115 match_length = high - low + 1; 116 fixed_length = (short)(13 + match_length * 4); 117 length = (short)(fixed_length + padding); 118 119 match = new int[match_length]; 120 indices = new int[match_length]; 121 targets = new InstructionHandle[match_length]; 122 123 for(int i=low; i <= high; i++) 124 match[i - low] = i; 125 126 for(int i=0; i < match_length; i++) { 127 indices[i] = bytes.readInt(); 128 } 129 } 130 131 132 140 public void accept(Visitor v) { 141 v.visitVariableLengthInstruction(this); 142 v.visitStackProducer(this); 143 v.visitBranchInstruction(this); 144 v.visitSelect(this); 145 v.visitTABLESWITCH(this); 146 } 147 } 148 | Popular Tags |