def create_default_pipeline(context, options):
from ParseTreeTransforms import WithTransform, PostParse
- from ParseTreeTransforms import AnalyseDeclarationsTransform, AnalyseExpressionsTransform
+ from ParseTreeTransforms import AnalyseDeclarationsTransform, AnalyseExpressionsTransform, MarkClosureVisitor
from ModuleNode import check_c_classes
return [
create_parse(context),
PostParse(),
WithTransform(),
+ MarkClosureVisitor(),
AnalyseDeclarationsTransform(),
check_c_classes,
AnalyseExpressionsTransform(),
no_opt_args = pyrex_prefix + "no_opt_args"
import_star = pyrex_prefix + "import_star"
import_star_set = pyrex_prefix + "import_star_set"
+scope_obj_cname = pyrex_prefix + "scope"
line_c_macro = "__LINE__"
import PyrexTypes
import TypeSlots
from PyrexTypes import py_object_type, error_type, CTypedefType, CFuncType
-from Symtab import ModuleScope, LocalScope, \
+from Symtab import ModuleScope, LocalScope, PersistentLocalScope, \
StructOrUnionScope, PyClassScope, CClassScope
from Cython.Utils import open_new_file, replace_suffix, EncodedString
import Options
# return_type PyrexType
# #filename string C name of filename string const
# entry Symtab.Entry
+ # needs_closure boolean Whether or not this function has inner functions/classes/yield
py_func = None
assmt = None
+ needs_closure = False
def analyse_default_values(self, env):
genv = env.global_scope()
genv = env
while env.is_py_class_scope or env.is_c_class_scope:
env = env.outer_scope
- lenv = LocalScope(name = self.entry.name, outer_scope = genv)
+ if self.needs_closure:
+ lenv = PersistentLocalScope(name = self.entry.name, outer_scope = genv)
+ else:
+ lenv = LocalScope(name = self.entry.name, outer_scope = genv)
lenv.return_type = self.return_type
type = self.entry.type
if type.is_cfunction:
#
-# Pyrex - Symbol Table
+# Symbol Table
#
import re
self.entries[name] = entry
+class PersistentLocalScope(LocalScope):
+
+ def mangle(self, prefix, name):
+ return "%s->%s" % (scope_obj_cname, name)
+
class StructOrUnionScope(Scope):
# Namespace of a C struct or union.