wmls/gen.pm

filter: Statementstmt 25.7% 296 / 1151 Branchbran 0.0% 0 / 476 Conditioncond 0.0% 0 / 57 MC/DCmcdc 0.0% 0 / 34 Subroutinesub 50.0% 97 / 194 Podpod 0.0% 0 / 3 totaltotal 20.5% 393 / 1915 CC 258 SCAR 52.3
CC
258
Cov
18%
visitLoadConst
992.0
visitLoadConst
702.0
generate
462.0
CRAP 186.3
« wmls/lexer.pm ↑ Summary wmls/node.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3
4 package WAP::wmls::multibyte;
5
6 0 ▶sub size {
Subroutine size: not called CC=2 SCAR=17.9
7 0 my ($value) = @_;
8 0 my $size;
9 0 ▶ for ($size = 1; $value >= 0x80; $value >>= 7) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value >= 128) 0 0 0
10 0 $size ++;
11 }
12 0 return $size;
13 }
14
15 ###############################################################################
16
17 package WAP::wmls::asm;
18
19 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
20
21 1 ▶use constant INTEGER_8 => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use constant INTEGER_16 => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use constant INTEGER_32 => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use constant FLOAT_32 => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use constant UTF8_STRING => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use constant EMPTY_STRING => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use constant STRING => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
28
29 1 our ($OUT, $VERBOSE);
30
31 0 ▶sub _put_mb {
Subroutine _put_mb: not called CC=2 SCAR=17.9
32 0 my ($value) = @_;
33 0 my $tmp = chr($value & 0x7f);
34 0 ▶ for ($value >>= 7; $value != 0; $value >>= 7) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value != 0) 0 0 0
35 0 $tmp = chr(0x80 | ($value & 0x7f)) . $tmp;
36 }
37 0 print $OUT $tmp;
38 0 return;
39 }
40
41 0 ▶sub _put_uint8 {
Subroutine _put_uint8: not called CC=1 SCAR=6.9
42 0 my ($value) = @_;
43 0 print $OUT chr $value;
44 0 return;
45 }
46
47 0 ▶sub _put_int8 {
Subroutine _put_int8: not called CC=1 SCAR=6.9
48 0 my ($value) = @_;
49 0 print $OUT pack 'c', $value;
50 0 return;
51 }
52
53 0 ▶sub _put_uint16 {
Subroutine _put_uint16: not called CC=1 SCAR=6.9
54 0 my ($value) = @_;
55 0 print $OUT pack 'n', $value;
56 0 return;
57 }
58
59 0 ▶sub _put_int16 {
Subroutine _put_int16: not called CC=1 SCAR=6.9
60 0 my ($value) = @_;
61 0 print $OUT pack 'n', unpack 'v', pack 's', $value;
62 0 return;
63 }
64
65 0 ▶sub _put_int32 {
Subroutine _put_int32: not called CC=1 SCAR=6.9
66 0 my ($value) = @_;
67 0 print $OUT pack 'N', unpack 'V', pack 'l', $value;
68 0 return;
69 }
70
71 0 ▶sub _put_float32 {
Subroutine _put_float32: not called CC=1 SCAR=6.9
72 0 my ($value) = @_;
73 0 print $OUT pack 'f', $value;
74 0 return;
75 }
76
77 0 ▶sub _put_string {
Subroutine _put_string: not called CC=1 SCAR=6.9
78 0 my ($value) = @_;
79 0 print $OUT $value;
80 0 return;
81 }
82
83 1 my @mnemo = (
84 '?',
85 'JUMP_FW',
86 'JUMP_FW_W',
87 'JUMP_BW',
88 'JUMP_BW_W',
89 'TJUMP_FW',
90 'TJUMP_FW_W',
91 'TJUMP_BW',
92 'TJUMP_BW_W',
93 'CALL',
94 'CALL_LIB',
95 'CALL_LIB_W',
96 'CALL_URL',
97 'CALL_URL_W',
98 'LOAD_VAR',
99 'STORE_VAR',
100 'INCR_VAR',
101 'DECR_VAR',
102 'LOAD_CONST',
103 'LOAD_CONST_W',
104 'CONST_0',
105 'CONST_1',
106 'CONST_M1',
107 'CONST_ES',
108 'CONST_INVALID',
109 'CONST_TRUE',
110 'CONST_FALSE',
111 'INCR',
112 'DECR',
113 'ADD_ASG',
114 'SUB_ASG',
115 'UMINUS',
116 'ADD',
117 'SUB',
118 'MUL',
119 'DIV',
120 'IDIV',
121 'REM',
122 'B_AND',
123 'B_OR',
124 'B_XOR',
125 'B_NOT',
126 'B_LSHIFT',
127 'B_RSSHIFT',
128 'B_RSZSHIFT',
129 'EQ',
130 'LE',
131 'LT',
132 'GE',
133 'GT',
134 'NE',
135 'NOT',
136 'SCAND',
137 'SCOR',
138 'TOBOOL',
139 'POP',
140 'TYPEOF',
141 'ISVALID',
142 'RETURN',
143 'RETURN_ES',
144 'DEBUG',
145 '?',
146 '?',
147 '?',
148 'STORE_VAR_S',
149 '?',
150 '?',
151 '?',
152 '?',
153 '?',
154 '?',
155 '?',
156 '?',
157 '?',
158 '?',
159 '?',
160 '?',
161 '?',
162 '?',
163 '?',
164 'LOAD_CONST_S',
165 '?',
166 '?',
167 '?',
168 '?',
169 '?',
170 '?',
171 '?',
172 '?',
173 '?',
174 '?',
175 '?',
176 '?',
177 '?',
178 '?',
179 '?',
180 'CALL_S',
181 '?',
182 '?',
183 '?',
184 '?',
185 '?',
186 '?',
187 '?',
188 'CALL_LIB_S',
189 '?',
190 '?',
191 '?',
192 '?',
193 '?',
194 '?',
195 '?',
196 'INCR_VAR_S',
197 '?',
198 '?',
199 '?',
200 '?',
201 '?',
202 '?',
203 '?',
204 '?',
205 '?',
206 '?',
207 '?',
208 '?',
209 '?',
210 '?',
211 '?',
212 'JUMP_FW_S',
213 '?',
214 '?',
215 '?',
216 '?',
217 '?',
218 '?',
219 '?',
220 '?',
221 '?',
222 '?',
223 '?',
224 '?',
225 '?',
226 '?',
227 '?',
228 '?',
229 '?',
230 '?',
231 '?',
232 '?',
233 '?',
234 '?',
235 '?',
236 '?',
237 '?',
238 '?',
239 '?',
240 '?',
241 '?',
242 '?',
243 '?',
244 'JUMP_BW_S',
245 '?',
246 '?',
247 '?',
248 '?',
249 '?',
250 '?',
251 '?',
252 '?',
253 '?',
254 '?',
255 '?',
256 '?',
257 '?',
258 '?',
259 '?',
260 '?',
261 '?',
262 '?',
263 '?',
264 '?',
265 '?',
266 '?',
267 '?',
268 '?',
269 '?',
270 '?',
271 '?',
272 '?',
273 '?',
274 '?',
275 '?',
276 'TJUMP_FW_S',
277 '?',
278 '?',
279 '?',
280 '?',
281 '?',
282 '?',
283 '?',
284 '?',
285 '?',
286 '?',
287 '?',
288 '?',
289 '?',
290 '?',
291 '?',
292 '?',
293 '?',
294 '?',
295 '?',
296 '?',
297 '?',
298 '?',
299 '?',
300 '?',
301 '?',
302 '?',
303 '?',
304 '?',
305 '?',
306 '?',
307 '?',
308 'LOAD_VAR_S',
309 '?',
310 '?',
311 '?',
312 '?',
313 '?',
314 '?',
315 '?',
316 '?',
317 '?',
318 '?',
319 '?',
320 '?',
321 '?',
322 '?',
323 '?',
324 '?',
325 '?',
326 '?',
327 '?',
328 '?',
329 '?',
330 '?',
331 '?',
332 '?',
333 '?',
334 '?',
335 '?',
336 '?',
337 '?',
338 '?',
339 '?',
340 );
341
342 0 ▶sub asmOpcode1 {
Subroutine asmOpcode1: not called CC=2 SCAR=17.9
343 0 my ($bytecode) = @_;
344 0 ▶ print $VERBOSE sprintf("%-14s\t", $mnemo[$bytecode])
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
345 if (defined $VERBOSE);
346 0 _put_uint8($bytecode);
347 0 return;
348 }
349
350 0 ▶sub asmOpcode1s {
Subroutine asmOpcode1s: not called CC=2 SCAR=17.9
351 0 my ($bytecode, $offset) = @_;
352 0 ▶ print $VERBOSE sprintf("%-14s%7u\t", $mnemo[$bytecode], $offset)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
353 if (defined $VERBOSE);
354 0 _put_uint8(($bytecode | $offset));
355 0 return;
356 }
357
358 0 ▶sub asmOpcode2 {
Subroutine asmOpcode2: not called CC=2 SCAR=17.9
359 0 my ($bytecode, $offset) = @_;
360 # LOAD_CONST
361 0 ▶ print $VERBOSE sprintf("%-14s%7u\t", $mnemo[$bytecode], $offset)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
362 if (defined $VERBOSE);
363 0 _put_uint8($bytecode);
364 0 _put_uint8($offset);
365 0 return;
366 }
367
368 0 ▶sub asmOpcode2s {
Subroutine asmOpcode2s: not called CC=2 SCAR=17.9
369 0 my ($bytecode, $idx1, $idx2) = @_;
370 # CALL_LIB_S
371 0 ▶ print $VERBOSE sprintf("%-14s%7u%7u\t", $mnemo[$bytecode], $idx1, $idx2)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
372 if (defined $VERBOSE);
373 0 _put_uint8($bytecode | $idx1);
374 0 _put_uint8($idx2);
375 0 return;
376 }
377
378 0 ▶sub asmOpcode3 {
Subroutine asmOpcode3: not called CC=2 SCAR=17.9
379 0 my ($bytecode, $idx1, $idx2) = @_;
380 # CALL_LIB
381 0 ▶ print $VERBOSE sprintf("%-14s%7u%7u\t", $mnemo[$bytecode], $idx1, $idx2)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
382 if (defined $VERBOSE);
383 0 _put_uint8($bytecode);
384 0 _put_uint8($idx1);
385 0 _put_uint8($idx2);
386 0 return;
387 }
388
389 0 ▶sub asmOpcode3w {
Subroutine asmOpcode3w: not called CC=2 SCAR=17.9
390 0 my ($bytecode, $offset) = @_;
391 # LOAD_CONST_W, JUMP_xW_W
392 0 ▶ print $VERBOSE sprintf("%-14s%7u\t", $mnemo[$bytecode], $offset)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
393 if (defined $VERBOSE);
394 0 _put_uint8($bytecode);
395 0 _put_uint16($offset);
396 0 return;
397 }
398
399 0 ▶sub asmOpcode4 {
Subroutine asmOpcode4: not called CC=2 SCAR=17.9
400 0 my ($bytecode, $idx1, $idx2, $idx3) = @_;
401 # CALL_URL
402 0 ▶ print $VERBOSE sprintf("%-14s%7u%7u%7u\t", $mnemo[$bytecode], $idx1, $idx2, $idx3)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
403 if (defined $VERBOSE);
404 0 _put_uint8($bytecode);
405 0 _put_uint8($idx1);
406 0 _put_uint8($idx2);
407 0 _put_uint8($idx3);
408 0 return;
409 }
410
411 0 ▶sub asmOpcode4w {
Subroutine asmOpcode4w: not called CC=2 SCAR=17.9
412 0 my ($bytecode, $idx1, $idx2) = @_;
413 # CALL_LIB_W
414 0 ▶ print $VERBOSE sprintf("%-14s%7u%7u\t", $mnemo[$bytecode], $idx1, $idx2)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
415 if (defined $VERBOSE);
416 0 _put_uint8($bytecode);
417 0 _put_uint8($idx1);
418 0 _put_uint16($idx2);
419 0 return;
420 }
421
422 0 ▶sub asmOpcode6 {
Subroutine asmOpcode6: not called CC=2 SCAR=17.9
423 0 my ($bytecode, $idx1, $idx2, $idx3) = @_;
424 # CALL_URL_W
425 0 ▶ print $VERBOSE sprintf("%-14s%7u%7u%7u\t", $mnemo[$bytecode], $idx1, $idx2, $idx3)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
426 if (defined $VERBOSE);
427 0 _put_uint8($bytecode);
428 0 _put_uint16($idx1);
429 0 _put_uint16($idx2);
430 0 _put_uint8($idx3);
431 0 return;
432 }
433
434 0 ▶sub asmByte {
Subroutine asmByte: not called CC=2 SCAR=17.9
435 0 my ($str, $value) = @_;
436 0 ▶ print $VERBOSE "$str $value\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
437 if (defined $VERBOSE);
438 0 _put_uint8($value);
439 0 return;
440 }
441
442 0 ▶sub asmMultiByte {
Subroutine asmMultiByte: not called CC=2 SCAR=17.9
443 0 my ($str, $value) = @_;
444 0 ▶ print $VERBOSE "$str $value\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
445 if (defined $VERBOSE);
446 0 _put_mb($value);
447 0 return;
448 }
449
450 0 ▶sub asmFunctionName {
Subroutine asmFunctionName: not called CC=2 SCAR=17.9
451 0 my ($idx, $name) = @_;
452 0 my $len = length $name;
453 0 ▶ print $VERBOSE "$idx\t[$len]\t$name\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
454 if (defined $VERBOSE);
455 0 _put_uint8($idx);
456 0 _put_uint8($len);
457 0 _put_string($name);
458 0 return;
459 }
460
461 0 ▶sub asmPragma1 {
Subroutine asmPragma1: not called CC=2 SCAR=17.9
462 0 my ($type, $value1) = @_;
463 0 ▶ print $VERBOSE sprintf("prag%7u%7u\n", $type, $value1)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
464 if (defined $VERBOSE);
465 0 _put_uint8($type);
466 0 _put_mb($value1);
467 0 return;
468 }
469
470 0 ▶sub asmPragma2 {
Subroutine asmPragma2: not called CC=2 SCAR=17.9
471 0 my ($type, $value1, $value2) = @_;
472 0 ▶ print $VERBOSE sprintf("prag%7u%7u%7u\n", $type, $value1, $value2)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
473 if (defined $VERBOSE);
474 0 _put_uint8($type);
475 0 _put_mb($value1);
476 0 _put_mb($value2);
477 0 return;
478 }
479
480 0 ▶sub asmPragma3 {
Subroutine asmPragma3: not called CC=2 SCAR=17.9
481 0 my ($type, $value1, $value2, $value3) = @_;
482 0 ▶ print $VERBOSE sprintf("prag%7u%7u%7u%7u\n", $type, $value1, $value2, $value3)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
483 if (defined $VERBOSE);
484 0 _put_uint8($type);
485 0 _put_mb($value1);
486 0 _put_mb($value2);
487 0 _put_mb($value3);
488 0 return;
489 }
490
491 0 ▶sub asmConstantInteger8 {
Subroutine asmConstantInteger8: not called CC=2 SCAR=17.9
492 0 my ($idx, $value) = @_;
493 0 ▶ print $VERBOSE sprintf("cst%-7u%7u%7d\n", $idx, INTEGER_8, $value)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
494 if (defined $VERBOSE);
495 0 _put_uint8(INTEGER_8);
496 0 _put_int8($value);
497 0 return;
498 }
499
500 0 ▶sub asmConstantInteger16 {
Subroutine asmConstantInteger16: not called CC=2 SCAR=17.9
501 0 my ($idx, $value) = @_;
502 0 ▶ print $VERBOSE sprintf("cst%-7u%7u%7d\n", $idx, INTEGER_16, $value)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
503 if (defined $VERBOSE);
504 0 _put_uint8(INTEGER_16);
505 0 _put_int16($value);
506 0 return;
507 }
508
509 0 ▶sub asmConstantInteger32 {
Subroutine asmConstantInteger32: not called CC=2 SCAR=17.9
510 0 my ($idx, $value) = @_;
511 0 ▶ print $VERBOSE sprintf("cst%-7u%7u%7d\n", $idx, INTEGER_32, $value)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
512 if (defined $VERBOSE);
513 0 _put_uint8(INTEGER_32);
514 0 _put_int32($value);
515 0 return;
516 }
517
518 0 ▶sub asmConstantFloat32 {
Subroutine asmConstantFloat32: not called CC=2 SCAR=17.9
519 0 my ($idx, $value) = @_;
520 0 ▶ print $VERBOSE sprintf("cst%-7u%7u %f\n", $idx, FLOAT_32, $value)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
521 if (defined $VERBOSE);
522 0 _put_uint8(FLOAT_32);
523 0 _put_float32($value);
524 0 return;
525 }
526
527 0 ▶sub asmConstantStringUTF8 {
Subroutine asmConstantStringUTF8: not called CC=2 SCAR=17.9
528 0 my ($idx, $value) = @_;
529 0 my $octets = encode('utf8', $value);
530 0 my $len = length $octets;
531 0 ▶ print $VERBOSE sprintf("cst%-7u%7u\t[%u]\t%s\n", $idx, UTF8_STRING, $len, $value)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
532 if (defined $VERBOSE);
533 0 _put_uint8(UTF8_STRING);
534 0 _put_mb($len);
535 0 _put_string($octets);
536 0 return;
537 }
538
539 0 ▶sub asmConstantString {
Subroutine asmConstantString: not called CC=2 SCAR=17.9
540 0 my ($idx, $value) = @_;
541 0 my $len = length $value;
542 0 ▶ print $VERBOSE sprintf("cst%-7u%7u\t[%u]\t%s\n", $idx, STRING, $len, $value)
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
543 if (defined $VERBOSE);
544 0 _put_uint8(STRING);
545 0 _put_mb($len);
546 0 _put_string($value);
547 0 return;
548 }
549
550 0 ▶sub asmComment {
Subroutine asmComment: not called CC=4 SCAR=30.0
551 0 my ($comment) = @_;
552 0 ▶ if (defined $comment) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $comment) { } 0 0 0
553 0 ▶ print $VERBOSE "; $comment\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
554 if (defined $VERBOSE);
555 }
556 else {
557 0 ▶ print $VERBOSE "\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $WAP::wmls::asm::VERBOSE 0 0 0
558 if (defined $VERBOSE);
559 }
560 0 return;
561 }
562
563 ###############################################################################
564
565 package WAP::wmls::verbose;
566
567 1 my $_Lineno = 0;
568 1 my $IN;
569
570 0 ▶sub Init {
Subroutine Init: not called CC=2 SCAR=17.9
571 0 my ($filename) = @_;
572 0 ▶ open $IN, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $IN, "<", $filename or die "can't open $filename ($!).\n" 0 0 0
573 or die "can't open $filename ($!).\n";
574 0 return;
575 }
576
577 0 ▶sub Source {
Subroutine Source: not called CC=4 SCAR=30.0
578 0 my ($opcode) = @_;
579 0 ▶ if (defined $WAP::wmls::asm::VERBOSE) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $WAP::wmls::asm::VERBOSE) 0 0 0
580 0 my $lineno = $opcode->{Lineno};
581 0 ▶ while ($lineno > $_Lineno) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lineno > $_Lineno) 0 0 0
582 0 my $line = <$IN>;
583 0 print $WAP::wmls::asm::VERBOSE sprintf(";line:%5d;\t", $_Lineno + 1);
584 0 ▶ print $WAP::wmls::asm::VERBOSE $line if ($line);
Branch: 1 branch
BranchTrueFalseTotal
if $line 0 0 0
585 0 $_Lineno ++;
586 }
587 }
588 0 return;
589 }
590
591 0 ▶sub End {
Subroutine End: not called CC=1 SCAR=6.9
592 0 close $IN;
593 0 return;
594 }
595
596 ###############################################################################
597
598 package WAP::wmls::constantVisitor;
599
600 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
601
602 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
603
604 1 ▶use constant INT8_MIN => -128;
Subroutine BEGIN: called CC=1 SCAR=0.0
605 1 ▶use constant INT8_MAX => 127;
Subroutine BEGIN: called CC=1 SCAR=0.0
606 1 ▶use constant INT16_MIN => -32768;
Subroutine BEGIN: called CC=1 SCAR=0.0
607 1 ▶use constant INT16_MAX => 32767;
Subroutine BEGIN: called CC=1 SCAR=0.0
608
609 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
610 0 my $proto = shift;
611 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
612 0 my $self = {};
613 0 bless($self, $class);
614 0 my ($parser) = @_;
615 0 $self->{parser} = $parser;
616 0 $self->{nb} = 0;
617 0 $self->{size} = 0;
618 0 $self->{action} = 0;
619 $self->{cst} = {
620 0 TYPE_INTEGER => {},
621 TYPE_FLOAT => {},
622 TYPE_STRING => {},
623 TYPE_UTF8_STRING => {},
624 };
625 0 return $self;
626 }
627
628 0 ▶sub visitUrl {
Subroutine visitUrl: not called CC=4 SCAR=30.0
629 0 my $self = shift;
630 0 my ($opcode) = @_;
631 0 my $def = $opcode->{Definition};
632 0 ▶ if ($def->{NbUse} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($def->{'NbUse'} == 0) { } 0 0 0
633 0 ▶ unless ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"action"}) 0 0 0
634 0 $self->{parser}->genWarning($opcode, "Unreferenced url - $def->{Symbol}.\n");
635 }
636 }
637 else {
638 0 ▶ unless ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"action"}) 0 0 0
639 0 $def->{Index} = $self->{nb};
640 }
641 0 $opcode->{Value}->visit($self); # LOAD_CONST
642 }
643 0 return;
644 }
645
646 0 ▶sub visitAccessDomain {
Subroutine visitAccessDomain: not called CC=1 SCAR=6.9
647 0 my $self = shift;
648 0 my ($opcode) = @_;
649 0 $opcode->{Value}->visit($self); # LOAD_CONST
650 0 return;
651 }
652
653 0 ▶sub visitAccessPath {
Subroutine visitAccessPath: not called CC=1 SCAR=6.9
654 0 my $self = shift;
655 0 my ($opcode) = @_;
656 0 $opcode->{Value}->visit($self); # LOAD_CONST
657 0 return;
658 }
659
660 0 ▶sub visitMetaName {}
Subroutine visitMetaName: not called CC=1 SCAR=0.0
661
662 0 ▶sub visitMetaHttpEquiv {}
Subroutine visitMetaHttpEquiv: not called CC=1 SCAR=0.0
663
664 0 ▶sub visitMetaUserAgent {
Subroutine visitMetaUserAgent: not called CC=1 SCAR=6.9
665 0 my $self = shift;
666 0 my ($opcode) = @_;
667 0 $opcode->{Value}->visit($self); # LOAD_CONST
668 0 return;
669 }
670
671 0 ▶sub visitFunction {
Subroutine visitFunction: not called CC=2 SCAR=17.9
672 0 my $self = shift;
673 0 my ($opcode) = @_;
674 $opcode->{Value}->visitActive($self)
675 0 ▶ if (defined $opcode->{Value});
Branch: 1 branch
BranchTrueFalseTotal
if defined $opcode->{"Value"} 0 0 0
676 0 return;
677 }
678
679 0 ▶sub visitLoadVar {}
Subroutine visitLoadVar: not called CC=1 SCAR=0.0
680
681 0 ▶sub visitStoreVar {}
Subroutine visitStoreVar: not called CC=1 SCAR=0.0
682
683 0 ▶sub visitIncrVar {}
Subroutine visitIncrVar: not called CC=1 SCAR=0.0
684
685 0 ▶sub visitDecrVar {}
Subroutine visitDecrVar: not called CC=1 SCAR=0.0
686
687 0 ▶sub visitAddAsg {}
Subroutine visitAddAsg: not called CC=1 SCAR=0.0
688
689 0 ▶sub visitSubAsg {}
Subroutine visitSubAsg: not called CC=1 SCAR=0.0
690
691 0 ▶sub visitLabel {}
Subroutine visitLabel: not called CC=1 SCAR=0.0
692
693 0 ▶sub visitPop {}
Subroutine visitPop: not called CC=1 SCAR=0.0
694
695 0 ▶sub visitToBool {}
Subroutine visitToBool: not called CC=1 SCAR=0.0
696
697 0 ▶sub visitScOr {}
Subroutine visitScOr: not called CC=1 SCAR=0.0
698
699 0 ▶sub visitScAnd {}
Subroutine visitScAnd: not called CC=1 SCAR=0.0
700
701 0 ▶sub visitReturn {}
Subroutine visitReturn: not called CC=1 SCAR=0.0
702
703 0 ▶sub visitReturnES {}
Subroutine visitReturnES: not called CC=1 SCAR=0.0
704
705 0 ▶sub visitCall {}
Subroutine visitCall: not called CC=1 SCAR=0.0
706
707 0 ▶sub visitCallLib {}
Subroutine visitCallLib: not called CC=1 SCAR=0.0
708
709 0 ▶sub visitCallUrl {
Subroutine visitCallUrl: not called CC=5 SCAR=34.0
710 0 my $self = shift;
711 0 my ($opcode) = @_;
712 0 my $def = $opcode->{Definition};
713 0 my $value = $def->{FunctionName};
714 0 ▶ unless ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"action"}) 0 0 0
715 0 ▶ if (exists $self->{cst}->{TYPE_UTF8_STRING}{$value}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"cst"}{"TYPE_UTF8_STRING"}{$value}) 0 0 0
716 0 $opcode->{Index} = $self->{cst}->{TYPE_UTF8_STRING}{$value};
717 0 $opcode->{Doublon} = 1;
718 0 return;
719 }
720 }
721 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
722 WAP::wmls::asm::asmConstantString($opcode->{Index}, $value)
723 0 ▶ unless (exists $opcode->{Doublon});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opcode->{"Doublon"} 0 0 0
724 }
725 else {
726 0 $opcode->{Index} = $self->{nb};
727 0 $self->{cst}->{TYPE_UTF8_STRING}{$value} = $self->{nb};
728 0 $self->{size} += 1;
729 0 $self->{size} += WAP::wmls::multibyte::size(length $value);
730 0 $self->{size} += length $value;
731 0 $self->{nb} += 1;
732 }
733 0 return;
734 }
735
736 0 ▶sub visitJump {}
Subroutine visitJump: not called CC=1 SCAR=0.0
737
738 0 ▶sub visitFalseJump {}
Subroutine visitFalseJump: not called CC=1 SCAR=0.0
739
740 0 ▶sub visitUnaryOp {}
Subroutine visitUnaryOp: not called CC=1 SCAR=0.0
741
742 0 ▶sub visitBinaryOp {}
Subroutine visitBinaryOp: not called CC=1 SCAR=0.0
743
744 0 ▶sub visitLoadConst {
Subroutine visitLoadConst: not called CC=31 SCAR=69.0
745 0 my $self = shift;
746 0 my ($opcode) = @_;
747 0 my $type = $opcode->{TypeDef};
748 0 ▶ if ($type eq 'TYPE_INTEGER') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'TYPE_INTEGER') { } 0 0 0
elsif ($type eq 'TYPE_FLOAT') { } 0 0 0
749 0 $self->{parser}->checkRangeInteger($opcode);
750 }
751 elsif ($type eq 'TYPE_FLOAT') {
752 0 $self->{parser}->checkRangeFloat($opcode);
753 }
754 0 $type = $opcode->{TypeDef};
755 0 ▶ if ( $type eq 'TYPE_BOOLEAN'
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "TYPE_BOOLEAN" or $type eq "TYPE_INVALID") 0 0 0
Condition0%0/3
$type eq "TYPE_BOOLEAN" or $type eq "TYPE_INVALID"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "TYPE_BOOLEAN" or $type eq "TYPE_INVALID"
$type eq "TYPE_BOOLEAN" $type eq "TYPE_INVALID"
Truth table0%0/3
A or B
A= $type eq "TYPE_BOOLEAN"B= $type eq "TYPE_INVALID"
ABresult
1X1
011
000
756 or $type eq 'TYPE_INVALID' ) {
757 0 return;
758 }
759 0 my $value = $opcode->{Value};
760 0 ▶ unless ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"action"}) 0 0 0
761 0 ▶ if (exists $self->{cst}->{$type}{$value}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"cst"}{$type}{$value}) 0 0 0
762 0 $opcode->{Index} = $self->{cst}->{$type}{$value};
763 0 $opcode->{Doublon} = 1;
764 0 return;
765 }
766 }
767 0 ▶ if ($type eq 'TYPE_INTEGER') {
Branch: 4 branches
BranchTrueFalseTotal
if ($type eq 'TYPE_INTEGER') { } 0 0 0
elsif ($type eq 'TYPE_FLOAT') { } 0 0 0
elsif ($type eq 'TYPE_UTF8_STRING') { } 0 0 0
elsif ($type eq 'TYPE_STRING') { } 0 0 0
768 0 ▶ return if ($value >= -1 and $value <= 1);
Branch: 1 branch
BranchTrueFalseTotal
if $value >= -1 and $value <= 1 0 0 0
Condition0%0/3
$value >= -1 and $value <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$value >= -1 and $value <= 1
$value >= -1 $value <= 1
Truth table0%0/3
A and B
A= $value >= -1B= $value <= 1
ABresult
0X0
100
111
769 0 ▶ if ($value >= INT8_MIN and $value <= INT8_MAX) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value >= -128 and $value <= 127) { } 0 0 0
elsif ($value >= -32768 and $value <= 32767) { } 0 0 0
Condition0%0/3
$value >= -128 and $value <= 127
!ll&&!rl&&r
000
MC/DC0%0/2
$value >= -128 and $value <= 127
$value >= -128 $value <= 127
Truth table0%0/3
A and B
A= $value >= -128B= $value <= 127
ABresult
0X0
100
111
770 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
771 WAP::wmls::asm::asmConstantInteger8($opcode->{Index}, $value)
772 0 ▶ unless (exists $opcode->{Doublon});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opcode->{"Doublon"} 0 0 0
773 }
774 else {
775 0 $opcode->{Index} = $self->{nb};
776 0 $self->{cst}->{TYPE_INTEGER}{$value} = $self->{nb};
777 0 $self->{size} += 2;
778 0 $self->{nb} += 1;
779 }
780 }
781 ▶ elsif ($value >= INT16_MIN and $value <= INT16_MAX) {
Condition0%0/3
$value >= -32768 and $value <= 32767
!ll&&!rl&&r
000
MC/DC0%0/2
$value >= -32768 and $value <= 32767
$value >= -32768 $value <= 32767
Truth table0%0/3
A and B
A= $value >= -32768B= $value <= 32767
ABresult
0X0
100
111
782 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
783 WAP::wmls::asm::asmConstantInteger16($opcode->{Index}, $value)
784 0 ▶ unless (exists $opcode->{Doublon});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opcode->{"Doublon"} 0 0 0
785 }
786 else {
787 0 $opcode->{Index} = $self->{nb};
788 0 $self->{cst}->{TYPE_INTEGER}{$value} = $self->{nb};
789 0 $self->{size} += 3;
790 0 $self->{nb} += 1;
791 }
792 }
793 else {
794 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
795 WAP::wmls::asm::asmConstantInteger32($opcode->{Index}, $value)
796 0 ▶ unless (exists $opcode->{Doublon});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opcode->{"Doublon"} 0 0 0
797 }
798 else {
799 0 $opcode->{Index} = $self->{nb};
800 0 $self->{cst}->{TYPE_INTEGER}{$value} = $self->{nb};
801 0 $self->{size} += 5;
802 0 $self->{nb} += 1;
803 }
804 }
805 }
806 elsif ($type eq 'TYPE_FLOAT') {
807 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
808 WAP::wmls::asm::asmConstantFloat32($opcode->{Index}, $value)
809 0 ▶ unless (exists $opcode->{Doublon});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opcode->{"Doublon"} 0 0 0
810 }
811 else {
812 0 $opcode->{Index} = $self->{nb};
813 0 $self->{cst}->{TYPE_FLOAT}{$value} = $self->{nb};
814 0 $self->{size} += 5;
815 0 $self->{nb} += 1;
816 }
817 }
818 elsif ($type eq 'TYPE_UTF8_STRING') {
819 0 ▶ return unless (length $value);
Branch: 1 branch
BranchTrueFalseTotal
unless length $value 0 0 0
820 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
821 WAP::wmls::asm::asmConstantStringUTF8($opcode->{Index}, $value)
822 0 ▶ unless (exists $opcode->{Doublon});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opcode->{"Doublon"} 0 0 0
823 }
824 else {
825 0 my $octets = encode('utf8', $value);
826 0 $opcode->{Index} = $self->{nb};
827 0 $self->{cst}->{TYPE_UTF8_STRING}{$value} = $self->{nb};
828 0 $self->{size} += 1;
829 0 $self->{size} += WAP::wmls::multibyte::size(length $octets);
830 0 $self->{size} += length $octets;
831 0 $self->{nb} += 1;
832 }
833 }
834 elsif ($type eq 'TYPE_STRING') {
835 0 ▶ return unless (length $value);
Branch: 1 branch
BranchTrueFalseTotal
unless length $value 0 0 0
836 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
837 WAP::wmls::asm::asmConstantString($opcode->{Index}, $value)
838 0 ▶ unless (exists $opcode->{Doublon});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opcode->{"Doublon"} 0 0 0
839 }
840 else {
841 0 $opcode->{Index} = $self->{nb};
842 0 $self->{cst}->{TYPE_STRING}{$value} = $self->{nb};
843 0 $self->{size} += 1;
844 0 $self->{size} += WAP::wmls::multibyte::size(length $value);
845 0 $self->{size} += length $value;
846 0 $self->{nb} += 1;
847 }
848 }
849 else {
850 0 croak "INTERNAL ERROR in constantVisitor::visitLoadConst $type $value\n";
851 }
852 0 return;
853 }
854
855 ###############################################################################
856
857 package WAP::wmls::pragmaVisitor;
858
859 1 ▶use constant ACCESS_DOMAIN => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
860 1 ▶use constant ACCESS_PATH => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
861 1 ▶use constant USER_AGENT_PROPERTY => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
862 1 ▶use constant USER_AGENT_PROPERTY_AND_SCHEME => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
863
864 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
865 0 my $proto = shift;
866 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
867 0 my $self = {};
868 0 bless($self, $class);
869 0 my ($parser) = @_;
870 0 $self->{parser} = $parser;
871 0 $self->{nb} = 0;
872 0 $self->{size} = 0;
873 0 $self->{action} = 0;
874 0 return $self;
875 }
876
877 0 ▶sub visitUrl {}
Subroutine visitUrl: not called CC=1 SCAR=0.0
878
879 0 ▶sub visitAccessDomain {
Subroutine visitAccessDomain: not called CC=2 SCAR=17.9
880 0 my $self = shift;
881 0 my ($opcode) = @_;
882 0 my $pragma = $opcode->{Value};
883 0 my $value = $pragma->{OpCode}->{Index};
884 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
885 0 WAP::wmls::verbose::Source($opcode);
886 0 WAP::wmls::asm::asmPragma1(ACCESS_DOMAIN, $value);
887 }
888 else {
889 0 $self->{size} += 1;
890 0 $self->{size} += WAP::wmls::multibyte::size($value);
891 0 $self->{nb} += 1;
892 }
893 0 return;
894 }
895
896 0 ▶sub visitAccessPath {
Subroutine visitAccessPath: not called CC=2 SCAR=17.9
897 0 my $self = shift;
898 0 my ($opcode) = @_;
899 0 my $pragma = $opcode->{Value};
900 0 my $value = $pragma->{OpCode}->{Index};
901 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
902 0 WAP::wmls::verbose::Source($opcode);
903 0 WAP::wmls::asm::asmPragma1(ACCESS_PATH, $value);
904 }
905 else {
906 0 $self->{size} += 1;
907 0 $self->{size} += WAP::wmls::multibyte::size($value);
908 0 $self->{nb} += 1;
909 }
910 0 return;
911 }
912
913 0 ▶sub visitMetaName {}
Subroutine visitMetaName: not called CC=1 SCAR=0.0
914
915 0 ▶sub visitMetaHttpEquiv {}
Subroutine visitMetaHttpEquiv: not called CC=1 SCAR=0.0
916
917 0 ▶sub visitMetaUserAgent {
Subroutine visitMetaUserAgent: not called CC=4 SCAR=30.0
918 0 my $self = shift;
919 0 my ($opcode) = @_;
920 0 my $pragma1 = $opcode->{Value};
921 0 my $value1 = $pragma1->{OpCode}->{Index};
922 0 my $pragma2 = $pragma1->{Next};
923 0 my $value2 = $pragma2->{OpCode}->{Index};
924 0 my $pragma3 = $pragma2->{Next};
925 0 ▶ if (defined $pragma3) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pragma3) { } 0 0 0
926 0 my $value3 = $pragma3->{OpCode}->{Index};
927 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
928 0 WAP::wmls::verbose::Source($opcode);
929 0 WAP::wmls::asm::asmPragma3(USER_AGENT_PROPERTY_AND_SCHEME, $value1, $value2, $value3);
930 }
931 else {
932 0 $self->{size} += 1;
933 0 $self->{size} += WAP::wmls::multibyte::size($value1);
934 0 $self->{size} += WAP::wmls::multibyte::size($value2);
935 0 $self->{size} += WAP::wmls::multibyte::size($value3);
936 0 $self->{nb} += 1;
937 }
938 }
939 else {
940 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
941 0 WAP::wmls::verbose::Source($opcode);
942 0 WAP::wmls::asm::asmPragma2(USER_AGENT_PROPERTY, $value1, $value2);
943 }
944 else {
945 0 $self->{size} += 1;
946 0 $self->{size} += WAP::wmls::multibyte::size($value1);
947 0 $self->{size} += WAP::wmls::multibyte::size($value2);
948 0 $self->{nb} += 1;
949 }
950 }
951 0 return;
952 }
953
954 ###############################################################################
955
956 package WAP::wmls::codeVisitor;
957
958 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
959
960 1 ▶use constant JUMP_FW_S => 0x80;
Subroutine BEGIN: called CC=1 SCAR=0.0
961 1 ▶use constant JUMP_FW => 0x01;
Subroutine BEGIN: called CC=1 SCAR=0.0
962 1 ▶use constant JUMP_FW_W => 0x02;
Subroutine BEGIN: called CC=1 SCAR=0.0
963 1 ▶use constant JUMP_BW_S => 0xA0;
Subroutine BEGIN: called CC=1 SCAR=0.0
964 1 ▶use constant JUMP_BW => 0x03;
Subroutine BEGIN: called CC=1 SCAR=0.0
965 1 ▶use constant JUMP_BW_W => 0x04;
Subroutine BEGIN: called CC=1 SCAR=0.0
966 1 ▶use constant TJUMP_FW_S => 0xC0;
Subroutine BEGIN: called CC=1 SCAR=0.0
967 1 ▶use constant TJUMP_FW => 0x05;
Subroutine BEGIN: called CC=1 SCAR=0.0
968 1 ▶use constant TJUMP_FW_W => 0x06;
Subroutine BEGIN: called CC=1 SCAR=0.0
969 1 ▶use constant TJUMP_BW => 0x07;
Subroutine BEGIN: called CC=1 SCAR=0.0
970 1 ▶use constant TJUMP_BW_W => 0x08;
Subroutine BEGIN: called CC=1 SCAR=0.0
971 1 ▶use constant CALL_S => 0x60;
Subroutine BEGIN: called CC=1 SCAR=0.0
972 1 ▶use constant CALL => 0x09;
Subroutine BEGIN: called CC=1 SCAR=0.0
973 1 ▶use constant CALL_LIB_S => 0x68;
Subroutine BEGIN: called CC=1 SCAR=0.0
974 1 ▶use constant CALL_LIB => 0x0A;
Subroutine BEGIN: called CC=1 SCAR=0.0
975 1 ▶use constant CALL_LIB_W => 0x0B;
Subroutine BEGIN: called CC=1 SCAR=0.0
976 1 ▶use constant CALL_URL => 0x0C;
Subroutine BEGIN: called CC=1 SCAR=0.0
977 1 ▶use constant CALL_URL_W => 0x0D;
Subroutine BEGIN: called CC=1 SCAR=0.0
978 1 ▶use constant LOAD_VAR_S => 0xE0;
Subroutine BEGIN: called CC=1 SCAR=0.0
979 1 ▶use constant LOAD_VAR => 0x0E;
Subroutine BEGIN: called CC=1 SCAR=0.0
980 1 ▶use constant STORE_VAR_S => 0x40;
Subroutine BEGIN: called CC=1 SCAR=0.0
981 1 ▶use constant STORE_VAR => 0x0F;
Subroutine BEGIN: called CC=1 SCAR=0.0
982 1 ▶use constant INCR_VAR_S => 0x70;
Subroutine BEGIN: called CC=1 SCAR=0.0
983 1 ▶use constant INCR_VAR => 0x10;
Subroutine BEGIN: called CC=1 SCAR=0.0
984 1 ▶use constant DECR_VAR => 0x11;
Subroutine BEGIN: called CC=1 SCAR=0.0
985 1 ▶use constant LOAD_CONST_S => 0x50;
Subroutine BEGIN: called CC=1 SCAR=0.0
986 1 ▶use constant LOAD_CONST => 0x12;
Subroutine BEGIN: called CC=1 SCAR=0.0
987 1 ▶use constant LOAD_CONST_W => 0x13;
Subroutine BEGIN: called CC=1 SCAR=0.0
988 1 ▶use constant CONST_0 => 0x14;
Subroutine BEGIN: called CC=1 SCAR=0.0
989 1 ▶use constant CONST_1 => 0x15;
Subroutine BEGIN: called CC=1 SCAR=0.0
990 1 ▶use constant CONST_M1 => 0x16;
Subroutine BEGIN: called CC=1 SCAR=0.0
991 1 ▶use constant CONST_ES => 0x17;
Subroutine BEGIN: called CC=1 SCAR=0.0
992 1 ▶use constant CONST_INVALID => 0x18;
Subroutine BEGIN: called CC=1 SCAR=0.0
993 1 ▶use constant CONST_TRUE => 0x19;
Subroutine BEGIN: called CC=1 SCAR=0.0
994 1 ▶use constant CONST_FALSE => 0x1A;
Subroutine BEGIN: called CC=1 SCAR=0.0
995 1 ▶use constant INCR => 0x1B;
Subroutine BEGIN: called CC=1 SCAR=0.0
996 1 ▶use constant DECR => 0x1C;
Subroutine BEGIN: called CC=1 SCAR=0.0
997 1 ▶use constant ADD_ASG => 0x1D;
Subroutine BEGIN: called CC=1 SCAR=0.0
998 1 ▶use constant SUB_ASG => 0x1E;
Subroutine BEGIN: called CC=1 SCAR=0.0
999 1 ▶use constant UMINUS => 0x1F;
Subroutine BEGIN: called CC=1 SCAR=0.0
1000 1 ▶use constant ADD => 0x20;
Subroutine BEGIN: called CC=1 SCAR=0.0
1001 1 ▶use constant SUB => 0x21;
Subroutine BEGIN: called CC=1 SCAR=0.0
1002 1 ▶use constant MUL => 0x22;
Subroutine BEGIN: called CC=1 SCAR=0.0
1003 1 ▶use constant DIV => 0x23;
Subroutine BEGIN: called CC=1 SCAR=0.0
1004 1 ▶use constant IDIV => 0x24;
Subroutine BEGIN: called CC=1 SCAR=0.0
1005 1 ▶use constant REM => 0x25;
Subroutine BEGIN: called CC=1 SCAR=0.0
1006 1 ▶use constant B_AND => 0x26;
Subroutine BEGIN: called CC=1 SCAR=0.0
1007 1 ▶use constant B_OR => 0x27;
Subroutine BEGIN: called CC=1 SCAR=0.0
1008 1 ▶use constant B_XOR => 0x28;
Subroutine BEGIN: called CC=1 SCAR=0.0
1009 1 ▶use constant B_NOT => 0x29;
Subroutine BEGIN: called CC=1 SCAR=0.0
1010 1 ▶use constant B_LSHIFT => 0x2A;
Subroutine BEGIN: called CC=1 SCAR=0.0
1011 1 ▶use constant B_RSSHIFT => 0x2B;
Subroutine BEGIN: called CC=1 SCAR=0.0
1012 1 ▶use constant B_RSZSHIFT => 0x2C;
Subroutine BEGIN: called CC=1 SCAR=0.0
1013 1 ▶use constant _EQ => 0x2D;
Subroutine BEGIN: called CC=1 SCAR=0.0
1014 1 ▶use constant _LE => 0x2E;
Subroutine BEGIN: called CC=1 SCAR=0.0
1015 1 ▶use constant _LT => 0x2F;
Subroutine BEGIN: called CC=1 SCAR=0.0
1016 1 ▶use constant _GE => 0x30;
Subroutine BEGIN: called CC=1 SCAR=0.0
1017 1 ▶use constant _GT => 0x31;
Subroutine BEGIN: called CC=1 SCAR=0.0
1018 1 ▶use constant _NE => 0x32;
Subroutine BEGIN: called CC=1 SCAR=0.0
1019 1 ▶use constant NOT => 0x33;
Subroutine BEGIN: called CC=1 SCAR=0.0
1020 1 ▶use constant SCAND => 0x34;
Subroutine BEGIN: called CC=1 SCAR=0.0
1021 1 ▶use constant SCOR => 0x35;
Subroutine BEGIN: called CC=1 SCAR=0.0
1022 1 ▶use constant TOBOOL => 0x36;
Subroutine BEGIN: called CC=1 SCAR=0.0
1023 1 ▶use constant POP => 0x37;
Subroutine BEGIN: called CC=1 SCAR=0.0
1024 1 ▶use constant TYPEOF => 0x38;
Subroutine BEGIN: called CC=1 SCAR=0.0
1025 1 ▶use constant ISVALID => 0x39;
Subroutine BEGIN: called CC=1 SCAR=0.0
1026 1 ▶use constant RETURN => 0x3A;
Subroutine BEGIN: called CC=1 SCAR=0.0
1027 1 ▶use constant RETURN_ES => 0x3B;
Subroutine BEGIN: called CC=1 SCAR=0.0
1028 1 ▶use constant DEBUG => 0x3C;
Subroutine BEGIN: called CC=1 SCAR=0.0
1029
1030 1 ▶use constant UINT3_MAX => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
1031 1 ▶use constant UINT4_MAX => 15;
Subroutine BEGIN: called CC=1 SCAR=0.0
1032 1 ▶use constant UINT5_MAX => 31;
Subroutine BEGIN: called CC=1 SCAR=0.0
1033 1 ▶use constant UINT8_MAX => 255;
Subroutine BEGIN: called CC=1 SCAR=0.0
1034 1 ▶use constant UINT16_MAX => 65535;
Subroutine BEGIN: called CC=1 SCAR=0.0
1035
1036 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
1037 0 my $proto = shift;
1038 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
1039 0 my $self = {};
1040 0 bless($self, $class);
1041 0 my ($parser) = @_;
1042 0 $self->{parser} = $parser;
1043 0 $self->{nb} = 0;
1044 0 $self->{size} = 0;
1045 0 $self->{action} = 0;
1046 0 return $self;
1047 }
1048
1049 0 ▶sub visitFunction {
Subroutine visitFunction: not called CC=7 SCAR=40.3
1050 0 my $self = shift;
1051 0 my ($opcode) = @_;
1052 0 my $func = $opcode->{Value};
1053 0 my $def = $opcode->{Definition};
1054 0 my $save_size = $self->{size};
1055 0 $self->{size} = 0;
1056 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'action'}) { } 0 0 0
1057 0 my $FunctionSize = $opcode->{Index};
1058 0 WAP::wmls::asm::asmComment("function prologue");
1059 0 WAP::wmls::asm::asmByte("NumberOfArguments", $def->{NumberOfArguments});
1060 0 WAP::wmls::asm::asmByte("NumberOfLocalVariables", $def->{NumberOfLocalVariables});
1061 0 WAP::wmls::asm::asmMultiByte("FunctionSize", $FunctionSize);
1062 0 WAP::wmls::asm::asmComment("function code");
1063 0 ▶ $func->visitActive($self)
Branch: 1 branch
BranchTrueFalseTotal
if defined $func 0 0 0
1064 if (defined $func);
1065 0 WAP::wmls::verbose::Source($opcode);
1066 }
1067 else {
1068 0 my $nb = $self->_indexeVariables($func, $def->{NumberOfArguments});
1069 0 ▶ if ($nb > UINT8_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nb > 255) { } 0 0 0
1070 0 $self->{parser}->genError($opcode, "too many variables");
1071 }
1072 else {
1073 0 $def->{NumberOfLocalVariables} = $nb - $def->{NumberOfArguments};
1074 0 my $func_size;
1075 do {
1076 0 $func_size = $self->{size};
1077 0 $self->{size} = 0;
1078 0 ▶ $func->visitActive($self)
Branch: 1 branch
BranchTrueFalseTotal
if defined $func 0 0 0
1079 if (defined $func);
1080 # print "size : $self->{size}\n";
1081 }
1082 while ( $func_size != $self->{size}
1083 0 ▶ and !exists $self->{parser}->YYData->{nb_error} );
Branch: 1 branch
BranchTrueFalseTotal
$func_size != $self->{"size"} and not exists $self->{"parser"}->YYData->{"nb_error"} and do { do { $func_size = $self->{"size"}; $self->{"size"} = 0; $func->visitActive($self) if defined $func } } 0 0 0
Condition0%0/3
$func_size != $self->{"size"} and not exists $self->{"parser"}->YYData->{"nb_error"}
!ll&&!rl&&r
000
MC/DC0%0/2
$func_size != $self->{"size"} and not exists $self->{"parser"}->YYData->{"nb_error"}
$func_size != $self->{"size"} not exists $self->{"parser"}->YYData->{"nb_error"}
Truth table0%0/3
A and not(B)
A= $func_size != $self->{"size"}B= not exists $self->{"parser"}->YYData->{"nb_error"}
ABresult
0X0
100
111
1084 }
1085 0 $opcode->{Index} = $self->{size};
1086 }
1087 0 $self->{size} = $save_size;
1088 0 $self->{size} += 2;
1089 0 $self->{size} += WAP::wmls::multibyte::size($opcode->{Index});
1090 0 $self->{size} += $opcode->{Index};
1091 0 return;
1092 }
1093
1094 0 ▶sub _indexeVariables {
Subroutine _indexeVariables: not called CC=10 SCAR=47.0
1095 0 my $self = shift;
1096 0 my ($func, $nb_args) = @_;
1097 0 my $idx = $nb_args;
1098 0 ▶ if (defined $func) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $func) 0 0 0
1099 0 ▶ for (my $node = $func->getFirstActive(); defined $node; $node = $node->getNextActive()) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node) 0 0 0
1100 0 my $opcode = $node->{OpCode};
1101 0 ▶ if ( $opcode->isa('LoadVar')
Branch: 1 branch
BranchTrueFalseTotal
if ($opcode->isa("LoadVar") or $opcode->isa("StoreVar") or $opcode->isa("IncrVar") or $opcode->isa("DecrVar") or $opcode->isa("AddAsg") or $opcode->isa("SubAsg")) 0 0 0
Condition0%0/15
$opcode->isa("LoadVar") or $opcode->isa("StoreVar") or $opcode->isa("IncrVar") or $opcode->isa("DecrVar") or $opcode->isa("AddAsg") or $opcode->isa("SubAsg")
l!l&&r!l&&!r
000
$opcode->isa("LoadVar") or $opcode->isa("StoreVar") or $opcode->isa("IncrVar") or $opcode->isa("DecrVar") or $opcode->isa("AddAsg")
l!l&&r!l&&!r
000
$opcode->isa("LoadVar") or $opcode->isa("StoreVar") or $opcode->isa("IncrVar") or $opcode->isa("DecrVar")
l!l&&r!l&&!r
000
$opcode->isa("LoadVar") or $opcode->isa("StoreVar") or $opcode->isa("IncrVar")
l!l&&r!l&&!r
000
$opcode->isa("LoadVar") or $opcode->isa("StoreVar")
l!l&&r!l&&!r
000
MC/DC0%0/6
$opcode->isa("LoadVar") or $opcode->isa("StoreVar") or $opcode->isa("IncrVar") or $opcode->isa("DecrVar") or $opcode->isa("AddAsg") or $opcode->isa("SubAsg")
$opcode->isa("LoadVar") $opcode->isa("StoreVar") $opcode->isa("IncrVar") $opcode->isa("DecrVar") $opcode->isa("AddAsg") $opcode->isa("SubAsg")
Truth table0%0/7
A or B or C or D or E or F
A= $opcode->isa("LoadVar")B= $opcode->isa("StoreVar")C= $opcode->isa("IncrVar")D= $opcode->isa("DecrVar")E= $opcode->isa("AddAsg")F= $opcode->isa("SubAsg")
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
1102 or $opcode->isa('StoreVar')
1103 or $opcode->isa('IncrVar')
1104 or $opcode->isa('DecrVar')
1105 or $opcode->isa('AddAsg')
1106 or $opcode->isa('SubAsg') ) {
1107 0 my $def = $opcode->{Definition};
1108 0 ▶ if ($def->{ID} == 0xffff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($def->{"ID"} == 65535) 0 0 0
1109 0 $def->{ID} = $idx;
1110 0 $idx ++;
1111 }
1112 }
1113 }
1114 }
1115 0 return $idx;
1116 }
1117
1118 0 ▶sub visitLoadVar {
Subroutine visitLoadVar: not called CC=7 SCAR=40.3
1119 0 my $self = shift;
1120 0 my ($opcode) = @_;
1121 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1122 0 WAP::wmls::verbose::Source($opcode);
1123 }
1124 0 my $def = $opcode->{Definition};
1125 0 my $vindex = $def->{ID};
1126 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitDecrVar\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $vindex <= 255 0 0 0
1127 unless ($vindex <= UINT8_MAX);
1128 0 ▶ if ($vindex <= UINT5_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vindex <= 31) { } 0 0 0
1129 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1130 0 WAP::wmls::asm::asmOpcode1s(LOAD_VAR_S, $vindex);
1131 }
1132 0 $self->{size} += 1;
1133 }
1134 else {
1135 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1136 0 WAP::wmls::asm::asmOpcode2(LOAD_VAR, $vindex);
1137 }
1138 0 $self->{size} += 2;
1139 }
1140 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1141 0 WAP::wmls::asm::asmComment($def->{Symbol});
1142 }
1143 0 return;
1144 }
1145
1146 0 ▶sub visitStoreVar {
Subroutine visitStoreVar: not called CC=7 SCAR=40.3
1147 0 my $self = shift;
1148 0 my ($opcode) = @_;
1149 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1150 0 WAP::wmls::verbose::Source($opcode);
1151 }
1152 0 my $def = $opcode->{Definition};
1153 0 my $vindex = $def->{ID};
1154 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitDecrVar\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $vindex <= 255 0 0 0
1155 unless ($vindex <= UINT8_MAX);
1156 0 ▶ if ($vindex <= UINT4_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vindex <= 15) { } 0 0 0
1157 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1158 0 WAP::wmls::asm::asmOpcode1s(STORE_VAR_S, $vindex);
1159 }
1160 0 $self->{size} += 1;
1161 }
1162 else {
1163 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1164 0 WAP::wmls::asm::asmOpcode2(STORE_VAR, $vindex);
1165 }
1166 0 $self->{size} += 2;
1167 }
1168 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1169 0 WAP::wmls::asm::asmComment($def->{Symbol});
1170 }
1171 0 return;
1172 }
1173
1174 0 ▶sub visitIncrVar {
Subroutine visitIncrVar: not called CC=7 SCAR=40.3
1175 0 my $self = shift;
1176 0 my ($opcode) = @_;
1177 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1178 0 WAP::wmls::verbose::Source($opcode);
1179 }
1180 0 my $def = $opcode->{Definition};
1181 0 my $vindex = $def->{ID};
1182 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitDecrVar\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $vindex <= 255 0 0 0
1183 unless ($vindex <= UINT8_MAX);
1184 0 ▶ if ($vindex <= UINT3_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vindex <= 7) { } 0 0 0
1185 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1186 0 WAP::wmls::asm::asmOpcode1s(INCR_VAR_S, $vindex);
1187 }
1188 0 $self->{size} += 1;
1189 }
1190 else {
1191 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1192 0 WAP::wmls::asm::asmOpcode2(INCR_VAR, $vindex);
1193 }
1194 0 $self->{size} += 2;
1195 }
1196 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1197 0 WAP::wmls::asm::asmComment($def->{Symbol});
1198 }
1199 0 return;
1200 }
1201
1202 0 ▶sub visitDecrVar {
Subroutine visitDecrVar: not called CC=3 SCAR=24.8
1203 0 my $self = shift;
1204 0 my ($opcode) = @_;
1205 0 my $def = $opcode->{Definition};
1206 0 my $vindex = $def->{ID};
1207 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitDecrVar\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $vindex <= 255 0 0 0
1208 unless ($vindex <= UINT8_MAX);
1209 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1210 0 WAP::wmls::verbose::Source($opcode);
1211 0 WAP::wmls::asm::asmOpcode2(DECR_VAR, $vindex);
1212 0 WAP::wmls::asm::asmComment($def->{Symbol});
1213 }
1214 0 $self->{size} += 2;
1215 0 return;
1216 }
1217
1218 0 ▶sub visitAddAsg {
Subroutine visitAddAsg: not called CC=3 SCAR=24.8
1219 0 my $self = shift;
1220 0 my ($opcode) = @_;
1221 0 my $def = $opcode->{Definition};
1222 0 my $vindex = $def->{ID};
1223 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitAddAsg\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $vindex <= 255 0 0 0
1224 unless ($vindex <= UINT8_MAX);
1225 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1226 0 WAP::wmls::verbose::Source($opcode);
1227 0 WAP::wmls::asm::asmOpcode2(ADD_ASG, $vindex);
1228 0 WAP::wmls::asm::asmComment($def->{Symbol});
1229 }
1230 0 $self->{size} += 2;
1231 0 return;
1232 }
1233
1234 0 ▶sub visitSubAsg {
Subroutine visitSubAsg: not called CC=3 SCAR=24.8
1235 0 my $self = shift;
1236 0 my ($opcode) = @_;
1237 0 my $def = $opcode->{Definition};
1238 0 my $vindex = $def->{ID};
1239 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitSubAsg\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $vindex <= 255 0 0 0
1240 unless ($vindex <= UINT8_MAX);
1241 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1242 0 WAP::wmls::verbose::Source($opcode);
1243 0 WAP::wmls::asm::asmOpcode2(SUB_ASG, $vindex);
1244 0 WAP::wmls::asm::asmComment($def->{Symbol});
1245 }
1246 0 $self->{size} += 2;
1247 0 return;
1248 }
1249
1250 0 ▶sub visitLabel {
Subroutine visitLabel: not called CC=2 SCAR=17.9
1251 0 my $self = shift;
1252 0 my ($opcode) = @_;
1253 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1254 # no verbose
1255 0 WAP::wmls::asm::asmComment($opcode->{Definition}->{Symbol});
1256 }
1257 0 $opcode->{Definition}->{Index} = $self->{size};
1258 0 return;
1259 }
1260
1261 0 ▶sub visitPop {
Subroutine visitPop: not called CC=2 SCAR=17.9
1262 0 my $self = shift;
1263 0 my ($opcode) = @_;
1264 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1265 # no verbose
1266 0 WAP::wmls::asm::asmOpcode1(POP);
1267 0 WAP::wmls::asm::asmComment();
1268 }
1269 0 $self->{size} += 1;
1270 0 return;
1271 }
1272
1273 0 ▶sub visitToBool {
Subroutine visitToBool: not called CC=2 SCAR=17.9
1274 0 my $self = shift;
1275 0 my ($opcode) = @_;
1276 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1277 0 WAP::wmls::verbose::Source($opcode);
1278 0 WAP::wmls::asm::asmOpcode1(TOBOOL);
1279 0 WAP::wmls::asm::asmComment();
1280 }
1281 0 $self->{size} += 1;
1282 0 return;
1283 }
1284
1285 0 ▶sub visitScOr {
Subroutine visitScOr: not called CC=2 SCAR=17.9
1286 0 my $self = shift;
1287 0 my ($opcode) = @_;
1288 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1289 0 WAP::wmls::verbose::Source($opcode);
1290 0 WAP::wmls::asm::asmOpcode1(SCOR);
1291 0 WAP::wmls::asm::asmComment();
1292 }
1293 0 $self->{size} += 1;
1294 0 return;
1295 }
1296
1297 0 ▶sub visitScAnd {
Subroutine visitScAnd: not called CC=2 SCAR=17.9
1298 0 my $self = shift;
1299 0 my ($opcode) = @_;
1300 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1301 0 WAP::wmls::verbose::Source($opcode);
1302 0 WAP::wmls::asm::asmOpcode1(SCAND);
1303 0 WAP::wmls::asm::asmComment();
1304 }
1305 0 $self->{size} += 1;
1306 0 return;
1307 }
1308
1309 0 ▶sub visitReturn {
Subroutine visitReturn: not called CC=2 SCAR=17.9
1310 0 my $self = shift;
1311 0 my ($opcode) = @_;
1312 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1313 0 WAP::wmls::verbose::Source($opcode);
1314 0 WAP::wmls::asm::asmOpcode1(RETURN);
1315 0 WAP::wmls::asm::asmComment();
1316 }
1317 0 $self->{size} += 1;
1318 0 return;
1319 }
1320
1321 0 ▶sub visitReturnES {
Subroutine visitReturnES: not called CC=2 SCAR=17.9
1322 0 my $self = shift;
1323 0 my ($opcode) = @_;
1324 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1325 0 WAP::wmls::verbose::Source($opcode);
1326 0 WAP::wmls::asm::asmOpcode1(RETURN_ES);
1327 0 WAP::wmls::asm::asmComment();
1328 }
1329 0 $self->{size} += 1;
1330 0 return;
1331 }
1332
1333 0 ▶sub visitCall {
Subroutine visitCall: not called CC=10 SCAR=47.0
1334 0 my $self = shift;
1335 0 my ($opcode) = @_;
1336 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1337 0 WAP::wmls::verbose::Source($opcode);
1338 }
1339 0 my $def = $opcode->{Definition};
1340 0 my $symb = $def->{Symbol};
1341 0 ▶ if ($def->{Type} ne 'UNDEF_FUNC') {
Branch: 1 branch
BranchTrueFalseTotal
if ($def->{'Type'} ne 'UNDEF_FUNC') { } 0 0 0
1342 0 my $nb_args = $def->{NumberOfArguments};
1343 0 my $findex = $def->{ID};
1344 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitCallLib\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $nb_args <= 255 0 0 0
1345 unless ($nb_args <= UINT8_MAX);
1346 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitCall\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $findex <= 255 0 0 0
1347 unless ($findex <= UINT8_MAX);
1348 0 ▶ if ($nb_args != $opcode->{Index}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nb_args != $opcode->{'Index'}) { } 0 0 0
elsif ($findex <= 7) { } 0 0 0
1349 0 $self->{parser}->genError($opcode, "Wrong argument number for local function - $symb.\n");
1350 }
1351 elsif ($findex <= UINT3_MAX) {
1352 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1353 0 WAP::wmls::asm::asmOpcode1s(CALL_S, $findex);
1354 }
1355 0 $self->{size} += 1;
1356 }
1357 else {
1358 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1359 0 WAP::wmls::asm::asmOpcode2(CALL, $findex);
1360 }
1361 0 $self->{size} += 2;
1362 }
1363 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1364 0 WAP::wmls::asm::asmComment($def->{Symbol});
1365 }
1366 }
1367 else {
1368 0 $self->{parser}->genError($opcode, "Undefined function - $symb.\n");
1369 }
1370 0 return;
1371 }
1372
1373 0 ▶sub visitCallLib {
Subroutine visitCallLib: not called CC=10 SCAR=47.0
1374 0 my $self = shift;
1375 0 my ($opcode) = @_;
1376 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1377 0 WAP::wmls::verbose::Source($opcode);
1378 }
1379 0 my $def = $opcode->{Definition};
1380 0 my $findex = $def->{ID};
1381 0 my $lindex = $def->{LibraryID};
1382 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitCallLib\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $findex <= 255 0 0 0
1383 unless ($findex <= UINT8_MAX);
1384 0 ▶ if ($findex <= UINT3_MAX and $lindex <= UINT8_MAX) {
Branch: 2 branches
BranchTrueFalseTotal
if ($findex <= 7 and $lindex <= 255) { } 0 0 0
elsif ($lindex <= 255) { } 0 0 0
Condition0%0/3
$findex <= 7 and $lindex <= 255
!ll&&!rl&&r
000
MC/DC0%0/2
$findex <= 7 and $lindex <= 255
$findex <= 7 $lindex <= 255
Truth table0%0/3
A and B
A= $findex <= 7B= $lindex <= 255
ABresult
0X0
100
111
1385 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1386 0 WAP::wmls::asm::asmOpcode2s(CALL_LIB_S, $findex, $lindex);
1387 }
1388 0 $self->{size} += 2;
1389 }
1390 elsif ($lindex <= UINT8_MAX) {
1391 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1392 0 WAP::wmls::asm::asmOpcode3(CALL_LIB, $findex, $lindex);
1393 }
1394 0 $self->{size} += 3;
1395 }
1396 else {
1397 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1398 0 WAP::wmls::asm::asmOpcode4w(CALL_LIB_W, $findex, $lindex);
1399 }
1400 0 $self->{size} += 4;
1401 }
1402 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1403 0 WAP::wmls::asm::asmComment($def->{Symbol});
1404 }
1405 0 return;
1406 }
1407
1408 0 ▶sub visitCallUrl {
Subroutine visitCallUrl: not called CC=10 SCAR=47.0
1409 0 my $self = shift;
1410 0 my ($opcode) = @_;
1411 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1412 0 WAP::wmls::verbose::Source($opcode);
1413 }
1414 0 my $urlindex = $opcode->{Url}->{Index};
1415 0 my $findex = $opcode->{Index};
1416 0 my $def = $opcode->{Definition};
1417 0 my $nb_args = $def->{NumberOfArguments};
1418 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitCallUrl\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $urlindex <= 65535 and $findex <= 65535 0 0 0
Condition0%0/3
$urlindex <= 65535 and $findex <= 65535
!ll&&!rl&&r
000
MC/DC0%0/2
$urlindex <= 65535 and $findex <= 65535
$urlindex <= 65535 $findex <= 65535
Truth table0%0/3
A and B
A= $urlindex <= 65535B= $findex <= 65535
ABresult
0X0
100
111
1419 unless ($urlindex <= UINT16_MAX and $findex <= UINT16_MAX);
1420 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitCallUrl\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $nb_args <= 255 0 0 0
1421 unless ($nb_args <= UINT8_MAX);
1422 0 ▶ if ($urlindex <= UINT8_MAX and $findex <= UINT8_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($urlindex <= 255 and $findex <= 255) { } 0 0 0
Condition0%0/3
$urlindex <= 255 and $findex <= 255
!ll&&!rl&&r
000
MC/DC0%0/2
$urlindex <= 255 and $findex <= 255
$urlindex <= 255 $findex <= 255
Truth table0%0/3
A and B
A= $urlindex <= 255B= $findex <= 255
ABresult
0X0
100
111
1423 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1424 0 WAP::wmls::asm::asmOpcode4(CALL_URL, $urlindex, $findex, $nb_args);
1425 }
1426 0 $self->{size} += 4;
1427 }
1428 else {
1429 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1430 0 WAP::wmls::asm::asmOpcode6(CALL_URL_W, $urlindex, $findex, $nb_args);
1431 }
1432 0 $self->{size} += 6;
1433 }
1434 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1435 0 WAP::wmls::asm::asmComment($def->{Symbol});
1436 }
1437 0 return;
1438 }
1439
1440 0 ▶sub visitJump {
Subroutine visitJump: not called CC=17 SCAR=57.2
1441 0 my $self = shift;
1442 0 my ($opcode) = @_;
1443 0 my $def = $opcode->{Definition};
1444 0 my $dest = $def->{Index};
1445 # no verbose
1446 0 ▶ if ($dest > $self->{size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dest > $self->{'size'}) { } 0 0 0
1447 0 my $offset = $dest - $self->{size};
1448 0 ▶ if ($offset <= UINT5_MAX + 1) {
Branch: 3 branches
BranchTrueFalseTotal
if ($offset <= 32) { } 0 0 0
elsif ($offset <= 257) { } 0 0 0
elsif ($offset <= 65538) { } 0 0 0
1449 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1450 0 WAP::wmls::asm::asmOpcode1s(JUMP_FW_S, $offset - 1);
1451 }
1452 0 $self->{size} += 1;
1453 }
1454 elsif ($offset <= UINT8_MAX + 2) {
1455 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1456 0 WAP::wmls::asm::asmOpcode2(JUMP_FW, $offset - 2);
1457 }
1458 0 $self->{size} += 2;
1459 }
1460 elsif ($offset <= UINT16_MAX + 3) {
1461 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1462 0 WAP::wmls::asm::asmOpcode3w(JUMP_FW_W, $offset - 3);
1463 }
1464 0 $self->{size} += 3;
1465 }
1466 else {
1467 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1468 0 $self->{parser}->genError($opcode, "Too long JUMP_FW");
1469 }
1470 0 $self->{size} += 3;
1471 }
1472 }
1473 else {
1474 0 my $offset = $self->{size} - $dest;
1475 0 ▶ if ($offset <= UINT5_MAX) {
Branch: 3 branches
BranchTrueFalseTotal
if ($offset <= 31) { } 0 0 0
elsif ($offset <= 255) { } 0 0 0
elsif ($offset <= 65535) { } 0 0 0
1476 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1477 0 WAP::wmls::asm::asmOpcode1s(JUMP_BW_S, $offset);
1478 }
1479 0 $self->{size} += 1;
1480 }
1481 elsif ($offset <= UINT8_MAX) {
1482 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1483 0 WAP::wmls::asm::asmOpcode2(JUMP_BW, $offset);
1484 }
1485 0 $self->{size} += 2;
1486 }
1487 elsif ($offset <= UINT16_MAX) {
1488 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1489 0 WAP::wmls::asm::asmOpcode3w(JUMP_BW_W, $offset);
1490 }
1491 0 $self->{size} += 3;
1492 }
1493 else {
1494 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1495 0 $self->{parser}->genError($opcode, "Too long JUMP_BW");
1496 }
1497 0 $self->{size} += 3;
1498 }
1499 }
1500 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1501 0 WAP::wmls::asm::asmComment($def->{Symbol});
1502 }
1503 0 return;
1504 }
1505
1506 0 ▶sub visitFalseJump {
Subroutine visitFalseJump: not called CC=15 SCAR=54.8
1507 0 my $self = shift;
1508 0 my ($opcode) = @_;
1509 0 my $def = $opcode->{Definition};
1510 0 my $dest = $def->{Index};
1511 # no verbose
1512 0 ▶ if ($dest > $self->{size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dest > $self->{'size'}) { } 0 0 0
1513 0 my $offset = $dest - $self->{size};
1514 0 ▶ if ($offset <= UINT5_MAX + 1) {
Branch: 3 branches
BranchTrueFalseTotal
if ($offset <= 32) { } 0 0 0
elsif ($offset <= 257) { } 0 0 0
elsif ($offset <= 65538) { } 0 0 0
1515 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1516 0 WAP::wmls::asm::asmOpcode1s(TJUMP_FW_S, $offset - 1);
1517 }
1518 0 $self->{size} += 1;
1519 }
1520 elsif ($offset <= UINT8_MAX + 2) {
1521 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1522 0 WAP::wmls::asm::asmOpcode2(TJUMP_FW, $offset - 2);
1523 }
1524 0 $self->{size} += 2;
1525 }
1526 elsif ($offset <= UINT16_MAX + 3) {
1527 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1528 0 WAP::wmls::asm::asmOpcode3w(TJUMP_FW_W, $offset - 3);
1529 }
1530 0 $self->{size} += 3;
1531 }
1532 else {
1533 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1534 0 $self->{parser}->genError($opcode, "Too long TJUMP_FW");
1535 }
1536 0 $self->{size} += 3;
1537 }
1538 }
1539 else {
1540 0 my $offset = $self->{size} - $dest;
1541 0 ▶ if ($offset <= UINT8_MAX) {
Branch: 2 branches
BranchTrueFalseTotal
if ($offset <= 255) { } 0 0 0
elsif ($offset <= 65535) { } 0 0 0
1542 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1543 0 WAP::wmls::asm::asmOpcode2(TJUMP_BW, $offset);
1544 }
1545 0 $self->{size} += 2;
1546 }
1547 elsif ($offset <= UINT16_MAX) {
1548 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1549 0 WAP::wmls::asm::asmOpcode3w(TJUMP_BW_W, $offset);
1550 }
1551 0 $self->{size} += 3;
1552 }
1553 else {
1554 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1555 0 $self->{parser}->genError($opcode, "Too long TJUMP_BW");
1556 }
1557 0 $self->{size} += 3;
1558 }
1559 }
1560 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1561 0 WAP::wmls::asm::asmComment($def->{Symbol});
1562 }
1563 0 return;
1564 }
1565
1566 0 ▶sub visitUnaryOp {
Subroutine visitUnaryOp: not called CC=9 SCAR=45.0
1567 0 my $self = shift;
1568 0 my ($opcode) = @_;
1569 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1570 0 WAP::wmls::verbose::Source($opcode);
1571 0 my $oper = $opcode->{Operator};
1572 0 ▶ if ($oper eq 'typeof') {
Branch: 7 branches
BranchTrueFalseTotal
if ($oper eq 'typeof') { } 0 0 0
elsif ($oper eq 'isvalid') { } 0 0 0
elsif ($oper eq '-') { } 0 0 0
elsif ($oper eq '~') { } 0 0 0
elsif ($oper eq '!') { } 0 0 0
elsif ($oper eq '++') { } 0 0 0
elsif ($oper eq '--') { } 0 0 0
1573 0 WAP::wmls::asm::asmOpcode1(TYPEOF);
1574 }
1575 elsif ($oper eq 'isvalid') {
1576 0 WAP::wmls::asm::asmOpcode1(ISVALID);
1577 }
1578 elsif ($oper eq '-') {
1579 0 WAP::wmls::asm::asmOpcode1(UMINUS);
1580 }
1581 elsif ($oper eq '~') {
1582 0 WAP::wmls::asm::asmOpcode1(B_NOT);
1583 }
1584 elsif ($oper eq '!') {
1585 0 WAP::wmls::asm::asmOpcode1(NOT);
1586 }
1587 elsif ($oper eq '++') {
1588 0 WAP::wmls::asm::asmOpcode1(INCR);
1589 }
1590 elsif ($oper eq '--') {
1591 0 WAP::wmls::asm::asmOpcode1(DECR);
1592 }
1593 else {
1594 0 croak "INTERNAL ERROR in codeVisitor::visitUnaryOp (oper:$oper)\n";
1595 }
1596 0 WAP::wmls::asm::asmComment();
1597 }
1598 0 $self->{size} += 1;
1599 0 return;
1600 }
1601
1602 0 ▶sub visitBinaryOp {
Subroutine visitBinaryOp: not called CC=20 SCAR=60.4
1603 0 my $self = shift;
1604 0 my ($opcode) = @_;
1605 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1606 0 WAP::wmls::verbose::Source($opcode);
1607 0 my $oper = $opcode->{Operator};
1608 0 ▶ if ($oper eq '+') {
Branch: 18 branches
BranchTrueFalseTotal
if ($oper eq '+') { } 0 0 0
elsif ($oper eq '-') { } 0 0 0
elsif ($oper eq '*') { } 0 0 0
elsif ($oper eq '/') { } 0 0 0
elsif ($oper eq 'div') { } 0 0 0
elsif ($oper eq '%') { } 0 0 0
elsif ($oper eq '<<') { } 0 0 0
elsif ($oper eq '>>') { } 0 0 0
elsif ($oper eq '>>>') { } 0 0 0
elsif ($oper eq '<') { } 0 0 0
elsif ($oper eq '>') { } 0 0 0
elsif ($oper eq '<=') { } 0 0 0
elsif ($oper eq '>=') { } 0 0 0
elsif ($oper eq '==') { } 0 0 0
elsif ($oper eq '!=') { } 0 0 0
elsif ($oper eq '&') { } 0 0 0
elsif ($oper eq '^') { } 0 0 0
elsif ($oper eq '|') { } 0 0 0
1609 0 WAP::wmls::asm::asmOpcode1(ADD);
1610 }
1611 elsif ($oper eq '-') {
1612 0 WAP::wmls::asm::asmOpcode1(SUB);
1613 }
1614 elsif ($oper eq '*') {
1615 0 WAP::wmls::asm::asmOpcode1(MUL);
1616 }
1617 elsif ($oper eq '/') {
1618 0 WAP::wmls::asm::asmOpcode1(DIV);
1619 }
1620 elsif ($oper eq 'div') {
1621 0 WAP::wmls::asm::asmOpcode1(IDIV);
1622 }
1623 elsif ($oper eq '%') {
1624 0 WAP::wmls::asm::asmOpcode1(REM);
1625 }
1626 elsif ($oper eq '<<') {
1627 0 WAP::wmls::asm::asmOpcode1(B_LSHIFT);
1628 }
1629 elsif ($oper eq '>>') {
1630 0 WAP::wmls::asm::asmOpcode1(B_RSSHIFT);
1631 }
1632 elsif ($oper eq '>>>') {
1633 0 WAP::wmls::asm::asmOpcode1(B_RSZSHIFT);
1634 }
1635 elsif ($oper eq '<') {
1636 0 WAP::wmls::asm::asmOpcode1(_LT);
1637 }
1638 elsif ($oper eq '>') {
1639 0 WAP::wmls::asm::asmOpcode1(_GT);
1640 }
1641 elsif ($oper eq '<=') {
1642 0 WAP::wmls::asm::asmOpcode1(_LE);
1643 }
1644 elsif ($oper eq '>=') {
1645 0 WAP::wmls::asm::asmOpcode1(_GE);
1646 }
1647 elsif ($oper eq '==') {
1648 0 WAP::wmls::asm::asmOpcode1(_EQ);
1649 }
1650 elsif ($oper eq '!=') {
1651 0 WAP::wmls::asm::asmOpcode1(_NE);
1652 }
1653 elsif ($oper eq '&') {
1654 0 WAP::wmls::asm::asmOpcode1(B_AND);
1655 }
1656 elsif ($oper eq '^') {
1657 0 WAP::wmls::asm::asmOpcode1(B_XOR);
1658 }
1659 elsif ($oper eq '|') {
1660 0 WAP::wmls::asm::asmOpcode1(B_OR);
1661 }
1662 else {
1663 0 croak "INTERNAL ERROR in codeVisitor::visitBinaryOp (oper:$oper)\n";
1664 }
1665 0 WAP::wmls::asm::asmComment();
1666 }
1667 0 $self->{size} += 1;
1668 0 return;
1669 }
1670
1671 0 ▶sub visitLoadConst {
Subroutine visitLoadConst: not called CC=26 SCAR=65.5
1672 0 my $self = shift;
1673 0 my ($opcode) = @_;
1674 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1675 0 WAP::wmls::verbose::Source($opcode);
1676 }
1677 0 my $type = $opcode->{TypeDef};
1678 0 my $value = $opcode->{Value};
1679 # print "index $opcode->{Index} cst $value\n";
1680 0 ▶ if ($type eq 'TYPE_INVALID') {
Branch: 5 branches
BranchTrueFalseTotal
if ($type eq 'TYPE_INVALID') { } 0 0 0
elsif ($type eq 'TYPE_BOOLEAN') { } 0 0 0
elsif ($type eq 'TYPE_STRING' or $type eq 'TYPE_UTF8_STRING') { } 0 0 0
elsif ($type eq 'TYPE_FLOAT') { } 0 0 0
elsif ($type eq 'TYPE_INTEGER') { } 0 0 0
1681 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1682 0 WAP::wmls::asm::asmOpcode1(CONST_INVALID);
1683 0 WAP::wmls::asm::asmComment();
1684 }
1685 0 $self->{size} += 1;
1686 }
1687 elsif ($type eq 'TYPE_BOOLEAN') {
1688 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1689 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
1690 0 WAP::wmls::asm::asmOpcode1(CONST_TRUE);
1691 0 WAP::wmls::asm::asmComment();
1692 }
1693 else {
1694 0 WAP::wmls::asm::asmOpcode1(CONST_FALSE);
1695 0 WAP::wmls::asm::asmComment();
1696 }
1697 }
1698 0 $self->{size} += 1;
1699 }
1700 ▶ elsif ($type eq 'TYPE_STRING' or $type eq 'TYPE_UTF8_STRING') {
Condition0%0/3
$type eq "TYPE_STRING" or $type eq "TYPE_UTF8_STRING"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "TYPE_STRING" or $type eq "TYPE_UTF8_STRING"
$type eq "TYPE_STRING" $type eq "TYPE_UTF8_STRING"
Truth table0%0/3
A or B
A= $type eq "TYPE_STRING"B= $type eq "TYPE_UTF8_STRING"
ABresult
1X1
011
000
1701 0 ▶ if (length $value == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $value == 0) { } 0 0 0
1702 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1703 0 WAP::wmls::asm::asmOpcode1(CONST_ES);
1704 0 WAP::wmls::asm::asmComment();
1705 }
1706 0 $self->{size} += 1;
1707 }
1708 else {
1709 0 goto load_const;
1710 }
1711 }
1712 elsif ($type eq 'TYPE_FLOAT') {
1713 load_const:
1714 0 my $cindex = $opcode->{Index};
1715 0 ▶ croak "INTERNAL ERROR in codeVisitor::visitLoadConst\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $cindex <= 65535 0 0 0
1716 unless ($cindex <= UINT16_MAX);
1717 0 ▶ if ($cindex <= UINT4_MAX) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cindex <= 15) { } 0 0 0
elsif ($cindex <= 255) { } 0 0 0
1718 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1719 0 WAP::wmls::asm::asmOpcode1s(LOAD_CONST_S, $cindex);
1720 }
1721 0 $self->{size} += 1;
1722 }
1723 elsif ($cindex <= UINT8_MAX) {
1724 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1725 0 WAP::wmls::asm::asmOpcode2(LOAD_CONST, $cindex);
1726 }
1727 0 $self->{size} += 2;
1728 }
1729 else {
1730 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1731 0 WAP::wmls::asm::asmOpcode3w(LOAD_CONST_W, $cindex);
1732 }
1733 0 $self->{size} += 3;
1734 }
1735 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1736 0 WAP::wmls::asm::asmComment($value);
1737 }
1738 }
1739 elsif ($type eq 'TYPE_INTEGER') {
1740 0 ▶ if ($value == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if ($value == 0) { } 0 0 0
elsif ($value == 1) { } 0 0 0
elsif ($value == -1) { } 0 0 0
1741 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1742 0 WAP::wmls::asm::asmOpcode1(CONST_0);
1743 0 WAP::wmls::asm::asmComment();
1744 }
1745 0 $self->{size} += 1;
1746 }
1747 elsif ($value == 1) {
1748 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1749 0 WAP::wmls::asm::asmOpcode1(CONST_1);
1750 0 WAP::wmls::asm::asmComment();
1751 }
1752 0 $self->{size} += 1;
1753 }
1754 elsif ($value == -1) {
1755 0 ▶ if ($self->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"action"}) 0 0 0
1756 0 WAP::wmls::asm::asmOpcode1(CONST_M1);
1757 0 WAP::wmls::asm::asmComment();
1758 }
1759 0 $self->{size} += 1;
1760 }
1761 else {
1762 0 goto load_const;
1763 }
1764 }
1765 else {
1766 0 croak "INTERNAL ERROR in codeVisitor::visitLoadConst (type:$type)\n";
1767 }
1768 0 return;
1769 }
1770
1771 ###############################################################################
1772
1773 package WAP::wmls::parser;
1774
1775 1 ▶use constant WMLS_MAJOR_VERSION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
1776 1 ▶use constant WMLS_MINOR_VERSION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
1777
1778 0 ▶sub genError {
Subroutine genError: not called CC=4 SCAR=30.0
Pod undocumented
1779 0 my $parser = shift;
1780 0 my ($opcode, $msg) = @_;
1781
1782 0 ▶ if (exists $parser->YYData->{nb_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{'nb_error'}) { } 0 0 0
1783 0 $parser->YYData->{nb_error} ++;
1784 }
1785 else {
1786 0 $parser->YYData->{nb_error} = 1;
1787 }
1788
1789 print STDOUT '#',$parser->YYData->{filename},':',$opcode->{Lineno},'#Error: ',$msg
1790 if ( exists $parser->YYData->{verbose_error}
1791 0 ▶ and $parser->YYData->{verbose_error});
Branch: 1 branch
BranchTrueFalseTotal
if exists $parser->YYData->{"verbose_error"} and $parser->YYData->{"verbose_error"} 0 0 0
Condition0%0/3
exists $parser->YYData->{"verbose_error"} and $parser->YYData->{"verbose_error"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $parser->YYData->{"verbose_error"} and $parser->YYData->{"verbose_error"}
exists $parser->YYData->{"verbose_error"} $parser->YYData->{"verbose_error"}
Truth table0%0/3
A and B
A= exists $parser->YYData->{"verbose_error"}B= $parser->YYData->{"verbose_error"}
ABresult
0X0
100
111
1792 0 return;
1793 }
1794
1795 0 ▶sub genWarning {
Subroutine genWarning: not called CC=4 SCAR=30.0
Pod undocumented
1796 0 my $parser = shift;
1797 0 my ($opcode, $msg) = @_;
1798
1799 0 ▶ if (exists $parser->YYData->{nb_warning}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parser->YYData->{'nb_warning'}) { } 0 0 0
1800 0 $parser->YYData->{nb_warning} ++;
1801 }
1802 else {
1803 0 $parser->YYData->{nb_warning} = 1;
1804 }
1805
1806 print STDOUT '#',$parser->YYData->{filename},':',$opcode->{Lineno},'#Warning: ',$msg
1807 if ( exists $parser->YYData->{verbose_warning}
1808 0 ▶ and $parser->YYData->{verbose_warning});
Branch: 1 branch
BranchTrueFalseTotal
if exists $parser->YYData->{"verbose_warning"} and $parser->YYData->{"verbose_warning"} 0 0 0
Condition0%0/3
exists $parser->YYData->{"verbose_warning"} and $parser->YYData->{"verbose_warning"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $parser->YYData->{"verbose_warning"} and $parser->YYData->{"verbose_warning"}
exists $parser->YYData->{"verbose_warning"} $parser->YYData->{"verbose_warning"}
Truth table0%0/3
A and B
A= exists $parser->YYData->{"verbose_warning"}B= $parser->YYData->{"verbose_warning"}
ABresult
0X0
100
111
1809 0 return;
1810 }
1811
1812 0 ▶sub generate {
Subroutine generate: not called CC=21 SCAR=61.4
Pod undocumented
1813 0 my $parser = shift;
1814
1815 0 my $CharacterSet = 4; # iso-8859-1
1816 # ConstantPool
1817 0 my $CodeSize = 0;
1818 0 my $constantVisitor = new WAP::wmls::constantVisitor($parser);
1819 $parser->YYData->{PragmaList}->visit($constantVisitor)
1820 0 ▶ if (defined $parser->YYData->{PragmaList});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parser->YYData->{"PragmaList"} 0 0 0
1821 $parser->YYData->{FunctionList}->visitActive($constantVisitor)
1822 0 ▶ if (defined $parser->YYData->{FunctionList});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parser->YYData->{"FunctionList"} 0 0 0
1823 0 my $NumberOfConstants = $constantVisitor->{nb};
1824 0 ▶ $parser->genError($parser->YYData->{FunctionList}, "Too many constants ($NumberOfConstants)")
Branch: 1 branch
BranchTrueFalseTotal
if $NumberOfConstants > 65535 0 0 0
1825 if ($NumberOfConstants > 65535);
1826 0 $CodeSize += WAP::wmls::multibyte::size($NumberOfConstants);
1827 0 $CodeSize += WAP::wmls::multibyte::size($CharacterSet);
1828 0 $CodeSize += $constantVisitor->{size};
1829 # PragmaPool
1830 0 my $pragmaVisitor = new WAP::wmls::pragmaVisitor($parser);
1831 $parser->YYData->{PragmaList}->visit($pragmaVisitor)
1832 0 ▶ if (defined $parser->YYData->{PragmaList});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parser->YYData->{"PragmaList"} 0 0 0
1833 0 my $NumberOfPragmas = $pragmaVisitor->{nb};
1834 0 ▶ $parser->genError($parser->YYData->{PragmaList}, "Too many pragmas ($NumberOfPragmas)")
Branch: 1 branch
BranchTrueFalseTotal
if $NumberOfPragmas > 65535 0 0 0
1835 if ($NumberOfPragmas > 65535);
1836 0 $CodeSize += WAP::wmls::multibyte::size($NumberOfPragmas);
1837 0 $CodeSize += $pragmaVisitor->{size};
1838 # FunctionPool
1839 0 my $NumberOfFunctions = 0;
1840 0 ▶ for (my $func = $parser->YYData->{FunctionList}; defined $func; $func = $func->{Next}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $func) 0 0 0
1841 0 $NumberOfFunctions ++;
1842 }
1843 0 ▶ $parser->genError($parser->YYData->{FunctionList}, "Too many functions ($NumberOfFunctions).\n")
Branch: 1 branch
BranchTrueFalseTotal
if $NumberOfFunctions > 255 0 0 0
1844 if ($NumberOfFunctions > 255);
1845 0 $CodeSize += 1; # NumberOfFunctions
1846 0 my $NumberOfFunctionNames = 0;
1847 0 ▶ for (my $func = $parser->YYData->{FunctionList}; defined $func; $func = $func->{Next}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $func) 0 0 0
1848 0 my $def = $func->{OpCode}->{Definition};
1849 0 ▶ next if ($def->{Type} ne 'PUBLIC_FUNC');
Branch: 1 branch
BranchTrueFalseTotal
if $def->{"Type"} ne "PUBLIC_FUNC" 0 0 0
1850 0 $NumberOfFunctionNames ++;
1851 0 $CodeSize += 1; # idx
1852 0 $CodeSize += 1; # length
1853 0 $CodeSize += length $def->{Symbol};
1854 }
1855 0 ▶ $parser->genError($parser->YYData->{FunctionList}->{OpCode}, "No external function defined.\n")
Branch: 1 branch
BranchTrueFalseTotal
unless $NumberOfFunctionNames 0 0 0
1856 unless ($NumberOfFunctionNames);
1857 0 $CodeSize += 1; # NumberOfFunctionNames
1858 0 my $codeVisitor = new WAP::wmls::codeVisitor($parser);
1859 $parser->YYData->{FunctionList}->visitActive($codeVisitor)
1860 0 ▶ if (defined $parser->YYData->{FunctionList});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parser->YYData->{"FunctionList"} 0 0 0
1861 0 $CodeSize += $codeVisitor->{size};
1862
1863 0 ▶ unless (exists $parser->YYData->{nb_error}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $parser->YYData->{"nb_error"}) 0 0 0
1864 0 my $filename = $parser->YYData->{filename};
1865 0 $filename =~ s/\.wmls$//;
1866 0 $filename .= '.wmlsc';
1867 0 ▶ open $WAP::wmls::asm::OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $WAP::wmls::asm::OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1868 or die "can't open $filename ($!)\n";
1869 0 binmode $WAP::wmls::asm::OUT, ':raw';
1870
1871 0 WAP::wmls::asm::asmComment($filename);
1872 0 WAP::wmls::asm::asmComment("");
1873 0 WAP::wmls::asm::asmComment("Bytecode Header");
1874 0 WAP::wmls::asm::asmComment("");
1875 0 WAP::wmls::asm::asmByte("VersionNumber", 16 * (WMLS_MAJOR_VERSION - 1) + WMLS_MINOR_VERSION);
1876 0 WAP::wmls::asm::asmMultiByte("CodeSize", $CodeSize);
1877 0 WAP::wmls::asm::asmComment("Constant Pool");
1878 0 WAP::wmls::asm::asmComment("");
1879 0 WAP::wmls::asm::asmMultiByte("NumberOfConstants", $NumberOfConstants);
1880 0 WAP::wmls::asm::asmMultiByte("CharacterSet", $CharacterSet);
1881 0 $constantVisitor->{action} = 1;
1882 $parser->YYData->{PragmaList}->visit($constantVisitor)
1883 0 ▶ if (defined $parser->YYData->{PragmaList});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parser->YYData->{"PragmaList"} 0 0 0
1884 $parser->YYData->{FunctionList}->visitActive($constantVisitor)
1885 0 ▶ if (defined $parser->YYData->{FunctionList});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parser->YYData->{"FunctionList"} 0 0 0
1886 0 WAP::wmls::asm::asmComment("Pragma Pool");
1887 0 WAP::wmls::asm::asmComment("");
1888 0 WAP::wmls::asm::asmMultiByte("NumberOfPragmas", $NumberOfPragmas);
1889 0 $pragmaVisitor->{nb} = 0;
1890 0 $pragmaVisitor->{action} = 1;
1891 $parser->YYData->{PragmaList}->visit($pragmaVisitor)
1892 0 ▶ if (defined $parser->YYData->{PragmaList});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parser->YYData->{"PragmaList"} 0 0 0
1893 0 WAP::wmls::asm::asmComment("Function Pool");
1894 0 WAP::wmls::asm::asmComment("");
1895 0 WAP::wmls::asm::asmByte("NumberOfFunctions", $NumberOfFunctions);
1896 0 WAP::wmls::asm::asmComment("Function Name Table");
1897 0 WAP::wmls::asm::asmComment("");
1898 0 WAP::wmls::asm::asmByte("NumberOfFunctionNames", $NumberOfFunctionNames);
1899 0 ▶ for (my $func = $parser->YYData->{FunctionList}; defined $func; $func = $func->{Next}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $func) 0 0 0
1900 0 my $def = $func->{OpCode}->{Definition};
1901 0 ▶ next if ($def->{Type} ne 'PUBLIC_FUNC');
Branch: 1 branch
BranchTrueFalseTotal
if $def->{"Type"} ne "PUBLIC_FUNC" 0 0 0
1902 0 WAP::wmls::asm::asmFunctionName($def->{ID}, $def->{Symbol});
1903 }
1904 0 WAP::wmls::asm::asmComment("Functions");
1905 0 WAP::wmls::asm::asmComment("");
1906 0 $codeVisitor->{action} = 1;
1907 $parser->YYData->{FunctionList}->visitActive($codeVisitor)
1908 0 ▶ if (defined $parser->YYData->{FunctionList});
Branch: 1 branch
BranchTrueFalseTotal
if defined $parser->YYData->{"FunctionList"} 0 0 0
1909
1910 0 close $WAP::wmls::asm::OUT;
1911 0 ▶ unlink($filename) if (exists $parser->YYData->{nb_error});
Branch: 1 branch
BranchTrueFalseTotal
if exists $parser->YYData->{"nb_error"} 0 0 0
1912 }
1913 0 return;
1914 }
1915
1916 1 1;
1917
« wmls/lexer.pm ↑ Summary wmls/node.pm »