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
132bdceb
Commit
132bdceb
authored
Jan 19, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise some uses of TypecastNode into coercions
parent
e4004f16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-5
No files found.
Cython/Compiler/ExprNodes.py
View file @
132bdceb
...
@@ -8373,6 +8373,9 @@ class TypecastNode(ExprNode):
...
@@ -8373,6 +8373,9 @@ class TypecastNode(ExprNode):
"Cannot cast to a function type"
)
"Cannot cast to a function type"
)
self
.
type
=
PyrexTypes
.
error_type
self
.
type
=
PyrexTypes
.
error_type
self
.
operand
=
self
.
operand
.
analyse_types
(
env
)
self
.
operand
=
self
.
operand
.
analyse_types
(
env
)
if
self
.
type
is
PyrexTypes
.
c_bint_type
:
# short circuit this to a coercion
return
self
.
operand
.
coerce_to_boolean
(
env
)
to_py
=
self
.
type
.
is_pyobject
to_py
=
self
.
type
.
is_pyobject
from_py
=
self
.
operand
.
type
.
is_pyobject
from_py
=
self
.
operand
.
type
.
is_pyobject
if
from_py
and
not
to_py
and
self
.
operand
.
is_ephemeral
():
if
from_py
and
not
to_py
and
self
.
operand
.
is_ephemeral
():
...
@@ -8380,10 +8383,7 @@ class TypecastNode(ExprNode):
...
@@ -8380,10 +8383,7 @@ class TypecastNode(ExprNode):
error
(
self
.
pos
,
"Casting temporary Python object to non-numeric non-Python type"
)
error
(
self
.
pos
,
"Casting temporary Python object to non-numeric non-Python type"
)
if
to_py
and
not
from_py
:
if
to_py
and
not
from_py
:
if
self
.
type
is
bytes_type
and
self
.
operand
.
type
.
is_int
:
if
self
.
type
is
bytes_type
and
self
.
operand
.
type
.
is_int
:
# FIXME: the type cast node isn't needed in this case
return
CoerceIntToBytesNode
(
self
.
operand
,
env
)
# and can be dropped once analyse_types() can return a
# different node
self
.
operand
=
CoerceIntToBytesNode
(
self
.
operand
,
env
)
elif
self
.
operand
.
type
.
can_coerce_to_pyobject
(
env
):
elif
self
.
operand
.
type
.
can_coerce_to_pyobject
(
env
):
self
.
result_ctype
=
py_object_type
self
.
result_ctype
=
py_object_type
base_type
=
self
.
base_type
.
analyse
(
env
)
base_type
=
self
.
base_type
.
analyse
(
env
)
...
@@ -8405,7 +8405,7 @@ class TypecastNode(ExprNode):
...
@@ -8405,7 +8405,7 @@ class TypecastNode(ExprNode):
else
:
else
:
warning
(
self
.
pos
,
"No conversion from %s to %s, python object pointer used."
%
(
self
.
type
,
self
.
operand
.
type
))
warning
(
self
.
pos
,
"No conversion from %s to %s, python object pointer used."
%
(
self
.
type
,
self
.
operand
.
type
))
elif
from_py
and
to_py
:
elif
from_py
and
to_py
:
if
self
.
typecheck
and
self
.
type
.
is_pyobject
:
if
self
.
typecheck
:
self
.
operand
=
PyTypeTestNode
(
self
.
operand
,
self
.
type
,
env
,
notnone
=
True
)
self
.
operand
=
PyTypeTestNode
(
self
.
operand
,
self
.
type
,
env
,
notnone
=
True
)
elif
isinstance
(
self
.
operand
,
SliceIndexNode
):
elif
isinstance
(
self
.
operand
,
SliceIndexNode
):
# This cast can influence the created type of string slices.
# This cast can influence the created type of string slices.
...
...
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