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
a9056438
Commit
a9056438
authored
Apr 26, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
another simplification of type inheritance sorting
parent
6965934d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
20 deletions
+18
-20
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+18
-20
No files found.
Cython/Compiler/ModuleNode.py
View file @
a9056438
...
...
@@ -257,11 +257,17 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
find_referenced_modules
(
imported_module
,
module_list
,
modules_seen
)
module_list
.
append
(
env
)
def
collect_inheritance_hierarchies
(
self
,
type_dict
,
getkey
):
base_dict
=
{}
for
key
,
entry
in
type_dict
.
items
():
def
sort_types_by_inheritance
(
self
,
type_dict
,
getkey
):
# copy the types into a list moving each parent type before
# its first child
type_items
=
type_dict
.
items
()
type_list
=
[]
for
i
,
item
in
enumerate
(
type_items
):
key
,
new_entry
=
item
# collect all base classes to check for children
hierarchy
=
set
()
base
=
entry
base
=
new_
entry
while
base
:
base_type
=
base
.
type
.
base_type
if
not
base_type
:
...
...
@@ -269,18 +275,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
base_key
=
getkey
(
base_type
)
hierarchy
.
add
(
base_key
)
base
=
type_dict
.
get
(
base_key
)
entry
.
base_keys
=
hierarchy
base_dict
[
key
]
=
entry
return
base_dict
new_entry
.
base_keys
=
hierarchy
def
sort_types_by_inheritance
(
self
,
base_dict
):
type_items
=
base_dict
.
items
()
type_list
=
[]
for
i
,
item
in
enumerate
(
type_items
):
type_key
,
new_entry
=
item
# find the first (sub-)subclass and insert before that
for
j
in
range
(
i
):
entry
=
type_list
[
j
]
if
type_
key
in
entry
.
base_keys
:
if
key
in
entry
.
base_keys
:
type_list
.
insert
(
j
,
new_entry
)
break
else
:
...
...
@@ -306,17 +306,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
vtabstruct_cname
(
entry_type
):
return
entry_type
.
vtabstruct_cname
vtab_hierarchies
=
self
.
sort_types_by_inheritance
(
self
.
collect_inheritance_hierarchies
(
vtab_dict
,
vtabstruct_cname
))
vtab_list
=
self
.
sort_types_by_inheritance
(
vtab_dict
,
vtabstruct_cname
)
def
objstruct_cname
(
entry_type
):
return
entry_type
.
objstruct_cname
vtabslot_hierarchies
=
self
.
sort_types_by_inheritance
(
self
.
collect_inheritance_hierarchies
(
vtabslot_dict
,
objstruct_cname
))
vtabslot_list
=
self
.
sort_types_by_inheritance
(
vtabslot_dict
,
objstruct_cname
)
return
(
vtab_
hierarchies
,
vtabslot_hierarchies
)
return
(
vtab_
list
,
vtabslot_list
)
def
generate_type_definitions
(
self
,
env
,
modules
,
vtab_list
,
vtabslot_list
,
code
):
vtabslot_entries
=
set
(
vtabslot_list
)
...
...
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