* expression.cs (Binary.CheckIsArguments): Added
authorJambunathan K <jambunathan@mono-cvs.ximian.com>
Sat, 7 May 2005 20:50:53 +0000 (20:50 -0000)
committerJambunathan K <jambunathan@mono-cvs.ximian.com>
Sat, 7 May 2005 20:50:53 +0000 (20:50 -0000)
(Binary.Emit, Binary.CheckArguments): Modified to support 'Is'
operator.

svn path=/trunk/mcs/; revision=44208

mcs/bmcs/ChangeLog
mcs/bmcs/expression.cs

index 68da2c8c7a71aff83b29c1a81d3085270e9f8fc9..7ca87c9d97b4487a942dcf03c32b4fa0766555ca 100644 (file)
@@ -1,4 +1,10 @@
-2005-05-01  Jambunathan K  <kjambunathan.devel@gmail.com>
+2005-05-08  Jambunathan K  <kjambunathan.devel@gmail.com>
+
+       * expression.cs (Binary.CheckIsArguments): Added
+       (Binary.Emit, Binary.CheckArguments): Modified to support 'Is'
+       operator.
+       
+2005-05-08  Jambunathan K  <kjambunathan.devel@gmail.com>
 
        * convert.cs: 
        * expression.cs: Miscellaneous fixes relating to
index b87d2544543afa02f7e3432fb98e4721c352334b..d8562f5155e6527a8d43bf1bdd13b2e67e33cd9d 100644 (file)
@@ -2301,6 +2301,45 @@ namespace Mono.CSharp {
                        right = new Binary (Binary.Operator.BitwiseAnd, right, new IntLiteral (mask), loc);
                        right = right.DoResolve (ec);
                }
+
+               void CheckIsArguments (EmitContext ec)
+               {
+                               Type l = left.Type;
+                               Type r = right.Type;
+                               Type = TypeManager.bool_type;
+                               
+                               bool left_is_null = left is NullLiteral;
+                               bool right_is_null = right is NullLiteral;
+
+                               if (left_is_null || right_is_null)
+                                       return;
+
+                               if (l.IsValueType || r.IsValueType) {
+                                       Error_OperatorCannotBeApplied ();
+                                       return;
+                               }
+
+                               
+                               if (l == r)
+                                       return; 
+                                       
+                               if (l.IsSubclassOf (r) || r.IsSubclassOf (l))
+                                       return; 
+
+                               if (!(Convert.WideningStandardConversionExists (ec, left, right.Type) ||
+                                     Convert.WideningStandardConversionExists (ec, right, left.Type))){
+                                       Error_OperatorCannotBeApplied ();
+                                       return;
+                               }
+
+                               if (left.Type != TypeManager.object_type)
+                                       left = new EmptyCast (left, TypeManager.object_type);
+                               if (right.Type != TypeManager.object_type)
+                                       right = new EmptyCast (right, TypeManager.object_type);
+
+                               return;
+               }
+
                
 #if false
                Expression ResolveOperator (EmitContext ec)
@@ -3076,6 +3115,7 @@ namespace Mono.CSharp {
                                opcode = OpCodes.Shl;
                                break;
 
+                       case Operator.Is:
                        case Operator.Equality:
                                opcode = OpCodes.Ceq;
                                break;
@@ -3285,7 +3325,7 @@ namespace Mono.CSharp {
                        Expression target_left_expr = left;
                        Expression target_right_expr = right;
 
-                       if (IsShortCircuitedLogicalExpression)
+                       if (IsShortCircuitedLogicalExpression || IsExpression)
                                return null;
 
                        if (l != TypeManager.object_type && r != TypeManager.object_type)
@@ -3365,6 +3405,11 @@ namespace Mono.CSharp {
                                return;
                        }
 
+                       if (IsExpression) {
+                               CheckIsArguments (ec);
+                               return;
+                       }
+
                        while (true) {
                                ++step;
 
@@ -3719,6 +3764,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               bool IsExpression {
+                       get {
+                               return (oper == Operator.Is);
+                       }
+               }
+
                MethodInfo HelperMethod {
                        get {
                                MethodInfo helper_method = null;