Move wapi shutdown to mono_cleanup () as TlsGetValue()/TlsSetValue() is used
[mono.git] / mcs / mcs / assign.cs
index 621cf6ce016e998dca281a1c81e010a07ff54602..8d58e82344ab02ba0f9f2c0674f016d51f108ba1 100644 (file)
@@ -330,12 +330,7 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       if ((RootContext.Version == LanguageVersion.ISO_1) && (source is MethodGroupExpr)){
-                               ((MethodGroupExpr) source).ReportUsageError (ec);
-                               return null;
-                       }
-
-                       if (!TypeManager.IsEqual (target_type, source_type)) {
+                       if (target_type != source_type) {
                                Expression resolved = ResolveConversions (ec);
 
                                if (resolved != this)
@@ -352,7 +347,7 @@ namespace Mono.CSharp {
                        if (tassign == null)
                                throw new InternalErrorException (target.GetType () + " does not support dynamic assignment");
 
-                       var target_object = tassign.MakeAssignExpression (ctx);
+                       var target_object = tassign.MakeAssignExpression (ctx, source);
 
                        //
                        // Some hacking is needed as DLR does not support void type and requires
@@ -506,56 +501,6 @@ namespace Mono.CSharp {
                }
        }
 
-       class EventAddOrRemove : ExpressionStatement {
-               EventExpr target;
-               Binary.Operator op;
-               Expression source;
-
-               public EventAddOrRemove (Expression target, Binary.Operator op, Expression source, Location loc)
-               {
-                       this.target = target as EventExpr;
-                       this.op = op;
-                       this.source = source;
-                       this.loc = loc;
-               }
-
-               public override Expression CreateExpressionTree (ResolveContext ec)
-               {
-                       return new SimpleAssign (target, source).CreateExpressionTree (ec);
-               }
-
-               protected override Expression DoResolve (ResolveContext ec)
-               {
-                       if (op != Binary.Operator.Addition && op != Binary.Operator.Subtraction)
-                               target.Error_AssignmentEventOnly (ec);
-
-                       source = source.Resolve (ec);
-                       if (source == null)
-                               return null;
-
-                       source = Convert.ImplicitConversionRequired (ec, source, target.Type, loc);
-                       if (source == null)
-                               return null;
-
-                       eclass = ExprClass.Value;
-                       type = TypeManager.void_type;
-                       return this;
-               }
-
-               public override void Emit (EmitContext ec)
-               {
-                       if (RootContext.EvalMode)
-                               EmitStatement (ec);
-                       else
-                               throw new InternalErrorException ("don't know what to emit");                           
-               }
-
-               public override void EmitStatement (EmitContext ec)
-               {
-                       target.EmitAddOrRemove (ec, op == Binary.Operator.Addition, source);
-               }
-       }
-
        //
        // This class is used for compound assignments.
        //
@@ -628,8 +573,28 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       if (target is EventExpr)
-                               return new EventAddOrRemove (target, op, right, loc).Resolve (ec);
+                       var event_expr = target as EventExpr;
+                       if (event_expr != null) {
+                               source = Convert.ImplicitConversionRequired (ec, right, target.Type, loc);
+                               if (source == null)
+                                       return null;
+
+                               Expression rside;
+                               if (op == Binary.Operator.Addition)
+                                       rside = EmptyExpression.EventAddition;
+                               else if (op == Binary.Operator.Subtraction)
+                                       rside = EmptyExpression.EventSubtraction;
+                               else
+                                       rside = null;
+
+                               target = target.ResolveLValue (ec, rside);
+                               if (target == null)
+                                       return null;
+
+                               eclass = ExprClass.Value;
+                               type = event_expr.Operator.ReturnType;
+                               return this;
+                       }
 
                        //
                        // Only now we can decouple the original source/target