Beispiel #1
0
 private bool ModifyInitialAssigment(IncrementedUse use)
 {
     if (ctx.InitialStatement == null)
     {
         return(false);
     }
     if (!(ctx.InitialStatement.Instruction is Assignment ass))
     {
         return(false);
     }
     if (ass.Src is Constant c)
     {
         ass.Src = Operator.IAdd.ApplyConstants(c, use.Increment);
     }
     else
     {
         // Change expression d = x to d = x + c.
         ass.Src = new BinaryExpression(
             Operator.IAdd,
             ass.Src.DataType,
             ass.Src,
             use.Increment);
     }
     return(true);
 }
Beispiel #2
0
 private void ModifyTest(LinearInductionVariableContext ctx, IncrementedUse use)
 {
     if (ctx.TestStatement == null)
     {
         return;
     }
     if (ctx.TestStatement.Instruction is Branch branch &&
         branch.Condition is BinaryExpression exp &&
         exp.Right is Constant c)
     {
         exp.Right = Operator.ISub.ApplyConstants(c, use.Increment);
     }
 }
Beispiel #3
0
 private void ModifyTest(LinearInductionVariableContext ctx, IncrementedUse use)
 {
     if (ctx.TestStatement == null)
         return;
     Branch branch;
     BinaryExpression exp ;
     Constant c ;
     if (ctx.TestStatement.Instruction.As(out branch) &&
         branch.Condition.As(out exp) &&
         exp.Right.As(out c))
     {
         exp.Right = Operator.ISub.ApplyConstants(c, use.Increment);
     }
 }
Beispiel #4
0
        public void ModifyUses()
        {
            if (incrUses.Count != 1)
            {
                return;
            }
            IncrementedUse use = incrUses[0];

            if (ModifyInitialAssigment(use))
            {
                use.Expression.Right = Constant.Create(use.Increment.DataType, 0);
                ModifyTest(ctx, use);
                liv.AddIncrement(use.Increment);
            }
        }
Beispiel #5
0
 private bool ModifyInitialAssigment(IncrementedUse use)
 {
     if (ctx.InitialStatement == null)
         return false;
     Assignment ass = ctx.InitialStatement.Instruction as Assignment;
     if (ass == null)
         return false;
     Constant c = ass.Src as Constant;
     if (c != null)
     {
         ass.Src = Operator.IAdd.ApplyConstants(c, use.Increment);
     }
     else
     {
         // Change expression d = x to d = x + c.
         ass.Src = new BinaryExpression(
             Operator.IAdd,
             ass.Src.DataType,
             ass.Src,
             use.Increment);
     }
     return true;
 }