[Mono-devel-list] iterators again! (CS0204)

Alan Jenkins sourcejedi at phonecoop.coop
Thu Feb 26 16:14:18 EST 2004


On Thu, 2004-02-26 at 18:52, Alan Jenkins wrote:
> I have found where the error comes from (csparser.jay) and why 
> (iterator_container is not set when entering a operator / getter), but I 
> havent yet found out whether changes are necessary in other places, and I 
> don't really understand jay.
> 
> I have filed a bug for this problem (#54902)

Attached is a patch which allows operators to use the iterator feature /
yield keyword.  Could someone please review this?

I may or may not be able to do the same for property accessors.  The
saga continues...
-------------- next part --------------
Index: class.cs
===================================================================
RCS file: /mono/mcs/mcs/class.cs,v
retrieving revision 1.401
diff -r1.401 class.cs
4874c4874
< 	public class Operator : MemberBase {
---
> 	public class Operator : MemberBase, IIteratorContainer {
4937c4937
< 				 Block block, Attributes attrs, Location loc)
---
> 				 Attributes attrs, Location loc)
4947d4946
< 			Block = block;
4985c4984,4989
< 			OperatorMethod.IsOperator = true;			
---
> 			OperatorMethod.IsOperator = true;
> 			OperatorMethod.Block = Block;
> 			
> 			if ((ModFlags & Modifiers.METHOD_YIELDS) != 0)
> 				((IIteratorContainer) OperatorMethod).SetYields ();	
> 						
5099d5102
< 			OperatorMethod.Block = Block;
5179a5183,5187
> 		}
> 		
> 		void IIteratorContainer.SetYields ()
> 		{
> 			ModFlags |= Modifiers.METHOD_YIELDS;
Index: cs-parser.jay
===================================================================
RCS file: /mono/mcs/mcs/cs-parser.jay,v
retrieving revision 1.283
diff -r1.283 cs-parser.jay
1361c1361,1364
< 	: opt_attributes opt_modifiers operator_declarator operator_body
---
> 	: operator_header {
> 		iterator_container = (IIteratorContainer) $1;
> 	  }
> 	  operator_body
1363,1367c1366,1368
< 		OperatorDeclaration decl = (OperatorDeclaration) $3;
< 		
< 		Operator op = new Operator (decl.optype, decl.ret_type, (int) $2, decl.arg1type, decl.arg1name,
< 					    decl.arg2type, decl.arg2name, (Block) $4, (Attributes) $1, decl.location);
< 
---
> 		Operator op = (Operator) $1;
> 		op.Block = (Block) $3;
> 	  	
1371a1373,1387
> 		
> 		iterator_container = null;
> 	  }
> 	;
> 	
> operator_header
> 	: opt_attributes opt_modifiers operator_declarator
> 	  {
> 		OperatorDeclaration decl = (OperatorDeclaration) $3;
> 		
> 		Operator op = new Operator (decl.optype, decl.ret_type, (int) $2, decl.arg1type, decl.arg1name,
> 					    decl.arg2type, decl.arg2name, (Attributes) $1, decl.location);
> 					    
> 				
> 		$$ = op;	    


More information about the Mono-devel-list mailing list