Vitja Makarov, 13.12.2010 07:49:
> 2010/12/13 Stefan Behnel:
>> Vitja Makarov, 12.12.2010 20:23:
>>> I've cleaned generators stuff a little:
>>>
>>>    * Turn YieldNodeCollector into TreeVisitor
>>
>> I think that's ok. It's a bit redundant with the tree traversal that
>> happens anyway, but it also keeps the code more compact and makes it more
>> understandable.
>>
>> BTW, please start using error test cases. That would easily have caught the
>> obvious reporting bug in visit_ReturnStatNode.
>
> I was thinking about that. I also found that 'return' statment is
> allowed inside generators.
> That should raise StopIteration and close generator.
> Don't know how to go here replace ReturnStatNode with another one

You can replace it by the equivalent of "raise StopIteration" during the 
MarkClosureVisitor transform, e.g. inside of the YieldNodeCollector (which 
would then have to be a transform again). Either emit a compiler error if 
the return statement has an argument (IIRC that's the forbidden case) or 
replace the node if it has none.


>>>    * Move ClosureTempAllocator to Code.py
>>
>> I still think that the reference should live in FunctionState so that it
>> goes out of scope automatically. It shouldn't live longer than the function.
>>
>
> Ok, I'll put reference to code.funcstate, or maybe add method to
> funcstate set_closure_class()
> That will create tempallocator?

Hmm, not sure. What about adding an "init_generator_temps(scope)" method to 
it that creates the CTA and attaches it to the current funcstate?

Stefan
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to