private IEnumerator SetValues(IGraphRunner graph, IVariableDictionary variables, int iteration, Variable item)
 {
     if (Index.IsValid)
     {
         Index.Execute(variables);                 // Variable.Int(iteration)
     }
     if (Value.IsValid)
     {
         Value.Execute(variables);                 // item
     }
     yield return(graph.Run(Loop, variables, nameof(Loop)));
 }
Exemple #2
0
        public void TestAssignmentStatement()
        {
            ExecutionEnvironment e = new ExecutionEnvironment();

            e.RegisterValue("a", 5);
            Identifier i = new Identifier();

            i.Variable = "a";
            AssignmentExpression s = new AssignmentExpression();

            s.Left = i;
            Literal l = new Literal()
            {
                Raw = "7"
            };

            s.Right = l;
            var c = s.Execute(e);

            Assert.AreEqual(c.ReturnValue, 7);
            e.RegisterValue("c", 5);
            var dd = new AssignmentExpression()
            {
                Left = new Identifier()
                {
                    Variable = "c"
                }, Right = new BinaryExpression()
                {
                    Left = new Identifier()
                    {
                        Variable = "c"
                    }, Operator = Operator.Add, Right = new Literal()
                    {
                        Raw = "2"
                    }
                }
            };
            var cx = dd.Execute(e);

            Assert.AreEqual(cx.ReturnValue, 7);
        }