public override void Print(Output output) { output.Print("for "); m_r.GetTarget(m_register + 3, Begin - 1).Print(output); output.Print(" = "); m_r.GetValue(m_register, Begin - 1).Print(output); output.Print(", "); m_r.GetValue(m_register + 1, Begin - 1).Print(output); var step = m_r.GetValue(m_register + 2, Begin - 1); if (!step.IsInteger || step.AsInteger() != 1) { output.Print(", "); step.Print(output); } output.Print(" do"); output.PrintLine(); output.IncreaseIndent(); Statement.PrintSequence(output, m_statements); output.DecreaseIndent(); output.Print("end"); }
public override void Print(Output output) { output.Print("for "); m_r.GetTarget(m_register + 3, Begin - 1).Print(output); var n = m_register + 2 + m_length; for (int r1 = m_register + 4; r1 <= n; r1++) { output.Print(", "); m_r.GetTarget(r1, Begin - 1).Print(output); } output.Print(" in "); Expression value = null; value = m_r.GetValue(m_register, Begin - 1); value.Print(output); // TODO: Optimize code if (!value.IsMultiple) { output.Print(", "); value = m_r.GetValue(m_register + 1, Begin - 1); value.Print(output); if (!value.IsMultiple) { output.Print(", "); value = m_r.GetValue(m_register + 2, Begin - 1); value.Print(output); } } output.Print(" do"); output.PrintLine(); output.IncreaseIndent(); Statement.PrintSequence(output, m_statements); output.DecreaseIndent(); output.Print("end"); }
public override Operation Process(Decompiler d) { if (m_statements.Count == 1) { var statement = m_statements[0]; if (statement is Assignment) { var assignment = statement as Assignment; if (assignment.GetArity() == 1) { if (m_branch is TestNode) { var node = m_branch as TestNode; var decl = m_r.GetDeclaration(node.Test, node.Line); if (assignment.GetFirstTarget().IsDeclaration(decl)) { var left = new LocalVariable(decl); var right = assignment.GetFirstValue(); var expr = (node.Inverted) ? Expression.MakeOR(left, right) : Expression.MakeAND(left, right); return(new LambdaOperation(End - 1, (r, block) => { return new Assignment(assignment.GetFirstTarget(), expr); })); } } } } } else if (m_statements.Count == 0 && m_stack != null) { var test = m_branch.GetRegister(); if (test < 0) { for (int reg = 0; reg < m_r.NumRegisters; reg++) { if (m_r.GetUpdated(reg, m_branch.End - 1) >= m_branch.Begin) { if (test >= 0) { test = -1; break; } test = reg; } } } if (test >= 0) { if (m_r.GetUpdated(test, m_branch.End - 1) >= m_branch.Begin) { var right = m_r.GetValue(test, m_branch.End); var setb = d.PopSetCondition(m_stack, m_stack.Peek().End, test); setb.UseExpression(right); var testReg = test; return(new LambdaOperation(End - 1, (r, block) => { r.SetValue(testReg, m_branch.End - 1, setb.AsExpression(r)); return null; })); } } } return(base.Process(d)); }