diff options
author | da-woods <dw-git@d-woods.co.uk> | 2021-07-19 08:41:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-19 09:41:34 +0200 |
commit | 9f78ed075f7371f931c7fa76b45589841c25668f (patch) | |
tree | 4f830787676cd6665ffa80b7695c45d83c2a3616 | |
parent | 3050637d434a45e775d94b46d96fce90f0b4e70b (diff) | |
download | cython-9f78ed075f7371f931c7fa76b45589841c25668f.tar.gz |
Rename GeneratorExpressionScope to ComprehensionScope (GH-4275)
Seems a remanant of an earlier implementation, but generator expressions *never* use "GeneratorExpressionScope" and in fact it's only used for comprehensions.
-rw-r--r-- | Cython/Compiler/ExprNodes.py | 2 | ||||
-rw-r--r-- | Cython/Compiler/Symtab.py | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index de50bca88..56e490490 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -8355,7 +8355,7 @@ class ScopedExprNode(ExprNode): if expr_scope is not None: self.expr_scope = expr_scope elif self.has_local_scope: - self.expr_scope = Symtab.GeneratorExpressionScope(outer_scope) + self.expr_scope = Symtab.ComprehensionScope(outer_scope) else: self.expr_scope = None diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 4b569a1d3..1aa65da33 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -346,7 +346,7 @@ class Scope(object): is_py_class_scope = 0 is_c_class_scope = 0 is_closure_scope = 0 - is_genexpr_scope = 0 + is_comprehension_scope = 0 is_passthrough = 0 is_cpp_class_scope = 0 is_property_scope = 0 @@ -1897,7 +1897,7 @@ class LocalScope(Scope): entry = Scope.lookup(self, name) if entry is not None: entry_scope = entry.scope - while entry_scope.is_genexpr_scope: + while entry_scope.is_comprehension_scope: entry_scope = entry_scope.outer_scope if entry_scope is not self and entry_scope.is_closure_scope: if hasattr(entry.scope, "scope_class"): @@ -1927,17 +1927,17 @@ class LocalScope(Scope): entry.cname = "%s->%s" % (Naming.cur_scope_cname, entry.cname) -class GeneratorExpressionScope(Scope): - """Scope for generator expressions and comprehensions. As opposed - to generators, these can be easily inlined in some cases, so all +class ComprehensionScope(Scope): + """Scope for comprehensions (but not generator expressions, which use ClosureScope). + As opposed to generators, these can be easily inlined in some cases, so all we really need is a scope that holds the loop variable(s). """ - is_genexpr_scope = True + is_comprehension_scope = True def __init__(self, outer_scope): parent_scope = outer_scope # TODO: also ignore class scopes? - while parent_scope.is_genexpr_scope: + while parent_scope.is_comprehension_scope: parent_scope = parent_scope.parent_scope name = parent_scope.global_scope().next_id(Naming.genexpr_id_ref) Scope.__init__(self, name, outer_scope, parent_scope) @@ -1946,7 +1946,7 @@ class GeneratorExpressionScope(Scope): # Class/ExtType scopes are filled at class creation time, i.e. from the # module init function or surrounding function. - while outer_scope.is_genexpr_scope or outer_scope.is_c_class_scope or outer_scope.is_py_class_scope: + while outer_scope.is_comprehension_scope or outer_scope.is_c_class_scope or outer_scope.is_py_class_scope: outer_scope = outer_scope.outer_scope self.var_entries = outer_scope.var_entries # keep declarations outside outer_scope.subscopes.add(self) |