This is so mutating inplace operations can be detected safely.
-z, --pre-import <module> If specified, assume undeclared names in this
module. Emulates the behavior of putting
"from <module> import *" at the top of the file.
+ --incref_local_binop Force local an extra incref on local variables before
+ performing any binary operations.
"""
#The following experimental options are supported only on MacOSX:
# -C, --compile Compile generated .c file to .o file
Options.embed_pos_in_docstring = 1
elif option in ("-z", "--pre-import"):
Options.pre_import = pop_arg()
+ elif option == "--incref_local_binop":
+ Options.incref_local_binop = 1
else:
bad_usage()
else:
self.coerce_operands_to_pyobjects(env)
self.type = py_object_type
self.is_temp = 1
+ if Options.incref_local_binop and self.operand1.type.is_pyobject:
+ self.operand1 = self.operand1.coerce_to_temp(env)
else:
self.analyse_c_operation(env)
self.dup = self.create_dup_node(env) # re-assigns lhs to a shallow copy
self.rhs.analyse_types(env)
self.lhs.analyse_target_types(env)
+ if Options.incref_local_binop and self.dup.type.is_pyobject:
+ self.dup = self.dup.coerce_to_temp(env)
def allocate_rhs_temps(self, env):
import ExprNodes
gcc_branch_hints = 1
pre_import = None
+
+# This is a SAGE-specific option that will
+# cause Cython to incref local variables before
+# performing a binary operation on them, for
+# safe detection of inplace operators.
+incref_local_binop = 0
+
# getter_cname string C func for getting property
# setter_cname string C func for setting or deleting property
# is_self_arg boolean Is the "self" arg of an exttype method
+ # is_arg boolean Is the arg of a method
# is_readonly boolean Can't be assigned to
# func_cname string C func implementing Python func
# pos position Source position where declared
getter_cname = None
setter_cname = None
is_self_arg = 0
+ is_arg = 0
is_declared_generic = 0
is_readonly = 0
func_cname = None
entry.is_variable = 1
if type.is_pyobject:
entry.init = "0"
+ entry.is_arg = 1
#entry.borrowed = 1 # Not using borrowed arg refs for now
self.arg_entries.append(entry)
return entry