edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/AssertTokenizer.cs;C392185 File: AssertTokenizer.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/AssertTokenizer.cs;C392185 (server) 5/19/2008 9:33 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/AssertTokenizer.cs;RegexOptions @@ -21,6 +21,7 @@ using Ruby.Compiler; using Ruby.Runtime; using Ruby.Compiler.Ast; +using Ruby.Builtins; namespace Ruby.Tests { internal class AssertTokenizer { @@ -104,7 +105,7 @@ return this; } - public AssertTokenizer/*!*/ Read(RegExOptions expected) { + public AssertTokenizer/*!*/ Read(RubyRegexOptions expected) { Next(); Tests.Assert(_actualToken == Tokens.RegexpEnd); Tests.Assert(_actualValue.Type == TokenValueType.RegexOptions); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/ParserTests.cs;C443223 File: ParserTests.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/ParserTests.cs;C443223 (server) 5/19/2008 9:33 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/ParserTests.cs;RegexOptions @@ -27,6 +27,7 @@ using Ruby.Compiler; using Ruby.Compiler.Ast; using Ruby.Runtime; +using Ruby.Builtins; namespace Ruby.Tests { public partial class Tests { @@ -293,10 +294,10 @@ t.Load("//")[Tokens.RegexpBeg][Tokens.RegexpEnd].EOF(); t.Load("/foo/")[Tokens.RegexpBeg]["foo"][Tokens.RegexpEnd].EOF(); - t.Load("/foo/aib").Skip(2).Read(RegExOptions.IGNORECASE).Expect(Errors.UnknownRegexOption, Errors.UnknownRegexOption); + t.Load("/foo/aib").Skip(2).Read(RubyRegexOptions.IgnoreCase).Expect(Errors.UnknownRegexOption, Errors.UnknownRegexOption); t.Load("/foo/9").Skip(2).Read(Tokens.RegexpEnd); // TODO: unexpected token 9 t.Load("/foo/esuniiimmmxxxooo").Skip(2). - Read(RegExOptions.IGNORECASE | RegExOptions.MULTILINE | RegExOptions.EXTENDED | RegExOptions.FIXED | RegExOptions.UTF8); + Read(RubyRegexOptions.IgnoreCase | RubyRegexOptions.Multiline | RubyRegexOptions.Extended | RubyRegexOptions.FIXED | RubyRegexOptions.UTF8); t.Expect(); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/TokenizerTestDriver.cs;C390406 File: TokenizerTestDriver.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/TokenizerTestDriver.cs;C390406 (server) 5/19/2008 9:33 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/TokenizerTestDriver.cs;RegexOptions @@ -26,6 +26,7 @@ using Ruby.Compiler.Ast; using Microsoft.Scripting.Runtime; using Ruby.Runtime; +using Ruby.Builtins; namespace Ruby.Tests { public class TokenizerTestDriver { @@ -262,7 +263,7 @@ break; case TokenValueType.RegexOptions: - output.Write("RegexOptions({0})", (RegExOptions)value.Integer); + output.Write("RegexOptions({0})", (RubyRegexOptions)value.Integer); break; case TokenValueType.String: =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;C443395 File: Initializers.Generated.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;C443395 (server) 5/19/2008 9:46 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;RegexOptions @@ -26,7 +26,7 @@ // Skipped primitive: __ClassSingleton // Skipped primitive: __MainSingleton - Ruby.Builtins.RubyModule def21 = DefineGlobalModule("Comparable", typeof(Ruby.Builtins.Comparable), new System.Action(LoadComparable_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); + Ruby.Builtins.RubyModule def22 = DefineGlobalModule("Comparable", typeof(Ruby.Builtins.Comparable), new System.Action(LoadComparable_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); Ruby.Builtins.RubyModule def2 = DefineGlobalModule("Enumerable", typeof(Ruby.Builtins.Enumerable), new System.Action(LoadEnumerable_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); Ruby.Builtins.RubyModule def5 = DefineGlobalModule("Errno", typeof(Ruby.Builtins.Errno), null, null, Ruby.Builtins.RubyModule.EmptyArray); DefineGlobalModule("Fcntl", typeof(Ruby.Builtins.Fcntl), new System.Action(LoadFcntl_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); @@ -45,10 +45,10 @@ #endif // Skipped primitive: Object ExtendModule(typeof(System.Collections.Generic.IDictionary), new System.Action(LoadSystem__Collections__Generic__IDictionary_Instance), null, new Ruby.Builtins.RubyModule[] {def2, }); - Ruby.Builtins.RubyModule def25 = ExtendModule(typeof(System.Collections.IEnumerable), new System.Action(LoadSystem__Collections__IEnumerable_Instance), null, new Ruby.Builtins.RubyModule[] {def2, }); + Ruby.Builtins.RubyModule def26 = ExtendModule(typeof(System.Collections.IEnumerable), new System.Action(LoadSystem__Collections__IEnumerable_Instance), null, new Ruby.Builtins.RubyModule[] {def2, }); ExtendModule(typeof(System.Collections.IList), new System.Action(LoadSystem__Collections__IList_Instance), null, new Ruby.Builtins.RubyModule[] {def2, }); - ExtendModule(typeof(System.IComparable), new System.Action(LoadSystem__IComparable_Instance), null, new Ruby.Builtins.RubyModule[] {def21, }); - DefineGlobalClass("Time", typeof(System.DateTime), classRef0, new System.Action(LoadTime_Instance), new System.Action(LoadTime_Class), new Ruby.Builtins.RubyModule[] {def21, }, new System.Delegate[] { + ExtendModule(typeof(System.IComparable), new System.Action(LoadSystem__IComparable_Instance), null, new Ruby.Builtins.RubyModule[] {def22, }); + DefineGlobalClass("Time", typeof(System.DateTime), classRef0, new System.Action(LoadTime_Instance), new System.Action(LoadTime_Class), new Ruby.Builtins.RubyModule[] {def22, }, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TimeOps.Create), }); DefineGlobalClass("Array", typeof(Ruby.Builtins.RubyArray), Context.ObjectClass, new System.Action(LoadArray_Instance), new System.Action(LoadArray_Class), new Ruby.Builtins.RubyModule[] {def2, }, new System.Delegate[] { @@ -61,7 +61,7 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ArrayOps.CreateArray), }); DefineGlobalClass("Binding", typeof(Ruby.Builtins.Binding), Context.ObjectClass, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("ClrString", typeof(System.String), Context.ObjectClass, new System.Action(LoadClrString_Instance), null, new Ruby.Builtins.RubyModule[] {def25, }, null); + DefineGlobalClass("ClrString", typeof(System.String), Context.ObjectClass, new System.Action(LoadClrString_Instance), null, new Ruby.Builtins.RubyModule[] {def26, }, null); DefineGlobalClass("Dir", typeof(Ruby.Builtins.RubyDir), Context.ObjectClass, new System.Action(LoadDir_Instance), new System.Action(LoadDir_Class), new Ruby.Builtins.RubyModule[] {def2, }, null); Ruby.Builtins.RubyClass def3 = DefineClass("Enumerable::Enumerator", typeof(Ruby.Builtins.Enumerable.Enumerator), Context.ObjectClass, null, null, new Ruby.Builtins.RubyModule[] {def2, }, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Enumerable.Enumerator.CreateForEach), @@ -69,7 +69,7 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Enumerable.Enumerator.Create), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Enumerable.Enumerator.Create), }); - Ruby.Builtins.RubyClass def22 = Context.ExceptionClass = DefineGlobalClass("Exception", typeof(System.Exception), Context.ObjectClass, new System.Action(LoadException_Instance), new System.Action(LoadException_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def23 = Context.ExceptionClass = DefineGlobalClass("Exception", typeof(System.Exception), Context.ObjectClass, new System.Action(LoadException_Instance), new System.Action(LoadException_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ExceptionOps.Factory), }); Context.FalseClass = DefineGlobalClass("FalseClass", typeof(Ruby.Builtins.FalseClass), Context.ObjectClass, new System.Action(LoadFalseClass_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); @@ -77,7 +77,7 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.HashOps.Hash), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.HashOps.Hash), }); - Ruby.Builtins.RubyClass def23 = DefineGlobalClass("IO", typeof(Ruby.Builtins.RubyIO), Context.ObjectClass, new System.Action(LoadIO_Instance), new System.Action(LoadIO_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def24 = DefineGlobalClass("IO", typeof(Ruby.Builtins.RubyIO), Context.ObjectClass, new System.Action(LoadIO_Instance), new System.Action(LoadIO_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.CreateIO), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.CreateIO), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.CreateIO), @@ -86,7 +86,7 @@ DefineGlobalClass("Method", typeof(Ruby.Builtins.RubyMethod), Context.ObjectClass, new System.Action(LoadMethod_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); // Skipped primitive: Module Context.NilClass = DefineGlobalClass("NilClass", typeof(Microsoft.Scripting.None), Context.ObjectClass, new System.Action(LoadNilClass_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def17 = DefineGlobalClass("Numeric", typeof(Ruby.Builtins.Numeric), Context.ObjectClass, new System.Action(LoadNumeric_Instance), null, new Ruby.Builtins.RubyModule[] {def21, }, null); + Ruby.Builtins.RubyClass def17 = DefineGlobalClass("Numeric", typeof(Ruby.Builtins.Numeric), Context.ObjectClass, new System.Action(LoadNumeric_Instance), null, new Ruby.Builtins.RubyModule[] {def22, }, null); DefineGlobalClass("Proc", typeof(Ruby.Builtins.Proc), Context.ObjectClass, new System.Action(LoadProc_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ProcOps.CreateProc), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ProcOps.CreateProc), @@ -100,10 +100,11 @@ 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), Context.ObjectClass, new System.Action(LoadString_Instance), null, new Ruby.Builtins.RubyModule[] {def2, def21, }, new System.Delegate[] { + DefineGlobalClass("String", typeof(Ruby.Builtins.MutableString), Context.ObjectClass, new System.Action(LoadString_Instance), null, new Ruby.Builtins.RubyModule[] {def2, def22, }, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Create), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Create), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.MutableStringOps.Create), @@ -117,72 +118,74 @@ Context.TrueClass = DefineGlobalClass("TrueClass", typeof(Ruby.Builtins.TrueClass), Context.ObjectClass, new System.Action(LoadTrueClass_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); DefineGlobalClass("UnboundMethod", typeof(Ruby.Builtins.UnboundMethod), Context.ObjectClass, new System.Action(LoadUnboundMethod_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); // Skipped primitive: Class - DefineGlobalClass("File", typeof(Ruby.Builtins.RubyFile), def23, new System.Action(LoadFile_Instance), new System.Action(LoadFile_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("File", typeof(Ruby.Builtins.RubyFile), def24, new System.Action(LoadFile_Instance), new System.Action(LoadFile_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyFileOps.CreateIO), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyFileOps.CreateIO), }); DefineGlobalClass("Float", typeof(System.Double), def17, new System.Action(LoadFloat_Instance), new System.Action(LoadFloat_Class), new Ruby.Builtins.RubyModule[] {def18, }, null); Ruby.Builtins.RubyClass def13 = DefineGlobalClass("Integer", typeof(Ruby.Builtins.Integer), def17, new System.Action(LoadInteger_Instance), new System.Action(LoadInteger_Class), new Ruby.Builtins.RubyModule[] {def18, }, null); - DefineGlobalClass("NoMemoryError", typeof(Ruby.Builtins.NoMemoryError), def22, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); - Ruby.Builtins.RubyClass def19 = DefineGlobalClass("ScriptError", typeof(Ruby.Builtins.ScriptError), def22, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("NoMemoryError", typeof(Ruby.Builtins.NoMemoryError), def23, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def20 = DefineGlobalClass("ScriptError", typeof(Ruby.Builtins.ScriptError), def23, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ScriptErrorOps.Factory), }); - Ruby.Builtins.RubyClass def20 = Context.StandardErrorClass = DefineGlobalClass("StandardError", typeof(System.SystemException), def22, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def19 = DefineGlobalClass("SignalException", typeof(Ruby.Builtins.SignalException), def23, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def21 = Context.StandardErrorClass = DefineGlobalClass("StandardError", typeof(System.SystemException), def23, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemExceptionOps.Factory), }); - DefineGlobalClass("StringIO", typeof(Ruby.Builtins.StringIO), def23, new System.Action(LoadStringIO_Instance), new System.Action(LoadStringIO_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("StringIO", typeof(Ruby.Builtins.StringIO), def24, new System.Action(LoadStringIO_Instance), new System.Action(LoadStringIO_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.StringIO.CreateIO), }); - DefineGlobalClass("SystemExit", typeof(Ruby.Builtins.SystemExit), def22, new System.Action(LoadSystemExit_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("SystemExit", typeof(Ruby.Builtins.SystemExit), def23, new System.Action(LoadSystemExit_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemExitOps.Factory), }); - DefineGlobalClass("SystemStackError", typeof(Ruby.Builtins.SystemStackError), def22, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("SystemStackError", typeof(Ruby.Builtins.SystemStackError), def23, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemStackErrorOps.Factory), }); - DefineGlobalClass("ArgumentError", typeof(System.ArgumentException), def20, new System.Action(LoadArgumentError_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("ArgumentError", typeof(System.ArgumentException), def21, new System.Action(LoadArgumentError_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ArgumentErrorOps.Factory), }); DefineGlobalClass("Bignum", typeof(Microsoft.Scripting.Math.BigInteger), def13, new System.Action(LoadBignum_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); DefineGlobalClass("Fixnum", typeof(System.Int32), def13, new System.Action(LoadFixnum_Instance), new System.Action(LoadFixnum_Class), Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("IndexError", typeof(System.IndexOutOfRangeException), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("IndexError", typeof(System.IndexOutOfRangeException), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.IndexErrorOps.Factory), }); - Ruby.Builtins.RubyClass def14 = DefineGlobalClass("IOError", typeof(System.IO.IOException), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("Interrupt", typeof(Ruby.Builtins.Interrupt), def19, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); + Ruby.Builtins.RubyClass def14 = DefineGlobalClass("IOError", typeof(System.IO.IOException), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.IOErrorOps.Factory), }); - DefineGlobalClass("LoadError", typeof(Ruby.Builtins.LoadError), def19, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("LoadError", typeof(Ruby.Builtins.LoadError), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.LoadErrorOps.Factory), }); - DefineGlobalClass("LocalJumpError", typeof(Ruby.Builtins.LocalJumpError), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("LocalJumpError", typeof(Ruby.Builtins.LocalJumpError), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.LocalJumpErrorOps.Factory), }); - Ruby.Builtins.RubyClass def24 = DefineGlobalClass("NameError", typeof(System.MemberAccessException), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def25 = DefineGlobalClass("NameError", typeof(System.MemberAccessException), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.NameErrorOps.Factory), }); - DefineGlobalClass("NotImplementedError", typeof(Ruby.Builtins.NotImplementedError), def19, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("NotImplementedError", typeof(Ruby.Builtins.NotImplementedError), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.NotImplementedErrorOps.Factory), }); - Ruby.Builtins.RubyClass def16 = DefineGlobalClass("RangeError", typeof(System.ArgumentOutOfRangeException), def20, new System.Action(LoadRangeError_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def16 = DefineGlobalClass("RangeError", typeof(System.ArgumentOutOfRangeException), def21, new System.Action(LoadRangeError_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RangeErrorOps.Factory), }); - DefineGlobalClass("RegexpError", typeof(Ruby.Builtins.RegexpError), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("RegexpError", typeof(Ruby.Builtins.RegexpError), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpErrorOps.Factory), }); - DefineGlobalClass("RuntimeError", typeof(Ruby.Builtins.RuntimeError), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("SecurityError", typeof(System.Security.SecurityException), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("RuntimeError", typeof(Ruby.Builtins.RuntimeError), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); + DefineGlobalClass("SecurityError", typeof(System.Security.SecurityException), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SecurityErrorOps.Factory), }); - DefineGlobalClass("SyntaxError", typeof(Ruby.Builtins.SyntaxError), def19, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("SyntaxError", typeof(Ruby.Builtins.SyntaxError), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SyntaxErrorOps.Factory), }); - Ruby.Builtins.RubyClass def15 = DefineGlobalClass("SystemCallError", typeof(System.Runtime.InteropServices.ExternalException), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + Ruby.Builtins.RubyClass def15 = DefineGlobalClass("SystemCallError", typeof(System.Runtime.InteropServices.ExternalException), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemCallErrorOps.Factory), }); - DefineGlobalClass("ThreadError", typeof(Ruby.Builtins.ThreadError), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("TypeError", typeof(System.InvalidOperationException), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("ThreadError", typeof(Ruby.Builtins.ThreadError), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); + DefineGlobalClass("TypeError", typeof(System.InvalidOperationException), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TypeErrorOps.Factory), }); - DefineGlobalClass("ZeroDivisionError", typeof(System.DivideByZeroException), def20, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("ZeroDivisionError", typeof(System.DivideByZeroException), def21, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.ZeroDivisionErrorOps.Factory), }); DefineGlobalClass("EOFError", typeof(Ruby.Builtins.EOFError), def14, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); @@ -194,7 +197,7 @@ Ruby.Builtins.RubyClass def11 = DefineClass("Errno::ENOENT", typeof(Ruby.Builtins.Errno.NoEntryError), def15, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyClass def12 = DefineClass("Errno::ENOTDIR", typeof(Ruby.Builtins.Errno.NotDirectoryError), def15, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); DefineGlobalClass("FloatDomainError", typeof(Ruby.Builtins.FloatDomainError), def16, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); - DefineGlobalClass("NoMethodError", typeof(System.MissingMethodException), def24, new System.Action(LoadNoMethodError_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + DefineGlobalClass("NoMethodError", typeof(System.MissingMethodException), def25, new System.Action(LoadNoMethodError_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.NoMethodErrorOps.Factory), }); #if !SILVERLIGHT @@ -1637,6 +1640,14 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Seek), }); + module.DefineMethod("sync", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Sync), + }); + + module.DefineMethod("sync=", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Sync), + }); + module.DefineMethod("tell", 0x9, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyIOOps.Pos), }); @@ -1707,6 +1718,10 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.SendMessage), }); + module.DefineMethod("=~", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.Match), + }); + module.DefineMethod("==", 0x9, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.ValueEquals), }); @@ -2924,10 +2939,18 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.CaseCompare), }); + module.DefineMethod("casefold?", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.IsCaseInsensitive), + }); + module.DefineMethod("inspect", 0x9, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.Inspect), }); + module.DefineMethod("kcode", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RegexpOps.GetEncoding), + }); + 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), @@ -4315,6 +4338,10 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TimeOps.IsUTC), }); + module.DefineMethod("gmt_offset", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TimeOps.Offset), + }); + module.DefineMethod("gmtime", 0x9, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.TimeOps.ToUTC), }); @@ -4672,7 +4699,9 @@ Ruby.Builtins.RubyClass def3 = DefineGlobalClass("IPSocket", typeof(Ruby.StandardLibrary.Sockets.IPSocket), def1, new System.Action(LoadIPSocket_Instance), new System.Action(LoadIPSocket_Class), Ruby.Builtins.RubyModule.EmptyArray, null); #endif #if !SILVERLIGHT - DefineGlobalClass("Socket", typeof(Ruby.StandardLibrary.Sockets.RubySocket), def1, new System.Action(LoadSocket_Instance), new System.Action(LoadSocket_Class), Ruby.Builtins.RubyModule.EmptyArray, null); + DefineGlobalClass("Socket", typeof(Ruby.StandardLibrary.Sockets.RubySocket), def1, new System.Action(LoadSocket_Instance), new System.Action(LoadSocket_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.CreateSocket), + }); #endif #if !SILVERLIGHT Ruby.Builtins.RubyClass def2 = DefineGlobalClass("TCPSocket", typeof(Ruby.StandardLibrary.Sockets.TCPSocket), def3, null, new System.Action(LoadTCPSocket_Class), Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { @@ -4916,6 +4945,39 @@ module.SetConstant("SOL_SOCKET", Ruby.StandardLibrary.Sockets.RubySocket.SOL_SOCKET); module.SetConstant("TCP_NODELAY", Ruby.StandardLibrary.Sockets.RubySocket.TCP_NODELAY); + module.DefineMethod("accept", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.Accept), + }); + + module.DefineMethod("accept_nonblock", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.AcceptNonBlocking), + }); + + module.DefineMethod("bind", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.Bind), + }); + + module.DefineMethod("connect", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.Connect), + }); + + module.DefineMethod("connect_nonblock", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.ConnectNonBlocking), + }); + + module.DefineMethod("listen", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.Listen), + }); + + module.DefineMethod("recvfrom", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.ReceiveFrom), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.ReceiveFrom), + }); + + module.DefineMethod("sysaccept", 0x9, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.SysAccept), + }); + } #endif @@ -5047,6 +5109,47 @@ new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.GetAddressInfo), }); + module.DefineMethod("gethostbyaddr", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.GetHostByAddress), + }); + + module.DefineMethod("gethostbyname", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.GetHostByName), + }); + + module.DefineMethod("gethostname", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.GetHostname), + }); + + module.DefineMethod("getnameinfo", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.GetNameInfo), + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.GetNameInfo), + }); + + module.DefineMethod("getservbyname", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.GetServiceByName), + }); + + module.DefineMethod("pack_sockaddr_in", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.PackInetSockAddr), + }); + + module.DefineMethod("pair", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.CreateSocketPair), + }); + + module.DefineMethod("sockaddr_in", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.PackInetSockAddr), + }); + + module.DefineMethod("socketpair", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.CreateSocketPair), + }); + + module.DefineMethod("unpack_sockaddr_in", 0x11, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.StandardLibrary.Sockets.RubySocket.UnPackInetSockAddr), + }); + } #endif @@ -5123,7 +5226,7 @@ Ruby.Builtins.RubyClass classRef0 = GetClass(typeof(System.Object)); - Ruby.Builtins.RubyModule def1 = DefineGlobalModule("OpenSSL", typeof(Ruby.StandardLibrary.OpenSsl.OpenSsl), null, null, Ruby.Builtins.RubyModule.EmptyArray); + Ruby.Builtins.RubyModule def1 = DefineGlobalModule("OpenSSL", typeof(Ruby.StandardLibrary.OpenSsl.OpenSsl), new System.Action(LoadOpenSSL_Instance), null, Ruby.Builtins.RubyModule.EmptyArray); Ruby.Builtins.RubyModule def2 = DefineModule("OpenSSL::Digest", typeof(Ruby.StandardLibrary.OpenSsl.OpenSsl.DigestFactory), null, null, Ruby.Builtins.RubyModule.EmptyArray); Ruby.Builtins.RubyClass def3 = DefineClass("OpenSSL::Digest::Digest", typeof(Ruby.StandardLibrary.OpenSsl.OpenSsl.DigestFactory.Digest), classRef0, new System.Action(LoadOpenSSL__Digest__Digest_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyClass def4 = DefineClass("OpenSSL::HMAC", typeof(Ruby.StandardLibrary.OpenSsl.OpenSsl.HMAC), classRef0, null, new System.Action(LoadOpenSSL__HMAC_Class), Ruby.Builtins.RubyModule.EmptyArray, null); @@ -5132,6 +5235,13 @@ def1.SetConstant("HMAC", def4); } + private void LoadOpenSSL_Instance(Ruby.Builtins.RubyModule/*!*/ module) { + module.SetConstant("OPENSSL_VERSION", Ruby.StandardLibrary.OpenSsl.OpenSsl.OPENSSL_VERSION); + module.SetConstant("OPENSSL_VERSION_NUMBER", Ruby.StandardLibrary.OpenSsl.OpenSsl.OPENSSL_VERSION_NUMBER); + module.SetConstant("VERSION", Ruby.StandardLibrary.OpenSsl.OpenSsl.VERSION); + + } + private void LoadOpenSSL__Digest__Digest_Instance(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineMethod("initialize", 0xa, new System.Delegate[] { @@ -5164,12 +5274,18 @@ #if !SILVERLIGHT Ruby.Builtins.RubyClass def5 = DefineClass("Digest::MD5", typeof(Ruby.StandardLibrary.Digest.Digest.MD5), def2, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); #endif + #if !SILVERLIGHT + Ruby.Builtins.RubyClass def6 = DefineClass("Digest::SHA1", typeof(Ruby.StandardLibrary.Digest.Digest.SHA1), def2, null, null, Ruby.Builtins.RubyModule.EmptyArray, null); + #endif def1.SetConstant("Instance", def4); def1.SetConstant("Class", def3); def1.SetConstant("Base", def2); #if !SILVERLIGHT def1.SetConstant("MD5", def5); #endif + #if !SILVERLIGHT + def1.SetConstant("SHA1", def6); + #endif } private void LoadDigest_Class(Ruby.Builtins.RubyModule/*!*/ module) { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;C437366 File: Protocols.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;C437366 (server) 5/19/2008 9:32 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs;RegexOptions @@ -175,7 +175,7 @@ /// Makes sure that we escape characters in the string. /// public static RubyRegex/*!*/ ConvertToRegexp(CodeContext/*!*/ context, object/*!*/ pattern) { - return new RubyRegex(RubyRegex.Escape(Protocols.CastToString(context, pattern)), RegexOptions.None); + return new RubyRegex(RubyRegex.Escape(Protocols.CastToString(context, pattern)), RubyRegexOptions.NONE); } #endregion =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs;C443395 File: MutableStringOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs;C443395 (server) 5/19/2008 9:31 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs;RegexOptions @@ -2259,7 +2259,7 @@ [RubyMethod("match")] public static object MatchObject(CodeContext/*!*/ context, MutableString/*!*/ self, object obj) { - RubyRegex regex = new RubyRegex(Protocols.CastToString(context, obj), RegexOptions.None); + RubyRegex regex = new RubyRegex(Protocols.CastToString(context, obj), RubyRegexOptions.NONE); return LibrarySites.InvokeMatch(context, regex, self); } @@ -2322,7 +2322,7 @@ [RubyMethod("scan")] public static RubyArray/*!*/ Scan(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]MutableString/*!*/ search) { - return Scan(context, self, Kernel.FlowTaint(context, search, new RubyRegex(RubyRegex.Escape(search), RegexOptions.None))); + return Scan(context, self, Kernel.FlowTaint(context, search, new RubyRegex(RubyRegex.Escape(search), RubyRegexOptions.NONE))); } [RubyMethod("scan")] @@ -2364,7 +2364,7 @@ [RubyMethod("scan")] public static object/*!*/ Scan(CodeContext/*!*/ context, MutableString/*!*/ self, [NotNull]BlockParam/*!*/ block, [NotNull]MutableString/*!*/ search) { - return Scan(context, self, block, Kernel.FlowTaint(context, search, new RubyRegex(RubyRegex.Escape(search), RegexOptions.None))); + return Scan(context, self, block, Kernel.FlowTaint(context, search, new RubyRegex(RubyRegex.Escape(search), RubyRegexOptions.NONE))); } [RubyMethod("scan")] =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyRegexOps.cs;C443395 File: RubyRegexOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyRegexOps.cs;C443395 (server) 5/19/2008 9:31 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyRegexOps.cs;RegexOptions @@ -20,6 +20,7 @@ using Ruby.Runtime; using Ruby.Compiler.Ast; +using Microsoft.Scripting.Utils; namespace Ruby.Builtins { [RubyClass("Regexp", Extends = typeof(RubyRegex), Inherits = typeof(Object)), Includes(typeof(Enumerable))] @@ -29,15 +30,11 @@ // initialize_copy //declared public instance methods: // == - // casefold? // eql? // hash - // kcode - // taguri - // taguri= - //declared singleton methods: + // singleton: // union - + //------------------------------------------------------------ Regexp::new // Regexp.new(string [, options [, lang]]) => regexp // Regexp.new(regexp) => regexp @@ -74,7 +71,7 @@ [RubyConstructor] public static RubyRegex/*!*/ Create([NotNull]MutableString/*!*/ str) { - return new RubyRegex(str, RegexOptions.None); + return new RubyRegex(str, RubyRegexOptions.NONE); } [RubyConstructor] @@ -84,12 +81,12 @@ [RubyConstructor] public static RubyRegex/*!*/ Create([NotNull]MutableString/*!*/ str, int options) { - return new RubyRegex(str, RubyRegex.ToClrOptions((Ruby.Compiler.Ast.RegExOptions)options)); + return new RubyRegex(str, (RubyRegexOptions)options); } [RubyConstructor] public static RubyRegex/*!*/ Create([NotNull]MutableString/*!*/ str, object options) { - return new RubyRegex(str, Protocols.IsTrue(options) ? RegexOptions.IgnoreCase : RegexOptions.None); + return new RubyRegex(str, Protocols.IsTrue(options) ? RubyRegexOptions.IgnoreCase : RubyRegexOptions.NONE); } [RubyConstructor] @@ -136,13 +133,13 @@ #endregion [RubyConstant] - public const int IGNORECASE = 1; + public const int IGNORECASE = (int)RubyRegexOptions.IgnoreCase; [RubyConstant] - public const int EXTENDED = 2; + public const int EXTENDED = (int)RubyRegexOptions.Extended; [RubyConstant] - public const int MULTILINE = 4; + public const int MULTILINE = (int)RubyRegexOptions.Multiline; [RubyMethod("to_s")] public static MutableString/*!*/ ToS(RubyRegex/*!*/ self) { @@ -174,28 +171,54 @@ [RubyMethod("options")] public static int GetOptions(RubyRegex/*!*/ self) { - return (int)RubyRegex.ToRubyOptions(self.Options); + return (int)self.Options; } - private static int AppendOptionString(MutableString/*!*/ result, RegexOptions options, bool enabled, bool includeEncoding) { + [RubyMethod("kcode")] + public static MutableString GetEncoding(RubyRegex/*!*/ self) { + switch (self.Options & RubyRegexOptions.EncodingMask) { + case RubyRegexOptions.NONE: return null; + case RubyRegexOptions.EUC: return MutableString.Create("euc"); + case RubyRegexOptions.FIXED: return MutableString.Create("none"); + case RubyRegexOptions.UTF8: return MutableString.Create("utf8"); + case RubyRegexOptions.SJIS: return MutableString.Create("sjis"); + default: throw Assert.Unreachable; + } + } + + [RubyMethod("casefold?")] + public static bool IsCaseInsensitive(RubyRegex/*!*/ self) { + return (self.Options & RubyRegexOptions.IgnoreCase) != 0; + } + + private static int AppendOptionString(MutableString/*!*/ result, RubyRegexOptions options, bool enabled, bool includeEncoding) { int count = 0; - - if (((options & RegexOptions.Multiline) != 0) == enabled) { + + if (((options & RubyRegexOptions.Multiline) != 0) == enabled) { result.Append('m'); count++; } - if (((options & RegexOptions.IgnoreCase) != 0) == enabled) { + if (((options & RubyRegexOptions.IgnoreCase) != 0) == enabled) { result.Append('i'); count++; } - if (((options & RegexOptions.IgnorePatternWhitespace) != 0) == enabled) { + if (((options & RubyRegexOptions.Extended) != 0) == enabled) { result.Append('x'); count++; } - // TODO: encoding + if (includeEncoding) { + switch (options & RubyRegexOptions.EncodingMask) { + case RubyRegexOptions.NONE: break; + case RubyRegexOptions.EUC: result.Append('e'); break; + case RubyRegexOptions.FIXED: result.Append('n'); break; + case RubyRegexOptions.UTF8: result.Append('u'); break; + case RubyRegexOptions.SJIS: result.Append('s'); break; + default: throw Assert.Unreachable; + } + } return count; } @@ -351,5 +374,6 @@ public static MutableString/*!*/ LastMatch(CodeContext/*!*/ context, object/*!*/ self, object group) { return LastMatch(context, self, Protocols.CastToFixnum(context, group)); } + } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C440810 File: Ruby.csproj =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C440810 (server) 5/19/2008 9:13 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;RegexOptions @@ -95,6 +95,7 @@ + @@ -216,7 +217,6 @@ - =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj.vspscc;C390406 edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.Content.cs;C438696 File: MutableString.Content.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.Content.cs;C438696 (server) 5/19/2008 9:30 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.Content.cs;RegexOptions @@ -59,7 +59,7 @@ } public abstract byte[]/*!*/ ToByteArray(); - public abstract GenericRegex/*!*/ ToRegularExpression(RegexOptions options); + public abstract GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options); // read: public abstract bool IsBinary { get; } @@ -163,8 +163,8 @@ public override byte[]/*!*/ ToByteArray() { return _owner._encoding.GetBytes(_data); } - - public override GenericRegex/*!*/ ToRegularExpression(RegexOptions options) { + + public override GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options) { return new StringRegex(_data, options); } @@ -480,7 +480,7 @@ return _owner._encoding.GetBytes(_data.ToString()); } - public override GenericRegex/*!*/ ToRegularExpression(RegexOptions options) { + public override GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options) { return new StringRegex(_data.ToString(), options); } @@ -822,7 +822,7 @@ return _data.ToArray(); } - public override GenericRegex/*!*/ ToRegularExpression(RegexOptions options) { + public override GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options) { return new BinaryRegex(_data.ToArray(), options); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.cs;C440810 File: MutableString.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.cs;C440810 (server) 5/19/2008 9:30 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.cs;RegexOptions @@ -162,7 +162,7 @@ #region Conversions - public GenericRegex/*!*/ ToRegularExpression(RegexOptions options) { + public GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options) { return _content.ToRegularExpression(options); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegex.cs;C443395 File: RubyRegex.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegex.cs;C443395 (server) 5/19/2008 9:24 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegex.cs;RegexOptions @@ -24,36 +24,34 @@ namespace Ruby.Builtins { public abstract class GenericRegex { + private readonly RubyRegexOptions _options; + public abstract bool IsEmpty { get; } - public abstract RegexOptions Options { get; } + public RubyRegexOptions Options { get { return _options; } } public abstract MutableString/*!*/ GetPattern(); public abstract Match/*!*/ Match(MutableString/*!*/ input, int start, int count); public abstract MatchCollection/*!*/ Matches(MutableString/*!*/ input, int start); public abstract MutableString[]/*!*/ Split(MutableString/*!*/ input, int count, int start); - protected GenericRegex() { + protected GenericRegex(RubyRegexOptions options) { + _options = options; } } public class BinaryRegex : GenericRegex { private readonly byte[]/*!*/ _pattern; - private readonly RegexOptions _options; - internal protected BinaryRegex(byte[]/*!*/ pattern, RegexOptions options) { + internal protected BinaryRegex(byte[]/*!*/ pattern, RubyRegexOptions options) + : base(options) { Assert.NotNull(pattern); _pattern = ArrayUtils.Copy(pattern); - _options = options; } public override bool IsEmpty { get { return _pattern.Length == 0; } } - public override RegexOptions Options { - get { return _options; } - } - public override Match/*!*/ Match(MutableString/*!*/ input, int start, int count) { throw new NotImplementedException(); } @@ -72,16 +70,18 @@ } public class StringRegex : GenericRegex { - internal static readonly StringRegex Empty = new StringRegex(new Regex(String.Empty, RegexOptions.None)); + internal static readonly StringRegex Empty = new StringRegex(new Regex(String.Empty, RubyRegex.ToClrOptions(RubyRegexOptions.NONE))); private readonly Regex/*!*/ _regex; - internal protected StringRegex(string/*!*/ pattern, RegexOptions options) { + internal protected StringRegex(string/*!*/ pattern, RubyRegexOptions options) + : base(options) { Assert.NotNull(pattern); - _regex = new Regex(pattern, options); + _regex = new Regex(pattern, RubyRegex.ToClrOptions(options)); } - internal protected StringRegex(Regex/*!*/ regex) { + internal protected StringRegex(Regex/*!*/ regex) + : base(RubyRegexOptions.NONE) { Assert.NotNull(regex); _regex = regex; } @@ -90,10 +90,6 @@ get { return _regex.ToString().Length == 0; } } - public override RegexOptions Options { - get { return _regex.Options; } - } - public override Match/*!*/ Match(MutableString/*!*/ input, int start, int count) { return _regex.Match(input.ConvertToString(), start, count); } @@ -118,20 +114,19 @@ _regex = StringRegex.Empty; } - // BUG #20132: Ruby regular expressions essentially behave like .NET multiline regular expressions - public RubyRegex(MutableString/*!*/ pattern, RegexOptions options) { + public RubyRegex(MutableString/*!*/ pattern, RubyRegexOptions options) { ContractUtils.RequiresNotNull(pattern, "pattern"); - _regex = pattern.ToRegularExpression(options/*TODO: | RegexOptions.Multiline*/); + _regex = pattern.ToRegularExpression(options); } - public RubyRegex(string/*!*/ pattern, RegexOptions options) { + public RubyRegex(string/*!*/ pattern, RubyRegexOptions options) { ContractUtils.RequiresNotNull(pattern, "pattern"); - _regex = new StringRegex(pattern, options/*TODO: | RegexOptions.Multiline*/); + _regex = new StringRegex(pattern, options); } - public RubyRegex(byte[]/*!*/ pattern, RegexOptions options) { + public RubyRegex(byte[]/*!*/ pattern, RubyRegexOptions options) { ContractUtils.RequiresNotNull(pattern, "pattern"); - _regex = new BinaryRegex(pattern, options/*TODO: | RegexOptions.Multiline*/); + _regex = new BinaryRegex(pattern, options); } public RubyRegex(Regex/*!*/ regex) { @@ -148,7 +143,7 @@ get { return _regex.IsEmpty; } } - public RegexOptions Options { + public RubyRegexOptions Options { get { return _regex.Options; } } @@ -205,7 +200,7 @@ ContractUtils.RequiresNotNull(str, "str"); // We are cloning a Regex object just so that we can do right to left eval. yuck. - Regex regex = new Regex(_regex.GetPattern().ConvertToString(), Options | RegexOptions.RightToLeft); + Regex regex = new Regex(_regex.GetPattern().ConvertToString(), ToClrOptions(Options) | RegexOptions.RightToLeft); MatchData result = new MatchData(regex.Match(str.ConvertToString(), offset), str); RubyUtils.GetScope(context).CurrentMatch = result.Success ? result : null; return result; @@ -221,42 +216,18 @@ #endregion - // TODO: encoding - public static RegexOptions ToClrOptions(Ruby.Compiler.Ast.RegExOptions options) { - RegexOptions result = RegexOptions.None; + public static RegexOptions ToClrOptions(RubyRegexOptions options) { + RegexOptions result = RegexOptions.Multiline; - if ((options & Ruby.Compiler.Ast.RegExOptions.MULTILINE) != 0) { - result |= RegexOptions.Multiline; - } - - if ((options & Ruby.Compiler.Ast.RegExOptions.IGNORECASE) != 0) { + if ((options & RubyRegexOptions.IgnoreCase) != 0) { result |= RegexOptions.IgnoreCase; } - if ((options & Ruby.Compiler.Ast.RegExOptions.EXTENDED) != 0) { + if ((options & RubyRegexOptions.Extended) != 0) { result |= RegexOptions.IgnorePatternWhitespace; } return result; } - - // TODO: encoding - public static Ruby.Compiler.Ast.RegExOptions ToRubyOptions(RegexOptions options) { - Ruby.Compiler.Ast.RegExOptions result = Ruby.Compiler.Ast.RegExOptions.NONE; - - if ((options & RegexOptions.Multiline) != 0) { - result |= Ruby.Compiler.Ast.RegExOptions.MULTILINE; - } - - if ((options & RegexOptions.IgnoreCase) != 0) { - result |= Ruby.Compiler.Ast.RegExOptions.IGNORECASE; - } - - if ((options & RegexOptions.IgnorePatternWhitespace) != 0) { - result |= Ruby.Compiler.Ast.RegExOptions.EXTENDED; - } - - return result; - } } } =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegexOptions.cs File: RubyRegexOptions.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegexOptions.cs;RegexOptions @@ -1,0 +1,31 @@ +?/* **************************************************************************** + * + * Copyright (c) Microsoft Corporation. + * + * This source code is subject to terms and conditions of the Microsoft Public License. A + * copy of the license can be found in the License.html file at the root of this distribution. If + * you cannot locate the Microsoft Public License, please send an email to + * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound + * by the terms of the Microsoft Public License. + * + * You must not remove this notice, or any other, from this software. + * + * + * ***************************************************************************/ + +namespace Ruby.Builtins { + public enum RubyRegexOptions { + NONE = 0, + IgnoreCase = 1, + Extended = 2, + Multiline = 4, + + // encoding: + FIXED = 16, + EUC = 32, + SJIS = 48, + UTF8 = 64, + + EncodingMask = FIXED | EUC | SJIS | UTF8 + } +} =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/RegularExpression.cs;C438696 File: RegularExpression.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/RegularExpression.cs;C438696 (server) 5/19/2008 9:16 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/RegularExpression.cs;RegexOptions @@ -23,13 +23,14 @@ namespace Ruby.Compiler.Ast { using MSA = Microsoft.Scripting.Ast; using Ast = Microsoft.Scripting.Ast.Expression; + using Ruby.Runtime; // /pattern/options public partial class RegularExpression : Expression { - private readonly RegExOptions _options; + private readonly RubyRegexOptions _options; private readonly List/*!*/ _pattern; - public RegExOptions Options { + public RubyRegexOptions Options { get { return _options; } } @@ -38,7 +39,7 @@ get { return _pattern; } } - public RegularExpression(List/*!*/ pattern, RegExOptions options, SourceSpan location) + public RegularExpression(List/*!*/ pattern, RubyRegexOptions options, SourceSpan location) : base(location) { ContractUtils.RequiresNotNullItems(pattern, "pattern"); @@ -47,7 +48,7 @@ } internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) { - return StringConstructor.TransformConcatentation(gen, _pattern, "CreateRegex", Ast.Constant(RubyRegex.ToClrOptions(_options))); + return StringConstructor.TransformConcatentation(gen, _pattern, "CreateRegex", Ast.Constant(_options)); } } } =================================================================== delete: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Regexp.cs;C438696 File: Regexp.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Regexp.cs;C438696 (server) 5/19/2008 9:14 PM +++ [no target file] @@ -1,34 +1,0 @@ -/* **************************************************************************** - * - * Copyright (c) Microsoft Corporation. - * - * This source code is subject to terms and conditions of the Microsoft Public License. A - * copy of the license can be found in the License.html file at the root of this distribution. If - * you cannot locate the Microsoft Public License, please send an email to - * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound - * by the terms of the Microsoft Public License. - * - * You must not remove this notice, or any other, from this software. - * - * - * ***************************************************************************/ - -using System; - -namespace Ruby.Compiler.Ast -{ - [Flags] - public enum RegExOptions { - NONE = 0, - IGNORECASE = 1, - EXTENDED = 2, - MULTILINE = 4, - - // encoding: - FIXED = 16, - EUC = 32, - SJIS = 48, - UTF8 = 64 - } - -} \ No newline at end of file =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Tokenizer.cs;C443223 File: Tokenizer.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Tokenizer.cs;C443223 (server) 5/19/2008 9:21 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Tokenizer.cs;RegexOptions @@ -26,6 +26,7 @@ using Ruby.Compiler.Ast; using Ruby.Runtime; +using Ruby.Builtins; namespace Ruby.Compiler { public enum LexicalState { @@ -2093,24 +2094,24 @@ // Reads // [:letter:]* // and converts it to RegEx options. - private RegExOptions ReadRegexOptions() { - RegExOptions encoding = 0; - RegExOptions options = 0; + private RubyRegexOptions ReadRegexOptions() { + RubyRegexOptions encoding = 0; + RubyRegexOptions options = 0; int c; while (IsLetter(c = nextc())) { switch (c) { - case 'i': options |= RegExOptions.IGNORECASE; break; - case 'x': options |= RegExOptions.EXTENDED; break; - case 'm': options |= RegExOptions.MULTILINE; break; + case 'i': options |= RubyRegexOptions.IgnoreCase; break; + case 'x': options |= RubyRegexOptions.Extended; break; + case 'm': options |= RubyRegexOptions.Multiline; break; case 'o': // TODO: Once option not implemented. break; - case 'n': encoding |= RegExOptions.FIXED; break; - case 'e': encoding = RegExOptions.EUC; break; - case 's': encoding = RegExOptions.SJIS; break; - case 'u': encoding = RegExOptions.UTF8; break; + case 'n': encoding |= RubyRegexOptions.FIXED; break; + case 'e': encoding = RubyRegexOptions.EUC; break; + case 's': encoding = RubyRegexOptions.SJIS; break; + case 'u': encoding = RubyRegexOptions.UTF8; break; default: ReportError(Errors.UnknownRegexOption, (char)c); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/TokenValue.cs;C390406 File: TokenValue.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/TokenValue.cs;C390406 (server) 5/19/2008 9:19 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/TokenValue.cs;RegexOptions @@ -21,6 +21,7 @@ using Microsoft.Scripting; using Microsoft.Scripting.Math; using Ruby.Compiler.Ast; +using Ruby.Builtins; namespace Ruby.Compiler { @@ -58,7 +59,7 @@ public double Double { get { return _double; } set { _double = value; } } internal VariableFactory VariableFactory { get { return (VariableFactory)obj; } set { obj = value; } } - public RegExOptions RegExOptions { get { return (RegExOptions)Integer; } set { Integer = (int)value; } } + public RubyRegexOptions RegExOptions { get { return (RubyRegexOptions)Integer; } set { Integer = (int)value; } } public Statement Statement { get { return (Statement)node; } set { node = value; } } public Expression Expression { get { return (Expression)node; } set { node = value; } } public CallExpression CallExpression { get { return (CallExpression)node; } set { node = value; } } @@ -124,7 +125,7 @@ _type = TokenValueType.SymbolId; } - internal void SetRegexOptions(RegExOptions value) { + internal void SetRegexOptions(RubyRegexOptions value) { Integer = (int)value; _type = TokenValueType.RegexOptions; } @@ -146,7 +147,7 @@ break; case TokenValueType.RegexOptions: - str = ((RegExOptions)Integer).ToString(); + str = ((RubyRegexOptions)Integer).ToString(); break; case TokenValueType.String: =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;C443395 File: RubyOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;C443395 (server) 5/19/2008 9:17 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;RegexOptions @@ -729,31 +729,31 @@ public const int MakeStringParamCount = 2; // emitted: - public static RubyRegex/*!*/ CreateRegex(string/*!*/ str1, RegexOptions options) { + public static RubyRegex/*!*/ CreateRegex(string/*!*/ str1, RubyRegexOptions options) { return new RubyRegex(str1, options); } // emitted: - public static RubyRegex/*!*/ CreateRegex(MutableString str1, RegexOptions options) { + public static RubyRegex/*!*/ CreateRegex(MutableString str1, RubyRegexOptions options) { return new RubyRegex(MutableString.CreateInternal(str1), options); } // emitted: - public static RubyRegex/*!*/ CreateRegex(string/*!*/ str1, MutableString str2, RegexOptions options) { + public static RubyRegex/*!*/ CreateRegex(string/*!*/ str1, MutableString str2, RubyRegexOptions options) { return new RubyRegex(MutableString.Create(str1).Append(str2), options); } // emitted: - public static RubyRegex/*!*/ CreateRegex(MutableString str1, string/*!*/ str2, RegexOptions options) { + public static RubyRegex/*!*/ CreateRegex(MutableString str1, string/*!*/ str2, RubyRegexOptions options) { return new RubyRegex(MutableString.CreateInternal(str1).Append(str2), options); } // emitted: - public static RubyRegex/*!*/ CreateRegex(MutableString str1, MutableString str2, RegexOptions options) { + public static RubyRegex/*!*/ CreateRegex(MutableString str1, MutableString str2, RubyRegexOptions options) { return new RubyRegex(MutableString.CreateInternal(str1).Append(str2), options); } // emitted: - public static RubyRegex/*!*/ CreateRegexN(object[]/*!*/ strings, RegexOptions options) { + public static RubyRegex/*!*/ CreateRegexN(object[]/*!*/ strings, RubyRegexOptions options) { return new RubyRegex(ConcatenateStrings(strings), options); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Globals/KCode.cs;C438696