コード例 #1
0
        public OneScript.DebugProtocol.Variable[] GetVariables(int frameId, int[] path)
        {
            var locals = _machine.GetFrameLocals(frameId);

            foreach (var step in path)
            {
                var variable = locals[step];
                if (HasProperties(variable))
                {
                    var obj = variable.AsObject();
                    locals = new List <IVariable>();
                    var propsCount = obj.GetPropCount();
                    for (int i = 0; i < propsCount; i++)
                    {
                        string propName = obj.GetPropName(i);

                        try
                        {
                            locals.Add(ScriptEngine.Machine.Variable.Create(obj.GetPropValue(i), propName));
                        }
                        catch (Exception e)
                        {
                            locals.Add(ScriptEngine.Machine.Variable.Create(ValueFactory.Create(e.Message), propName));
                        }
                    }
                }
            }

            var result = new OneScript.DebugProtocol.Variable[locals.Count];

            for (int i = 0; i < locals.Count; i++)
            {
                result[i] = new OneScript.DebugProtocol.Variable()
                {
                    Name         = locals[i].Name,
                    IsStructured = HasProperties(locals[i]),
                    Presentation = locals[i].AsString(),
                    TypeName     = locals[i].SystemType.Name
                };
            }

            return(result);
        }