Skip to content

Commit 1c5e9d8

Browse files
author
Geoffrey Broadwell
committed
Cache the inversion of all type relationships in the type graph
1 parent d864a34 commit 1c5e9d8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/Perl6/Type.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use v6;
33
class Perl6::Type {
44
has Str $.name handles <Str>;
55
has @.super;
6+
has @.sub;
67
has @.roles;
8+
has @.doers;
79
has $.packagetype is rw = 'class';
810

911
has @.mro;

lib/Perl6/TypeGraph.pm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class Perl6::TypeGraph {
6565
$t.super.push: $get-type('Any');
6666
}
6767
}
68+
# Cache the inversion of all type relationships
69+
for %.types.values -> $t {
70+
$_.sub.push($t) for $t.super;
71+
$_.doers.push($t) for $t.roles;
72+
}
6873
self!topo-sort;
6974
}
7075
method !topo-sort {

0 commit comments

Comments
 (0)