| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package MooseX::Compile::Base; |
|
4
|
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
21801
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
99
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
157
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
2921
|
use Path::Class; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use constant DEBUG => our $DEBUG || $ENV{MX_COMPILE_DEBUG}; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_version { |
|
15
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my ( $class, $version, $file ) = @args{qw(class version file)}; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if ( $self->is_version_compatible($version) ) { |
|
20
|
|
|
|
|
|
|
my ( $basename ) = ( $class =~ /([^:]+)$/ ); |
|
21
|
|
|
|
|
|
|
require Carp; |
|
22
|
|
|
|
|
|
|
Carp::croak( "class '$class' was compiled by an incompatible version of MooseX::Compile ($version, this is $VERSION). " |
|
23
|
|
|
|
|
|
|
. "Please remove the files '$basename.pmc' and '$basename.mopc' next to '$file' and recompile the class" ); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub is_version_compatible { |
|
28
|
|
|
|
|
|
|
my ( $self, $compiled_version, $runtime_version ) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$runtime_version = $VERSION if not defined $runtime_version; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$compiled_version gt $runtime_version or ( $compiled_version lt ( $runtime_version - 1 ) ); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub load_classes { |
|
36
|
|
|
|
|
|
|
my ( $self, @classes ) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
foreach my $class ( @classes ) { |
|
39
|
|
|
|
|
|
|
next if $class->can("meta"); |
|
40
|
|
|
|
|
|
|
( my $file = "$class.pm" ) =~ s{::}{/}g; |
|
41
|
|
|
|
|
|
|
require $file; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub cached_meta_file { |
|
46
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $meta_file = $args{pmc_file} || die "PMC file path must be specified"; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$meta_file =~ s/\.pmc$/.mopc/; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return file($meta_file); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
{ |
|
56
|
|
|
|
|
|
|
package MooseX::Compile::Scope::Guard; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub DESTROY { |
|
59
|
|
|
|
|
|
|
my $self = shift; |
|
60
|
|
|
|
|
|
|
$self->[0]->(); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
package MooseX::Compile::mangled::immutable_metaclass; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package MooseX::Compile::mangled::constraint; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
package MooseX::Compile::mangled::subref; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
package MooseX::Compile::MetaBlackHole; |
|
70
|
|
|
|
|
|
|
# FIXME use Class::MOP::Immutable's opts? |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub isa { |
|
73
|
|
|
|
|
|
|
my ( $self, $class ) = @_; |
|
74
|
|
|
|
|
|
|
return 1 if $class eq 'Moose::Meta::Class' or $class eq 'Class::MOP::Class'; |
|
75
|
|
|
|
|
|
|
return $self->SUPER::isa($class); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub DESTROY {} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub make_immutable {} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub name { |
|
83
|
|
|
|
|
|
|
my $self = shift; |
|
84
|
|
|
|
|
|
|
$self->{name}; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub superclasses { |
|
88
|
|
|
|
|
|
|
my $self = shift; |
|
89
|
|
|
|
|
|
|
die "Can't set superclasses in class body for compiled classes, use __mx_compile_post_hook" if @_; |
|
90
|
|
|
|
|
|
|
no strict 'refs'; |
|
91
|
|
|
|
|
|
|
@{ $self->name . '::ISA' }; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
95
|
|
|
|
|
|
|
my $self = shift; |
|
96
|
|
|
|
|
|
|
require Carp; |
|
97
|
|
|
|
|
|
|
Carp::carp(sprintf "ignoring meta method %s till pmc finishes loading", our $AUTOLOAD); |
|
98
|
|
|
|
|
|
|
return; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__PACKAGE__ |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |