Exemplo n.º 1
0
        public Variable Execute(char[] toArray = null, int from = -1)
        {
            toArray = toArray == null ? Constants.END_PARSE_ARRAY : toArray;
            Pointer = from < 0 ? Pointer : from;

            if (!m_data.EndsWith(Constants.END_STATEMENT.ToString()))
            {
                m_data += Constants.END_STATEMENT;
            }

            Variable result = null;

            if (InTryBlock)
            {
                result = Parser.SplitAndMerge(this, toArray);
            }
            else
            {
                try
                {
                    result = Parser.SplitAndMerge(this, toArray);
                }
                catch (ParsingException parseExc)
                {
                    throw parseExc;
                }
                catch (Exception exc)
                {
                    ParsingException parseExc = new ParsingException(exc.Message, this, exc);
                    throw parseExc;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public async Task <Variable> ExecuteAsync(char[] toArray = null, int from = -1)
        {
            toArray = toArray == null ? Constants.END_PARSE_ARRAY : toArray;
            Pointer = from < 0 ? Pointer : from;

            if (!m_data.EndsWith(Constants.END_STATEMENT.ToString()))
            {
                m_data += Constants.END_STATEMENT;
            }

            Variable result = null;

            bool handleByDebugger = DebuggerServer.DebuggerAttached && !Debugger.Executing;

            if (DebuggerServer.DebuggerAttached)
            {
                result = await Debugger.CheckBreakpoints(this);

                if (result != null)
                {
                    return(result);
                }
            }

            if (InTryBlock)
            {
                result = await Parser.SplitAndMergeAsync(this, toArray);
            }
            else
            {
                try
                {
                    result = await Parser.SplitAndMergeAsync(this, toArray);
                }
                catch (ParsingException parseExc)
                {
                    if (handleByDebugger)
                    {
                        Debugger.ProcessException(this, parseExc);
                    }
                    throw;
                }
                catch (Exception exc)
                {
                    ParsingException parseExc = new ParsingException(exc.Message, this, exc);
                    if (handleByDebugger)
                    {
                        Debugger.ProcessException(this, parseExc);
                    }
                    throw parseExc;
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public Variable Execute(char[] toArray)
        {
            if (!m_data.EndsWith(Constants.END_STATEMENT.ToString()))
            {
                m_data += Constants.END_STATEMENT;
            }

            Variable result = null;

            bool handleByDebugger = DebuggerServer.DebuggerAttached && !Debugger.Executing;

            if (DebuggerServer.DebuggerAttached)
            {
                result = Debugger.CheckBreakpoints(this).Result;
                if (result != null)
                {
                    return(result);
                }
            }

            if (InTryBlock)
            {
                result = Parser.SplitAndMerge(this, toArray);
            }
            else
            {
                try
                {
                    result = Parser.SplitAndMerge(this, toArray);
                }
                catch (ParsingException parseExc)
                {
                    if (handleByDebugger)
                    {
                        Debugger.ProcessException(this, parseExc);
                    }
                    throw;
                }
                catch (Exception exc)
                {
                    ParsingException parseExc = new ParsingException(exc.Message, this, exc);
                    if (handleByDebugger)
                    {
                        Debugger.ProcessException(this, parseExc);
                    }
                    throw parseExc;
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public static void ProcessException(ParsingScript script, ParsingException exc)
        {
            Debugger debugger = script != null && script.Debugger != null ?
                                script.Debugger : MainInstance;

            if (debugger == null)
            {
                return;
            }

            if (debugger.ReplMode)
            {
                string replResult = DebuggerUtils.ResponseMainToken(DebuggerUtils.DebugAction.REPL) +
                                    "Exception thrown: " + exc.Message + "\n";
                debugger.SendBack(replResult, false);
                debugger.LastResult = null;
                ParserFunction.InvalidateStacksAfterLevel(0);
                return;
            }

            string stack     = exc.ExceptionStack;
            string vars      = debugger.GetAllVariables(script);
            int    varsCount = vars.Split('\n').Length;

            string result = "exc\n" + exc.Message + "\n";

            //result += exc. + "\n";
            result += varsCount + "\n";
            result += vars + "\n";
            result += stack + "\n";

            debugger.SendBack(result, !debugger.ReplMode);
            debugger.LastResult = null;

            ParserFunction.InvalidateStacksAfterLevel(0);
        }
Exemplo n.º 5
0
        public static void ProcessException(ParsingScript script, ParsingException exc)
        {
            Debugger debugger = script.Debugger != null ? script.Debugger : MainInstance;

            if (debugger == null)
            {
                return;
            }

            string stack     = exc.ExceptionStack;
            string vars      = debugger.GetAllVariables(script);
            int    varsCount = vars.Split('\n').Length;

            string result = "exc\n" + exc.Message + "\n";

            result += varsCount + "\n";
            result += vars + "\n";
            result += stack + "\n";

            debugger.SendBack(result);
            debugger.LastResult = null;

            ParserFunction.InvalidateStacksAfterLevel(0);
        }