Esempio n. 1
0
        void Run(string code, bool useTry)
        {
            if (!builded)
            {
                Log_Error("Build 失败无法运行");
            }



            CSLE.CLS_Content content = env.CreateContent();//创建一个上下文,出错以后可以用此上下文捕获信息
            if (useTry)
            {
                try
                {
                    __Run(code, content);
                }
                catch (Exception err)
                {
                    string errValue  = content.DumpValue();
                    string errStack  = content.DumpStack(null);
                    string errSystem = "SystemError:\n" + err.ToString();

                    MessageBox.Show(errValue + errStack + errSystem);
                }
            }
            else
            {
                __Run(code, content);
            }
        }
Esempio n. 2
0
        //---------------------------------------------------------------------
        public object doFile(string file_name)
        {
            string code;

            mMapFile.TryGetValue(file_name, out code);
            if (code == null)
            {
                EbLog.Error("EbScriptMgr.runScript() Error! 读取文件失败,File=" + file_name);
                return(null);
            }

            if (mContent == null)
            {
                mContent = mEnvironment.CreateContent();
            }

            try
            {
                var tokens = mEnvironment.tokenParser.Parse(code);
                var expr   = mEnvironment.Expr_CompilerToken(tokens);
                return(mEnvironment.Expr_Execute(expr, mContent));
            }
            catch (Exception ec)
            {
                EbLog.Error("EbScriptMgr.runScript() Error!");
                EbLog.Error(ec.ToString());
                EbLog.Error(mContent.DumpValue());
                EbLog.Error(mContent.DumpStack(null));
            }

            return(null);
        }
Esempio n. 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            listLog.Items.Clear();
            if (compilerResult == null)
            {
                button2_Click(sender, e);
            }

            if (compilerResult != null)
            {
                CSLE.ICLS_Expression   exp         = compilerResult;
                CSLE.CLS_Content.Value returnvalue = new CSLE.CLS_Content.Value();
                CSLE.CLS_Content       content     = this.scriptService.CreateContent();
                try
                {
                    returnvalue = exp.ComputeValue(content);
                }
                catch (Exception err)
                {
                    string contentValue = content.DumpValue();
                    string contentStack = content.DumpStack(null);
                    string systemError  = "SystemError:\n" + err.ToString();

                    MessageBox.Show(contentValue + "\n" + contentStack + "\n" + systemError);
                    Log_Error("执行错误" + err.ToString() + ":" + contentStack + "\n" + contentValue);
                }
                if (returnvalue == null)
                {
                    Log("result=<none>");
                }
                else if (null != returnvalue.type)
                {
                    Log("result=<" + returnvalue.type.Name + ">" + returnvalue.value);
                }
                else
                {
                    Log("result=<unknown>" + returnvalue.value);
                }
            }
        }