diff --git a/jode/ChangeLog b/jode/ChangeLog index c85ca93..0daf342 100644 --- a/jode/ChangeLog +++ b/jode/ChangeLog @@ -1,4 +1,21 @@ -Tue Jan 30 15:35:19 2001 Jochen Hoenicke +2001-01-31 Jochen Hoenicke + + * jode/expr/Expression.java.in (updateParentTypes): Call setType, + instead of merging the types. Other childs want to know about the + type change as well. + * jode/decompiler/LocalInfo.java (combineWith): Reorganized a bit, + but no changes. + * jode/expr/InvokeOperator.java.in (dumpExpression): Always print + the ThisOperator if a field is from a parent class of an outer + class is used. And always qualify the this operator if not + innermost. + +2001-01-30 Jochen Hoenicke + + * jode/jvm/SyntheticAnalyzer.java.in (checkConstructorAccess): + Allow the special unifyParam to be the last parameter. + +2001-01-30 Jochen Hoenicke * jode/decompiler/TabbedPrintWriter.java: Better gnu style handling: (openBraceClass) (closeBraceClass) @@ -16,7 +33,7 @@ Tue Jan 30 15:35:19 2001 Jochen Hoenicke * jode/decompiler/UnaryOperator.java (dumpExpression): Insert a space for GNU_SPACING. -Tue Jan 30 15:28:10 2001 Jochen Hoenicke +2001-01-30 Jochen Hoenicke Added pascal style from Rolf Howarth * jode/decompiler/Options.java (PASCAL_STYLE): new constant. @@ -27,7 +44,7 @@ Tue Jan 30 15:28:10 2001 Jochen Hoenicke openBraceContinue, closeBrace, closeBraceNoSpace, closeBraceContinue): handle flush left. -Tue Jan 30 00:28:10 2001 Jochen Hoenicke +2001-01-30 Jochen Hoenicke * jode/type/NullType.java (intersection): Removed, since the version in ReferenceType is more correct. Before diff --git a/jode/jode/decompiler/LocalInfo.java b/jode/jode/decompiler/LocalInfo.java index 261a548..dba4a66 100644 --- a/jode/jode/decompiler/LocalInfo.java +++ b/jode/jode/decompiler/LocalInfo.java @@ -126,56 +126,58 @@ public class LocalInfo implements Declarable { * If this is called with ourself nothing will happen. * @param li the local info that we want to shadow. */ - public void combineWith(LocalInfo li) { - li = li.getLocalInfo(); - if (shadow != null) { - getLocalInfo().combineWith(li); - } else { - if (this != li) { - shadow = li; - if (!nameIsGenerated) - shadow.name = name; - if (constExpr != null) { - if (shadow.constExpr != null) - throw new jode.AssertError - ("local has multiple constExpr"); - shadow.constExpr = constExpr; - } - -// GlobalOptions.err.println("combining "+name+"("+type+") and " -// +shadow.name+"("+shadow.type+")"); - shadow.setType(type); - - - boolean needTypeUpdate = !li.type.equals(type); - - java.util.Enumeration enum = operators.elements(); - while (enum.hasMoreElements()) { - LocalVarOperator lvo = - (LocalVarOperator) enum.nextElement(); - if (needTypeUpdate) { - if ((GlobalOptions.debuggingFlags - & GlobalOptions.DEBUG_TYPES) != 0) - GlobalOptions.err.println("updating " + lvo); - lvo.updateType(); - } - shadow.operators.addElement(lvo); - } - - enum = hints.elements(); - while (enum.hasMoreElements()) { - Object hint = enum.nextElement(); - if (!shadow.hints.contains(hint)) - shadow.hints.addElement(hint); - } + public void combineWith(LocalInfo shadow) { + if (this.shadow != null) { + getLocalInfo().combineWith(shadow); + return; + } - /* Clear unused fields, to allow garbage collection. - */ - type = null; - name = null; - operators = null; - } - } + shadow = shadow.getLocalInfo(); + if (this == shadow) + return; + + this.shadow = shadow; + if (!nameIsGenerated) + shadow.name = name; + if (constExpr != null) { + if (shadow.constExpr != null) + throw new jode.AssertError + ("local has multiple constExpr"); + shadow.constExpr = constExpr; + } + +// GlobalOptions.err.println("combining "+name+"("+type+") and " +// +shadow.name+"("+shadow.type+")"); + shadow.setType(type); + + + boolean needTypeUpdate = !shadow.type.equals(type); + + java.util.Enumeration enum = operators.elements(); + while (enum.hasMoreElements()) { + LocalVarOperator lvo = + (LocalVarOperator) enum.nextElement(); + if (needTypeUpdate) { + if ((GlobalOptions.debuggingFlags + & GlobalOptions.DEBUG_TYPES) != 0) + GlobalOptions.err.println("updating " + lvo); + lvo.updateType(); + } + shadow.operators.addElement(lvo); + } + + enum = hints.elements(); + while (enum.hasMoreElements()) { + Object hint = enum.nextElement(); + if (!shadow.hints.contains(hint)) + shadow.hints.addElement(hint); + } + + /* Clear unused fields, to allow garbage collection. + */ + type = null; + name = null; + operators = null; } /** diff --git a/jode/jode/decompiler/MethodAnalyzer.java.in b/jode/jode/decompiler/MethodAnalyzer.java.in index ad29a81..1a1e07f 100644 --- a/jode/jode/decompiler/MethodAnalyzer.java.in +++ b/jode/jode/decompiler/MethodAnalyzer.java.in @@ -1011,8 +1011,7 @@ public class MethodAnalyzer implements Scope, ClassDeclarer { expr).getSubExpressions()[0]; if (expr instanceof ThisOperator) { outerValueArray[j] = - new ThisOperator(((ThisOperator) - expr).getClassInfo()); + new ThisOperator(((ThisOperator) expr).getClassInfo()); continue; } LocalInfo li = null; diff --git a/jode/jode/expr/Expression.java.in b/jode/jode/expr/Expression.java.in index 8e2cd4f..4d0a4bc 100644 --- a/jode/jode/expr/Expression.java.in +++ b/jode/jode/expr/Expression.java.in @@ -53,23 +53,7 @@ public abstract class Expression { } public void updateParentType(Type otherType) { - Type newType = otherType.intersection(type); - if (type.equals(newType)) - return; - - if (newType == Type.tError) { - if (otherType == Type.tError) { - // Don't propagate type errors. - return; - } - GlobalOptions.err.println("updateParentType: Type error in " - +this+": merging "+getType() - +" and "+otherType); - if ((GlobalOptions.debuggingFlags - & GlobalOptions.DEBUG_TYPES) != 0) - Thread.dumpStack(); - } - type = newType; + setType(newType); if (parent != null) parent.updateType(); } diff --git a/jode/jode/expr/IfThenElseOperator.java b/jode/jode/expr/IfThenElseOperator.java index 586460e..33e2e6b 100644 --- a/jode/jode/expr/IfThenElseOperator.java +++ b/jode/jode/expr/IfThenElseOperator.java @@ -39,9 +39,9 @@ public class IfThenElseOperator extends Operator { } public void updateType() { - Type subType = Type.tSuperType(subExpressions[1].getType()) + Type commonType = Type.tSuperType(subExpressions[1].getType()) .intersection(Type.tSuperType(subExpressions[2].getType())); - updateParentType(subType); + updateParentType(commonType); } public Expression simplify() { diff --git a/jode/jode/expr/InvokeOperator.java.in b/jode/jode/expr/InvokeOperator.java.in index 0f5d55e..75c5d54 100644 --- a/jode/jode/expr/InvokeOperator.java.in +++ b/jode/jode/expr/InvokeOperator.java.in @@ -1058,30 +1058,19 @@ public final class InvokeOperator extends Operator ThisOperator thisOp = (ThisOperator) subExpressions[0]; Scope scope = writer.getScope(thisOp.getClassInfo(), Scope.CLASSSCOPE); - if (writer.conflicts(methodName, scope, Scope.METHODNAME)) { + if (writer.conflicts(methodName, scope, Scope.METHODNAME) + || (/* This field is inherited from the parent of + * an outer class, or it is inherited from the + * parent of this class and there is a conflicting + * field in some outer class. + */ + getMethodAnalyzer() == null + && (!isThis() || + writer.conflicts(methodName, null, + Scope.NOSUPERMETHODNAME)))) { thisOp.dumpExpression(writer, 950); writer.breakOp(); writer.print("."); - } else if (/* This is a inherited field conflicting - * with a field name in some outer class. - */ - getMethodAnalyzer() == null - && writer.conflicts(methodName, null, - Scope.NOSUPERMETHODNAME)) { - ClassAnalyzer ana = methodAnalyzer.getClassAnalyzer(); - while (ana.getParent() instanceof ClassAnalyzer - && ana != scope) - ana = (ClassAnalyzer) ana.getParent(); - if (ana == scope) { - // For a simple outer class we can say this - writer.print("this"); - } else { - // For a class that owns a method that owns - // us, we have to give the full class name - thisOp.dumpExpression(writer, 950); - } - writer.breakOp(); - writer.print("."); } } else { if (needsCast(0, paramTypes)){ diff --git a/jode/jode/jvm/SyntheticAnalyzer.java.in b/jode/jode/jvm/SyntheticAnalyzer.java.in index add4956..a6d13d1 100644 --- a/jode/jode/jvm/SyntheticAnalyzer.java.in +++ b/jode/jode/jvm/SyntheticAnalyzer.java.in @@ -330,10 +330,11 @@ public class SyntheticAnalyzer implements Opcodes { public boolean checkConstructorAccess() { ClassInfo clazzInfo = method.getClazzInfo(); BytecodeInfo bytecode = method.getBytecode(); + String[] paramTypes + = TypeSignature.getParameterTypes(method.getType()); Handler[] excHandlers = bytecode.getExceptionHandlers(); if (excHandlers != null && excHandlers.length != 0) return false; - Iterator iter = bytecode.getInstructions().iterator(); Instruction instr = (Instruction) iter.next(); @@ -343,8 +344,7 @@ public class SyntheticAnalyzer implements Opcodes { if (instr.getLocalSlot() > slot && unifyParam == -1 && params > 0 - && TypeSignature.getParameterTypes(method.getType()) - [params - 1].charAt(0) == 'L') { + && paramTypes[params - 1].charAt(0) == 'L') { unifyParam = params; params++; slot++; @@ -357,7 +357,12 @@ public class SyntheticAnalyzer implements Opcodes { || instr.getOpcode() == opc_dload) ? 2 : 1; instr = (Instruction) iter.next(); } - if (instr.getOpcode() == opc_invokespecial) { + if (params > 0 && instr.getOpcode() == opc_invokespecial) { + + if (unifyParam == -1 && params <= paramTypes.length + && paramTypes[params - 1].charAt(0) == 'L') + unifyParam = params++; + Reference ref = instr.getReference(); String refClazz = ref.getClazz().substring(1); if (!(refClazz.substring(0, refClazz.length()-1) @@ -371,6 +376,7 @@ public class SyntheticAnalyzer implements Opcodes { || unifyParam == -1 || refType.getParameterTypes().length != params - 2) return false; + instr = (Instruction) iter.next(); if (instr.getOpcode() != opc_return) return false;