diff --git a/jode/jode/expr/ComplexExpression.java b/jode/jode/expr/ComplexExpression.java index 68f5b97..76549cf 100644 --- a/jode/jode/expr/ComplexExpression.java +++ b/jode/jode/expr/ComplexExpression.java @@ -19,7 +19,8 @@ package jode.expr; import jode.Decompiler; -import jode.Type; +import jode.type.Type; +import jode.decompiler.TabbedPrintWriter; public class ComplexExpression extends Expression { Operator operator; @@ -317,28 +318,9 @@ public class ComplexExpression extends Expression { return operator.getType() == Type.tVoid; } - public String toString() { - String[] expr = new String[subExpressions.length]; - for (int i=0; i") - + operator.getOperandType(i)+") "+expr[i]; - if (700 < operator.getOperandPriority(i)) - expr[i] = "(" + expr[i] + ")"; - } - else if (subExpressions[i].getType() == Type.tError) - expr[i] = "(/*type error */" + expr[i]+")"; - } - if (Decompiler.isTypeDebugging && parent != null) - return "[("+type+") "+ operator.toString(expr)+"]"; - return operator.toString(expr); + public void dumpExpression(TabbedPrintWriter writer) + throws java.io.IOException { + operator.dumpExpression(writer, subExpressions); } public boolean equals(Object o) { @@ -498,7 +480,7 @@ public class ComplexExpression extends Expression { if ((operator.getOperatorIndex() == operator.OPASSIGN_OP+operator.ADD_OP || operator.getOperatorIndex() == - operator.OPASSIGN_OP+operator.NEG_OP) && + operator.OPASSIGN_OP+operator.SUB_OP) && (one.getValue().equals("1") || one.getValue().equals("1.0"))) { diff --git a/jode/jode/expr/Operator.java b/jode/jode/expr/Operator.java index 66ca0e8..e5f9e9c 100644 --- a/jode/jode/expr/Operator.java +++ b/jode/jode/expr/Operator.java @@ -18,11 +18,12 @@ */ package jode.expr; -import jode.Type; +import jode.type.Type; +import jode.decompiler.TabbedPrintWriter; public abstract class Operator extends Expression { public final static int ADD_OP = 1; - public final static int NEG_OP = 2; + public final static int SUB_OP = 2; public final static int SHIFT_OP = 6; public final static int AND_OP = 9; public final static int ASSIGN_OP = 12; @@ -35,6 +36,7 @@ public abstract class Operator extends Expression { public final static int LOG_AND_OP = 32; /* must be even! */ public final static int LOG_OR_OP = 33; public final static int LOG_NOT_OP = 34; + public final static int NEG_OP = 36; static String opString[] = { "", " + ", " - ", " * ", " / ", " % ", " << ", " >> ", " >>> ", " & ", " | ", " ^ ", @@ -42,7 +44,7 @@ public abstract class Operator extends Expression { " <<= ", " >>= ", " >>>= ", " &= ", " |= ", " ^= ", "++", "--", " == "," != "," < "," >= "," > ", " <= ", " && ", " || ", - "!", "~" + "!", "~", "-" }; protected int operator; @@ -98,23 +100,20 @@ public abstract class Operator extends Expression { */ public abstract int getPriority(); - /** - * Get minimum priority of the nth operand. - * @see getPriority - */ - public abstract int getOperandPriority(int i); public abstract Type getOperandType(int i); public abstract int getOperandCount(); public abstract void setOperandType(Type[] inputTypes); - public abstract String toString(String[] operands); - public String toString() - { - String[] operands = new String[getOperandCount()]; - for (int i=0; i< operands.length; i++) { - operands[i] = "stack_"+(operands.length-i-1); - } - return toString(operands); + public abstract void dumpExpression + (TabbedPrintWriter writer, Expression[] operands) + throws java.io.IOException; + + public void dumpExpression(TabbedPrintWriter writer) + throws java.io.IOException { + Expression[] operands = new Expression[getOperandCount()]; + for (int i=0; i< operands.length; i++) + operands[i] = new NopOperator(getOperandType(i)); + dumpExpression(writer, operands); } }