01: /*
02: * ProGuard -- shrinking, optimization, obfuscation, and preverification
03: * of Java bytecode.
04: *
05: * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the Free
09: * Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful, but WITHOUT
13: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15: * more details.
16: *
17: * You should have received a copy of the GNU General Public License along
18: * with this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: package proguard.classfile.instruction;
22:
23: /**
24: * This Instruction represents a simple instruction without variable arguments
25: * or constant pool references.
26: *
27: * @author Eric Lafortune
28: */
29: public abstract class SwitchInstruction extends Instruction {
30: public int defaultOffset;
31: public int[] jumpOffsets;
32:
33: /**
34: * Creates an uninitialized SwitchInstruction.
35: */
36: public SwitchInstruction() {
37: }
38:
39: /**
40: * Creates a new SwitchInstruction with the given arguments.
41: */
42: public SwitchInstruction(byte opcode, int defaultOffset,
43: int[] jumpOffsets) {
44: this .opcode = opcode;
45: this .defaultOffset = defaultOffset;
46: this .jumpOffsets = jumpOffsets;
47: }
48:
49: /**
50: * Copies the given instruction into this instruction.
51: * @param switchInstruction the instruction to be copied.
52: * @return this instruction.
53: */
54: public SwitchInstruction copy(SwitchInstruction switchInstruction) {
55: this .opcode = switchInstruction.opcode;
56: this .defaultOffset = switchInstruction.defaultOffset;
57: this .jumpOffsets = switchInstruction.jumpOffsets;
58:
59: return this ;
60: }
61:
62: // Implementations for Instruction.
63:
64: public String toString(int offset) {
65: return "[" + offset + "] " + toString() + " (target="
66: + (offset + defaultOffset) + ")";
67: }
68:
69: // Implementations for Object.
70:
71: public String toString() {
72: return getName() + " (" + jumpOffsets.length
73: + " offsets, default=" + defaultOffset + ")";
74: }
75: }
|