Ejemplo n.º 1
0
 public void Merge(CefMemory memoryScope)
 {
     foreach (var variable in memoryScope)
     {
         this.Add(variable);
     }
 }
Ejemplo n.º 2
0
 public void Update(CefMemory memScope)
 {
     foreach (var variable in memScope)
     {
         Set(variable);
     }
 }
Ejemplo n.º 3
0
        public CefMemory RequiredMemory()
        {
            CefMemory Memory = new CefMemory();

            foreach (var func in funcs.OrEmptyIfNull())
            {
                Memory.Add(Types.Variable.Create(func.GetType().Name, ""));
            }
            return(Memory);
        }
Ejemplo n.º 4
0
        public async Task <bool> Run()
        {
            Output     = "";
            MemoryDump = "";
            Processed  = false;
            ExpressionResult exres = ExpressionResult.OK;

            try
            {
                this.Analize();
                Memory = new CefMemory();
                for (var i = 0; i < Expressions.Count; i++)
                {
                    if (Processed)
                    {
                        return(false);
                    }
                    if (exres == ExpressionResult.CondFalse)
                    {
                        exres = ExpressionResult.OK;
                    }
                    else
                    {
                        Memory.Update(Expressions[i].RequiredMemory());
                        exres = await Expressions[i].Execute(Browser, Memory, Callback, Log);//expression writes variables to the memory!!
                        //memoryScope.Update(expression.Memory);//updates all values
                    }
                }
            }
            catch (Exception ex)
            {
                Output += ex.Message + " in " + ex.StackTrace;
            }



            Completed();
            return(true);
        }
Ejemplo n.º 5
0
 public abstract Task <ExpressionResult> Execute(Browser.Browser Browser, CefMemory Memory, Interpreter.CallBackEventHandler ceh = null, Action log = null);
Ejemplo n.º 6
0
        public async override Task <ExpressionResult> Execute(Browser.Browser Browser, CefMemory Memory, Interpreter.CallBackEventHandler ceh = null, Action log = null)
        {
            ExpressionResult res = ExpressionResult.OK;

            if (expressions != null)
            {
                for (int i = 0; i < expressions.Count; i++)
                {
                    if (stop)
                    {
                        return(ExpressionResult.Error);
                    }
                    res = await expressions[i].Execute(Browser, Memory, ceh, log);

                    switch (res)
                    {
                    case ExpressionResult.CallBack:
                        ceh?.Invoke(Memory);
                        break;

                    case ExpressionResult.CondFalse:
                    case ExpressionResult.WhileCondFalse:
                        res = ExpressionResult.OK;
                        i++;
                        break;

                    case ExpressionResult.WhileCondTrue:
                        res = await expressions[i + 1].Execute(Browser, Memory, ceh, log);
                        i--;
                        break;

                    default:
                        break;
                    }
                }
            }


            return(res);
        }
Ejemplo n.º 7
0
        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);
        }