decompiler: create less thrown away objects - pt.2

master
Egor.Ushakov 10 years ago
parent 7e30facd33
commit 5770d25e59
  1. 15
      src/org/jetbrains/java/decompiler/code/ExceptionTable.java
  2. 4
      src/org/jetbrains/java/decompiler/code/FullInstructionSequence.java
  3. 16
      src/org/jetbrains/java/decompiler/code/InstructionSequence.java
  4. 4
      src/org/jetbrains/java/decompiler/code/SimpleInstructionSequence.java

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,15 +18,18 @@ package org.jetbrains.java.decompiler.code;
import org.jetbrains.java.decompiler.code.interpreter.Util;
import org.jetbrains.java.decompiler.struct.StructContext;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ExceptionTable {
public static final ExceptionTable EMPTY = new ExceptionTable(null) {
@Override
public List<ExceptionHandler> getHandlers() {
return Collections.emptyList();
}
};
private List<ExceptionHandler> handlers = new ArrayList<ExceptionHandler>();
public ExceptionTable() {
}
private final List<ExceptionHandler> handlers;
public ExceptionTable(List<ExceptionHandler> handlers) {
this.handlers = handlers;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ public class FullInstructionSequence extends InstructionSequence {
// *****************************************************************************
public FullInstructionSequence(VBStyleCollection<Instruction, Integer> collinstr, ExceptionTable extable) {
this.collinstr = collinstr;
super(collinstr);
this.exceptionTable = extable;
// translate raw exception handlers to instr

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,11 +34,19 @@ public abstract class InstructionSequence {
// private fields
// *****************************************************************************
protected VBStyleCollection<Instruction, Integer> collinstr = new VBStyleCollection<Instruction, Integer>();
protected final VBStyleCollection<Instruction, Integer> collinstr;
protected int pointer = 0;
protected ExceptionTable exceptionTable = new ExceptionTable();
protected ExceptionTable exceptionTable = ExceptionTable.EMPTY;
protected InstructionSequence() {
this(new VBStyleCollection<Instruction, Integer>());
}
protected InstructionSequence(VBStyleCollection<Instruction, Integer> collinstr) {
this.collinstr = collinstr;
}
// *****************************************************************************
// public methods
@ -52,7 +60,7 @@ public abstract class InstructionSequence {
public void clear() {
collinstr.clear();
pointer = 0;
exceptionTable = new ExceptionTable();
exceptionTable = ExceptionTable.EMPTY;
}
public void addInstruction(Instruction inst, int offset) {

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ public class SimpleInstructionSequence extends InstructionSequence {
}
public SimpleInstructionSequence(VBStyleCollection<Instruction, Integer> collinstr) {
this.collinstr = collinstr;
super(collinstr);
}
public SimpleInstructionSequence clone() {

Loading…
Cancel
Save