Types moved to jode.type

dumpExpression


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@611 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 1ee2befce5
commit ff22fd1303
  1. 30
      jode/jode/expr/ComplexExpression.java
  2. 31
      jode/jode/expr/Operator.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<subExpressions.length; i++) {
expr[i] = subExpressions[i].
toString(Decompiler.isTypeDebugging
? 700 /* type cast priority */
: operator.getOperandPriority(i));
if (Decompiler.isTypeDebugging) {
expr[i] = "("+
(operator.getOperandType(i)
.equals(subExpressions[i].getType())
? "" : ""+subExpressions[i].getType()+"->")
+ 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"))) {

@ -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);
}
}

Loading…
Cancel
Save