Commit d87d0194 authored by gsamain's avatar gsamain Committed by Xavier Thompson

Change lock checking method semantic: they now check if themselves are locked,...

Change lock checking method semantic: they now check if themselves are locked, not if their parent object are locked
parent 7ce3caa5
...@@ -724,9 +724,25 @@ class ExprNode(Node): ...@@ -724,9 +724,25 @@ class ExprNode(Node):
error(self.pos, "Address is not constant") error(self.pos, "Address is not constant")
def is_rhs_locked(self, env): def is_rhs_locked(self, env):
if hasattr(self, 'entry') and self.entry.type.is_cyp_class and self.entry.is_variable\
and not (self.entry.is_rlocked or self.entry.is_wlocked):
if self.entry.type.lock_mode == "autolock":
print "Request read lock autolock here"
self.entry.is_rlocked = True
self.entry.locking_node.needs_rlock = True
elif self.entry.type.lock_mode == "checklock":
return False
return True return True
def is_lhs_locked(self, env): def is_lhs_locked(self, env):
if hasattr(self, 'entry') and self.entry.type.is_cyp_class and self.entry.is_variable\
and not self.entry.is_wlocked:
if self.entry.type.lock_mode == "autolock":
print "Request write lock autolock here", self.entry.name
self.entry.is_wlocked = True
self.entry.locking_node.needs_wlock = True
elif self.entry.type.lock_mode == "checklock":
return False
return True return True
def check_rhs_locked(self, env): def check_rhs_locked(self, env):
...@@ -7367,27 +7383,17 @@ class AttributeNode(ExprNode): ...@@ -7367,27 +7383,17 @@ class AttributeNode(ExprNode):
def is_rhs_locked(self, env): def is_rhs_locked(self, env):
obj = self.obj obj = self.obj
if hasattr(obj, 'entry') and obj.entry.type.is_cyp_class and (obj.entry.is_variable or obj.entry.is_cfunction)\
and not (obj.entry.is_rlocked and (not self.entry.is_cfunction or self.entry.type.is_const_method) or obj.entry.is_wlocked):
if obj.entry.type.lock_mode == "autolock":
print "Request read lock autolock here"
self.obj.entry.is_rlocked = True
self.obj.entry.locking_node.needs_rlock = True
elif obj.entry.type.lock_mode == "checklock":
return False
return True
def is_lhs_locked(self, env): # The subexpr mechanism will here issue check_rhs_lock on self.obj
obj = self.obj # BUT if we are calling a non-const method, the object can be modified.
if self.is_lvalue() and hasattr(obj, 'entry') and obj.entry.type.is_cyp_class and not obj.entry.is_wlocked: # So here we're calling directly check_lhs_lock if this is needed.
if obj.entry.type.lock_mode == "autolock": if self.entry.is_cfunction and self.entry.type.is_const_method:
print "Request write lock autolock here" print self.entry.name, "const method in rhs check detected !"
self.needs_autolock = True if self.entry.is_cfunction and not self.entry.type.is_const_method:
self.obj.entry.is_wlocked = True print self.entry.name, "is considered a non const method"
self.obj.entry.locking_node.needs_wlock = True self.obj.check_lhs_locked(env)
elif obj.entry.type.lock_mode == "checklock":
return False return ExprNode.is_rhs_locked(self, env)
return True
def is_cimported_module_without_shadow(self, env): def is_cimported_module_without_shadow(self, env):
return self.obj.is_cimported_module_without_shadow(env) return self.obj.is_cimported_module_without_shadow(env)
......
...@@ -5803,8 +5803,10 @@ class SingleAssignmentNode(AssignmentNode): ...@@ -5803,8 +5803,10 @@ class SingleAssignmentNode(AssignmentNode):
self.lhs.entry.locking_node = self self.lhs.entry.locking_node = self
self.lhs.entry.is_wlocked = False self.lhs.entry.is_wlocked = False
self.lhs.entry.is_rlocked = False self.lhs.entry.is_rlocked = False
self.rhs.check_rhs_locked(env) if self.rhs.is_attribute:
self.lhs.check_lhs_locked(env) self.rhs.obj.check_rhs_locked(env)
if self.lhs.is_attribute:
self.lhs.obj.check_lhs_locked(env)
unrolled_assignment = self.unroll_lhs(env) unrolled_assignment = self.unroll_lhs(env)
if unrolled_assignment: if unrolled_assignment:
return unrolled_assignment return unrolled_assignment
......
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