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
3d681d3e
Commit
3d681d3e
authored
Dec 09, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix viewpoint adaptation of the fields of and 'iso' cypclass
parent
8f14ad8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
19 deletions
+17
-19
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+10
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+5
-15
No files found.
Cython/Compiler/ExprNodes.py
View file @
3d681d3e
...
...
@@ -11379,8 +11379,8 @@ class ConsumeNode(ExprNode):
self
.
type
=
PyrexTypes
.
error_type
return
self
if
operand_type
.
is_qualified_cyp_class
:
if
operand_type
.
qualifier
==
'iso
!
'
:
error
(
self
.
pos
,
"Cannot consume iso
!
"
)
if
operand_type
.
qualifier
==
'iso
&
'
:
error
(
self
.
pos
,
"Cannot consume iso
&
"
)
self
.
type
=
PyrexTypes
.
error_type
return
self
self
.
generate_runtime_check
=
operand_type
.
qualifier
not
in
(
'iso'
,
'iso~'
)
...
...
Cython/Compiler/PyrexTypes.py
View file @
3d681d3e
...
...
@@ -4802,7 +4802,7 @@ class ConstCypclassType(BaseType):
class
QualifiedCypclassType
(
BaseType
):
"A qualified cypclass reference"
# qualifier string the qualifier keyword: ('active' | 'iso' | 'iso~' | 'iso
!
' )
# qualifier string the qualifier keyword: ('active' | 'iso' | 'iso~' | 'iso
&
' )
subtypes
=
[
'qual_base_type'
]
...
...
@@ -4813,7 +4813,7 @@ class QualifiedCypclassType(BaseType):
'active'
:
(
'active'
,
'iso~'
),
'iso'
:
(
'iso~'
,),
'iso~'
:
(),
'iso
!'
:
(
),
'iso
&'
:
(
'iso~'
,
),
}
def
__init__
(
self
,
base_type
,
qualifier
):
...
...
@@ -5823,6 +5823,14 @@ def qualified_method_type(base_type, const, volatile):
else
:
return
QualifiedMethodType
(
base_type
,
const
,
volatile
)
def
viewpoint_adaptation
(
base_type
,
qualifier
=
'iso&'
):
# Perform viewpoint adaptation for cypclass types.
if
base_type
.
is_qualified_cyp_class
:
return
base_type
if
base_type
.
is_cyp_class
:
return
QualifiedCypclassType
(
base_type
,
qualifier
)
return
base_type
def
same_type
(
type1
,
type2
):
return
type1
.
same_as
(
type2
)
...
...
Cython/Compiler/Symtab.py
View file @
3d681d3e
...
...
@@ -17,7 +17,8 @@ from .Errors import warning, error, InternalError
from
.StringEncoding
import
EncodedString
from
.
import
Options
,
Naming
from
.
import
PyrexTypes
from
.PyrexTypes
import
py_object_type
,
cy_object_type
,
unspecified_type
from
.PyrexTypes
import
(
py_object_type
,
cy_object_type
,
unspecified_type
,
viewpoint_adaptation
)
from
.TypeSlots
import
(
pyfunction_signature
,
pymethod_signature
,
richcmp_special_methods
,
get_special_method_signature
,
get_property_accessor_signature
)
...
...
@@ -3297,25 +3298,14 @@ class IsoCypclassScope(QualifiedCypclassScope):
def
__init__
(
self
,
base_type_scope
):
QualifiedCypclassScope
.
__init__
(
self
,
base_type_scope
,
'iso'
)
def
adapt
(
self
,
fieldtype
,
qualifier
=
'iso'
):
if
fieldtype
.
is_qualified_cyp_class
:
# attribute is sendable (either 'iso' or 'active')
return
fieldtype
elif
fieldtype
.
is_cyp_class
:
# viewpoint adaptation
return
PyrexTypes
.
cyp_class_qualified_type
(
fieldtype
,
qualifier
)
else
:
return
fieldtype
def
adapt_arg_type
(
self
,
arg
):
arg
=
copy
.
copy
(
arg
)
arg
.
type
=
self
.
adapt
(
arg
.
type
)
arg
.
type
=
viewpoint_adaptation
(
arg
.
type
)
return
arg
def
adapt_method_entry
(
self
,
base_entry
):
iso_method_type
=
copy
.
copy
(
base_entry
.
type
)
# The return type should be treated as 'iso' but cannot be consumed
return_type
=
self
.
adapt
(
base_entry
.
type
.
return_type
,
qualifier
=
'iso!'
)
return_type
=
viewpoint_adaptation
(
base_entry
.
type
.
return_type
)
iso_method_type
.
return_type
=
return_type
iso_method_type
.
args
=
[
self
.
adapt_arg_type
(
arg
)
for
arg
in
base_entry
.
type
.
args
]
if
hasattr
(
base_entry
.
type
,
'op_arg_struct'
):
...
...
@@ -3339,7 +3329,7 @@ class IsoCypclassScope(QualifiedCypclassScope):
return
iso_alternatives
[
0
]
else
:
base_entry_type
=
base_entry
.
type
adapted_type
=
self
.
adapt
(
base_entry_type
)
adapted_type
=
viewpoint_adaptation
(
base_entry_type
)
if
adapted_type
is
base_entry_type
:
return
base_entry
else
:
...
...
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