edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C447221 File: RubyTests.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C447221 (server) 5/23/2008 4:13 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;miscfixes2 @@ -38,6 +38,7 @@ Scenario_RubySimpleCall2, Scenario_RubySimpleCall3, Scenario_RubySimpleCall4, + AttributeAccessors1, Scenario_RubyMethodMissing1, Scenario_RubyMethodMissing2, Scenario_RubySingletonConstants1, =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/MethodTests.cs;C444795 File: MethodTests.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/MethodTests.cs;C444795 (server) 5/23/2008 4:13 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/MethodTests.cs;miscfixes2 @@ -86,6 +86,26 @@ } + public void AttributeAccessors1() { + AssertOutput(delegate { + CompilerTest(@" +class C + attr_accessor :foo + alias :bar :foo + alias :bar= :foo= +end + +x = C.new +x.foo = 123 +x.bar = x.foo + 1 +puts x.foo, x.bar +"); + }, @" +124 +124 +"); + } + public void MethodAdded1() { AssertOutput(delegate { CompilerTest(@" =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;C448016 File: Initializers.Generated.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;C448016 (server) 5/23/2008 2:56 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;miscfixes2 @@ -38,7 +38,12 @@ DefineGlobalModule("Math", typeof(Ruby.Builtins.RubyMath), new System.Action(LoadMath_Instance), new System.Action(LoadMath_Class), Ruby.Builtins.RubyModule.EmptyArray); ExtendClass(typeof(Microsoft.Scripting.Actions.TypeTracker), new System.Action(LoadMicrosoft__Scripting__Actions__TypeTracker_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); Ruby.Builtins.RubyModule def21 = DefineGlobalModule("Precision", typeof(Ruby.Builtins.Precision), new System.Action(LoadPrecision_Instance), new System.Action(LoadPrecision_Class), Ruby.Builtins.RubyModule.EmptyArray); - DefineGlobalModule("Process", typeof(Ruby.Builtins.RubyProcess), null, new System.Action(LoadProcess_Class), Ruby.Builtins.RubyModule.EmptyArray); + #if !SILVERLIGHT + DefineGlobalModule("Process", typeof(Ruby.Builtins.RubyProcess), new System.Action(LoadProcess_Instance), new System.Action(LoadProcess_Class), Ruby.Builtins.RubyModule.EmptyArray); + #endif + #if !SILVERLIGHT + DefineGlobalModule("Signal", typeof(Ruby.Builtins.Signal), null, new System.Action(LoadSignal_Class), Ruby.Builtins.RubyModule.EmptyArray); + #endif ExtendClass(typeof(System.Type), new System.Action(LoadSystem__Type_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, null); // Skipped primitive: __ClassSingletonSingleton #if !SILVERLIGHT @@ -135,10 +140,12 @@ Ruby.Builtins.RubyClass def24 = Context.StandardErrorClass = DefineGlobalClass("StandardError", typeof(System.SystemException), def26, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemExceptionOps.Factory), }); + #if !SILVERLIGHT Ruby.Builtins.RubyClass def12 = DefineClass("Struct::Tms", typeof(Ruby.Builtins.RubyStructOps.Tms), def11, null, null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyStructOps.Tms.CreateInstance), new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyStructOps.Tms.CreateInstance), }); + #endif DefineGlobalClass("SystemExit", typeof(Ruby.Builtins.SystemExit), def26, new System.Action(LoadSystemExit_Instance), null, Ruby.Builtins.RubyModule.EmptyArray, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.SystemExitOps.Factory), }); @@ -213,7 +220,9 @@ #if !SILVERLIGHT def13.SetConstant("Stat", def14); #endif + #if !SILVERLIGHT def11.SetConstant("Tms", def12); + #endif def3.SetConstant("EACCES", def4); def3.SetConstant("EBADF", def5); def3.SetConstant("EDOM", def6); @@ -2480,6 +2489,13 @@ new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.ToString), }); + #if !SILVERLIGHT + module.DefineLibraryMethod("trap", 0x2a, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.Trap), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.Trap), + }); + + #endif module.DefineLibraryMethod("untaint", 0x29, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.Untaint), }); @@ -2629,6 +2645,13 @@ new Microsoft.Scripting.Utils.Action(Ruby.Builtins.Kernel.Throw), }); + #if !SILVERLIGHT + module.DefineLibraryMethod("trap", 0x31, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.Trap), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Kernel.Trap), + }); + + #endif } private void LoadMarshal_Instance(Ruby.Builtins.RubyModule/*!*/ module) { @@ -3378,8 +3401,23 @@ } + #if !SILVERLIGHT + private void LoadProcess_Instance(Ruby.Builtins.RubyModule/*!*/ module) { + + module.DefineLibraryMethod("kill", 0x2a, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyProcess.Kill), + }); + + } + #endif + + #if !SILVERLIGHT private void LoadProcess_Class(Ruby.Builtins.RubyModule/*!*/ module) { + module.DefineLibraryMethod("kill", 0x31, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyProcess.Kill), + }); + module.DefineLibraryMethod("pid", 0x31, new System.Delegate[] { new Microsoft.Scripting.Utils.Function(Ruby.Builtins.RubyProcess.GetPid), }); @@ -3393,6 +3431,7 @@ }); } + #endif private void LoadRange_Instance(Ruby.Builtins.RubyModule/*!*/ module) { @@ -3552,6 +3591,21 @@ } + #if !SILVERLIGHT + private void LoadSignal_Class(Ruby.Builtins.RubyModule/*!*/ module) { + + module.DefineLibraryMethod("list", 0x31, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Signal.List), + }); + + module.DefineLibraryMethod("trap", 0x31, new System.Delegate[] { + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Signal.Trap), + new Microsoft.Scripting.Utils.Function(Ruby.Builtins.Signal.Trap), + }); + + } + #endif + private void LoadString_Instance(Ruby.Builtins.RubyModule/*!*/ module) { module.DefineLibraryMethod("%", 0x29, new System.Delegate[] { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/IronRuby.Libraries.csproj;C447029 File: IronRuby.Libraries.csproj =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/IronRuby.Libraries.csproj;C447029 (server) 5/23/2008 2:46 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/IronRuby.Libraries.csproj;miscfixes2 @@ -108,6 +108,7 @@ + =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/IronRuby.Libraries.csproj.vspscc;C390406 edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;C448016 File: Kernel.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;C448016 (server) 5/23/2008 2:45 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;miscfixes2 @@ -547,7 +547,22 @@ //test //trace_var - //trap + +#if !SILVERLIGHT // Signals dont make much sense in Silverlight as cross-process communication is not allowed + [RubyMethod("trap", RubyMethodAttributes.PrivateInstance, BuildConfig = "!SILVERLIGHT")] + [RubyMethod("trap", RubyMethodAttributes.PublicSingleton, BuildConfig = "!SILVERLIGHT")] + public static object Trap(CodeContext/*!*/ context, RubyModule/*!*/ self, object signalId, [NotNull]Proc/*!*/ proc) { + return Signal.Trap(context, self, signalId, proc); + } + + [RubyMethod("trap", RubyMethodAttributes.PrivateInstance, BuildConfig = "!SILVERLIGHT")] + [RubyMethod("trap", RubyMethodAttributes.PublicSingleton, BuildConfig = "!SILVERLIGHT")] + public static object Trap(CodeContext/*!*/ context, RubyModule/*!*/ self, BlockParam block, object/*!*/ signalId) { + return Signal.Trap(context, self, block, signalId); + } + +#endif + //untrace_var //warn =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C447221 File: ModuleOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C447221 (server) 5/23/2008 4:13 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;miscfixes2 @@ -331,15 +331,16 @@ private static void DefineAccessor(CodeContext/*!*/ context, RubyModule/*!*/ self, SymbolId name, bool readable, bool writable) { string getterMethodName = SymbolTable.IdToString(name); - + RubyScope scope = RubyUtils.GetScope(context); + RubyMethodVisibility visibility = (RubyMethodVisibility)(scope.MethodAttributes & RubyMethodAttributes.VisibilityMask); if (readable) { - self.DefineRuleGenerator(getterMethodName, (int)scope.MethodAttributes, new RuleGenerator(RuleGenerators.AttributeRead)); + self.SetLibraryMethod(name, new RubyAttributeReaderInfo(visibility, self, getterMethodName), false); } if (writable) { - self.DefineRuleGenerator(getterMethodName + "=", (int)scope.MethodAttributes, new RuleGenerator(RuleGenerators.AttributeWrite)); + self.SetLibraryMethod(SymbolTable.StringToId(getterMethodName + "="), new RubyAttributeWriterInfo(visibility, self, getterMethodName), false); } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyProcess.cs;C443985 File: RubyProcess.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyProcess.cs;C443985 (server) 5/23/2008 2:45 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyProcess.cs;miscfixes2 @@ -12,6 +12,7 @@ * * * ***************************************************************************/ +#if !SILVERLIGHT using System; using System.Diagnostics; @@ -27,7 +28,7 @@ /// /// Process builtin module /// - [RubyModule("Process")] + [RubyModule("Process", BuildConfig = "!SILVERLIGHT")] public static class RubyProcess { // abort @@ -47,17 +48,19 @@ // groups // groups= // initgroups - // kill + + [RubyMethod("kill", RubyMethodAttributes.PrivateInstance)] + [RubyMethod("kill", RubyMethodAttributes.PublicSingleton)] + public static object Kill(CodeContext/*!*/ context, object self, object signalId, object pid) { + throw RubyExceptions.CreateNotImplementedError("Signals are not currently implemented. Signal.trap just pretends to work"); + } + // maxgroups // maxgroups= [RubyMethod("pid", RubyMethodAttributes.PublicSingleton)] public static int GetPid(object self/*!*/) { -#if !SILVERLIGHT return Process.GetCurrentProcess().Id; -#else - return 0; -#endif } [RubyMethod("ppid", RubyMethodAttributes.PublicSingleton)] @@ -74,13 +77,13 @@ [RubyMethod("times", RubyMethodAttributes.PublicSingleton)] public static RubyStructOps.Tms GetTimes(CodeContext/*!*/ context, object self/*!*/) { RubyStructOps.Tms result = RubyStructOps.Tms.CreateInstance(context); -#if !SILVERLIGHT + Process process = Process.GetCurrentProcess(); result.UserTime = process.UserProcessorTime.TotalSeconds; result.SystemTime = process.PrivilegedProcessorTime.TotalSeconds; result.ChildUserTime = 0; result.ChildSystemTime = 0; -#endif + return result; } @@ -94,7 +97,7 @@ } public static partial class RubyStructOps { - [RubyClass("Tms")] + [RubyClass("Tms", BuildConfig = "!SILVERLIGHT")] public class Tms : RubyStruct { private static readonly SymbolId[]/*!*/ _attributes = SymbolTable.StringsToIds(new string[] { "utime", "stime", "cutime", "cstime" }); private static bool _inited = false; @@ -148,3 +151,4 @@ } } } +#endif =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Signal.cs File: Signal.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Signal.cs;miscfixes2 @@ -1,0 +1,68 @@ +?/* **************************************************************************** + * + * 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. + * + * + * ***************************************************************************/ +#if !SILVERLIGHT // Signals dont make much sense in Silverlight as cross-process communication is not allowed + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; +using Microsoft.Scripting; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Ast; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting.Utils; +using Ruby.Runtime; +using Ruby.Runtime.Calls; + +namespace Ruby.Builtins { + + [RubyModule("Signal", BuildConfig="!SILVERLIGHT")] + public static class Signal { + #region Private Instance & Singleton Methods + + [RubyMethod("list", RubyMethodAttributes.PublicSingleton)] + public static Hash/*!*/ List(CodeContext/*!*/ context, RubyModule/*!*/ self) { + Hash result = new Hash(context); + result.Add(MutableString.Create("TERM"), RuntimeHelpers.Int32ToObject(15)); + result.Add(MutableString.Create("SEGV"), RuntimeHelpers.Int32ToObject(11)); + result.Add(MutableString.Create("KILL"), RuntimeHelpers.Int32ToObject(9)); + result.Add(MutableString.Create("EXIT"), RuntimeHelpers.Int32ToObject(0)); + result.Add(MutableString.Create("INT"), RuntimeHelpers.Int32ToObject(2)); + result.Add(MutableString.Create("FPE"), RuntimeHelpers.Int32ToObject(8)); + result.Add(MutableString.Create("ABRT"), RuntimeHelpers.Int32ToObject(22)); + result.Add(MutableString.Create("ILL"), RuntimeHelpers.Int32ToObject(4)); + return result; + } + + [RubyMethod("trap", RubyMethodAttributes.PublicSingleton)] + public static object Trap(CodeContext/*!*/ context, RubyModule/*!*/ self, object signalId, [NotNull]Proc/*!*/ proc) { + // TODO: For now, just ignore the signal handler. The full implementation will need to build on + // the signal and raise functions in msvcrt. + return null; + } + + [RubyMethod("trap", RubyMethodAttributes.PublicSingleton)] + public static object Trap(CodeContext/*!*/ context, RubyModule/*!*/ self, BlockParam block, object/*!*/ signalId) { + // TODO: For now, just ignore the signal handler. The full implementation will need to build on + // the signal and raise functions in msvcrt. + return null; + } + + + #endregion + } +} +#endif =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/BasicSocket.cs;C443395 File: BasicSocket.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/BasicSocket.cs;C443395 (server) 5/23/2008 2:34 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/BasicSocket.cs;miscfixes2 @@ -316,7 +316,7 @@ result.Add(MutableString.Create(ep.Address.ToString())); } else { // TODO: MRI returns localhost rather than the local machine name here - result.Add(MutableString.Create(System.Net.Dns.GetHostEntry(ep.Address).HostName)); + result.Add(MutableString.Create(Dns.GetHostEntry(ep.Address).HostName)); } result.Add(MutableString.Create(ep.Address.ToString())); return result; =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/Socket.cs;C443395 File: Socket.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/Socket.cs;C443395 (server) 5/23/2008 2:05 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/socket/Socket.cs;miscfixes2 @@ -43,27 +43,56 @@ int protocolType = Protocols.CastToFixnum(context, protocol); RubyArray results = new RubyArray(); - IPHostEntry entry = Dns.GetHostEntry(strHostname.ConvertToString()); - for(int i=0; i< entry.AddressList.Length; ++i) { + + IPHostEntry entry = GetHostEntry(strHostname.ConvertToString()); + for (int i = 0; i < entry.AddressList.Length; ++i) { IPAddress address = entry.AddressList[i]; RubyArray result = new RubyArray(); result.Add(ToAddressFamilyString(address.AddressFamily)); - result.Add(MutableString.Create(iPort.ToString())); - if ( DoNotReverseLookup ) { + result.Add(iPort); + if (DoNotReverseLookup) { result.Add(MutableString.Create(address.ToString())); } else { - IPHostEntry alias = Dns.GetHostEntry(address); + IPHostEntry alias = GetHostEntry(address); result.Add(MutableString.Create(alias.HostName)); } result.Add(MutableString.Create(address.ToString())); result.Add((int)address.AddressFamily); result.Add((int)socketType); - result.Add(iPort); + + // TODO: protocol type: + result.Add(IPPROTO_UDP); + results.Add(result); } return results; } + // TODO: handle other invalid addresses + private static IPHostEntry/*!*/ GetHostEntry(IPAddress/*!*/ address) { + if (address.Equals(IPAddress.Any)) { + return MakeAnyEntry(); + } else { + return Dns.GetHostEntry(address); + } + } + + private static IPHostEntry/*!*/ GetHostEntry(string/*!*/ hostNameOrAddress) { + if (hostNameOrAddress == IPAddress.Any.ToString()) { + return MakeAnyEntry(); + } else { + return Dns.GetHostEntry(hostNameOrAddress); + } + } + + private static IPHostEntry/*!*/ MakeAnyEntry() { + IPHostEntry entry = new IPHostEntry(); + entry.AddressList = new IPAddress[] { IPAddress.Any }; + entry.Aliases = new string[] { IPAddress.Any.ToString() }; + entry.HostName = IPAddress.Any.ToString(); + return entry; + } + [RubyMethod("gethostbyaddr", RubyMethodAttributes.PublicSingleton)] public static RubyArray GetHostByAddress(CodeContext/*!*/ context, RubyClass/*!*/ klass, object address, [Optional]object type) { if (type is Missing) { @@ -72,7 +101,7 @@ AddressFamily addressFamily = ConvertToAddressFamily(context, type); MutableString strAddress = Protocols.CastToString(context, address); - IPHostEntry entry = Dns.GetHostEntry(new IPAddress(strAddress.ConvertToBytes())); + IPHostEntry entry = GetHostEntry(new IPAddress(strAddress.ConvertToBytes())); return CreateHostEntryArray(entry, true); } @@ -144,7 +173,7 @@ address = ConvertToHostString(context, hostInfo[3]); } - IPHostEntry entry = Dns.GetHostEntry(address.ConvertToString()); + IPHostEntry entry = GetHostEntry(address.ConvertToString()); RubyArray result = new RubyArray(2); result.Add(MutableString.Create(entry.HostName)); @@ -160,7 +189,7 @@ public static RubyArray/*!*/ GetNameInfo(CodeContext/*!*/ context, RubyClass/*!*/ klass, object address, [Optional]object flags) { MutableString string_address = Protocols.CastToString(context, address); IPEndPoint ep = UnpackSockAddr(string_address); - IPHostEntry entry = Dns.GetHostEntry(ep.Address); + IPHostEntry entry = GetHostEntry(ep.Address); ServiceName service = SearchForService(ep.Port); RubyArray result = new RubyArray(2); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C447029 File: Ruby.csproj =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C447029 (server) 5/23/2008 4:13 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;miscfixes2 @@ -120,6 +120,7 @@ + =================================================================== 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/RubyModule.cs;C444795 File: RubyModule.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C444795 (server) 5/23/2008 4:13 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;miscfixes2 @@ -562,7 +562,7 @@ SetLibraryMethod(SymbolTable.StringToId(name), new RubyCustomMethodInfo(generator, visibility, this), skipEvent); } - private void SetLibraryMethod(SymbolId name, RubyMemberInfo/*!*/ method, bool noEvent) { + public void SetLibraryMethod(SymbolId name, RubyMemberInfo/*!*/ method, bool noEvent) { // trigger event only for non-builtins: if (noEvent) { SetMethodNoEvent(name, method); =================================================================== add: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyAccessorInfo.cs File: RubyAccessorInfo.cs =================================================================== --- [no source file] +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyAccessorInfo.cs;miscfixes2 @@ -1,0 +1,77 @@ +?/* **************************************************************************** + * + * 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 Microsoft.Scripting.Utils; +using Microsoft.Scripting.Actions; +using Microsoft.Scripting.Runtime; +using Microsoft.Scripting; + +using Ruby.Builtins; + +namespace Ruby.Runtime.Calls { + using Ast = Microsoft.Scripting.Ast.Expression; + using AstFactory = Ruby.Compiler.Ast.AstFactory; + using Microsoft.Scripting.Ast; + + public abstract class RubyAttributeAccessorInfo : RubyMemberInfo { + protected readonly SymbolId _instanceVariableName; + + protected RubyAttributeAccessorInfo(RubyMethodVisibility visibility, RubyModule/*!*/ declaringModule, string/*!*/ name) + : base(visibility, declaringModule) { + Assert.NotEmpty(name); + _instanceVariableName = SymbolTable.StringToId("@" + name); + } + } + + public sealed class RubyAttributeReaderInfo : RubyAttributeAccessorInfo { + public RubyAttributeReaderInfo(RubyMethodVisibility visibility, RubyModule/*!*/ declaringModule, string/*!*/ name) + : base(visibility, declaringModule, name) { + } + + internal override void SetInvocationRule(string/*!*/ name, ActionBinder/*!*/ binder, CodeContext/*!*/ callerContext, + RuleBuilder/*!*/ rule, CallArguments/*!*/ args) { + + rule.Target = rule.MakeReturn(binder, + AstFactory.OpCall("GetInstanceVariable", + rule.Context, + Ast.Convert(args.Expressions[0], typeof(object)), + Ast.Constant(_instanceVariableName) + ) + ); + } + } + + public sealed class RubyAttributeWriterInfo : RubyAttributeAccessorInfo { + public RubyAttributeWriterInfo(RubyMethodVisibility visibility, RubyModule/*!*/ declaringModule, string/*!*/ name) + : base(visibility, declaringModule, name) { + } + + internal override void SetInvocationRule(string/*!*/ name, ActionBinder/*!*/ binder, CodeContext/*!*/ callerContext, + RuleBuilder/*!*/ rule, CallArguments/*!*/ args) { + + VariableExpression bfc; + Expression[] actualArgs = RubyMethodGroupInfo.MakeActualArgs(rule, args, 0, out bfc); + + rule.Target = rule.MakeReturn(binder, + AstFactory.OpCall("SetInstanceVariable", + Ast.Convert(actualArgs[0], typeof(object)), + Ast.Convert(actualArgs[1], typeof(object)), + rule.Context, + Ast.Constant(_instanceVariableName) + ) + ); + } + } +} =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;C429806 File: RubyMemberInfo.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;C429806 (server) 5/23/2008 4:13 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;miscfixes2 @@ -64,7 +64,7 @@ } internal virtual void SetInvocationRule(string name, ActionBinder/*!*/ binder, CodeContext/*!*/ callerContext, - RuleBuilder/*!*/ result, CallArguments/*!*/ args) { + RuleBuilder/*!*/ rule, CallArguments/*!*/ args) { throw Assert.Unreachable; } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RuleGenerators.cs;C445606 File: RuleGenerators.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RuleGenerators.cs;C445606 (server) 5/23/2008 4:13 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RuleGenerators.cs;miscfixes2 @@ -51,34 +51,5 @@ ((RubyMethod)args.Values[0]).SetRuleForCall(rule, callerContext, binder, args); } - - public static void AttributeRead(string/*!*/ name, ActionBinder/*!*/ binder, CodeContext/*!*/ callerContext, - RuleBuilder/*!*/ rule, CallArguments/*!*/ args) { - - rule.Target = rule.MakeReturn(binder, - AstFactory.OpCall("GetInstanceVariable", - rule.Context, - Ast.Convert(args.Expressions[0], typeof(object)), - Ast.Constant(SymbolTable.StringToId("@" + name)) - ) - ); - } - - public static void AttributeWrite(string/*!*/ name, ActionBinder/*!*/ binder, CodeContext/*!*/ callerContext, - RuleBuilder/*!*/ rule, CallArguments/*!*/ args) { - Debug.Assert(name.EndsWith("=")); - - VariableExpression bfc; - Expression[] actualArgs = RubyMethodGroupInfo.MakeActualArgs(rule, args, 0, out bfc); - - rule.Target = rule.MakeReturn(binder, - AstFactory.OpCall("SetInstanceVariable", - Ast.Convert(actualArgs[0], typeof(object)), - Ast.Convert(actualArgs[1], typeof(object)), - rule.Context, - Ast.Constant(SymbolTable.StringToId("@" + name.Substring(0, name.Length - 1))) - ) - ); - } } } ===================================================================