line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#load.pm
|
2
|
|
|
|
|
|
|
#Last Change: 2009-01-19
|
3
|
|
|
|
|
|
|
#Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch
|
4
|
|
|
|
|
|
|
#Version 0.8
|
5
|
|
|
|
|
|
|
####################
|
6
|
|
|
|
|
|
|
#This file is part of the Dotiac::DTL project.
|
7
|
|
|
|
|
|
|
#http://search.cpan.org/perldoc?Dotiac::DTL
|
8
|
|
|
|
|
|
|
#
|
9
|
|
|
|
|
|
|
#load.pm is published under the terms of the MIT license, which basically
|
10
|
|
|
|
|
|
|
#means "Do with it whatever you want". For more information, see the
|
11
|
|
|
|
|
|
|
#license.txt file that should be enclosed with libsofu distributions. A copy of
|
12
|
|
|
|
|
|
|
#the license is (at the time of writing) also available at
|
13
|
|
|
|
|
|
|
#http://www.opensource.org/licenses/mit-license.php .
|
14
|
|
|
|
|
|
|
###############################################################################
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Dotiac::DTL::Tag::load;
|
17
|
11
|
|
|
11
|
|
69
|
use base qw/Dotiac::DTL::Tag/;
|
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
995
|
|
18
|
11
|
|
|
11
|
|
70
|
use strict;
|
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
449
|
|
19
|
11
|
|
|
11
|
|
60
|
use warnings;
|
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
15626
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = 0.8;
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new {
|
24
|
2
|
|
|
2
|
1
|
4
|
my $class=shift;
|
25
|
2
|
|
|
|
|
7
|
my $self={p=>shift()};
|
26
|
2
|
|
|
|
|
6
|
my $module=shift;
|
27
|
2
|
|
|
|
|
8
|
$module=~s/[^\w\s]/_/g;
|
28
|
2
|
|
|
|
|
8
|
my @modules=split /\s+/,$module;
|
29
|
2
|
|
|
|
|
6
|
$self->{module}=[map {"Dotiac::DTL::Addon::$_"} @modules];
|
|
2
|
|
|
|
|
17
|
|
30
|
2
|
|
|
|
|
5
|
foreach my $m (@{$self->{module}}) {
|
|
2
|
|
|
|
|
10
|
|
31
|
2
|
|
|
|
|
148
|
eval "require $m";
|
32
|
2
|
50
|
|
|
|
3618
|
unless ($Dotiac::DTL::Addon::Loaded{$m}++) {
|
33
|
2
|
|
|
|
|
17
|
"$m"->import();
|
34
|
2
|
|
|
|
|
12
|
push @Dotiac::DTL::Addon::Loaded,"$m";
|
35
|
|
|
|
|
|
|
}
|
36
|
2
|
50
|
|
|
|
11
|
die $@ if $@;
|
37
|
|
|
|
|
|
|
}
|
38
|
2
|
|
|
|
|
9
|
bless $self,$class;
|
39
|
2
|
|
|
|
|
11
|
return $self;
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
sub print {
|
42
|
2
|
|
|
2
|
1
|
4
|
my $self=shift;
|
43
|
2
|
|
|
|
|
6
|
print $self->{p};
|
44
|
2
|
|
|
|
|
5
|
foreach my $m (@{$self->{module}}) {
|
|
2
|
|
|
|
|
7
|
|
45
|
2
|
50
|
|
|
|
12
|
unless ($Dotiac::DTL::Addon::Loaded{$m}++) {
|
46
|
2
|
|
|
|
|
13
|
"$m"->import();
|
47
|
2
|
|
|
|
|
12
|
push @Dotiac::DTL::Addon::Loaded,"$m";
|
48
|
|
|
|
|
|
|
}
|
49
|
|
|
|
|
|
|
}
|
50
|
2
|
|
|
|
|
16
|
$self->{n}->print(@_);
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
sub string {
|
53
|
2
|
|
|
2
|
1
|
5
|
my $self=shift;
|
54
|
2
|
|
|
|
|
5
|
foreach my $m (@{$self->{module}}) {
|
|
2
|
|
|
|
|
8
|
|
55
|
2
|
50
|
|
|
|
13
|
unless ($Dotiac::DTL::Addon::Loaded{$m}++) {
|
56
|
2
|
|
|
|
|
14
|
"$m"->import();
|
57
|
2
|
|
|
|
|
13
|
push @Dotiac::DTL::Addon::Loaded,"$m";
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
}
|
60
|
2
|
|
|
|
|
16
|
return $self->{p}.$self->{n}->string(@_);
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
sub perl {
|
64
|
2
|
|
|
2
|
1
|
6
|
my $self=shift;
|
65
|
2
|
|
|
|
|
3
|
my $fh=shift;
|
66
|
2
|
|
|
|
|
5
|
my $id=shift;
|
67
|
2
|
|
|
|
|
24
|
$self->SUPER::perl($fh,$id,@_);
|
68
|
2
|
|
|
|
|
4
|
my @mods=grep !$Dotiac::DTL::Addon::NOCOMPILE{$_},@{$self->{module}};
|
|
2
|
|
|
|
|
12
|
|
69
|
|
|
|
|
|
|
#die Data::Dumper->Dump([\%Dotiac::DTL::Addon::NOCOMPILE,[@mods]]);
|
70
|
2
|
|
|
|
|
6
|
print $fh "my ";
|
71
|
2
|
|
|
|
|
15
|
print $fh (Data::Dumper->Dump([\@mods],["\$module$id"]));
|
72
|
2
|
|
|
|
|
100
|
foreach my $m (@mods) {
|
73
|
1
|
|
|
|
|
3
|
print $fh "require $m;\n";
|
74
|
1
|
|
|
|
|
4
|
print $fh "unless (\$Dotiac::DTL::Addon::Loaded{\"$m\"}++) {\n";
|
75
|
1
|
|
|
|
|
4
|
print $fh "\t$m->import();\n";
|
76
|
1
|
|
|
|
|
3
|
print $fh "\t\tpush \@Dotiac::DTL::Addon::Loaded,\"$m\";\n";
|
77
|
1
|
|
|
|
|
3
|
print $fh "\t}\n";
|
78
|
|
|
|
|
|
|
}
|
79
|
2
|
50
|
|
|
|
22
|
return $self->{n}->perl($fh,$id+1,@_) if $self->{n};
|
80
|
0
|
|
|
|
|
0
|
return $id;
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
sub perlprint {
|
83
|
2
|
|
|
2
|
1
|
5
|
my $self=shift;
|
84
|
2
|
|
|
|
|
6
|
my $fh=shift;
|
85
|
2
|
|
|
|
|
4
|
my $id=shift;
|
86
|
2
|
|
|
|
|
4
|
my $level=shift;
|
87
|
2
|
|
|
|
|
8
|
my $in="\t" x $level;
|
88
|
2
|
|
|
|
|
9
|
print $fh $in,"foreach my \$m (\@\$module$id) {\n";
|
89
|
2
|
|
|
|
|
4
|
print $fh $in,"\tunless (\$Dotiac::DTL::Addon::Loaded{\$m}++) {\n";
|
90
|
2
|
|
|
|
|
6
|
print $fh $in,"\t\t\"\$m\"->import();\n";
|
91
|
2
|
|
|
|
|
12
|
print $fh $in,"\t\t\tpush \@Dotiac::DTL::Addon::Loaded,\"\$m\";\n";
|
92
|
2
|
|
|
|
|
5
|
print $fh $in,"\t}\n";
|
93
|
2
|
|
|
|
|
4
|
print $fh $in,"}\n";
|
94
|
2
|
|
|
|
|
17
|
$self->SUPER::perlprint($fh,$id,$level,@_);
|
95
|
2
|
|
|
|
|
11
|
return $self->{n}->perlprint($fh,$id+1,$level,@_);
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
sub perlstring {
|
98
|
2
|
|
|
2
|
1
|
5
|
my $self=shift;
|
99
|
2
|
|
|
|
|
4
|
my $fh=shift;
|
100
|
2
|
|
|
|
|
6
|
my $id=shift;
|
101
|
2
|
|
|
|
|
18
|
my $level=shift;
|
102
|
2
|
|
|
|
|
11
|
my $in="\t" x $level;
|
103
|
2
|
|
|
|
|
14
|
print $fh $in,"foreach my \$m (\@\$module$id) {\n";
|
104
|
2
|
|
|
|
|
8
|
print $fh $in,"\tunless (\$Dotiac::DTL::Addon::Loaded{\$m}++) {\n";
|
105
|
2
|
|
|
|
|
4
|
print $fh $in,"\t\t\"\$m\"->import();\n";
|
106
|
2
|
|
|
|
|
6
|
print $fh $in,"\t\t\tpush \@Dotiac::DTL::Addon::Loaded,\"\$m\";\n";
|
107
|
2
|
|
|
|
|
6
|
print $fh $in,"\t}\n";
|
108
|
2
|
|
|
|
|
13
|
print $fh $in,"}\n";
|
109
|
2
|
|
|
|
|
25
|
$self->SUPER::perlstring($fh,$id,$level,@_);
|
110
|
2
|
|
|
|
|
15
|
return $self->{n}->perlstring($fh,$id+1,$level,@_);
|
111
|
|
|
|
|
|
|
}
|
112
|
|
|
|
|
|
|
sub perlcount {
|
113
|
0
|
|
|
0
|
1
|
0
|
my $self=shift;
|
114
|
0
|
|
|
|
|
0
|
my $id=shift;
|
115
|
0
|
|
|
|
|
0
|
return $self->{n}->perlcount($id+1);
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
sub perleval {
|
118
|
2
|
|
|
2
|
1
|
6
|
my $self=shift;
|
119
|
2
|
|
|
|
|
14
|
my $fh=shift;
|
120
|
2
|
|
|
|
|
5
|
my $id=shift;
|
121
|
2
|
|
|
|
|
6
|
my $level=shift;
|
122
|
2
|
|
|
|
|
6
|
my $in="\t" x $level;
|
123
|
2
|
|
|
|
|
10
|
print $fh $in,"foreach my \$m (\@\$module$id) {\n";
|
124
|
2
|
|
|
|
|
7
|
print $fh $in,"\tunless (\$Dotiac::DTL::Addon::Loaded{\$m}++) {\n";
|
125
|
2
|
|
|
|
|
5
|
print $fh $in,"\t\t\"\$m\"->import();\n";
|
126
|
2
|
|
|
|
|
5
|
print $fh $in,"\t\t\tpush \@Dotiac::DTL::Addon::Loaded,\"\$m\";\n";
|
127
|
2
|
|
|
|
|
5
|
print $fh $in,"\t}\n";
|
128
|
2
|
|
|
|
|
4
|
print $fh $in,"}\n";
|
129
|
2
|
|
|
|
|
13
|
return $self->{n}->perleval($fh,$id+1,$level,@_);
|
130
|
|
|
|
|
|
|
}
|
131
|
|
|
|
|
|
|
sub perlinit {
|
132
|
2
|
|
|
2
|
1
|
6
|
my $self=shift;
|
133
|
2
|
|
|
|
|
5
|
my $fh=shift;
|
134
|
2
|
|
|
|
|
5
|
my $id=shift;
|
135
|
2
|
|
|
|
|
14
|
return $self->{n}->perlinit($fh,$id+1,@_);
|
136
|
|
|
|
|
|
|
}
|
137
|
|
|
|
|
|
|
sub next {
|
138
|
2
|
|
|
2
|
1
|
7
|
my $self=shift;
|
139
|
2
|
|
|
|
|
23
|
$self->{n}=shift;
|
140
|
|
|
|
|
|
|
}
|
141
|
|
|
|
|
|
|
sub eval {
|
142
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
143
|
0
|
|
|
|
|
|
foreach my $m (@{$self->{module}}) {
|
|
0
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
unless ($Dotiac::DTL::Addon::Loaded{$m}) {
|
145
|
0
|
|
|
|
|
|
"$m"->import();
|
146
|
0
|
|
|
|
|
|
push @Dotiac::DTL::Addon::Loaded,"$m";
|
147
|
|
|
|
|
|
|
}
|
148
|
|
|
|
|
|
|
}
|
149
|
0
|
|
|
|
|
|
$self->{n}->eval(@_);
|
150
|
|
|
|
|
|
|
}
|
151
|
|
|
|
|
|
|
1;
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
__END__
|