示例#1
0
 bool Completed(ParsingScript debugging)
 {
     return((LastResult != null && LastResult.IsReturn) ||
            !debugging.StillValid());
 }
示例#2
0
        public virtual Task <Variable> GetProperty(string sPropertyName, List <Variable> args = null, ParsingScript script = null)
        {
            sPropertyName = Variable.GetActualPropertyName(sPropertyName, GetProperties());
            switch (sPropertyName)
            {
            case "Name": return(Task.FromResult(GetNameProperty()));

            case "Color": return(Task.FromResult(GetColorProperty()));

            case "Translate":
                return(Task.FromResult(
                           args != null && args.Count > 0 ?
                           Translate(args[0]) : Variable.EmptyInstance));

            default:
                return(Task.FromResult(Variable.EmptyInstance));
            }
        }
示例#3
0
        string GetCurrentFilename(ParsingScript script)
        {
            string filename = Path.GetFullPath(script.Filename);

            return(filename);
        }
示例#4
0
        string GetAllVariables(ParsingScript script)
        {
            string vars = ParserFunction.GetVariables(script);

            return(vars);
        }
示例#5
0
        async Task ProcessClientCommand(string data)
        {
            string load = "";

            DebuggerUtils.DebugAction action = DebuggerUtils.StringToAction(data, ref load);
            string result = "N/A";

            SteppingIn     = SteppingOut = false;
            SendBackResult = true;
            m_firstBlock   = true;
            End            = false;
            string responseToken = DebuggerUtils.ResponseMainToken(action);

            //Trace("REQUEST: " + data);
            if (action == DebuggerUtils.DebugAction.REPL ||
                action == DebuggerUtils.DebugAction._REPL)
            {
                string filename = "";
                if (action == DebuggerUtils.DebugAction.REPL)
                {
                    int ind = load.IndexOf('|');
                    if (ind >= 0)
                    {
                        if (ind > 0)
                        {
                            filename = load.Substring(0, ind);
                        }
                        if (ind + 1 < load.Length)
                        {
                            load = load.Substring(ind + 1);
                        }
                    }
                }
                result = await ProcessRepl(load, filename);

                result = responseToken + (result == null ? "" : result);
                SendBack(result, false);
                return;
            }
            if (action == DebuggerUtils.DebugAction.SET_BP)
            {
                TheBreakpoints.AddBreakpoints(this, load);
                return;
            }

            if (action == DebuggerUtils.DebugAction.FILE)
            {
                MainInstance = this;
                string filename  = load;
                string rawScript = Utils.GetFileContents(filename);

                if (string.IsNullOrWhiteSpace(rawScript))
                {
                    ProcessException(null, new ParsingException("Could not load script " + filename));
                    return;
                }

                try
                {
                    m_script = Utils.ConvertToScript(rawScript, out m_char2Line, filename);
                }
                catch (ParsingException exc)
                {
                    ProcessException(m_debugging, exc);
                    return;
                }
                m_debugging                = new ParsingScript(m_script, 0, m_char2Line);
                m_debugging.Filename       = filename;
                m_debugging.MainFilename   = m_debugging.Filename;
                m_debugging.OriginalScript = rawScript;
                m_debugging.Debugger       = this;

                m_steppingIns.Clear();
                m_completedStepIn.Reset();
                ProcessingBlock = SendBackResult = InInclude = End = false;
                m_blockLevel    = m_maxBlockLevel = 0;
            }
            else if (action == DebuggerUtils.DebugAction.VARS)
            {
                result = GetAllVariables(m_debugging);
            }
            else if (action == DebuggerUtils.DebugAction.ALL)
            {
                result = await DebugScript();
            }
            else if (action == DebuggerUtils.DebugAction.STACK)
            {
                result = GetStack();
            }
            else if (action == DebuggerUtils.DebugAction.CONTINUE)
            {
                Continue = true;
                action   = DebuggerUtils.DebugAction.NEXT;
            }
            else if (action == DebuggerUtils.DebugAction.STEP_IN)
            {
                SteppingIn = true;
                Continue   = false;
                action     = DebuggerUtils.DebugAction.NEXT;
            }
            else if (action == DebuggerUtils.DebugAction.STEP_OUT)
            {
                SteppingOut = true;
                Continue    = false;
                action      = DebuggerUtils.DebugAction.NEXT;
            }
            else if (action == DebuggerUtils.DebugAction.NEXT)
            {
                Continue = false;
            }
            else
            {
                Console.WriteLine("UNKNOWN CMD: {0}", data);
                return;
            }

            if (action == DebuggerUtils.DebugAction.NEXT)
            {
                if (m_debugging == null)
                {
                    result = "Error: Not initialized";
                    Console.WriteLine(result);
                }
                else
                {
                    Variable res = await ProcessNext();

                    //Trace("MAIN Ret:" + (LastResult != null && LastResult.IsReturn) +
                    //      " NULL:" + (res == null) + " db.sb=" + m_debugging.Debugger.SendBackResult +
                    //      " PTR:" + m_debugging.Pointer + "/" + m_script.Length);
                    if (End)
                    {
                        responseToken = DebuggerUtils.ResponseMainToken(DebuggerUtils.DebugAction.END);
                    }
                    else if (res == null || !SendBackResult)
                    {
                        // It will be processed by the stepped-out OR by completed stepped-in code.
                        return;
                    }
                    else
                    {
                        result = CreateResult(Output);
                        if (string.IsNullOrEmpty(result))
                        {
                            return;
                        }
                    }
                }
            }

            result = responseToken + result;
            SendBack(result, true);
        }
示例#6
0
 protected override Variable Evaluate(ParsingScript script)
 {
     return(new Variable(System.Math.Log10(System.Math.E)));
 }
示例#7
0
 protected override Variable Evaluate(ParsingScript script)
 {
     return(new Variable(System.Math.Sqrt(1 / 2)));
 }