Author: martin
Date: 2005-04-07 09:31:52 -0400 (Thu, 07 Apr 2005)
New Revision: 42639

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/anonymous.cs
   trunk/mcs/gmcs/attribute.cs
   trunk/mcs/gmcs/class.cs
   trunk/mcs/gmcs/convert.cs
   trunk/mcs/gmcs/delegate.cs
   trunk/mcs/gmcs/expression.cs
   trunk/mcs/gmcs/generic.cs
   trunk/mcs/gmcs/pending.cs
   trunk/mcs/gmcs/support.cs
   trunk/mcs/gmcs/typemanager.cs
Log:
**** Merged r40327 from MCS ****


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/ChangeLog    2005-04-07 13:31:52 UTC (rev 42639)
@@ -1,3 +1,16 @@
+2005-02-09  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Combine two near-redundant caches.
+       * typemanager.cs (method_params): Rename from method_internal_params.
+       (TypeManager.GetParameterData): New.  Replace
+       Invocation.GetParameterData.
+       (TypeManager.LookupParametersByBuilder): Remove.
+       * expression.cs (Invocation.method_parameter_cache): Remove.
+       (Invocation.GetParameterData): Remove.
+       Update to changes.
+       * anonymous.cs, attribute.cs, convert.cs, delegate.cs:
+       Update to changes.
+
 2005-02-08  Raja R Harinath  <[EMAIL PROTECTED]>
 
        Fix #72015.

Modified: trunk/mcs/gmcs/anonymous.cs
===================================================================
--- trunk/mcs/gmcs/anonymous.cs 2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/anonymous.cs 2005-04-07 13:31:52 UTC (rev 42639)
@@ -165,7 +165,7 @@
 
                        MethodGroupExpr invoke_mg = Delegate.GetInvokeMethod 
(ec, delegate_type, loc);
                        invoke_mb = (MethodInfo) invoke_mg.Methods [0];
-                       ParameterData invoke_pd = Invocation.GetParameterData 
(invoke_mb);
+                       ParameterData invoke_pd = TypeManager.GetParameterData 
(invoke_mb);
 
                        //
                        // If implicit parameters are set, then we must check 
for out in the parameters

Modified: trunk/mcs/gmcs/attribute.cs
===================================================================
--- trunk/mcs/gmcs/attribute.cs 2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/attribute.cs 2005-04-07 13:31:52 UTC (rev 42639)
@@ -550,7 +550,7 @@
                        // of type object
                        //
 
-                       ParameterData pd = Invocation.GetParameterData 
(constructor);
+                       ParameterData pd = TypeManager.GetParameterData 
(constructor);
 
                        int last_real_param = pd.Count;
                        if (pd.HasParams) {

Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs     2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/class.cs     2005-04-07 13:31:52 UTC (rev 42639)
@@ -3558,7 +3558,7 @@
 
                protected override bool CheckGenericOverride (MethodInfo 
method, string name)
                {
-                       ParameterData pd = Invocation.GetParameterData (method);
+                       ParameterData pd = TypeManager.GetParameterData 
(method);
 
                        for (int i = 0; i < ParameterTypes.Length; i++) {
                                GenericConstraints ogc = pd.GenericConstraints 
(i);

Modified: trunk/mcs/gmcs/convert.cs
===================================================================
--- trunk/mcs/gmcs/convert.cs   2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/convert.cs   2005-04-07 13:31:52 UTC (rev 42639)
@@ -896,7 +896,7 @@
                        //
                        Type source_type = source.Type;
                        foreach (MethodBase mb in me.Methods){
-                               ParameterData pd = Invocation.GetParameterData 
(mb);
+                               ParameterData pd = TypeManager.GetParameterData 
(mb);
                                Type param_type = pd.ParameterType (0);
 
                                if (param_type == source_type)
@@ -1158,7 +1158,7 @@
 
                        
                        foreach (MethodBase mb in union.Methods){
-                               ParameterData pd = Invocation.GetParameterData 
(mb);
+                               ParameterData pd = TypeManager.GetParameterData 
(mb);
                                MethodInfo mi = (MethodInfo) mb;
                                
                                if (pd.ParameterType (0) == 
most_specific_source &&

Modified: trunk/mcs/gmcs/delegate.cs
===================================================================
--- trunk/mcs/gmcs/delegate.cs  2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/delegate.cs  2005-04-07 13:31:52 UTC (rev 42639)
@@ -471,19 +471,18 @@
                                return null;
 
                        MethodBase invoke_mb = mg.Methods [0];
-                       ParameterData invoke_pd = Invocation.GetParameterData 
(invoke_mb);
+                       ParameterData invoke_pd = TypeManager.GetParameterData 
(invoke_mb);
 
                        if (!mg.HasTypeArguments &&
                            !TypeManager.InferTypeArguments (ec, invoke_pd, ref 
mb))
                                return null;
 
-                       ParameterData pd = Invocation.GetParameterData (mb);
-                       int pd_count = pd.Count;
+                       ParameterData pd = TypeManager.GetParameterData (mb);
 
-                       if (invoke_pd.Count != pd_count)
+                       if (invoke_pd.Count != pd.Count)
                                return null;
 
-                       for (int i = pd_count; i > 0; ) {
+                       for (int i = pd.Count; i > 0; ) {
                                i--;
 
                                Type invoke_pd_type = invoke_pd.ParameterType 
(i);
@@ -545,7 +544,7 @@
                        }
                        
                        MethodBase mb = ((MethodGroupExpr) ml).Methods [0];
-                       ParameterData pd = Invocation.GetParameterData (mb);
+                       ParameterData pd = TypeManager.GetParameterData (mb);
 
                        int pd_count = pd.Count;
 
@@ -601,7 +600,7 @@
                        }
                        
                        MethodBase mb = ((MethodGroupExpr) ml).Methods [0];
-                       ParameterData pd = Invocation.GetParameterData (mb);
+                       ParameterData pd = TypeManager.GetParameterData (mb);
 
                        Expression probe_ml = Expression.MemberLookup (
                                ec, delegate_type, "Invoke", loc);
@@ -612,7 +611,7 @@
                        }
                        
                        MethodBase probe_mb = ((MethodGroupExpr) 
probe_ml).Methods [0];
-                       ParameterData probe_pd = Invocation.GetParameterData 
(probe_mb);
+                       ParameterData probe_pd = TypeManager.GetParameterData 
(probe_mb);
                        
                        if (((MethodInfo) mb).ReturnType != ((MethodInfo) 
probe_mb).ReturnType)
                                return false;
@@ -764,7 +763,7 @@
                                ec, type, "Invoke", MemberTypes.Method,
                                Expression.AllBindingFlags, loc);
                        MethodBase method = ((MethodGroupExpr) 
invoke_method).Methods [0];
-                       ParameterData param = Invocation.GetParameterData 
(method);
+                       ParameterData param = TypeManager.GetParameterData 
(method);
                        string delegate_desc = Delegate.FullDelegateDesc (type, 
method, param);
 
                        if (!mg.HasTypeArguments &&
@@ -810,33 +809,32 @@
 
                protected Expression ResolveMethodGroupExpr (EmitContext ec, 
MethodGroupExpr mg)
                {
-                               foreach (MethodInfo mi in mg.Methods){
-                                       delegate_method = Delegate.VerifyMethod 
(
-                                               ec, type, mi, loc);
-
-                                       if (delegate_method != null)
-                                               break;
-                               }
-                                       
-                               if (delegate_method == null) {
-                                       Error_NoMatchingMethodForDelegate (ec, 
mg, type, loc);
-                                       return null;
-                               }
-
-                               //
-                               // Check safe/unsafe of the delegate
-                               //
-                               if (!ec.InUnsafe){
-                                       ParameterData param = 
Invocation.GetParameterData (delegate_method);
-                                       int count = param.Count;
-                                       
-                                       for (int i = 0; i < count; i++){
-                                               if (param.ParameterType 
(i).IsPointer){
-                                                       Expression.UnsafeError 
(loc);
-                                                       return null;
-                                               }
+                       foreach (MethodInfo mi in mg.Methods){
+                               delegate_method  = Delegate.VerifyMethod (ec, 
type, mi, loc);
+                               
+                               if (delegate_method != null)
+                                       break;
+                       }
+                       
+                       if (delegate_method == null) {
+                               Error_NoMatchingMethodForDelegate (ec, mg, 
type, loc);
+                               return null;
+                       }
+                       
+                       //
+                       // Check safe/unsafe of the delegate
+                       //
+                       if (!ec.InUnsafe){
+                               ParameterData param = 
TypeManager.GetParameterData (delegate_method);
+                               int count = param.Count;
+                               
+                               for (int i = 0; i < count; i++){
+                                       if (param.ParameterType (i).IsPointer){
+                                               Expression.UnsafeError (loc);
+                                               return null;
                                        }
                                }
+                       }
                                                
                        //TODO: implement caching when performance will be low
                        IMethodData md = TypeManager.GetMethod 
(delegate_method);

Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs        2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/expression.cs        2005-04-07 13:31:52 UTC (rev 42639)
@@ -4316,13 +4316,6 @@
                Expression expr;
                MethodBase method = null;
                
-               static Hashtable method_parameter_cache;
-
-               static Invocation ()
-               {
-                       method_parameter_cache = new PtrHashtable ();
-               }
-                       
                //
                // arguments is an ArrayList, but we do not want to typecast,
                // as it might be null.
@@ -4344,31 +4337,6 @@
                }
 
                /// <summary>
-               ///   Returns the Parameters (a ParameterData interface) for the
-               ///   Method `mb'
-               /// </summary>
-               public static ParameterData GetParameterData (MethodBase mb)
-               {
-                       object pd = method_parameter_cache [mb];
-                       object ip;
-                       
-                       if (pd != null)
-                               return (ParameterData) pd;
-
-                       ip = TypeManager.LookupParametersByBuilder (mb);
-                       if (ip != null){
-                               method_parameter_cache [mb] = ip;
-
-                               return (ParameterData) ip;
-                       } else {
-                               ReflectionParameters rp = new 
ReflectionParameters (mb);
-                               method_parameter_cache [mb] = rp;
-
-                               return (ParameterData) rp;
-                       }
-               }
-
-               /// <summary>
                ///   Determines "better conversion" as specified in 7.4.2.3
                ///
                ///    Returns : p    if a->p is better,
@@ -4483,8 +4451,8 @@
                                           MethodBase candidate, bool 
candidate_params,
                                           MethodBase best, bool best_params, 
Location loc)
                {
-                       ParameterData candidate_pd = GetParameterData 
(candidate);
-                       ParameterData best_pd = GetParameterData (best);
+                       ParameterData candidate_pd = 
TypeManager.GetParameterData (candidate);
+                       ParameterData best_pd = TypeManager.GetParameterData 
(best);
                
                        int cand_count = candidate_pd.Count;
 
@@ -4589,7 +4557,7 @@
                        sb.Append (".");
                        sb.Append (mb.Name);
                        
-                       ParameterData pd = GetParameterData (mb);
+                       ParameterData pd = TypeManager.GetParameterData (mb);
 
                        int count = pd.Count;
                        sb.Append (" (");
@@ -4683,7 +4651,7 @@
                                                      int arg_count, MethodBase 
candidate,
                                                      bool do_varargs)
                {
-                       ParameterData pd = GetParameterData (candidate);
+                       ParameterData pd = TypeManager.GetParameterData 
(candidate);
                        
                        int pd_count = pd.Count;
 
@@ -4781,7 +4749,7 @@
                static bool IsApplicable (EmitContext ec, ArrayList arguments, 
int arg_count,
                                          MethodBase candidate)
                {
-                       ParameterData pd = GetParameterData (candidate);
+                       ParameterData pd = TypeManager.GetParameterData 
(candidate);
 
                        if (arg_count != pd.Count)
                                return false;
@@ -4931,7 +4899,7 @@
                                //
                                for (int i = 0; i < methods.Length; ++i) {
                                        MethodBase c = (MethodBase) methods [i];
-                                       ParameterData pd = GetParameterData (c);
+                                       ParameterData pd = 
TypeManager.GetParameterData (c);
 
                                        if (pd.Count != arg_count)
                                                continue;
@@ -4951,7 +4919,7 @@
                                         
                                        for (int i = 0; i < methods.Length; 
++i) {
                                                MethodBase c = methods [i];
-                                               ParameterData pd = 
GetParameterData (c);
+                                               ParameterData pd = 
TypeManager.GetParameterData (c);
 
                                                if (pd.Count != arg_count)
                                                        continue;
@@ -5119,7 +5087,7 @@
                                                          Type delegate_type, 
bool may_fail,
                                                          Location loc)
                {
-                       ParameterData pd = GetParameterData (method);
+                       ParameterData pd = TypeManager.GetParameterData 
(method);
                        int pd_count = pd.Count;
                        
                        for (int j = 0; j < arg_count; j++) {
@@ -5362,7 +5330,7 @@
                {
                        ParameterData pd;
                        if (mb != null)
-                               pd = GetParameterData (mb);
+                               pd = TypeManager.GetParameterData (mb);
                        else
                                pd = null;
                        
@@ -5432,7 +5400,7 @@
                static Type[] GetVarargsTypes (EmitContext ec, MethodBase mb,
                                               ArrayList arguments)
                {
-                       ParameterData pd = GetParameterData (mb);
+                       ParameterData pd = TypeManager.GetParameterData (mb);
 
                        if (arguments == null)
                                return new Type [0];

Modified: trunk/mcs/gmcs/generic.cs
===================================================================
--- trunk/mcs/gmcs/generic.cs   2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/generic.cs   2005-04-07 13:31:52 UTC (rev 42639)
@@ -598,7 +598,7 @@
                                        mb = mb.GetGenericMethodDefinition ();
 
                                int pos = type.GenericParameterPosition;
-                               ParameterData pd = Invocation.GetParameterData 
(mb);
+                               ParameterData pd = TypeManager.GetParameterData 
(mb);
                                GenericConstraints temp_gc = 
pd.GenericConstraints (pos);
                                Type mparam = mb.GetGenericArguments () [pos];
 
@@ -2118,7 +2118,7 @@
                        else
                                arg_count = arguments.Count;
                        
-                       ParameterData pd = Invocation.GetParameterData (method);
+                       ParameterData pd = TypeManager.GetParameterData 
(method);
 
                        int pd_count = pd.Count;
 
@@ -2207,7 +2207,7 @@
                        else
                                arg_count = 0;
 
-                       ParameterData pd = Invocation.GetParameterData (method);
+                       ParameterData pd = TypeManager.GetParameterData 
(method);
                        if (arg_count != pd.Count)
                                return false;
 
@@ -2251,7 +2251,7 @@
                        if (!TypeManager.IsGenericMethod (method))
                                return true;
 
-                       ParameterData pd = Invocation.GetParameterData (method);
+                       ParameterData pd = TypeManager.GetParameterData 
(method);
                        if (apd.Count != pd.Count)
                                return false;
 

Modified: trunk/mcs/gmcs/pending.cs
===================================================================
--- trunk/mcs/gmcs/pending.cs   2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/pending.cs   2005-04-07 13:31:52 UTC (rev 42639)
@@ -467,7 +467,7 @@
                                CallingConventions.Standard | 
CallingConventions.HasThis,
                                base_method.ReturnType, args);
 
-                       ParameterData pd = Invocation.GetParameterData 
(iface_method);
+                       ParameterData pd = TypeManager.GetParameterData 
(iface_method);
                        proxy.DefineParameter (0, ParameterAttributes.None, "");
                        for (int i = 0; i < pd.Count; i++) {
                                string name = pd.ParameterName (i);

Modified: trunk/mcs/gmcs/support.cs
===================================================================
--- trunk/mcs/gmcs/support.cs   2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/support.cs   2005-04-07 13:31:52 UTC (rev 42639)
@@ -50,7 +50,7 @@
 
                        if (mb.Mono_IsInflatedMethod) {
                                MethodInfo generic = 
mb.GetGenericMethodDefinition ();
-                               gpd = Invocation.GetParameterData (generic);
+                               gpd = TypeManager.GetParameterData (generic);
 
                                last_arg_is_params = gpd.HasParams;
                                return;

Modified: trunk/mcs/gmcs/typemanager.cs
===================================================================
--- trunk/mcs/gmcs/typemanager.cs       2005-04-07 13:16:30 UTC (rev 42638)
+++ trunk/mcs/gmcs/typemanager.cs       2005-04-07 13:31:52 UTC (rev 42639)
@@ -242,10 +242,9 @@
        static Hashtable indexer_arguments;
 
        // <remarks>
-       //   Maybe `method_arguments' should be replaced and only
-       //   method_internal_params should be kept?
+       //   Maps a MethodBase to its ParameterData (either InternalParameters 
or ReflectionParameters)
        // <remarks>
-       static Hashtable method_internal_params;
+       static Hashtable method_params;
 
        // <remarks>
        //  Keeps track of methods
@@ -277,7 +276,7 @@
                builder_to_ifaces = null;
                method_arguments = null;
                indexer_arguments = null;
-               method_internal_params = null;
+               method_params = null;
                builder_to_method = null;
                
                fields = null;
@@ -377,7 +376,7 @@
                builder_to_member_cache = new PtrHashtable ();
                builder_to_method = new PtrHashtable ();
                method_arguments = new PtrHashtable ();
-               method_internal_params = new PtrHashtable ();
+               method_params = new PtrHashtable ();
                indexer_arguments = new PtrHashtable ();
                builder_to_ifaces = new PtrHashtable ();
                
@@ -937,7 +936,7 @@
 
                MethodBase mb = pb.GetSetMethod (true) != null ? 
pb.GetSetMethod (true) : pb.GetGetMethod (true);
                string signature = GetFullNameSignature (mb);
-               string arg = TypeManager.LookupParametersByBuilder 
(mb).ParameterDesc (0);
+               string arg = GetParameterData (mb).ParameterDesc (0);
                return String.Format ("{0}.this[{1}]", signature.Substring (0, 
signature.LastIndexOf ('.')), arg);
        }
 
@@ -948,15 +947,8 @@
         {
                StringBuilder sig = new StringBuilder ("(");
 
-               //
-               // FIXME: We should really have a single function to do
-               // everything instead of the following 5 line pattern
-               //
-                ParameterData iparams = LookupParametersByBuilder (mb);
+               ParameterData iparams = GetParameterData (mb);
 
-               if (iparams == null)
-                       iparams = new ReflectionParameters (mb);
-               
                // Is property
                if (mb.IsSpecialName && iparams.Count == 0 && !mb.IsConstructor)
                        return GetFullNameSignature (mb);
@@ -1863,18 +1855,20 @@
                        args = NoTypes;
                                
                method_arguments.Add (mb, args);
-               method_internal_params.Add (mb, ip);
+               method_params.Add (mb, ip);
        }
        
-       static public InternalParameters LookupParametersByBuilder (MethodBase 
mb)
+       static public ParameterData GetParameterData (MethodBase mb)
        {
-               if (! (mb is ConstructorBuilder || mb is MethodBuilder))
-                       return null;
-               
-               if (method_internal_params.Contains (mb))
-                       return (InternalParameters) method_internal_params [mb];
-               else
-                       throw new Exception ("Argument for Method not 
registered" + mb);
+               object pd = method_params [mb];
+               if (pd == null) {
+                       if (mb is MethodBuilder || mb is ConstructorBuilder)
+                               throw new InternalErrorException ("Argument for 
Method not registered" + mb);
+
+                       method_params [mb] = pd = new ReflectionParameters (mb);
+               }
+
+               return (ParameterData) pd;
        }
 
        /// <summary>

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

Reply via email to