env.add_lambda_def(self.def_node)
-class OldYieldExprNode(ExprNode):
- # XXX: remove me someday
- #
- # arg ExprNode the value to return from the generator
- # label_name string name of the C label used for this yield
-
- subexprs = ['arg']
- type = py_object_type
-
- def analyse_types(self, env):
- self.is_temp = 1
- if self.arg is not None:
- self.arg.analyse_types(env)
- if not self.arg.type.is_pyobject:
- self.arg = self.arg.coerce_to_pyobject(env)
- error(self.pos, "Generators are not supported")
-
- def generate_result_code(self, code):
- self.label_name = code.new_label('resume_from_yield')
- code.use_label(self.label_name)
- code.putln("/* FIXME: save temporary variables */")
- code.putln("/* FIXME: return from function, yielding value */")
- code.put_label(self.label_name)
- code.putln("/* FIXME: restore temporary variables and */")
- code.putln("/* FIXME: extract sent value from closure */")
-
class YieldExprNode(ExprNode):
# Yield expression node
#
self.yield_nodes = []
visit_Node = Visitor.TreeVisitor.visitchildren
- def visit_OldYieldExprNode(self, node):
+ def visit_YieldExprNode(self, node):
self.yield_nodes.append(node)
self.visitchildren(node)
def visit_DefNode(self, node):
pass
+ def visit_GeneratorExpressionNode(self, node):
+ pass
+
class MarkClosureVisitor(CythonTransform):
def visit_ModuleNode(self, node):
self.needs_closure = True
return node
-
class CreateClosureClasses(CythonTransform):
# Output closure classes in module scope for all functions
# that really need it.
def p_genexp(s, expr):
# s.sy == 'for'
loop = p_comp_for(s, Nodes.ExprStatNode(
- expr.pos, expr = ExprNodes.OldYieldExprNode(expr.pos, arg=expr)))
+ expr.pos, expr = ExprNodes.YieldExprNode(expr.pos, arg=expr)))
return ExprNodes.GeneratorExpressionNode(expr.pos, loop=loop)
expr_terminators = (')', ']', '}', ':', '=', 'NEWLINE')