Fix compilation of array initializer used inside field initializer of an anonymous...
[mono.git] / mcs / mcs / constant.cs
index f9c84433aeadea46c7f3817e7ea9a165b901c368..04bd2a759351c2dca19e2326b3eb49347f560fd7 100644 (file)
@@ -78,6 +78,11 @@ namespace Mono.CSharp {
                        return c;
                }
 
+               public override bool ContainsEmitWithAwait ()
+               {
+                       return false;
+               }
+
                public virtual Constant ConvertImplicitly (TypeSpec type)
                {
                        if (this.type == type)
@@ -309,7 +314,13 @@ namespace Mono.CSharp {
                
                public virtual bool IsOneInteger {
                        get { return false; }
-               }               
+               }
+
+               public override bool IsSideEffectFree {
+                       get {
+                               return true;
+                       }
+               }
 
                //
                // Returns true iff 1) the stack type of this is one of Object, 
@@ -421,9 +432,9 @@ namespace Mono.CSharp {
                public override void Emit (EmitContext ec)
                {
                        if (Value)
-                               ec.Emit (OpCodes.Ldc_I4_1);
+                               ec.EmitInt (1);
                        else
-                               ec.Emit (OpCodes.Ldc_I4_0);
+                               ec.EmitInt (0);
                }
 
                public override bool IsDefaultValue {
@@ -1939,7 +1950,7 @@ namespace Mono.CSharp {
                public override void Emit (EmitContext ec)
                {
                        if (Value == null) {
-                               ec.Emit (OpCodes.Ldnull);
+                               ec.EmitNull ();
                                return;
                        }
 
@@ -2044,7 +2055,7 @@ namespace Mono.CSharp {
 
                public override void Emit (EmitContext ec)
                {
-                       ec.Emit (OpCodes.Ldnull);
+                       ec.EmitNull ();
 
                        // Only to make verifier happy
                        if (type.IsGenericParameter)
@@ -2146,7 +2157,7 @@ namespace Mono.CSharp {
                        //
                        // Emits null pointer
                        //
-                       ec.Emit (OpCodes.Ldc_I4_0);
+                       ec.EmitInt (0);
                        ec.Emit (OpCodes.Conv_U);
                }
        }
@@ -2156,7 +2167,8 @@ namespace Mono.CSharp {
        ///   used by BitwiseAnd to ensure that the second expression is invoked
        ///   regardless of the value of the left side.  
        /// </summary>
-       public class SideEffectConstant : Constant {
+       public class SideEffectConstant : Constant
+       {
                public readonly Constant value;
                Expression side_effect;
                
@@ -2172,6 +2184,12 @@ namespace Mono.CSharp {
                        this.side_effect = side_effect;
                }
 
+               public override bool IsSideEffectFree {
+                       get {
+                               return false;
+                       }
+               }
+
                public override object GetValue ()
                {
                        return value.GetValue ();