예제 #1
0
        public override void Scopes(Response response, dynamic arguments)
        {
            int             frameId = getInt(arguments, "frameId", 0);
            GetFrameInfoCmd cmd     = new GetFrameInfoCmd();

            cmd.m_stack_idx      = frameId;
            _cur_frame_variables = SendOneCmdAndWaitForResponse(cmd) as GetFrameInfoRes;

            var scopes = new List <Scope>();

            scopes.Add(new Scope("Local", 1));
            scopes.Add(new Scope("Closure", 2));

            SendResponse(response, new ScopesResponseBody(scopes));
        }
예제 #2
0
        internal void FillFrameInfo(GetFrameInfoRes res, int stack_idx)
        {
            if (stack_idx > _calls.Count)
            {
                return;
            }
            var call_idx = _calls.Count - stack_idx;
            var call     = _calls[call_idx];
            var closure  = call.closure;
            var func     = closure.func;
            var pc       = call.pc;

            if (stack_idx != 1)
            {
                pc -= 1;
            }
            pc = Math.Max(0, pc);

            var all_local_var_infos = func.GetAllLocalVarInfo();

            foreach (var info in all_local_var_infos)
            {
                if (info.begin_pc <= pc && pc < info.end_pc)
                {
                    GetFrameInfoRes.ValueInfo value = new GetFrameInfoRes.ValueInfo();
                    value.name = info.name;
                    var obj = _stack[call.register_idx + info.register_idx];
                    if (obj == null)
                    {
                        value.type  = "null";
                        value.value = "nil";
                    }
                    else
                    {
                        value.type  = obj.GetType().Name;
                        value.value = obj.ToString();
                    }
                    res.m_locals.Add(value);
                }
            }

            var all_upvalue_infos = func.GetAllUpValueInfos();

            for (int i = 0; i < all_upvalue_infos.Count; ++i)
            {
                GetFrameInfoRes.ValueInfo value = new GetFrameInfoRes.ValueInfo();
                value.name = all_upvalue_infos[i].name;
                var obj = closure.GetUpvalue(i).Read();
                if (obj == null)
                {
                    value.type  = "null";
                    value.value = "nil";
                }
                else
                {
                    value.type  = obj.GetType().Name;
                    value.value = obj.ToString();
                }
                res.m_upvalues.Add(value);
            }
        }