line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=============================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# DESCRIPTION: replace variables in expressions with mapped |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, <zahatski@gmail.com> |
6
|
|
|
|
|
|
|
#=============================================================================== |
7
|
|
|
|
|
|
|
#$Id$ |
8
|
|
|
|
|
|
|
package Plosurin::Utl::ExpMapVariables; |
9
|
4
|
|
|
4
|
|
30
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
144
|
|
10
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
149
|
|
11
|
4
|
|
|
4
|
|
1495
|
use Plosurin::AbstractVisiter; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
130
|
|
12
|
4
|
|
|
4
|
|
27
|
use base 'Plosurin::AbstractVisiter'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
525
|
|
13
|
4
|
|
|
4
|
|
27
|
use Data::Dumper; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
243
|
|
14
|
4
|
|
|
4
|
|
25
|
use vars qw($AUTOLOAD); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
958
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSYS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
new Plosurin::Utl::ExpMapVariables:: |
20
|
|
|
|
|
|
|
vars=>{ 'template_variable'=>"translated_var_name" }, |
21
|
|
|
|
|
|
|
params=>{tamplate_param=>0} |
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub Var { |
25
|
4
|
|
|
4
|
0
|
80
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#variable node |
28
|
4
|
|
|
|
|
67
|
my $n = shift; |
29
|
4
|
50
|
|
|
|
17
|
return if $n->{MAPPED}; #check if current var already mapped |
30
|
4
|
|
50
|
|
|
21
|
my $vars = $self->{vars} || {}; |
31
|
4
|
100
|
|
|
|
18
|
if ( exists $vars->{ $n->{Ident} } ) { |
32
|
3
|
|
|
|
|
13
|
$n->{Ident} = $vars->{ $n->{Ident} }; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# use as param |
37
|
1
|
50
|
33
|
|
|
8
|
unless ( exists $self->{params} && defined $self->{params}) { |
38
|
1
|
|
|
|
|
6
|
$n->{Ident} = 'args{\'' . $n->{Ident} . '\'}'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
0
|
my $params = $self->{params}; |
42
|
0
|
0
|
|
|
|
0
|
unless ( exists $params->{ $n->{Ident} } ) { |
43
|
0
|
|
|
|
|
0
|
die "Unknown variable $n->{Ident}"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
0
|
|
|
|
|
0
|
$n->{Ident} = 'args{\'' . $n->{Ident} . '\'}'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
4
|
|
|
|
|
20
|
$n->{MAPPED}++; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub __default_method { |
54
|
13
|
|
|
13
|
|
23
|
my $self = shift; |
55
|
13
|
|
|
|
|
18
|
my $n = shift; |
56
|
13
|
|
|
|
|
47
|
$self->visit_childs($n); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|