Commit 6a6a8f45 authored by Stefan Behnel's avatar Stefan Behnel

Reduce global state in FlowControl.py to see if it reduces the chance of...

Reduce global state in FlowControl.py to see if it reduces the chance of reload problems (it's a compiled module which cannot be reloaded).
parent e969ef32
...@@ -107,6 +107,7 @@ cdef class ControlFlowAnalysis(CythonTransform): ...@@ -107,6 +107,7 @@ cdef class ControlFlowAnalysis(CythonTransform):
cdef list stack cdef list stack
cdef object env cdef object env
cdef ControlFlow flow cdef ControlFlow flow
cdef object object_expr
cdef bint in_inplace_assignment cdef bint in_inplace_assignment
cpdef mark_assignment(self, lhs, rhs=*) cpdef mark_assignment(self, lhs, rhs=*)
......
...@@ -5,14 +5,12 @@ from __future__ import absolute_import ...@@ -5,14 +5,12 @@ from __future__ import absolute_import
import cython import cython
cython.declare(PyrexTypes=object, ExprNodes=object, Nodes=object, 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, fake_rhs_expr=object, TypedExprNode=object)
object_expr=object, fake_rhs_expr=object, TypedExprNode=object)
from . import Builtin from . import Builtin
from . import ExprNodes from . import ExprNodes
from . import Nodes from . import Nodes
from . import Options from . import Options
from .PyrexTypes import py_object_type, unspecified_type
from . import PyrexTypes from . import PyrexTypes
from .Visitor import TreeVisitor, CythonTransform from .Visitor import TreeVisitor, CythonTransform
...@@ -30,9 +28,8 @@ class TypedExprNode(ExprNodes.ExprNode): ...@@ -30,9 +28,8 @@ class TypedExprNode(ExprNodes.ExprNode):
def may_be_none(self): def may_be_none(self):
return self._may_be_none != False return self._may_be_none != False
object_expr = TypedExprNode(py_object_type, may_be_none=True)
# Fake rhs to silence "unused variable" warning # Fake rhs to silence "unused variable" warning
fake_rhs_expr = TypedExprNode(unspecified_type) fake_rhs_expr = TypedExprNode(PyrexTypes.unspecified_type)
class ControlBlock(object): class ControlBlock(object):
...@@ -375,9 +372,9 @@ class NameDeletion(NameAssignment): ...@@ -375,9 +372,9 @@ class NameDeletion(NameAssignment):
def infer_type(self): def infer_type(self):
inferred_type = self.rhs.infer_type(self.entry.scope) inferred_type = self.rhs.infer_type(self.entry.scope)
if (not inferred_type.is_pyobject and if (not inferred_type.is_pyobject
inferred_type.can_coerce_to_pyobject(self.entry.scope)): and inferred_type.can_coerce_to_pyobject(self.entry.scope)):
return py_object_type return PyrexTypes.py_object_type
self.inferred_type = inferred_type self.inferred_type = inferred_type
return inferred_type return inferred_type
...@@ -687,6 +684,7 @@ class ControlFlowAnalysis(CythonTransform): ...@@ -687,6 +684,7 @@ class ControlFlowAnalysis(CythonTransform):
self.env = node.scope self.env = node.scope
self.stack = [] self.stack = []
self.flow = ControlFlow() self.flow = ControlFlow()
self.object_expr = TypedExprNode(PyrexTypes.py_object_type, may_be_none=True)
self.visitchildren(node) self.visitchildren(node)
check_definitions(self.flow, self.current_directives) check_definitions(self.flow, self.current_directives)
...@@ -771,7 +769,7 @@ class ControlFlowAnalysis(CythonTransform): ...@@ -771,7 +769,7 @@ class ControlFlowAnalysis(CythonTransform):
self.flow.nextblock() self.flow.nextblock()
if not rhs: if not rhs:
rhs = object_expr rhs = self.object_expr
if lhs.is_name: if lhs.is_name:
if lhs.entry is not None: if lhs.entry is not None:
entry = lhs.entry entry = lhs.entry
......
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