[java decompiler] cleanup (dead code; optimizations; warnings)
This commit is contained in:
@@ -109,7 +109,7 @@ public class StructContext {
|
||||
StructClass cl = new StructClass(in, isOwn, loader);
|
||||
classes.put(cl.qualifiedName, cl);
|
||||
unit.addClass(cl, filename);
|
||||
loader.addClassLink(cl.qualifiedName, new LazyLoader.Link(LazyLoader.Link.CLASS, file.getAbsolutePath(), null));
|
||||
loader.addClassLink(cl.qualifiedName, new LazyLoader.Link(file.getAbsolutePath(), null));
|
||||
}
|
||||
catch (IOException ex) {
|
||||
String message = "Corrupted class file: " + file;
|
||||
@@ -145,7 +145,7 @@ public class StructContext {
|
||||
StructClass cl = new StructClass(bytes, isOwn, loader);
|
||||
classes.put(cl.qualifiedName, cl);
|
||||
unit.addClass(cl, name);
|
||||
loader.addClassLink(cl.qualifiedName, new LazyLoader.Link(LazyLoader.Link.ENTRY, file.getAbsolutePath(), name));
|
||||
loader.addClassLink(cl.qualifiedName, new LazyLoader.Link(file.getAbsolutePath(), name));
|
||||
}
|
||||
else {
|
||||
unit.addOtherEntry(file.getAbsolutePath(), name);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class StructMethod extends StructMember {
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseResources() throws IOException {
|
||||
public void releaseResources() {
|
||||
if (containsCode && expanded) {
|
||||
seq = null;
|
||||
expanded = false;
|
||||
@@ -141,12 +141,12 @@ public class StructMethod extends StructMember {
|
||||
else {
|
||||
switch (opcode) {
|
||||
case opc_bipush:
|
||||
operands.add(Integer.valueOf(in.readByte()));
|
||||
operands.add((int)in.readByte());
|
||||
i++;
|
||||
break;
|
||||
case opc_ldc:
|
||||
case opc_newarray:
|
||||
operands.add(Integer.valueOf(in.readUnsignedByte()));
|
||||
operands.add(in.readUnsignedByte());
|
||||
i++;
|
||||
break;
|
||||
case opc_sipush:
|
||||
@@ -171,7 +171,7 @@ public class StructMethod extends StructMember {
|
||||
if (opcode != opc_sipush) {
|
||||
group = GROUP_JUMP;
|
||||
}
|
||||
operands.add(Integer.valueOf(in.readShort()));
|
||||
operands.add((int)in.readShort());
|
||||
i += 2;
|
||||
break;
|
||||
case opc_ldc_w:
|
||||
@@ -230,12 +230,12 @@ public class StructMethod extends StructMember {
|
||||
case opc_iinc:
|
||||
if (wide) {
|
||||
operands.add(in.readUnsignedShort());
|
||||
operands.add(Integer.valueOf(in.readShort()));
|
||||
operands.add((int)in.readShort());
|
||||
i += 4;
|
||||
}
|
||||
else {
|
||||
operands.add(in.readUnsignedByte());
|
||||
operands.add(Integer.valueOf(in.readByte()));
|
||||
operands.add((int)in.readByte());
|
||||
i += 2;
|
||||
}
|
||||
break;
|
||||
@@ -309,11 +309,11 @@ public class StructMethod extends StructMember {
|
||||
if (!operands.isEmpty()) {
|
||||
ops = new int[operands.size()];
|
||||
for (int j = 0; j < operands.size(); j++) {
|
||||
ops[j] = operands.get(j).intValue();
|
||||
ops[j] = operands.get(j);
|
||||
}
|
||||
}
|
||||
|
||||
Instruction instr = ConstantsUtil.getInstructionInstance(opcode, wide, group, bytecode_version, ops);
|
||||
Instruction instr = Instruction.create(opcode, wide, group, bytecode_version, ops);
|
||||
|
||||
instructions.addWithKey(instr, offset);
|
||||
|
||||
@@ -331,7 +331,6 @@ public class StructMethod extends StructMember {
|
||||
handler.handler = in.readUnsignedShort();
|
||||
|
||||
int excclass = in.readUnsignedShort();
|
||||
handler.class_index = excclass;
|
||||
if (excclass != 0) {
|
||||
handler.exceptionClass = pool.getPrimitiveConstant(excclass).getString();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.jetbrains.java.decompiler.struct.consts.LinkConstant;
|
||||
import org.jetbrains.java.decompiler.struct.consts.PooledConstant;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||
import org.jetbrains.java.decompiler.struct.consts.LinkConstant;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class StructEnclosingMethodAttribute extends StructGeneralAttribute {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class StructExceptionsAttribute extends StructGeneralAttribute {
|
||||
}
|
||||
|
||||
public String getExcClassname(int index, ConstantPool pool) {
|
||||
return pool.getPrimitiveConstant(throwsExceptions.get(index).intValue()).getString();
|
||||
return pool.getPrimitiveConstant(throwsExceptions.get(index)).getString();
|
||||
}
|
||||
|
||||
public List<Integer> getThrowsExceptions() {
|
||||
|
||||
@@ -33,7 +33,6 @@ public class StructGeneralAttribute {
|
||||
public static final String ATTRIBUTE_SYNTHETIC = "Synthetic";
|
||||
public static final String ATTRIBUTE_DEPRECATED = "Deprecated";
|
||||
public static final String ATTRIBUTE_LINE_NUMBER_TABLE = "LineNumberTable";
|
||||
public static final String ATTRIBUTE_SOURCE_FILE = "SourceFile";
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -82,9 +81,6 @@ public class StructGeneralAttribute {
|
||||
else if (ATTRIBUTE_LINE_NUMBER_TABLE.equals(name)) {
|
||||
attr = new StructLineNumberTableAttribute();
|
||||
}
|
||||
else if (ATTRIBUTE_SOURCE_FILE.equals(name)) {
|
||||
attr = new StructSourceFileAttribute();
|
||||
}
|
||||
else {
|
||||
// unsupported attribute
|
||||
return null;
|
||||
|
||||
@@ -11,7 +11,6 @@ import java.util.List;
|
||||
|
||||
public class StructInnerClassesAttribute extends StructGeneralAttribute {
|
||||
public static class Entry {
|
||||
public final int innerNameIdx;
|
||||
public final int outerNameIdx;
|
||||
public final int simpleNameIdx;
|
||||
public final int accessFlags;
|
||||
@@ -19,8 +18,7 @@ public class StructInnerClassesAttribute extends StructGeneralAttribute {
|
||||
public final String enclosingName;
|
||||
public final String simpleName;
|
||||
|
||||
private Entry(int innerNameIdx, int outerNameIdx, int simpleNameIdx, int accessFlags, String innerName, String enclosingName, String simpleName) {
|
||||
this.innerNameIdx = innerNameIdx;
|
||||
private Entry(int outerNameIdx, int simpleNameIdx, int accessFlags, String innerName, String enclosingName, String simpleName) {
|
||||
this.outerNameIdx = outerNameIdx;
|
||||
this.simpleNameIdx = simpleNameIdx;
|
||||
this.accessFlags = accessFlags;
|
||||
@@ -48,7 +46,7 @@ public class StructInnerClassesAttribute extends StructGeneralAttribute {
|
||||
String outerName = outerNameIdx != 0 ? pool.getPrimitiveConstant(outerNameIdx).getString() : null;
|
||||
String simpleName = simpleNameIdx != 0 ? pool.getPrimitiveConstant(simpleNameIdx).getString() : null;
|
||||
|
||||
entries.add(new Entry(innerNameIdx, outerNameIdx, simpleNameIdx, accessFlags, innerName, outerName, simpleName));
|
||||
entries.add(new Entry(outerNameIdx, simpleNameIdx, accessFlags, innerName, outerName, simpleName));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -59,4 +57,4 @@ public class StructInnerClassesAttribute extends StructGeneralAttribute {
|
||||
public List<Entry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,6 @@ public class StructLineNumberTableAttribute extends StructGeneralAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
public int getFirstLine() {
|
||||
return myLineInfo.length > 0 ? myLineInfo[1] : -1;
|
||||
}
|
||||
|
||||
public int findLineNumber(int pc) {
|
||||
if (myLineInfo.length >= 2) {
|
||||
for (int i = myLineInfo.length - 2; i >= 0; i -= 2) {
|
||||
@@ -51,4 +47,4 @@ public class StructLineNumberTableAttribute extends StructGeneralAttribute {
|
||||
public int[] getRawData() {
|
||||
return myLineInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
/*
|
||||
u2 local_variable_type_table_length;
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.java.decompiler.struct.attr;
|
||||
|
||||
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class StructSourceFileAttribute extends StructGeneralAttribute {
|
||||
|
||||
private String fileName;
|
||||
|
||||
@Override
|
||||
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
|
||||
int index = data.readUnsignedShort();
|
||||
fileName = pool.getPrimitiveConstant(index).getString();
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
@@ -46,17 +46,17 @@ public class ConstantPool implements NewClassNameBuilder {
|
||||
break;
|
||||
|
||||
case CodeConstants.CONSTANT_Float:
|
||||
pool.add(new PrimitiveConstant(CodeConstants.CONSTANT_Float, Float.valueOf(in.readFloat())));
|
||||
pool.add(new PrimitiveConstant(CodeConstants.CONSTANT_Float, in.readFloat()));
|
||||
break;
|
||||
|
||||
case CodeConstants.CONSTANT_Long:
|
||||
pool.add(new PrimitiveConstant(CodeConstants.CONSTANT_Long, Long.valueOf(in.readLong())));
|
||||
pool.add(new PrimitiveConstant(CodeConstants.CONSTANT_Long, in.readLong()));
|
||||
pool.add(null);
|
||||
i++;
|
||||
break;
|
||||
|
||||
case CodeConstants.CONSTANT_Double:
|
||||
pool.add(new PrimitiveConstant(CodeConstants.CONSTANT_Double, Double.valueOf(in.readDouble())));
|
||||
pool.add(new PrimitiveConstant(CodeConstants.CONSTANT_Double, in.readDouble()));
|
||||
pool.add(null);
|
||||
i++;
|
||||
break;
|
||||
@@ -137,10 +137,6 @@ public class ConstantPool implements NewClassNameBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return pool.size();
|
||||
}
|
||||
|
||||
public String[] getClassElement(int elementType, String className, int nameIndex, int descriptorIndex) {
|
||||
String elementName = ((PrimitiveConstant)getConstant(nameIndex)).getString();
|
||||
String descriptor = ((PrimitiveConstant)getConstant(descriptorIndex)).getString();
|
||||
|
||||
@@ -1,41 +1,14 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.java.decompiler.struct.consts;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
* NameAndType, FieldRef, MethodRef, InterfaceMethodref
|
||||
* InvokeDynamic, MethodHandle
|
||||
*/
|
||||
|
||||
public class LinkConstant extends PooledConstant {
|
||||
|
||||
// *****************************************************************************
|
||||
// public fields
|
||||
// *****************************************************************************
|
||||
|
||||
public int index1, index2;
|
||||
|
||||
public String classname;
|
||||
|
||||
public String elementname;
|
||||
|
||||
public String descriptor;
|
||||
|
||||
public int paramCount = 0;
|
||||
|
||||
public boolean isVoid = false;
|
||||
|
||||
public boolean returnCategory2 = false;
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// constructors
|
||||
// *****************************************************************************
|
||||
|
||||
public LinkConstant(int type, String classname, String elementname, String descriptor) {
|
||||
this.type = type;
|
||||
super(type);
|
||||
this.classname = classname;
|
||||
this.elementname = elementname;
|
||||
this.descriptor = descriptor;
|
||||
@@ -44,18 +17,25 @@ public class LinkConstant extends PooledConstant {
|
||||
}
|
||||
|
||||
public LinkConstant(int type, int index1, int index2) {
|
||||
this.type = type;
|
||||
super(type);
|
||||
this.index1 = index1;
|
||||
this.index2 = index2;
|
||||
}
|
||||
|
||||
private void initConstant() {
|
||||
if (type == CONSTANT_Methodref ||
|
||||
type == CONSTANT_InterfaceMethodref ||
|
||||
type == CONSTANT_InvokeDynamic ||
|
||||
type == CONSTANT_MethodHandle) {
|
||||
int parenth = descriptor.indexOf(')');
|
||||
if (descriptor.length() < 2 || parenth < 0 || descriptor.charAt(0) != '(') {
|
||||
throw new IllegalArgumentException("Invalid descriptor: " + descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// public methods
|
||||
// *****************************************************************************
|
||||
|
||||
@Override
|
||||
public void resolveConstant(ConstantPool pool) {
|
||||
|
||||
if (type == CONSTANT_NameAndType) {
|
||||
elementname = pool.getPrimitiveConstant(index1).getString();
|
||||
descriptor = pool.getPrimitiveConstant(index2).getString();
|
||||
@@ -80,18 +60,7 @@ public class LinkConstant extends PooledConstant {
|
||||
initConstant();
|
||||
}
|
||||
|
||||
public void writeToStream(DataOutputStream out) throws IOException {
|
||||
out.writeByte(type);
|
||||
if (type == CONSTANT_MethodHandle) {
|
||||
out.writeByte(index1);
|
||||
}
|
||||
else {
|
||||
out.writeShort(index1);
|
||||
}
|
||||
out.writeShort(index2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (o == null || !(o instanceof LinkConstant)) return false;
|
||||
@@ -102,51 +71,4 @@ public class LinkConstant extends PooledConstant {
|
||||
this.descriptor.equals(cn.descriptor) &&
|
||||
(this.type != CONSTANT_NameAndType || this.classname.equals(cn.classname));
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// private methods
|
||||
// *****************************************************************************
|
||||
|
||||
private void initConstant() {
|
||||
|
||||
if (type == CONSTANT_Methodref ||
|
||||
type == CONSTANT_InterfaceMethodref ||
|
||||
type == CONSTANT_InvokeDynamic ||
|
||||
type == CONSTANT_MethodHandle) {
|
||||
resolveDescriptor(descriptor);
|
||||
}
|
||||
else if (type == CONSTANT_Fieldref) {
|
||||
returnCategory2 = ("D".equals(descriptor) || "J".equals(descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveDescriptor(String descr) {
|
||||
int parenth = descr.indexOf(')');
|
||||
if (descr.length() < 2 || parenth < 0 || descr.charAt(0) != '(') {
|
||||
throw new IllegalArgumentException("Invalid descriptor: " + descr);
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
if (parenth > 1) { // params
|
||||
int index = 1;
|
||||
while (index < parenth) {
|
||||
char c = descr.charAt(index);
|
||||
if (c == 'L') {
|
||||
index = descr.indexOf(";", index);
|
||||
}
|
||||
else if (c == '[') {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
counter++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
paramCount = counter;
|
||||
char retChar = descr.charAt(parenth + 1);
|
||||
isVoid = retChar == 'V';
|
||||
returnCategory2 = (retChar == 'D') || (retChar == 'J');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,101 +3,12 @@ package org.jetbrains.java.decompiler.struct.consts;
|
||||
|
||||
import org.jetbrains.java.decompiler.code.CodeConstants;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
public class PooledConstant implements CodeConstants {
|
||||
public final int type;
|
||||
|
||||
/*
|
||||
cp_info {
|
||||
u1 tag;
|
||||
u1 info[];
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public class PooledConstant implements CodeConstants, VariableTypeEnum {
|
||||
|
||||
// *****************************************************************************
|
||||
// public fields
|
||||
// *****************************************************************************
|
||||
|
||||
public int type;
|
||||
|
||||
public boolean own = false;
|
||||
|
||||
public int returnType;
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// private fields
|
||||
// *****************************************************************************
|
||||
|
||||
private Object[] values;
|
||||
|
||||
// *****************************************************************************
|
||||
// constructors
|
||||
// *****************************************************************************
|
||||
|
||||
public PooledConstant() {
|
||||
}
|
||||
|
||||
public PooledConstant(int type, Object[] values) {
|
||||
public PooledConstant(int type) {
|
||||
this.type = type;
|
||||
this.values = values;
|
||||
this.returnType = poolTypeToIntern(type);
|
||||
}
|
||||
|
||||
public PooledConstant(int type, boolean own, Object[] values) {
|
||||
this.type = type;
|
||||
this.own = own;
|
||||
this.values = values;
|
||||
this.returnType = poolTypeToIntern(type);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// public methods
|
||||
// *****************************************************************************
|
||||
|
||||
public void resolveConstant(ConstantPool pool) {
|
||||
// to be overwritten
|
||||
}
|
||||
|
||||
public void writeToStream(DataOutputStream out) throws IOException {
|
||||
// to be overwritten
|
||||
}
|
||||
|
||||
public int poolTypeToIntern(int type) {
|
||||
|
||||
switch (type) {
|
||||
case CONSTANT_Integer:
|
||||
return INT;
|
||||
case CONSTANT_Float:
|
||||
return FLOAT;
|
||||
case CONSTANT_Long:
|
||||
return LONG;
|
||||
case CONSTANT_Double:
|
||||
return DOUBLE;
|
||||
case CONSTANT_String:
|
||||
case CONSTANT_Class: // 1.5 -> ldc class
|
||||
return REFERENCE;
|
||||
default:
|
||||
throw new RuntimeException("Huh?? What are you trying to load?");
|
||||
}
|
||||
}
|
||||
|
||||
public Object getValue(int index) {
|
||||
return values[index];
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// getter and setter methods
|
||||
// *****************************************************************************
|
||||
|
||||
public Object[] getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(Object[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
public void resolveConstant(ConstantPool pool) { }
|
||||
}
|
||||
@@ -1,97 +1,43 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.java.decompiler.struct.consts;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
* Integer, Long, Float, Double, String, Class, UTF8
|
||||
*/
|
||||
|
||||
public class PrimitiveConstant extends PooledConstant {
|
||||
|
||||
// *****************************************************************************
|
||||
// public fields
|
||||
// *****************************************************************************
|
||||
|
||||
public int index;
|
||||
|
||||
public Object value;
|
||||
|
||||
public boolean isArray;
|
||||
|
||||
// *****************************************************************************
|
||||
// constructors
|
||||
// *****************************************************************************
|
||||
|
||||
public PrimitiveConstant(int type, Object value) {
|
||||
this.type = type;
|
||||
super(type);
|
||||
this.value = value;
|
||||
|
||||
initConstant();
|
||||
}
|
||||
|
||||
public PrimitiveConstant(int type, int index) {
|
||||
this.type = type;
|
||||
super(type);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// public methods
|
||||
// *****************************************************************************
|
||||
|
||||
public int getInt() {
|
||||
return ((Integer)value).intValue();
|
||||
}
|
||||
|
||||
public long getLong() {
|
||||
return ((Long)value).longValue();
|
||||
}
|
||||
|
||||
public float getFloat() {
|
||||
return ((Float)value).floatValue();
|
||||
}
|
||||
|
||||
public double getDouble() {
|
||||
return ((Double)value).doubleValue();
|
||||
private void initConstant() {
|
||||
if (type == CONSTANT_Class) {
|
||||
String className = getString();
|
||||
isArray = (className.length() > 0 && className.charAt(0) == '['); // empty string for a class name seems to be possible in some android files
|
||||
}
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return (String)value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolveConstant(ConstantPool pool) {
|
||||
|
||||
if (type == CONSTANT_Class || type == CONSTANT_String || type == CONSTANT_MethodType) {
|
||||
value = pool.getPrimitiveConstant(index).getString();
|
||||
initConstant();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToStream(DataOutputStream out) throws IOException {
|
||||
|
||||
out.writeByte(type);
|
||||
switch (type) {
|
||||
case CONSTANT_Integer:
|
||||
out.writeInt(getInt());
|
||||
break;
|
||||
case CONSTANT_Float:
|
||||
out.writeFloat(getFloat());
|
||||
break;
|
||||
case CONSTANT_Long:
|
||||
out.writeLong(getLong());
|
||||
break;
|
||||
case CONSTANT_Double:
|
||||
out.writeDouble(getDouble());
|
||||
break;
|
||||
case CONSTANT_Utf8:
|
||||
out.writeUTF(getString());
|
||||
break;
|
||||
default: // CONSTANT_Class, CONSTANT_String, CONSTANT_MethodType
|
||||
out.writeShort(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (o == null || !(o instanceof PrimitiveConstant)) return false;
|
||||
@@ -101,12 +47,4 @@ public class PrimitiveConstant extends PooledConstant {
|
||||
this.isArray == cn.isArray &&
|
||||
this.value.equals(cn.value);
|
||||
}
|
||||
|
||||
private void initConstant() {
|
||||
if (type == CONSTANT_Class) {
|
||||
String className = getString();
|
||||
isArray =
|
||||
(className.length() > 0 && className.charAt(0) == '['); // empty string for a class name seems to be possible in some android files
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.java.decompiler.struct.consts;
|
||||
|
||||
public interface VariableTypeEnum {
|
||||
|
||||
int BOOLEAN = 1;
|
||||
int BYTE = 2;
|
||||
int CHAR = 3;
|
||||
int SHORT = 4;
|
||||
int INT = 5;
|
||||
int FLOAT = 6;
|
||||
int LONG = 7;
|
||||
int DOUBLE = 8;
|
||||
int RETURN_ADDRESS = 9;
|
||||
int REFERENCE = 10;
|
||||
int INSTANCE_UNINITIALIZED = 11;
|
||||
int VALUE_UNKNOWN = 12;
|
||||
int VOID = 13;
|
||||
|
||||
Integer BOOLEAN_OBJ = new Integer(BOOLEAN);
|
||||
Integer BYTE_OBJ = new Integer(BYTE);
|
||||
Integer CHAR_OBJ = new Integer(CHAR);
|
||||
Integer SHORT_OBJ = new Integer(SHORT);
|
||||
Integer INT_OBJ = new Integer(INT);
|
||||
Integer FLOAT_OBJ = new Integer(FLOAT);
|
||||
Integer LONG_OBJ = new Integer(LONG);
|
||||
Integer DOUBLE_OBJ = new Integer(DOUBLE);
|
||||
Integer RETURN_ADDRESS_OBJ = new Integer(RETURN_ADDRESS);
|
||||
Integer REFERENCE_OBJ = new Integer(REFERENCE);
|
||||
Integer INSTANCE_UNINITIALIZED_OBJ = new Integer(INSTANCE_UNINITIALIZED);
|
||||
Integer VALUE_UNKNOWN_OBJ = new Integer(VALUE_UNKNOWN);
|
||||
Integer VOID_OBJ = new Integer(VOID);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ package org.jetbrains.java.decompiler.struct.gen.generics;
|
||||
import org.jetbrains.java.decompiler.code.CodeConstants;
|
||||
import org.jetbrains.java.decompiler.main.DecompilerContext;
|
||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
|
||||
import org.jetbrains.java.decompiler.util.TextUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -157,12 +158,9 @@ public class GenericMain {
|
||||
}
|
||||
|
||||
public static String getGenericCastTypeName(GenericType type) {
|
||||
String s = getTypeName(type);
|
||||
int dim = type.arrayDim;
|
||||
while (dim-- > 0) {
|
||||
s += "[]";
|
||||
}
|
||||
return s;
|
||||
StringBuilder s = new StringBuilder(getTypeName(type));
|
||||
TextUtil.append(s, "[]", type.arrayDim);
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
private static String getTypeName(GenericType type) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LazyLoader {
|
||||
|
||||
private final Map<String, Link> mapClassLinks = new HashMap<>();
|
||||
private final IBytecodeProvider provider;
|
||||
|
||||
@@ -130,17 +129,11 @@ public class LazyLoader {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Link {
|
||||
public static final int CLASS = 1;
|
||||
public static final int ENTRY = 2;
|
||||
|
||||
public final int type;
|
||||
public final String externalPath;
|
||||
public final String internalPath;
|
||||
|
||||
public Link(int type, String externalPath, String internalPath) {
|
||||
this.type = type;
|
||||
public Link(String externalPath, String internalPath) {
|
||||
this.externalPath = externalPath;
|
||||
this.internalPath = internalPath;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.java.decompiler.struct.match;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.ExitExprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.FunctionExprent;
|
||||
@@ -17,6 +10,8 @@ import org.jetbrains.java.decompiler.struct.gen.VarType;
|
||||
import org.jetbrains.java.decompiler.struct.match.IMatchable.MatchProperties;
|
||||
import org.jetbrains.java.decompiler.struct.match.MatchNode.RuleValue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class MatchEngine {
|
||||
|
||||
@@ -114,9 +109,9 @@ public class MatchEngine {
|
||||
MatchProperties property = (node_type == MatchNode.MATCHNODE_STATEMENT ? stat_properties : expr_properties).get(values[0]);
|
||||
if(property == null) { // unknown property defined
|
||||
throw new RuntimeException("Unknown matching property");
|
||||
} else {
|
||||
|
||||
Object value = null;
|
||||
}
|
||||
else {
|
||||
Object value;
|
||||
int parameter = 0;
|
||||
|
||||
String strValue = values[1];
|
||||
@@ -222,19 +217,17 @@ public class MatchEngine {
|
||||
}
|
||||
|
||||
public boolean checkAndSetVariableValue(String name, Object value) {
|
||||
|
||||
Object old_value = variables.get(name);
|
||||
if(old_value == null) {
|
||||
variables.put(name, value);
|
||||
} else if(!old_value.equals(value)) {
|
||||
return false;
|
||||
if (old_value != null) {
|
||||
return old_value.equals(value);
|
||||
}
|
||||
else {
|
||||
variables.put(name, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object getVariableValue(String name) {
|
||||
return variables.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user