Exemple #1
0
        /// <summary>
        /// スクリプトを実行します。
        /// </summary>
        public object Execute(string script)
        {
            if (IsRunning)
            {
                throw new KarinException("既に実行中です。");
            }

            try {
                StopFlag  = false;
                IsRunning = true;

                //字句解析
                var ana = new TextAnalyzer(script, "script root");
                ana.Analyze();

                TokenUtility.Check(ana.Tokens);
                var rpn = TokenUtility.ToRPN(ana.Tokens);

                //実行
                var ret = Ride(rpn);

                if (ret is ReturnedObject)
                {
                    ret = (ret as ReturnedObject).Value;
                }
                return(ret);
            } finally {
                ScopedVariables.Clear();
                IsRunning = false;
            }
        }
Exemple #2
0
        /// <summary>
        /// スクリプトを実行します。
        /// (再帰用)
        /// </summary>
        internal object Eval(string script)
        {
            var ana = new TextAnalyzer(script, "script eval");

            ana.Analyze();

            TokenUtility.Check(ana.Tokens);
            var rpn = TokenUtility.ToRPN(ana.Tokens);
            var ret = Ride(rpn);

            if (ret is ReturnedObject)
            {
                ret = (ret as ReturnedObject).Value;
            }
            return(ret);
        }