Commit 2e3b4b60 authored by gsamain's avatar gsamain

Introduce some lock getters

parent fc3506fd
...@@ -703,6 +703,19 @@ class ExprNode(Node): ...@@ -703,6 +703,19 @@ class ExprNode(Node):
self.tracked_state.is_wlocked = True self.tracked_state.is_wlocked = True
self.tracked_state.needs_wlock = True self.tracked_state.needs_wlock = True
def needs_rlock(self):
if self.tracked_state is None:
return False
return self.tracked_state.needs_rlock
def needs_wlock(self):
if self.tracked_state is None:
return False
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"
...@@ -6034,6 +6047,12 @@ class SimpleCallNode(CallNode): ...@@ -6034,6 +6047,12 @@ class SimpleCallNode(CallNode):
def set_autowlock(self, env): def set_autowlock(self, env):
self.wlocked = True self.wlocked = True
def needs_rlock(self):
return self.rlocked
def needs_wlock(self):
return self.wlocked
def calculate_result_code(self): def calculate_result_code(self):
return self.c_call_code() return self.c_call_code()
...@@ -7512,9 +7531,9 @@ class AttributeNode(ExprNode): ...@@ -7512,9 +7531,9 @@ class AttributeNode(ExprNode):
rhs.result_as(self.ctype()))) rhs.result_as(self.ctype())))
#rhs.result())) #rhs.result()))
if self.is_autolock(): if self.is_autolock():
if tracked_state.needs_wlock: if self.needs_wlock():
code.putln("Cy_WLOCK(%s);" % select_code) code.putln("Cy_WLOCK(%s);" % select_code)
elif tracked_state.needs_rlock: elif self.needs_rlock():
code.putln("Cy_RLOCK(%s);" % select_code) code.putln("Cy_RLOCK(%s);" % select_code)
rhs.generate_post_assignment_code(code) rhs.generate_post_assignment_code(code)
...@@ -13723,11 +13742,16 @@ class CoerceToTempNode(CoercionNode): ...@@ -13723,11 +13742,16 @@ class CoerceToTempNode(CoercionNode):
# The arg is always already analysed # The arg is always already analysed
return self return self
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
def ensure_lhs_locked(self, env, is_dereferenced = False): def ensure_lhs_locked(self, env, is_dereferenced = False):
self.arg.ensure_lhs_locked(env, is_dereferenced) self.arg.ensure_lhs_locked(env, is_dereferenced)
self.tracked_state = self.arg.tracked_state
def coerce_to_boolean(self, env): def coerce_to_boolean(self, env):
self.arg = self.arg.coerce_to_boolean(env) self.arg = self.arg.coerce_to_boolean(env)
......
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