public Expression GetValue() { return(Branch.AsExpression(m_r)); }
public override Operation Process(Decompiler d) { if (m_empty) { var expr = m_r.GetExpression(Branch.SetTarget, End); Branch.UseExpression(expr); return(new RegisterSet(End - 1, Branch.SetTarget, Branch.AsExpression(m_r))); } else if (m_assign != null) { Branch.UseExpression(m_assign.GetFirstValue()); var target = m_assign.GetFirstTarget(); var value = GetValue(); return(new LambdaOperation(End - 1, (r, block) => { return new Assignment(target, value); })); } else { return(new LambdaOperation(End - 1, (r, block) => { Expression expr = null; var register = 0; for (; register < r.NumRegisters; register++) { if (r.GetUpdated(register, Branch.End - 1) == Branch.End - 1) { expr = r.GetValue(register, Branch.End); break; } } if (d.Code.Op(Branch.End - 2) == Op.LOADBOOL && d.Code.C(Branch.End - 2) != 0) { var target = d.Code.A(Branch.End - 2); if (d.Code.Op(Branch.End - 3) == Op.JMP && d.Code.sBx(Branch.End - 3) == 2) { expr = r.GetValue(target, Branch.End - 2); } else { expr = r.GetValue(target, Branch.Begin); } Branch.UseExpression(expr); if (r.IsLocal(target, Branch.End - 1)) { return new Assignment(r.GetTarget(target, Branch.End - 1), Branch.AsExpression(r)); } r.SetValue(target, Branch.End - 1, Branch.AsExpression(r)); } else if (expr != null && Target >= 0) { Branch.UseExpression(expr); if (r.IsLocal(Target, Branch.End - 1)) { return new Assignment(r.GetTarget(Target, Branch.End - 1), Branch.AsExpression(r)); } r.SetValue(Target, Branch.End - 1, Branch.AsExpression(r)); } else { Console.WriteLine("-- fail " + (Branch.End - 1)); Console.WriteLine(expr); Console.WriteLine(Target); } return null; })); } }
public void UseAssignment(Assignment assignment) { m_assign = assignment; Branch.UseExpression(assignment.GetFirstValue()); }