예제 #1
0
        public override void Evaluate(Response response, dynamic arguments)
        {
            // expression, frameId, context
            int frameId = getInt(arguments, "frameId");
            var frame   = _framesHandles.Get(frameId, null);

            if (frame == null)
            {
                SendErrorResponse(response, 10001, "No active stackframe");
                return;
            }

            var expression = (string)arguments.expression;
            var context    = (string)arguments.context;

            int id = -1;

            OneScript.DebugProtocol.Variable evalResult;
            try
            {
                evalResult = _process.Evaluate(frame, expression);

                if (evalResult.IsStructured)
                {
                    var loc = new EvaluatedVariableLocator(expression, frameId);
                    id = _variableHandles.Create(loc);
                }
            }
            catch (Exception e)
            {
                evalResult = new OneScript.DebugProtocol.Variable()
                {
                    Presentation = e.Message, Name = "$evalFault"
                };
            }

            if (evalResult.Name.Equals("$evalFault") && context.Equals("hover"))
            {
                evalResult.Presentation = "";
            }

            var protResult = new EvaluateResponseBody(evalResult.Presentation, id)
            {
                type = evalResult.TypeName
            };

            SendResponse(response, protResult);
        }
        public override void Evaluate(Response response, dynamic arguments)
        {
            // expression, frameId, context
            int frameId = getInt(arguments, "frameId");
            var frame   = _framesHandles.Get(frameId, null);

            if (frame == null)
            {
                SendErrorResponse(response, 10001, "No active stackframe");
                return;
            }

            var expression = (string)arguments.expression;
            var context    = (string)arguments.context;

            if (context != "watch")
            {
                SendResponse(response);
                return;
            }

            OneScript.DebugProtocol.Variable evalResult;
            try
            {
                evalResult = _process.Evaluate(frame, expression);
            }
            catch (Exception e)
            {
                evalResult = new OneScript.DebugProtocol.Variable()
                {
                    Presentation = e.Message
                };
            }

            var protResult = new EvaluateResponseBody(evalResult.Presentation)
            {
                type = evalResult.TypeName
            };

            SendResponse(response, protResult);
        }