2004-04-22 Marek Safar <marek.safar@seznam.cz>
authorMarek Safar <marek.safar@gmail.com>
Thu, 22 Apr 2004 06:59:12 +0000 (06:59 -0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 22 Apr 2004 06:59:12 +0000 (06:59 -0000)
* decl.cs (caching_flags): New member for storing cached values
as bit flags.
(MemberCore.Flags): New enum where bit flags for caching_flags
are defined.
(MemberCore.cls_compliance): Moved to caching_flags.
(DeclSpace.Created): Moved to caching_flags.

* class.cs: Use caching_flags instead of DeclSpace.Created

svn path=/trunk/mcs/; revision=25816

mcs/mcs/ChangeLog
mcs/mcs/class.cs
mcs/mcs/decl.cs

index 5b9957721befb760dafaa977e1cad77d78b62862..5965abbb6d33d0b313f1ab398befc06b3ab62c5c 100755 (executable)
@@ -1,3 +1,14 @@
+2004-04-22  Marek Safar  <marek.safar@seznam.cz>
+
+       * decl.cs (caching_flags): New member for storing cached values
+       as bit flags.
+       (MemberCore.Flags): New enum where bit flags for caching_flags
+       are defined.
+       (MemberCore.cls_compliance): Moved to caching_flags.
+       (DeclSpace.Created): Moved to caching_flags.
+
+       * class.cs: Use caching_flags instead of DeclSpace.Created
+        
 2004-04-21  Miguel de Icaza  <miguel@ximian.com>
 
        * ecore.cs (PropertyExpr.GetAccesor): Only perform the 1540 check
index 2c92673c86bf077cea5c220da4926e2cf097dafb..f56c48b9415f0769926d10ea55188b075d94b7f1 100755 (executable)
@@ -1860,11 +1860,11 @@ namespace Mono.CSharp {
 
                public override void CloseType ()
                {
-                       if (Created)
+                       if ((caching_flags & Flags.CloseTypeCreated) != 0)
                                return;
                        
                        try {
-                               Created = true;
+                               caching_flags |= Flags.CloseTypeCreated;
                                TypeBuilder.CreateType ();
                        } catch (TypeLoadException){
                                //
index 77ea3c663d24b7471629b00492b62a0c8626b5ca..97855902a4d0dd5bd2d9a68fa92e606f0af4826b 100755 (executable)
@@ -42,24 +42,26 @@ namespace Mono.CSharp {
                /// </summary>
                Attributes attributes;
 
-               public enum ClsComplianceValue
-               {
-                       Undetected,
-                       Yes,
-                       No      
+               [Flags]
+               public enum Flags {
+                       Obsolete_Undetected = 1,                // Obsolete attribute has not beed detected yet
+                       Obsolete = 1 << 1,                      // Type has obsolete attribute
+                       ClsCompliance_Undetected = 1 << 2,      // CLS Compliance has not been detected yet
+                       ClsCompliant = 1 << 3,                  // Type is CLS Compliant
+                       CloseTypeCreated = 1 << 4               // Tracks whether we have Closed the type
                }
 
                /// <summary>
-               /// Whether CLS compliance must be done on this type.
+               ///   MemberCore flags at first detected then cached
                /// </summary>
-               protected ClsComplianceValue cls_compliance;
+               protected Flags caching_flags;
 
                public MemberCore (string name, Attributes attrs, Location loc)
                {
                        Name = name;
                        Location = loc;
                        attributes = attrs;
-                       cls_compliance = ClsComplianceValue.Undetected;
+                       caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected;
                }
 
                public abstract bool Define (TypeContainer parent);
@@ -116,20 +118,16 @@ namespace Mono.CSharp {
                /// </summary>
                public bool IsClsCompliaceRequired (DeclSpace container)
                {
-                       if (cls_compliance != ClsComplianceValue.Undetected)
-                               return cls_compliance == ClsComplianceValue.Yes;
+                       if ((caching_flags & Flags.ClsCompliance_Undetected) == 0)
+                               return (caching_flags & Flags.ClsCompliant) != 0;
 
-                       if (!IsExposedFromAssembly (container)) {
-                               cls_compliance = ClsComplianceValue.No;
+                       if (!IsExposedFromAssembly (container) || !GetClsCompliantAttributeValue (container)) {
+                               caching_flags &= ~Flags.ClsCompliance_Undetected;
                                return false;
                        }
 
-                       if (!GetClsCompliantAttributeValue (container)) {
-                               cls_compliance = ClsComplianceValue.No;
-                               return false;
-                       }
-
-                       cls_compliance = ClsComplianceValue.Yes;
+                       caching_flags &= ~Flags.ClsCompliance_Undetected;
+                       caching_flags |= Flags.ClsCompliant;
                        return true;
                }
 
@@ -158,17 +156,11 @@ namespace Mono.CSharp {
                        if (OptAttributes != null) {
                                Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ds);
                                if (cls_attribute != null) {
-                                       if (cls_attribute.GetClsCompliantAttributeValue (ds)) {
-                                               cls_compliance = ClsComplianceValue.Yes;
-                                               return true;
-                                       }
-                                       cls_compliance = ClsComplianceValue.No;
-                                       return false;
+                                       return cls_attribute.GetClsCompliantAttributeValue (ds);
                                }
                        }
 
-                       cls_compliance = ds.GetClsCompliantAttributeValue ();
-                       return cls_compliance == ClsComplianceValue.Yes;
+                       return (ds.GetClsCompliantAttributeValue () & Flags.ClsCompliant) != 0;
                }
 
                /// <summary>
@@ -287,11 +279,6 @@ namespace Mono.CSharp {
                /// </summary>
                public TypeBuilder TypeBuilder;
 
-               /// <summary>
-               ///   This variable tracks whether we have Closed the type
-               /// </summary>
-               public bool Created = false;
-               
                //
                // This is the namespace in which this typecontainer
                // was declared.  We use this to resolve names.
@@ -463,7 +450,7 @@ namespace Mono.CSharp {
 
                public virtual void CloseType ()
                {
-                       if (!Created){
+                       if ((caching_flags & Flags.CloseTypeCreated) == 0){
                                try {
                                        TypeBuilder.CreateType ();
                                } catch {
@@ -478,7 +465,7 @@ namespace Mono.CSharp {
                                        // Note that this still creates the type and
                                        // it is possible to save it
                                }
-                               Created = true;
+                               caching_flags |= Flags.CloseTypeCreated;
                        }
                }
 
@@ -968,25 +955,31 @@ namespace Mono.CSharp {
                /// Goes through class hierarchy and get value of first CLSCompliantAttribute that found.
                /// If no is attribute exists then return assembly CLSCompliantAttribute.
                /// </summary>
-               public ClsComplianceValue GetClsCompliantAttributeValue ()
+               public Flags GetClsCompliantAttributeValue ()
                {
-                       if (cls_compliance != ClsComplianceValue.Undetected)
-                               return cls_compliance;
+                       if ((caching_flags & Flags.ClsCompliance_Undetected) == 0)
+                               return caching_flags;
+
+                       caching_flags &= ~Flags.ClsCompliance_Undetected;
 
                        if (OptAttributes != null) {
                                Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (this);
                                if (cls_attribute != null) {
-                                       cls_compliance = cls_attribute.GetClsCompliantAttributeValue (this) ? ClsComplianceValue.Yes : ClsComplianceValue.No;
-                                       return cls_compliance;
+                                       if (cls_attribute.GetClsCompliantAttributeValue (this)) {
+                                               caching_flags |= Flags.ClsCompliant;
+                                       }
+                                       return caching_flags;
                                }
                        }
 
                        if (parent == null) {
-                               cls_compliance = CodeGen.Assembly.IsClsCompliant ? ClsComplianceValue.Yes : ClsComplianceValue.No;
-                               return cls_compliance;
+                               if (CodeGen.Assembly.IsClsCompliant)
+                                       caching_flags |= Flags.ClsCompliant;
+                               return caching_flags;
                        }
 
-                       return parent.GetClsCompliantAttributeValue ();
+                       caching_flags |= (parent.GetClsCompliantAttributeValue () & Flags.ClsCompliant);
+                       return caching_flags;
                }