Author: jbevain
Date: 2008-01-22 09:01:07 -0500 (Tue, 22 Jan 2008)
New Revision: 93526

Modified:
   trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
   trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
   trunk/mcs/class/System.Core/System.Linq.Expressions/ExpressionPrinter.cs
   trunk/mcs/class/System.Core/System.Linq.Expressions/LambdaExpression.cs
   trunk/mcs/class/System.Core/System.Linq.Expressions/NewArrayExpression.cs
Log:
2008-01-22  Jb Evain  <[EMAIL PROTECTED]>

        * Expression.cs, ExpressionPrinter.cs, NewArrayExpression.cs:
        implement Expression.NewArrayBounds.



Modified: trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog       
2008-01-22 13:59:06 UTC (rev 93525)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog       
2008-01-22 14:01:07 UTC (rev 93526)
@@ -1,5 +1,10 @@
 2008-01-22  Jb Evain  <[EMAIL PROTECTED]>
 
+       * Expression.cs, ExpressionPrinter.cs, NewArrayExpression.cs:
+       implement Expression.NewArrayBounds.
+
+2008-01-22  Jb Evain  <[EMAIL PROTECTED]>
+
        * ExpressionPrinter.cs: fix Lambda and Equal.
 
 2008-01-22  Miguel de Icaza  <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs   
2008-01-22 13:59:06 UTC (rev 93525)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs   
2008-01-22 14:01:07 UTC (rev 93526)
@@ -1319,16 +1319,24 @@
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public static NewArrayExpression NewArrayBounds (Type type, 
params Expression [] bounds)
                {
-                       throw new NotImplementedException ();
+                       return NewArrayBounds (type, bounds as 
IEnumerable<Expression>);
                }
 
-               [MonoTODO]
                public static NewArrayExpression NewArrayBounds (Type type, 
IEnumerable<Expression> bounds)
                {
-                       throw new NotImplementedException ();
+                       if (type == null)
+                               throw new ArgumentNullException ("type");
+                       if (bounds == null)
+                               throw new ArgumentNullException ("bounds");
+
+                       var array_bounds = bounds.ToReadOnlyCollection ();
+                       foreach (var expression in array_bounds)
+                               if (!IsInt (expression.Type))
+                                       throw new ArgumentException ("The 
bounds collection can only contain expression of integers types");
+
+                       return new NewArrayExpression 
(ExpressionType.NewArrayBounds, type.MakeArrayType (array_bounds.Count), 
array_bounds);
                }
 
                [MonoTODO]

Modified: 
trunk/mcs/class/System.Core/System.Linq.Expressions/ExpressionPrinter.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/ExpressionPrinter.cs    
2008-01-22 13:59:06 UTC (rev 93525)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/ExpressionPrinter.cs    
2008-01-22 14:01:07 UTC (rev 93526)
@@ -320,6 +320,16 @@
 
                protected override void VisitNewArray (NewArrayExpression 
newArray)
                {
+                       switch (newArray.NodeType) {
+                       case ExpressionType.NewArrayBounds:
+                               Print ("new ");
+                               Print (newArray.Type);
+                               Print ("(");
+                               VisitExpressionList (newArray.Expressions);
+                               Print (")");
+                               return;
+                       }
+
                        throw new NotImplementedException ();
                }
 

Modified: 
trunk/mcs/class/System.Core/System.Linq.Expressions/LambdaExpression.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/LambdaExpression.cs     
2008-01-22 13:59:06 UTC (rev 93525)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/LambdaExpression.cs     
2008-01-22 14:01:07 UTC (rev 93526)
@@ -156,29 +156,30 @@
 
                public Delegate Compile ()
                {
-                       if (lambda_delegate == null){
-                               var ec = new EmitContext (this);
+                       if (lambda_delegate != null)
+                               return lambda_delegate;
 
-                               Emit (ec);
+                       var ec = new EmitContext (this);
 
-                               if (Environment.GetEnvironmentVariable 
("LINQ_DBG") != null){
-                                       string fname = "linq" + 
(EmitContext.method_count-1) + ".dll";
-                                       AssemblyBuilder ab = Thread.GetDomain 
().DefineDynamicAssembly (
-                                               new AssemblyName (fname), 
AssemblyBuilderAccess.RunAndSave, "/tmp");
-                                       
-                                       ModuleBuilder b = 
ab.DefineDynamicModule (fname, fname);
-                                       TypeBuilder tb = b.DefineType ("LINQ", 
TypeAttributes.Public);
-                                       MethodBuilder mb = tb.DefineMethod 
("GeneratedMethod", MethodAttributes.Static, Type, ec.ParamTypes);
-                                       ec.ig = mb.GetILGenerator ();
+                       Emit (ec);
 
-                                       Emit (ec);
+                       if (Environment.GetEnvironmentVariable ("LINQ_DBG") != 
null){
+                               string fname = "linq" + 
(EmitContext.method_count-1) + ".dll";
+                               AssemblyBuilder ab = Thread.GetDomain 
().DefineDynamicAssembly (
+                                       new AssemblyName (fname), 
AssemblyBuilderAccess.RunAndSave, "/tmp");
+                               
+                               ModuleBuilder b = ab.DefineDynamicModule 
(fname, fname);
+                               TypeBuilder tb = b.DefineType ("LINQ", 
TypeAttributes.Public);
+                               MethodBuilder mb = tb.DefineMethod 
("GeneratedMethod", MethodAttributes.Static, Type, ec.ParamTypes);
+                               ec.ig = mb.GetILGenerator ();
 
-                                       tb.CreateType ();
-                                       ab.Save (fname);
-                               }
-                               
-                               lambda_delegate = ec.CreateDelegate ();
+                               Emit (ec);
+
+                               tb.CreateType ();
+                               ab.Save (fname);
                        }
+                       
+                       lambda_delegate = ec.CreateDelegate ();
                        return lambda_delegate;
                }
        }

Modified: 
trunk/mcs/class/System.Core/System.Linq.Expressions/NewArrayExpression.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/NewArrayExpression.cs   
2008-01-22 13:59:06 UTC (rev 93525)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/NewArrayExpression.cs   
2008-01-22 14:01:07 UTC (rev 93526)
@@ -39,6 +39,12 @@
                        get { return expressions; }
                }
 
+               internal NewArrayExpression (ExpressionType et, Type type, 
ReadOnlyCollection<Expression> expressions)
+                       : base (et, type)
+               {
+                       this.expressions = expressions;
+               }
+
                internal override void Emit (EmitContext ec)
                {
                        throw new NotImplementedException ();

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

Reply via email to