LocalVarOperator now fillDeclarableis itself.

ConstOperator.isOne(type) added and used.


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1210 379699f6-c40d-0410-875b-85095c16579e
branch_1_1
jochen 25 years ago
parent 22166d2741
commit e959a929a9
  1. 23
      jode/jode/expr/ConstOperator.java
  2. 9
      jode/jode/expr/LocalVarOperator.java.in
  3. 3
      jode/jode/expr/StoreInstruction.java

@ -73,6 +73,29 @@ public class ConstOperator extends NoArgOperator {
return value;
}
/**
* Return true, if this value is a one of the given type.
* This is used for ++ and -- instructions.
* @param type the type for which this must be a one. This may
* be different from the type this value actually is.
*/
public boolean isOne(Type type) {
if (type instanceof IntegerType) {
return (value instanceof Integer
&& ((Integer)value).intValue() == 1);
} else if (type == Type.tLong) {
return (value instanceof Long
&& ((Integer)value).longValue() == 1L);
} else if (type == Type.tFloat) {
return (value instanceof Float
&& ((Integer)value).floatValue() == 1.0f);
} else if (type == Type.tDouble) {
return (value instanceof Double
&& ((Integer)value).doubleValue() == 1.0);
}
return false;
}
public int getPriority() {
return 1000;
}

@ -1,4 +1,4 @@
/* LocalOperator Copyright (C) 1998-1999 Jochen Hoenicke.
/* LocalVarOperator Copyright (C) 1998-1999 Jochen Hoenicke.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,6 +23,8 @@ import jode.type.Type;
import jode.decompiler.LocalInfo;
import jode.decompiler.TabbedPrintWriter;
import @COLLECTIONS@.Collection;
public abstract class LocalVarOperator extends Operator {
LocalInfo local;
@ -47,6 +49,11 @@ public abstract class LocalVarOperator extends Operator {
updateParentType(local.getType());
}
public void fillDeclarables(Collection used) {
used.add(local);
super.fillDeclarables(used);
}
public LocalInfo getLocalInfo() {
return local.getLocalInfo();
}

@ -90,8 +90,7 @@ public class StoreInstruction extends Operator
if ((getOperatorIndex() == OPASSIGN_OP+ADD_OP ||
getOperatorIndex() == OPASSIGN_OP+SUB_OP)
&& one.getValue() instanceof Number
&& ((Number)one.getValue()).doubleValue() == 1.0) {
&& one.isOne(subExpressions[0].getType())) {
int op = (getOperatorIndex() == OPASSIGN_OP+ADD_OP)
? INC_OP : DEC_OP;

Loading…
Cancel
Save