Commit b3429679 authored by Stefan Behnel's avatar Stefan Behnel

fix bug where multiple utility code dependencies could be ignored due to loop...

fix bug where multiple utility code dependencies could be ignored due to loop variable reassignment (only last one wins)
parent 2c7cd1b4
...@@ -137,26 +137,22 @@ class CythonUtilityCode(Code.UtilityCodeBase): ...@@ -137,26 +137,22 @@ class CythonUtilityCode(Code.UtilityCodeBase):
pipeline = Pipeline.insert_into_pipeline(pipeline, transform, pipeline = Pipeline.insert_into_pipeline(pipeline, transform,
before=before) before=before)
if self.from_scope: def merge_scope(scope):
def scope_transform(module_node): def merge_scope_transform(module_node):
module_node.scope.merge_in(self.from_scope) module_node.scope.merge_in(scope)
return module_node return module_node
return merge_scope_transform
transform = ParseTreeTransforms.AnalyseDeclarationsTransform if self.from_scope:
pipeline = Pipeline.insert_into_pipeline(pipeline, scope_transform, pipeline = Pipeline.insert_into_pipeline(
before=transform) pipeline, merge_scope(self.from_scope),
before=ParseTreeTransforms.AnalyseDeclarationsTransform)
for dep in self.requires: for dep in self.requires:
if (isinstance(dep, CythonUtilityCode) if isinstance(dep, CythonUtilityCode) and hasattr(dep, 'tree') and not cython_scope:
and hasattr(dep, 'tree') pipeline = Pipeline.insert_into_pipeline(
and not cython_scope): pipeline, merge_scope(dep.tree.scope),
def scope_transform(module_node): before=ParseTreeTransforms.AnalyseDeclarationsTransform)
module_node.scope.merge_in(dep.tree.scope)
return module_node
transform = ParseTreeTransforms.AnalyseDeclarationsTransform
pipeline = Pipeline.insert_into_pipeline(pipeline, scope_transform,
before=transform)
if self.outer_module_scope: if self.outer_module_scope:
# inject outer module between utility code module and builtin module # inject outer module between utility code module and builtin module
...@@ -164,9 +160,9 @@ class CythonUtilityCode(Code.UtilityCodeBase): ...@@ -164,9 +160,9 @@ class CythonUtilityCode(Code.UtilityCodeBase):
module_node.scope.outer_scope = self.outer_module_scope module_node.scope.outer_scope = self.outer_module_scope
return module_node return module_node
transform = ParseTreeTransforms.AnalyseDeclarationsTransform pipeline = Pipeline.insert_into_pipeline(
pipeline = Pipeline.insert_into_pipeline(pipeline, scope_transform, pipeline, scope_transform,
before=transform) before=ParseTreeTransforms.AnalyseDeclarationsTransform)
(err, tree) = Pipeline.run_pipeline(pipeline, tree, printtree=False) (err, tree) = Pipeline.run_pipeline(pipeline, tree, printtree=False)
assert not err, err assert not err, err
......
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