edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C429806 File: ModuleOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C429806 (server) 5/3/2008 11:37 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;RubyScopeDebugView @@ -834,48 +834,7 @@ [RubyMethod("to_s")] [RubyMethod("name")] public static MutableString/*!*/ GetName(RubyModule/*!*/ self) { - if (self.IsSingletonClass) { - RubyClass c = (RubyClass)self; - object singletonOf; - MutableString result = new MutableString(); - - int nestings = 0; - while (true) { - nestings++; - result.Append("#', nestings); - } else if (self.Name.IsEmpty) { - MutableString result = new MutableString(); - result.Append("#<"); - result.Append(SymbolTable.IdToString(self.ExecutionContext.GetClassOf(self).Name)); - result.Append(':'); - RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(self.ExecutionContext, self)); - result.Append('>'); - return result; - } else { - return new MutableString(self.Name); - } + return self.GetDisplayName(); } #endregion =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C429806 File: RubyModule.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C429806 (server) 5/3/2008 11:37 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;RubyScopeDebugView @@ -694,5 +694,54 @@ } #endregion + + #region Utils + + public MutableString/*!*/ GetDisplayName() { + if (IsSingletonClass) { + RubyClass c = (RubyClass)this; + object singletonOf; + MutableString result = new MutableString(); + + int nestings = 0; + while (true) { + nestings++; + result.Append("#', nestings); + } else if (_name.IsEmpty) { + MutableString result = new MutableString(); + result.Append("#<"); + result.Append(SymbolTable.IdToString(_executionContext.GetClassOf(this).Name)); + result.Append(':'); + RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(_executionContext, this)); + result.Append('>'); + return result; + } else { + return new MutableString(_name); + } + } + + #endregion } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs;C429806 File: RubyScope.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs;C429806 (server) 5/3/2008 11:37 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs;RubyScopeDebugView @@ -29,7 +29,12 @@ namespace Ruby.Runtime { +#if SILVERLIGHT public abstract class RubyScope : CodeContext { +#else + [DebuggerTypeProxy(typeof(RubyScope.DebugView))] + public abstract class RubyScope : CodeContext { +#endif // TODO: merge the following two: private readonly SymbolId[]/*!*/ _localNames; private readonly IAttributesCollection/*!*/ _frame; @@ -175,6 +180,96 @@ return result; } + + #region Debug View +#if !SILVERLIGHT + internal sealed class DebugView { + private readonly RubyScope/*!*/ _scope; + private readonly string/*!*/ _selfClassName; + private readonly string/*!*/ _matchClassName; + + public DebugView(RubyScope/*!*/ scope) { + Assert.NotNull(scope); + _scope = scope; + _selfClassName = _scope.ExecutionContext.GetImmediateClassOf(_scope._selfObject).GetDisplayName().ToString(); + _matchClassName = _scope.ExecutionContext.GetImmediateClassOf(_scope._currentMatch).GetDisplayName().ToString(); + } + + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public VariableView[]/*!*/ A0 { + get { + List result = new List(); + RubyScope scope = _scope; + while (true) { + foreach (KeyValuePair variable in scope._frame.SymbolAttributes) { + string name = SymbolTable.IdToString(variable.Key); + if (!name.StartsWith("#")) { + string className = _scope.ExecutionContext.GetImmediateClassOf(variable.Value).GetDisplayName().ToString(); + if (scope != _scope) { + name += " (outer)"; + } + result.Add(new VariableView(name, variable.Value, className)); + } + } + + if (scope.Kind != ScopeKind.Block) { + break; + } + scope = (RubyScope)scope.Parent; + } + return result.ToArray(); + } + } + + [DebuggerDisplay("{A1}", Name = "self", Type = "{_selfClassName,nq}")] + public object/*!*/ A1 { + get { return _scope._selfObject; } + } + + [DebuggerDisplay("{A2 != null ? A2.ToString() : \"nil\",nq}", Name = "$~", Type = "{_matchClassName,nq}")] + public Match/*!*/ A2 { + get { return _scope._currentMatch; } + } + + [DebuggerDisplay("{B}", Name = "MethodAttributes", Type = "")] + public RubyMethodAttributes/*!*/ B { + get { return _scope._methodAttributes; } + } + + [DebuggerDisplay("{C}", Name = "ParentScope", Type = "")] + public RubyScope/*!*/ C { + get { return (RubyScope)_scope.Parent; } + } + + [DebuggerDisplay("", Name = "RawVariables", Type = "")] + public System.Collections.Hashtable/*!*/ D { + get { + System.Collections.Hashtable result = new System.Collections.Hashtable(); + foreach (KeyValuePair variable in _scope._frame.SymbolAttributes) { + result.Add(variable.Key, variable.Value); + } + return result; + } + } + + [DebuggerDisplay("{_value}", Name = "{_name,nq}", Type = "{_valueClassName,nq}")] + internal struct VariableView { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly string/*!*/ _name; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly object _value; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly string/*!*/ _valueClassName; + + public VariableView(string/*!*/ name, object value, string/*!*/ valueClassName) { + _name = name; + _value = value; + _valueClassName = valueClassName; + } + } + } +#endif + #endregion } public sealed class RubyMethodScope : RubyScope { ===================================================================