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(LOOKUPSWITCH, match, targets, target);
00022
00023 length = (short)(9 + match_length * 8);
00024
00025 fixed_length = length;
00026 }
00027
00028
00029
00030
00031 public void dump(DataOutputStream out) throws IOException {
00032 super.dump(out);
00033 out.writeInt(match_length);
00034
00035 for(int i=0; i < match_length; i++) {
00036 out.writeInt(match[i]);
00037 out.writeInt(indices[i] = getTargetOffset(targets[i]));
00038 }
00039 }
00040
00041
00042
00043 protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
00044 {
00045 super.initFromFile(bytes, wide);
00046
00047 match_length = bytes.readInt();
00048 fixed_length = (short)(9 + match_length * 8);
00049 length = (short)(fixed_length + padding);
00050
00051 match = new int[match_length];
00052 indices = new int[match_length];
00053 targets = new InstructionHandle[match_length];
00054
00055 for(int i=0; i < match_length; i++) {
00056 match[i] = bytes.readInt();
00057 indices[i] = bytes.readInt();
00058 }
00059 }
00060 }