Author: martin
Date: 2005-03-22 05:27:54 -0500 (Tue, 22 Mar 2005)
New Revision: 42088

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/attribute.cs
   trunk/mcs/gmcs/codegen.cs
   trunk/mcs/gmcs/pending.cs
   trunk/mcs/gmcs/statement.cs
   trunk/mcs/gmcs/symbolwriter.cs
Log:
**** Merged r41134-r41268 from MCS ****


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-03-22 10:27:14 UTC (rev 42087)
+++ trunk/mcs/gmcs/ChangeLog    2005-03-22 10:27:54 UTC (rev 42088)
@@ -1,3 +1,31 @@
+2005-02-25  Marek Safar  <[EMAIL PROTECTED]>
+
+       * attribute.cs (Atttribute.Resolve): Add cache for parameter-less
+       attributes. Removed useless attribute double check.
+       It saves almost 2MBs for corlib.
+
+2005-02-25  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #72924.
+       * statement.cs (ExpressionStatement.Resolve): Make robust to being
+       called twice in case of error.
+
+2005-02-23  Chris Toshok  <[EMAIL PROTECTED]>
+
+       Fix compiler portions of #72827.
+       * statement.cs (Block.Emit): call Begin/EndScope on the
+       EmitContext instead of the ILGenerator.
+
+       * codegen.cs (EmitContext.BeginScope): new method, call
+       ILGenerator.BeginScope as well as the SymbolWriter's OpenScope (if
+       we have one.)
+       (EmitContext.BeginScope): same, but EndScope and CloseScope
+
+       * symbolwriter.cs (SymbolWriter.OpenScope): get the current il
+       offset and call the superclass's OpenScope(int) with it.
+       (SymbolWriter.CloseScope): get the current il
+       offset and call superclass's CloseScope(int) with it.
+
 2005-02-23  Marek Safar  <[EMAIL PROTECTED]>
 
        * anonymous.cs (AnonymousMethod.Compatible): Fixed to report

Modified: trunk/mcs/gmcs/attribute.cs
===================================================================
--- trunk/mcs/gmcs/attribute.cs 2005-03-22 10:27:14 UTC (rev 42087)
+++ trunk/mcs/gmcs/attribute.cs 2005-03-22 10:27:54 UTC (rev 42088)
@@ -302,6 +302,9 @@
                        return false;
                }
                
+               // Cache for parameter-less attributes
+               static PtrHashtable att_cache = new PtrHashtable ();
+
                public virtual CustomAttributeBuilder Resolve (EmitContext ec)
                {
                        if (resolve_error)
@@ -309,25 +312,25 @@
 
                        resolve_error = true;
 
-                       Type oldType = Type;
-                       
-                       // Sanity check.
-                       Type = CheckAttributeType (ec); // TODO: I really don't 
think we need such expensive double check
+                       if (Type == null)
+                               Type = CheckAttributeType (ec);
 
-                       if (oldType == null && Type == null)
+                       if (Type == null)
                                return null;
-                       if (oldType != null && oldType != Type){
-                               Report.Error (-27, Location,
-                                             "Attribute {0} resolved to 
different types at different times: {1} vs. {2}",
-                                             Name, oldType, Type);
-                               return null;
-                       }
 
                        if (Type.IsAbstract) {
                                Report.Error (653, Location, "Cannot apply 
attribute class '{0}' because it is abstract", Name);
                                return null;
                        }
 
+                       if (Arguments == null) {
+                               object o = att_cache [Type];
+                               if (o != null) {
+                                       resolve_error = false;
+                                       return (CustomAttributeBuilder)o;
+                               }
+                       }
+
                        bool MethodImplAttr = false;
                        bool MarshalAsAttr = false;
                        bool GuidAttr = false;
@@ -615,9 +618,13 @@
                                                prop_info_arr, prop_values_arr,
                                                field_info_arr, 
field_values_arr);
                                }
-                               else
+                               else {
                                        cb = new CustomAttributeBuilder (
                                                (ConstructorInfo) constructor, 
pos_values);
+
+                                       if (pos_values.Length == 0)
+                                               att_cache.Add (Type, cb);
+                               }
                        } catch (Exception e) {
                                //
                                // Sample:
@@ -755,10 +762,10 @@
                                Resolve (ec);
 
                        // Some error occurred
-                       if (pos_values == null)
+                       if (resolve_error)
                                return null;
 
-                       if (pos_values.Length == 0)
+                       if (pos_values == null || pos_values.Length == 0)
                                return new ObsoleteAttribute ();
 
                        if (pos_values.Length == 1)

Modified: trunk/mcs/gmcs/codegen.cs
===================================================================
--- trunk/mcs/gmcs/codegen.cs   2005-03-22 10:27:14 UTC (rev 42087)
+++ trunk/mcs/gmcs/codegen.cs   2005-03-22 10:27:54 UTC (rev 42088)
@@ -809,6 +809,22 @@
                        CodeGen.SymbolWriter.DefineLocalVariable (name, 
builder);
                }
 
+               public void BeginScope ()
+               {
+                       ig.BeginScope();
+
+                       if (CodeGen.SymbolWriter != null)
+                               CodeGen.SymbolWriter.OpenScope(ig);
+               }
+
+               public void EndScope ()
+               {
+                       ig.EndScope();
+
+                       if (CodeGen.SymbolWriter != null)
+                               CodeGen.SymbolWriter.CloseScope(ig);
+               }
+
                /// <summary>
                ///   Returns a temporary storage for a variable of type t as 
                ///   a local variable in the current body.

Modified: trunk/mcs/gmcs/pending.cs
===================================================================
--- trunk/mcs/gmcs/pending.cs   2005-03-22 10:27:14 UTC (rev 42087)
+++ trunk/mcs/gmcs/pending.cs   2005-03-22 10:27:54 UTC (rev 42088)
@@ -175,8 +175,14 @@
                                
                                int j = 0;
                                foreach (MethodInfo m in mi){
-                                       Type [] types = 
TypeManager.GetArgumentTypes (m);
+                                       Type [] types;
                                        
+                                       // If there is a previous error, just 
ignore
+                                       if (m == null)
+                                               types = TypeManager.NoTypes;
+                                       else
+                                               types = 
TypeManager.GetArgumentTypes (m);
+                                       
                                        pending_implementations [i].args [j] = 
types;
                                        j++;
                                }

Modified: trunk/mcs/gmcs/statement.cs
===================================================================
--- trunk/mcs/gmcs/statement.cs 2005-03-22 10:27:14 UTC (rev 42087)
+++ trunk/mcs/gmcs/statement.cs 2005-03-22 10:27:54 UTC (rev 42088)
@@ -530,7 +530,8 @@
 
                public override bool Resolve (EmitContext ec)
                {
-                       expr = expr.ResolveStatement (ec);
+                       if (expr != null)
+                               expr = expr.ResolveStatement (ec);
                        return expr != null;
                }
                
@@ -2071,7 +2072,7 @@
 
                        if (emit_debug_info) {
                                if (is_lexical_block)
-                                       ec.ig.BeginScope ();
+                                       ec.BeginScope ();
 
                                if (variables != null) {
                                        foreach (DictionaryEntry de in 
variables) {
@@ -2091,7 +2092,7 @@
                        ec.Mark (EndLocation, true); 
 
                        if (emit_debug_info && is_lexical_block)
-                               ec.ig.EndScope ();
+                               ec.EndScope ();
 
                        ec.CurrentBlock = prev_block;
                }

Modified: trunk/mcs/gmcs/symbolwriter.cs
===================================================================
--- trunk/mcs/gmcs/symbolwriter.cs      2005-03-22 10:27:14 UTC (rev 42087)
+++ trunk/mcs/gmcs/symbolwriter.cs      2005-03-22 10:27:54 UTC (rev 42088)
@@ -66,6 +66,18 @@
                        DefineLocalVariable (name, signature);
                }
 
+               public int OpenScope (ILGenerator ig)
+               {
+                       int offset = get_il_offset_func (ig);
+                       return OpenScope (offset);
+               }
+
+               public void CloseScope (ILGenerator ig)
+               {
+                       int offset = get_il_offset_func (ig);
+                       CloseScope (offset);
+               }
+
                public void MarkSequencePoint (ILGenerator ig, int row, int 
column)
                {
                        int offset = get_il_offset_func (ig);

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

Reply via email to