Commit 09802d7a authored by gsamain's avatar gsamain Committed by Xavier Thompson

Clearer tracked state management (was_locked removal)

parent a7b9dcd8
...@@ -321,7 +321,6 @@ class ExprNode(Node): ...@@ -321,7 +321,6 @@ class ExprNode(Node):
result_is_used = True result_is_used = True
is_numpy_attribute = False is_numpy_attribute = False
tracked_state = None tracked_state = None
was_locked = False
# The Analyse Expressions phase for expressions is split # The Analyse Expressions phase for expressions is split
# into two sub-phases: # into two sub-phases:
...@@ -726,12 +725,10 @@ class ExprNode(Node): ...@@ -726,12 +725,10 @@ class ExprNode(Node):
error(self.pos, "Address is not constant") error(self.pos, "Address is not constant")
def set_autorlock(self, env): def set_autorlock(self, env):
self.tracked_state.was_locked = True
self.tracked_state.is_rlocked = True self.tracked_state.is_rlocked = True
self.tracked_state.needs_rlock = True self.tracked_state.needs_rlock = True
def set_autowlock(self, env): def set_autowlock(self, env):
self.tracked_state.was_locked = True
self.tracked_state.is_wlocked = True self.tracked_state.is_wlocked = True
self.tracked_state.needs_wlock = True self.tracked_state.needs_wlock = True
...@@ -745,9 +742,6 @@ class ExprNode(Node): ...@@ -745,9 +742,6 @@ class ExprNode(Node):
return False return False
return self.tracked_state.needs_wlock return self.tracked_state.needs_wlock
def get_was_locked(self):
return self.was_locked
def is_autolock(self): def is_autolock(self):
return self.type.is_cyp_class and self.type.lock_mode == "autolock" return self.type.is_cyp_class and self.type.lock_mode == "autolock"
...@@ -762,8 +756,6 @@ class ExprNode(Node): ...@@ -762,8 +756,6 @@ class ExprNode(Node):
self.tracked_state = env.declare_tracked(self.entry) self.tracked_state = env.declare_tracked(self.entry)
if self.is_autolock() and self.entry.is_variable: if self.is_autolock() and self.entry.is_variable:
env.declare_autolocked(self) env.declare_autolocked(self)
self.was_locked = self.tracked_state.was_locked
self.tracked_state.was_locked = True
def is_rhs_locked(self, env): def is_rhs_locked(self, env):
if not hasattr(self, 'entry') or not self.entry.type.is_cyp_class: if not hasattr(self, 'entry') or not self.entry.type.is_cyp_class:
...@@ -13912,9 +13904,6 @@ class CoerceToTempNode(CoercionNode): ...@@ -13912,9 +13904,6 @@ class CoerceToTempNode(CoercionNode):
def may_be_none(self): def may_be_none(self):
return self.arg.may_be_none() return self.arg.may_be_none()
def get_was_locked(self):
return self.arg.get_was_locked()
def ensure_rhs_locked(self, env, is_dereferenced = False): def ensure_rhs_locked(self, env, is_dereferenced = False):
self.arg.ensure_rhs_locked(env, is_dereferenced) self.arg.ensure_rhs_locked(env, is_dereferenced)
self.tracked_state = self.arg.tracked_state self.tracked_state = self.arg.tracked_state
......
...@@ -2071,7 +2071,7 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -2071,7 +2071,7 @@ class FuncDefNode(StatNode, BlockNode):
code.funcstate.gil_owned = False code.funcstate.gil_owned = False
for node in lenv.autolocked_nodes: for node in lenv.autolocked_nodes:
if node.entry.is_variable and not node.entry.is_local and (node.tracked_state.needs_wlock or node.tracked_state.needs_rlock): if node.entry.is_variable and not node.entry.is_local and (node.needs_wlock() or node.needs_rlock()):
node_result = node.result() node_result = node.result()
code.putln("if (%s != NULL)" % node_result) code.putln("if (%s != NULL)" % node_result)
if node.needs_wlock(): if node.needs_wlock():
...@@ -2248,7 +2248,7 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -2248,7 +2248,7 @@ class FuncDefNode(StatNode, BlockNode):
# which leads to a dangling lock on the previous reference # which leads to a dangling lock on the previous reference
# (and attempt to unlock a non-locked ref). # (and attempt to unlock a non-locked ref).
if not node.get_was_locked() and (node.tracked_state.needs_wlock or node.tracked_state.needs_rlock): if node.needs_wlock() or node.needs_rlock():
code.putln("Cy_UNLOCK(%s);" % node.result()) code.putln("Cy_UNLOCK(%s);" % node.result())
for entry in lenv.var_entries: for entry in lenv.var_entries:
......
...@@ -162,7 +162,6 @@ class Entry(object): ...@@ -162,7 +162,6 @@ class Entry(object):
# is_rlocked boolean Is locked with a read lock (used for cypclass) # is_rlocked boolean Is locked with a read lock (used for cypclass)
# needs_rlock boolean The entry needs a read lock (used in autolock mode) # needs_rlock boolean The entry needs a read lock (used in autolock mode)
# needs_wlock boolean The entry needs a write lock (used in autolock mode) # needs_wlock boolean The entry needs a write lock (used in autolock mode)
# was_locked boolean Indicates to nodes falling through that the first lock already took place
# TODO: utility_code and utility_code_definition serves the same purpose... # TODO: utility_code and utility_code_definition serves the same purpose...
...@@ -238,7 +237,6 @@ class Entry(object): ...@@ -238,7 +237,6 @@ class Entry(object):
is_rlocked = False is_rlocked = False
needs_rlock = False needs_rlock = False
needs_wlock = False needs_wlock = False
was_locked = False
def __init__(self, name, cname, type, pos = None, init = None): def __init__(self, name, cname, type, pos = None, init = None):
self.name = name self.name = name
...@@ -321,7 +319,6 @@ class TrackedLockedEntry: ...@@ -321,7 +319,6 @@ class TrackedLockedEntry:
self.is_rlocked = False self.is_rlocked = False
self.needs_wlock = False self.needs_wlock = False
self.needs_rlock = False self.needs_rlock = False
self.was_locked = False
class Scope(object): class Scope(object):
# name string Unqualified name # name string Unqualified name
......
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