From 63b8d35d08a198215ddabb42cca5b0e823232768 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 29 Aug 2014 16:05:51 +0400 Subject: java-decompiler: post-import cleanup (dead code dropped) --- .../jetbrains/java/decompiler/util/ListStack.java | 8 - .../java/decompiler/util/SFormsFastMap.java | 251 ------------------ .../java/decompiler/util/SFormsFastMapOld.java | 290 --------------------- 3 files changed, 549 deletions(-) delete mode 100644 src/org/jetbrains/java/decompiler/util/SFormsFastMap.java delete mode 100644 src/org/jetbrains/java/decompiler/util/SFormsFastMapOld.java (limited to 'src/org/jetbrains/java/decompiler/util') diff --git a/src/org/jetbrains/java/decompiler/util/ListStack.java b/src/org/jetbrains/java/decompiler/util/ListStack.java index 20c6614..19c2416 100644 --- a/src/org/jetbrains/java/decompiler/util/ListStack.java +++ b/src/org/jetbrains/java/decompiler/util/ListStack.java @@ -77,14 +77,6 @@ public class ListStack extends ArrayList { return pointer; } - public T get(int index) { - return super.get(index); - } - - public T set(int index, T element) { - return super.set(index, element); - } - public T getByOffset(int offset) { return this.get(pointer + offset); } diff --git a/src/org/jetbrains/java/decompiler/util/SFormsFastMap.java b/src/org/jetbrains/java/decompiler/util/SFormsFastMap.java deleted file mode 100644 index 51c64d2..0000000 --- a/src/org/jetbrains/java/decompiler/util/SFormsFastMap.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright 2000-2014 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.java.decompiler.util; - -import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; - -public class SFormsFastMap { - - private int size; - - private List lstElements = new ArrayList(3); - - { - lstElements.add((E[])new Object[5]); - lstElements.add((E[])new Object[5]); - lstElements.add((E[])new Object[5]); - } - - public SFormsFastMap() { - } - - public SFormsFastMap(SFormsFastMap map) { - for (int i = 2; i >= 0; i--) { - E[] arr = map.lstElements.get(i); - E[] arrnew = (E[])new Object[arr.length]; - - System.arraycopy(arr, 0, arrnew, 0, arr.length); - - lstElements.set(i, arrnew); - - for (E element : arrnew) { - if (element != null) { - size++; - } - } - } - } - - public int size() { - return size; - } - - public boolean isEmpty() { - return size == 0; - } - - public void put(int key, E value) { - putInternal(key, value, false); - } - - public void remove(int key) { - putInternal(key, null, true); - } - - public void removeAllFields() { - E[] arr = lstElements.get(2); - for (int i = arr.length - 1; i >= 0; i--) { - E val = arr[i]; - if (val != null) { - arr[i] = null; - size--; - } - } - } - - public void putInternal(final int key, final E value, boolean remove) { - - int index = 0; - int ikey = key; - if (ikey < 0) { - index = 2; - ikey = -ikey; - } - else if (ikey >= VarExprent.STACK_BASE) { - index = 1; - ikey -= VarExprent.STACK_BASE; - } - - E[] arr = lstElements.get(index); - if (ikey >= arr.length) { - if (remove) { - return; - } - else { - arr = ensureCapacity(arr, ikey + 1, false); - lstElements.set(index, arr); - } - } - - E oldval = arr[ikey]; - arr[ikey] = value; - - if (oldval == null && value != null) { - size++; - } - else if (oldval != null && value == null) { - size--; - } - } - - public boolean containsKey(int key) { - return get(key) != null; - } - - public E get(int key) { - - int index = 0; - if (key < 0) { - index = 2; - key = -key; - } - else if (key >= VarExprent.STACK_BASE) { - index = 1; - key -= VarExprent.STACK_BASE; - } - - E[] arr = lstElements.get(index); - - if (key < arr.length) { - return arr[key]; - } - return null; - } - - public void union(SFormsFastMap map, IElementsUnion union) { - - for (int i = 2; i >= 0; i--) { - E[] lstOwn = lstElements.get(i); - E[] lstExtern = map.lstElements.get(i); - - int externsize = lstExtern.length; - - if (lstOwn.length < externsize) { - lstOwn = ensureCapacity(lstOwn, externsize, true); - lstElements.set(i, lstOwn); - } - - int ownsize = lstOwn.length; - int minsize = ownsize > externsize ? externsize : ownsize; - - for (int j = minsize - 1; j >= 0; j--) { - E second = lstExtern[j]; - - if (second != null) { - E first = lstOwn[j]; - - if (first == null) { - lstOwn[j] = union.copy(second); - size++; - } - else { - union.union(first, second); - } - } - } - - // ITimer timer = TimerFactory.newTimer(); - // timer.start(); - // - // if(externsize > minsize) { - // for(int j=minsize;j> entryList() { - List> list = new ArrayList>(); - - for (int i = 2; i >= 0; i--) { - int ikey = 0; - for (final E ent : lstElements.get(i)) { - if (ent != null) { - final int key = i == 0 ? ikey : (i == 1 ? ikey + VarExprent.STACK_BASE : -ikey); - - list.add(new Entry() { - - private Integer var = key; - private E val = ent; - - public Integer getKey() { - return var; - } - - public E getValue() { - return val; - } - - public E setValue(E newvalue) { - return null; - } - }); - } - - ikey++; - } - } - - return list; - } - - private E[] ensureCapacity(E[] arr, int size, boolean exact) { - - int minsize = size; - if (!exact) { - minsize = 2 * arr.length / 3 + 1; - if (size > minsize) { - minsize = size; - } - } - - E[] arrnew = (E[])new Object[minsize]; - System.arraycopy(arr, 0, arrnew, 0, arr.length); - - return arrnew; - } - - public interface IElementsUnion { - E union(E first, E second); - - E copy(E element); - } -} diff --git a/src/org/jetbrains/java/decompiler/util/SFormsFastMapOld.java b/src/org/jetbrains/java/decompiler/util/SFormsFastMapOld.java deleted file mode 100644 index 7d428a4..0000000 --- a/src/org/jetbrains/java/decompiler/util/SFormsFastMapOld.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright 2000-2014 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.java.decompiler.util; - -import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; - -public class SFormsFastMapOld { - - private List>> lstElements = new ArrayList>>(3); - - { - lstElements.add(new ArrayList>()); - lstElements.add(new ArrayList>()); - lstElements.add(new ArrayList>()); - } - - public SFormsFastMapOld() { - } - - public SFormsFastMapOld(SFormsFastMapOld map) { - for (int i = 2; i >= 0; i--) { - lstElements.set(i, new ArrayList>(map.lstElements.get(i))); - } - } - - public int size() { - int size = 0; - for (int i = 2; i >= 0; i--) { - size += lstElements.get(i).size(); - } - return size; - } - - public boolean isEmpty() { - - for (int i = 2; i >= 0; i--) { - if (!lstElements.get(i).isEmpty()) { - return false; - } - } - - return true; - } - - public void put(int key, E value) { - putInternal(key, value, false); - } - - public void remove(int key) { - putInternal(key, null, true); - } - - public void removeAllFields() { - lstElements.get(2).clear(); - } - - public void putInternal(final int key, final E value, boolean remove) { - - int index = 0; - int ikey = key; - if (ikey < 0) { - index = 2; - ikey = -ikey; - } - else if (ikey >= VarExprent.STACK_BASE) { - index = 1; - ikey -= VarExprent.STACK_BASE; - } - - ArrayList> lst = lstElements.get(index); - if (ikey >= lst.size()) { - if (remove) { - return; - } - else { - ensureCapacity(lst, ikey + 1, false); - } - } - - lst.set(ikey, value == null ? null : new Entry() { - - private Integer var = key; - private E val = value; - - public Integer getKey() { - return var; - } - - public E getValue() { - return val; - } - - public E setValue(E newvalue) { - val = newvalue; - return null; - } - }); - } - - public boolean containsKey(int key) { - return get(key) != null; - } - - public E get(int key) { - - int index = 0; - if (key < 0) { - index = 2; - key = -key; - } - else if (key >= VarExprent.STACK_BASE) { - index = 1; - key -= VarExprent.STACK_BASE; - } - - ArrayList> lst = lstElements.get(index); - - Entry ent; - if (key < lst.size() && (ent = lst.get(key)) != null) { - return ent.getValue(); - } - return null; - } - - public void union(SFormsFastMapOld map, IElementsUnion union) { - - for (int i = 2; i >= 0; i--) { - ArrayList> lstOwn = lstElements.get(i); - ArrayList> lstExtern = map.lstElements.get(i); - - int ownsize = lstOwn.size(); - int externsize = lstExtern.size(); - - int minsize = ownsize > externsize ? externsize : ownsize; - - for (int j = minsize - 1; j >= 0; j--) { - Entry second = lstExtern.get(j); - - if (second != null) { - Entry first = lstOwn.get(j); - - if (first == null) { - putInternal(second.getKey(), union.copy(second.getValue()), false); - } - else { - first.setValue(union.union(first.getValue(), second.getValue())); - } - } - } - - if (externsize > minsize) { - // ensureCapacity(lstOwn, externsize, true); - // lstOwn.addAll(lstExtern.subList(minsize, externsize)); - - for (int j = minsize; j < externsize; j++) { - Entry second = lstExtern.get(j); - // if(first != null) { - // first.setValue(union.copy(first.getValue())); - // } - - if (second != null) { - putInternal(second.getKey(), union.copy(second.getValue()), false); - } - // lstOwn.add(lstExtern.get(j)); - } - } - } - } - - public List> entryList() { - List> list = new ArrayList>(); - - for (int i = 2; i >= 0; i--) { - for (Entry ent : lstElements.get(i)) { - if (ent != null) { - list.add(ent); - } - } - } - - return list; - } - - // public SFormsFastMapIterator iterator() { - // return new SFormsFastMapIterator(); - // } - - private void ensureCapacity(ArrayList> lst, int size, boolean exact) { - - if (!exact) { - int minsize = 2 * lst.size() / 3 + 1; - if (minsize > size) { - size = minsize; - } - } - - lst.ensureCapacity(size); - for (int i = size - lst.size(); i > 0; i--) { - lst.add(null); - } - } - - public interface IElementsUnion { - E union(E first, E second); - - E copy(E element); - } - - // public class SFormsFastMapIterator implements Iterator> { - // - // private int[] pointer = new int[]{0, -1}; - // private int[] next_pointer = null; - // - // private int[] getNextIndex(int list, int index) { - // - // while(list < 3) { - // ArrayList lst = lstElements.get(list); - // - // while(++index < lst.size()) { - // E element = lst.get(index); - // if(element != null) { - // return new int[] {list, index}; - // } - // } - // - // index = -1; - // list++; - // } - // - // return null; - // } - // - // public boolean hasNext() { - // next_pointer = getNextIndex(pointer[0], pointer[1]); - // return (next_pointer != null); - // } - // - // public Entry next() { - // if(next_pointer != null) { - // pointer = next_pointer; - // } else { - // int[] nextpointer = getNextIndex(pointer[0], pointer[1]); - // if(nextpointer != null) { - // pointer = nextpointer; - // } else { - // return null; - // } - // } - // - // next_pointer = null; - // - // return new Entry() { - // public Integer getKey() { - // return null; - // } - // - // public E getValue() { - // return null; - // } - // - // public E setValue(E value) { - // throw new RuntimeException("not implemented!"); - // } - // }; - // //lstElements.get(pointer[0]).get(pointer[1]); - // } - // - // public void remove() { - // throw new RuntimeException("not implemented!"); - // } - // - // } -} -- cgit v1.2.3