Beispiel #1
0
        public void Log()
        {
            string str = "";

            try { str += ((global::CefPreter.Types.String)Memory.Get("Print")).Value; }
            catch {
                //vse norm, tak tozhe mozhna, reli
            }
            if (!String.IsNullOrWhiteSpace(str))
            {
                this.Output += "\r\n" + str;
                Memory.Set(Types.Variable.Create("Print", ""));
            }
            MemoryDump = Memory.ToString();
        }
        public async override Task <ExpressionResult> Execute(Browser.Browser browser, CefMemory memory, Interpreter.CallBackEventHandler ceh = null, Action log = null)
        {
            ExpressionResult res = ExpressionResult.OK;

            Types.Variable result = null;

            if (functions.Count > 0)
            {
                if (functions[0].GetType().Name == "CLBCK")
                {
                    res = ExpressionResult.CallBack;
                }

                foreach (Function.Function f in functions.OrEmptyIfNull())
                {
                    if (stop)
                    {
                        return(ExpressionResult.Error);
                    }
                    var func = f.Clone() as Function.Function;


                    if (func.GetType().Name == "AString" || func.GetType().Name == "ANumber")
                    {
                        memory.Remove(func.Parameters[0].Name, true);
                    }
                    func.Parameters = memory.UnpackAllVariables(func.Parameters);


                    result = await func.Exec(browser);

                    if (func.GetType().Name == "If")
                    {
                        if ((int)((Types.Number)result).Value == 0)
                        {
                            res = ExpressionResult.CondFalse;
                        }
                        else
                        {
                            res = ExpressionResult.CondTrue;
                        }
                    }
                    else if (func.GetType().Name == "While")
                    {
                        if ((int)((Types.Number)result).Value == 1)
                        {
                            res = ExpressionResult.WhileCondTrue;
                        }
                        else
                        {
                            res = ExpressionResult.WhileCondFalse;
                        }
                    }



                    if (result != null)
                    {
                        memory.Set(result);
                    }
                    log?.Invoke();
                }
            }
            return(res);
        }