From 0e32c28865b1cd086dc42a0ec8faca0ca41cfabd Mon Sep 17 00:00:00 2001 From: hoenicke Date: Tue, 5 Dec 2000 19:05:47 +0000 Subject: [PATCH] Moved getDefaultValue to TypeSignature git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1278 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/bytecode/TypeSignature.java | 22 +++++++++++++++++++ .../ConstantRuntimeEnvironment.java | 19 ---------------- .../obfuscator/modules/ConstantAnalyzer.java | 2 +- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/jode/jode/bytecode/TypeSignature.java b/jode/jode/bytecode/TypeSignature.java index 53e9b56..566fba6 100644 --- a/jode/jode/bytecode/TypeSignature.java +++ b/jode/jode/bytecode/TypeSignature.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. diff --git a/jode/jode/obfuscator/ConstantRuntimeEnvironment.java b/jode/jode/obfuscator/ConstantRuntimeEnvironment.java index bbd66f8..ebf7893 100644 --- a/jode/jode/obfuscator/ConstantRuntimeEnvironment.java +++ b/jode/jode/obfuscator/ConstantRuntimeEnvironment.java @@ -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)) diff --git a/jode/jode/obfuscator/modules/ConstantAnalyzer.java b/jode/jode/obfuscator/modules/ConstantAnalyzer.java index c5672fa..cd94dff 100644 --- a/jode/jode/obfuscator/modules/ConstantAnalyzer.java +++ b/jode/jode/obfuscator/modules/ConstantAnalyzer.java @@ -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);