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
Boxiang Sun
cython
Commits
3beaa8e5
Commit
3beaa8e5
authored
Jul 13, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow GenericBoolBinopNode to coerce back to BoolBinopNode for boolean results
parent
c3346c6e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+9
-4
No files found.
Cython/Compiler/ExprNodes.py
View file @
3beaa8e5
...
...
@@ -9669,14 +9669,15 @@ class BoolBinopNode(ExprNode):
is_temp
=
self
.
is_temp
)
def
coerce_to
(
self
,
dst_type
,
env
):
if
not
dst_type
.
is_pyobject
:
if
self
.
operand1
.
is_ephemeral
()
or
self
.
operand2
.
is_ephemeral
():
error
(
self
.
pos
,
"Unsafe C derivative of temporary Python reference used in and/or expression"
)
if
dst_type
is
PyrexTypes
.
c_bint_type
:
return
self
.
coerce_to_boolean
(
env
)
return
GenericBoolBinopNode
.
from_node
(
self
,
env
=
env
,
type
=
dst_type
,
operator
=
self
.
operator
,
operand1
=
self
.
operand1
,
operand2
=
self
.
operand2
)
def
is_ephemeral
(
self
):
return
self
.
operand1
.
is_ephemeral
()
or
self
.
operand2
.
is_ephemeral
()
def
analyse_types
(
self
,
env
):
# Note: we do not do any coercion here as we most likely do not know the final type anyway.
# We even accept to set self.type to ErrorType if both operands do not have a spanning type.
...
...
@@ -9757,6 +9758,10 @@ class BoolBinopResultNode(ExprNode):
arg
.
pos
,
arg
=
arg
,
type
=
result_type
,
value
=
CloneNode
(
arg
).
coerce_to
(
result_type
,
env
).
coerce_to_simple
(
env
))
def
coerce_to_boolean
(
self
,
env
):
# coercing to simple boolean case after being instantiated => replace by simple coerced result
return
self
.
arg
.
arg
.
coerce_to_boolean
(
env
)
def
generate_operand_test
(
self
,
code
):
# Generate code to test the truth of the first operand.
if
self
.
arg
.
type
.
is_pyobject
:
...
...
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