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
fc0547e4
Commit
fc0547e4
authored
Apr 29, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow type expressions in comparisons
parent
ee914074
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
23 deletions
+16
-23
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+3
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+5
-19
tests/run/check_fused_types.pyx
tests/run/check_fused_types.pyx
+4
-4
tests/run/check_fused_types_pxd.pxd
tests/run/check_fused_types_pxd.pxd
+3
-0
No files found.
Cython/Compiler/Main.py
View file @
fc0547e4
...
...
@@ -141,7 +141,9 @@ class Context(object):
FlattenInListTransform
(),
WithTransform
(
self
),
DecoratorTransform
(
self
),
# PrintTree(),
AnalyseDeclarationsTransform
(
self
),
# PrintTree(),
AutoTestDictTransform
(
self
),
EmbedSignature
(
self
),
EarlyReplaceBuiltinCalls
(
self
),
## Necessary?
...
...
@@ -159,6 +161,7 @@ class Context(object):
DropRefcountingTransform
(),
FinalOptimizePhase
(
self
),
GilCheck
(),
# PrintTree(),
]
def
create_pyx_pipeline
(
self
,
options
,
result
,
py
=
False
):
...
...
Cython/Compiler/Nodes.py
View file @
fc0547e4
...
...
@@ -2055,6 +2055,7 @@ class FusedCFuncDefNode(StatListNode):
cname
=
self
.
node
.
type
.
get_specific_cname
(
cname
)
copied_node
.
entry
.
func_cname
=
copied_node
.
entry
.
cname
=
cname
# TransformBuiltinMethods(copied_node)
ParseTreeTransforms
.
ReplaceFusedTypeChecks
(
copied_node
.
local_scope
)(
copied_node
)
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
fc0547e4
...
...
@@ -1912,11 +1912,13 @@ class ReplaceFusedTypeChecks(VisitorTransform):
def
visit_IfClauseNode
(
self
,
node
):
cond
=
node
.
condition
if
isinstance
(
cond
,
ExprNodes
.
PrimaryCmpNode
):
type1
,
type2
=
self
.
get_types
(
cond
)
op
=
cond
.
operator
type1
=
cond
.
operand1
.
analyse_as_type
(
self
.
local_scope
)
type2
=
cond
.
operand2
.
analyse_as_type
(
self
.
local_scope
)
type1
=
self
.
specialize_type
(
type1
,
cond
.
operand1
.
pos
)
if
type1
and
type2
:
type1
=
self
.
specialize_type
(
type1
,
cond
.
operand1
.
pos
)
op
=
cond
.
operator
if
op
==
'is'
:
type2
=
self
.
specialize_type
(
type2
,
cond
.
operand1
.
pos
)
if
type1
.
same_as
(
type2
):
...
...
@@ -1942,22 +1944,6 @@ class ReplaceFusedTypeChecks(VisitorTransform):
return
node
def
get_types
(
self
,
node
):
if
node
.
operand1
.
is_name
and
node
.
operand2
.
is_name
:
return
self
.
get_type
(
node
.
operand1
),
self
.
get_type
(
node
.
operand2
)
return
None
,
None
def
get_type
(
self
,
node
):
type
=
PyrexTypes
.
parse_basic_type
(
node
.
name
)
if
not
type
:
# Don't use self.lookup_type() as it will specialize
entry
=
self
.
local_scope
.
lookup
(
node
.
name
)
if
entry
and
entry
.
is_type
:
type
=
entry
.
type
return
type
def
specialize_type
(
self
,
type
,
pos
):
try
:
return
type
.
specialize
(
self
.
local_scope
.
fused_to_specific
)
...
...
tests/run/check_fused_types.pyx
View file @
fc0547e4
cimport
cython
cimport
check_fused_types_pxd
ctypedef
char
*
string_t
ctypedef
cython
.
fused_type
(
int
,
long
,
float
,
string_t
)
fused_t
ctypedef
cython
.
fused_type
(
int
,
long
)
other_t
ctypedef
cython
.
fused_type
(
int
,
float
)
unresolved_t
cdef
func
(
fused_t
a
,
other_t
b
):
cdef
int
int_a
...
...
@@ -22,13 +22,13 @@ cdef func(fused_t a, other_t b):
print
'fused_t is string_t'
string_a
=
a
if
fused_t
in
unresolved_t
:
if
fused_t
in
check_fused_types_pxd
.
unresolved_t
:
print
'fused_t in unresolved_t'
if
int
in
unresolved_t
:
if
int
in
check_fused_types_pxd
.
unresolved_t
:
print
'int in unresolved_t'
if
string_t
in
unresolved_t
:
if
string_t
in
check_fused_types_pxd
.
unresolved_t
:
print
'string_t in unresolved_t'
...
...
tests/run/check_fused_types_pxd.pxd
0 → 100644
View file @
fc0547e4
cimport
cython
ctypedef
cython
.
fused_type
(
int
,
float
)
unresolved_t
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