|
|
@ -147,7 +147,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
Instruction pred; |
|
|
|
Instruction pred; |
|
|
|
try { |
|
|
|
try { |
|
|
|
NopOperator op = (NopOperator) ih.getInstruction(); |
|
|
|
NopOperator op = (NopOperator) ih.getInstruction(); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
pred = ih.getInstruction(); |
|
|
|
pred = ih.getInstruction(); |
|
|
|
if (pred == null) |
|
|
|
if (pred == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -168,19 +168,19 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
if (ih.getInstruction() instanceof DupOperator) |
|
|
|
if (ih.getInstruction() instanceof DupOperator) |
|
|
|
/* this is not the end of the array assign */ |
|
|
|
/* this is not the end of the array assign */ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
ArrayStoreOperator store = |
|
|
|
ArrayStoreOperator store = |
|
|
|
(ArrayStoreOperator) ih.getInstruction(); |
|
|
|
(ArrayStoreOperator) ih.getInstruction(); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
Expression lastconst = (Expression) ih.getInstruction(); |
|
|
|
Expression lastconst = (Expression) ih.getInstruction(); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
Expression lastindexexpr = (Expression) ih.getInstruction(); |
|
|
|
Expression lastindexexpr = (Expression) ih.getInstruction(); |
|
|
|
ConstOperator lastindexop = |
|
|
|
ConstOperator lastindexop = |
|
|
|
(ConstOperator) lastindexexpr.getOperator(); |
|
|
|
(ConstOperator) lastindexexpr.getOperator(); |
|
|
|
if (!MyType.isOfType(lastindexop.getType(), MyType.tUInt)) |
|
|
|
if (!MyType.isOfType(lastindexop.getType(), MyType.tInt)) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
int lastindex = Integer.parseInt(lastindexop.getValue()); |
|
|
|
int lastindex = Integer.parseInt(lastindexop.getValue()); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
if (dup.getDepth() != 0 || |
|
|
|
if (dup.getDepth() != 0 || |
|
|
|
dup.getCount() != store.getLValueType().stackSize()) |
|
|
|
dup.getCount() != store.getLValueType().stackSize()) |
|
|
@ -189,12 +189,12 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
consts[lastindex] = lastconst; |
|
|
|
consts[lastindex] = lastconst; |
|
|
|
count = 1; |
|
|
|
count = 1; |
|
|
|
while (lastindex-- > 0) { |
|
|
|
while (lastindex-- > 0) { |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
ArrayStoreOperator store2 = |
|
|
|
ArrayStoreOperator store2 = |
|
|
|
(ArrayStoreOperator) ih.getInstruction(); |
|
|
|
(ArrayStoreOperator) ih.getInstruction(); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
lastconst = (Expression) ih.getInstruction(); |
|
|
|
lastconst = (Expression) ih.getInstruction(); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
Expression indexexpr = (Expression) ih.getInstruction(); |
|
|
|
Expression indexexpr = (Expression) ih.getInstruction(); |
|
|
|
ConstOperator indexop = |
|
|
|
ConstOperator indexop = |
|
|
|
(ConstOperator) indexexpr.getOperator(); |
|
|
|
(ConstOperator) indexexpr.getOperator(); |
|
|
@ -210,14 +210,14 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
lastindex--; |
|
|
|
lastindex--; |
|
|
|
} |
|
|
|
} |
|
|
|
consts[lastindex] = lastconst; |
|
|
|
consts[lastindex] = lastconst; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
dup = (DupOperator) ih.getInstruction(); |
|
|
|
dup = (DupOperator) ih.getInstruction(); |
|
|
|
if (dup.getDepth() != 0 || |
|
|
|
if (dup.getDepth() != 0 || |
|
|
|
dup.getCount() != store.getLValueType().stackSize()) |
|
|
|
dup.getCount() != store.getLValueType().stackSize()) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
count++; |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
Expression newArrayExpr = (Expression) ih.getInstruction(); |
|
|
|
Expression newArrayExpr = (Expression) ih.getInstruction(); |
|
|
|
NewArrayOperator newArrayOp = |
|
|
|
NewArrayOperator newArrayOp = |
|
|
|
(NewArrayOperator) newArrayExpr.getOperator(); |
|
|
|
(NewArrayOperator) newArrayExpr.getOperator(); |
|
|
@ -245,15 +245,13 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
public InstructionHeader createExpression(InstructionHeader ih) { |
|
|
|
public InstructionHeader createExpression(InstructionHeader ih) { |
|
|
|
Operator op; |
|
|
|
Operator op; |
|
|
|
Expression exprs[]; |
|
|
|
Expression exprs[]; |
|
|
|
int count; |
|
|
|
int params; |
|
|
|
try { |
|
|
|
try { |
|
|
|
op = (Operator) ih.getInstruction(); |
|
|
|
op = (Operator) ih.getInstruction(); |
|
|
|
int params = op.getOperandCount(); |
|
|
|
params = op.getOperandCount(); |
|
|
|
exprs = new Expression[params]; |
|
|
|
exprs = new Expression[params]; |
|
|
|
count = 1; |
|
|
|
|
|
|
|
for (int i = params-1; i>=0; i--) { |
|
|
|
for (int i = params-1; i>=0; i--) { |
|
|
|
count++; |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
|
|
|
|
exprs[i] = (Expression) ih.getInstruction(); |
|
|
|
exprs[i] = (Expression) ih.getInstruction(); |
|
|
|
if (exprs[i].isVoid()) { |
|
|
|
if (exprs[i].isVoid()) { |
|
|
|
if (i == params-1) |
|
|
|
if (i == params-1) |
|
|
@ -263,6 +261,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
i++; |
|
|
|
i++; |
|
|
|
exprs[i] = e; |
|
|
|
exprs[i] = e; |
|
|
|
|
|
|
|
ih.combine(2, e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (NullPointerException ex) { |
|
|
|
} catch (NullPointerException ex) { |
|
|
@ -270,7 +269,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
} catch (ClassCastException ex) { |
|
|
|
} catch (ClassCastException ex) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
ih.combine(count, new Expression(op, exprs)); |
|
|
|
ih.combine(params+1, new Expression(op, exprs)); |
|
|
|
return ih; |
|
|
|
return ih; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -303,7 +302,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
StoreInstruction store; |
|
|
|
StoreInstruction store; |
|
|
|
try { |
|
|
|
try { |
|
|
|
store = (StoreInstruction) ih.getInstruction(); |
|
|
|
store = (StoreInstruction) ih.getInstruction(); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
|
|
|
|
|
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
if (dup.getDepth() != store.getLValueOperandCount() && |
|
|
|
if (dup.getDepth() != store.getLValueOperandCount() && |
|
|
@ -337,7 +336,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
if (iinc.getValue().equals("-1")) |
|
|
|
if (iinc.getValue().equals("-1")) |
|
|
|
op ^= 1; |
|
|
|
op ^= 1; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
Expression loadExpr = (Expression) ih.getInstruction(); |
|
|
|
Expression loadExpr = (Expression) ih.getInstruction(); |
|
|
|
LocalLoadOperator load = |
|
|
|
LocalLoadOperator load = |
|
|
|
(LocalLoadOperator)loadExpr.getOperator(); |
|
|
|
(LocalLoadOperator)loadExpr.getOperator(); |
|
|
@ -363,7 +362,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
store = (StoreInstruction) ih.getInstruction(); |
|
|
|
store = (StoreInstruction) ih.getInstruction(); |
|
|
|
if (store.getLValueOperandCount() == 0) |
|
|
|
if (store.getLValueOperandCount() == 0) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
BinaryOperator binOp = (BinaryOperator) ih.getInstruction(); |
|
|
|
BinaryOperator binOp = (BinaryOperator) ih.getInstruction(); |
|
|
|
if (binOp.getOperator() == store.ADD_OP) |
|
|
|
if (binOp.getOperator() == store.ADD_OP) |
|
|
|
op = Operator.INC_OP; |
|
|
|
op = Operator.INC_OP; |
|
|
@ -371,7 +370,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
op = Operator.DEC_OP; |
|
|
|
op = Operator.DEC_OP; |
|
|
|
else |
|
|
|
else |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
Expression expr = (Expression) ih.getInstruction(); |
|
|
|
Expression expr = (Expression) ih.getInstruction(); |
|
|
|
ConstOperator constOp = (ConstOperator) expr.getOperator(); |
|
|
|
ConstOperator constOp = (ConstOperator) expr.getOperator(); |
|
|
|
if (!constOp.getValue().equals("1") && |
|
|
|
if (!constOp.getValue().equals("1") && |
|
|
@ -379,18 +378,18 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
if (constOp.getValue().equals("-1")) |
|
|
|
if (constOp.getValue().equals("-1")) |
|
|
|
op ^= 1; |
|
|
|
op ^= 1; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
if (dup.getCount() != store.getLValueType().stackSize() || |
|
|
|
if (dup.getCount() != store.getLValueType().stackSize() || |
|
|
|
dup.getDepth() != store.getLValueOperandCount()) |
|
|
|
dup.getDepth() != store.getLValueOperandCount()) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
Operator load = (Operator) ih.getInstruction(); |
|
|
|
Operator load = (Operator) ih.getInstruction(); |
|
|
|
|
|
|
|
|
|
|
|
if (!store.matches(load)) |
|
|
|
if (!store.matches(load)) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
DupOperator dup2 = (DupOperator) ih.getInstruction(); |
|
|
|
DupOperator dup2 = (DupOperator) ih.getInstruction(); |
|
|
|
if (dup2.getCount() != store.getLValueOperandCount() || |
|
|
|
if (dup2.getCount() != store.getLValueOperandCount() || |
|
|
|
dup2.getDepth() != 0) |
|
|
|
dup2.getDepth() != 0) |
|
|
@ -413,20 +412,20 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
BinaryOperator binop; |
|
|
|
BinaryOperator binop; |
|
|
|
try { |
|
|
|
try { |
|
|
|
store = (StoreInstruction) ih.getInstruction(); |
|
|
|
store = (StoreInstruction) ih.getInstruction(); |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
binop = (BinaryOperator) ih.getInstruction(); |
|
|
|
binop = (BinaryOperator) ih.getInstruction(); |
|
|
|
if (binop.getOperator() < binop.ADD_OP || |
|
|
|
if (binop.getOperator() < binop.ADD_OP || |
|
|
|
binop.getOperator() >= binop.ASSIGN_OP) |
|
|
|
binop.getOperator() >= binop.ASSIGN_OP) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
rightHandSide = (Expression) ih.getInstruction(); |
|
|
|
rightHandSide = (Expression) ih.getInstruction(); |
|
|
|
if (rightHandSide.isVoid()) |
|
|
|
if (rightHandSide.isVoid()) |
|
|
|
return null; /* XXX */ |
|
|
|
return null; /* XXX */ |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
Operator load = (Operator) ih.getInstruction(); |
|
|
|
Operator load = (Operator) ih.getInstruction(); |
|
|
|
if (!store.matches(load)) |
|
|
|
if (!store.matches(load)) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
if (dup.getDepth() != 0 && |
|
|
|
if (dup.getDepth() != 0 && |
|
|
|
dup.getCount() != store.getLValueOperandCount()) |
|
|
|
dup.getCount() != store.getLValueOperandCount()) |
|
|
@ -455,16 +454,16 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
int params = constrCall.getOperandCount(); |
|
|
|
int params = constrCall.getOperandCount(); |
|
|
|
exprs = new Expression[params]; |
|
|
|
exprs = new Expression[params]; |
|
|
|
for (int i = params-1; i>0; i--) { |
|
|
|
for (int i = params-1; i>0; i--) { |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
exprs[i] = (Expression) ih.getInstruction(); |
|
|
|
exprs[i] = (Expression) ih.getInstruction(); |
|
|
|
if (exprs[i].isVoid()) |
|
|
|
if (exprs[i].isVoid()) |
|
|
|
return null; /* XXX */ |
|
|
|
return null; /* XXX */ |
|
|
|
} |
|
|
|
} |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
DupOperator dup = (DupOperator) ih.getInstruction(); |
|
|
|
if (dup.getCount() != 1 && dup.getDepth() != 0) |
|
|
|
if (dup.getCount() != 1 && dup.getDepth() != 0) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
ih = ih.getSimpleUniquePredecessor(); |
|
|
|
exprs[0] = (Expression) ih.getInstruction(); |
|
|
|
exprs[0] = (Expression) ih.getInstruction(); |
|
|
|
if (exprs[0].isVoid()) |
|
|
|
if (exprs[0].isVoid()) |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -493,7 +492,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
InstructionHeader[] dests2 = ih2.getSuccessors(); |
|
|
|
InstructionHeader[] dests2 = ih2.getSuccessors(); |
|
|
|
|
|
|
|
|
|
|
|
/* if ih2.getUniquePredecessor.getOperator().isVoid() XXX */ |
|
|
|
/* if ih2.getSimpleUniquePredecessor.getOperator().isVoid() XXX */ |
|
|
|
|
|
|
|
|
|
|
|
Vector predec = ih2.getPredecessors(); |
|
|
|
Vector predec = ih2.getPredecessors(); |
|
|
|
if (predec.size() != 1) |
|
|
|
if (predec.size() != 1) |
|
|
@ -510,12 +509,12 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
e = new Expression[2]; |
|
|
|
e = new Expression[2]; |
|
|
|
operator = Operator.LOG_AND_OP; |
|
|
|
operator = Operator.LOG_AND_OP; |
|
|
|
e[1] = (Expression)ih2.getInstruction(); |
|
|
|
e[1] = (Expression)ih2.getInstruction(); |
|
|
|
e[0] = ((Expression)ih2.getInstruction()).negate(); |
|
|
|
e[0] = ((Expression)ih1.getInstruction()).negate(); |
|
|
|
} else if (dests1[1] == dests2[1]) { |
|
|
|
} else if (dests1[1] == dests2[1]) { |
|
|
|
e = new Expression[2]; |
|
|
|
e = new Expression[2]; |
|
|
|
operator = Operator.LOG_OR_OP; |
|
|
|
operator = Operator.LOG_OR_OP; |
|
|
|
e[1] = (Expression)ih2.getInstruction(); |
|
|
|
e[1] = (Expression)ih2.getInstruction(); |
|
|
|
e[0] = (Expression)ih2.getInstruction(); |
|
|
|
e[0] = (Expression)ih1.getInstruction(); |
|
|
|
} else |
|
|
|
} else |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} catch (ClassCastException ex) { |
|
|
|
} catch (ClassCastException ex) { |
|
|
@ -531,6 +530,64 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
return ih1; |
|
|
|
return ih1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public InstructionHeader createFunnyIfThenElseOp(InstructionHeader ih) { |
|
|
|
|
|
|
|
Expression cond = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
InstructionHeader ifHeader= ih; |
|
|
|
|
|
|
|
if (ifHeader.switchType != MyType.tBoolean) |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
CompareUnaryOperator compare = |
|
|
|
|
|
|
|
(CompareUnaryOperator) ifHeader.getInstruction(); |
|
|
|
|
|
|
|
if ((compare.getOperator() & ~1) != compare.EQUALS_OP) |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
Enumeration enum = ih.getPredecessors().elements(); |
|
|
|
|
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
ih = (InstructionHeader) enum.nextElement(); |
|
|
|
|
|
|
|
Expression zeroExpr = (Expression) ih.getInstruction(); |
|
|
|
|
|
|
|
ConstOperator zero = |
|
|
|
|
|
|
|
(ConstOperator) zeroExpr.getOperator(); |
|
|
|
|
|
|
|
if (!zero.getValue().equals("0")) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ih = ih.getUniquePredecessor(); |
|
|
|
|
|
|
|
if (ih.switchType != MyType.tBoolean) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (compare.getOperator() == compare.EQUALS_OP && |
|
|
|
|
|
|
|
ih.getSuccessors()[1] != ifHeader.getSuccessors()[0] |
|
|
|
|
|
|
|
|| compare.getOperator() == compare.NOTEQUALS_OP && |
|
|
|
|
|
|
|
ih.getSuccessors()[1] != ifHeader.getSuccessors()[1]) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cond = (Expression) ih.getInstruction(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} catch (ClassCastException ex) { |
|
|
|
|
|
|
|
} catch (NullPointerException ex) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cond == null) |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ClassCastException ex) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} catch (NullPointerException ex) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InstructionHeader next = ih.nextInstruction; |
|
|
|
|
|
|
|
ih.nextInstruction = next.nextInstruction; |
|
|
|
|
|
|
|
ih.successors[1].predecessors.removeElement(ih); |
|
|
|
|
|
|
|
ih.switchType = MyType.tVoid; |
|
|
|
|
|
|
|
ih.successors = next.successors; |
|
|
|
|
|
|
|
ih.successors[0].predecessors.removeElement(next); |
|
|
|
|
|
|
|
ih.successors[0].predecessors.addElement(ih); |
|
|
|
|
|
|
|
ih.succs = next.succs; |
|
|
|
|
|
|
|
ih.length += next.length; |
|
|
|
|
|
|
|
return ih; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public InstructionHeader createIfThenElseOperator(InstructionHeader ih) { |
|
|
|
public InstructionHeader createIfThenElseOperator(InstructionHeader ih) { |
|
|
|
InstructionHeader ifHeader; |
|
|
|
InstructionHeader ifHeader; |
|
|
|
Expression e[] = new Expression[3]; |
|
|
|
Expression e[] = new Expression[3]; |
|
|
@ -551,7 +608,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
succs[0].getSuccessors()[0] != succs[1].getSuccessors()[0]) |
|
|
|
succs[0].getSuccessors()[0] != succs[1].getSuccessors()[0]) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
e[0] = (Expression) ifHeader.getInstruction(); |
|
|
|
e[0] = ((Expression) ifHeader.getInstruction()).negate(); |
|
|
|
e[1] = (Expression) succs[0].getInstruction(); |
|
|
|
e[1] = (Expression) succs[0].getInstruction(); |
|
|
|
e[2] = (Expression) succs[1].getInstruction(); |
|
|
|
e[2] = (Expression) succs[1].getInstruction(); |
|
|
|
} catch (ClassCastException ex) { |
|
|
|
} catch (ClassCastException ex) { |
|
|
@ -563,11 +620,13 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
(MyType.intersection(e[1].getType(),e[2].getType())); |
|
|
|
(MyType.intersection(e[1].getType(),e[2].getType())); |
|
|
|
ifHeader.instr = new Expression(iteo, e); |
|
|
|
ifHeader.instr = new Expression(iteo, e); |
|
|
|
ifHeader.nextInstruction = ih.nextInstruction; |
|
|
|
ifHeader.nextInstruction = ih.nextInstruction; |
|
|
|
|
|
|
|
ifHeader.length = ih.addr + ih.length - ifHeader.addr; |
|
|
|
|
|
|
|
ifHeader.succs = ih.succs; |
|
|
|
ifHeader.successors = ih.successors; |
|
|
|
ifHeader.successors = ih.successors; |
|
|
|
ifHeader.switchType = Type.tVoid; |
|
|
|
ifHeader.switchType = Type.tVoid; |
|
|
|
ifHeader.nextInstruction.predecessors.removeElement(succs[0]); |
|
|
|
ifHeader.successors[0].predecessors.removeElement(succs[0]); |
|
|
|
ifHeader.nextInstruction.predecessors.removeElement(succs[1]); |
|
|
|
ifHeader.successors[0].predecessors.removeElement(succs[1]); |
|
|
|
ifHeader.nextInstruction.predecessors.addElement(ifHeader); |
|
|
|
ifHeader.successors[0].predecessors.addElement(ifHeader); |
|
|
|
return ifHeader; |
|
|
|
return ifHeader; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -578,6 +637,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
ih = next) { |
|
|
|
ih = next) { |
|
|
|
if (env.isVerbose) |
|
|
|
if (env.isVerbose) |
|
|
|
System.err.print("."); |
|
|
|
System.err.print("."); |
|
|
|
|
|
|
|
// System.err.println(""+ih.getAddress());
|
|
|
|
if ((next = removeNop(ih)) != null) continue; |
|
|
|
if ((next = removeNop(ih)) != null) continue; |
|
|
|
if ((next = createExpression(ih)) != null) continue; |
|
|
|
if ((next = createExpression(ih)) != null) continue; |
|
|
|
if ((next = createPostIncExpression(ih)) != null) continue; |
|
|
|
if ((next = createPostIncExpression(ih)) != null) continue; |
|
|
@ -585,6 +645,7 @@ public class CodeAnalyzer implements Analyzer, Constants { |
|
|
|
if ((next = createAssignOp(ih)) != null) continue; |
|
|
|
if ((next = createAssignOp(ih)) != null) continue; |
|
|
|
if ((next = combineNewConstructor(ih)) != null) continue; |
|
|
|
if ((next = combineNewConstructor(ih)) != null) continue; |
|
|
|
if ((next = combineIfGotoExpressions(ih)) != null) continue; |
|
|
|
if ((next = combineIfGotoExpressions(ih)) != null) continue; |
|
|
|
|
|
|
|
if ((next = createFunnyIfThenElseOp(ih)) != null) continue; |
|
|
|
if ((next = createIfThenElseOperator(ih)) != null) continue; |
|
|
|
if ((next = createIfThenElseOperator(ih)) != null) continue; |
|
|
|
if ((next = createAssignExpression(ih)) != null) continue; |
|
|
|
if ((next = createAssignExpression(ih)) != null) continue; |
|
|
|
if ((next = createConstantArray(ih)) != null) continue; |
|
|
|
if ((next = createConstantArray(ih)) != null) continue; |
|
|
|