Exemplo n.º 1
0
        async Task <string> ProcessRepl(string repl, string filename = "")
        {
            ReplMode = true;

            Dictionary <int, int> char2Line;
            string        script     = Utils.ConvertToScript(repl, out char2Line);
            ParsingScript tempScript = new ParsingScript(script, 0, char2Line);

            tempScript.OriginalScript = repl;
            tempScript.Debugger       = this;
            if (!string.IsNullOrWhiteSpace(filename))
            {
                tempScript.Filename = filename;
            }

            Variable result    = null;
            bool     excThrown = false;
            string   stringRes = "";

            try
            {
                while (tempScript.Pointer < script.Length)
                {
                    result = await DebuggerUtils.Execute(tempScript);

                    tempScript.GoToNextStatement();
                    while (tempScript.TryCurrent() == Constants.END_STATEMENT)
                    {
                        tempScript.Forward();
                    }
                }

                if (TrySendFile(result, tempScript, ref excThrown) || excThrown)
                {
                    return("");
                }

                stringRes = string.IsNullOrEmpty(Output) ? "" : Output + (Output.EndsWith("\n") ? "" : "\n");

                stringRes += result == null ? "" : result.AsString();
                stringRes += (stringRes.EndsWith("\n") ? "" : "\n");
            }
            catch (Exception exc)
            {
                Console.WriteLine("ProcessRepl Exception: " + exc);
                return(""); // The exception was already thrown and sent back.
            }
            finally
            {
                ReplMode = false;
            }


            return(stringRes);
        }
Exemplo n.º 2
0
        public async Task <bool> ExecuteNextStatement()
        {
            int endGroupRead = 0;

            if (m_debugging.Pointer >= m_script.Length - 1)
            {
                LastResult = null;
                End        = true;
                return(true);
            }

            //int startPointer = m_debugging.Pointer;
            if (ProcessingBlock)
            {
                endGroupRead = m_debugging.GoToNextStatement();
                if (ProcessingBlock && endGroupRead > 0)
                {
                    return(true);
                }
            }

            Executing = true;
            try
            {
                LastResult = await DebuggerUtils.Execute(m_debugging);
            }
            catch (ParsingException exc)
            {
                if (m_debugging.InTryBlock)
                {
                    throw exc;
                }
                ProcessException(m_debugging, exc);
                return(true);
            }
            finally
            {
                Executing = false;
            }

            endGroupRead = m_debugging.GoToNextStatement();

            // Check if after this statement the Step In is completed and we can unwind the stack:
            bool completedSteppingIn = Completed(m_debugging) || (ProcessingBlock && endGroupRead > 0) ||
                                       LastResult.Type == Variable.VarType.CONTINUE ||
                                       LastResult.Type == Variable.VarType.BREAK ||
                                       LastResult.IsReturn;

            return(completedSteppingIn);
        }