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
Xavier Thompson
cython
Commits
5ea4b23c
Commit
5ea4b23c
authored
Dec 14, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce 'locked&' qualifier
parent
34a5e359
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
3 deletions
+17
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+8
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+2
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+4
-2
No files found.
Cython/Compiler/Nodes.py
View file @
5ea4b23c
...
@@ -782,6 +782,8 @@ class CFuncDeclaratorNode(CDeclaratorNode):
...
@@ -782,6 +782,8 @@ class CFuncDeclaratorNode(CDeclaratorNode):
exc_check
=
self
.
exception_check
exc_check
=
self
.
exception_check
if
return_type
.
is_cfunction
:
if
return_type
.
is_cfunction
:
error
(
self
.
pos
,
"Function cannot return a function"
)
error
(
self
.
pos
,
"Function cannot return a function"
)
if
return_type
.
is_qualified_cyp_class
and
return_type
.
qualifier
in
(
'locked&'
,):
error
(
self
.
pos
,
"Function cannot return a 'locked&' qualifier"
)
func_type
=
PyrexTypes
.
CFuncType
(
func_type
=
PyrexTypes
.
CFuncType
(
return_type
,
func_type_args
,
self
.
has_varargs
,
return_type
,
func_type_args
,
self
.
has_varargs
,
optional_arg_count
=
self
.
optional_arg_count
,
optional_arg_count
=
self
.
optional_arg_count
,
...
@@ -1370,6 +1372,9 @@ class QualifiedCypclassNode(CBaseTypeNode):
...
@@ -1370,6 +1372,9 @@ class QualifiedCypclassNode(CBaseTypeNode):
if
not
base
.
is_cyp_class
:
if
not
base
.
is_cyp_class
:
error
(
self
.
pos
,
"Qualifier '%s' can only apply to cypclass types"
%
self
.
qualifier
)
error
(
self
.
pos
,
"Qualifier '%s' can only apply to cypclass types"
%
self
.
qualifier
)
return
base
return
base
# if self.qualifier in ('locked&',) and env.return_type is None:
# error(self.pos, "Qualifier '%s' can only be used inside functions" % self.qualifier)
# return base
return
PyrexTypes
.
cyp_class_qualified_type
(
base
,
self
.
qualifier
)
return
PyrexTypes
.
cyp_class_qualified_type
(
base
,
self
.
qualifier
)
...
@@ -1502,6 +1507,9 @@ class CVarDefNode(StatNode):
...
@@ -1502,6 +1507,9 @@ class CVarDefNode(StatNode):
else
:
else
:
if
self
.
directive_locals
:
if
self
.
directive_locals
:
error
(
self
.
pos
,
"Decorators can only be followed by functions"
)
error
(
self
.
pos
,
"Decorators can only be followed by functions"
)
if
base_type
.
is_qualified_cyp_class
and
base_type
.
qualifier
in
(
'locked&'
,
)
and
env
.
return_type
is
None
:
error
(
self
.
pos
,
"'locked&' variables are only allowed inside a function"
)
return
error_type
self
.
entry
=
dest_scope
.
declare_var
(
self
.
entry
=
dest_scope
.
declare_var
(
name
,
type
,
declarator
.
pos
,
name
,
type
,
declarator
.
pos
,
cname
=
cname
,
visibility
=
visibility
,
in_pxd
=
self
.
in_pxd
,
cname
=
cname
,
visibility
=
visibility
,
in_pxd
=
self
.
in_pxd
,
...
...
Cython/Compiler/Parsing.py
View file @
5ea4b23c
...
@@ -2548,6 +2548,9 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
...
@@ -2548,6 +2548,9 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
if
s
.
sy
==
'IDENT'
and
s
.
systring
in
(
'active'
,
'iso'
,
'locked'
):
if
s
.
sy
==
'IDENT'
and
s
.
systring
in
(
'active'
,
'iso'
,
'locked'
):
qualifier
=
s
.
systring
qualifier
=
s
.
systring
s
.
next
()
s
.
next
()
if
s
.
sy
==
'&'
and
qualifier
in
(
'locked'
,):
qualifier
=
"%s&"
%
qualifier
s
.
next
()
base_type
=
p_c_base_type
(
s
,
self_flag
=
self_flag
,
nonempty
=
nonempty
,
templates
=
templates
)
base_type
=
p_c_base_type
(
s
,
self_flag
=
self_flag
,
nonempty
=
nonempty
,
templates
=
templates
)
return
Nodes
.
QualifiedCypclassNode
(
pos
,
base_type
=
base_type
,
qualifier
=
qualifier
)
return
Nodes
.
QualifiedCypclassNode
(
pos
,
base_type
=
base_type
,
qualifier
=
qualifier
)
...
...
Cython/Compiler/PyrexTypes.py
View file @
5ea4b23c
...
@@ -4860,7 +4860,8 @@ class QualifiedCypclassType(BaseType):
...
@@ -4860,7 +4860,8 @@ class QualifiedCypclassType(BaseType):
'iso'
:
(
'iso~'
,),
'iso'
:
(
'iso~'
,),
'iso~'
:
(),
'iso~'
:
(),
'iso->'
:
(
'iso~'
,),
'iso->'
:
(
'iso~'
,),
'locked'
:
(
'locked'
,
'iso~'
),
'locked'
:
(
'locked'
,
'locked&'
,
'iso~'
),
'locked&'
:
(
'locked&'
,
'iso~'
),
}
}
def
__new__
(
cls
,
base_type
,
qualifier
):
def
__new__
(
cls
,
base_type
,
qualifier
):
...
...
Cython/Compiler/Symtab.py
View file @
5ea4b23c
...
@@ -3318,8 +3318,8 @@ def qualified_cypclass_scope(base_type_scope, qualifier):
...
@@ -3318,8 +3318,8 @@ def qualified_cypclass_scope(base_type_scope, qualifier):
return
ActiveCypclassScope
(
base_type_scope
)
return
ActiveCypclassScope
(
base_type_scope
)
elif
qualifier
.
startswith
(
'iso'
):
elif
qualifier
.
startswith
(
'iso'
):
return
IsoCypclassScope
(
base_type_scope
,
qualifier
)
return
IsoCypclassScope
(
base_type_scope
,
qualifier
)
elif
qualifier
==
'locked'
:
elif
qualifier
.
startswith
(
'locked'
)
:
return
IsoCypclassScope
(
base_type_scope
,
'locked'
)
return
IsoCypclassScope
(
base_type_scope
,
qualifier
)
else
:
else
:
return
QualifiedCypclassScope
(
base_type_scope
,
qualifier
)
return
QualifiedCypclassScope
(
base_type_scope
,
qualifier
)
...
@@ -3346,6 +3346,8 @@ class IsoCypclassScope(QualifiedCypclassScope):
...
@@ -3346,6 +3346,8 @@ class IsoCypclassScope(QualifiedCypclassScope):
if
base_type
.
self_qualifier
:
if
base_type
.
self_qualifier
:
if
self
.
qualifier
in
PyrexTypes
.
QualifiedCypclassType
.
assignable_to
[
base_type
.
self_qualifier
]:
if
self
.
qualifier
in
PyrexTypes
.
QualifiedCypclassType
.
assignable_to
[
base_type
.
self_qualifier
]:
return
base_entry
return
base_entry
elif
base_type
.
self_qualifier
==
'locked&'
and
self
.
qualifier
==
'locked'
:
return
base_entry
else
:
else
:
return
None
return
None
iso_method_type
=
copy
.
copy
(
base_type
)
iso_method_type
=
copy
.
copy
(
base_type
)
...
...
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