X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Bot.pm;h=9a289f0695a55a39866706d9f199a5bd491ecb26;hb=741af182c0359e3b9be3848a772750b2642428a9;hp=dde08adc2b42ff6dc1acaf027b51f686ef990905;hpb=06eb99af20cebc85b1f609becb125b4dc32bf8ff;p=NDIRC.git diff --git a/Bot.pm b/Bot.pm index dde08ad..9a289f0 100644 --- a/Bot.pm +++ b/Bot.pm @@ -33,6 +33,7 @@ use POE::Component::IRC::Plugin::AutoJoin; use POE::Component::IRC::Plugin::NickReclaim; use NDIRC::Dispatcher; +use NDIRC::Context; use IO::File; @@ -114,9 +115,66 @@ sub sig_usr1 { $kernel->yield( 'refresh' ); } +sub clear_constraint { + my $tc = shift; + + while (1) { + if (ref $tc eq 'MooseX::Meta::TypeConstraint::Structured'){ + for my $t (@{$tc->{type_constraints}}){ + clear_constraint($t); + } + + } + if (ref $tc eq 'Moose::Meta::TypeConstraint::Parameterized'){ + clear_constraint($tc->{type_parameter}); + } + last if ref $tc eq 'HASH'; + last if ref $tc eq ''; + if (defined $tc->{_type_constraint}){ + $tc = $tc->{_type_constraint}; + }elsif(defined $tc->{__type_constraint}){ + $tc = $tc->{__type_constraint}; + }else{ + last; + } + } +} + +sub clear_metains { + my $ins = shift; + + for my $a (@{$ins->{attributes}}){ + for my $m (@{$a->{associated_methods}}){ + $m->{body} = undef; + } + clear_constraint($a->{isa}); + } +} + +sub clear_cycles { + my $c = shift; + + for my $m (values %{$c->meta->{methods}}){ + clear_constraint($m->{type_constraint}); + + my $ps = $m->{parsed_signature}; + for my $p (@{$ps->{_positional_params}->{params}}){ + clear_metains($p->{__MOP__}->{_meta_instance}); + } + + $m->{body} = undef; + } + clear_metains($c->meta->{_meta_instance}); +} + + sub sig_usr2 { my $self = shift @_; + for my $c (values %{$self->disp->commands}){ + clear_cycles($c); + } + $self->disp($self->_build_disp); }