2009-02-16 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / nullable.cs
index b2277407d802b65bf85a7e0c0717b66edc255ea3..c058e59db45a1a087aa33d1c5c4a1195d43b5f80 100644 (file)
@@ -136,22 +136,19 @@ namespace Mono.CSharp.Nullable
                public override void Emit (EmitContext ec)
                {
                        Store (ec);
-                       AddressOf (ec, AddressOp.LoadStore);
-                       ec.ig.EmitCall (OpCodes.Call, info.Value, null);
+                       Invocation.EmitCall (ec, false, this, info.Value, null, loc);
                }
 
                public void EmitCheck (EmitContext ec)
                {
                        Store (ec);
-                       AddressOf (ec, AddressOp.LoadStore);
-                       ec.ig.EmitCall (OpCodes.Call, info.HasValue, null);
+                       Invocation.EmitCall (ec, false, this, info.HasValue, null, loc);
                }
 
                public void EmitGetValueOrDefault (EmitContext ec)
                {
                        Store (ec);
-                       AddressOf (ec, AddressOp.LoadStore);
-                       ec.ig.EmitCall (OpCodes.Call, info.GetValueOrDefault, null);
+                       Invocation.EmitCall (ec, false, this, info.GetValueOrDefault, null, loc);
                }
 
                public override bool Equals (object obj)
@@ -626,13 +623,13 @@ namespace Mono.CSharp.Nullable
                        // Arguments can be lifted for equal operators when the return type is bool and both
                        // arguments are of same type
                        //      
-                       if (left is NullLiteral) {
+                       if (left_orig.IsNull) {
                                left = right;
                                left_null_lifted = true;
                                type = TypeManager.bool_type;
                        }
 
-                       if (right is NullLiteral) {
+                       if (right_orig.IsNull) {
                                right = left;
                                right_null_lifted = true;
                                type = TypeManager.bool_type;
@@ -807,10 +804,10 @@ namespace Mono.CSharp.Nullable
 
                        if ((Oper & Operator.ComparisonMask) != 0) {
                                //
-                               // Emit true when equality operator both operands are null
-                               // or inequality operator operands has only one null
+                               // Emit true when equality operator both operands are same
+                               // or inequality operator operands are not
                                //
-                               if ((Oper == Operator.Equality && left_unwrap != null && right_unwrap != null) ||
+                               if ((Oper == Operator.Equality && left_unwrap == right_unwrap) ||
                                        (Oper == Operator.Inequality && left_unwrap != right_unwrap))
                                        ig.Emit (OpCodes.Ldc_I4_1);
                                else