Author: jbevain
Date: 2008-01-22 09:20:05 -0500 (Tue, 22 Jan 2008)
New Revision: 93528
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
Log:
2008-01-22 Jb Evain <[EMAIL PROTECTED]>
* Expression.cs, ExpressionPrinter.cs: implement NewArrayList.
Modified: trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
2008-01-22 14:17:16 UTC (rev 93527)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/ChangeLog
2008-01-22 14:20:05 UTC (rev 93528)
@@ -1,5 +1,9 @@
2008-01-22 Jb Evain <[EMAIL PROTECTED]>
+ * Expression.cs, ExpressionPrinter.cs: implement NewArrayList.
+
+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/Expression.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
2008-01-22 14:17:16 UTC (rev 93527)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
2008-01-22 14:20:05 UTC (rev 93528)
@@ -1339,16 +1339,31 @@
return new NewArrayExpression
(ExpressionType.NewArrayBounds, type.MakeArrayType (array_bounds.Count),
array_bounds);
}
- [MonoTODO]
- public static NewArrayExpression NewArrayInit (Type type,
params Expression [] bounds)
+ public static NewArrayExpression NewArrayInit (Type type,
params Expression [] initializers)
{
- throw new NotImplementedException ();
+ return NewArrayInit (type, initializers as
IEnumerable<Expression>);
}
- [MonoTODO]
- public static NewArrayExpression NewArrayInit (Type type,
IEnumerable<Expression> bounds)
+ public static NewArrayExpression NewArrayInit (Type type,
IEnumerable<Expression> initializers)
{
- throw new NotImplementedException ();
+ if (type == null)
+ throw new ArgumentNullException ("type");
+ if (initializers == null)
+ throw new ArgumentNullException
("initializers");
+
+ var array_initializers =
initializers.ToReadOnlyCollection ();
+
+ foreach (var expression in initializers) {
+ if (expression == null)
+ throw new ArgumentNullException
("initializers");
+
+ if (!type.IsAssignableFrom (expression.Type))
+ throw new InvalidOperationException ();
+
+ // TODO: Quote elements if type == typeof
(Expression)
+ }
+
+ return new NewArrayExpression
(ExpressionType.NewArrayInit, type.MakeArrayType (), array_initializers);
}
public static UnaryExpression Not (Expression expression)
Modified:
trunk/mcs/class/System.Core/System.Linq.Expressions/ExpressionPrinter.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/ExpressionPrinter.cs
2008-01-22 14:17:16 UTC (rev 93527)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/ExpressionPrinter.cs
2008-01-22 14:20:05 UTC (rev 93528)
@@ -320,17 +320,22 @@
protected override void VisitNewArray (NewArrayExpression
newArray)
{
+ Print ("new ");
switch (newArray.NodeType) {
case ExpressionType.NewArrayBounds:
- Print ("new ");
Print (newArray.Type);
Print ("(");
VisitExpressionList (newArray.Expressions);
Print (")");
return;
+ case ExpressionType.NewArrayInit:
+ Print ("[] {");
+ VisitExpressionList (newArray.Expressions);
+ Print ("}");
+ return;
}
- throw new NotImplementedException ();
+ throw new NotSupportedException ();
}
protected override void VisitInvocation (InvocationExpression
invocation)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches