From 663631f0456fcc245dd835889f86541d75161c53 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 28 Aug 2014 20:52:43 +0400 Subject: java-decompiler: post-import cleanup (classes moved) --- .../java/decompiler/code/InstructionSequence.java | 219 +++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 src/org/jetbrains/java/decompiler/code/InstructionSequence.java (limited to 'src/org/jetbrains/java/decompiler/code/InstructionSequence.java') diff --git a/src/org/jetbrains/java/decompiler/code/InstructionSequence.java b/src/org/jetbrains/java/decompiler/code/InstructionSequence.java new file mode 100644 index 0000000..4c29820 --- /dev/null +++ b/src/org/jetbrains/java/decompiler/code/InstructionSequence.java @@ -0,0 +1,219 @@ +/* + * Fernflower - The Analytical Java Decompiler + * http://www.reversed-java.com + * + * (C) 2008 - 2010, Stiver + * + * This software is NEITHER public domain NOR free software + * as per GNU License. See license.txt for more details. + * + * This software is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. + */ + +package org.jetbrains.java.decompiler.code; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import org.jetbrains.java.decompiler.code.interpreter.Util; +import org.jetbrains.java.decompiler.main.DecompilerContext; +import org.jetbrains.java.decompiler.struct.StructContext; +import org.jetbrains.java.decompiler.util.InterpreterUtil; +import org.jetbrains.java.decompiler.util.VBStyleCollection; + + +public abstract class InstructionSequence { + + // ***************************************************************************** + // private fields + // ***************************************************************************** + + protected VBStyleCollection collinstr = new VBStyleCollection(); + + protected int pointer = 0; + + protected ExceptionTable exceptionTable = new ExceptionTable(); + + // ***************************************************************************** + // public methods + // ***************************************************************************** + + // to nbe overwritten + public InstructionSequence clone() {return null;} + + public void clear() { + collinstr.clear(); + pointer = 0; + exceptionTable = new ExceptionTable(); + } + + public void addInstruction(Instruction inst, int offset){ + collinstr.addWithKey(inst, offset); + } + + public void addInstruction(int index, Instruction inst, int offset){ + collinstr.addWithKeyAndIndex(index, inst, offset); + } + + public void addSequence(InstructionSequence seq){ + for(int i=0;i handlers = exceptionTable.getHandlers(); + + out.writeShort(handlers.size()); + for(int i=0;i() { + + public int compare(ExceptionHandler handler0, ExceptionHandler handler1) { + + if(handler0.to == handler1.to) { + if(handler0.exceptionClass == null) { + return 1; + } else { + if(handler1.exceptionClass == null) { + return -1; + } else if(handler0.exceptionClass.equals(handler1.exceptionClass)){ + return (handler0.from > handler1.from)?-1:1; // invalid code + } else { + if(Util.instanceOf(context, handler0.exceptionClass, handler1.exceptionClass)) { + return -1; + } else { + return 1; + } + } + } + } else { + return (handler0.to > handler1.to)?1:-1; + } + } + }); + + } + + + // ***************************************************************************** + // getter and setter methods + // ***************************************************************************** + + public int getPointer() { + return pointer; + } + + public void setPointer(int pointer) { + this.pointer = pointer; + } + + public ExceptionTable getExceptionTable() { + return exceptionTable; + } + + public void setExceptionTable(ExceptionTable exceptionTable) { + this.exceptionTable = exceptionTable; + } + +} -- cgit v1.2.3