[svn] r6410: nemerle/trunk/lib/list.n
VladD2
svnadmin at nemerle.org
Sun Jul 2 02:34:18 CEST 2006
Log:
Add debugging display (in VS) to list[a'].
Author: VladD2
Date: Sun Jul 2 02:34:16 2006
New Revision: 6410
Modified:
nemerle/trunk/lib/list.n
Modified: nemerle/trunk/lib/list.n
==============================================================================
--- nemerle/trunk/lib/list.n (original)
+++ nemerle/trunk/lib/list.n Sun Jul 2 02:34:16 2006
@@ -31,7 +31,8 @@
using Nemerle.Collections.List;
using NCL = Nemerle.Collections.List;
-
+using SCG = System.Collections.Generic;
+using System.Diagnostics;
namespace Nemerle.Core
{
@@ -42,13 +43,15 @@
from head element and tail.
*/
[System.Serializable]
- public variant list ['a] : System.Collections.Generic.IEnumerable ['a]
+ [System.Runtime.InteropServices.ComVisible(false)]
+ [DebuggerDisplay("Length = {Length}: {ToString()}")]
+ public variant list ['a] : SCG.IEnumerable ['a]
{
[System.Serializable]
| Cons { hd : 'a; tl : list ['a]; }
[System.Serializable]
- | Nil {}
+ | Nil { public override ToString () : string { "[]" } }
public override ToString () : string
{
@@ -88,6 +91,7 @@
}
}
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Length : int
{
get {
@@ -103,6 +107,7 @@
/**
* Returns true if the given list is empty.
*/
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
public IsEmpty : bool
{
get {
@@ -117,6 +122,7 @@
* Returns head (first element) of list.
* Given empty list throws System.ArgumentException.
*/
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Head : 'a {
get {
match (this) {
@@ -129,6 +135,7 @@
/**
* Returns tail (all elements except the first one) of list.
*/
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Tail : list ['a] {
get {
match (this) {
@@ -143,6 +150,7 @@
* Given empty list throws InvalidArgument exception.
* Works in time O(n) and memory O(1).
*/
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Last : 'a {
get {
NCL.Last (this)
@@ -440,6 +448,13 @@
NCL.RemoveDuplicates (this)
}
+ // For debugging purpose.
+ [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
+ protected AsArray : array ['a]
+ {
+ get { ToArray () }
+ }
+
public ToArray () : array ['a]
{
def result = array (Length);
@@ -489,14 +504,25 @@
// private helpers
concat_helper (sep : string, sb : System.Text.StringBuilder) : void
{
+ def to_string (value : object)
+ {
+ match (value)
+ {
+ | str is string => "\"" + str + "\""
+ | null => "<null>"
+ | _ => value.ToString ()
+ }
+ };
+
def loop (lst) {
- | [x] => ignore (sb.Append (x.ToString ()))
+ | [x] => ignore (sb.Append (to_string (x)))
| x :: xs =>
- ignore (sb.Append (x.ToString ()).Append (sep));
+ ignore (sb.Append (to_string (x)).Append (sep));
loop (xs)
| [] => ()
};
+
loop (this)
}
}
More information about the svn
mailing list