clear tmpInfo after analyzing

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@488 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 543f1cc3d4
commit e4407e4c47
  1. 29
      jode/jode/decompiler/CodeAnalyzer.java
  2. 28
      jode/jode/decompiler/DeadCodeAnalysis.java

@ -1,18 +1,18 @@
/* /* CodeAnalyzer Copyright (C) 1998-1999 Jochen Hoenicke.
* CodeAnalyzer (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$
*/ */
@ -107,8 +107,6 @@ public class CodeAnalyzer implements Analyzer {
|| instr.preds.size() != 1) || instr.preds.size() != 1)
instr.tmpInfo = new FlowBlock instr.tmpInfo = new FlowBlock
(this, instr.addr, instr.length); (this, instr.addr, instr.length);
else
instr.tmpInfo = null;
} }
for (int i=0; i < handlers.length; i++) { for (int i=0; i < handlers.length; i++) {
@ -181,6 +179,9 @@ public class CodeAnalyzer implements Analyzer {
excHandlers.addHandler(start, endAddr, handler, type); excHandlers.addHandler(start, endAddr, handler, type);
} }
} }
for (Instruction instr = code.getFirstInstr();
instr != null; instr = instr.nextByAddr)
instr.tmpInfo = null;
if (Decompiler.isVerbose) if (Decompiler.isVerbose)
Decompiler.err.print('-'); Decompiler.err.print('-');

@ -1,3 +1,22 @@
/* DeadCodeAnalysis Copyright (C) 1999 Jochen Hoenicke.
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
package jode.decompiler; package jode.decompiler;
import jode.bytecode.BytecodeInfo; import jode.bytecode.BytecodeInfo;
import jode.bytecode.Instruction; import jode.bytecode.Instruction;
@ -34,10 +53,6 @@ public class DeadCodeAnalysis {
} }
public static void removeDeadCode(BytecodeInfo code) { public static void removeDeadCode(BytecodeInfo code) {
for (Instruction instr = code.getFirstInstr();
instr != null; instr = instr.nextByAddr)
instr.tmpInfo = null;
propagateReachability(code.getFirstInstr(), code.getFirstInstr()); propagateReachability(code.getFirstInstr(), code.getFirstInstr());
Handler[] handlers = code.getExceptionHandlers(); Handler[] handlers = code.getExceptionHandlers();
boolean changed; boolean changed;
@ -92,6 +107,9 @@ public class DeadCodeAnalysis {
handlers[i].end = handlers[i].end.prevByAddr; handlers[i].end = handlers[i].end.prevByAddr;
} }
} }
/* clean up tmpInfo */
for (Instruction instr = code.getFirstInstr();
instr != null; instr = instr.nextByAddr)
instr.tmpInfo = null;
} }
} }

Loading…
Cancel
Save