Пример #1
0
        public Value Evaluate(ExecutionContext vm, LocalVariables lv)
        {
            var length = statements.Length;
            var result = new StringBuilder();

            for (var i = 0; i < length; i++)
            {
                if (Lexer.IsEvaluate(statements[i]))
                {
                    var expression = vm.Parser.MakeExpression(statements[i]);
                    result.Append(expression.Evaluate(vm, lv).ToString());
                }
                else
                {
                    result.Append(statements[i]);
                }
            }
            var   index = 0;
            Value value;
            var   name      = result.ToString();
            var   array     = Lexer.SplitArrayIndexer(name);
            var   statement = array[0].Substring(1);

            if (LocalVariables.IsLocalVariable(name))
            {
                if (array.Length > 1)
                {
                    index = int.Parse(array[1]);
                    value = lv.GetVariable(statement)[index].Clone();
                }
                else
                {
                    value = lv.GetVariable(statement).Clone();
                }
            }
            else
            {
                if (array.Length > 1)
                {
                    index = int.Parse(array[1]);
                    if (vm.Functions.IsFunction(statement))
                    {
                        return(vm.Functions.ExecFunction(vm, statement)[index]);
                    }
                    value = vm.Variables.GetVariable(statement)[index].Clone();
                }
                else
                {
                    if (vm.Functions.IsFunction(statement))
                    {
                        return(vm.Functions.ExecFunction(vm, statement));
                    }
                    value = vm.Variables.GetVariable(statement).Clone();
                }
            }
            if (value.ValueType == ValueType.Array)
            {
                index = vm.Random.Next(value.ToArray().Count);
                return(value[index].Clone());
            }
            return(value);
        }
Пример #2
0
 public Value Evaluate(ExecutionContext vm, LocalVariables lv)
 {
     return(new Value(text));
 }
Пример #3
0
 public override Value Evaluate(ExecutionContext vm, LocalVariables lv)
 {
     return(expression.Evaluate(vm, lv));
 }
Пример #4
0
        public override Value Execute(ExecutionContext vm, LocalVariables lv)
        {
            var argv = lv.GetVariable("argv");

            return(new Value(argv[0].ToString().ToUpperInvariant()));
        }
Пример #5
0
 public bool IsExecutable(ExecutionContext vm, LocalVariables lv)
 {
     return(expression.Evaluate(vm, lv).ToBoolean());
 }
Пример #6
0
 public bool IsExecutable(ExecutionContext vm, LocalVariables lv)
 {
     // システム関数は常に実行可能
     return(true);
 }
Пример #7
0
        public override Value Execute(ExecutionContext vm, LocalVariables lv)
        {
            var argv = lv.GetVariable("argv");

            return(new Value(argv.ToArray()));
        }
Пример #8
0
        public override Value Execute(ExecutionContext vm, LocalVariables lv)
        {
            var argv = lv.GetVariable("argv");

            return(base.Execute(vm, lv));
        }
Пример #9
0
 public override Value Execute(ExecutionContext vm, LocalVariables lv)
 {
     return(base.Execute(vm, lv));
 }
Пример #10
0
        public override Value Execute(ExecutionContext vm, LocalVariables lv)
        {
            var argv = lv.GetVariable("argv");

            return(new Value(argv[1].ToString().LastIndexOf(argv[0].ToString())));
        }
Пример #11
0
        public override Value Execute(ExecutionContext vm, LocalVariables lv)
        {
            var argv = lv.GetVariable("argv");

            return(new Value(vm.Random.Next(argv[0].ToInt32())));
        }
Пример #12
0
        public override Value Execute(ExecutionContext vm, LocalVariables lv)
        {
            var argv = lv.GetVariable("argv");

            return(new Value(Path.GetFileName(argv[0].ToString())));
        }
Пример #13
0
        public override Value Execute(ExecutionContext vm, LocalVariables lv)
        {
            var argv = lv.GetVariable("argv");

            return(argv[0].Clone());
        }
Пример #14
0
 public override Value Execute(ExecutionContext vm, LocalVariables lv)
 {
     // 変数のシリアライズ
     vm.Variables.Serialize(Path.Combine(vm.RootDirectory, "imouto_vars.txt"));
     return(new Value());
 }
Пример #15
0
        public override Value Evaluate(ExecutionContext vm, LocalVariables lv)
        {
            var value = expression.Evaluate(vm, lv);

            return(new Value(~value.ToInt32()));
        }
Пример #16
0
        public override Value Execute(ExecutionContext vm, LocalVariables lv)
        {
            var argv = lv.GetVariable("argv");

            return(new Value(Math.Log10(argv[0].ToDouble())));
        }
Пример #17
0
 public virtual Value Evaluate(ExecutionContext vm, LocalVariables lv)
 {
     return(null);
 }
Пример #18
0
 public virtual Value Execute(ExecutionContext vm, LocalVariables lv)
 {
     return(new Value());
 }