SyntheticAnalyzer: Allow the special unifyParam to be the last parameter.

Expression: Call setType in updateParentTypes.
InvokeOperator: print ThisOperator more often.


git-svn-id: https://svn.code.sf.net/p/jode/code/branches/branch_1_1@1293 379699f6-c40d-0410-875b-85095c16579e
branch_1_1
hoenicke 24 years ago
parent cb12d3ead2
commit d0a70c3626
  1. 23
      jode/ChangeLog
  2. 100
      jode/jode/decompiler/LocalInfo.java
  3. 3
      jode/jode/decompiler/MethodAnalyzer.java.in
  4. 18
      jode/jode/expr/Expression.java.in
  5. 4
      jode/jode/expr/IfThenElseOperator.java
  6. 31
      jode/jode/expr/InvokeOperator.java.in
  7. 14
      jode/jode/jvm/SyntheticAnalyzer.java.in

@ -1,4 +1,21 @@
Tue Jan 30 15:35:19 2001 Jochen Hoenicke <jochen@gnu.org> 2001-01-31 Jochen Hoenicke <jochen@gnu.org>
* 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 <jochen@gnu.org>
* jode/jvm/SyntheticAnalyzer.java.in (checkConstructorAccess):
Allow the special unifyParam to be the last parameter.
2001-01-30 Jochen Hoenicke <jochen@gnu.org>
* jode/decompiler/TabbedPrintWriter.java: Better gnu style handling: * jode/decompiler/TabbedPrintWriter.java: Better gnu style handling:
(openBraceClass) (closeBraceClass) (openBraceClass) (closeBraceClass)
@ -16,7 +33,7 @@ Tue Jan 30 15:35:19 2001 Jochen Hoenicke <jochen@gnu.org>
* jode/decompiler/UnaryOperator.java (dumpExpression): Insert * jode/decompiler/UnaryOperator.java (dumpExpression): Insert
a space for GNU_SPACING. a space for GNU_SPACING.
Tue Jan 30 15:28:10 2001 Jochen Hoenicke <jochen@gnu.org> 2001-01-30 Jochen Hoenicke <jochen@gnu.org>
Added pascal style from Rolf Howarth <rolf@squarebox.co.uk> Added pascal style from Rolf Howarth <rolf@squarebox.co.uk>
* jode/decompiler/Options.java (PASCAL_STYLE): new constant. * jode/decompiler/Options.java (PASCAL_STYLE): new constant.
@ -27,7 +44,7 @@ Tue Jan 30 15:28:10 2001 Jochen Hoenicke <jochen@gnu.org>
openBraceContinue, closeBrace, closeBraceNoSpace, openBraceContinue, closeBrace, closeBraceNoSpace,
closeBraceContinue): handle flush left. closeBraceContinue): handle flush left.
Tue Jan 30 00:28:10 2001 Jochen Hoenicke <jochen@gnu.org> 2001-01-30 Jochen Hoenicke <jochen@gnu.org>
* jode/type/NullType.java (intersection): Removed, since the * jode/type/NullType.java (intersection): Removed, since the
version in ReferenceType is more correct. Before version in ReferenceType is more correct. Before

@ -126,56 +126,58 @@ public class LocalInfo implements Declarable {
* If this is called with ourself nothing will happen. * If this is called with ourself nothing will happen.
* @param li the local info that we want to shadow. * @param li the local info that we want to shadow.
*/ */
public void combineWith(LocalInfo li) { public void combineWith(LocalInfo shadow) {
li = li.getLocalInfo(); if (this.shadow != null) {
if (shadow != null) { getLocalInfo().combineWith(shadow);
getLocalInfo().combineWith(li); return;
} 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);
}
/* Clear unused fields, to allow garbage collection. shadow = shadow.getLocalInfo();
*/ if (this == shadow)
type = null; return;
name = null;
operators = null; 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;
} }
/** /**

@ -1011,8 +1011,7 @@ public class MethodAnalyzer implements Scope, ClassDeclarer {
expr).getSubExpressions()[0]; expr).getSubExpressions()[0];
if (expr instanceof ThisOperator) { if (expr instanceof ThisOperator) {
outerValueArray[j] = outerValueArray[j] =
new ThisOperator(((ThisOperator) new ThisOperator(((ThisOperator) expr).getClassInfo());
expr).getClassInfo());
continue; continue;
} }
LocalInfo li = null; LocalInfo li = null;

@ -53,23 +53,7 @@ public abstract class Expression {
} }
public void updateParentType(Type otherType) { public void updateParentType(Type otherType) {
Type newType = otherType.intersection(type); setType(newType);
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;
if (parent != null) if (parent != null)
parent.updateType(); parent.updateType();
} }

@ -39,9 +39,9 @@ public class IfThenElseOperator extends Operator {
} }
public void updateType() { public void updateType() {
Type subType = Type.tSuperType(subExpressions[1].getType()) Type commonType = Type.tSuperType(subExpressions[1].getType())
.intersection(Type.tSuperType(subExpressions[2].getType())); .intersection(Type.tSuperType(subExpressions[2].getType()));
updateParentType(subType); updateParentType(commonType);
} }
public Expression simplify() { public Expression simplify() {

@ -1058,30 +1058,19 @@ public final class InvokeOperator extends Operator
ThisOperator thisOp = (ThisOperator) subExpressions[0]; ThisOperator thisOp = (ThisOperator) subExpressions[0];
Scope scope = writer.getScope(thisOp.getClassInfo(), Scope scope = writer.getScope(thisOp.getClassInfo(),
Scope.CLASSSCOPE); 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); thisOp.dumpExpression(writer, 950);
writer.breakOp(); writer.breakOp();
writer.print("."); 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 { } else {
if (needsCast(0, paramTypes)){ if (needsCast(0, paramTypes)){

@ -330,10 +330,11 @@ public class SyntheticAnalyzer implements Opcodes {
public boolean checkConstructorAccess() { public boolean checkConstructorAccess() {
ClassInfo clazzInfo = method.getClazzInfo(); ClassInfo clazzInfo = method.getClazzInfo();
BytecodeInfo bytecode = method.getBytecode(); BytecodeInfo bytecode = method.getBytecode();
String[] paramTypes
= TypeSignature.getParameterTypes(method.getType());
Handler[] excHandlers = bytecode.getExceptionHandlers(); Handler[] excHandlers = bytecode.getExceptionHandlers();
if (excHandlers != null && excHandlers.length != 0) if (excHandlers != null && excHandlers.length != 0)
return false; return false;
Iterator iter = bytecode.getInstructions().iterator(); Iterator iter = bytecode.getInstructions().iterator();
Instruction instr = (Instruction) iter.next(); Instruction instr = (Instruction) iter.next();
@ -343,8 +344,7 @@ public class SyntheticAnalyzer implements Opcodes {
if (instr.getLocalSlot() > slot if (instr.getLocalSlot() > slot
&& unifyParam == -1 && params > 0 && unifyParam == -1 && params > 0
&& TypeSignature.getParameterTypes(method.getType()) && paramTypes[params - 1].charAt(0) == 'L') {
[params - 1].charAt(0) == 'L') {
unifyParam = params; unifyParam = params;
params++; params++;
slot++; slot++;
@ -357,7 +357,12 @@ public class SyntheticAnalyzer implements Opcodes {
|| instr.getOpcode() == opc_dload) ? 2 : 1; || instr.getOpcode() == opc_dload) ? 2 : 1;
instr = (Instruction) iter.next(); 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(); Reference ref = instr.getReference();
String refClazz = ref.getClazz().substring(1); String refClazz = ref.getClazz().substring(1);
if (!(refClazz.substring(0, refClazz.length()-1) if (!(refClazz.substring(0, refClazz.length()-1)
@ -371,6 +376,7 @@ public class SyntheticAnalyzer implements Opcodes {
|| unifyParam == -1 || unifyParam == -1
|| refType.getParameterTypes().length != params - 2) || refType.getParameterTypes().length != params - 2)
return false; return false;
instr = (Instruction) iter.next(); instr = (Instruction) iter.next();
if (instr.getOpcode() != opc_return) if (instr.getOpcode() != opc_return)
return false; return false;

Loading…
Cancel
Save