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
63492533
Commit
63492533
authored
Nov 05, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better fused types error detection, specialized fused C++ templates
parent
824ec8d6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
9 deletions
+48
-9
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+22
-0
Cython/Compiler/Pipeline.py
Cython/Compiler/Pipeline.py
+2
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+16
-7
tests/errors/fused_types.pyx
tests/errors/fused_types.pyx
+3
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
63492533
...
...
@@ -614,7 +614,11 @@ class ExprNode(Node):
src
.
entry
.
used
=
True
return
self
if
src_type
.
is_fused
:
error
(
self
.
pos
,
"Type is not specific"
)
else
:
error
(
self
.
pos
,
"Cannot coerce to a type that is not specialized"
)
self
.
type
=
error_type
return
self
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
63492533
...
...
@@ -1726,6 +1726,28 @@ class AnalyseExpressionsTransform(CythonTransform):
return
node
class
FindInvalidUseOfFusedTypes
(
CythonTransform
):
def
visit_FuncDefNode
(
self
,
node
):
# Errors related to use in functions with fused args will already
# have been detected
if
not
node
.
has_fused_arguments
:
if
not
node
.
is_generator_body
and
node
.
return_type
.
is_fused
:
error
(
node
.
pos
,
"Return type is not specified as argument type"
)
else
:
self
.
visitchildren
(
node
)
return
node
def
visit_ExprNode
(
self
,
node
):
if
node
.
type
and
node
.
type
.
is_fused
:
error
(
node
.
pos
,
"Invalid use of fused types, type cannot be specialized"
)
else
:
self
.
visitchildren
(
node
)
return
node
class
ExpandInplaceOperators
(
EnvTransform
):
def
visit_InPlaceAssignmentNode
(
self
,
node
):
...
...
Cython/Compiler/Pipeline.py
View file @
63492533
...
...
@@ -125,7 +125,7 @@ def create_pipeline(context, mode, exclude_classes=()):
from
Visitor
import
PrintTree
from
ParseTreeTransforms
import
WithTransform
,
NormalizeTree
,
PostParse
,
PxdPostParse
from
ParseTreeTransforms
import
ForwardDeclareTypes
,
AnalyseDeclarationsTransform
from
ParseTreeTransforms
import
AnalyseExpressionsTransform
from
ParseTreeTransforms
import
AnalyseExpressionsTransform
,
FindInvalidUseOfFusedTypes
from
ParseTreeTransforms
import
CreateClosureClasses
,
MarkClosureVisitor
,
DecoratorTransform
from
ParseTreeTransforms
import
InterpretCompilerDirectives
,
TransformBuiltinMethods
from
ParseTreeTransforms
import
ExpandInplaceOperators
,
ParallelRangeTransform
...
...
@@ -187,6 +187,7 @@ def create_pipeline(context, mode, exclude_classes=()):
IntroduceBufferAuxiliaryVars
(
context
),
_check_c_declarations
,
AnalyseExpressionsTransform
(
context
),
FindInvalidUseOfFusedTypes
(
context
),
CreateClosureClasses
(
context
),
## After all lookups and type inference
ExpandInplaceOperators
(
context
),
OptimizeBuiltinCalls
(
context
),
## Necessary?
...
...
Cython/Compiler/PyrexTypes.py
View file @
63492533
...
...
@@ -50,7 +50,7 @@ class BaseType(object):
for
attr
in
subtypes
:
list_or_subtype
=
getattr
(
self
,
attr
)
if
list_or_subtype
:
if
isinstance
(
list_or_subtype
,
BaseType
):
list_or_subtype
.
get_fused_types
(
result
,
seen
)
else
:
...
...
@@ -61,7 +61,14 @@ class BaseType(object):
return
None
is_fused
=
property
(
get_fused_types
,
doc
=
"Whether this type or any of its "
def
_get_fused_types
(
self
):
"""
Add this indirection for the is_fused property to allow overriding
get_fused_types in subclasses.
"""
return
self
.
get_fused_types
()
is_fused
=
property
(
_get_fused_types
,
doc
=
"Whether this type or any of its "
"subtypes is a fused type"
)
def
__lt__
(
self
,
other
):
...
...
@@ -2864,6 +2871,8 @@ class CppClassType(CType):
exception_check
=
True
namespace
=
None
subtypes
=
[
'templates'
]
def
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
=
None
,
template_type
=
None
):
self
.
name
=
name
self
.
cname
=
cname
...
...
tests/errors/fused_types.pyx
View file @
63492533
...
...
@@ -57,10 +57,13 @@ _ERRORS = u"""
fused_types.pyx:10:15: fused_type does not take keyword arguments
fused_types.pyx:15:38: Type specified multiple times
fused_types.pyx:17:33: Cannot fuse a fused type
fused_types.pyx:26:4: Invalid use of fused types, type cannot be specialized
fused_types.pyx:26:4: Not enough types specified to specialize the function, int2_t is still fused
fused_types.pyx:27:4: Invalid use of fused types, type cannot be specialized
fused_types.pyx:27:4: Not enough types specified to specialize the function, int2_t is still fused
fused_types.pyx:28:16: Call with wrong number of arguments (expected 2, got 1)
fused_types.pyx:29:16: Call with wrong number of arguments (expected 2, got 3)
fused_types.pyx:30:4: Invalid use of fused types, type cannot be specialized
fused_types.pyx:30:4: Keyword and starred arguments not allowed in cdef functions.
fused_types.pyx:36:6: Invalid base type for memoryview slice: int *
fused_types.pyx:39:0: Fused lambdas not allowed
...
...
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