Author: martin
Date: 2005-03-22 05:05:55 -0500 (Tue, 22 Mar 2005)
New Revision: 42079

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/anonymous.cs
   trunk/mcs/gmcs/codegen.cs
   trunk/mcs/gmcs/cs-tokenizer.cs
   trunk/mcs/gmcs/decl.cs
   trunk/mcs/gmcs/expression.cs
Log:
**** Merged r40511-r40612 from MCS ****


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-03-22 10:03:03 UTC (rev 42078)
+++ trunk/mcs/gmcs/ChangeLog    2005-03-22 10:05:55 UTC (rev 42079)
@@ -1,3 +1,43 @@
+2005-02-14  Marek Safar  <[EMAIL PROTECTED]>
+
+       * expression.cs (New.DoResolve): Add complex core type reduction.
+       (New.Constantify): Converts complex core type syntax like 'new int ()'
+       to simple constant.
+       
+2005-02-14  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * decl.cs (EntryType.EntryType): New constructor to create an
+       updated copy of a cache entry.
+       (MemberCache.AddMethods): Use it.
+       (MemberCache.ClearDeclaredOnly): Remove.
+       (MemberCache.MemberCache): Update.
+
+2005-02-11  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * codegen.cs (EmitContext): Introduce the `MethodIsStatic'
+       variable.  This one is represents the actual low-level declaration
+       of the method, as opposed to the semantic level `IsStatic'.   
+
+       An anonymous method which is hosted into a static method might be
+       actually an instance method.  IsStatic would reflect the
+       container, while MethodIsStatic represents the actual code
+       generated.
+
+       * expression.cs (ParameterReference): Use the new MethodIsStatic
+       instead of IsStatic.
+
+       * anonymous.cs (AnonymousMethod.Compatible): Pass the
+       Modifiers.STATIC to the Anonymous' Method EmitContext if static is
+       set on the current EmitContext. 
+
+       * expression.cs (Cast): Overload DoResolveLValue so we can pass
+       resolve our casted expression as an LValue.  This triggers the
+       proper LValue processing that is later required by Assign.
+
+       This fixes 72347.
+
+       * cs-tokenizer.cs (pp_and): recurse on pp_and, fixes #61903.
+
 2005-02-11  Marek Safar  <[EMAIL PROTECTED]>
 
        C# 2.0 Fixed buffer implementation

Modified: trunk/mcs/gmcs/anonymous.cs
===================================================================
--- trunk/mcs/gmcs/anonymous.cs 2005-03-22 10:03:03 UTC (rev 42078)
+++ trunk/mcs/gmcs/anonymous.cs 2005-03-22 10:05:55 UTC (rev 42079)
@@ -123,8 +123,9 @@
                                throw new Exception ("Type host is null");
                        
                        if (current_type == type_host && ec.IsStatic){
-                               if (ec.IsStatic)
+                               if (ec.IsStatic){
                                        method_modifiers |= Modifiers.STATIC;
+                               }
                                current_type = null;
                        } 
 
@@ -134,7 +135,6 @@
                                method_modifiers, false, new MemberName 
("<#AnonymousMethod>" + anonymous_method_count++),
                                Parameters, null, loc);
                        method.Block = Block;
-
                        
                        //
                        // Swap the TypeBuilder while we define the method, 
then restore
@@ -276,13 +276,14 @@
                                ec.TypeContainer, ec.DeclSpace, loc, null,
                                invoke_mb.ReturnType,
                                /* REVIEW */ (ec.InIterator ? 
Modifiers.METHOD_YIELDS : 0) |
-                               (ec.InUnsafe ? Modifiers.UNSAFE : 0),
+                               (ec.InUnsafe ? Modifiers.UNSAFE : 0) |
+                               (ec.IsStatic ? Modifiers.STATIC : 0),
                                /* No constructor */ false);
 
                        aec.CurrentAnonymousMethod = this;
                        ContainerAnonymousMethod = ec.CurrentAnonymousMethod;
                        ContainingBlock = ec.CurrentBlock;
-               
+
                        if (aec.ResolveTopBlock (ec, Block, amp, loc, out 
unreachable))
                                return new AnonymousDelegate (this, 
delegate_type, loc).Resolve (ec);
 
@@ -309,8 +310,7 @@
                        // Adjust based on the computed state of the
                        // method from CreateMethodHost
                        
-                       if ((method_modifiers & Modifiers.STATIC) != 0)
-                               aec.IsStatic = true;
+                       aec.MethodIsStatic = (method_modifiers & 
Modifiers.STATIC) != 0;
                        
                        aec.EmitMeta (Block, amp);
                        aec.EmitResolvedTopBlock (Block, unreachable);

Modified: trunk/mcs/gmcs/codegen.cs
===================================================================
--- trunk/mcs/gmcs/codegen.cs   2005-03-22 10:03:03 UTC (rev 42078)
+++ trunk/mcs/gmcs/codegen.cs   2005-03-22 10:05:55 UTC (rev 42079)
@@ -292,6 +292,16 @@
                public bool IsStatic;
 
                /// <summary>
+               ///   Whether the actual created method is static or instance 
method.
+               ///   Althoug the method might be declared as `static', if an 
anonymous
+               ///   method is involved, we might turn this into an instance 
method.
+               ///
+               ///   So this reflects the low-level staticness of the method, 
while
+               ///   IsStatic represents the semantic, high-level staticness.
+               /// </summary>
+               public bool MethodIsStatic;
+
+               /// <summary>
                ///   Whether we are emitting a field initializer
                /// </summary>
                public bool IsFieldInitializer;
@@ -423,7 +433,6 @@
                }
                
                Phase current_phase;
-               
                FlowBranching current_flow_branching;
                
                public EmitContext (DeclSpace parent, DeclSpace ds, Location l, 
ILGenerator ig,
@@ -440,6 +449,7 @@
                                throw new Exception ("FUCK");
                        
                        IsStatic = (code_flags & Modifiers.STATIC) != 0;
+                       MethodIsStatic = IsStatic;
                        InIterator = (code_flags & Modifiers.METHOD_YIELDS) != 
0;
                        RemapToProxy = InIterator;
                        ReturnType = return_type;

Modified: trunk/mcs/gmcs/cs-tokenizer.cs
===================================================================
--- trunk/mcs/gmcs/cs-tokenizer.cs      2005-03-22 10:03:03 UTC (rev 42078)
+++ trunk/mcs/gmcs/cs-tokenizer.cs      2005-03-22 10:05:55 UTC (rev 42079)
@@ -1634,7 +1634,7 @@
                                if (s [0] == '&'){
                                        if (len > 2 && s [1] == '&'){
                                                s = s.Substring (2);
-                                               return (va & pp_eq (ref s));
+                                               return (va & pp_and (ref s));
                                        } else {
                                                Error_InvalidDirective ();
                                                return false;

Modified: trunk/mcs/gmcs/decl.cs
===================================================================
--- trunk/mcs/gmcs/decl.cs      2005-03-22 10:03:03 UTC (rev 42078)
+++ trunk/mcs/gmcs/decl.cs      2005-03-22 10:05:55 UTC (rev 42079)
@@ -1771,10 +1771,8 @@
                        // method cache with all declared and inherited methods.
                        Type type = container.Type;
                        if (!(type is TypeBuilder) && !type.IsInterface && 
!type.IsGenericParameter) {
-                               if (Container.BaseCache != null) {
+                               if (Container.BaseCache != null)
                                        method_hash = DeepCopy 
(Container.BaseCache.method_hash);
-                                       ClearDeclaredOnly (method_hash);
-                               }
                                else
                                        method_hash = new Hashtable ();
                                AddMethods (type);
@@ -1820,15 +1818,6 @@
                        return hash;
                }
 
-               void ClearDeclaredOnly (Hashtable hash)
-               {
-                       IDictionaryEnumerator it = hash.GetEnumerator ();
-                       while (it.MoveNext ()) {
-                               foreach (CacheEntry ce in (ArrayList) it.Value)
-                                       ce.EntryType &= ~EntryType.Declared;
-                       }
-               }
-
                /// <summary>
                ///   Add the contents of `cache' to the member_hash.
                /// </summary>
@@ -1963,7 +1952,7 @@
 
                                        if (member.MethodHandle.Value == 
old.MethodHandle.Value && 
                                            declaring_type == 
old.DeclaringType) {
-                                               entry.Member = member;
+                                               list [n] = new CacheEntry 
(entry, member);
                                                break;
                                        }
                                }
@@ -2060,8 +2049,8 @@
 
                protected class CacheEntry {
                        public readonly IMemberContainer Container;
-                       public EntryType EntryType;
-                       public MemberInfo Member;
+                       public readonly EntryType EntryType;
+                       public readonly MemberInfo Member;
 
                        public CacheEntry (IMemberContainer container, 
MemberInfo member,
                                           MemberTypes mt, BindingFlags bf)
@@ -2071,6 +2060,13 @@
                                this.EntryType = GetEntryType (mt, bf);
                        }
 
+                       public CacheEntry (CacheEntry other, MemberInfo update)
+                       {
+                               this.Container = other.Container;
+                               this.EntryType = other.EntryType & 
~EntryType.Declared;
+                               this.Member = update;
+                       }
+
                        public override string ToString ()
                        {
                                return String.Format ("CacheEntry 
({0}:{1}:{2})", Container.Name,

Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs        2005-03-22 10:03:03 UTC (rev 42078)
+++ trunk/mcs/gmcs/expression.cs        2005-03-22 10:05:55 UTC (rev 42079)
@@ -1804,12 +1804,26 @@
                        return null;
                }
                
+               public override Expression DoResolveLValue (EmitContext ec, 
Expression right_side)
+               {
+                       expr = expr.DoResolveLValue (ec, right_side);
+                       if (expr == null)
+                               return null;
+
+                       return ResolveRest (ec);
+               }
+
                public override Expression DoResolve (EmitContext ec)
                {
                        expr = expr.Resolve (ec);
                        if (expr == null)
                                return null;
 
+                       return ResolveRest (ec);
+               }
+
+               Expression ResolveRest (EmitContext ec)
+               {
                        TypeExpr target = target_type.ResolveAsTypeTerminal 
(ec);
                        if (target == null)
                                return null;
@@ -1839,7 +1853,7 @@
                        expr = Convert.ExplicitConversion (ec, expr, type, loc);
                        return expr;
                }
-
+               
                public override void Emit (EmitContext ec)
                {
                        //
@@ -4012,8 +4026,9 @@
                        ILGenerator ig = ec.ig;
                        int arg_idx = idx;
 
-                       if (!ec.IsStatic)
+                       if (!ec.MethodIsStatic)
                                arg_idx++;
+                       
 
                        EmitLdArg (ig, arg_idx);
 
@@ -4037,7 +4052,7 @@
                        ILGenerator ig = ec.ig;
                        int arg_idx = idx;
 
-                       if (!ec.IsStatic)
+                       if (!ec.MethodIsStatic)
                                arg_idx++;
 
                        EmitLdArg (ig, arg_idx);
@@ -4075,7 +4090,7 @@
                        
                        prepared = prepare_for_load;
                        
-                       if (!ec.IsStatic)
+                       if (!ec.MethodIsStatic)
                                arg_idx++;
 
                        if (is_ref && !prepared)
@@ -4113,7 +4128,7 @@
                        
                        int arg_idx = idx;
 
-                       if (!ec.IsStatic)
+                       if (!ec.MethodIsStatic)
                                arg_idx++;
 
                        if (is_ref){
@@ -5827,6 +5842,42 @@
 //                     value_target = MyEmptyExpression;
                }
 
+
+               /// <summary>
+               /// Converts complex core type syntax like 'new int ()' to 
simple constant
+               /// </summary>
+               Expression Constantify (Type t)
+               {
+                       if (t == TypeManager.int32_type)
+                               return new IntConstant (0);
+                       if (t == TypeManager.uint32_type)
+                               return new UIntConstant (0);
+                       if (t == TypeManager.int64_type)
+                               return new LongConstant (0);
+                       if (t == TypeManager.uint64_type)
+                               return new ULongConstant (0);
+                       if (t == TypeManager.float_type)
+                               return new FloatConstant (0);
+                       if (t == TypeManager.double_type)
+                               return new DoubleConstant (0);
+                       if (t == TypeManager.short_type)
+                               return new ShortConstant (0);
+                       if (t == TypeManager.ushort_type)
+                               return new UShortConstant (0);
+                       if (t == TypeManager.sbyte_type)
+                               return new SByteConstant (0);
+                       if (t == TypeManager.byte_type)
+                               return new ByteConstant (0);
+                       if (t == TypeManager.char_type)
+                               return new CharConstant ('\0');
+                       if (t == TypeManager.bool_type)
+                               return new BoolConstant (false);
+                       if (t == TypeManager.decimal_type)
+                               return new DecimalConstant (0);
+
+                       return null;
+               }
+
                public override Expression DoResolve (EmitContext ec)
                {
                        //
@@ -5846,6 +5897,12 @@
                        TypeExpr texpr = RequestedType.ResolveAsTypeTerminal 
(ec);
                        if (texpr == null)
                                return null;
+
+                       if (Arguments == null) {
+                               Expression c = Constantify (type);
+                               if (c != null)
+                                       return c;
+                       }
                        
                        type = texpr.Type;
                        if (type == null)

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

Reply via email to