simplify() now in extra method

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@637 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent d93672ba8a
commit eac030bc79
  1. 3
      jode/jode/flow/ConditionalBlock.java
  2. 7
      jode/jode/flow/IfThenElseBlock.java
  3. 6
      jode/jode/flow/InstructionContainer.java
  4. 19
      jode/jode/flow/LoopBlock.java
  5. 2
      jode/jode/flow/ReturnBlock.java
  6. 2
      jode/jode/flow/SwitchBlock.java
  7. 9
      jode/jode/flow/SynchronizedBlock.java

@ -122,7 +122,7 @@ public class ConditionalBlock extends InstructionContainer {
public void dumpInstruction(TabbedPrintWriter writer)
throws java.io.IOException
{
writer.println("IF ("+instr.simplify().toString()+")");
writer.println("IF ("+instr.toString()+")");
writer.tab();
trueBlock.dumpSource(writer);
writer.untab();
@ -135,3 +135,4 @@ public class ConditionalBlock extends InstructionContainer {
|| CreateIfThenElseOperator.createFunny(this, last);
}
}

@ -140,7 +140,7 @@ public class IfThenElseBlock extends StructuredBlock {
throws java.io.IOException
{
boolean needBrace = thenBlock.needsBraces();
writer.print("if ("+cond.simplify().toString()+")");
writer.print("if ("+cond.toString()+")");
if (needBrace)
writer.openBrace();
else
@ -194,6 +194,11 @@ public class IfThenElseBlock extends StructuredBlock {
&& (elseBlock.jump != null || elseBlock.jumpMayBeChanged());
}
public void simplify() {
cond = cond.simplify();
super.simplify();
}
public boolean doTransformations() {
StructuredBlock last = flowBlock.lastModified;
return CreateCheckNull.transformJikes(this, last)

@ -99,6 +99,12 @@ public abstract class InstructionContainer extends StructuredBlock {
return instr;
}
public void simplify() {
if (instr != null)
instr = instr.simplify();
super.simplify();
}
/**
* Set the contained instruction.
* @param instr the new instruction.

@ -246,7 +246,7 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
/* special syntax for endless loops: */
writer.print("for (;;)");
else
writer.print("while ("+cond.simplify().toString()+")");
writer.print("while ("+cond.toString()+")");
break;
case DOWHILE:
writer.print("do");
@ -259,11 +259,11 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
init.getInstruction().getOperator())
.getLocalInfo().getType().getHint()
+ " ");
writer.print(init.getInstruction().simplify().toString());
writer.print(init.getInstruction().toString());
} else
writer.print("/**/");
writer.print("; "+cond.simplify().toString()+"; "
+incr.getInstruction().simplify().toString()+")");
writer.print("; "+cond.toString()+"; "
+incr.getInstruction().toString()+")");
break;
}
if (needBrace)
@ -439,8 +439,19 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
return mayChangeJump;
}
public void simplify() {
cond = cond.simplify();
if (type == FOR) {
incr.simplify();
if (init != null)
init.simplify();
}
super.simplify();
}
public boolean doTransformations() {
return init == null && (type == FOR || type == POSSFOR)
&& CreateForInitializer.transform(this, flowBlock.lastModified);
}
}

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

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

@ -85,7 +85,7 @@ public class SynchronizedBlock extends StructuredBlock {
writer.println("MISSING MONITORENTER");
writer.print("synchronized ("
+ (object != null
? object.simplify().toString()
? object.toString()
: local.getName()) + ")");
writer.openBrace();
writer.tab();
@ -94,6 +94,13 @@ public class SynchronizedBlock extends StructuredBlock {
writer.closeBrace();
}
public void simplify() {
if (object != null)
object = object.simplify();
super.simplify();
}
public boolean doTransformations() {
StructuredBlock last = flowBlock.lastModified;
return (!isEntered && CompleteSynchronized.enter(this, last))

Loading…
Cancel
Save