rename wrt to our conventions
[mono.git] / mcs / class / System.Core / System.Linq.Expressions / ListInitExpression.cs
index 4bafad54ec96d462bab28d3b7be2cc878f81a819..30915a89dc3b28933cae728236ef027a61509023 100644 (file)
@@ -1,4 +1,12 @@
-// Permission is hereby granted, free of charge, to any person obtaining
+//
+// ListInitExpression.cs
+//
+// Author:
+//   Jb Evain (jbevain@novell.com)
+//
+// (C) 2008 Novell, Inc. (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
 // without limitation the rights to use, copy, modify, merge, publish,
 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-//
-// Authors:
-//             Antonello Provenzano  <antonello@deveel.com>
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System;
+using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Text;
 
-namespace System.Linq.Expressions
-{
-       public sealed class ListInitExpression : Expression
-       {
-               #region .ctor
-               internal ListInitExpression(NewExpression newExpression, ReadOnlyCollection<ElementInit> expressions)
-                       : base(ExpressionType.ListInit, newExpression.Type)
-               {
-                       this.newExpression = newExpression;
-                       this.initializers = initializers;
-               }
-               #endregion
+namespace System.Linq.Expressions {
 
-               #region Fields
-               private ReadOnlyCollection<ElementInit> initializers;
-               private NewExpression newExpression;
-               #endregion
+       public sealed class ListInitExpression : Expression {
 
-               #region Properties
-               public ReadOnlyCollection<ElementInit> Initializers
-               {
+               NewExpression new_expression;
+               ReadOnlyCollection<ElementInit> initializers;
+
+               public NewExpression NewExpression {
+                       get { return new_expression; }
+               }
+
+               public ReadOnlyCollection<ElementInit> Initializers {
                        get { return initializers; }
                }
 
-               public NewExpression NewExpression
+               internal ListInitExpression (NewExpression new_expression, ReadOnlyCollection<ElementInit> initializers)
+                       : base (ExpressionType.ListInit, new_expression.Type)
                {
-                       get { return newExpression; }
+                       this.new_expression = new_expression;
+                       this.initializers = initializers;
                }
-               #endregion
 
-               #region Internal Methods
-               internal override void BuildString(StringBuilder builder)
+               internal override void Emit (EmitContext ec)
                {
-                       // we need to build the "new" expression before...
-                       newExpression.BuildString(builder);
-
-                       //... and the elements of the list ...
-                       builder.Append("{");
-
-                       int exprc = initializers.Count;
-                       for (int i = 0; i < exprc; i++)
-                       {
-                               throw new System.NotImplementedException ();
-                               //initializers[i].BuildString(builder);
-                               //if (i < initializers.Count - 1)
-                               //      builder.Append(", ");
-                       }
-
-                       builder.Append("}");
+                       var local = ec.EmitStored (new_expression);
+                       ec.EmitCollection (initializers, local);
+                       ec.EmitLoad (local);
                }
-               #endregion
        }
-}
\ No newline at end of file
+}