edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializer.Generated.cs;C434537 File: Initializer.Generated.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializer.Generated.cs;C434537 (server) 5/8/2008 2:10 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializer.Generated.cs;MutableString5 @@ -44,7 +44,7 @@ #endif // Skipped primitive: Object Ruby.Builtins.RubyModule def34 = DefineModule("System::Collections::Generic::IDictionary", typeof(System.Collections.Generic.IDictionary), new System.Action(LoadSystem__Collections__Generic__IDictionary_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); - Ruby.Builtins.RubyModule def47 = DefineModule("System::Collections::IEnumerable", typeof(System.Collections.IEnumerable), new System.Action(LoadSystem__Collections__IEnumerable_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); + DefineModule("System::Collections::IEnumerable", typeof(System.Collections.IEnumerable), new System.Action(LoadSystem__Collections__IEnumerable_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); Ruby.Builtins.RubyModule def42 = DefineModule("System::Collections::IList", typeof(System.Collections.IList), new System.Action(LoadSystem__Collections__IList_Instance), null, new Ruby.Builtins.RubyModule[] {def28, }); DefineModule("System::IComparable", typeof(System.IComparable), new System.Action(LoadSystem__IComparable_Instance), null, new Ruby.Builtins.RubyModule[] {def40, }); DefineGlobalClass("Time", typeof(System.DateTime), typeof(Ruby.Builtins.TimeOps), new System.Action(LoadTime_Instance), new System.Action(LoadTime_Class), classRef1, new Ruby.Builtins.RubyModule[] {def40, }, new System.Delegate[] { @@ -71,7 +71,7 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ArrayOps.CreateArray), }); DefineGlobalClass("Binding", typeof(Ruby.Builtins.Binding), typeof(Ruby.Builtins.BindingOps), null, null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("ClrString", typeof(System.String), typeof(Ruby.Builtins.StringOps), new System.Action(LoadClrString_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def47, }, null); + DefineGlobalClass("ClrString", typeof(System.String), typeof(Ruby.Builtins.StringOps), new System.Action(LoadClrString_Instance), null, Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyClass def13 = DefineClass("Digest::Class", typeof(Ruby.StandardLibrary.Digest.Class), null, null, new System.Action(LoadDigest__Class_Class), Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def14, }, null); DefineGlobalClass("Dir", typeof(Ruby.Builtins.RubyDir), null, new System.Action(LoadDir_Instance), new System.Action(LoadDir_Class), Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, }, null); Ruby.Builtins.RubyClass def41 = Context.ExceptionClass = DefineGlobalClass("Exception", typeof(System.Exception), typeof(Ruby.Builtins.ExceptionOps), new System.Action(LoadException_Instance), new System.Action(LoadException_Class), Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { @@ -101,15 +101,18 @@ DefineGlobalClass("Range", typeof(Ruby.Builtins.Range), typeof(Ruby.Builtins.RangeOps), new System.Action(LoadRange_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, }, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RangeOps.CreateRange), }); - DefineGlobalClass("Regexp", typeof(Ruby.Builtins.Regexp), typeof(Ruby.Builtins.RegexpOps), new System.Action(LoadRegexp_Instance), new System.Action(LoadRegexp_Class), Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, }, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), + DefineGlobalClass("Regexp", typeof(Ruby.Builtins.RubyRegex), typeof(Ruby.Builtins.RegexpOps), new System.Action(LoadRegexp_Instance), new System.Action(LoadRegexp_Class), Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, }, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Create), }); - DefineGlobalClass("String", typeof(Ruby.Builtins.MutableString), typeof(Ruby.Builtins.MutableStringOps), new System.Action(LoadString_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, def40, }, null); + DefineGlobalClass("String", typeof(Ruby.Builtins.MutableString), typeof(Ruby.Builtins.MutableStringOps), new System.Action(LoadString_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, def40, }, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Create), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Create), + }); DefineGlobalClass("StringScanner", typeof(Ruby.Builtins.StringScanner), null, new System.Action(LoadStringScanner_Instance), new System.Action(LoadStringScanner_Class), Context.ObjectClass, Ruby.Builtins.RubyModule.EmptyArray, null); DefineGlobalClass("Struct", typeof(Ruby.Builtins.RubyStruct), typeof(Ruby.Builtins.RubyStructOps), new System.Action(LoadStruct_Instance), null, Context.ObjectClass, new Ruby.Builtins.RubyModule[] {def28, }, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyStructOps.CreateStructClass), @@ -1622,7 +1625,6 @@ module.DefineMethod("puts", 0x9, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.PutsEmptyLine), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Puts), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Puts), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Puts), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Puts), @@ -1674,8 +1676,6 @@ }); module.DefineMethod("write", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Write), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Write), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Write), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Write), }); @@ -2855,26 +2855,26 @@ module.SetConstant("MULTILINE", Ruby.Builtins.RegexpOps.MULTILINE); module.DefineMethod("~", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.ImplicitMatch), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.ImplicitMatch), }); module.DefineMethod("=~", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.MatchIndex), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.MatchIndex), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.MatchIndex), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.MatchIndex), }); module.DefineMethod("===", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.CaseCompare), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.CaseCompare), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.CaseCompare), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.CaseCompare), }); module.DefineMethod("match", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Match), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Match), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Match), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Match), }); module.DefineMethod("source", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Source), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Source), }); } @@ -2885,12 +2885,12 @@ module.SetConstant("MULTILINE", Ruby.Builtins.RegexpOps.MULTILINE); module.DefineMethod("compile", 0x11, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Compile), }); module.DefineMethod("escape", 0x11, new System.Delegate[] { @@ -2918,7 +2918,7 @@ }); module.DefineMethod("*", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Repeat), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Repeat), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Repeat), }); @@ -2931,9 +2931,9 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), }); module.DefineMethod("[]=", 0x9, new System.Delegate[] { @@ -2964,7 +2964,7 @@ }); module.DefineMethod("=~", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Match), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Match), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Match), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Match), }); @@ -3073,23 +3073,22 @@ }); module.DefineMethod("gsub", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.BlockReplaceAll), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAll), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.BlockReplaceAll), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAll), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAll), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAll), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAll), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAll), }); module.DefineMethod("gsub!", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.BlockReplaceAllInPlace), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAllInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.BlockReplaceAllInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAllInPlace), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAllInPlace), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAllInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAllInPlace), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceAllInPlace), }); module.DefineMethod("include?", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Include), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Include), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Include), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Include), @@ -3105,9 +3104,9 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Index), }); module.DefineMethod("initialize", 0xa, new System.Delegate[] { @@ -3145,7 +3144,7 @@ }); module.DefineMethod("match", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.MatchRegexp), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.MatchRegexp), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.MatchObject), }); @@ -3163,10 +3162,10 @@ }); module.DefineMethod("scan", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Scan), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Scan), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Scan), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Scan), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Scan), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Scan), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Scan), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Scan), }); @@ -3184,9 +3183,9 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.GetChars), }); module.DefineMethod("slice!", 0x9, new System.Delegate[] { @@ -3197,9 +3196,9 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.RemoveCharInPlace), }); @@ -3210,8 +3209,8 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Split), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Split), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Split), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Split), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Split), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Split), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Split), }); module.DefineMethod("strip", 0x9, new System.Delegate[] { @@ -3223,18 +3222,18 @@ }); module.DefineMethod("sub", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.BlockReplaceFirst), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirst), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.BlockReplaceFirst), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirst), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirst), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirst), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirst), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirst), }); module.DefineMethod("sub!", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.BlockReplaceFirstInPlace), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirstInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.BlockReplaceFirstInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirstInPlace), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirstInPlace), - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirstInPlace), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirstInPlace), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.ReplaceFirstInPlace), }); @@ -3320,11 +3319,11 @@ }); module.DefineMethod("check", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.Check), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.Check), }); module.DefineMethod("check_until", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.CheckUntil), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.CheckUntil), }); module.DefineMethod("clear", 0x9, new System.Delegate[] { @@ -3344,7 +3343,7 @@ }); module.DefineMethod("exist?", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function>(Ruby.Builtins.StringScanner.Exist), + new Microsoft.Scripting.Utils.Function>(Ruby.Builtins.StringScanner.Exist), }); module.DefineMethod("get_byte", 0x9, new System.Delegate[] { @@ -3364,7 +3363,7 @@ }); module.DefineMethod("match?", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function>(Ruby.Builtins.StringScanner.Match), + new Microsoft.Scripting.Utils.Function>(Ruby.Builtins.StringScanner.Match), }); module.DefineMethod("matched", 0x9, new System.Delegate[] { @@ -3436,27 +3435,27 @@ }); module.DefineMethod("scan", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.Scan), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.Scan), }); module.DefineMethod("scan_full", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.ScanFull), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.ScanFull), }); module.DefineMethod("scan_until", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.ScanUntil), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.ScanUntil), }); module.DefineMethod("search_full", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.SearchFull), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringScanner.SearchFull), }); module.DefineMethod("skip", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function>(Ruby.Builtins.StringScanner.Skip), + new Microsoft.Scripting.Utils.Function>(Ruby.Builtins.StringScanner.Skip), }); module.DefineMethod("skip_until", 0x9, new System.Delegate[] { - new Microsoft.Scripting.Utils.Function>(Ruby.Builtins.StringScanner.SkipUntil), + new Microsoft.Scripting.Utils.Function>(Ruby.Builtins.StringScanner.SkipUntil), }); module.DefineMethod("string", 0x9, new System.Delegate[] { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;C429806 File: Protocols.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;C429806 (server) 5/7/2008 10:16 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;MutableString5 @@ -23,6 +23,7 @@ using Microsoft.Scripting.Math; using Ruby.Builtins; using Microsoft.Scripting.Runtime; +using System.Text.RegularExpressions; namespace Ruby.Runtime { /// @@ -160,10 +161,10 @@ } public static double ConvertStringToFloat(CodeContext context, MutableString value) { try { - return double.Parse(value.ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat); + return double.Parse(value.ConvertToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat); } catch (FormatException x) { MutableString valueString = RubySites.Inspect(context, value); - throw RubyExceptions.CreateArgumentError("invalid value for Float(): " + valueString.ToString(), x); + throw RubyExceptions.CreateArgumentError("invalid value for Float(): " + valueString.ConvertToString(), x); } } #endregion @@ -173,9 +174,8 @@ /// Convert to a Regexp from an object via a string /// Makes sure that we escape characters in the string. /// - public static Regexp ConvertToRegexp(CodeContext/*!*/ context, object/*!*/ pattern) { - string patternString = Protocols.CastToString(context, pattern); - return new Regexp(new System.Text.RegularExpressions.Regex(System.Text.RegularExpressions.Regex.Escape(patternString))); + public static RubyRegex/*!*/ ConvertToRegexp(CodeContext/*!*/ context, object/*!*/ pattern) { + return new RubyRegex(RubyRegex.Escape(Protocols.CastToString(context, pattern)), RegexOptions.None); } #endregion @@ -452,7 +452,7 @@ if (result == null) { MutableString argErrMsg = RubySites.Inspect(context, obj); argErrMsg.Append(" is not a symbol"); - throw RubyExceptions.CreateArgumentError(argErrMsg.ToString()); + throw RubyExceptions.CreateArgumentError(argErrMsg.ConvertToString()); } RubyUtils.GetExecutionContext(context).ReportWarning("do not use Fixnums as Symbols"); return (SymbolId)result; @@ -465,7 +465,7 @@ MutableString typeErrMsg = RubySites.Inspect(context, obj); typeErrMsg.Append(" is not a symbol"); - throw RubyExceptions.CreateTypeError(typeErrMsg.ToString()); + throw RubyExceptions.CreateTypeError(typeErrMsg.ConvertToString()); } #endregion =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/BigNumOps.cs;C390406 File: BigNumOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/BigNumOps.cs;C390406 (server) 5/8/2008 1:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/BigNumOps.cs;MutableString5 @@ -712,13 +712,15 @@ #endregion #region to_s + /// /// Returns a string containing the representation of self base 10. /// [RubyMethod("to_s")] public static object ToString(BigInteger/*!*/ self) { - return new MutableString(self.ToString()); + return MutableString.Create(self.ToString()); } + /// /// Returns a string containing the representation of self base radix (2 through 36). /// @@ -726,12 +728,13 @@ [RubyMethod("to_s")] public static object ToString(BigInteger/*!*/ self, uint radix) { if (radix < 2 || radix > 36) { - throw RubyExceptions.CreateArgumentError("illegal radix " + radix.ToString()); + throw RubyExceptions.CreateArgumentError(String.Format("illegal radix {0}", radix)); } // TODO: Can we do the ToLower in BigInteger? - return new MutableString(self.ToString((uint)radix).ToLower()); + return MutableString.Create(self.ToString((uint)radix).ToLower()); } + #endregion #endregion =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ClassOps.cs;C429806 File: ClassOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ClassOps.cs;C429806 (server) 5/8/2008 3:17 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ClassOps.cs;MutableString5 @@ -89,11 +89,12 @@ Type type = self.Tracker.Type; int required = type.GetGenericArguments().Length; if (required == 0) { - throw RubyExceptions.CreateArgumentError(string.Format("'{0}' is not a generic type", type.ToString())); + throw RubyExceptions.CreateArgumentError(String.Format("'{0}' is not a generic type", type.FullName)); } + int provided = typeArgs == null ? 0 : typeArgs.Length; if (required != provided) { - throw RubyExceptions.CreateArgumentError(string.Format("Type '{0}' requires {1} generic type arguments, {2} provided", type.ToString(), required, provided)); + throw RubyExceptions.CreateArgumentError(String.Format("Type '{0}' requires {1} generic type arguments, {2} provided", type.FullName, required, provided)); } // pull out the type arguments =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Dir.cs;C415805 File: Dir.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Dir.cs;C415805 (server) 5/7/2008 10:16 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Dir.cs;MutableString5 @@ -53,12 +53,13 @@ #endregion public RubyDir([NotNull]MutableString/*!*/ dirname) { + string strName = dirname.ConvertToString(); try { - _rawEntries = Directory.GetFileSystemEntries(dirname); + _rawEntries = Directory.GetFileSystemEntries(strName); } catch (Exception ex) { - throw ToRubyException(ex, dirname, DirectoryOperation.Open); + throw ToRubyException(ex, strName, DirectoryOperation.Open); } - _dirName = new MutableString(NormalizePathSeparators(dirname)); + _dirName = MutableString.Create(NormalizePathSeparators(strName)); _closed = false; _pos = -2; } @@ -72,19 +73,20 @@ [RubyMethod("chdir", RubyMethodAttributes.PublicSingleton)] public static object ChangeDirectory(CodeContext context, object self, BlockParam block, MutableString dir) { Debug.Assert(block == null || context != null); + string strDir = dir.ConvertToString(); if (block == null) { try { - Directory.SetCurrentDirectory(dir); + Directory.SetCurrentDirectory(strDir); } catch (Exception ex) { - throw ToRubyException(ex, dir, DirectoryOperation.ChangeDir); + throw ToRubyException(ex, strDir, DirectoryOperation.ChangeDir); } return 0; } else { string current = Directory.GetCurrentDirectory(); object ret = null; try { - Directory.SetCurrentDirectory(dir); + Directory.SetCurrentDirectory(strDir); block.BlockJumped(ret = _ChrdirSite.Invoke(context, block, dir)); } finally { Directory.SetCurrentDirectory(current); @@ -116,7 +118,7 @@ throw new ArgumentException("HOME/LOGDIR not set"); } - return ChangeDirectory(self, new MutableString(defaultDirectory)); + return ChangeDirectory(self, MutableString.Create(defaultDirectory)); #else throw new InvalidOperationException(); #endif @@ -131,29 +133,31 @@ [RubyMethod("rmdir", RubyMethodAttributes.PublicSingleton)] [RubyMethod("unlink", RubyMethodAttributes.PublicSingleton)] public static int RemoveDirectory(object self, [NotNull]MutableString/*!*/ dirname) { + string strDir = dirname.ConvertToString(); try { - Directory.Delete(dirname); + Directory.Delete(strDir); } catch (Exception ex) { - throw ToRubyException(ex, dirname, DirectoryOperation.Delete); + throw ToRubyException(ex, strDir, DirectoryOperation.Delete); } return 0; } [RubyMethod("entries", RubyMethodAttributes.PublicSingleton)] public static RubyArray/*!*/ GetEntries(object self, [NotNull]MutableString/*!*/ dirname) { + string strDir = dirname.ConvertToString(); string[] rawEntries = null; try { - rawEntries = Directory.GetFileSystemEntries(dirname); + rawEntries = Directory.GetFileSystemEntries(strDir); } catch (Exception ex) { - throw ToRubyException(ex, dirname, DirectoryOperation.Open); + throw ToRubyException(ex, strDir, DirectoryOperation.Open); } RubyArray ret = new RubyArray(rawEntries.Length + 2); - ret.Add(new MutableString(".")); - ret.Add(new MutableString("..")); + ret.Add(MutableString.Create(".")); + ret.Add(MutableString.Create("..")); foreach (string entry in rawEntries) { - ret.Add(new MutableString(Path.GetFileName(entry))); + ret.Add(MutableString.Create(Path.GetFileName(entry))); } return ret; } @@ -171,7 +175,7 @@ [RubyMethod("getwd", RubyMethodAttributes.PublicSingleton)] [RubyMethod("pwd", RubyMethodAttributes.PublicSingleton)] public static MutableString/*!*/ GetCurrentDirectory(object self) { - return new MutableString(NormalizePathSeparators(Directory.GetCurrentDirectory())); + return MutableString.Create(NormalizePathSeparators(Directory.GetCurrentDirectory())); } // TODO: ruby specific pattern matching... @@ -179,28 +183,29 @@ [RubyMethod("glob", RubyMethodAttributes.PublicSingleton)] public static void Glob(CodeContext/*!*/ context, object self, BlockParam block, [NotNull]MutableString/*!*/ pattern, [Optional]int flags) { - foreach (string entry in Directory.GetFileSystemEntries(Directory.GetCurrentDirectory(), pattern)) { - if (block.BlockJumped(_GlobSite.Invoke(context, block, new MutableString(Path.GetFileName(entry))))) return; + foreach (string entry in Directory.GetFileSystemEntries(Directory.GetCurrentDirectory(), pattern.ConvertToString())) { + if (block.BlockJumped(_GlobSite.Invoke(context, block, MutableString.Create(Path.GetFileName(entry))))) return; } } [RubyMethod("glob", RubyMethodAttributes.PublicSingleton)] [RubyMethod("[]", RubyMethodAttributes.PublicSingleton)] public static RubyArray/*!*/ Glob(object self, [NotNull]MutableString/*!*/ pattern, [Optional]int flags) { - string[] rawEntries = Directory.GetFileSystemEntries(Directory.GetCurrentDirectory(), pattern); + string[] rawEntries = Directory.GetFileSystemEntries(Directory.GetCurrentDirectory(), pattern.ConvertToString()); RubyArray ret = new RubyArray(rawEntries.Length); foreach (string entry in rawEntries) { - ret.Add(new MutableString(Path.GetFileName(entry))); + ret.Add(MutableString.Create(Path.GetFileName(entry))); } return ret; } [RubyMethod("mkdir", RubyMethodAttributes.PublicSingleton)] public static int MakeDirectory(object self, [NotNull]MutableString/*!*/ dirname, [Optional]object permissions) { + string strDir = dirname.ConvertToString(); try { - Directory.CreateDirectory(dirname); + Directory.CreateDirectory(strDir); } catch (Exception ex) { - throw ToRubyException(ex, dirname, DirectoryOperation.Create); + throw ToRubyException(ex, strDir, DirectoryOperation.Create); } return 0; } @@ -276,11 +281,11 @@ MutableString ret; if (self._pos == -2) { - ret = new MutableString("."); + ret = MutableString.Create("."); } else if (self._pos == -1) { - ret = new MutableString(".."); + ret = MutableString.Create(".."); } else { - ret = new MutableString(Path.GetFileName(self._rawEntries[self._pos])); + ret = MutableString.Create(Path.GetFileName(self._rawEntries[self._pos])); } self._pos++; return ret; @@ -314,7 +319,7 @@ private void ThrowIfClosed() { if (_closed) { - throw IOErrorOps.Factory(new MutableString("closed directory")); + throw IOErrorOps.Factory(MutableString.Create("closed directory")); } } @@ -358,7 +363,7 @@ } // throw anyway - return SystemCallErrorOps.Factory(new MutableString(String.Format("unknown scenario - {0}, {1}, {2}", + return SystemCallErrorOps.Factory(MutableString.Create(String.Format("unknown scenario - {0}, {1}, {2}", exceptionType, path, op))); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/EnvironmentSingletonOps.cs;C404624 File: EnvironmentSingletonOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/EnvironmentSingletonOps.cs;C404624 (server) 5/7/2008 10:16 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/EnvironmentSingletonOps.cs;MutableString5 @@ -32,12 +32,13 @@ [RubyMethod("[]", RubyMethodAttributes.PublicInstance)] public static MutableString GetVariable(object/*!*/ self, [NotNull]MutableString/*!*/ name) { - return new MutableString(Environment.GetEnvironmentVariable(name.ToString())); + string value = Environment.GetEnvironmentVariable(name.ConvertToString()); + return (value != null) ? MutableString.Create(value) : null; } [RubyMethod("[]=", RubyMethodAttributes.PublicInstance)] public static MutableString GetVariable(object/*!*/ self, [NotNull]MutableString/*!*/ name, MutableString value) { - Environment.SetEnvironmentVariable(name.ToString(), (value != null) ? value : null); + Environment.SetEnvironmentVariable(name.ConvertToString(), (value != null) ? value.ConvertToString() : null); return value; } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Errno.cs;C390406 File: Errno.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Errno.cs;C390406 (server) 5/8/2008 1:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Errno.cs;MutableString5 @@ -31,8 +31,8 @@ internal static string/*!*/ MakeMessage(ref MutableString message, string/*!*/ baseMessage) { Assert.NotNull(baseMessage); - string result = MakeMessage(message != null ? message.ToString() : null, baseMessage); - message = new MutableString(result); + string result = MakeMessage(message != null ? message.ConvertToString() : null, baseMessage); + message = MutableString.Create(result); return result; } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ExceptionOps.cs;C422137 File: ExceptionOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ExceptionOps.cs;C422137 (server) 5/8/2008 1:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ExceptionOps.cs;MutableString5 @@ -83,7 +83,7 @@ } internal static string/*!*/ MakeMessage(MutableString message, string/*!*/ className) { - return (message == null) ? className : message.ToString(); + return (message == null) ? className : message.ConvertToString(); } #endregion @@ -107,7 +107,7 @@ Assert.NotNull(self); if (message == null) { - message = new MutableString(SymbolTable.IdToString(RubyUtils.GetExecutionContext(context).GetClassOf(self).Name)); + message = MutableString.Create(SymbolTable.IdToString(RubyUtils.GetExecutionContext(context).GetClassOf(self).Name)); } RubyExceptionData data = RubyExceptionData.GetInstance(self); @@ -173,7 +173,7 @@ return className; } - MutableString result = new MutableString(); + MutableString result = MutableString.CreateMutable(); result.Append("#<"); result.Append(className); result.Append(": "); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FalseClass.cs;C420856 File: FalseClass.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FalseClass.cs;C420856 (server) 5/8/2008 1:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FalseClass.cs;MutableString5 @@ -27,7 +27,7 @@ [RubyMethodAttribute("to_s")] public static MutableString/*!*/ ToString(bool self) { Debug.Assert(self == false); - return new MutableString("false"); + return MutableString.Create("false"); } [RubyMethodAttribute("&")] =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;C422137 File: FileOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;C422137 (server) 5/7/2008 10:16 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;MutableString5 @@ -29,12 +29,12 @@ [RubyConstructor] public static RubyIO CreateIO(CodeContext/*!*/ context, MutableString/*!*/ path) { - return new RubyFile(RubyUtils.GetExecutionContext(context), path, "r"); + return new RubyFile(RubyUtils.GetExecutionContext(context), path.ConvertToString(), "r"); } [RubyConstructor] public static RubyIO CreateIO(CodeContext/*!*/ context, MutableString/*!*/ path, [NotNull] MutableString/*!*/ modeString) { - return new RubyFile(RubyUtils.GetExecutionContext(context), path, modeString); + return new RubyFile(RubyUtils.GetExecutionContext(context), path.ConvertToString(), modeString.ConvertToString()); } #region Private Singleton Methods @@ -59,10 +59,11 @@ [RubyMethod("delete", RubyMethodAttributes.PublicSingleton)] public static int Delete(CodeContext/*!*/ context, object/*!*/ self, MutableString/*!*/ path) { - if (!File.Exists(path)) - throw new Errno.NoEntryError(String.Format("No such file or directory - {0}", path)); + string strPath = path.ConvertToString(); + if (!File.Exists(strPath)) + throw new Errno.NoEntryError(String.Format("No such file or directory - {0}", strPath)); - File.Delete(path); + File.Delete(strPath); return 1; } @@ -81,13 +82,13 @@ [RubyMethod("directory?", RubyMethodAttributes.PublicSingleton)] public static bool IsDirectory(object/*!*/ self, MutableString/*!*/ path) { - return Directory.Exists(path); + return Directory.Exists(path.ConvertToString()); } [RubyMethod("dirname", RubyMethodAttributes.PublicSingleton)] public static MutableString DirName(object/*!*/ self, MutableString/*!*/ path) { - string directoryName = System.IO.Path.GetDirectoryName(path); - return new MutableString(String.IsNullOrEmpty(directoryName) ? "." : directoryName); + string directoryName = System.IO.Path.GetDirectoryName(path.ConvertToString()); + return MutableString.Create(String.IsNullOrEmpty(directoryName) ? "." : directoryName); } //executable? @@ -96,7 +97,8 @@ [RubyMethod("exist?", RubyMethodAttributes.PublicSingleton)] [RubyMethod("exists?", RubyMethodAttributes.PublicSingleton)] public static bool Exists(object self/*!*/, MutableString/*!*/ path) { - return File.Exists(path) || Directory.Exists(path); + string strPath = path.ConvertToString(); + return File.Exists(strPath) || Directory.Exists(strPath); } [RubyMethod("exist?", RubyMethodAttributes.PublicSingleton)] @@ -115,7 +117,7 @@ [RubyMethod("join", RubyMethodAttributes.PublicSingleton)] public static MutableString Join(CodeContext/*!*/ context, object/*!*/ self, [NotNull] params object[] strings) { - MutableString result = new MutableString(); + MutableString result = MutableString.CreateMutable(); for (int i = 0; i < strings.Length; ++i) { result.Append(Protocols.ConvertToString(context, strings[i])); @@ -150,20 +152,20 @@ #else try { if (path == null || path.Length == 0) - return new MutableString(Directory.GetCurrentDirectory()); + return MutableString.Create(Directory.GetCurrentDirectory()); - if (path.Length == 1 && path[0] == '~') - return new MutableString(System.IO.Path.GetFullPath(Environment.GetEnvironmentVariable("HOME"))); + if (path.Length == 1 && path.GetChar(0) == '~') + return MutableString.Create(System.IO.Path.GetFullPath(Environment.GetEnvironmentVariable("HOME"))); - if (path[0] == '~' && (path[1] == System.IO.Path.DirectorySeparatorChar || path[1] == System.IO.Path.AltDirectorySeparatorChar)) { + if (path.GetChar(0) == '~' && (path.GetChar(1) == System.IO.Path.DirectorySeparatorChar || path.GetChar(1) == System.IO.Path.AltDirectorySeparatorChar)) { string homeDirectory = Environment.GetEnvironmentVariable("HOME"); - return path.Length < 3 ? new MutableString(homeDirectory) : new MutableString(System.IO.Path.Combine(homeDirectory, path.Substring(2))); + return path.Length < 3 ? MutableString.Create(homeDirectory) : MutableString.Create(System.IO.Path.Combine(homeDirectory, path.GetSlice(2).ConvertToString())); } else { - return new MutableString(System.IO.Path.GetFullPath(path)); + return MutableString.Create(System.IO.Path.GetFullPath(path.ConvertToString())); } } catch (Exception e) { // Re-throw exception as a reasonable Ruby exception - throw new Errno.InvalidError(path, e); + throw new Errno.InvalidError(path.ConvertToString(), e); } #endif } @@ -181,10 +183,10 @@ [RubyMethod("expand_path", RubyMethodAttributes.PublicSingleton)] public static MutableString ExpandPath(object/*!*/ self, [NotNull]MutableString/*!*/ path, [NotNull]MutableString/*!*/ basePath) { // We ignore basePath parameter if first string starts with a ~ - if (path.Length > 0 && path[0] == '~') { + if (path.Length > 0 && path.GetChar(0) == '~') { return ParsePathForProfileDir(path); } else { - return new MutableString(System.IO.Path.GetFullPath(System.IO.Path.Combine(ParsePathForProfileDir(basePath), path))); + return MutableString.Create(System.IO.Path.GetFullPath(System.IO.Path.Combine(ParsePathForProfileDir(basePath).ConvertToString(), path.ConvertToString()))); } } @@ -241,14 +243,12 @@ [RubyMethod("inspect")] public static MutableString/*!*/ Inspect(CodeContext/*!*/ context, RubyFile/*!*/ self) { - MutableString result = new MutableString(); - result.Append("#"); - return result; + return MutableString.CreateMutable("#'); } [RubyMethod("path")] public static MutableString/*!*/ Path(RubyFile/*!*/ self) { - return new MutableString(self.Path); + return MutableString.Create(self.Path); } //truncate @@ -257,12 +257,12 @@ #region Declared Constants [RubyConstant] - public readonly static MutableString ALT_SEPARATOR = new MutableString("\\"); + public readonly static MutableString ALT_SEPARATOR = MutableString.Create("\\"); [RubyConstant] - public readonly static MutableString PATH_SEPARATOR = new MutableString(";"); + public readonly static MutableString PATH_SEPARATOR = MutableString.Create(";"); - private readonly static MutableString INTERNAL_SEPARATOR = new MutableString("/"); + private readonly static MutableString INTERNAL_SEPARATOR = MutableString.Create("/"); [RubyConstant] public readonly static MutableString SEPARATOR = INTERNAL_SEPARATOR; =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FixnumOps.cs;C405838 File: FixnumOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FixnumOps.cs;C405838 (server) 5/8/2008 1:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FixnumOps.cs;MutableString5 @@ -843,7 +843,7 @@ /// 12345.to_s => "12345" [RubyMethod("to_s")] public static object ToString(object self) { - return new MutableString(self.ToString()); + return MutableString.Create(self.ToString()); } /// /// Returns a string representing the value of self using base radix. @@ -863,7 +863,7 @@ } // TODO: Should we try to use a Fixnum specific ToString? // TODO: Can we do the ToLower in BigInteger? - return new MutableString(self.ToString((uint)radix).ToLower()); + return MutableString.Create(self.ToString((uint)radix).ToLower()); } #endregion =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FloatOps.cs;C420856 File: FloatOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FloatOps.cs;C420856 (server) 5/8/2008 11:20 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FloatOps.cs;MutableString5 @@ -540,7 +540,7 @@ /// [RubyMethod("to_s")] public static MutableString ToString(CodeContext/*!*/ context, double self) { - StringFormatter sf = new StringFormatter(context, new MutableString("%.15g"), new object[] { self }); + StringFormatter sf = new StringFormatter(context, "%.15g", new object[] { self }); sf.TrailingZeroAfterWholeFloat = true; return sf.Format(); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Integer.cs;C417565 File: Integer.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Integer.cs;C417565 (server) 5/8/2008 1:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Integer.cs;MutableString5 @@ -83,7 +83,7 @@ throw RubyExceptions.CreateRangeError(intSelf.ToString() + " out of char range"); } // TODO: this is incorrect right now, and we fail some specs because we don't have byte strings - return new MutableString(((char)intSelf).ToString()); + return MutableString.Create(((char)intSelf).ToString()); } #endregion =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/IoOps.cs;C415805 File: IoOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/IoOps.cs;C415805 (server) 5/7/2008 10:16 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/IoOps.cs;MutableString5 @@ -91,7 +91,7 @@ [RubyMethod("foreach", RubyMethodAttributes.PublicSingleton)] public static void ForEach(CodeContext/*!*/ context, RubyClass/*!*/ self, BlockParam/*!*/ block, MutableString path, MutableString separator) { - using (RubyIO io = new RubyIO(RubyUtils.GetExecutionContext(context), File.OpenRead(path), "r")) + using (RubyIO io = new RubyIO(RubyUtils.GetExecutionContext(context), File.OpenRead(path.ConvertToString()), "r")) Each(context, io, block, separator); } @@ -123,10 +123,11 @@ } private static RubyIO OpenFileForRead(CodeContext/*!*/ context, MutableString/*!*/ path) { - if (!File.Exists(path)) { - throw new Errno.NoEntryError(String.Format("No such file or directory - {0}", path)); + string strPath = path.ConvertToString(); + if (!File.Exists(strPath)) { + throw new Errno.NoEntryError(String.Format("No such file or directory - {0}", strPath)); } - return new RubyIO(RubyUtils.GetExecutionContext(context), File.OpenRead(path), "r"); + return new RubyIO(RubyUtils.GetExecutionContext(context), File.OpenRead(strPath), "r"); } //pipe @@ -184,7 +185,7 @@ [RubyMethod("readlines", RubyMethodAttributes.PublicSingleton)] public static List ReadLines(CodeContext/*!*/ context, RubyClass/*!*/ self, MutableString path, MutableString separator) { - using (RubyIO io = new RubyIO(RubyUtils.GetExecutionContext(context), File.OpenRead(path), "r")) { + using (RubyIO io = new RubyIO(RubyUtils.GetExecutionContext(context), File.OpenRead(path.ConvertToString()), "r")) { return ReadLines(context, io, separator); } } @@ -304,13 +305,13 @@ } int separatorOffset = 0; - MutableString result = new MutableString(); + MutableString result = MutableString.CreateMutable(); char? c; while ((c = self.GetChar()) != null) { - result.Append(c); + result.Append(c.Value); - if (separator != null && c == separator.Chars[separatorOffset]) { + if (separator != null && c == separator.GetChar(separatorOffset)) { if (separatorOffset == separator.Length - 1) break; separatorOffset++; @@ -369,45 +370,56 @@ } [RubyMethod("print")] - public static object Print(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] string/*!*/ val) { + public static object Print(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull]string/*!*/ val) { return LibrarySites.InvokeWrite(context, self, val); } [RubyMethod("print")] - public static object Print(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] MutableString/*!*/ val) { + public static object Print(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull]MutableString/*!*/ val) { return LibrarySites.InvokeWrite(context, self, val); } [RubyMethod("print")] - public static object Print(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] params object[]/*!*/ args) { + public static object Print(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull]params object[]/*!*/ args) { MutableString delimiter = RubyUtils.GetExecutionContext(context).OutputSeparator; object result = null; for (int i = 0; i < args.Length; i++) { - string str = ToPrintedString(context, args[i]); - result = Print(context, self, delimiter == null ? str : str + delimiter); + MutableString str = ToPrintedString(context, args[i]); + if (delimiter != null) { + str.Append(delimiter); + } + result = Print(context, self, str); } return result; } //printf [RubyMethod("putc")] - public static MutableString/*!*/ Putc(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] string/*!*/ val) { - return Putc(context, self, new MutableString(val)); + public static MutableString/*!*/ Putc(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull]string/*!*/ val) { + if (val.Length == 0) { + throw RubyExceptions.CreateTypeError("can't convert String into Integer"); + } + MutableString c = MutableString.CreateMutable(1).Append(val[0]); + LibrarySites.InvokeWrite(context, self, c); + return c; } [RubyMethod("putc")] - public static MutableString/*!*/ Putc(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] MutableString/*!*/ val) { - if (val.Length == 0) + public static MutableString/*!*/ Putc(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull]MutableString/*!*/ val) { + if (val.Length == 0) { throw RubyExceptions.CreateTypeError("can't convert String into Integer"); - - LibrarySites.InvokeWrite(context, self, val[0]); - return val; + } + MutableString c = val.GetSlice(0, 1); + LibrarySites.InvokeWrite(context, self, c); + return c; } [RubyMethod("putc")] - public static int Putc(CodeContext/*!*/ context, RubyIO/*!*/ self, int chr) { - LibrarySites.InvokeWrite(context, self, Convert.ToChar(chr)); - return chr; + public static int Putc(CodeContext/*!*/ context, RubyIO/*!*/ self, int c) { + // TODO: + MutableString str = MutableString.CreateBinary(1).Append(unchecked((byte)c)); + LibrarySites.InvokeWrite(context, self, str); + return c; } [RubyMethod("putc")] @@ -415,8 +427,8 @@ return Putc(context, self, (int)Protocols.CastToInteger(context, obj)); } - public static string/*!*/ ToPrintedString(CodeContext/*!*/ context, object obj) { - MutableString str = new MutableString(); + public static MutableString/*!*/ ToPrintedString(CodeContext/*!*/ context, object obj) { + MutableString str = MutableString.CreateMutable(); List list = obj as List; IDictionary hash; @@ -430,15 +442,15 @@ str.Append((bool)obj ? "true" : "false"); } else if (obj is double) { if ((double)(int)(double)obj == (double)obj) { - str.Append(obj); + str.Append(obj.ToString()); str.Append(".0"); } else { - str.Append(obj); + str.Append(obj.ToString()); } } else { str.Append(RubySites.ToS(context, obj)); } - return str.ToString(); + return str; } [RubyMethod("puts")] @@ -447,24 +459,20 @@ } [RubyMethod("puts")] - public static object Puts(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] string/*!*/ val) { - if (!val.EndsWith("\n")) - val += "\n"; + public static object Puts(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull]MutableString/*!*/ val) { + if (!val.EndsWith('\n')) { + val = MutableString.Create(val).Append('\n'); + } return LibrarySites.InvokeWrite(context, self, val); } [RubyMethod("puts")] - public static object Puts(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] MutableString/*!*/ val) { - return Puts(context, self, val.ToString()); - } - - [RubyMethod("puts")] - public static object Puts(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] object/*!*/ val) { + public static object Puts(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull]object/*!*/ val) { return Puts(context, self, ToPrintedString(context, val)); } [RubyMethod("puts")] - public static object Puts(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull] params object[]/*!*/ vals) { + public static object Puts(CodeContext/*!*/ context, RubyIO/*!*/ self, [NotNull]params object[]/*!*/ vals) { object result = null; for (int i = 0; i < vals.Length; ++i) result = Puts(context, self, vals[i]); @@ -480,10 +488,11 @@ buffer.Clear(); for (int i = 0; i < bytes; ++i) { char? c = self.GetChar(); - if (c == null) + if (c == null) { return buffer; - else - buffer.Append(c); + } else { + buffer.Append(c.Value); + } } return buffer; } @@ -491,16 +500,17 @@ [RubyMethod("read")] public static MutableString Read(CodeContext/*!*/ context, RubyIO/*!*/ self, int bytes) { self.AssertOpenedForReading(); - return Read(context, self, bytes, new MutableString()); + return Read(context, self, bytes, MutableString.CreateMutable()); } [RubyMethod("read")] public static MutableString Read(CodeContext/*!*/ context, RubyIO/*!*/ self) { self.AssertOpenedForReading(); - MutableString result = new MutableString(); + MutableString result = MutableString.CreateMutable(); char? c; - while ((c = self.GetChar()) != null) - result.Append(c); + while ((c = self.GetChar()) != null) { + result.Append(c.Value); + } return result; } @@ -600,25 +610,13 @@ //ungetc [RubyMethod("write")] - public static int Write(RubyIO/*!*/ self, char val) { + public static int Write(RubyIO/*!*/ self, [NotNull]MutableString/*!*/ val) { self.AssertOpenedForWriting(); self.Write(val); - return 1; - } - - [RubyMethod("write")] - public static int Write(RubyIO/*!*/ self, [NotNull] string/*!*/ val) { - self.AssertOpenedForWriting(); - self.Write(val); return val.Length; } [RubyMethod("write")] - public static int Write(RubyIO/*!*/ self, [NotNull] MutableString/*!*/ val) { - return Write(self, val.ToString()); - } - - [RubyMethod("write")] public static int Write(CodeContext/*!*/ context, RubyIO/*!*/ self, object/*!*/ obj) { // TODO: make a ConvertToString and make this call it return Write(self, Protocols.ConvertToString(context, obj)); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;C434537 File: Kernel.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;C434537 (server) 5/7/2008 10:16 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;MutableString5 @@ -152,7 +152,7 @@ [RubyMethod("exit", RubyMethodAttributes.PrivateInstance)] [RubyMethod("exit", RubyMethodAttributes.PublicSingleton)] public static void Exit(CodeContext/*!*/ context, object self, int exitCode) { - throw new SystemExit(exitCode, new MutableString("exit")); + throw new SystemExit(exitCode, "exit"); } [RubyMethod("exit!", RubyMethodAttributes.PrivateInstance)] @@ -192,7 +192,7 @@ RubyArray arguments = ec.InputProvider.CommandLineArguments; // TODO: - MutableString result = new MutableString(""); + MutableString result = MutableString.Create(""); scope.LastInputLine = result; @@ -210,7 +210,7 @@ foreach (KeyValuePair global in ec.GlobalVariables) { if (global.Value.IsEnumerated) { // TODO: Ruby 1.9 returns symbols: - result.Add(new MutableString(SymbolTable.IdToString(global.Key))); + result.Add(MutableString.Create(SymbolTable.IdToString(global.Key))); } } } @@ -237,13 +237,13 @@ [RubyMethod("load", RubyMethodAttributes.PrivateInstance)] [RubyMethod("load", RubyMethodAttributes.PublicSingleton)] public static bool Load(CodeContext/*!*/ context, object self, MutableString/*!*/ libraryName) { - return RubyUtils.GetExecutionContext(context).Loader.LoadModule(context, self, libraryName, LoadFlags.None); + return RubyUtils.GetExecutionContext(context).Loader.LoadModule(context, self, libraryName.ConvertToString(), LoadFlags.None); } [RubyMethod("load", RubyMethodAttributes.PrivateInstance)] [RubyMethod("load", RubyMethodAttributes.PublicSingleton)] public static bool Load(CodeContext/*!*/ context, object self, MutableString/*!*/ libraryName, bool wrap) { - return RubyUtils.GetExecutionContext(context).Loader.LoadModule(context, self, libraryName, wrap ? LoadFlags.LoadIsolated : LoadFlags.None); + return RubyUtils.GetExecutionContext(context).Loader.LoadModule(context, self, libraryName.ConvertToString(), wrap ? LoadFlags.LoadIsolated : LoadFlags.None); } [RubyMethod("local_variables", RubyMethodAttributes.PrivateInstance)] @@ -254,7 +254,7 @@ RubyArray result = new RubyArray(symbols.Count); for (int i = 0; i < symbols.Count; i++) { - result.Add(new MutableString(symbols[i])); + result.Add(MutableString.Create(symbols[i])); } return result; } @@ -289,13 +289,13 @@ [RubyMethod("putc", RubyMethodAttributes.PrivateInstance)] [RubyMethod("putc", RubyMethodAttributes.PublicSingleton)] - public static void Putc(CodeContext/*!*/ context, object/*!*/ self, [NotNull]object arg) { + public static void Putc(CodeContext/*!*/ context, object self, [NotNull]object arg) { LibrarySites.InvokePutc(context, RubyUtils.GetExecutionContext(context).StandardOutput, arg); } [RubyMethod("puts", RubyMethodAttributes.PrivateInstance)] [RubyMethod("puts", RubyMethodAttributes.PublicSingleton)] - public static void PutString(CodeContext/*!*/ context, object/*!*/ self, [NotNull]params object[] args) { + public static void PutString(CodeContext/*!*/ context, object self, [NotNull]params object[]/*!*/ args) { LibrarySites.InvokePuts(context, RubyUtils.GetExecutionContext(context).StandardOutput, new List(args)); } @@ -407,7 +407,7 @@ str = RubySites.ToStr(context, format); } - return new StringFormatter(context, str, args).Format(); + return new StringFormatter(context, str.ConvertToString(), args).Format(); } //srand @@ -665,7 +665,7 @@ RubyArray result = new RubyArray(symbols.Length); foreach (SymbolId id in symbols) { - result.Add(new MutableString(id)); + result.Add(MutableString.Create(id)); } return result; } @@ -833,7 +833,7 @@ [RubyMethod("require")] [RubyMethod("require", RubyMethodAttributes.PublicSingleton)] public static bool Require(CodeContext/*!*/ context, object self, [NotNull]MutableString/*!*/ libraryName) { - return RubyUtils.GetExecutionContext(context).Loader.LoadModule(context, self, libraryName.ToString(), LoadFlags.LoadOnce); + return RubyUtils.GetExecutionContext(context).Loader.LoadModule(context, self, libraryName.ConvertToString(), LoadFlags.LoadOnce); } #endregion =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/LibrarySites.cs;C429806 File: LibrarySites.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/LibrarySites.cs;C429806 (server) 5/8/2008 3:39 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/LibrarySites.cs;MutableString5 @@ -197,9 +197,9 @@ return _PrecSite.Invoke(context, value, klass); } - private static DynamicSite _MatchSite = DynamicSite.Create( + private static DynamicSite _MatchSite = DynamicSite.Create( InstanceCallAction("match", ArgumentKind.Simple)); - public static object InvokeMatch(CodeContext/*!*/ context, Regexp regex, MutableString str) { + public static object InvokeMatch(CodeContext/*!*/ context, RubyRegex regex, MutableString str) { return _MatchSite.Invoke(context, regex, str); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MatchDataOps.cs;C417565 File: MatchDataOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MatchDataOps.cs;C417565 (server) 5/8/2008 1:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MatchDataOps.cs;MutableString5 @@ -39,7 +39,7 @@ [RubyMethod("[]")] public static MutableString GetGroup(Match/*!*/ self, int i) { i = IListOps.NormalizeIndex(self.Groups.Count, i); - return (i >= 0 && i < self.Groups.Count) ? new MutableString(self.Groups[i].Value) : null; + return (i >= 0 && i < self.Groups.Count) ? MutableString.Create(self.Groups[i].Value) : null; } [RubyMethod("[]")] =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C434537 File: ModuleOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C434537 (server) 5/8/2008 1:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;MutableString5 @@ -555,7 +555,7 @@ RubyArray result = new RubyArray(); self.ForEachClassVariable(true, delegate(RubyModule/*!*/ module, SymbolId name, object value) { if (!name.IsEmpty && !visited.ContainsKey(name)) { - result.Add(new MutableString(name)); + result.Add(MutableString.Create(name)); visited.Add(name, true); } return false; @@ -627,7 +627,7 @@ if (!visited.ContainsKey(name)) { visited.Add(name, true); - result.Add(new MutableString(name)); + result.Add(MutableString.Create(name)); } return false; }); @@ -728,7 +728,7 @@ } else if (method.IsUndefined) { visited.Add(name, true); } else if (((RubyMethodAttributes)method.Visibility & attributes) != 0 && !visited.ContainsKey(name)) { - result.Add(new MutableString(name)); + result.Add(MutableString.Create(name)); visited.Add(name, true); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs;C428766 File: MutableStringOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs;C428766 (server) 5/7/2008 10:16 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs;MutableString5 @@ -49,6 +49,16 @@ [Includes(typeof(Enumerable), typeof(Comparable))] public class MutableStringOps { + [RubyConstructor] + public static MutableString/*!*/ Create(CodeContext/*!*/ context) { + return MutableString.CreateMutable(); + } + + [RubyConstructor] + public static MutableString/*!*/ Create(CodeContext/*!*/ context, [NotNull]MutableString/*!*/ str) { + return MutableString.Create(str); + } + #region Helpers private static readonly DynamicSite/*!*/ @@ -86,23 +96,23 @@ // \x00-0xDD # all characters in hex range public class IntervalParser { - private string _range; + private readonly MutableString/*!*/ _range; private int _pos; private bool _rangeStarted; private char _startRange; - public IntervalParser(string range) { + public IntervalParser(MutableString/*!*/ range) { _range = range; _pos = 0; _rangeStarted = false; } public char? PeekChar() { - return _pos >= _range.Length ? (char?)null : _range[_pos]; + return _pos >= _range.Length ? (char?)null : _range.GetChar(_pos); } public char? GetChar() { - return _pos >= _range.Length ? (char?)null : _range[_pos++]; + return _pos >= _range.Length ? (char?)null : _range.GetChar(_pos++); } public int HexToInt(char? c) { @@ -168,15 +178,15 @@ public MutableString/*!*/ ParseSequence() { _pos = 0; - MutableString result = new MutableString(); + MutableString result = MutableString.CreateMutable(); if (_range.Length == 0) return result; bool negate = false; - if (_range[0] == '^') { + if (_range.GetChar(0) == '^') { // Special case of ^ if (_range.Length == 1) { - result.Append("^"); + result.Append('^'); return result; } @@ -193,10 +203,11 @@ // _startRange - c. ignore ranges which are the reverse sequence if (_startRange <= c) { for (int i = _startRange; i <= c; ++i) { - if (negate) + if (negate) { array.Set(i, false); - else + } else { result.Append((char)i); + } } } _rangeStarted = false; @@ -209,7 +220,7 @@ array.Set((char)c, false); array.Set('-', false); } else { - result.Append(c); + result.Append(c.Value); result.Append('-'); } break; @@ -217,20 +228,22 @@ _startRange = (char)c; if (_rangeStarted) { - if (negate) + if (negate) { array.Set('-', false); - else + } else { result.Append('-'); + } _rangeStarted = false; } else { _rangeStarted = true; } _pos++; // consume - } else { - if (negate) + if (negate) { array.Set((char)c, false); - else - result.Append(c); + } else { + result.Append(c.Value); + } } } } @@ -253,7 +266,7 @@ return result; bool negate = false; - if (_range[0] == '^') { + if (_range.GetChar(0) == '^') { // Special case of ^ if (_range.Length == 1) { result.Set('^', true); @@ -304,9 +317,9 @@ public class RangeParser { - private string[]/*!*/ _ranges; + private readonly MutableString[]/*!*/ _ranges; - public RangeParser(params string[]/*!*/ ranges) { + public RangeParser(params MutableString[]/*!*/ ranges) { ContractUtils.RequiresNotNull(ranges, "ranges"); _ranges = ranges; } @@ -365,7 +378,7 @@ if (args == null) { args = new object[] { arg }; } - StringFormatter formatter = new StringFormatter(context, self, args); + StringFormatter formatter = new StringFormatter(context, self.ConvertToString(), args); return Kernel.FlowTaint(context, self, formatter.Format()); } @@ -374,24 +387,22 @@ #region * [RubyMethod("*")] - public static MutableString Repeat(MutableString/*!*/ self, int times) { - if (times < 0) + public static MutableString/*!*/ Repeat(CodeContext/*!*/ context, MutableString/*!*/ self, int times) { + if (times < 0) { throw RubyExceptions.CreateArgumentError("negative argument"); + } - if (times == 0) { - self.Clear(); - } else { - string current = self.Chars.ToString(); - for (int i = 0; i < times - 1; ++i) - self.Append(current); + MutableString result = MutableString.CreateMutable(); + for (int i = 0; i < times; i++) { + result.Append(self); } - return self; + return Kernel.FlowTaint(context, self, CreateSubClass(context, self, result)); } [RubyMethod("*")] public static MutableString Repeat(CodeContext/*!*/ context, MutableString/*!*/ self, object times) { - return Repeat(self, Protocols.CastToFixnum(context, times)); + return Repeat(context, self, Protocols.CastToFixnum(context, times)); } #endregion @@ -408,7 +419,7 @@ [RubyMethod("+")] public static MutableString Concatenate(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]MutableString/*!*/ other) { - return Kernel.FlowTaint(context, self, other, new MutableString(self).Append(other)); + return Kernel.FlowTaint(context, self, other, MutableString.Create(self).Append(other)); } [RubyMethod("+")] @@ -547,7 +558,7 @@ #region slice! - private static Group MatchRegexp(CodeContext/*!*/ context, MutableString/*!*/ self, Regexp regex, int occurrance) { + private static Group MatchRegexp(CodeContext/*!*/ context, MutableString/*!*/ self, RubyRegex regex, int occurrance) { Match match = RegexpOps.Match(context, regex, self); if (match == null || !match.Success) return null; @@ -568,12 +579,14 @@ [RubyMethod("slice!")] public static object RemoveCharInPlace(CodeContext/*!*/ context, MutableString/*!*/ self, int index) { - if (!InRangeNormalized(self, ref index)) + if (!InRangeNormalized(self, ref index)) { return null; + } Kernel.RequiresNotFrozen(context, self); - object result = (object)(int)self[index]; + // TODO: optimize if the value is not read: + int result = self.PeekByte(index); self.Remove(index, 1); return result; } @@ -597,7 +610,7 @@ length = self.Length - start; } - MutableString result = CreateSubClass(context, self, self.Substring(start, length)); + MutableString result = CreateSubClass(context, self, self.GetSlice(start, length)); self.Remove(start, length); return Kernel.FlowTaint(context, self, result); } @@ -632,40 +645,45 @@ } [RubyMethod("slice!")] - public static MutableString RemoveCharInPlace(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]Regexp/*!*/ regex) { - if (regex.Regex.ToString() == String.Empty) + public static MutableString RemoveCharInPlace(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]RubyRegex/*!*/ regex) { + if (regex.IsEmpty) { return Kernel.FlowTaint(context, self, regex, CreateSubClass(context, self)); + } Match match = RegexpOps.Match(context, regex, self); - if (match == null || !match.Success) + if (match == null || !match.Success) { return null; + } return Kernel.FlowTaint(context, regex, RemoveCharInPlace(context, self, match.Index, match.Length)); } [RubyMethod("slice!")] - public static MutableString RemoveCharInPlace(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]Regexp/*!*/ regex, int occurrance) { - if (regex.Regex.ToString() == String.Empty) + public static MutableString RemoveCharInPlace(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]RubyRegex/*!*/ regex, int occurrance) { + if (regex.IsEmpty) { return Kernel.FlowTaint(context, self, regex, CreateSubClass(context, self)); + } Group group = MatchRegexp(context, self, regex, occurrance); return group == null ? null : Kernel.FlowTaint(context, regex, RemoveCharInPlace(context, self, group.Index, group.Length)); } [RubyMethod("slice!")] - public static MutableString RemoveCharInPlace(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]Regexp/*!*/ regex, [NotNull]object/*!*/ occurrance) { + public static MutableString RemoveCharInPlace(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]RubyRegex/*!*/ regex, [NotNull]object/*!*/ occurrance) { return RemoveCharInPlace(context, self, regex, Protocols.CastToFixnum(context, occurrance)); } [RubyMethod("slice!")] public static MutableString RemoveCharInPlace(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]MutableString/*!*/ searchStr) { // Odd behavior: taint only flows from searchStr and *not* self. Seems like a bug in Ruby to me. - if (searchStr.Length == 0) + if (searchStr.Length == 0) { return Kernel.FlowTaint(context, searchStr, CreateSubClass(context, self)); + } - int index = self.ToString().IndexOf(searchStr); - if (index < 0) + int index = self.IndexOf(searchStr); + if (index < 0) { return null; + } RemoveCharInPlace(context, self, index, searchStr.Length); return Kernel.FlowTaint(context, searchStr, CreateSubClass(context, searchStr, searchStr)); @@ -678,7 +696,7 @@ [RubyMethod("[]")] [RubyMethod("slice")] public static object GetChar(MutableString/*!*/ self, int index) { - return InRangeNormalized(self, ref index) ? (object)(int)self[index] : null; + return InRangeNormalized(self, ref index) ? (object)(int)self.GetByte(index) : null; } [RubyMethod("[]")] @@ -701,7 +719,7 @@ if (start + length > self.Length) length = self.Length - start; - return Kernel.FlowTaint(context, self, CreateSubClass(context, self, self.Substring(start, length))); + return Kernel.FlowTaint(context, self, CreateSubClass(context, self, self.GetSlice(start, length))); } [RubyMethod("[]")] @@ -740,36 +758,43 @@ [RubyMethod("[]")] [RubyMethod("slice")] public static MutableString GetChars(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]MutableString/*!*/ searchStr) { - return self.ToString().Contains(searchStr.ToString()) ? Kernel.FlowTaint(context, self, searchStr, CreateSubClass(context, searchStr, searchStr)) : null; + if (self.IndexOf(searchStr) != -1) { + return Kernel.FlowTaint(context, self, searchStr, CreateSubClass(context, searchStr, searchStr)); + } else { + return null; + } } [RubyMethod("[]")] [RubyMethod("slice")] - public static MutableString GetChars(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]Regexp/*!*/ regex) { - if (regex.Regex.ToString() == String.Empty) + public static MutableString GetChars(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]RubyRegex/*!*/ regex) { + if (regex.IsEmpty) { return Kernel.FlowTaint(context, self, regex, CreateSubClass(context, self)); + } Match match = RegexpOps.Match(context, regex, self); - if (match == null) + if (match == null) { return null; + } string result = match.Value; - return result == String.Empty ? null : Kernel.FlowTaint(context, self, regex, CreateSubClass(context, self, new MutableString(result))); + return result == String.Empty ? null : Kernel.FlowTaint(context, self, regex, CreateSubClass(context, self, MutableString.Create(result))); } [RubyMethod("[]")] [RubyMethod("slice")] - public static MutableString GetChars(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]Regexp/*!*/ regex, int occurrance) { - if (regex.Regex.ToString() == String.Empty) + public static MutableString GetChars(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]RubyRegex/*!*/ regex, int occurrance) { + if (regex.IsEmpty) { return Kernel.FlowTaint(context, self, regex, CreateSubClass(context, self)); + } Group group = MatchRegexp(context, self, regex, occurrance); - return group == null ? null : Kernel.FlowTaint(context, self, regex, CreateSubClass(context, self, new MutableString(group.Value))); + return group == null ? null : Kernel.FlowTaint(context, self, regex, CreateSubClass(context, self, MutableString.Create(group.Value))); } [RubyMethod("[]")] [RubyMethod("slice")] - public static MutableString GetChars(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]Regexp/*!*/ regex, object occurrance) { + public static MutableString GetChars(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]RubyRegex/*!*/ regex, object occurrance) { return GetChars(context, self, regex, Protocols.CastToFixnum(context, occurrance)); } @@ -779,7 +804,7 @@ public static MutableString/*!*/ RemoveChar(MutableString/*!*/ self, int index) { self.Remove(index, 1); - return new MutableString(); + return MutableString.CreateMutable(); } [RubyMethod("[]=")] @@ -795,8 +820,8 @@ return RemoveChar(self, index); } - self[index] = value[value.Length - 1]; - self.Insert(index, value.Substring(0, value.Length - 1)); + self.Replace(index, 1, value); + Kernel.FlowTaint(context, value, self); return value; } @@ -806,10 +831,11 @@ Kernel.RequiresNotFrozen(context, self); index = index < 0 ? index + self.Length : index; - if (index < 0 || index >= self.Length) + if (index < 0 || index >= self.Length) { throw RubyExceptions.CreateIndexError(String.Format("index {0} out of string", index)); + } - self[index] = (char)((int)value & 0xFF); + self.SetByte(index, unchecked((byte)value)); return value; } @@ -833,7 +859,8 @@ } [RubyMethod("[]=")] - public static MutableString SetChar(CodeContext/*!*/ context, MutableString/*!*/ self, int start, int charsToOverwrite, [NotNull]MutableString/*!*/ value) { + public static MutableString SetChar(CodeContext/*!*/ context, MutableString/*!*/ self, int start, int charsToOverwrite, + [NotNull]MutableString/*!*/ value) { Kernel.RequiresNotFrozen(context, self); if (charsToOverwrite < 0) @@ -852,18 +879,15 @@ insertIndex = self.Length; } - for (int i = 0; i < limit; ++i) - self[start + i] = value[i]; - - Insert(context, self, insertIndex, value.Substring(limit)); + self.Replace(start, limit, value); } else { int deleteIndex = start + value.Length; int limit = value.Length; if (deleteIndex > self.Length) { + // TODO: ??? } - for (int i = 0; i < value.Length; ++i) - self[start + i] = value[i]; + self.Replace(start, value.Length, value); int pos = start + value.Length; int charsToRemove = charsToOverwrite - value.Length; @@ -901,30 +925,30 @@ #region casecmp, capitalize, capitalize!, downcase, downcase!, swapcase, swapcase!, upcase, upcase! public static bool UpCaseChar(MutableString/*!*/ self, int index) { - char current = self.Chars[index]; + char current = self.GetChar(index); if (current >= 'a' && current <= 'z') { - self.Chars[index] = Char.ToUpper(current); + self.SetChar(index, Char.ToUpper(current)); return true; } return false; } public static bool DownCaseChar(MutableString/*!*/ self, int index) { - char current = self.Chars[index]; + char current = self.GetChar(index); if (current >= 'A' && current <= 'Z') { - self.Chars[index] = Char.ToLower(current); + self.SetChar(index, Char.ToLower(current)); return true; } return false; } public static bool SwapCaseChar(MutableString/*!*/ self, int index) { - char current = self.Chars[index]; + char current = self.GetChar(index); if (current >= 'A' && current <= 'Z') { - self.Chars[index] = Char.ToLower(current); + self.SetChar(index, Char.ToLower(current)); return true; } else if (current >= 'a' && current <= 'z') { - self.Chars[index] = Char.ToUpper(current); + self.SetChar(index, Char.ToUpper(current)); return true; } return false; @@ -992,7 +1016,7 @@ [RubyMethod("capitalize")] public static MutableString/*!*/ Capitalize(CodeContext/*!*/ context, MutableString/*!*/ self) { - MutableString result = new MutableString(self); + MutableString result = MutableString.Create(self); CapitalizeMutableString(result); return Kernel.FlowTaint(context, self, CreateSubClass(context, self, result)); } @@ -1014,7 +1038,7 @@ [RubyMethod("downcase")] public static MutableString/*!*/ DownCase(CodeContext/*!*/ context, MutableString/*!*/ self) { - MutableString result = new MutableString(self); + MutableString result = MutableString.Create(self); DownCaseMutableString(result); return Kernel.FlowTaint(context, self, CreateSubClass(context, self, result)); } @@ -1037,7 +1061,7 @@ [RubyMethod("swapcase")] public static MutableString/*!*/ SwapCase(CodeContext/*!*/ context, MutableString/*!*/ self) { - MutableString result = new MutableString(self); + MutableString result = MutableString.Create(self); SwapCaseMutableString(result); return Kernel.FlowTaint(context, self, CreateSubClass(context, self, result)); } @@ -1059,7 +1083,7 @@ [RubyMethod("upcase")] public static MutableString/*!*/ UpCase(CodeContext/*!*/ context, MutableString/*!*/ self) { - MutableString result = new MutableString(self); + MutableString result = MutableString.Create(self); UpCaseMutableString(result); return Kernel.FlowTaint(context, self, CreateSubClass(context, self, result)); } @@ -1081,21 +1105,25 @@ return self; } if (padding == null) { - padding = new MutableString(" "); + padding = MutableString.Create(" "); } + char[] charArray = new char[length]; int n = (length - self.Length) / 2; + for (int i = 0; i < n; i++) { - charArray[i] = padding[(i % padding.Length)]; + charArray[i] = padding.GetChar(i % padding.Length); } + for (int i = 0; i < self.Length; i++) { - charArray[n + i] = self[i]; + charArray[n + i] = self.GetChar(i); } + int m = length - self.Length - n; for (int i = 0; i < m; i++) { - charArray[n + self.Length + i] = padding[(i % padding.Length)]; + charArray[n + self.Length + i] = padding.GetChar(i % padding.Length); } - return new MutableString(new string(charArray)); + return MutableString.Create(new string(charArray)); } //----------------------------------------------------------- String#chomp @@ -1122,11 +1150,21 @@ if (offset < 0) { return false; } - for (int i = 0; i < terminator.Length; i++) { - if (str[offset + i] != terminator[i]) { - return false; + + if (str.IsBinary) { + for (int i = 0; i < terminator.Length; i++) { + if (str.GetChar(offset + i) != terminator.GetChar(i)) { + return false; + } } + } else { + for (int i = 0; i < terminator.Length; i++) { + if (str.GetByte(offset + i) != terminator.GetByte(i)) { + return false; + } + } } + return true; } @@ -1134,16 +1172,16 @@ int end = str.Length; while (true) { if (end > 1) { - if (str[end - 1] == '\n') { - end -= str[end - 2] == '\r' ? 2 : 1; - } else if (removeCarriageReturnsToo && str[end - 1] == '\r') { + if (str.GetChar(end - 1) == '\n') { + end -= str.GetChar(end - 2) == '\r' ? 2 : 1; + } else if (removeCarriageReturnsToo && str.GetChar(end - 1) == '\r') { end -= 1; } else { break; } } else if (end > 0) { - if (str[end - 1] == '\n' || str[end - 1] == '\r') { + if (str.GetChar(end - 1) == '\n' || str.GetChar(end - 1) == '\r') { end -= 1; } break; @@ -1151,7 +1189,7 @@ break; } } - return str.Substring(0, end); + return str.GetSlice(0, end); } private static MutableString InternalChomp(CodeContext/*!*/ context, MutableString/*!*/ self, MutableString separator) { @@ -1163,12 +1201,12 @@ return Kernel.FlowTaint(context, self, ChompTrailingCarriageReturns(self, false)); // Remove single trailing CR/LFs - MutableString result = Kernel.FlowTaint(context, self, CreateSubClass(context, self, new MutableString(self))); + MutableString result = Kernel.FlowTaint(context, self, CreateSubClass(context, self, MutableString.Create(self))); int length = result.Length; - if (separator.Length == 1 && separator[0] == '\n') { - if (length > 1 && result[length - 2] == '\r' && result[length - 1] == '\n') { + if (separator.Length == 1 && separator.GetChar(0) == '\n') { + if (length > 1 && result.GetChar(length - 2) == '\r' && result.GetChar(length - 1) == '\n') { result.Remove(length - 2, 2); - } else if (length > 0 && (self[length - 1] == '\n' || result[length - 1] == '\r')) { + } else if (length > 0 && (self.GetChar(length - 1) == '\n' || result.GetChar(length - 1) == '\r')) { result.Remove(length - 1, 1); } } else if (EndsWith(result, separator)) { @@ -1235,7 +1273,7 @@ // "x".chop.chop #=> "" private static MutableString Chop(MutableString/*!*/ self) { - if (self.Length == 1 || self[self.Length - 2] != '\r' || self[self.Length - 1] != '\n') { + if (self.Length == 1 || self.GetChar(self.Length - 2) != '\r' || self.GetChar(self.Length - 1) != '\n') { self.Remove(self.Length - 1, 1); } else { self.Remove(self.Length - 2, 2); @@ -1252,7 +1290,7 @@ [RubyMethod("chop")] public static MutableString Chop(CodeContext/*!*/ context, MutableString/*!*/ self) { - MutableString result = self.Length == 0 ? new MutableString() : Chop(new MutableString(self)); + MutableString result = self.Length == 0 ? MutableString.CreateMutable() : Chop(MutableString.Create(self)); return Kernel.FlowTaint(context, self, CreateSubClass(context, self, result)); } @@ -1294,19 +1332,20 @@ case '#': return "\\#"; default: - if (c < 32 || c > 126) + if (c < 32 || c > 126) { return GetOctalRepresentationOfChar(c); - else + } else { return c.ToString(); + } } } [RubyMethod("dump")] [RubyMethod("inspect")] public static MutableString/*!*/ Dump(CodeContext/*!*/ context, MutableString/*!*/ self) { - MutableString result = new MutableString(); + MutableString result = MutableString.CreateMutable(); result.Append("\""); - foreach (char c in self.ToString()) { + foreach (char c in self.ConvertToString()) { result.Append(GetStringRepresentationOfChar(c)); } result.Append("\""); @@ -1336,7 +1375,7 @@ int i = 0; while (i < str.Length) { - object result = EachByteSharedSite.Invoke(context, block, str[i]); + object result = EachByteSharedSite.Invoke(context, block, str.GetByte(i)); if (block.BlockJumped(result)) return result; i++; } @@ -1381,14 +1420,16 @@ [RubyMethod("each_line")] public static object EachLine(CodeContext/*!*/ context, MutableString/*!*/ self, BlockParam block, [NotNull]MutableString/*!*/ separator) { bool paragraphMode = false; - string sep = separator; + MutableString sep = separator; if (separator.Length == 0) { paragraphMode = true; - sep = "\n"; + sep = MutableString.Create("\n"); } + MutableString doubleSep = (paragraphMode) ? MutableString.Create(sep).Append(sep) : null; + // TODO: this is slow, refactor when we redo MutableString - string str = self; + MutableString str = self; int start = 0; // In "normal" mode just split the string at the end of each seperator occurrance. @@ -1404,7 +1445,7 @@ end = str.Length; } } else { - end = str.IndexOf(sep + sep, start); + end = str.IndexOf(doubleSep, start); if (end >= 0) { end += (2 * sep.Length); while (str.IndexOf(sep, end) == end) { @@ -1416,7 +1457,7 @@ } // Yield the current line - MutableString line = new MutableString(str.Substring(start, end - start)); + MutableString line = MutableString.Create(str.GetSlice(start, end - start)); if (block.BlockJumped(_EachBlockSite.Invoke(context, block, Kernel.FlowTaint(context, self, CreateSubClass(context, self, line))))) return self; @@ -1525,19 +1566,19 @@ CallSiteFactory.CreateSimpleCallSite(RubyContext.RubyBinder); private static int InvokeReplaceBlock(Match/*!*/ match, MutableString/*!*/ self, MutableString/*!*/ result, CodeContext/*!*/ context, BlockParam/*!*/ block, int offset) { - object blockResult = ReplaceSharedSite.Invoke(context, block, new MutableString(match.Value)); + object blockResult = ReplaceSharedSite.Invoke(context