line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
55
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package MarpaX::Languages::IDL::AST::Value; |
5
|
1
|
|
|
1
|
|
7
|
use Scalar::Util qw/blessed/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
109
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Translate an IDL source to an AST - parse tree value helpers |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.005'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use constant { |
13
|
1
|
|
|
|
|
97
|
LEXEME_INDEX => 0 |
14
|
1
|
|
|
1
|
|
7
|
}; |
|
1
|
|
|
|
|
3
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use constant { |
17
|
1
|
|
|
|
|
386
|
LEXEME_INDEX_START => 0, |
18
|
|
|
|
|
|
|
LEXEME_INDEX_LENGTH => 1, |
19
|
|
|
|
|
|
|
LEXEME_INDEX_VALUE => 2 |
20
|
1
|
|
|
1
|
|
7
|
}; |
|
1
|
|
|
|
|
2
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
0
|
|
|
0
|
1
|
|
my ($class) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# "Contents of an entire IDL file, together with the contents of any files referenced by #include statements, forms a naming scope. |
27
|
|
|
|
|
|
|
# Definitions that do not appear inside a scope are part of the global scope. There is only a single global scope, irrespective |
28
|
|
|
|
|
|
|
# of the number of source files that form a specification." |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# Scopes can be nested. |
31
|
|
|
|
|
|
|
# |
32
|
0
|
|
|
|
|
|
my $self = { |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
bless($self, $class); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _scopedName { |
41
|
0
|
|
|
0
|
|
|
my ($self, $scopedName) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# We concatenate identifiers to have a single-like lexeme |
45
|
|
|
|
|
|
|
# |
46
|
0
|
|
|
|
|
|
my @scopedNames = (); |
47
|
0
|
|
|
|
|
|
my $firstIdentifier = $scopedName->[0]; |
48
|
0
|
|
|
|
|
|
my $lastIdentifier = $scopedName->[-1]; |
49
|
0
|
|
|
|
|
|
my $firstLexeme = $firstIdentifier->[LEXEME_INDEX]; |
50
|
0
|
|
|
|
|
|
my $lastLexeme = $lastIdentifier->[LEXEME_INDEX]; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $start = $firstLexeme->[LEXEME_INDEX_START]; |
53
|
0
|
|
|
|
|
|
my $length = $lastLexeme->[LEXEME_INDEX_START] + $lastLexeme->[LEXEME_INDEX_LENGTH] - $start; |
54
|
0
|
|
|
|
|
|
map {push(@scopedNames, $_->[LEXEME_INDEX]->[LEXEME_INDEX_VALUE])} @{$scopedName}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $value = join('::', @scopedNames); |
56
|
0
|
|
|
|
|
|
my $rc = bless [$start, $length, $value ], blessed($scopedName); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $rc; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
MarpaX::Languages::IDL::AST::Value - Translate an IDL source to an AST - parse tree value helpers |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 0.005 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This module contain some tools used by IDL to AST |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 new() |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Instanciate a new object. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Jean-Damien Durand <jeandamiendurand@free.fr> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Jean-Damien Durand. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
94
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |