else:
self.not_implemented("infer_type")
+ def nonlocally_immutable(self):
+ # Returns whether this variable is a safe reference, i.e.
+ # can't be modified as part of globals or closures.
+ return self.is_temp
+
# --------------- Type Analysis ------------------
def analyse_as_module(self, env):
def is_simple(self):
return 1
+ def nonlocally_immutable(self):
+ return 1
+
def may_be_none(self):
return False
# If it's not a C variable, it'll be in a temp.
return 1
+ def nonlocally_immutable(self):
+ entry = self.entry
+ return entry and (entry.is_local or entry.is_arg) and not entry.in_closure
+
def calculate_target_results(self, env):
pass
if i == 0 and self.self is not None:
# a method's cloned "self" argument is ok
pass
- elif arg.is_name and arg.entry and arg.entry.is_local and not arg.entry.in_closure:
+ elif arg.nonlocally_immutable():
# plain local variables are ok
pass
else:
# either temp or constant => always simple
return True
+ def nonlocally_immutable(self):
+ # either temp or constant => always safe
+ return True
+
def calculate_result_code(self):
if len(self.args) > 0:
return self.result_code
# either temp or a C cast => no side effects
return True
+ def nonlocally_immutable(self):
+ return self.operand.nonlocally_immutable()
+
def nogil_check(self, env):
if self.type and self.type.is_pyobject and self.is_temp:
self.gil_error()