aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Compiler/FlowControl.py
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/tools/cython/Cython/Compiler/FlowControl.py
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler/FlowControl.py')
-rw-r--r--contrib/tools/cython/Cython/Compiler/FlowControl.py74
1 files changed, 37 insertions, 37 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/FlowControl.py b/contrib/tools/cython/Cython/Compiler/FlowControl.py
index 7e8270b198..df04471f90 100644
--- a/contrib/tools/cython/Cython/Compiler/FlowControl.py
+++ b/contrib/tools/cython/Cython/Compiler/FlowControl.py
@@ -2,7 +2,7 @@ from __future__ import absolute_import
import cython
cython.declare(PyrexTypes=object, ExprNodes=object, Nodes=object,
- Builtin=object, InternalError=object, error=object, warning=object,
+ Builtin=object, InternalError=object, error=object, warning=object,
py_object_type=object, unspecified_type=object,
object_expr=object, fake_rhs_expr=object, TypedExprNode=object)
@@ -15,9 +15,9 @@ from . import PyrexTypes
from .Visitor import TreeVisitor, CythonTransform
from .Errors import error, warning, InternalError
-from .Optimize import ConstantFolding
+from .Optimize import ConstantFolding
+
-
class TypedExprNode(ExprNodes.ExprNode):
# Used for declaring assignments of a specified type without a known entry.
def __init__(self, type, may_be_none=None, pos=None):
@@ -256,7 +256,7 @@ class ControlFlow(object):
for entry in block.bounded:
block.i_kill |= self.assmts[entry].bit
- for assmts in self.assmts.values():
+ for assmts in self.assmts.values():
self.entry_point.i_gen |= assmts.bit
self.entry_point.i_output = self.entry_point.i_gen
@@ -486,11 +486,11 @@ class GV(object):
if annotate_defs:
for stat in block.stats:
if isinstance(stat, NameAssignment):
- label += '\n %s [%s %s]' % (
- stat.entry.name, 'deletion' if stat.is_deletion else 'definition', stat.pos[1])
+ label += '\n %s [%s %s]' % (
+ stat.entry.name, 'deletion' if stat.is_deletion else 'definition', stat.pos[1])
elif isinstance(stat, NameReference):
if stat.entry:
- label += '\n %s [reference %s]' % (stat.entry.name, stat.pos[1])
+ label += '\n %s [reference %s]' % (stat.entry.name, stat.pos[1])
if not label:
label = 'empty'
pid = ctx.nodeid(block)
@@ -505,16 +505,16 @@ class GV(object):
class MessageCollection(object):
"""Collect error/warnings messages first then sort"""
def __init__(self):
- self.messages = set()
+ self.messages = set()
def error(self, pos, message):
- self.messages.add((pos, True, message))
+ self.messages.add((pos, True, message))
def warning(self, pos, message):
- self.messages.add((pos, False, message))
+ self.messages.add((pos, False, message))
def report(self):
- for pos, is_error, message in sorted(self.messages):
+ for pos, is_error, message in sorted(self.messages):
if is_error:
error(pos, message)
else:
@@ -582,14 +582,14 @@ def check_definitions(flow, compiler_directives):
node.cf_maybe_null = False
# Find uninitialized references and cf-hints
- for node, entry in references.items():
+ for node, entry in references.items():
if Uninitialized in node.cf_state:
node.cf_maybe_null = True
if not entry.from_closure and len(node.cf_state) == 1:
node.cf_is_null = True
if (node.allow_null or entry.from_closure
- or entry.is_pyclass_attr or entry.type.is_error):
- pass # Can be uninitialized here
+ or entry.is_pyclass_attr or entry.type.is_error):
+ pass # Can be uninitialized here
elif node.cf_is_null:
if entry.error_on_uninitialized or (
Options.error_on_uninitialized and (
@@ -635,7 +635,7 @@ def check_definitions(flow, compiler_directives):
for entry in flow.entries:
if (not entry.cf_references
and not entry.is_pyclass_attr):
- if entry.name != '_' and not entry.name.startswith('unused'):
+ if entry.name != '_' and not entry.name.startswith('unused'):
# '_' is often used for unused variables, e.g. in loops
if entry.is_arg:
if warn_unused_arg:
@@ -675,7 +675,7 @@ class ControlFlowAnalysis(CythonTransform):
def visit_ModuleNode(self, node):
self.gv_ctx = GVContext()
- self.constant_folder = ConstantFolding()
+ self.constant_folder = ConstantFolding()
# Set of NameNode reductions
self.reductions = set()
@@ -778,13 +778,13 @@ class ControlFlowAnalysis(CythonTransform):
if entry is None: # TODO: This shouldn't happen...
return
self.flow.mark_assignment(lhs, rhs, entry)
- elif lhs.is_sequence_constructor:
- for i, arg in enumerate(lhs.args):
- if not rhs or arg.is_starred:
- item_node = None
- else:
- item_node = rhs.inferable_item_node(i)
- self.mark_assignment(arg, item_node)
+ elif lhs.is_sequence_constructor:
+ for i, arg in enumerate(lhs.args):
+ if not rhs or arg.is_starred:
+ item_node = None
+ else:
+ item_node = rhs.inferable_item_node(i)
+ self.mark_assignment(arg, item_node)
else:
self._visit(lhs)
@@ -832,7 +832,7 @@ class ControlFlowAnalysis(CythonTransform):
self.in_inplace_assignment = True
self.visitchildren(node)
self.in_inplace_assignment = False
- self.mark_assignment(node.lhs, self.constant_folder(node.create_binop_node()))
+ self.mark_assignment(node.lhs, self.constant_folder(node.create_binop_node()))
return node
def visit_DelStatNode(self, node):
@@ -843,8 +843,8 @@ class ControlFlowAnalysis(CythonTransform):
error(arg.pos,
"can not delete variable '%s' "
"referenced in nested scope" % entry.name)
- if not node.ignore_nonexisting:
- self._visit(arg) # mark reference
+ if not node.ignore_nonexisting:
+ self._visit(arg) # mark reference
self.flow.mark_deletion(arg, entry)
else:
self._visit(arg)
@@ -981,11 +981,11 @@ class ControlFlowAnalysis(CythonTransform):
for arg in sequence.args[:2]:
self.mark_assignment(target, arg)
if len(sequence.args) > 2:
- self.mark_assignment(target, self.constant_folder(
+ self.mark_assignment(target, self.constant_folder(
ExprNodes.binop_node(node.pos,
'+',
sequence.args[0],
- sequence.args[2])))
+ sequence.args[2])))
if not is_special:
# A for-loop basically translates to subsequent calls to
@@ -996,9 +996,9 @@ class ControlFlowAnalysis(CythonTransform):
self.mark_assignment(target, node.item)
- def visit_AsyncForStatNode(self, node):
- return self.visit_ForInStatNode(node)
-
+ def visit_AsyncForStatNode(self, node):
+ return self.visit_ForInStatNode(node)
+
def visit_ForInStatNode(self, node):
condition_block = self.flow.nextblock()
next_block = self.flow.newblock()
@@ -1010,9 +1010,9 @@ class ControlFlowAnalysis(CythonTransform):
if isinstance(node, Nodes.ForInStatNode):
self.mark_forloop_target(node)
- elif isinstance(node, Nodes.AsyncForStatNode):
- # not entirely correct, but good enough for now
- self.mark_assignment(node.target, node.item)
+ elif isinstance(node, Nodes.AsyncForStatNode):
+ # not entirely correct, but good enough for now
+ self.mark_assignment(node.target, node.item)
else: # Parallel
self.mark_assignment(node.target)
@@ -1090,8 +1090,8 @@ class ControlFlowAnalysis(CythonTransform):
self.flow.nextblock()
self.mark_assignment(node.target, node.bound1)
if node.step is not None:
- self.mark_assignment(node.target, self.constant_folder(
- ExprNodes.binop_node(node.pos, '+', node.bound1, node.step)))
+ self.mark_assignment(node.target, self.constant_folder(
+ ExprNodes.binop_node(node.pos, '+', node.bound1, node.step)))
# Body block
self.flow.nextblock()
self._visit(node.body)
@@ -1182,7 +1182,7 @@ class ControlFlowAnalysis(CythonTransform):
# Exception entry point
entry_point = self.flow.newblock()
self.flow.block = entry_point
- self._visit(node.finally_except_clause)
+ self._visit(node.finally_except_clause)
if self.flow.block and self.flow.exceptions:
self.flow.block.add_child(self.flow.exceptions[-1].entry_point)