fixes for switch blocks

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@491 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 15b9ad802a
commit 968e24ed1f
  1. 56
      jode/jode/decompiler/Opcodes.java

@ -1,18 +1,18 @@
/* /* Opcodes Copyright (C) 1999 Jochen Hoenicke.
* Opcodes (c) 1998 Jochen Hoenicke
* *
* You may distribute under the terms of the GNU General Public License. * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
* *
* IN NO EVENT SHALL JOCHEN HOENICKE BE LIABLE TO ANY PARTY FOR DIRECT, * This program is distributed in the hope that it will be useful,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF * but WITHOUT ANY WARRANTY; without even the implied warranty of
* THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JOCHEN HOENICKE * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * GNU General Public License for more details.
* *
* JOCHEN HOENICKE SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT * You should have received a copy of the GNU General Public License
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * along with this program; see the file COPYING. If not, write to
* PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* BASIS, AND JOCHEN HOENICKE HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* $Id$ * $Id$
*/ */
@ -126,17 +126,7 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
case opc_nop: case opc_nop:
return createBlock(ca, instr, new EmptyBlock return createBlock(ca, instr, new EmptyBlock
(new Jump(FlowBlock.NEXT_BY_ADDR))); (new Jump(FlowBlock.NEXT_BY_ADDR)));
case opc_aconst_null:
case opc_iconst_m1:
case opc_iconst_0: case opc_iconst_1: case opc_iconst_2:
case opc_iconst_3: case opc_iconst_4: case opc_iconst_5:
case opc_lconst_0: case opc_lconst_1:
case opc_fconst_0: case opc_fconst_1: case opc_fconst_2:
case opc_dconst_0: case opc_dconst_1:
case opc_bipush:
case opc_sipush:
case opc_ldc: case opc_ldc:
case opc_ldc_w:
case opc_ldc2_w: case opc_ldc2_w:
return createNormal (ca, instr, new ConstOperator(instr.objData)); return createNormal (ca, instr, new ConstOperator(instr.objData));
@ -281,9 +271,9 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
FlowBlock[] dests = new FlowBlock[instr.succs.length]; FlowBlock[] dests = new FlowBlock[instr.succs.length];
for (int i=0; i < cases.length; i++) { for (int i=0; i < cases.length; i++) {
cases[i] = i+low; cases[i] = i+low;
dests[i] = (FlowBlock) instr.succs[i+1].tmpInfo; dests[i] = (FlowBlock) instr.succs[i].tmpInfo;
} }
dests[cases.length] = (FlowBlock) instr.succs[0].tmpInfo; dests[cases.length] = (FlowBlock)instr.succs[cases.length].tmpInfo;
return createSwitch(ca, instr, cases, dests); return createSwitch(ca, instr, cases, dests);
} }
case opc_lookupswitch: { case opc_lookupswitch: {
@ -291,7 +281,7 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
FlowBlock[] dests = new FlowBlock[instr.succs.length]; FlowBlock[] dests = new FlowBlock[instr.succs.length];
for (int i=0; i < dests.length; i++) for (int i=0; i < dests.length; i++)
dests[i] = (FlowBlock) instr.succs[i].tmpInfo; dests[i] = (FlowBlock) instr.succs[i].tmpInfo;
dests[cases.length] = (FlowBlock) instr.succs[0].tmpInfo; dests[cases.length] = (FlowBlock)instr.succs[cases.length].tmpInfo;
return createSwitch(ca, instr, cases, dests); return createSwitch(ca, instr, cases, dests);
} }
case opc_ireturn: case opc_lreturn: case opc_ireturn: case opc_lreturn:
@ -305,29 +295,27 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
(ca, instr, new EmptyBlock(new Jump(FlowBlock.END_OF_METHOD))); (ca, instr, new EmptyBlock(new Jump(FlowBlock.END_OF_METHOD)));
case opc_getstatic: case opc_getstatic:
case opc_getfield: { case opc_getfield: {
String[] ref = (String[]) instr.objData; Reference ref = (Reference) instr.objData;
return createNormal return createNormal
(ca, instr, new GetFieldOperator (ca, instr, new GetFieldOperator
(ca, opcode == opc_getstatic, (ca, opcode == opc_getstatic, ref));
Type.tClass(ref[0]), Type.tType(ref[2]), ref[1]));
} }
case opc_putstatic: case opc_putstatic:
case opc_putfield: { case opc_putfield: {
String[] ref = (String[]) instr.objData; Reference ref = (Reference) instr.objData;
return createNormal return createNormal
(ca, instr, new PutFieldOperator (ca, instr, new PutFieldOperator
(ca, opcode == opc_putstatic, (ca, opcode == opc_putstatic, ref));
Type.tClass(ref[0]), Type.tType(ref[2]), ref[1]));
} }
case opc_invokevirtual: case opc_invokevirtual:
case opc_invokespecial: case opc_invokespecial:
case opc_invokestatic : case opc_invokestatic :
case opc_invokeinterface: { case opc_invokeinterface: {
String[] ref = (String[]) instr.objData; Reference ref = (Reference) instr.objData;
StructuredBlock block = createNormal StructuredBlock block = createNormal
(ca, instr, new InvokeOperator (ca, instr, new InvokeOperator
(ca, opcode == opc_invokespecial, Type.tClass(ref[0]), (ca, opcode == opc_invokestatic,
new MethodType(opcode == opc_invokestatic, ref[2]), ref[1])); opcode == opc_invokespecial, ref));
return block; return block;
} }
case opc_new: { case opc_new: {

Loading…
Cancel
Save