Author: jbevain
Date: 2008-01-31 11:53:42 -0500 (Thu, 31 Jan 2008)
New Revision: 94475

Modified:
   trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
   trunk/mcs/class/System.Core/System.Linq.Expressions/MemberExpression.cs
Log:
2008-01-31  Jb Evain  <[EMAIL PROTECTED]>

        * MemberExpression.cs: Simple support for emitting fields.



Modified: trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog       
2008-01-31 16:28:57 UTC (rev 94474)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog       
2008-01-31 16:53:42 UTC (rev 94475)
@@ -1,3 +1,7 @@
+2008-01-31  Jb Evain  <[EMAIL PROTECTED]>
+
+       * MemberExpression.cs: Simple support for emitting fields.
+
 2008-01-30  Jb Evain  <[EMAIL PROTECTED]>
 
        * MethodCallExpression.cs: very naive implementation of Emit.

Modified: 
trunk/mcs/class/System.Core/System.Linq.Expressions/MemberExpression.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/MemberExpression.cs     
2008-01-31 16:28:57 UTC (rev 94474)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/MemberExpression.cs     
2008-01-31 16:53:42 UTC (rev 94475)
@@ -28,7 +28,7 @@
 
 using System;
 using System.Reflection;
-using System.Text;
+using System.Reflection.Emit;
 
 namespace System.Linq.Expressions {
 
@@ -54,7 +54,33 @@
 
                internal override void Emit (EmitContext ec)
                {
+                       var property = member as PropertyInfo;
+                       if (property != null) {
+                               EmitPropertyAccess (ec, property);
+                               return;
+                       }
+
+                       var field = member as FieldInfo;
+                       if (field != null) {
+                               EmitFieldAccess (ec, field);
+                               return;
+                       }
+
+                       throw new NotSupportedException ();
+               }
+
+               void EmitPropertyAccess (EmitContext ec, PropertyInfo property)
+               {
                        throw new NotImplementedException ();
                }
+
+               void EmitFieldAccess (EmitContext ec, FieldInfo field)
+               {
+                       if (!field.IsStatic) {
+                               expression.Emit (ec);
+                               ec.ig.Emit (OpCodes.Ldfld, field);
+                       } else
+                               ec.ig.Emit (OpCodes.Ldsfld, field);
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to