protected override BaseExpression Visit(PostIncrement inc) { //Add(inc.Name); throw new NotImplementedException(); return(base.Visit(inc)); }
protected override IEnumerable <BaseStatement> Visit(PostIncrement inc) { var tmp = MkTmp(); return(new BaseStatement[] { // Save original value new Assignment(tmp, new Variable(inc.Name)), // Increment it in place new Assignment(inc.Name, new Increment(inc.Name)), // Return original value new Assignment(MkTmp(), new Variable(tmp)) }); }
public void TestPostIncrementStatement() { List <IInstruction> instructions = new List <IInstruction>(); instructions.Add(new Instruction(OpCodes.Ldarg, 0, (ushort)0)); instructions.Add(new Instruction(OpCodes.Ldc_I4, 1, 42)); instructions.Add(new Instruction(OpCodes.Add, 2, 1)); instructions.Add(new Instruction(OpCodes.Starg, 3, (ushort)0)); PostIncrement idiom = new PostIncrement(); idiom.Process(instructions, 0); Assert.AreEqual(2, instructions.Count); Assert.AreEqual(OpCodes.Ldarg.Value, instructions[0].OpCode.Value); Assert.AreEqual(OpCodeTable.PostIncrementStatementOpCode.Value, instructions[1].OpCode.Value); Assert.AreEqual(42, instructions[1].Argument); }
public virtual TResult Visit(BaseExpression expression) { return(expression switch { Phi a => Visit(a), Increment a => Visit(a), Decrement a => Visit(a), ErrorExpression a => Visit(a), Bracketed a => Visit(a), Abs a => Visit(a), Sqrt a => Visit(a), Sine a => Visit(a), Cosine a => Visit(a), Tangent a => Visit(a), ArcSine a => Visit(a), ArcCos a => Visit(a), ArcTan a => Visit(a), PostIncrement a => Visit(a), PreIncrement a => Visit(a), PostDecrement a => Visit(a), PreDecrement a => Visit(a), Add a => Visit(a), Subtract a => Visit(a), Multiply a => Visit(a), Divide a => Visit(a), Modulo a => Visit(a), Negate a => Visit(a), Exponent a => Visit(a), Or a => Visit(a), And a => Visit(a), Not a => Visit(a), Factorial a => Visit(a), Variable a => Visit(a), ConstantNumber a => Visit(a), ConstantString a => Visit(a), EqualTo a => Visit(a), NotEqualTo a => Visit(a), GreaterThan a => Visit(a), GreaterThanEqualTo a => Visit(a), LessThan a => Visit(a), LessThanEqualTo a => Visit(a), _ => VisitUnknown(expression) });
protected override bool Visit(PostIncrement inc) => throw new NotSupportedException();
protected override Type Visit(PostIncrement inc) => VariableRead(inc.Name);
[NotNull] protected abstract TResult Visit([NotNull] PostIncrement inc);
protected override BaseExpression Visit(PostIncrement inc) { _names.Add(inc.Name); return(base.Visit(inc)); }
protected override BaseExpression Visit(PostIncrement inc) { using (AppendLine($"{inc.Name}++")) return(inc); }
[NotNull] protected virtual BaseExpression Visit([NotNull] PostIncrement inc) { return(new PostIncrement(Visit(inc.Name))); }
protected override IDataFlowGraphExpressionNode Visit(PostIncrement inc) { throw new NotSupportedException("PostIncrement must be converted to Increment before data flow analysis"); }
protected override bool Visit(PostIncrement inc) => true;