1 17 package org.apache.bcel.generic; 18 19 import java.io.DataOutputStream ; 20 import java.io.IOException ; 21 import org.apache.bcel.util.ByteSequence; 22 23 30 public class LOOKUPSWITCH extends Select { 31 32 36 LOOKUPSWITCH() { 37 } 38 39 40 public LOOKUPSWITCH(int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) { 41 super(org.apache.bcel.Constants.LOOKUPSWITCH, match, targets, defaultTarget); 42 length = (short) (9 + match_length * 8); 44 fixed_length = length; 45 } 46 47 48 52 public void dump( DataOutputStream out ) throws IOException { 53 super.dump(out); 54 out.writeInt(match_length); for (int i = 0; i < match_length; i++) { 56 out.writeInt(match[i]); out.writeInt(indices[i] = getTargetOffset(targets[i])); 58 } 59 } 60 61 62 65 protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException { 66 super.initFromFile(bytes, wide); match_length = bytes.readInt(); 68 fixed_length = (short) (9 + match_length * 8); 69 length = (short) (fixed_length + padding); 70 match = new int[match_length]; 71 indices = new int[match_length]; 72 targets = new InstructionHandle[match_length]; 73 for (int i = 0; i < match_length; i++) { 74 match[i] = bytes.readInt(); 75 indices[i] = bytes.readInt(); 76 } 77 } 78 79 80 88 public void accept( Visitor v ) { 89 v.visitVariableLengthInstruction(this); 90 v.visitStackProducer(this); 91 v.visitBranchInstruction(this); 92 v.visitSelect(this); 93 v.visitLOOKUPSWITCH(this); 94 } 95 } 96 | Popular Tags |