getIdentifier(ref)

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@584 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 2f20c95fde
commit a58ace28de
  1. 180
      jode/jode/obfuscator/ConstantRuntimeEnvironment.java

@ -56,96 +56,96 @@ public class ConstantRuntimeEnvironment extends SimpleRuntimeEnvironment {
///#endif ///#endif
static { static {
addWhite(new Reference("java.lang.String", "toCharArray", "()[C")); addWhite(new Reference("Ljava/lang/String;", "toCharArray", "()[C"));
addWhite(new Reference("java.lang.StringBuffer", "<init>", addWhite(new Reference("Ljava/lang/StringBuffer;", "<init>",
"(Ljava/lang/String;)V")); "(Ljava/lang/String;)V"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(Ljava/lang/String;)Ljava/lang/StringBuffer;")); "(Ljava/lang/String;)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(C)Ljava/lang/StringBuffer;")); "(C)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(B)Ljava/lang/StringBuffer;")); "(B)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(S)Ljava/lang/StringBuffer;")); "(S)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(Z)Ljava/lang/StringBuffer;")); "(Z)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(F)Ljava/lang/StringBuffer;")); "(F)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(I)Ljava/lang/StringBuffer;")); "(I)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(J)Ljava/lang/StringBuffer;")); "(J)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "append", addWhite(new Reference("Ljava/lang/StringBuffer;", "append",
"(D)Ljava/lang/StringBuffer;")); "(D)Ljava/lang/StringBuffer;"));
addWhite(new Reference("java.lang.StringBuffer", "toString", addWhite(new Reference("Ljava/lang/StringBuffer;", "toString",
"()Ljava/lang/String;")); "()Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "<init>", "()V")); addWhite(new Reference("Ljava/lang/String;", "<init>", "()V"));
addWhite(new Reference("java.lang.String", "<init>", "([C)V")); addWhite(new Reference("Ljava/lang/String;", "<init>", "([C)V"));
addWhite(new Reference("java.lang.String", "<init>", "([CII)V")); addWhite(new Reference("Ljava/lang/String;", "<init>", "([CII)V"));
addWhite(new Reference("java.lang.String", "<init>", addWhite(new Reference("Ljava/lang/String;", "<init>",
"(Ljava/lang/String;)V")); "(Ljava/lang/String;)V"));
addWhite(new Reference("java.lang.String", "<init>", addWhite(new Reference("Ljava/lang/String;", "<init>",
"(Ljava/lang/StringBuffer;)V")); "(Ljava/lang/StringBuffer;)V"));
addWhite(new Reference("java.lang.String", "length", "()I")); addWhite(new Reference("Ljava/lang/String;", "length", "()I"));
addWhite(new Reference("java.lang.String", "replace", addWhite(new Reference("Ljava/lang/String;", "replace",
"(CC)Ljava/lang/String;")); "(CC)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(Z)Ljava/lang/String;")); "(Z)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(B)Ljava/lang/String;")); "(B)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(S)Ljava/lang/String;")); "(S)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(C)Ljava/lang/String;")); "(C)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(D)Ljava/lang/String;")); "(D)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(F)Ljava/lang/String;")); "(F)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(I)Ljava/lang/String;")); "(I)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(J)Ljava/lang/String;")); "(J)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "valueOf", addWhite(new Reference("Ljava/lang/String;", "valueOf",
"(Ljava/lang/Object;)Ljava/lang/String;")); "(Ljava/lang/Object;)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "substring", addWhite(new Reference("Ljava/lang/String;", "substring",
"(I)Ljava/lang/String;")); "(I)Ljava/lang/String;"));
addWhite(new Reference("java.lang.String", "substring", addWhite(new Reference("Ljava/lang/String;", "substring",
"(II)Ljava/lang/String;")); "(II)Ljava/lang/String;"));
addWhite(new Reference("java.lang.reflect.Modifier", "toString", addWhite(new Reference("Ljava.lang/reflect/Modifier;", "toString",
"(I)Ljava/lang/String;")); "(I)Ljava/lang/String;"));
addWhite(new Reference("java.lang.Math", "abs", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "abs", "(D)D"));
addWhite(new Reference("java.lang.Math", "abs", "(F)F")); addWhite(new Reference("Ljava/lang/Math;", "abs", "(F)F"));
addWhite(new Reference("java.lang.Math", "abs", "(I)I")); addWhite(new Reference("Ljava/lang/Math;", "abs", "(I)I"));
addWhite(new Reference("java.lang.Math", "abs", "(J)J")); addWhite(new Reference("Ljava/lang/Math;", "abs", "(J)J"));
addWhite(new Reference("java.lang.Math", "acos", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "acos", "(D)D"));
addWhite(new Reference("java.lang.Math", "asin", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "asin", "(D)D"));
addWhite(new Reference("java.lang.Math", "atan", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "atan", "(D)D"));
addWhite(new Reference("java.lang.Math", "atan2", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "atan2", "(D)D"));
addWhite(new Reference("java.lang.Math", "ceil", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "ceil", "(D)D"));
addWhite(new Reference("java.lang.Math", "cos", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "cos", "(D)D"));
addWhite(new Reference("java.lang.Math", "exp", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "exp", "(D)D"));
addWhite(new Reference("java.lang.Math", "floor", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "floor", "(D)D"));
addWhite(new Reference("java.lang.Math", "IEEEremainder", "(DD)D")); addWhite(new Reference("Ljava/lang/Math;", "IEEEremainder", "(DD)D"));
addWhite(new Reference("java.lang.Math", "log", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "log", "(D)D"));
addWhite(new Reference("java.lang.Math", "max", "(DD)D")); addWhite(new Reference("Ljava/lang/Math;", "max", "(DD)D"));
addWhite(new Reference("java.lang.Math", "max", "(FF)F")); addWhite(new Reference("Ljava/lang/Math;", "max", "(FF)F"));
addWhite(new Reference("java.lang.Math", "max", "(II)I")); addWhite(new Reference("Ljava/lang/Math;", "max", "(II)I"));
addWhite(new Reference("java.lang.Math", "max", "(JJ)J")); addWhite(new Reference("Ljava/lang/Math;", "max", "(JJ)J"));
addWhite(new Reference("java.lang.Math", "min", "(DD)D")); addWhite(new Reference("Ljava/lang/Math;", "min", "(DD)D"));
addWhite(new Reference("java.lang.Math", "min", "(FF)F")); addWhite(new Reference("Ljava/lang/Math;", "min", "(FF)F"));
addWhite(new Reference("java.lang.Math", "min", "(II)I")); addWhite(new Reference("Ljava/lang/Math;", "min", "(II)I"));
addWhite(new Reference("java.lang.Math", "min", "(JJ)J")); addWhite(new Reference("Ljava/lang/Math;", "min", "(JJ)J"));
addWhite(new Reference("java.lang.Math", "pow", "(DD)D")); addWhite(new Reference("Ljava/lang/Math;", "pow", "(DD)D"));
addWhite(new Reference("java.lang.Math", "rint", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "rint", "(D)D"));
addWhite(new Reference("java.lang.Math", "round", "(D)J")); addWhite(new Reference("Ljava/lang/Math;", "round", "(D)J"));
addWhite(new Reference("java.lang.Math", "round", "(F)I")); addWhite(new Reference("Ljava/lang/Math;", "round", "(F)I"));
addWhite(new Reference("java.lang.Math", "sin", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "sin", "(D)D"));
addWhite(new Reference("java.lang.Math", "sqrt", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "sqrt", "(D)D"));
addWhite(new Reference("java.lang.Math", "tan", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "tan", "(D)D"));
addWhite(new Reference("java.lang.Math", "toDegrees", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "toDegrees", "(D)D"));
addWhite(new Reference("java.lang.Math", "toRadians", "(D)D")); addWhite(new Reference("Ljava/lang/Math;", "toRadians", "(D)D"));
addWhite(new Reference("java.lang.Math", "E", "D")); addWhite(new Reference("Ljava/lang/Math;", "E", "D"));
addWhite(new Reference("java.lang.Math", "PI", "D")); addWhite(new Reference("Ljava/lang/Math;", "PI", "D"));
} }
MethodIdentifier m; MethodIdentifier m;
@ -158,17 +158,13 @@ public class ConstantRuntimeEnvironment extends SimpleRuntimeEnvironment {
if (isWhite(ref)) if (isWhite(ref))
return super.getField(ref, obj); return super.getField(ref, obj);
Type type = Type.tType(ref.getType()); Type type = Type.tType(ref.getType());
ClassIdentifier ci = (ClassIdentifier) FieldIdentifier fi = (FieldIdentifier)
m.clazz.bundle.getIdentifier(ref.getClazz()); m.clazz.bundle.getIdentifier(ref);
if (ci != null) { if (fi != null && !fi.isNotConstant()) {
FieldIdentifier fi = (FieldIdentifier) Object result = fi.getConstant();
ci.getIdentifier(ref.getName(), ref.getType()); if (result == null)
if (fi != null && !fi.isNotConstant()) { result = type.getDefaultValue();
Object result = fi.getConstant();
if (result == null)
result = type.getDefaultValue();
return result; return result;
}
} }
throw new InterpreterException("Field " + ref + " not constant"); throw new InterpreterException("Field " + ref + " not constant");
} }
@ -191,27 +187,23 @@ public class ConstantRuntimeEnvironment extends SimpleRuntimeEnvironment {
if (isWhite(ref)) if (isWhite(ref))
return super.invokeMethod(ref, isVirtual, cls, params); return super.invokeMethod(ref, isVirtual, cls, params);
Type type = Type.tType(ref.getType()); Type type = Type.tType(ref.getType());
ClassIdentifier ci = (ClassIdentifier) MethodIdentifier mi = (MethodIdentifier)
m.clazz.bundle.getIdentifier(ref.getClazz()); m.clazz.bundle.getIdentifier(ref);
if (ci != null) { if (mi != null) {
MethodIdentifier mi = (MethodIdentifier) BytecodeInfo code = mi.getBytecode();
ci.getIdentifier(ref.getName(), ref.getType()); if (code != null) {
if (mi != null) { MethodType mt = (MethodType) Type.tType(ref.getType());
BytecodeInfo code = mi.getBytecode(); Value[] locals = new Value[code.getMaxLocals()];
if (code != null) { for (int i=0; i< locals.length; i++)
MethodType mt = (MethodType) Type.tType(ref.getType()); locals[i] = new Value();
Value[] locals = new Value[code.getMaxLocals()]; int slot = 0;
for (int i=0; i< locals.length; i++) if (cls != null)
locals[i] = new Value(); locals[slot++].setObject(cls);
int slot = 0; for (int i = 0; i < params.length; i++) {
if (cls != null) locals[slot].setObject(params[i]);
locals[slot++].setObject(cls); slot += mt.getParameterTypes()[i].stackSize();
for (int i = 0; i < params.length; i++) {
locals[slot].setObject(params[i]);
slot += mt.getParameterTypes()[i].stackSize();
}
return Interpreter.interpretMethod(this, code, locals);
} }
return Interpreter.interpretMethod(this, code, locals);
} }
} }
throw new InterpreterException("Invoking library method " + ref + "."); throw new InterpreterException("Invoking library method " + ref + ".");

Loading…
Cancel
Save