This file is indexed.

/usr/share/perl5/PlSense/Symbol/Module.pm is in plsense 0.3.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
package PlSense::Symbol::Module;

use parent qw{ PlSense::Symbol };
use strict;
use warnings;
use Class::Std::Storable;
use List::AllUtils qw{ first uniq firstidx };
use Scalar::Util qw{ weaken };
use PlSense::Logger;
{
    my %filepath_of :ATTR( :init_arg<filepath> );
    sub get_filepath { my ($self) = @_; return $filepath_of{ident $self}; }

    my %projectnm_of :ATTR( :init_arg<projectnm> :default('') );
    sub get_projectnm { my ($self) = @_; return $projectnm_of{ident $self}; }

    my %lastmodified_of :ATTR( :init_arg<lastmodified> );
    sub get_lastmodified { my ($self) = @_; return $lastmodified_of{ident $self}; }

    my %initialized_is :ATTR( :default(0) );
    sub initialized { my ($self) = @_; $initialized_is{ident $self} = 1; }
    sub uninitialized { my ($self) = @_; $initialized_is{ident $self} = 0; }
    sub is_initialized { my ($self) = @_; return $initialized_is{ident $self}; }

    my %parents_of :ATTR();
    sub update_parent {
        my ($self) = @_;
        DELETE_INVALID:
        while ( ( my $idx = firstidx { ! $_ } @{$parents_of{ident $self}} ) >= 0 ) {
            splice @{$parents_of{ident $self}}, $idx, 1;
        }
    }
    sub push_parent {
        my ($self, $parent, $not_weaken) = @_;
        if ( ! $parent || ! $parent->isa("PlSense::Symbol::Module") ) {
            logger->error("Not PlSense::Symbol::Module");
            return;
        }
        if ( $self->exist_parent($parent->get_name) ) {
            logger->warn("Already exist [".$parent->get_name()."]");
            return;
        }
        push @{$parents_of{ident $self}}, $parent;
        if ( ! $not_weaken ) { weaken @{$parents_of{ident $self}}[-1]; }
    }
    sub count_parent {
        my ($self) = @_;
        $self->update_parent;
        return $#{$parents_of{ident $self}} + 1;
    }
    sub get_parent {
        my ($self, $index) = @_;
        if ( $index !~ m{ ^\d+$ }xms ) {
            logger->warn("Not Integer");
            return;
        }
        if ( $index < 1 || $index > $#{$parents_of{ident $self}} + 1 ) {
            logger->warn("Out of Index");
            return;
        }
        return @{$parents_of{ident $self}}[$index - 1];
    }
    sub exist_parent {
        my ($self, $mdlnm) = @_;
        my @ret = grep { $_ && $_->get_name eq $mdlnm } @{$parents_of{ident $self}};
        return $#ret >= 0 ? 1 : 0;
    }
    sub reset_parent { my ($self) = @_; $parents_of{ident $self} = []; }

    my %usingmdls_of :ATTR();
    sub update_usingmdl {
        my ($self) = @_;
        DELETE_INVALID:
        while ( ( my $idx = firstidx { ! $_ } @{$usingmdls_of{ident $self}} ) >= 0 ) {
            splice @{$usingmdls_of{ident $self}}, $idx, 1;
        }
    }
    sub push_usingmdl {
        my ($self, $usingmdl, $not_weaken) = @_;
        if ( ! $usingmdl || ! $usingmdl->isa("PlSense::Symbol::Module") ) {
            logger->error("Not PlSense::Symbol::Module");
            return;
        }
        if ( $self->exist_usingmdl($usingmdl->get_name()) ) {
            logger->warn("Already exist : ".$usingmdl->get_name());
            return;
        }
        push @{$usingmdls_of{ident $self}}, $usingmdl;
        if ( ! $not_weaken ) { weaken @{$usingmdls_of{ident $self}}[-1]; }
    }
    sub count_usingmdl {
        my ($self) = @_;
        $self->update_usingmdl;
        return $#{$usingmdls_of{ident $self}} + 1;
    }
    sub get_usingmdl {
        my ($self, $index) = @_;
        if ( $index !~ m{ ^\d+$ }xms ) {
            logger->warn("Not Integer");
            return;
        }
        if ( $index < 1 || $index > $#{$usingmdls_of{ident $self}} + 1 ) {
            logger->warn("Out of Index");
            return;
        }
        return @{$usingmdls_of{ident $self}}[$index - 1];
    }
    sub exist_usingmdl {
        my ($self, $mdlnm) = @_;
        my @ret = grep { $_ && $_->get_name eq $mdlnm } @{$usingmdls_of{ident $self}};
        return $#ret >= 0 ? 1 : 0;
    }
    sub reset_usingmdl { my ($self) = @_; $usingmdls_of{ident $self} = []; }

    my %bundlemdls_of :ATTR( :default(undef) );
    sub update_bundlemdl {
        my ($self) = @_;
        DELETE_INVALID:
        while ( ( my $idx = firstidx { ! $_ } @{$bundlemdls_of{ident $self}} ) >= 0 ) {
            splice @{$bundlemdls_of{ident $self}}, $idx, 1;
        }
    }
    sub push_bundlemdl {
        my ($self, $bundlemdl, $not_weaken) = @_;
        if ( ! $bundlemdl || ! $bundlemdl->isa("PlSense::Symbol::Module") ) {
            logger->error("Not PlSense::Symbol::Module");
            return;
        }
        if ( $self->exist_bundlemdl($bundlemdl->get_name()) ) {
            logger->warn("Already exist : ".$bundlemdl->get_name());
            return;
        }
        push @{$bundlemdls_of{ident $self}}, $bundlemdl;
        if ( ! $not_weaken ) { weaken @{$bundlemdls_of{ident $self}}[-1]; }
    }
    sub count_bundlemdl {
        my ($self) = @_;
        $self->update_bundlemdl;
        return $#{$bundlemdls_of{ident $self}} + 1;
    }
    sub get_bundlemdl {
        my ($self, $index) = @_;
        if ( ! $index || $index !~ m{ ^\d+$ }xms ) {
            logger->warn("Not Integer");
            return;
        }
        if ( $index < 1 || $index > $#{$bundlemdls_of{ident $self}} + 1 ) {
            logger->warn("Out of Index");
            return;
        }
        return @{$bundlemdls_of{ident $self}}[$index - 1];
    }
    sub exist_bundlemdl {
        my ($self, $mdlnm) = @_;
        my @ret = grep { $_ && $_->get_name eq $mdlnm } @{$bundlemdls_of{ident $self}};
        return $#ret >= 0 ? 1 : 0;
    }
    sub reset_bundlemdl { my ($self) = @_; $bundlemdls_of{ident $self} = []; }

    my %memberh_of :ATTR();
    sub set_member {
        my ($self, $membernm, $member) = @_;
        if ( ! $member || ! $member->isa("PlSense::Symbol::Variable") ) {
            logger->error("Not PlSense::Symbol::Variable");
            return;
        }
        if ( $membernm ne $member->get_name() ) {
            logger->warn("Not equal key[$membernm] and member's name[".$member->get_name()."]");
            return;
        }
        $memberh_of{ident $self}->{$membernm} = $member;
    }
    sub exist_member {
        my ($self, $membernm) = @_;
        return $membernm && exists $memberh_of{ident $self}->{$membernm};
    }
    sub get_member {
        my ($self, $membernm) = @_;
        if ( ! exists $memberh_of{ident $self}->{$membernm} ) {
            logger->warn("Not exist member[$membernm] in ".$self->get_fullnm);
            return;
        }
        return $memberh_of{ident $self}->{$membernm};
    }
    sub keys_member {
        my ($self) = @_;
        return keys %{$memberh_of{ident $self}};
    }

    my %methodh_of :ATTR();
    sub set_method {
        my ($self, $methodnm, $method) = @_;
        if ( ! $method || ! $method->isa("PlSense::Symbol::Method") ) {
            logger->error("Not PlSense::Symbol::Method");
            return;
        }
        if ( $methodnm ne $method->get_name() ) {
            logger->warn("Not equal key[$methodnm] and method's name[".$method->get_name()."]");
            return;
        }
        $methodh_of{ident $self}->{$methodnm} = $method;
    }
    sub exist_method {
        my ($self, $methodnm) = @_;
        return $methodnm && exists $methodh_of{ident $self}->{$methodnm};
    }
    sub get_method {
        my ($self, $methodnm) = @_;
        if ( ! exists $methodh_of{ident $self}->{$methodnm} ) {
            logger->warn("Not exist method[$methodnm] in ".$self->get_fullnm);
            return;
        }
        return $methodh_of{ident $self}->{$methodnm};
    }
    sub keys_method {
        my ($self) = @_;
        return keys %{$methodh_of{ident $self}};
    }

    my %source_of :ATTR();
    sub set_source {
        my ($self, $source) = @_;
        $source_of{ident $self} = $source;
    }
    sub get_source { my ($self) = @_; return $source_of{ident $self}; }

    sub BUILD {
        my ($class, $ident, $arg_ref) = @_;
        $class->set_type("module");
        $class->reset_all;

        my $name = $arg_ref->{name} || "";
        if ( ! $name || $name !~ m{ ^ [a-zA-Z_][a-zA-Z0-9_:]* $ }xms ) {
            logger->error("Name is invalid value : [$name]");
        }

        my $filepath = $arg_ref->{filepath} || "";
        if ( ! -f $filepath ) {
            logger->error("Not exist file[$filepath]");
        }
    }

    sub reset_all {
        my ($self, $lastmodified) = @_;
        $parents_of{ident $self} = [];
        $usingmdls_of{ident $self} = [];
        $bundlemdls_of{ident $self} = [];
        $memberh_of{ident $self} = {};
        $methodh_of{ident $self} = {};
        $source_of{ident $self} = undef;
        $initialized_is{ident $self} = 0;
        if ( $lastmodified ) { $lastmodified_of{ident $self} = $lastmodified; }
    }

    sub renew {
        my ($self) = @_;
        return PlSense::Symbol::Module->new({ name => $self->get_name,
                                              filepath => $self->get_filepath,
                                              projectnm => $self->get_projectnm,
                                              lastmodified => $self->get_lastmodified,
                                              linenumber => $self->get_linenumber,
                                              colnumber => $self->get_colnumber, });
    }

    sub interchange_to {
        my ($self, $mdl) = @_;
        if ( ! $mdl || ! $mdl->isa("PlSense::Symbol::Module") ) { return; }

        $self->reset_all($mdl->get_lastmodified);
        MEMBER:
        foreach my $membernm ( $mdl->keys_member ) {
            my $member = $mdl->get_member($membernm);
            $member->set_belong($self);
        }
        METHOD:
        foreach my $methodnm ( $mdl->keys_method ) {
            my $method = $mdl->get_method($methodnm);
            $method->set_module($self);
        }
        PARENT:
        for my $i ( 1..$mdl->count_parent ) { $self->push_parent( $mdl->get_parent($i) ); }
        USINGMDL:
        for my $i ( 1..$mdl->count_usingmdl ) { $self->push_usingmdl( $mdl->get_usingmdl($i) ); }
        BUNDLEMDL:
        for my $i ( 1..$mdl->count_bundlemdl ) { $self->push_bundlemdl( $mdl->get_bundlemdl($i) ); }
        $self->set_helptext($mdl->get_helptext);
        $self->set_source($mdl->get_source);
        $mdl->is_initialized ? $self->initialized : $self->uninitialized;
    }

    sub get_fullnm {
        my $self = shift;
        return $self->get_name eq "main" ? "main[".$self->get_filepath."]" : $self->get_name;
    }

    sub to_detail_string {
        my $self = shift;
        my $ret = "";
        my $first;
        my $addr = sprintf("%s", $self);
        $addr =~ s{ ^ PlSense::Symbol::Module=SCALAR\((.+)\) $ }{$1}xms;
        $ret .= "MYSELF: ".$self->get_name."($addr)\n";
        $ret .= "PARENT: ";
        $first = 1;
        PARENT:
        for ( my $i = 1; $i <= $self->count_parent; $i++ ) {
            my $mdl = $self->get_parent($i);
            if ( ! $first ) { $ret .= ", "; }
            $first = 0;
            $ret .= $mdl->get_name;
            my $addr = sprintf("%s", $mdl);
            $addr =~ s{ ^ PlSense::Symbol::Module=SCALAR\((.+)\) $ }{$1}xms;
            $ret .= "($addr)";
        }
        $ret .= "\n";
        $ret .= "INCLUDE: ";
        $first = 1;
        USINGMDL:
        for ( my $i = 1; $i <= $self->count_usingmdl; $i++ ) {
            my $mdl = $self->get_usingmdl($i);
            if ( ! $first ) { $ret .= ", "; }
            $first = 0;
            $ret .= $mdl->get_name;
            my $addr = sprintf("%s", $mdl);
            $addr =~ s{ ^ PlSense::Symbol::Module=SCALAR\((.+)\) $ }{$1}xms;
            $ret .= "($addr)";
        }
        $ret .= "\n";
        MEMBER:
        foreach my $var ( values %{$memberh_of{ident $self}} ) {
            $ret .= $var->get_name." LEXICAL[".$var->is_lexical."] IMPORTIVE[".$var->is_importive."]\n";
        }
        METHOD:
        foreach my $mtd ( values %{$methodh_of{ident $self}} ) {
            my $attr = $mtd->get_attribute;
            my $attrtext = $attr ? $attr->{content} : "";
            $ret .= "&".$mtd->get_name." ATTR[".$attrtext."] PUBLIC[".$mtd->is_publicly."] PRIVATE[".$mtd->is_privately."] IMPORTIVE[".$mtd->is_importive."] RESERVED[".$mtd->is_reserved."]\n";
            VAR:
            foreach my $varnm ( $mtd->keys_variable ) {
                my $var = $mtd->get_variable($varnm);
                $ret .= "  ".$var->get_name." LEXICAL[".$var->is_lexical."] IMPORTIVE[".$var->is_importive."]\n";
            }
        }
        return $ret;
    }

    sub is_objective {
        my $self = shift;
        return $self->exist_method("new");
    }

    sub is_exportable {
        my $self = shift;
        return $self->exist_parent("Exporter") || $self->exist_usingmdl("Exporter");
    }

    sub is_ancestor_of {
        my ($self, $mdl) = @_;
        if ( ! $mdl || ! $mdl->isa("PlSense::Symbol::Module") ) { return; }
        PARENT:
        for my $i ( 1..$mdl->count_parent ) {
            my $parent = $mdl->get_parent($i);
            if ( $parent->get_name eq $self->get_name ) { return 1; }
            $self->is_ancestor_of($parent) && return 1;
        }
        return;
    }

    sub get_own_methods {
        my ($self, $only_name) = @_;
        my %mtd_of;
        METHOD:
        foreach my $mtd ( values %{$methodh_of{ident $self}} ) {
            my $mtdnm = $mtd->get_name;
            if ( $mtd->is_importive ) { next METHOD; }
            $mtd_of{$mtdnm} = $mtd;
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_inherit_methods {
        my ($self, $only_name) = @_;
        my %mtd_of;
        PARENT:
        for ( my $i = 1; $i <= $self->count_parent; $i++ ) {
            my $parent = $self->get_parent($i);
            PARENTMTD:
            foreach my $mtd ( $parent->get_not_private_methods ) {
                if ( exists $mtd_of{$mtd->get_name} ) { next PARENTMTD; }
                $mtd_of{$mtd->get_name} = $mtd;
            }
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_public_methods {
        my ($self, $only_name) = @_;
        my %mtd_of;
        METHOD:
        foreach my $mtd ( values %{$methodh_of{ident $self}} ) {
            my $mtdnm = $mtd->get_name;
            if ( $mtd->is_importive ) { next METHOD; }
            if ( $mtd->is_reserved ) { next METHOD; }
            if ( ! $mtd->is_publicly ) { next METHOD; }
            $mtd_of{$mtdnm} = $mtd;
        }
        PARENT:
        for ( my $i = 1; $i <= $self->count_parent; $i++ ) {
            my $parent = $self->get_parent($i);
            PARENTMTD:
            foreach my $mtd ( $parent->get_public_methods ) {
                if ( exists $mtd_of{$mtd->get_name} ) { next PARENTMTD; }
                $mtd_of{$mtd->get_name} = $mtd;
            }
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_not_private_methods {
        my ($self, $only_name) = @_;
        my %mtd_of;
        METHOD:
        foreach my $mtd ( values %{$methodh_of{ident $self}} ) {
            my $mtdnm = $mtd->get_name;
            if ( $mtd->is_importive ) { next METHOD; }
            if ( $mtd->is_reserved ) { next METHOD; }
            if ( $mtd->is_privately ) { next METHOD; }
            $mtd_of{$mtdnm} = $mtd;
        }
        INHERITMTD:
        foreach my $mtd ( $self->get_inherit_methods ) {
            if ( exists $mtd_of{$mtd->get_name} ) { next INHERITMTD; }
            $mtd_of{$mtd->get_name} = $mtd;
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_all_objective_methods {
        my ($self, $only_name) = @_;
        my %mtd_of;
        METHOD:
        foreach my $mtd ( values %{$methodh_of{ident $self}} ) {
            my $mtdnm = $mtd->get_name;
            if ( $mtd->is_importive ) { next METHOD; }
            if ( $mtd->is_reserved ) { next METHOD; }
            $mtd_of{$mtdnm} = $mtd;
        }
        INHERITMTD:
        foreach my $mtd ( $self->get_inherit_methods ) {
            if ( exists $mtd_of{$mtd->get_name} ) { next INHERITMTD; }
            $mtd_of{$mtd->get_name} = $mtd;
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_instance_methods {
        my ($self, $mdl, $only_name) = @_;
        $only_name = $only_name ? 1 : 0;
        my $is_me = $mdl && $mdl->isa("PlSense::Symbol::Module") && $self->get_name eq $mdl->get_name ? 1 : 0;
        my $is_ancestor = $self->is_ancestor_of($mdl) ? 1 : 0;
        my $mdltext = $mdl && $mdl->isa("PlSense::Symbol::Module") ? $mdl->get_name : "";
        logger->debug("Get instance methods of [".$self->get_name."] in [$mdltext]. is_me[$is_me] is_ancestor[$is_ancestor] only_name[$only_name]");
        return $is_me       ? $self->get_all_objective_methods($only_name)
             : $is_ancestor ? $self->get_not_private_methods($only_name)
             :                $self->get_public_methods($only_name);
    }

    sub get_static_methods {
        my ($self, $mdl, $only_name) = @_;
        my %mtd_of;
        INSTANCEMTD:
        foreach my $mtd ( $self->get_instance_methods($mdl) ) {
            $mtd_of{$mtd->get_name} = $mtd;
        }
        IMPORTMTD:
        foreach my $mtd ( values %{$methodh_of{ident $self}} ) {
            my $mtdnm = $mtd->get_name;
            if ( ! $mtd->is_importive ) { next IMPORTMTD; }
            if ( $mtd->is_reserved ) { next IMPORTMTD; }
            if ( exists $mtd_of{$mtdnm} ) { next IMPORTMTD; }
            USINGMDL:
            for ( my $i = 1; $i <= $self->count_usingmdl; $i++ ) {
                my $m = $self->get_usingmdl($i);
                if ( ! $m->exist_method($mtdnm) ) { next USINGMDL; }
                my $extmtd = $m->get_method($mtdnm);
                if ( $extmtd->is_importive ) { next USINGMDL; }
                $mtd_of{$mtdnm} = $extmtd;
                last USINGMDL;
            }
            if ( ! exists $mtd_of{$mtdnm} ) { $mtd_of{$mtdnm} = $mtd; }
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_any_methods {
        my ($self, $only_name) = @_;
        my %mtd_of;
        METHOD:
        foreach my $mtd ( values %{$methodh_of{ident $self}} ) {
            my $mtdnm = $mtd->get_name;
            $mtd_of{$mtdnm} = $mtd;
        }
        INHERITMTD:
        foreach my $mtd ( $self->get_inherit_methods ) {
            if ( exists $mtd_of{$mtd->get_name} ) { next INHERITMTD; }
            $mtd_of{$mtd->get_name} = $mtd;
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_any_original_methods {
        my ($self, $only_name) = @_;
        my %mtd_of;
        METHOD:
        foreach my $mtd ( values %{$methodh_of{ident $self}} ) {
            my $mtdnm = $mtd->get_name;
            if ( $mtd->is_importive ) {
                USINGMDL:
                for ( my $i = 1; $i <= $self->count_usingmdl; $i++ ) {
                    my $m = $self->get_usingmdl($i);
                    if ( ! $m->exist_method($mtdnm) ) { next USINGMDL; }
                    my $extmtd = $m->get_method($mtdnm);
                    # if ( $extmtd->is_importive ) { next USINGMDL; }
                    $mtd_of{$mtdnm} = $extmtd;
                    last USINGMDL;
                }
                if ( ! exists $mtd_of{$mtdnm} ) { $mtd_of{$mtdnm} = $mtd; }
            }
            else {
                $mtd_of{$mtdnm} = $mtd;
            }
        }
        INHERITMTD:
        foreach my $mtd ( $self->get_inherit_methods ) {
            if ( exists $mtd_of{$mtd->get_name} ) { next INHERITMTD; }
            $mtd_of{$mtd->get_name} = $mtd;
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_external_methods {
        my ($self, $only_name) = @_;
        my %mtd_of;
        USINGMDL:
        for ( my $i = 1; $i <= $self->count_usingmdl; $i++ ) {
            my $m = $self->get_usingmdl($i);
            MTD:
            foreach my $mtd ( $m->get_public_methods ) {
                if ( exists $mtd_of{$mtd->get_fullnm} ) { next MTD; }
                $mtd_of{$mtd->get_fullnm} = $mtd;
            }
        }
        my @ret;
        PUSH:
        foreach my $mtdnm ( sort keys %mtd_of ) {
            push @ret, $only_name ? $mtdnm : $mtd_of{$mtdnm};
        }
        return @ret;
    }

    sub get_instance_method {
        my ($self, $mdl, $mtdnm) = @_;
        return first { $mtdnm && $_->get_name eq $mtdnm } $self->get_instance_methods($mdl);
    }

    sub get_any_method {
        my ($self, $mtdnm) = @_;
        if ( ! $mtdnm ) { return; }
        if ( $mtdnm =~ s{ \A SUPER:: }{}xms ) {
            PARENT:
            for my $i ( 1..$self->count_parent ) {
                my $parent = $self->get_parent($i);
                # I'm not sure which method is right, get_any_method, get_instance_method.
                my $mtd = $parent->get_any_method($mtdnm) or next PARENT;
                return $mtd;
            }
        }
        else {
            return first { $_->get_name eq $mtdnm } $self->get_any_methods;
        }
    }

    sub get_any_original_method {
        my ($self, $mtdnm) = @_;
        my $mtd = $self->get_any_method($mtdnm) or return;
        if ( ! $mtd->is_importive ) { return $mtd; }
        USINGMDL:
        for ( my $i = 1; $i <= $self->count_usingmdl; $i++ ) {
            my $m = $self->get_usingmdl($i);
            if ( ! $m->exist_method($mtdnm) ) { next USINGMDL; }
            my $extmtd = $m->get_method($mtdnm);
            # if ( $extmtd->is_importive ) { next USINGMDL; }
            return $extmtd;
        }
        return $mtd;
    }

    sub exist_instance_method {
        my ($self, $mdl, $mtdnm) = @_;
        return $self->get_instance_method($mdl, $mtdnm) ? 1 : 0;
    }

    sub exist_any_method {
        my ($self, $mtdnm) = @_;
        return $self->get_any_method($mtdnm) ? 1 : 0;
    }

    sub get_public_scalars {
        my ($self, $only_name) = @_;
        return $self->get_public_variables("scalar", $only_name);
    }

    sub get_public_arrays {
        my ($self, $only_name) = @_;
        return $self->get_public_variables("array", $only_name);
    }

    sub get_public_hashes {
        my ($self, $only_name) = @_;
        return $self->get_public_variables("hash", $only_name);
    }

    sub get_public_any_variables {
        my ($self, $only_name) = @_;
        return $self->get_public_variables("", $only_name);
    }

    sub get_public_variables : PRIVATE {
        my ($self, $type, $only_name) = @_;
        my %var_of;
        MEMBER:
        foreach my $var ( values %{$memberh_of{ident $self}} ) {
            if ( $var->is_lexical ) { next MEMBER; }
            # This comment out is wrong. but effort for bad module that not use 'my' and 'our' at definition
            # if ( $var->is_importive ) { next MEMBER; }
            if ( $type && $var->get_type ne $type ) { next MEMBER; }
            $var_of{$var->get_fullnm} = $var;
        }
        my @ret;
        PUSH:
        foreach my $varnm ( sort keys %var_of ) {
            push @ret, $only_name ? $varnm : $var_of{$varnm};
        }
        return @ret;
    }

    sub get_current_scalars {
        my ($self, $methodnm, $only_name) = @_;
        return $self->get_current_variables("scalar", $methodnm, $only_name);
    }

    sub get_current_arrays {
        my ($self, $methodnm, $only_name) = @_;
        return $self->get_current_variables("array", $methodnm, $only_name);
    }

    sub get_current_hashes {
        my ($self, $methodnm, $only_name) = @_;
        return $self->get_current_variables("hash", $methodnm, $only_name);
    }

    sub get_current_any_variables {
        my ($self, $methodnm, $only_name) = @_;
        return $self->get_current_variables("", $methodnm, $only_name);
    }

    sub get_current_variables : PRIVATE {
        my ($self, $type, $mtdnm, $only_name) = @_;
        my %var_of;
        if ( $self->exist_method($mtdnm) ) {
            my $mtd = $self->get_method($mtdnm);
            VARIABLE:
            foreach my $varnm ( $mtd->keys_variable ) {
                my $var = $mtd->get_variable($varnm);
                if ( $type && $var->get_type ne $type ) { next VARIABLE; }
                if ( exists $var_of{$varnm} ) { next VARIABLE; }
                $var_of{$varnm} = $var;
            }
        }
        MEMBER:
        foreach my $var ( values %{$memberh_of{ident $self}} ) {
            my $varnm = $var->get_name;
            if ( $type && $var->get_type ne $type ) { next MEMBER; }
            if ( exists $var_of{$varnm} ) { next MEMBER; }
            $var_of{$varnm} = $var;
        }
        my @ret;
        PUSH:
        foreach my $varnm ( sort keys %var_of ) {
            push @ret, $only_name ? $varnm : $var_of{$varnm};
        }
        return @ret;
    }

    sub get_external_scalars {
        my ($self, $only_name) = @_;
        return $self->get_external_variables("scalar", $only_name);
    }

    sub get_external_arrays {
        my ($self, $only_name) = @_;
        return $self->get_external_variables("array", $only_name);
    }

    sub get_external_hashes {
        my ($self, $only_name) = @_;
        return $self->get_external_variables("hash", $only_name);
    }

    sub get_external_any_variables {
        my ($self, $only_name) = @_;
        return $self->get_external_variables("", $only_name);
    }

    sub get_external_variables : PRIVATE {
        my ($self, $type, $only_name) = @_;
        my %var_of;
        USINGMDL:
        for ( my $i = 1; $i <= $self->count_usingmdl; $i++ ) {
            my $m = $self->get_usingmdl($i);
            VAR:
            foreach my $var ( $m->get_public_variables($type, 0) ) {
                if ( $type && $var->get_type ne $type ) { next VAR; }
                if ( exists $var_of{$var->get_fullnm} ) { next VAR; }
                $var_of{$var->get_fullnm} = $var;
            }
        }
        my @ret;
        PUSH:
        foreach my $varnm ( sort keys %var_of ) {
            push @ret, $only_name ? $varnm : $var_of{$varnm};
        }
        return @ret;
    }

    sub get_all_parents {
        my ($self, $only_name) = @_;
        my @ret;
        PARENT:
        for ( my $i = 1; $i <= $self->count_parent; $i++ ) {
            my $parent = $self->get_parent($i);
            push @ret, $parent;
            push @ret, $parent->get_all_parents;
        }
        return ! $only_name ? @ret : map { $_->get_name } @ret;
    }
}

1;

__END__