public override Expression AsExpression(Registers registers) { var transpose = false; var leftExpr = registers.GetKExpression(m_left, Line); var rightExpr = registers.GetKExpression(m_right, Line); if (((m_left | m_right) & 256) == 0) { transpose = registers.GetUpdated(m_left, Line) > registers.GetUpdated(m_right, Line); } else { transpose = rightExpr.ConstantIndex < leftExpr.ConstantIndex; } var op = !transpose ? "<" : ">"; Expression rtn = new BinaryExpression(op, !transpose ? leftExpr : rightExpr, !transpose ? rightExpr : leftExpr, Expression.PRECEDENCE_COMPARE, Expression.ASSOCIATIVITY_LEFT); if (m_invert) { rtn = Expression.MakeNOT(rtn); } return(rtn); }
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)); }