Commit 4510e2ef authored by Robert Bradshaw's avatar Robert Bradshaw

First pass at PersistentLocalScope

parent ec7cd84b
......@@ -349,13 +349,14 @@ def create_generate_code(context, options):
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(),
......
......@@ -72,6 +72,7 @@ optional_args_cname = pyrex_prefix + "optional_args"
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__"
......
......@@ -10,7 +10,7 @@ import Naming
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
......@@ -773,9 +773,11 @@ class FuncDefNode(StatNode, BlockNode):
# 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()
......@@ -807,6 +809,9 @@ class FuncDefNode(StatNode, BlockNode):
genv = env
while env.is_py_class_scope or env.is_c_class_scope:
env = env.outer_scope
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
......
......@@ -185,7 +185,7 @@ class AnalyseExpressionsTransform(VisitorTransform):
self.visitchildren(node)
return node
class MarkClosureNode(VisitorTransform):
class MarkClosureVisitor(VisitorTransform):
needs_closure = False
......
#
# Pyrex - Symbol Table
# Symbol Table
#
import re
......@@ -1121,6 +1121,11 @@ class LocalScope(Scope):
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.
......
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