Пример #1
0
        ///////////////////////////////////////////////////////////////////////

        internal StringList GetWatchpoints()
        {
            StringList result = new StringList();

            foreach (KeyValuePair <string, IVariable> pair in this)
            {
                IVariable variable = pair.Value;

                if (variable == null)
                {
                    continue;
                }

                VariableFlags flags = EntityOps.GetWatchpointFlags(
                    variable.Flags);

                if (flags != VariableFlags.None)
                {
                    //
                    // NOTE: Two element sub-list of name and watch types.
                    //
                    result.Add(new StringList(
                                   variable.Name, flags.ToString()).ToString());
                }
            }

            return(result);
        }
Пример #2
0
        ///////////////////////////////////////////////////////////////////////////////////////

        #region IExecute Members
        public override ReturnCode Execute(
            Interpreter interpreter,
            IClientData clientData,
            ArgumentList arguments,
            ref Result result
            )
        {
            ReturnCode code = ReturnCode.Ok;

            if (interpreter != null)
            {
                if (arguments != null)
                {
                    if ((arguments.Count == 3) || (arguments.Count == 4))
                    {
                        VariableFlags flags = VariableFlags.None;

                        object enumValue = EnumOps.TryParseFlagsEnum(
                            interpreter, typeof(VariableFlags),
                            flags.ToString(), arguments[1],
                            interpreter.CultureInfo, true, true,
                            true, ref result);

                        if (enumValue is VariableFlags)
                        {
                            flags = (VariableFlags)enumValue;

                            if (arguments.Count == 3)
                            {
                                code = interpreter.GetVariableValue(
                                    flags, arguments[2], ref result, ref result);
                            }
                            else if (arguments.Count == 4)
                            {
                                code = interpreter.SetVariableValue(
                                    flags, arguments[2], arguments[3], null, ref result);

                                if (code == ReturnCode.Ok)
                                {
                                    //
                                    // NOTE: Maybe it was append mode?  Re-get the value now.
                                    //
                                    code = interpreter.GetVariableValue(
                                        flags, arguments[2], ref result, ref result);
                                }
                            }
                        }
                        else
                        {
                            code = ReturnCode.Error;
                        }
                    }
                    else
                    {
                        result = "wrong # args: should be \"setf varFlags varName ?newValue?\"";
                        code   = ReturnCode.Error;
                    }
                }
                else
                {
                    result = "invalid argument list";
                    code   = ReturnCode.Error;
                }
            }
            else
            {
                result = "invalid interpreter";
                code   = ReturnCode.Error;
            }

            return(code);
        }
Пример #3
0
        ///////////////////////////////////////////////////////////////////////////////////////

        #region IExecute Members
        public override ReturnCode Execute(
            Interpreter interpreter,
            IClientData clientData,
            ArgumentList arguments,
            ref Result result
            )
        {
            if (interpreter != null)
            {
                if (arguments != null)
                {
                    if (arguments.Count >= 2)
                    {
                        VariableFlags flags = VariableFlags.None;

                        object enumValue = EnumOps.TryParseFlagsEnum(
                            interpreter, typeof(VariableFlags),
                            flags.ToString(), arguments[1],
                            interpreter.CultureInfo, true, true,
                            true, ref result);

                        if (enumValue is VariableFlags)
                        {
                            flags = (VariableFlags)enumValue;

                            if (arguments.Count > 2)
                            {
                                for (int argumentIndex = 2;
                                     argumentIndex < arguments.Count;
                                     argumentIndex++)
                                {
                                    if (interpreter.UnsetVariable(flags,
                                                                  arguments[argumentIndex],
                                                                  ref result) != ReturnCode.Ok)
                                    {
                                        return(ReturnCode.Error);
                                    }
                                }

                                result = String.Empty;
                                return(ReturnCode.Ok);
                            }

                            //
                            // NOTE: Do nothing if no more arguments supplied,
                            //       so as to match command documentation
                            //       (COMPAT: Tcl).
                            //
                            result = String.Empty;
                            return(ReturnCode.Ok);
                        }
                        else
                        {
                            return(ReturnCode.Error);
                        }
                    }
                    else
                    {
                        result = "wrong # args: should be \"unsetf varFlags ?varName varName ...?\"";
                        return(ReturnCode.Error);
                    }
                }
                else
                {
                    result = "invalid argument list";
                    return(ReturnCode.Error);
                }
            }
            else
            {
                result = "invalid interpreter";
                return(ReturnCode.Error);
            }
        }
Пример #4
0
        ///////////////////////////////////////////////////////////////////////

        public StringPairList ToStringPairList()
        {
            StringPairList result = new StringPairList();

            if (variable != null)
            {
                result.Add(variable.Kind.ToString());
                result.Add((IPair <string>)null);

                if (variable.Name != null)
                {
                    result.Add("name", variable.Name);
                }
                else
                {
                    result.Add("name", String.Empty);
                }

                if (EntityOps.IsArray2(variable))
                {
                    ElementDictionary arrayValue = variable.ArrayValue;

                    if (arrayValue != null)
                    {
                        result.Add("<array>");

                        if (index != null)
                        {
                            object value;

                            if (arrayValue.TryGetValue(index, out value))
                            {
                                if (value != null)
                                {
                                    result.Add("value",
                                               StringOps.GetStringFromObject(
                                                   value, null, !(value is TraceInfo)));
                                }
                                else
                                {
                                    result.Add("value", FormatOps.DisplayNull);
                                }
                            }
                            else
                            {
                                result.Add("value", "<noValue>");
                            }
                        }
                        else
                        {
                            result.Add("value", "<noIndex>");
                        }
                    }
                    else
                    {
                        result.Add("<noArray>");
                    }
                }
                else
                {
                    object value = variable.Value;

                    if (value != null)
                    {
                        result.Add("value",
                                   StringOps.GetStringFromObject(value));
                    }
                    else
                    {
                        result.Add("value", "<noValue>");
                    }
                }

                result.Add("flags", variable.Flags.ToString());
                result.Add((IPair <string>)null);
            }

            result.Add("TraceInfo");
            result.Add((IPair <string>)null);

            if (trace != null)
            {
                result.Add("trace", trace.ToString());
            }
            else
            {
                result.Add("trace", "<noTrace>");
            }

            result.Add("breakpointType", breakpointType.ToString());

            if (frame != null)
            {
                result.Add("frame", (frame.Name != null) ?
                           frame.Name : "<noFrameName>");
            }
            else
            {
                result.Add("frame", "<noFrame>");
            }

            if (name != null)
            {
                result.Add("name", name);
            }
            else
            {
                result.Add("name", "<noName>");
            }

            if (index != null)
            {
                result.Add("index", index);
            }
            else
            {
                result.Add("index", "<noIndex>");
            }

            result.Add("flags", flags.ToString());

            if (oldValue != null)
            {
                result.Add("oldValue",
                           StringOps.GetStringFromObject(oldValue));
            }
            else
            {
                result.Add("oldValue", "<noOldValue>");
            }

            if (newValue != null)
            {
                result.Add("newValue",
                           StringOps.GetStringFromObject(newValue));
            }
            else
            {
                result.Add("newValue", "<noNewValue>");
            }

            if (oldValues != null)
            {
                result.Add("oldValues", oldValues.ToString());
            }
            else
            {
                result.Add("oldValues", "<noOldValues>");
            }

            if (newValues != null)
            {
                result.Add("newValues", newValues.ToString());
            }
            else
            {
                result.Add("newValues", "<noNewValues>");
            }

            if (list != null)
            {
                result.Add("list", list.ToString());
            }
            else
            {
                result.Add("list", "<noList>");
            }

            result.Add("cancel", cancel.ToString());
            result.Add("postProcess", postProcess.ToString());
            result.Add("returnCode", returnCode.ToString());

            return(result);
        }