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