Commit eb6e9b56 authored by Stefan Behnel's avatar Stefan Behnel

eliminate StopIterationNode

parent 8c58fa41
......@@ -5033,20 +5033,6 @@ class YieldExprNode(ExprNode):
else:
code.putln(code.error_goto_if_null(Naming.sent_value_cname, self.pos))
class StopIterationNode(Node):
# XXX: is it okay?
child_attrs = []
def analyse_expressions(self, env):
pass
def generate_function_definitions(self, env, code):
pass
def generate_execution_code(self, code):
code.putln('/* Stop iteration */')
code.putln('PyErr_SetNone(PyExc_StopIteration); %s' % code.error_goto(self.pos))
#-------------------------------------------------------------------
#
# Unary operator nodes
......
......@@ -1372,6 +1372,9 @@ class FuncDefNode(StatNode, BlockNode):
# -------------------------
self.body.generate_execution_code(code)
if self.is_generator:
code.putln('PyErr_SetNone(PyExc_StopIteration); %s' % code.error_goto(self.pos))
# ----- Default return value
code.putln("")
if self.return_type.is_pyobject:
......
......@@ -1407,12 +1407,10 @@ class MarkGeneratorVisitor(CythonTransform):
error(collector.returns[0].pos, "'return' with argument inside generator")
elif collector.yields:
allocator = ClosureTempAllocator()
stop_node = ExprNodes.StopIterationNode(node.pos, arg=None)
# XXX: move allocator inside local scope
for y in collector.yields:
y.temp_allocator = allocator
node.temp_allocator = allocator
node.body.stats.append(stop_node)
node.is_generator = True
node.needs_closure = True
node.yields = collector.yields
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment