simplify expressions before printing them

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@56 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 27 years ago
parent 1915c9f8f4
commit 7be8903482
  1. 2
      jode/jode/flow/ConditionalBlock.java
  2. 1
      jode/jode/flow/FlowBlock.java
  3. 3
      jode/jode/flow/IfThenElseBlock.java
  4. 4
      jode/jode/flow/InstructionBlock.java
  5. 10
      jode/jode/flow/LoopBlock.java
  6. 3
      jode/jode/flow/ReturnBlock.java
  7. 2
      jode/jode/flow/SwitchBlock.java
  8. 3
      jode/jode/flow/ThrowBlock.java

@ -76,7 +76,7 @@ public class ConditionalBlock extends InstructionContainer {
public void dumpInstruction(TabbedPrintWriter writer)
throws java.io.IOException
{
writer.println("IF ("+instr.toString()+")");
writer.println("IF ("+instr.simplify().toString()+")");
writer.tab();
trueBlock.dumpSource(writer);
writer.untab();

@ -1013,7 +1013,6 @@ public class FlowBlock {
new CombineIfGotoExpressions(),
new CreateIfThenElseOperator(),
new CreateConstantArray(),
new SimplifyExpression()
};

@ -97,7 +97,8 @@ public class IfThenElseBlock extends StructuredBlock {
throws java.io.IOException
{
boolean needBrace = thenBlock.needsBraces();
writer.println("if ("+cond.toString()+")"+(needBrace?" {":""));
writer.println("if ("+cond.simplify().toString()+")"
+(needBrace?" {":""));
writer.tab();
thenBlock.dumpSource(writer);
writer.untab();

@ -70,11 +70,11 @@ public class InstructionBlock extends InstructionContainer {
writer.println
(((LocalStoreOperator) ((Expression)instr).getOperator())
.getLocalInfo().getType().toString()/*XXX*/
+ " " + instr.toString() + ";");
+ " " + instr.simplify().toString() + ";");
} else {
if (instr.getType() != Type.tVoid)
writer.print("push ");
writer.println(instr.toString()+";");
writer.println(instr.simplify().toString()+";");
}
}
}

@ -135,14 +135,16 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
boolean needBrace = bodyBlock.needsBraces();
switch (type) {
case WHILE:
writer.print("while ("+cond.toString()+")");
writer.print("while ("+cond.simplify().toString()+")");
break;
case DOWHILE:
writer.print("do");
break;
case FOR:
writer.print("for ("+(init != null ? init.toString() : "") +
"; "+cond.toString()+"; "+incr.toString()+")");
writer.print("for ("
+(init != null ? init.simplify().toString() : "")
+"; "+cond.simplify().toString()+"; "
+incr.simplify().toString()+")");
break;
}
writer.println( needBrace?" {": "");
@ -151,7 +153,7 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
writer.untab();
if (type == DOWHILE)
writer.println((needBrace?"} ": "")+
"while ("+cond.toString()+")");
"while ("+cond.simplify().toString()+")");
else if (needBrace)
writer.println("}");
}

@ -61,6 +61,7 @@ public class ReturnBlock extends InstructionContainer {
public void dumpInstruction(TabbedPrintWriter writer)
throws java.io.IOException
{
writer.println("return" + (instr == null ? "" : " " + instr) + ";");
writer.println("return" +
(instr == null ? "" : " " + instr.simplify()) + ";");
}
}

@ -133,7 +133,7 @@ implements BreakableBlock {
writer.println(label+":");
writer.tab();
}
writer.println("switch ("+instr+") {");
writer.println("switch ("+instr.simplify()+") {");
for (int i=0; i < caseBlocks.length; i++)
caseBlocks[i].dumpSource(writer);
writer.println("}");

@ -32,6 +32,7 @@ public class ThrowBlock extends InstructionContainer {
public void dumpInstruction(TabbedPrintWriter writer)
throws java.io.IOException
{
writer.println("throw" + (instr == null ? "" : " " + instr) + ";");
writer.println("throw" +
(instr == null ? "" : " " + instr.simplify()) + ";");
}
}

Loading…
Cancel
Save