2008-07-14 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / cfold.cs
index 61896262e907554e2eb22442cc5c95012678f144..d2b8c0bf07a2223e366b148e557b84bfc2d7b6f9 100644 (file)
@@ -5,9 +5,9 @@
 //   Miguel de Icaza (miguel@ximian.com)
 //   Marek Safar (marek.safar@seznam.cz)
 //
-// (C) 2002, 2003 Ximian, Inc.
-//
-
+// Copyright 2002, 2003 Ximian, Inc.
+// Copyright 2003-2008, Novell, Inc.
+// 
 using System;
 
 namespace Mono.CSharp {
@@ -80,7 +80,7 @@ namespace Mono.CSharp {
                                return BinaryFold (ec, oper, ((EmptyConstantCast)left).child, right, loc);
 
                        if (left is SideEffectConstant) {
-                               result = BinaryFold (ec, oper, ((SideEffectConstant) left).left, right, loc);
+                               result = BinaryFold (ec, oper, ((SideEffectConstant) left).value, right, loc);
                                if (result == null)
                                        return null;
                                return new SideEffectConstant (result, left, loc);
@@ -90,7 +90,7 @@ namespace Mono.CSharp {
                                return BinaryFold (ec, oper, left, ((EmptyConstantCast)right).child, loc);
 
                        if (right is SideEffectConstant) {
-                               result = BinaryFold (ec, oper, left, ((SideEffectConstant) right).left, loc);
+                               result = BinaryFold (ec, oper, left, ((SideEffectConstant) right).value, loc);
                                if (result == null)
                                        return null;
                                return new SideEffectConstant (result, right, loc);
@@ -782,7 +782,7 @@ namespace Mono.CSharp {
                        case Binary.Operator.LeftShift:
                                IntConstant ic = right.ConvertImplicitly (TypeManager.int32_type) as IntConstant;
                                if (ic == null){
-                                       Binary.Error_OperatorCannotBeApplied (loc, "<<", lt, rt);
+                                       Binary.Error_OperatorCannotBeApplied (left, right, oper, loc);
                                        return null;
                                }
 
@@ -798,7 +798,7 @@ namespace Mono.CSharp {
                                if (left.Type == TypeManager.int32_type)
                                        return new IntConstant (((IntConstant)left).Value << lshift_val, left.Location);
 
-                               Binary.Error_OperatorCannotBeApplied (loc, "<<", lt, rt);
+                               Binary.Error_OperatorCannotBeApplied (left, right, oper, loc);
                                break;
 
                                //
@@ -807,7 +807,7 @@ namespace Mono.CSharp {
                        case Binary.Operator.RightShift:
                                IntConstant sic = right.ConvertImplicitly (TypeManager.int32_type) as IntConstant;
                                if (sic == null){
-                                       Binary.Error_OperatorCannotBeApplied (loc, ">>", lt, rt);
+                                       Binary.Error_OperatorCannotBeApplied (left, right, oper, loc); ;
                                        return null;
                                }
                                int rshift_val = sic.Value;
@@ -822,18 +822,18 @@ namespace Mono.CSharp {
                                if (left.Type == TypeManager.int32_type)
                                        return new IntConstant (((IntConstant)left).Value >> rshift_val, left.Location);
 
-                               Binary.Error_OperatorCannotBeApplied (loc, ">>", lt, rt);
+                               Binary.Error_OperatorCannotBeApplied (left, right, oper, loc);
                                break;
 
                        case Binary.Operator.Equality:
-                               if (left is NullConstant){
-                                       if (right is NullConstant)
+                               if (left is NullLiteral){
+                                       if (right is NullLiteral)
                                                return new BoolConstant (true, left.Location);
                                        else if (right is StringConstant)
                                                return new BoolConstant (
                                                        ((StringConstant) right).Value == null, left.Location);
-                               } else if (right is NullConstant){
-                                       if (left is NullConstant)
+                               } else if (right is NullLiteral) {
+                                       if (left is NullLiteral)
                                                return new BoolConstant (true, left.Location);
                                        else if (left is StringConstant)
                                                return new BoolConstant (
@@ -874,14 +874,14 @@ namespace Mono.CSharp {
                                return new BoolConstant (bool_res, left.Location);
 
                        case Binary.Operator.Inequality:
-                               if (left is NullConstant){
-                                       if (right is NullConstant)
+                               if (left is NullLiteral) {
+                                       if (right is NullLiteral)
                                                return new BoolConstant (false, left.Location);
                                        else if (right is StringConstant)
                                                return new BoolConstant (
                                                        ((StringConstant) right).Value != null, left.Location);
-                               } else if (right is NullConstant){
-                                       if (left is NullConstant)
+                               } else if (right is NullLiteral) {
+                                       if (left is NullLiteral)
                                                return new BoolConstant (false, left.Location);
                                        else if (left is StringConstant)
                                                return new BoolConstant (