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
Show 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):
...
@@ -257,11 +257,17 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
find_referenced_modules
(
imported_module
,
module_list
,
modules_seen
)
self
.
find_referenced_modules
(
imported_module
,
module_list
,
modules_seen
)
module_list
.
append
(
env
)
module_list
.
append
(
env
)
def
collect_inheritance_hierarchies
(
self
,
type_dict
,
getkey
):
def
sort_types_by_inheritance
(
self
,
type_dict
,
getkey
):
base_dict
=
{}
# copy the types into a list moving each parent type before
for
key
,
entry
in
type_dict
.
items
():
# 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
()
hierarchy
=
set
()
base
=
entry
base
=
new_
entry
while
base
:
while
base
:
base_type
=
base
.
type
.
base_type
base_type
=
base
.
type
.
base_type
if
not
base_type
:
if
not
base_type
:
...
@@ -269,18 +275,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -269,18 +275,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
base_key
=
getkey
(
base_type
)
base_key
=
getkey
(
base_type
)
hierarchy
.
add
(
base_key
)
hierarchy
.
add
(
base_key
)
base
=
type_dict
.
get
(
base_key
)
base
=
type_dict
.
get
(
base_key
)
entry
.
base_keys
=
hierarchy
new_entry
.
base_keys
=
hierarchy
base_dict
[
key
]
=
entry
return
base_dict
def
sort_types_by_inheritance
(
self
,
base_dict
):
# find the first (sub-)subclass and insert before that
type_items
=
base_dict
.
items
()
type_list
=
[]
for
i
,
item
in
enumerate
(
type_items
):
type_key
,
new_entry
=
item
for
j
in
range
(
i
):
for
j
in
range
(
i
):
entry
=
type_list
[
j
]
entry
=
type_list
[
j
]
if
type_
key
in
entry
.
base_keys
:
if
key
in
entry
.
base_keys
:
type_list
.
insert
(
j
,
new_entry
)
type_list
.
insert
(
j
,
new_entry
)
break
break
else
:
else
:
...
@@ -306,17 +306,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -306,17 +306,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
vtabstruct_cname
(
entry_type
):
def
vtabstruct_cname
(
entry_type
):
return
entry_type
.
vtabstruct_cname
return
entry_type
.
vtabstruct_cname
vtab_hierarchies
=
self
.
sort_types_by_inheritance
(
vtab_list
=
self
.
sort_types_by_inheritance
(
self
.
collect_inheritance_hierarchies
(
vtab_dict
,
vtabstruct_cname
)
vtab_dict
,
vtabstruct_cname
))
def
objstruct_cname
(
entry_type
):
def
objstruct_cname
(
entry_type
):
return
entry_type
.
objstruct_cname
return
entry_type
.
objstruct_cname
vtabslot_hierarchies
=
self
.
sort_types_by_inheritance
(
vtabslot_list
=
self
.
sort_types_by_inheritance
(
self
.
collect_inheritance_hierarchies
(
vtabslot_dict
,
objstruct_cname
)
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
):
def
generate_type_definitions
(
self
,
env
,
modules
,
vtab_list
,
vtabslot_list
,
code
):
vtabslot_entries
=
set
(
vtabslot_list
)
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