edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;C443395
File: Kernel.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;C443395  (server)    5/20/2008 4:18 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Kernel.cs;Accessors
@@ -723,7 +723,7 @@
         public static object InstanceVariableSet(CodeContext/*!*/ context, object/*!*/ self, SymbolId name, object value) {
             // When setting a value we have to check the name first, otherwise we might insert an invalid value
             CheckInstanceVarName(name);
-            return RubyOps.SetInstanceVariable(context, self, name, value);
+            return RubyOps.SetInstanceVariable(self, value, context, name);
         }
 
         [RubyMethod("instance_variable_set")]
@@ -784,6 +784,7 @@
         }
 
         #region __send__, send
+
         [RubyMethod("__send__")]
         [RubyMethod("send")]
         public static object SendMessage(CodeContext/*!*/ context, object self, BlockParam block) {
@@ -795,12 +796,12 @@
         public static object SendMessage(CodeContext/*!*/ context, object self, BlockParam block, SymbolId methodName, [NotNull]params object[] args) {
             // TODO: This is really slow because it spins up a new site each invocation
             if (block != null) {
-                DynamicSite<object, Proc, List<object>, object> site = DynamicSite<object, Proc, List<object>, object>.Create(
+                DynamicSite<object, Proc, RubyArray, object> site = DynamicSite<object, Proc, RubyArray, object>.Create(
                     RubySites.InstanceCallAction(methodName, ArgumentKind.Block, ArgumentKind.List));
 
                 return site.Invoke(context, self, block.Proc, new RubyArray(args));
             } else {
-                DynamicSite<object, List<object>, object> site = DynamicSite<object, List<object>, object>.Create(
+                DynamicSite<object, RubyArray, object> site = DynamicSite<object, RubyArray, object>.Create(
                     RubySites.InstanceCallAction(methodName, ArgumentKind.List));
 
                 return site.Invoke(context, self, new RubyArray(args));
@@ -812,6 +813,7 @@
         public static object SendMessage(CodeContext/*!*/ context, object self, BlockParam block, object methodName, [NotNull]params object[] args) {
             return SendMessage(context, self, block, Protocols.CastToSymbol(context, methodName), args);
         }
+
         #endregion
 
         #region method, methods, singleton_methods
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs;C443395
File: Marshal.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs;C443395  (server)    5/20/2008 6:32 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs;Accessors
@@ -634,7 +634,7 @@
                     obj = UnmarshalNewObject(baseType);
                     for (int i = 0; i < count; i++) {
                         SymbolId name = ReadSymbol();
-                        RubyOps.SetInstanceVariable(_context, obj, name, ReadAnObject());
+                        RubyOps.SetInstanceVariable(obj, ReadAnObject(), _context, name);
                     }
                 }
                 return obj;
@@ -718,7 +718,7 @@
                 int count = ReadInt32();
                 for (int i = 0; i < count; i++) {
                     SymbolId name = ReadSymbol();
-                    RubyOps.SetInstanceVariable(_context, obj, name, ReadAnObject());
+                    RubyOps.SetInstanceVariable(obj, ReadAnObject(), _context, name);
                 }
                 return obj;
             }
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C443395
File: ModuleOps.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C443395  (server)    5/20/2008 4:07 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;Accessors
@@ -276,24 +276,18 @@
         //  method_removed
         //  method_undefined
 
-        private static Function<object, object>/*!*/ CreateGetter(CodeContext/*!*/ context, SymbolId name) {
-            return delegate(object self) { return RubyOps.GetInstanceVariable(context, self, name); };
-        }
-
-        private static Function<object, object, object>/*!*/ CreateSetter(CodeContext/*!*/ context, SymbolId name) {
-            return delegate(object self, object value) { return RubyOps.SetInstanceVariable(context, self, name, value); };
-        }
-
         private static void DefineAccessor(CodeContext/*!*/ context, RubyModule/*!*/ self, SymbolId name, bool readable, bool writable) {
-            string getterMethodName = name.ToString();
-            string setterMethodName = getterMethodName + "=";
-            SymbolId instanceVariableName = SymbolTable.StringToId("@" + getterMethodName);
+            string getterMethodName = SymbolTable.IdToString(name);
 
-            if (readable)
-                self.DefineMethod(getterMethodName, (int)RubyMethodAttributes.PublicInstance, CreateGetter(context, instanceVariableName));
+            RubyScope scope = RubyUtils.GetScope(context);
 
-            if (writable)
-                self.DefineMethod(setterMethodName, (int)RubyMethodAttributes.PublicInstance, CreateSetter(context, instanceVariableName));
+            if (readable) {
+                self.DefineRuleGenerator(getterMethodName, (int)scope.MethodAttributes, new RuleGenerator(RuleGenerators.AttributeRead));
+            }
+            
+            if (writable) {
+                self.DefineRuleGenerator(getterMethodName + "=", (int)scope.MethodAttributes, new RuleGenerator(RuleGenerators.AttributeWrite));
+            }
         }
 
         [RubyMethod("attr", RubyMethodAttributes.PrivateInstance)]
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Struct.cs;C443985
File: Struct.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Struct.cs;C443985  (server)    5/20/2008 4:42 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Struct.cs;Accessors
@@ -22,8 +22,10 @@
 using Microsoft.Scripting.Utils;
 using Ruby.Runtime;
 using Microsoft.Scripting.Runtime;
+using Ruby.Runtime.Calls;
 
 namespace Ruby.Builtins {
+    using Ast = Microsoft.Scripting.Ast.Expression;
     
     /// <summary>
     /// Struct is an interesting Ruby class because it generates other classes.
@@ -86,6 +88,20 @@
 
         #endregion
 
+        #region Emitted Helpers
+
+        // emitted: 
+        public object GetData(int index) {
+            return _data[index];
+        }
+
+        // emitted: 
+        public object SetData(int index, object value) {
+            return _data[index] = value;
+        }
+        
+        #endregion
+
         #region IDuplicable Members
 
         void IDuplicable.InitializeFrom(object obj) {
@@ -466,17 +482,38 @@
 
             for (int i = 0; i < structMembers.Length; i++) {
                 string getter = SymbolTable.IdToString(structMembers[i]);
-                cls.DefineMethod(getter, (int)RubyMethodAttributes.PublicInstance, CreateGetter(i));
-                cls.DefineMethod(getter + '=', (int)RubyMethodAttributes.PublicInstance, CreateSetter(i));
+                cls.DefineRuleGenerator(getter, (int)RubyMethodAttributes.PublicInstance, CreateGetter(i));
+                cls.DefineRuleGenerator(getter + '=', (int)RubyMethodAttributes.PublicInstance, CreateSetter(i));
             }
         }
 
-        private static Function<RubyStruct, object>/*!*/ CreateGetter(int index) {
-            return delegate(RubyStruct self) { return self._data[index]; };
+        private static RuleGenerator/*!*/ CreateGetter(int index) {
+            return delegate(string/*!*/ name, ActionBinder/*!*/ binder, CodeContext/*!*/ callerContext, RuleBuilder/*!*/ rule, CallArguments/*!*/ args) {
+                rule.Target = rule.MakeReturn(binder,
+                    Ast.Call(
+                        Ast.Convert(args.Expressions[0], typeof(RubyStruct)), 
+                        typeof(RubyStruct).GetMethod("GetData"), 
+                        Ast.Constant(index)
+                    )
+                ); 
+            };
         }
 
-        private static Function<RubyStruct, object, object>/*!*/ CreateSetter(int index) {
-            return delegate(RubyStruct self, object value) { return self._data[index] = value; };
+        private static RuleGenerator/*!*/ CreateSetter(int index) {
+            return delegate(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,
+                    Ast.Call(
+                        Ast.Convert(actualArgs[0], typeof(RubyStruct)), 
+                        typeof(RubyStruct).GetMethod("SetData"), 
+                        Ast.Constant(index), 
+                        Ast.Convert(actualArgs[1], typeof(object))
+                   )
+                );
+            };
         }
     }
 }
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/LeftValues/InstanceVariable.cs;C440810
File: InstanceVariable.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/LeftValues/InstanceVariable.cs;C440810  (server)    5/20/2008 6:27 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/LeftValues/InstanceVariable.cs;Accessors
@@ -34,7 +34,7 @@
         }
 
         internal override MSA.Expression/*!*/ TransformWriteVariable(AstGenerator/*!*/ gen, MSA.Expression/*!*/ rightValue) {
-            return AstFactory.OpCall("SetInstanceVariable", Ast.CodeContext(), gen.CurrentSelfVariable, Ast.Constant(Name), rightValue);
+            return AstFactory.OpCall("SetInstanceVariable", gen.CurrentSelfVariable, rightValue, Ast.CodeContext(), Ast.Constant(Name));
         }
 
         internal override MSA.Expression TransformDefinedCondition(AstGenerator/*!*/ gen) {
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;C444052
File: RubyOps.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;C444052  (server)    5/20/2008 6:29 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;Accessors
@@ -1111,7 +1111,7 @@
         }
 
         // emitted:
-        public static object SetInstanceVariable(CodeContext/*!*/ context, object self, SymbolId name, object value) {
+        public static object SetInstanceVariable(object self, object value, CodeContext/*!*/ context, SymbolId name) {
             RubyUtils.GetExecutionContext(context).GetInstanceData(self).SetInstanceVariable(name, value);
             return value;
         }
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/CallArguments.cs;C429806
File: CallArguments.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/CallArguments.cs;C429806  (server)    5/20/2008 6:22 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/CallArguments.cs;Accessors
@@ -34,11 +34,11 @@
         private readonly IList<Expression/*!*/>/*!*/ _expressions;
         private readonly CallSignature _signature;
 
-        internal object[]/*!*/ Values {
+        public object[]/*!*/ Values {
             get { return _values; }
         }
 
-        internal IList<Expression/*!*/>/*!*/ Expressions {
+        public IList<Expression/*!*/>/*!*/ Expressions {
             get { return _expressions; }
         }
 
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupInfo.cs;C443395
File: RubyMethodGroupInfo.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupInfo.cs;C443395  (server)    5/20/2008 4:23 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupInfo.cs;Accessors
@@ -54,6 +54,7 @@
             Assert.NotNullItems(overloads);
             Assert.NotNull(declaringModule);
             _overloads = overloads;
+
             _isStatic = isStatic;
         }
 
@@ -70,20 +71,6 @@
             RuleBuilder/*!*/ result, CallArguments/*!*/ args) {
 
             Assert.NotNull(binder, result, args);
-            
-            // TODO: this is a hack to support for bound delegates
-            // This is needed if the delegate is a C# closure (e.g. Struct getters/setters)
-            // This can go away once the method binder understands delegates insteade of MethodInfos
-            if (_overloads != null && _overloads.Length == 1 && _overloads[0].Target != null) {
-                object delegateTarget = _overloads[0].Target;
-
-                args = args.InsertAt(0, delegateTarget, Ast.RuntimeConstant(delegateTarget));
-                // HACK: this flattens out the call signature to a simple one, because
-                // GetSignatureToMatch/MakeActualArgs can't handle it otherwise
-                // (those functions really need cleanup)
-                args = new CallArguments(args.Values, args.Expressions, new CallSignature(args.Length));
-            }
-
             SetInvocationRuleInternal(name, MethodBases, binder, result, args, _isStatic, null);
         }
 
@@ -237,7 +224,7 @@
             return false;
         }
 
-        private static Expression[]/*!*/ MakeActualArgs(RuleBuilder/*!*/ rule, CallArguments/*!*/ args, int blockAdjust, out VariableExpression bfcVariable) {
+        public static Expression[]/*!*/ MakeActualArgs(RuleBuilder/*!*/ rule, CallArguments/*!*/ args, int blockAdjust, out VariableExpression bfcVariable) {
 
             // TODO: the test should be generated by MakeBindingTarget
 
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RuleGenerators.cs;C438696
File: RuleGenerators.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RuleGenerators.cs;C438696  (server)    5/20/2008 5:52 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RuleGenerators.cs;Accessors
@@ -13,14 +13,17 @@
  *
  * ***************************************************************************/
 
+using System.Diagnostics;
 using Microsoft.Scripting.Actions;
 using Microsoft.Scripting.Runtime;
+using Microsoft.Scripting;
 using Ruby.Builtins;
-using System.Diagnostics;
 
 namespace Ruby.Runtime.Calls {
     using Ast = Microsoft.Scripting.Ast.Expression;
-    
+    using AstFactory = Ruby.Compiler.Ast.AstFactory;
+    using Microsoft.Scripting.Ast;
+        
     public delegate void RuleGenerator(string/*!*/ name, ActionBinder/*!*/ binder, CodeContext/*!*/ callerContext,
         RuleBuilder/*!*/ result, CallArguments/*!*/ args);
 
@@ -48,5 +51,34 @@
 
             ((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)))
+                )
+            );
+        }
     }
 }
===================================================================
