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 TABLESWITCH extends Select {
00014
00015
00016
00017
00018 TABLESWITCH() {}
00019
00020
00021
00022
00023
00024
00025 public TABLESWITCH(int[] match, InstructionHandle[] targets,
00026 InstructionHandle target) {
00027 super(TABLESWITCH, match, targets, target);
00028
00029 length = (short)(13 + match_length * 4);
00030
00031 fixed_length = length;
00032 }
00033
00034
00035
00036
00037 public void dump(DataOutputStream out) throws IOException {
00038 super.dump(out);
00039
00040 out.writeInt(match[0]);
00041 out.writeInt(match[match_length - 1]);
00042
00043 for(int i=0; i < match_length; i++)
00044 out.writeInt(indices[i] = getTargetOffset(targets[i]));
00045 }
00046
00047
00048
00049 protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
00050 {
00051 super.initFromFile(bytes, wide);
00052
00053 int low = bytes.readInt();
00054 int high = bytes.readInt();
00055
00056 match_length = high - low + 1;
00057 fixed_length = (short)(13 + match_length * 4);
00058 length = (short)(fixed_length + padding);
00059
00060 match = new int[match_length];
00061 indices = new int[match_length];
00062 targets = new InstructionHandle[match_length];
00063
00064 for(int i=low; i <= high; i++)
00065 match[i - low] = i;
00066
00067 for(int i=0; i < match_length; i++) {
00068 indices[i] = bytes.readInt();
00069 }
00070 }
00071 }