Commit 108d4195 authored by gsamain's avatar gsamain Committed by Xavier Thompson

Introduce some lock getters

parent 251d92e4
...@@ -733,6 +733,19 @@ class ExprNode(Node): ...@@ -733,6 +733,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"
...@@ -6128,6 +6141,12 @@ class SimpleCallNode(CallNode): ...@@ -6128,6 +6141,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()
...@@ -7612,9 +7631,9 @@ class AttributeNode(ExprNode): ...@@ -7612,9 +7631,9 @@ class AttributeNode(ExprNode):
rhs.move_result_rhs_as(self.ctype()))) rhs.move_result_rhs_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)
...@@ -13845,11 +13864,16 @@ class CoerceToTempNode(CoercionNode): ...@@ -13845,11 +13864,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