Moved getDefaultValue to TypeSignature

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1278 379699f6-c40d-0410-875b-85095c16579e
master
hoenicke 24 years ago
parent 00448cfcbc
commit 0e32c28865
  1. 22
      jode/jode/bytecode/TypeSignature.java
  2. 19
      jode/jode/obfuscator/ConstantRuntimeEnvironment.java
  3. 2
      jode/jode/obfuscator/modules/ConstantAnalyzer.java

@ -216,6 +216,28 @@ public class TypeSignature {
return params;
}
public static Object getDefaultValue(String typeSig) {
switch(typeSig.charAt(0)) {
case 'Z':
case 'B':
case 'S':
case 'C':
case 'I':
return new Integer(0);
case 'J':
return new Long(0L);
case 'D':
return new Double(0.0);
case 'F':
return new Float(0.0F);
case 'L':
case '[':
return null;
default:
throw new IllegalArgumentException(typeSig);
}
}
/**
* Returns the number of words, an object of the given simple type
* signature takes.

@ -222,25 +222,6 @@ public class ConstantRuntimeEnvironment extends SimpleRuntimeEnvironment {
interpreter = new Interpreter(this);
}
public static Object getDefaultValue(String typeSig) {
switch(typeSig.charAt(0)) {
case 'Z':
case 'B':
case 'S':
case 'C':
case 'I':
return new Integer(0);
case 'J':
return new Long(0L);
case 'D':
return new Double(0.0);
case 'F':
return new Float(0.0F);
default:
return null;
}
}
public Object getField(Reference ref, Object obj)
throws InterpreterException {
if (isWhite(ref))

@ -1479,7 +1479,7 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer {
} else {
Object obj = fi.getConstant();
if (obj == null)
obj = runtime.getDefaultValue(ref.getType());
obj = TypeSignature.getDefaultValue(ref.getType());
ConstantInfo constInfo = new ConstantInfo(CONSTANT, obj);
constantInfos.put(instr, constInfo);
result = new ConstValue(obj);

Loading…
Cancel
Save