Commit c40bf20c authored by Stefan Behnel's avatar Stefan Behnel

minor code beautification

parent 6c5c2b9c
...@@ -55,6 +55,7 @@ def generate_pyx_code_stage_factory(options, result): ...@@ -55,6 +55,7 @@ def generate_pyx_code_stage_factory(options, result):
return result return result
return generate_pyx_code_stage return generate_pyx_code_stage
def inject_pxd_code_stage_factory(context): def inject_pxd_code_stage_factory(context):
def inject_pxd_code_stage(module_node): def inject_pxd_code_stage(module_node):
for name, (statlistnode, scope) in context.pxds.items(): for name, (statlistnode, scope) in context.pxds.items():
...@@ -62,6 +63,7 @@ def inject_pxd_code_stage_factory(context): ...@@ -62,6 +63,7 @@ def inject_pxd_code_stage_factory(context):
return module_node return module_node
return inject_pxd_code_stage return inject_pxd_code_stage
def use_utility_code_definitions(scope, target, seen=None): def use_utility_code_definitions(scope, target, seen=None):
if seen is None: if seen is None:
seen = set() seen = set()
...@@ -78,6 +80,7 @@ def use_utility_code_definitions(scope, target, seen=None): ...@@ -78,6 +80,7 @@ def use_utility_code_definitions(scope, target, seen=None):
elif entry.as_module: elif entry.as_module:
use_utility_code_definitions(entry.as_module, target, seen) use_utility_code_definitions(entry.as_module, target, seen)
def inject_utility_code_stage_factory(context): def inject_utility_code_stage_factory(context):
def inject_utility_code_stage(module_node): def inject_utility_code_stage(module_node):
use_utility_code_definitions(context.cython_scope, module_node.scope) use_utility_code_definitions(context.cython_scope, module_node.scope)
...@@ -85,11 +88,12 @@ def inject_utility_code_stage_factory(context): ...@@ -85,11 +88,12 @@ def inject_utility_code_stage_factory(context):
# Note: the list might be extended inside the loop (if some utility code # Note: the list might be extended inside the loop (if some utility code
# pulls in other utility code, explicitly or implicitly) # pulls in other utility code, explicitly or implicitly)
for utilcode in module_node.scope.utility_code_list: for utilcode in module_node.scope.utility_code_list:
if utilcode in added: continue if utilcode in added:
continue
added.append(utilcode) added.append(utilcode)
if utilcode.requires: if utilcode.requires:
for dep in utilcode.requires: for dep in utilcode.requires:
if not dep in added and not dep in module_node.scope.utility_code_list: if dep not in added and dep not in module_node.scope.utility_code_list:
module_node.scope.utility_code_list.append(dep) module_node.scope.utility_code_list.append(dep)
tree = utilcode.get_tree() tree = utilcode.get_tree()
if tree: if tree:
...@@ -97,6 +101,7 @@ def inject_utility_code_stage_factory(context): ...@@ -97,6 +101,7 @@ def inject_utility_code_stage_factory(context):
return module_node return module_node
return inject_utility_code_stage return inject_utility_code_stage
class UseUtilityCodeDefinitions(CythonTransform): class UseUtilityCodeDefinitions(CythonTransform):
# Temporary hack to use any utility code in nodes' "utility_code_definitions". # Temporary hack to use any utility code in nodes' "utility_code_definitions".
# This should be moved to the code generation phase of the relevant nodes once # This should be moved to the code generation phase of the relevant nodes once
...@@ -120,6 +125,7 @@ class UseUtilityCodeDefinitions(CythonTransform): ...@@ -120,6 +125,7 @@ class UseUtilityCodeDefinitions(CythonTransform):
self.process_entry(node.type_entry) self.process_entry(node.type_entry)
return node return node
# #
# Pipeline factories # Pipeline factories
# #
......
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