Author: miguel
Date: 2006-01-13 15:17:46 -0500 (Fri, 13 Jan 2006)
New Revision: 55546

Modified:
   branches/mono-1-1-13/mcs/gmcs/ChangeLog
   branches/mono-1-1-13/mcs/gmcs/cfold.cs
   branches/mono-1-1-13/mcs/gmcs/codegen.cs
   branches/mono-1-1-13/mcs/gmcs/cs-tokenizer.cs
   branches/mono-1-1-13/mcs/gmcs/driver.cs
   branches/mono-1-1-13/mcs/gmcs/expression.cs
   branches/mono-1-1-13/mcs/gmcs/iterators.cs
   branches/mono-1-1-13/mcs/gmcs/typemanager.cs
Log:
Backport to the branch the gmcs fixes as well

Modified: branches/mono-1-1-13/mcs/gmcs/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/gmcs/ChangeLog     2006-01-13 20:16:11 UTC (rev 
55545)
+++ branches/mono-1-1-13/mcs/gmcs/ChangeLog     2006-01-13 20:17:46 UTC (rev 
55546)
@@ -1,3 +1,53 @@
+2006-01-12  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       This fixes the problem where we used ldfld instead of ldflda to
+       load the "THIS" pointer on captured parameters, when THIS is a
+       value type.  See bug #77205.
+       
+       * iterators.cs (CapturedThisReference.Emit): Pass false to
+       EmitThis (we do not need the address).
+
+       * codegen.cs (EmitThis): it needs to know whether we need the
+       address of `this' or not.  This is used by value types.  
+
+       * expression.cs (This.AddressOf): Pass true to the EmitThis call,
+       every other call passes false.
+
+2006-01-12  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #77221.
+       * typemanager.cs (TryGetBaseDefinition): Rename from the mis-named
+       GetOverride.
+       * expression.cs (Invocation.OverloadResolve): Update.
+       (Invocation.DoResolve): Avoid double resolution of invocation.
+
+2006-01-11  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #77180.
+       * expression.cs (Unary.Emit): When in /checked+ mode, don't emit
+       unary negation of floating point types as 0-expr; negation cannot
+       overflow in floating point types.
+
+       Fix #77204.
+       * expression.cs (MemberAccess.DoResolve): Disallow the use of '.'
+       on operands of 'void' type.
+
+       Fix #77200.
+       * cfold.cs (BinaryFold): Implement folding of BinaryOr, BinaryAnd
+       and ExclusiveOr for boolean constants too.
+
+2006-01-12  Ben Maurer  <[EMAIL PROTECTED]>
+
+       * expression.cs: Fix Console.WriteLine ((this = x).foo);
+
+2006-01-12  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * cs-tokenizer.cs (Position): New class used to save and restore
+       the position state in the tokenizer.  Before this patch the save
+       and restore was not complete enough so the line and columns would
+       start to drift and the debugger and stack traces will get the
+       wrong data.
+
 2006-01-10  Martin Baulig  <[EMAIL PROTECTED]>
 
        * generic.cs
@@ -12,6 +62,38 @@
        instead of the `TypeBuilder' for this "<>THIS" variable; fixes
        #77061. 
 
+2006-01-09  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #75636.
+       * expression.cs (Invocation.OverloadResolve): Replace reflected
+       override methods with their base virtual methods, rather than
+       skipping over them.
+       * typemanager.cs (TypeManager.GetOverride): New.
+
+2005-12-21  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * driver.cs: Report the case of no source files and no -out:
+       argument provided.
+
+2005-12-20  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #77035.
+       * expression.cs (ComposedCast.GetSignatureForError): Define.
+
+2006-01-10  Martin Baulig  <[EMAIL PROTECTED]>
+
+       * generic.cs
+       (TypeParameter.InflateConstraints): New public method.
+
+       * iterators.cs (Iterator.DefineNestedTypes): Also inflate the
+       constraints; fixes #77042.
+
+2006-01-10  Martin Baulig  <[EMAIL PROTECTED]>
+
+       * anonymous.cs (ScopeInfo.EmitScopeType): Use the `CurrentType'
+       instead of the `TypeBuilder' for this "<>THIS" variable; fixes
+       #77061. 
+
 2006-01-05  Jb Evain  <[EMAIL PROTECTED]>
 
        * class.cs (Property.Define, Indexer.Define): do not tag the
@@ -44,6 +126,11 @@
 
        Fixes #77119 which was a late change in the spec.
 
+2005-12-23  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * anonymous.cs (ScopeInfo.LinkScope): Do not link the scope to its
+       parent if its the same scope.  Fixes #77060.
+
 2005-12-22  Marek Safar  <[EMAIL PROTECTED]>
 
        * expression.cs (ComposedCast.DoResolveAsTypeStep): Fixed wrong merge.

Modified: branches/mono-1-1-13/mcs/gmcs/cfold.cs
===================================================================
--- branches/mono-1-1-13/mcs/gmcs/cfold.cs      2006-01-13 20:16:11 UTC (rev 
55545)
+++ branches/mono-1-1-13/mcs/gmcs/cfold.cs      2006-01-13 20:17:46 UTC (rev 
55546)
@@ -202,6 +202,23 @@
                                        right = ((EnumConstant) right).Child;
                        }
 
+                       if (left is BoolConstant && right is BoolConstant) {
+                               bool lv = ((BoolConstant) left ).Value;
+                               bool rv = ((BoolConstant) right).Value;
+                               switch (oper) {
+                               case Binary.Operator.BitwiseAnd:
+                               case Binary.Operator.LogicalAnd:
+                                       return new BoolConstant (lv && rv, 
left.Location);
+                               case Binary.Operator.BitwiseOr:
+                               case Binary.Operator.LogicalOr:
+                                       return new BoolConstant (lv || rv, 
left.Location);
+                               case Binary.Operator.ExclusiveOr:
+                                       return new BoolConstant (lv ^ rv, 
left.Location);
+                               default:
+                                       throw new InternalErrorException 
("Invalid operator on booleans: " + oper);
+                               }
+                       }
+
                        Type wrap_as;
                        Constant result = null;
                        switch (oper){
@@ -998,22 +1015,6 @@
                                Binary.Error_OperatorCannotBeApplied (loc, 
">>", lt, rt);
                                break;
 
-                       case Binary.Operator.LogicalAnd:
-                               if (left is BoolConstant && right is 
BoolConstant){
-                                       return new BoolConstant (
-                                               ((BoolConstant) left).Value &&
-                                               ((BoolConstant) right).Value, 
left.Location);
-                               }
-                               break;
-
-                       case Binary.Operator.LogicalOr:
-                               if (left is BoolConstant && right is 
BoolConstant){
-                                       return new BoolConstant (
-                                               ((BoolConstant) left).Value ||
-                                               ((BoolConstant) right).Value, 
left.Location);
-                               }
-                               break;
-                               
                        case Binary.Operator.Equality:
                                if (left is BoolConstant && right is 
BoolConstant){
                                        return new BoolConstant (

Modified: branches/mono-1-1-13/mcs/gmcs/codegen.cs
===================================================================
--- branches/mono-1-1-13/mcs/gmcs/codegen.cs    2006-01-13 20:16:11 UTC (rev 
55545)
+++ branches/mono-1-1-13/mcs/gmcs/codegen.cs    2006-01-13 20:17:46 UTC (rev 
55546)
@@ -910,7 +910,7 @@
                // Emits the proper object to address fields on a remapped
                // variable/parameter to field in anonymous-method/iterator 
proxy classes.
                //
-               public void EmitThis ()
+               public void EmitThis (bool need_address)
                {
                        ig.Emit (OpCodes.Ldarg_0);
                        if (capture_context != null && CurrentAnonymousMethod 
!= null){
@@ -919,7 +919,10 @@
                                        if (si.ParentLink != null)
                                                ig.Emit (OpCodes.Ldfld, 
si.ParentLink);
                                        if (si.THIS != null){
-                                               ig.Emit (OpCodes.Ldfld, 
si.THIS);
+                                               if (need_address && 
TypeManager.IsValueType (si.THIS.FieldType))
+                                                       ig.Emit 
(OpCodes.Ldflda, si.THIS);
+                                               else
+                                                       ig.Emit (OpCodes.Ldfld, 
si.THIS);
                                                break;
                                        }
                                        si = si.ParentScope;

Modified: branches/mono-1-1-13/mcs/gmcs/cs-tokenizer.cs
===================================================================
--- branches/mono-1-1-13/mcs/gmcs/cs-tokenizer.cs       2006-01-13 20:16:11 UTC 
(rev 55545)
+++ branches/mono-1-1-13/mcs/gmcs/cs-tokenizer.cs       2006-01-13 20:17:46 UTC 
(rev 55546)
@@ -255,6 +255,55 @@
                        }
                }
 
+               //
+               // This is used when the tokenizer needs to save
+               // the current position as it needs to do some parsing
+               // on its own to deamiguate a token in behalf of the
+               // parser.
+               //
+               Stack position_stack = new Stack ();
+               class Position {
+                       public int position;
+                       public int ref_line;
+                       public int col;
+                       public int putback_char;
+                       public int previous_col;
+                       public int parsing_generic_less_than;
+                       
+                       public Position (Tokenizer t)
+                       {
+                               position = t.reader.Position;
+                               ref_line = t.ref_line;
+                               col = t.col;
+                               putback_char = t.putback_char;
+                               previous_col = t.previous_col;
+                               parsing_generic_less_than = 
t.parsing_generic_less_than;
+                       }
+               }
+               
+               public void PushPosition ()
+               {
+                       position_stack.Push (new Position (this));
+               }
+
+               public void PopPosition ()
+               {
+                       Position p = (Position) position_stack.Pop ();
+
+                       reader.Position = p.position;
+                       ref_line = p.ref_line;
+                       col = p.col;
+                       putback_char = p.putback_char;
+                       previous_col = p.previous_col;
+
+               }
+
+               // Do not reset the position, ignore it.
+               public void DiscardPosition ()
+               {
+                       position_stack.Pop ();
+               }
+               
                static void AddKeyword (string kw, int token) {
                        keywordStrings.Add (kw, kw);
                        if (keywords [kw.Length] == null) {
@@ -568,16 +617,9 @@
 
                                --deambiguate_close_parens;
 
-                               // Save current position and parse next token.
-                               int old = reader.Position;
-                               int old_ref_line = ref_line;
-                               int old_col = col;
-
+                               PushPosition ();
                                int new_token = token ();
-                               reader.Position = old;
-                               ref_line = old_ref_line;
-                               col = old_col;
-                               putback_char = -1;
+                               PopPosition ();
 
                                if (new_token == Token.OPEN_PARENS)
                                        return Token.CLOSE_PARENS_OPEN_PARENS;
@@ -605,22 +647,21 @@
                                if (parsing_generic_less_than++ > 0)
                                        return Token.OP_GENERICS_LT;
 
-                               int old = reader.Position;
                                if (handle_typeof) {
                                        int dimension;
+                                       PushPosition ();
                                        if (parse_generic_dimension (out 
dimension)) {
                                                val = dimension;
+                                               DiscardPosition ();
                                                return Token.GENERIC_DIMENSION;
                                        }
-                                       reader.Position = old;
-                                       putback_char = -1;
+                                       PopPosition ();
                                }
 
                                // Save current position and parse next token.
-                               old = reader.Position;
+                               PushPosition ();
                                bool is_generic_lt = parse_less_than ();
-                               reader.Position = old;
-                               putback_char = -1;
+                               PopPosition ();
 
                                if (is_generic_lt) {
                                        parsing_generic_less_than++;
@@ -1252,8 +1293,7 @@
                        if (putback_char != -1) {
                                x = putback_char;
                                putback_char = -1;
-                       }
-                       else
+                       } else
                                x = reader.Read ();
                        if (x == '\n') {
                                line++;
@@ -2015,23 +2055,15 @@
 
                        if (res == Token.PARTIAL) {
                                // Save current position and parse next token.
-                               int old = reader.Position;
-                               int old_putback = putback_char;
-                               int old_ref_line = ref_line;
-                               int old_col = col;
+                               PushPosition ();
 
-                               putback_char = -1;
-
                                int next_token = token ();
                                bool ok = (next_token == Token.CLASS) ||
                                        (next_token == Token.STRUCT) ||
                                        (next_token == Token.INTERFACE) ||
                                        (next_token == Token.ENUM); // 
"partial" is a keyword in 'partial enum', even though it's not valid
 
-                               reader.Position = old;
-                               ref_line = old_ref_line;
-                               col = old_col;
-                               putback_char = old_putback;
+                               PopPosition ();
 
                                if (ok)
                                        return res;

Modified: branches/mono-1-1-13/mcs/gmcs/driver.cs
===================================================================
--- branches/mono-1-1-13/mcs/gmcs/driver.cs     2006-01-13 20:16:11 UTC (rev 
55545)
+++ branches/mono-1-1-13/mcs/gmcs/driver.cs     2006-01-13 20:17:46 UTC (rev 
55546)
@@ -1602,6 +1602,11 @@
                        // Quick hack
                        //
                        if (output_file == null){
+                               if (first_source == null){
+                                       Report.Error (1562, "If no source files 
are specified you must specify the output file with -out:");
+                                       return false;
+                               }
+                                       
                                int pos = first_source.LastIndexOf ('.');
 
                                if (pos > 0)

Modified: branches/mono-1-1-13/mcs/gmcs/expression.cs
===================================================================
--- branches/mono-1-1-13/mcs/gmcs/expression.cs 2006-01-13 20:16:11 UTC (rev 
55545)
+++ branches/mono-1-1-13/mcs/gmcs/expression.cs 2006-01-13 20:17:46 UTC (rev 
55546)
@@ -615,7 +615,7 @@
                                throw new Exception ("This should be caught by 
Resolve");
                                
                        case Operator.UnaryNegation:
-                               if (ec.CheckState) {
+                               if (ec.CheckState && type != 
TypeManager.float_type && type != TypeManager.double_type) {
                                        ig.Emit (OpCodes.Ldc_I4_0);
                                        if (type == TypeManager.int64_type)
                                                ig.Emit (OpCodes.Conv_U8);
@@ -4681,45 +4681,55 @@
 
                        MethodBase[] methods = me.Methods;
 
+                       int nmethods = methods.Length;
+
+                       if (!me.IsBase) {
+                               //
+                               // Methods marked 'override' don't take part in 
'applicable_type'
+                               // computation, nor in the actual overload 
resolution.
+                               // However, they still need to be emitted 
instead of a base virtual method.
+                               // So, we salt them away into the 
'candidate_overrides' array.
+                               //
+                               // In case of reflected methods, we replace 
each overriding method with
+                               // its corresponding base virtual method.  This 
is to improve compatibility
+                               // with non-C# libraries which change the 
visibility of overrides (#75636)
+                               //
+                               int j = 0;
+                               for (int i = 0; i < methods.Length; ++i) {
+                                       MethodBase m = methods [i];
+                                       if (TypeManager.IsOverride (m)) {
+                                               if (candidate_overrides == null)
+                                                       candidate_overrides = 
new ArrayList ();
+                                               candidate_overrides.Add (m);
+                                               m = 
TypeManager.TryGetBaseDefinition (m);
+                                       }
+                                       if (m != null)
+                                               methods [j++] = m;
+                               }
+                               nmethods = j;
+                       }
+
                        //
                        // First we construct the set of applicable methods
                        //
                        bool is_sorted = true;
-                       for (int i = 0; i < methods.Length; i++){
+                       for (int i = 0; i < nmethods; i++){
                                Type decl_type = methods [i].DeclaringType;
 
                                //
                                // If we have already found an applicable method
                                // we eliminate all base types (Section 
14.5.5.1)
                                //
-                               if ((applicable_type != null) &&
-                                       IsAncestralType (decl_type, 
applicable_type))
+                               if (applicable_type != null && IsAncestralType 
(decl_type, applicable_type))
                                        continue;
 
                                //
-                               // Methods marked 'override' don't take part in 
'applicable_type'
-                               // computation, nor in the actual overload 
resolution.
-                               // However, they still need to be emitted 
instead of a base virtual method.
-                               // We avoid doing the 'applicable' test here, 
since it'll anyway be applied
-                               // to the base virtual function, and IsOverride 
is much faster than IsApplicable.
-                               //
-                               if (!me.IsBase && TypeManager.IsOverride 
(methods [i])) {
-                                       if (candidate_overrides == null)
-                                               candidate_overrides = new 
ArrayList ();
-                                       candidate_overrides.Add (methods [i]);
-                                       continue;
-                               }
-
-                               //
                                // Check if candidate is applicable (section 
14.4.2.1)
                                //   Is candidate applicable in normal form?
                                //
-                               bool is_applicable = IsApplicable (
-                                       ec, me, Arguments, arg_count, ref 
methods [i]);
+                               bool is_applicable = IsApplicable (ec, me, 
Arguments, arg_count, ref methods [i]);
 
-                               if (!is_applicable &&
-                                       (IsParamsMethodApplicable (
-                                       ec, me, Arguments, arg_count, ref 
methods [i]))) {
+                               if (!is_applicable && IsParamsMethodApplicable 
(ec, me, Arguments, arg_count, ref methods [i])) {
                                        MethodBase candidate = methods [i];
                                        if (candidate_to_form == null)
                                                candidate_to_form = new 
PtrHashtable ();
@@ -4750,7 +4760,7 @@
                                // return by providing info about the closest 
match
                                //
                                int errors = Report.Errors;
-                               for (int i = 0; i < methods.Length; ++i) {
+                               for (int i = 0; i < nmethods; ++i) {
                                        MethodBase c = (MethodBase) methods [i];
                                        ParameterData pd = 
TypeManager.GetParameterData (c);
 
@@ -5070,8 +5080,13 @@
                        return true;
                }
 
+               private bool resolved = false;
                public override Expression DoResolve (EmitContext ec)
                {
+                       if (resolved)
+                               return this.method == null ? null : this;
+
+                       resolved = true;
                        //
                        // First, resolve the expression that is used to
                        // trigger the invocation
@@ -5111,7 +5126,7 @@
                        }
 
                        MethodGroupExpr mg = (MethodGroupExpr) expr;
-                       method = OverloadResolve (ec, mg, Arguments, false, 
loc);
+                       MethodBase method = OverloadResolve (ec, mg, Arguments, 
false, loc);
 
                        if (method == null)
                                return null;
@@ -5168,6 +5183,7 @@
                                mg.InstanceExpression.CheckMarshallByRefAccess 
(ec.ContainerType);
 
                        eclass = ExprClass.Value;
+                       this.method = method;
                        return this;
                }
 
@@ -6839,11 +6855,20 @@
                        ILGenerator ig = ec.ig;
                        
                        if (ec.TypeContainer is Struct){
-                               ec.EmitThis ();
+                               ec.EmitThis (false);
                                source.Emit (ec);
-                               if (leave_copy)
+                               
+                               LocalTemporary t = null;
+                               if (leave_copy) {
+                                       t = new LocalTemporary (ec, type);
                                        ec.ig.Emit (OpCodes.Dup);
+                                       t.Store (ec);
+                               }
+
                                ig.Emit (OpCodes.Stobj, type);
+                               
+                               if (leave_copy)
+                                       t.Emit (ec);
                        } else {
                                throw new Exception ("how did you get here");
                        }
@@ -6853,7 +6878,7 @@
                {
                        ILGenerator ig = ec.ig;
 
-                       ec.EmitThis ();
+                       ec.EmitThis (false);
                        if (ec.TypeContainer is Struct)
                                ig.Emit (OpCodes.Ldobj, type);
                }
@@ -6874,7 +6899,7 @@
 
                public void AddressOf (EmitContext ec, AddressOp mode)
                {
-                       ec.EmitThis ();
+                       ec.EmitThis (true);
 
                        // FIMXE
                        // FIGURE OUT WHY LDARG_S does not work
@@ -7265,6 +7290,11 @@
                                return null;
                        }
 
+                       if (expr_type == TypeManager.void_type) {
+                               Error (23, "The `.' operator can not be applied 
to operands of type 'void'");
+                               return null;
+                       }
+
                        Expression member_lookup;
                        member_lookup = MemberLookup (
                                ec, expr_type, expr_type, Identifier, loc);
@@ -8688,16 +8718,17 @@
                }
 
                public override string Name {
-                       get {
-                               return left + dim;
-                       }
+                       get { return left + dim; }
                }
 
                public override string FullName {
-                       get {
-                               return type.FullName;
-                       }
+                       get { return type.FullName; }
                }
+
+               public override string GetSignatureForError ()
+               {
+                       return left.GetSignatureForError () + dim;
+               }
        }
 
        public class FixedBufferPtr : Expression {

Modified: branches/mono-1-1-13/mcs/gmcs/iterators.cs
===================================================================
--- branches/mono-1-1-13/mcs/gmcs/iterators.cs  2006-01-13 20:16:11 UTC (rev 
55545)
+++ branches/mono-1-1-13/mcs/gmcs/iterators.cs  2006-01-13 20:17:46 UTC (rev 
55546)
@@ -951,7 +951,7 @@
 
                        public override void Emit (EmitContext ec)
                        {
-                               ec.EmitThis ();
+                               ec.EmitThis (false);
                        }
                }
 

Modified: branches/mono-1-1-13/mcs/gmcs/typemanager.cs
===================================================================
--- branches/mono-1-1-13/mcs/gmcs/typemanager.cs        2006-01-13 20:16:11 UTC 
(rev 55545)
+++ branches/mono-1-1-13/mcs/gmcs/typemanager.cs        2006-01-13 20:17:46 UTC 
(rev 55546)
@@ -1774,12 +1774,10 @@
 
        static public void RegisterOverride (MethodBase override_method, 
MethodBase base_method)
        {
-               if (method_overrides.Contains (override_method)) {
-                       if (method_overrides [override_method] != base_method)
-                               throw new InternalErrorException ("Override 
mismatch: " + override_method);
-                       return;
-               }
-               method_overrides [override_method] = base_method;
+               if (!method_overrides.Contains (override_method))
+                       method_overrides [override_method] = base_method;
+               if (method_overrides [override_method] != base_method)
+                       throw new InternalErrorException ("Override mismatch: " 
+ override_method);
        }
 
        static public bool IsOverride (MethodBase m)
@@ -1789,6 +1787,11 @@
                        (m is MethodBuilder || method_overrides.Contains (m));
        }
 
+       static public MethodBase TryGetBaseDefinition (MethodBase m)
+       {
+               return (MethodBase) method_overrides [m];
+       }
+
        /// <summary>
        ///    Returns the argument types for an indexer based on its 
PropertyInfo
        ///

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to