line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Farly::ASA::Generator;
|
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
705
|
use 5.008008;
|
|
9
|
|
|
|
|
32
|
|
|
9
|
|
|
|
|
334
|
|
4
|
9
|
|
|
9
|
|
46
|
use strict;
|
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
256
|
|
5
|
9
|
|
|
9
|
|
71
|
use warnings;
|
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
274
|
|
6
|
9
|
|
|
9
|
|
46
|
use Carp;
|
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
526
|
|
7
|
9
|
|
|
9
|
|
46
|
use Scalar::Util qw(blessed);
|
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
451
|
|
8
|
9
|
|
|
9
|
|
48
|
use Log::Any qw($log);
|
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
68
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.26';
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new {
|
13
|
6
|
|
|
6
|
0
|
30
|
my ($class) = @_;
|
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
|
|
495
|
my $self = {
|
16
|
|
|
|
|
|
|
CONTAINER => Farly::Object::List->new(), # result
|
17
|
|
|
|
|
|
|
};
|
18
|
6
|
|
|
|
|
25
|
bless $self, $class;
|
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
|
|
62
|
$log->info("$self new");
|
21
|
6
|
|
|
|
|
48
|
$log->info( "$self CONTAINER is " . $self->container() );
|
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
29
|
return $self;
|
24
|
|
|
|
|
|
|
}
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub container {
|
27
|
338
|
|
|
338
|
0
|
2154
|
return $_[0]->{CONTAINER};
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub visit {
|
31
|
326
|
|
|
326
|
0
|
675
|
my ( $self, $node ) = @_;
|
32
|
|
|
|
|
|
|
# $node isa reference to the root of the AST
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# the Farly translator parses one firewall object at a time
|
35
|
326
|
|
|
|
|
1666
|
my $object = Farly::Object->new();
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# the AST root node is the 'ENTRY'
|
38
|
326
|
|
|
|
|
1416
|
$object->set( 'ENTRY', Farly::Value::String->new( ref($node) ) );
|
39
|
|
|
|
|
|
|
|
40
|
326
|
|
|
|
|
1450
|
$log->debug( "ENTRY = " . ref($node) );
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# set s of explored vertices
|
43
|
326
|
|
|
|
|
987
|
my %seen;
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#stack is all neighbors of s
|
46
|
|
|
|
|
|
|
my @stack;
|
47
|
326
|
|
|
|
|
542
|
push @stack, $node;
|
48
|
|
|
|
|
|
|
|
49
|
326
|
|
|
|
|
426
|
my $key;
|
50
|
|
|
|
|
|
|
|
51
|
326
|
|
|
|
|
909
|
while (@stack) {
|
52
|
|
|
|
|
|
|
|
53
|
1980
|
|
|
|
|
5669
|
my $node = pop @stack;
|
54
|
|
|
|
|
|
|
|
55
|
1980
|
50
|
|
|
|
6988
|
next if ( $seen{$node}++ );
|
56
|
|
|
|
|
|
|
|
57
|
1980
|
|
|
|
|
6444
|
$log->debug( "ast node class = " . ref($node) );
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# continue exploring the AST
|
60
|
1980
|
|
|
|
|
7654
|
foreach my $key ( keys %$node ) {
|
61
|
|
|
|
|
|
|
|
62
|
3298
|
|
|
|
|
5997
|
my $next = $node->{$key};
|
63
|
|
|
|
|
|
|
|
64
|
3298
|
100
|
|
|
|
5570
|
if ( $key eq '__VALUE__' ) {
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#then $next isa token
|
67
|
1644
|
|
|
|
|
4855
|
$object->set( ref($node), $next );
|
68
|
1644
|
|
|
|
|
7155
|
$log->debug( "set " . ref($node) . " = " . ref($next). " " . $next->as_string );
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
else {
|
71
|
1654
|
|
|
|
|
5022
|
push @stack, $next;
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
|
76
|
326
|
|
|
|
|
2541
|
$self->container->add($object);
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1;
|
80
|
|
|
|
|
|
|
__END__
|