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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
a66ffc46
Commit
a66ffc46
authored
Nov 03, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor handling of new references
parent
8cfda3ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+11
-6
No files found.
Cython/Compiler/ExprNodes.py
View file @
a66ffc46
...
@@ -737,6 +737,11 @@ class ExprNode(Node):
...
@@ -737,6 +737,11 @@ class ExprNode(Node):
# a subnode.
# a subnode.
return
self
.
is_temp
return
self
.
is_temp
def
result_is_new_reference
(
self
):
# Return true if the result is a new reference that is
# already incref-ed and will need to be decref-ed later.
return
self
.
result_in_temp
()
def
target_code
(
self
):
def
target_code
(
self
):
# Return code fragment for use as LHS of a C assignment.
# Return code fragment for use as LHS of a C assignment.
return
self
.
calculate_result_code
()
return
self
.
calculate_result_code
()
...
@@ -786,7 +791,7 @@ class ExprNode(Node):
...
@@ -786,7 +791,7 @@ class ExprNode(Node):
Make sure we own a reference to result.
Make sure we own a reference to result.
If the result is in a temp, it is already a new reference.
If the result is in a temp, it is already a new reference.
"""
"""
if
not
self
.
result_i
n_temp
():
if
not
self
.
result_i
s_new_reference
():
# FIXME: is this verification really necessary ?
# FIXME: is this verification really necessary ?
if
self
.
type
.
is_cyp_class
and
"NULL"
in
self
.
result
():
if
self
.
type
.
is_cyp_class
and
"NULL"
in
self
.
result
():
pass
pass
...
@@ -798,7 +803,7 @@ class ExprNode(Node):
...
@@ -798,7 +803,7 @@ class ExprNode(Node):
Make sure we own the reference to this memoryview slice.
Make sure we own the reference to this memoryview slice.
"""
"""
# TODO ideally this would be shared with "make_owned_reference"
# TODO ideally this would be shared with "make_owned_reference"
if
not
self
.
result_i
n_temp
():
if
not
self
.
result_i
s_new_reference
():
code
.
put_incref_memoryviewslice
(
self
.
result
(),
self
.
type
,
code
.
put_incref_memoryviewslice
(
self
.
result
(),
self
.
type
,
have_gil
=
not
self
.
in_nogil_context
)
have_gil
=
not
self
.
in_nogil_context
)
...
@@ -4247,13 +4252,13 @@ class IndexNode(_IndexingBaseNode):
...
@@ -4247,13 +4252,13 @@ class IndexNode(_IndexingBaseNode):
temp
.
use_managed_ref
=
False
temp
.
use_managed_ref
=
False
return
temp
return
temp
def
make_owned_reference
(
self
,
code
):
def
result_is_new_reference
(
self
):
if
self
.
type
.
is_cyp_class
and
not
(
self
.
base
.
type
.
is_array
or
self
.
base
.
type
.
is_ptr
):
if
self
.
type
.
is_cyp_class
and
not
(
self
.
base
.
type
.
is_array
or
self
.
base
.
type
.
is_ptr
):
# This is already a new reference
# This is already a new reference
# either via cpp operator[]
# either via cpp operator[]
# or via cypclass __getitem__
# or via cypclass __getitem__
return
return
True
ExprNode
.
make_owned_reference
(
self
,
code
)
return
ExprNode
.
result_is_new_reference
(
self
)
gil_message
=
"Indexing Python object"
gil_message
=
"Indexing Python object"
...
@@ -8035,7 +8040,7 @@ class SequenceNode(ExprNode):
...
@@ -8035,7 +8040,7 @@ class SequenceNode(ExprNode):
for
i
in
range
(
arg_count
):
for
i
in
range
(
arg_count
):
arg
=
self
.
args
[
i
]
arg
=
self
.
args
[
i
]
if
c_mult
or
not
arg
.
result_i
n_temp
():
if
c_mult
or
not
arg
.
result_i
s_new_reference
():
code
.
put_incref
(
arg
.
result
(),
arg
.
ctype
())
code
.
put_incref
(
arg
.
result
(),
arg
.
ctype
())
arg
.
generate_giveref
(
code
)
arg
.
generate_giveref
(
code
)
code
.
putln
(
"%s(%s, %s, %s);"
%
(
code
.
putln
(
"%s(%s, %s, %s);"
%
(
...
...
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