00001 package de.fub.bytecode.generic;
00002
00003 import java.io.*;
00004 import de.fub.bytecode.util.ByteSequence;
00005
00006
00007
00008
00009
00010
00011
00012
00013 public class LOOKUPSWITCH extends Select {
00014
00015
00016
00017
00018 LOOKUPSWITCH() {}
00019 public LOOKUPSWITCH(int[] match, InstructionHandle[] targets,
00020 InstructionHandle target) {
00021 super(de.fub.bytecode.Constants.LOOKUPSWITCH, match, targets, target);
00022
00023 length = (short)(9 + match_length * 8);
00024
00025 fixed_length = length;
00026 }
00027
00028
00029
00030
00031
00032
00033
00034
00035 public void accept(Visitor v) {
00036 v.visitVariableLengthInstruction(this);
00037 v.visitStackProducer(this);
00038 v.visitInstructionTargeter(this);
00039 v.visitBranchInstruction(this);
00040 v.visitSelect(this);
00041 v.visitLOOKUPSWITCH(this);
00042 }
00043
00044
00045
00046
00047 public void dump(DataOutputStream out) throws IOException {
00048 super.dump(out);
00049 out.writeInt(match_length);
00050
00051 for(int i=0; i < match_length; i++) {
00052 out.writeInt(match[i]);
00053 out.writeInt(indices[i] = getTargetOffset(targets[i]));
00054 }
00055 }
00056
00057
00058
00059 protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
00060 {
00061 super.initFromFile(bytes, wide);
00062
00063 match_length = bytes.readInt();
00064 fixed_length = (short)(9 + match_length * 8);
00065 length = (short)(fixed_length + padding);
00066
00067 match = new int[match_length];
00068 indices = new int[match_length];
00069 targets = new InstructionHandle[match_length];
00070
00071 for(int i=0; i < match_length; i++) {
00072 match[i] = bytes.readInt();
00073 indices[i] = bytes.readInt();
00074 }
00075 }
00076 }