Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
c1609002
Commit
c1609002
authored
Sep 05, 2007
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
incref_local_binop option for SAGE
This is so mutating inplace operations can be detected safely.
parent
36549f78
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
0 deletions
+18
-0
Cython/Compiler/CmdLine.py
Cython/Compiler/CmdLine.py
+4
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-0
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+7
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+3
-0
No files found.
Cython/Compiler/CmdLine.py
View file @
c1609002
...
...
@@ -22,6 +22,8 @@ Options:
-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
...
...
@@ -76,6 +78,8 @@ def parse_command_line(args):
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
:
...
...
Cython/Compiler/ExprNodes.py
View file @
c1609002
...
...
@@ -2430,6 +2430,8 @@ class BinopNode(ExprNode):
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
)
...
...
Cython/Compiler/Nodes.py
View file @
c1609002
...
...
@@ -1624,6 +1624,8 @@ class InPlaceAssignmentNode(AssignmentNode):
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
...
...
Cython/Compiler/Options.py
View file @
c1609002
...
...
@@ -9,3 +9,10 @@ embed_pos_in_docstring = 0
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
Cython/Compiler/Symtab.py
View file @
c1609002
...
...
@@ -40,6 +40,7 @@ class Entry:
# 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
...
...
@@ -81,6 +82,7 @@ class Entry:
getter_cname
=
None
setter_cname
=
None
is_self_arg
=
0
is_arg
=
0
is_declared_generic
=
0
is_readonly
=
0
func_cname
=
None
...
...
@@ -910,6 +912,7 @@ class LocalScope(Scope):
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment