Author: martin
Date: 2005-07-08 12:45:30 -0400 (Fri, 08 Jul 2005)
New Revision: 47112

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/class.cs
   trunk/mcs/mcs/cs-parser.jay
Log:
2005-07-08  Martin Baulig  <[EMAIL PROTECTED]>

        Fix test-iter-10.cs - distinguish whether we `yield' in a property
        gettter (allowed) or setter (not allowed).

        * class.cs (Accessor): Implement IIteratorContainer.
        (Accessor.Yields): New public field.
        (PropertyBase.PropertyMethod.Define): Handle iterators on a
        per-accessor basis.

        * cs-parser.jay
        (get_accessor_declaration, set_accessor_declaration): Set the
        `yields' flag on the accessor, not the property.
        (property_declaration): Do the iterators check on a per-accessor
        basis and not for the whole property.



Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-07-08 16:43:41 UTC (rev 47111)
+++ trunk/mcs/mcs/ChangeLog     2005-07-08 16:45:30 UTC (rev 47112)
@@ -5,6 +5,22 @@
 
 2005-07-08  Martin Baulig  <[EMAIL PROTECTED]>
 
+       Fix test-iter-10.cs - distinguish whether we `yield' in a property
+       gettter (allowed) or setter (not allowed).
+
+       * class.cs (Accessor): Implement IIteratorContainer.
+       (Accessor.Yields): New public field.
+       (PropertyBase.PropertyMethod.Define): Handle iterators on a
+       per-accessor basis.
+
+       * cs-parser.jay
+       (get_accessor_declaration, set_accessor_declaration): Set the
+       `yields' flag on the accessor, not the property.
+       (property_declaration): Do the iterators check on a per-accessor
+       basis and not for the whole property.
+
+2005-07-08  Martin Baulig  <[EMAIL PROTECTED]>
+
        * anonymous.cs (CaptureContext.EmitParameterInstance): Correctly
        handle parameters in nested scopes; fixes #74808; see gtest-188.cs.
 

Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs      2005-07-08 16:43:41 UTC (rev 47111)
+++ trunk/mcs/mcs/class.cs      2005-07-08 16:45:30 UTC (rev 47112)
@@ -3118,7 +3118,6 @@
                        }
                }
 
-               // TODO: why is it done in extra call ?
                public void SetYields ()
                {
                        ModFlags |= Modifiers.METHOD_YIELDS;
@@ -5661,7 +5660,7 @@
        //
        // `set' and `get' accessors are represented with an Accessor.
        // 
-       public class Accessor {
+       public class Accessor : IIteratorContainer {
                //
                // Null if the accessor is empty, or a Block if not
                //
@@ -5675,6 +5674,7 @@
                public Attributes Attributes;
                public Location Location;
                public int ModFlags;
+               public bool Yields;
                
                public Accessor (ToplevelBlock b, int mod, Attributes attrs, 
Location loc)
                {
@@ -5683,9 +5683,13 @@
                        Location = loc;
                        ModFlags = Modifiers.Check (AllowedModifiers, mod, 0, 
loc);
                }
+
+               public void SetYields ()
+               {
+                       Yields = true;
+               }
        }
 
-
        // Ooouh Martin, templates are missing here.
        // When it will be possible move here a lot of child code and template 
method type.
        public abstract class AbstractPropertyEventMethod: MemberCore, 
IMethodData {
@@ -6005,6 +6009,7 @@
                {
                        protected readonly MethodCore method;
                        protected MethodAttributes flags;
+                       bool yields;
 
                        public PropertyMethod (MethodCore method, string prefix)
                                : base (method, prefix)
@@ -6020,6 +6025,7 @@
                                this.method = method;
                                Parent = method.Parent;
                                this.ModFlags = accessor.ModFlags;
+                               yields = accessor.Yields;
 
                                if (accessor.ModFlags != 0 && 
RootContext.Version == LanguageVersion.ISO_1) {
                                        Report.FeatureIsNotStandardized 
(Location, "access modifiers on properties");
@@ -6074,7 +6080,7 @@
                                //
                                // Setup iterator if we are one
                                //
-                               if ((ModFlags & Modifiers.METHOD_YIELDS) != 0){
+                               if (yields) {
                                        Iterator iterator = new Iterator (this,
                                                Parent, method.ParameterInfo, 
ModFlags);
                                        
@@ -6363,7 +6369,7 @@
                }
        }
                        
-       public class Property : PropertyBase, IIteratorContainer {
+       public class Property : PropertyBase {
                const int AllowedModifiers =
                        Modifiers.NEW |
                        Modifiers.PUBLIC |

Modified: trunk/mcs/mcs/cs-parser.jay
===================================================================
--- trunk/mcs/mcs/cs-parser.jay 2005-07-08 16:43:41 UTC (rev 47111)
+++ trunk/mcs/mcs/cs-parser.jay 2005-07-08 16:45:30 UTC (rev 47112)
@@ -1260,8 +1260,6 @@
                lexer.PropertyParsing = true;
 
                $$ = lexer.Location;
-
-               iterator_container = SimpleIteratorContainer.GetSimple ();
          }
          accessor_declarations 
          {
@@ -1283,12 +1281,9 @@
 
                prop = new Property (current_class, (Expression) $3, (int) $2, 
false,
                                     name, (Attributes) $1, get_block, 
set_block, loc);
-               if (SimpleIteratorContainer.Simple.Yields)
-                       prop.SetYields ();
                
                current_container.AddProperty (prop);
                implicit_value_parameter_type = null;
-               iterator_container = null;
 
                if (RootContext.Documentation != null)
                        prop.DocComment = ConsumeStoredComment ();
@@ -1334,6 +1329,8 @@
                else 
                        current_local_parameters = indexer_parameters;
                lexer.PropertyParsing = false;
+
+               iterator_container = SimpleIteratorContainer.GetSimple ();
          }
           accessor_body
          {
@@ -1341,14 +1338,21 @@
                        Report.Error (1007, lexer.Location, "Property accessor 
already defined");
                        break;
                }
-               $$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) 
$1, lexer.Location);
+               Accessor accessor = new Accessor ((ToplevelBlock) $5, (int) $2, 
(Attributes) $1, lexer.Location);
                has_get = true;
                current_local_parameters = null;
                lexer.PropertyParsing = true;
 
+               if (SimpleIteratorContainer.Simple.Yields)
+                       accessor.SetYields ();
+
+               iterator_container = null;
+
                if (RootContext.Documentation != null)
                        if (Lexer.doc_state == XmlCommentState.Error)
                                Lexer.doc_state = XmlCommentState.NotAllowed;
+
+               $$ = accessor;
          }
        ;
 
@@ -1380,6 +1384,8 @@
                }
                
                lexer.PropertyParsing = false;
+
+               iterator_container = SimpleIteratorContainer.GetSimple ();
          }
          accessor_body
          {
@@ -1387,14 +1393,21 @@
                        Report.Error (1007, lexer.Location, "Property accessor 
already defined");
                        break;
                }
-               $$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) 
$1, lexer.Location);
+               Accessor accessor = new Accessor ((ToplevelBlock) $5, (int) $2, 
(Attributes) $1, lexer.Location);
                has_set = true;
                current_local_parameters = null;
                lexer.PropertyParsing = true;
 
+               if (SimpleIteratorContainer.Simple.Yields)
+                       accessor.SetYields ();
+
+               iterator_container = null;
+
                if (RootContext.Documentation != null
                        && Lexer.doc_state == XmlCommentState.Error)
                        Lexer.doc_state = XmlCommentState.NotAllowed;
+
+               $$ = accessor;
          }
        ;
 
@@ -2207,7 +2220,6 @@
                
                lexer.PropertyParsing = true;
                parsing_indexer  = true;
-               iterator_container = SimpleIteratorContainer.GetSimple ();
                
                indexer_parameters = decl.param_list;
          }
@@ -2241,8 +2253,6 @@
                indexer = new Indexer (current_class, decl.type, name,
                                       (int) $2, false, decl.param_list, 
(Attributes) $1,
                                       get_block, set_block, loc);
-               if (SimpleIteratorContainer.Simple.Yields)
-                       indexer.SetYields ();
 
                if (RootContext.Documentation != null)
                        indexer.DocComment = ConsumeStoredComment ();
@@ -2252,7 +2262,6 @@
                current_local_parameters = null;
                implicit_value_parameter_type = null;
                indexer_parameters = null;
-               iterator_container = null;
          }
        ;
 

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

Reply via email to