line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package MarpaX::Languages::ECMAScript::AST::Impl::Singleton; |
5
|
1
|
|
|
1
|
|
6
|
use base 'Class::Singleton'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
756
|
|
6
|
1
|
|
|
1
|
|
1032
|
use Sereal qw/encode_sereal decode_sereal/; |
|
1
|
|
|
|
|
453
|
|
|
1
|
|
|
|
|
48
|
|
7
|
1
|
|
|
1
|
|
1126
|
use Data::Compare qw//; |
|
1
|
|
|
|
|
13020
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
11
|
use Marpa::R2 2.078000; |
|
1
|
|
|
|
|
38
|
|
|
1
|
|
|
|
|
29
|
|
9
|
1
|
|
|
1
|
|
26
|
use Log::Any qw/$log/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Singleton hosting all the grammar precompiled Marpa::R2::Scanless::G objects |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.018'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _new_instance { |
17
|
1
|
|
|
1
|
|
15
|
my ($class) = @_; |
18
|
1
|
|
|
|
|
5
|
my $self = bless {_G => {} }, $class; |
19
|
1
|
|
|
|
|
4
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub G { |
24
|
1
|
|
|
1
|
1
|
4
|
my ($self, $grammarOptionsHashp) = @_; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
50
|
|
|
5
|
$grammarOptionsHashp //= {}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# Search the key |
30
|
|
|
|
|
|
|
# |
31
|
1
|
|
|
|
|
4
|
my $key = undef; |
32
|
1
|
|
|
|
|
3
|
foreach (keys %{$self->{_G}}) { |
|
1
|
|
|
|
|
14
|
|
33
|
0
|
|
|
|
|
0
|
my $thisKey = $_; |
34
|
0
|
|
|
|
|
0
|
my $thisOptionsHashp = decode_sereal($thisKey); |
35
|
0
|
|
|
|
|
0
|
my $c = new Data::Compare($grammarOptionsHashp, $thisOptionsHashp); |
36
|
0
|
0
|
|
|
|
0
|
if ($c->Cmp) { |
37
|
0
|
|
|
|
|
0
|
$key = $thisKey; |
38
|
0
|
|
|
|
|
0
|
last; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
# Create a new key if necessary |
43
|
|
|
|
|
|
|
# |
44
|
1
|
50
|
|
|
|
5
|
if (! defined($key)) { |
45
|
1
|
|
|
|
|
9
|
$log->debugf('Creating grammar key'); |
46
|
1
|
|
|
|
|
62
|
$key = encode_sereal($grammarOptionsHashp); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
1
|
50
|
|
|
|
40
|
if (! defined($self->{_G}->{$key})) { |
50
|
|
|
|
|
|
|
# |
51
|
|
|
|
|
|
|
# Create the grammar object |
52
|
|
|
|
|
|
|
# |
53
|
1
|
|
|
|
|
5
|
$log->debugf('Creating grammar object'); |
54
|
1
|
|
|
|
|
15
|
$self->{_G}->{$key} = Marpa::R2::Scanless::G->new($grammarOptionsHashp); |
55
|
|
|
|
|
|
|
} else { |
56
|
0
|
|
|
|
|
0
|
$log->debugf('Found cached grammar object'); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
1669
|
return $self->{_G}->{$key}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |