X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fsupport.cs;h=ab3cc5c1492bc3f62be5b9c7e77600a4047d8104;hb=b078895e893c2896b1dbdff3fac055aa2f7f2b1f;hp=35066a16faf2b018c047ad65148832810b6cd8d0;hpb=c251b192a55c255f278c9b9ad2ec949264a36526;p=mono.git diff --git a/mcs/mcs/support.cs b/mcs/mcs/support.cs index 35066a16faf..ab3cc5c1492 100644 --- a/mcs/mcs/support.cs +++ b/mcs/mcs/support.cs @@ -36,77 +36,6 @@ namespace Mono.CSharp { return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode (obj); } } -#if !NET_4_0 && !MONODROID - public class Tuple : IEquatable> - { - public Tuple (T1 item1, T2 item2) - { - Item1 = item1; - Item2 = item2; - } - - public T1 Item1 { get; private set; } - public T2 Item2 { get; private set; } - - public override int GetHashCode () - { - return Item1.GetHashCode () ^ Item2.GetHashCode (); - } - - #region IEquatable> Members - - public bool Equals (Tuple other) - { - return EqualityComparer.Default.Equals (Item1, other.Item1) && - EqualityComparer.Default.Equals (Item2, other.Item2); - } - - #endregion - } - - public class Tuple : IEquatable> - { - public Tuple (T1 item1, T2 item2, T3 item3) - { - Item1 = item1; - Item2 = item2; - Item3 = item3; - } - - public T1 Item1 { get; private set; } - public T2 Item2 { get; private set; } - public T3 Item3 { get; private set; } - - public override int GetHashCode () - { - return Item1.GetHashCode () ^ Item2.GetHashCode () ^ Item3.GetHashCode (); - } - - #region IEquatable> Members - - public bool Equals (Tuple other) - { - return EqualityComparer.Default.Equals (Item1, other.Item1) && - EqualityComparer.Default.Equals (Item2, other.Item2) && - EqualityComparer.Default.Equals (Item3, other.Item3); - } - - #endregion - } - - static class Tuple - { - public static Tuple Create (T1 item1, T2 item2) - { - return new Tuple (item1, item2); - } - - public static Tuple Create (T1 item1, T2 item2, T3 item3) - { - return new Tuple (item1, item2, item3); - } - } -#endif static class ArrayComparer { @@ -136,21 +65,28 @@ namespace Mono.CSharp { /// public class SeekableStreamReader : IDisposable { + public const int DefaultReadAheadSize = +#if FULL_AST + 65536 / 2; // Large buffer because of ReadChars of large literal string +#else + 4096 / 2; +#endif + StreamReader reader; Stream stream; - static char[] buffer; + char[] buffer; int read_ahead_length; // the length of read buffer int buffer_start; // in chars int char_count; // count of filled characters in buffer[] int pos; // index into buffer[] - public SeekableStreamReader (Stream stream, Encoding encoding) + public SeekableStreamReader (Stream stream, Encoding encoding, char[] sharedBuffer = null) { this.stream = stream; + this.buffer = sharedBuffer; - const int default_read_ahead = 2048; - InitializeStream (default_read_ahead); + InitializeStream (DefaultReadAheadSize); reader = new StreamReader (stream, encoding, true); } @@ -315,4 +251,38 @@ namespace Mono.CSharp { } } } + + struct TypeNameParser + { + internal static string Escape(string name) + { + if (name == null) { + return null; + } + StringBuilder sb = null; + for (int pos = 0; pos < name.Length; pos++) { + char c = name[pos]; + switch (c) { + case '\\': + case '+': + case ',': + case '[': + case ']': + case '*': + case '&': + if (sb == null) { + sb = new StringBuilder(name, 0, pos, name.Length + 3); + } + sb.Append("\\").Append(c); + break; + default: + if (sb != null) { + sb.Append(c); + } + break; + } + } + return sb != null ? sb.ToString() : name; + } + } }