code = globalstate['all_the_rest']
self.generate_cached_builtins_decls(env, code)
- # generate lambda function definitions
- for node in env.lambda_defs:
- node.generate_function_definitions(env, code)
+ self.generate_lambda_definitions(env, code)
# generate normal function definitions
self.body.generate_function_definitions(env, code)
code.mark_pos(None)
for entry in entries:
code.globalstate.add_cached_builtin_decl(entry)
del entries[:]
-
+
+ def generate_lambda_definitions(self, env, code):
+ for node in env.lambda_defs:
+ node.generate_function_definitions(env, code)
class StatListNode(Node):
# stats a list of StatNode
# Generate closure function definitions
self.body.generate_function_definitions(lenv, code)
# generate lambda function definitions
- for node in lenv.lambda_defs:
- node.generate_function_definitions(lenv, code)
+ self.generate_lambda_definitions(lenv, code)
is_getbuffer_slot = (self.entry.name == "__getbuffer__" and
self.entry.scope.is_c_class_scope)
self.target.analyse_target_expression(env, self.classobj)
def generate_function_definitions(self, env, code):
+ self.generate_lambda_definitions(self.scope, code)
self.body.generate_function_definitions(self.scope, code)
def generate_execution_code(self, code):
self.body.analyse_expressions(scope)
def generate_function_definitions(self, env, code):
+ self.generate_lambda_definitions(self.scope, code)
if self.body:
self.body.generate_function_definitions(
self.entry.type.scope, code)
--- /dev/null
+cdef int cdef_CONST = 123
+CONST = 456
+
+cdef class Foo:
+ """
+ >>> obj = Foo()
+ >>> obj.id(123)
+ 123
+ >>> obj.cconst_mul(1)
+ 123
+ >>> obj.const_mul(1)
+ 456
+ >>> obj.foo[0](1)
+ 1
+ """
+ id = lambda self, x: x
+ cconst_mul = lambda self, x: x * cdef_CONST
+ const_mul = lambda self, x: x * CONST
+ foo = (lambda x:x,)
+
+class Bar:
+ """
+ >>> obj = Bar()
+ >>> obj.id(123)
+ 123
+ >>> obj.cconst_mul(1)
+ 123
+ >>> obj.const_mul(1)
+ 456
+ >>> obj.foo[0](1)
+ 1
+ """
+ id = lambda self, x: x
+ cconst_mul = lambda self, x: x * cdef_CONST
+ const_mul = lambda self, x: x * CONST
+ foo = (lambda x:x,)