From dc7ec25ceb7745bc6a2894c8aeab4e8928bdad79 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 22 Apr 2004 06:59:12 +0000 Subject: [PATCH] 2004-04-22 Marek Safar * 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 | 11 +++++++ mcs/mcs/class.cs | 4 +-- mcs/mcs/decl.cs | 75 +++++++++++++++++++++-------------------------- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index 5b9957721be..5965abbb6d3 100755 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,14 @@ +2004-04-22 Marek Safar + + * 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 * ecore.cs (PropertyExpr.GetAccesor): Only perform the 1540 check diff --git a/mcs/mcs/class.cs b/mcs/mcs/class.cs index 2c92673c86b..f56c48b9415 100755 --- a/mcs/mcs/class.cs +++ b/mcs/mcs/class.cs @@ -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){ // diff --git a/mcs/mcs/decl.cs b/mcs/mcs/decl.cs index 77ea3c663d2..97855902a4d 100755 --- a/mcs/mcs/decl.cs +++ b/mcs/mcs/decl.cs @@ -42,24 +42,26 @@ namespace Mono.CSharp { /// 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 } /// - /// Whether CLS compliance must be done on this type. + /// MemberCore flags at first detected then cached /// - 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 { /// 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; } /// @@ -287,11 +279,6 @@ namespace Mono.CSharp { /// public TypeBuilder TypeBuilder; - /// - /// This variable tracks whether we have Closed the type - /// - 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. /// - 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; } -- 2.25.1