instr.dumpExpression

printType


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@696 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent cf4c2b7032
commit 7bfa6f0a9d
  1. 52
      jode/jode/flow/LoopBlock.java

@ -208,24 +208,21 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
return new StructuredBlock[] { bodyBlock }; return new StructuredBlock[] { bodyBlock };
} }
public void dumpDeclaration(TabbedPrintWriter writer, LocalInfo local) /**
throws java.io.IOException * Make the declarations, i.e. initialize the declare variable
{ * to correct values. This will declare every variable that
if (type == FOR && init != null * is marked as used, but not done.
&& (init.getInstruction().getOperator() * @param done The set of the already declare variables.
instanceof LocalStoreOperator) */
&& (((LocalStoreOperator) public void makeDeclaration(VariableSet done) {
init.getInstruction().getOperator()).getLocalInfo() super.makeDeclaration(done);
== local.getLocalInfo())) if (type == FOR && init != null)
isDeclaration = true; init.checkDeclaration(declare);
else
super.dumpDeclaration(writer, local);
} }
public void dumpSource(TabbedPrintWriter writer) public void dumpSource(TabbedPrintWriter writer)
throws java.io.IOException throws java.io.IOException
{ {
isDeclaration = false;
super.dumpSource(writer); super.dumpSource(writer);
} }
@ -245,8 +242,11 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
if (cond == TRUE) if (cond == TRUE)
/* special syntax for endless loops: */ /* special syntax for endless loops: */
writer.print("for (;;)"); writer.print("for (;;)");
else else {
writer.print("while ("+cond.toString()+")"); writer.print("while (");
cond.dumpExpression(writer);
writer.print(")");
}
break; break;
case DOWHILE: case DOWHILE:
writer.print("do"); writer.print("do");
@ -254,16 +254,20 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
case FOR: case FOR:
writer.print("for ("); writer.print("for (");
if (init != null) { if (init != null) {
if (isDeclaration) if (init.isDeclaration) {
writer.print(((LocalStoreOperator) writer.printType(((LocalStoreOperator)
init.getInstruction().getOperator()) init.getInstruction().getOperator())
.getLocalInfo().getType().getHint() .getLocalInfo().getType().getHint());
+ " "); writer.print(" ");
writer.print(init.getInstruction().toString()); }
init.getInstruction().dumpExpression(writer);
} else } else
writer.print("/**/"); writer.print("/**/");
writer.print("; "+cond.toString()+"; " writer.print("; ");
+incr.getInstruction().toString()+")"); cond.dumpExpression(writer);
writer.print("; ");
incr.getInstruction().dumpExpression(writer);
writer.print(")");
break; break;
} }
if (needBrace) if (needBrace)
@ -276,7 +280,9 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
if (type == DOWHILE) { if (type == DOWHILE) {
if (needBrace) if (needBrace)
writer.closeBraceContinue(); writer.closeBraceContinue();
writer.println("while ("+cond.simplify().toString()+");"); writer.print("while (");
cond.dumpExpression(writer);
writer.println(");");
} else if (needBrace) } else if (needBrace)
writer.closeBrace(); writer.closeBrace();
} }

Loading…
Cancel
Save