Exemplo n.º 1
0
        public static Field RunSequence(Runner runner, Node block)
        {
            if (block.Count < 1)
            {
                throw new ArgumentException();
            }
            Field result = default;

            foreach (var child in block)
            {
                result = runner.Eval(child);
                var field = runner.GetFieldOrInit(Convert.ToString(child));
                if (field.FieldType == FieldType.BuiltInFunction &&
                    field.Value == index["return"])
                {
                    return(result);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public static Field SetValue(Runner runner, Node block)
        {
            if (block.Count < 2)
            {
                throw new ArgumentException();
            }
            var tag = Convert.ToString(block[0]);

            if (block.Count == 2)
            {
                return(runner.SetField(tag, runner.Eval(block[1])));
            }
            Field field = runner.GetFieldOrInit(tag, FieldType.Object);

            for (int i = 1, l = block.Count - 2; i < l; i++)
            {
                field = field.GetAndEnsureType(runner.Eval(block[i]), FieldType.Object);
            }
            return(field[runner.Eval(block[block.Count - 2])] =
                       runner.Eval(block[block.Count - 1]));
        }