line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::AMF::Parser::AMF0; |
2
|
7
|
|
|
7
|
|
38
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
223
|
|
3
|
7
|
|
|
7
|
|
39
|
use warnings; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
156
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
4036
|
use Data::AMF::IO; |
|
7
|
|
|
|
|
669
|
|
|
7
|
|
|
|
|
215
|
|
6
|
7
|
|
|
7
|
|
4522
|
use Data::AMF::Parser::AMF3; |
|
7
|
|
|
|
|
23
|
|
|
7
|
|
|
|
|
92
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant PARSERS => [ |
9
|
|
|
|
|
|
|
\&parse_number, |
10
|
|
|
|
|
|
|
\&parse_boolean, |
11
|
|
|
|
|
|
|
\&parse_string, |
12
|
|
|
|
|
|
|
\&parse_object, |
13
|
|
|
|
|
|
|
\&parse_movieclip, |
14
|
|
|
|
|
|
|
\&parse_null, |
15
|
|
|
|
|
|
|
\&parse_undefined, |
16
|
|
|
|
|
|
|
\&parse_reference, |
17
|
|
|
|
|
|
|
\&parse_ecma_array, |
18
|
0
|
|
|
|
|
0
|
sub { }, # object end |
19
|
7
|
|
|
|
|
5712
|
\&parse_strict_array, |
20
|
|
|
|
|
|
|
\&parse_date, |
21
|
|
|
|
|
|
|
\&parse_long_string, |
22
|
|
|
|
|
|
|
\&parse_unsupported, |
23
|
|
|
|
|
|
|
\&parse_recordset, |
24
|
|
|
|
|
|
|
\&parse_xml_document, |
25
|
|
|
|
|
|
|
\&parse_typed_object, |
26
|
|
|
|
|
|
|
\&parse_avmplus_object, |
27
|
7
|
|
|
7
|
|
1243
|
]; |
|
7
|
|
|
|
|
14
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub parse { |
30
|
1
|
|
|
1
|
1
|
3
|
my ($class, $data) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
2
|
my @res; |
33
|
1
|
50
|
|
|
|
23
|
my $io = ref($data) eq 'Data::AMF::IO' ? $data : Data::AMF::IO->new(data => $data); |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
108
|
while (defined( my $marker = $io->read_u8 )) { |
36
|
1
|
50
|
|
|
|
5
|
my $p = PARSERS->[$marker] or die; |
37
|
1
|
|
|
|
|
5
|
push @res, $p->($io); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
12
|
@res; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub parse_one { |
44
|
0
|
|
|
0
|
1
|
|
my ($class, $data) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my @res; |
47
|
0
|
0
|
|
|
|
|
my $io = ref($data) eq 'Data::AMF::IO' ? $data : Data::AMF::IO->new($data); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $marker = $io->read_u8; |
50
|
0
|
0
|
|
|
|
|
return unless defined $marker; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
my $p = PARSERS->[$marker] or die; |
53
|
0
|
|
|
|
|
|
$p->($io); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub parse_number { |
57
|
1
|
|
|
1
|
1
|
3
|
my $io = shift; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
6
|
$io->read_double; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub parse_boolean { |
63
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
$io->read_u8 ? 1 : 0; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub parse_string { |
69
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
$io->read_utf8; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub parse_object { |
75
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
my $obj = {}; |
78
|
0
|
|
|
|
|
0
|
push @{ $io->refs }, $obj; |
|
0
|
|
|
|
|
0
|
|
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
while (1) { |
81
|
0
|
|
|
|
|
0
|
my $len = $io->read_u16; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
0
|
if ($len == 0) { |
84
|
0
|
|
|
|
|
0
|
$io->read_u8; # object-end marker |
85
|
0
|
|
|
|
|
0
|
return $obj; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
0
|
my $key = $io->read($len); |
88
|
0
|
|
|
|
|
0
|
my $value = __PACKAGE__->parse_one($io); |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
$obj->{ $key } = $value; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
0
|
$obj; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
0
|
1
|
0
|
sub parse_movieclip { } |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub parse_null { |
99
|
0
|
|
|
0
|
1
|
0
|
undef; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub parse_undefined { |
103
|
0
|
|
|
0
|
1
|
0
|
undef; # XXX |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub parse_reference { |
107
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
108
|
0
|
|
|
|
|
0
|
my $index = $io->read_u16; |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
0
|
$io->refs->[$index] or return; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub parse_ecma_array { |
114
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
my $count = $io->read_u32; |
117
|
0
|
|
|
|
|
0
|
parse_object($io); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub parse_strict_array { |
121
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
0
|
my $count = $io->read_u32; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
my @res; |
126
|
0
|
|
|
|
|
0
|
for (1 .. $count) { |
127
|
0
|
|
|
|
|
0
|
push @res, __PACKAGE__->parse_one($io); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
0
|
my $array = \@res; |
131
|
0
|
|
|
|
|
0
|
push @{ $io->refs }, $array; |
|
0
|
|
|
|
|
0
|
|
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
0
|
$array; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub parse_date { |
137
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
0
|
my $msec = $io->read_double; |
140
|
0
|
|
|
|
|
0
|
my $tz = $io->read_s16; |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
0
|
$msec; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub parse_long_string { |
146
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
0
|
$io->read_utf8_long; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
0
|
1
|
0
|
sub parse_unsupported { } |
152
|
0
|
|
|
0
|
1
|
0
|
sub parse_recordset { } |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub parse_xml_document { |
155
|
0
|
|
|
0
|
1
|
0
|
parse_long_string(shift) # XXX |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub parse_typed_object { |
159
|
0
|
|
|
0
|
1
|
0
|
my $io = shift; |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
0
|
my $class = $io->read_utf8; |
162
|
0
|
|
|
|
|
0
|
parse_object($io); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub parse_avmplus_object { |
166
|
0
|
|
|
0
|
0
|
0
|
my $io = shift; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
0
|
my $parser = Data::AMF::Parser::AMF3->new; |
169
|
0
|
|
|
|
|
0
|
$parser->{'io'} = $io; |
170
|
0
|
|
|
|
|
0
|
$parser->read; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
__END__ |