Разваливается switch, теряются goto
Issue #76
new
Тестовый код:
<?php
SCANNER_TOP:
$token = current($tokens);
switch ($token[0]) {
case 'ANNOTATION_CLASS':
$contentEnd = false;
$annotationIndex++;
$class = substr($token[1], 1);
$class = $this->nameInformation->resolveName($class);
$annotations[$annotationIndex] = [$class, null];
goto SCANNER_CONTINUE;
// goto no break needed
case 'ANNOTATION_CONTENT_START':
$annotations[$annotationIndex][1] = '';
//fall-through
case 'ANNOTATION_CONTENT_END':
case 'ANNOTATION_CONTENT':
case 'ANNOTATION_WHITESPACE':
case 'ANNOTATION_NEWLINE':
if (!$contentEnd && isset($annotations[$annotationIndex]) && is_string($annotations[$annotationIndex][1])) {
$annotations[$annotationIndex][1] .= $token[1];
}
if ($token[0] === 'ANNOTATION_CONTENT_END') {
$contentEnd = true;
}
goto SCANNER_CONTINUE;
}
SCANNER_CONTINUE:
if (next($tokens) === false) {
goto SCANNER_END;
}
goto SCANNER_TOP;
SCANNER_END:
Выход
<?php
switch ($token[0]) {
}
/*
0 3 SEND_REF ?0 $tokens ?1 ;60 <<72
1 3 DO_FCALL $0= "current" ?0 ;1
2 3 ASSIGN $token $0:current($tokens) ;0
3 4 FETCH_DIM_R $2= $token 0 ;0
4 5 CASE #3= $2:$token[0] "ANNOTATION_CLASS" ;0 >>6
5 5 JMPZ ?0 #3:"ANNOTATION_NEWLINE" ?25 ;0 >>25
6 6 ASSIGN $contentEnd false ;0 <<4
7 7 POST_INC #5= $annotationIndex ?0 ;0
8 7 FREE ?0 #5:next($tokens) === false ?0 ;0
9 8 FETCH_DIM_R $6= $token 1 ;0
10 8 SEND_VAR ?0 $6:$token[1] ?1 ;60
11 8 SEND_VAL ?0 1 ?2 ;60
12 8 DO_FCALL $7= "substr" ?0 ;2
13 8 ASSIGN $class $7:substr($token[1], 1) ;0
14 9 FETCH_OBJ_R $9= ?7 "nameInformation" ;268435456
15 9 INIT_METHOD_CALL ?0 $9:$this->nameInformation "resolveName" ;0
16 9 SEND_VAR ?0 $class ?1 ;61
17 9 DO_FCALL_BY_NAME $11= ?0 ?0 ;1
18 9 ASSIGN $class $11:$this->nameInformation->resolveName($class) ;0
19 10 INIT_ARRAY #14= $class ?0 ;0
20 10 ADD_ARRAY_ELEMENT #14= NULL ?0 ;0
21 10 ASSIGN_DIM $annotations $annotationIndex ;0
22 10 OP_DATA ?0 #14:array($class, NULL) $15:next($tokens) === false ;0
23 11 GOTO ?0 ?66 1 ;0
24 13 JMP ?0 ?27 ?0 ;0 >>27
25 13 CASE #3= $2:$token[0] "ANNOTATION_CONTENT_START" ;0 >>27 <<5
26 13 JMPZ ?0 #3:"ANNOTATION_NEWLINE" ?31 ;0 >>31
27 14 FETCH_DIM_W $16= $annotations $annotationIndex ;0 <<24,25
28 14 ASSIGN_DIM $16:$annotations[$annotationIndex][1] 1 ;0
29 14 OP_DATA ?0 "" $18:next($tokens) === false ;0
30 16 JMP ?0 ?33 ?0 ;0 >>33
31 16 CASE #3= $2:$token[0] "ANNOTATION_CONTENT_END" ;0 >>33 <<26
32 16 JMPZ ?0 #3:"ANNOTATION_NEWLINE" ?34 ;0 >>34
33 17 JMP ?0 ?36 ?0 ;0 >>36 <<30,31
34 17 CASE #3= $2:$token[0] "ANNOTATION_CONTENT" ;0 >>36 <<32
35 17 JMPZ ?0 #3:"ANNOTATION_NEWLINE" ?37 ;0 >>37
36 18 JMP ?0 ?39 ?0 ;0 >>39 <<33,34
37 18 CASE #3= $2:$token[0] "ANNOTATION_WHITESPACE" ;0 >>39 <<35
38 18 JMPZ ?0 #3:"ANNOTATION_NEWLINE" ?40 ;0 >>40
39 19 JMP ?0 ?42 ?0 ;0 >>42 <<36,37
40 19 CASE #3= $2:$token[0] "ANNOTATION_NEWLINE" ;0 >>42 <<38
41 19 JMPZ ?0 #3:"ANNOTATION_NEWLINE" ?65 ;0 >>65
42 20 BOOL_NOT #19= $contentEnd ?0 ;0 <<39,40
43 20 JMPZ_EX #19= #19:is_string($annotations[$annotationIndex][1]) ?46 ;0 >>46
44 20 ISSET_ISEMPTY_DIM_OBJ #20= $annotations $annotationIndex ;33554432
45 20 BOOL #19= #20:isset($annotations[$annotationIndex]) ?0 ;0
46 20 JMPZ_EX #19= #19:is_string($annotations[$annotationIndex][1]) ?52 ;0 >>52 <<43
47 20 FETCH_DIM_R $21= $annotations $annotationIndex ;0
48 20 FETCH_DIM_R $22= $21:$annotations[$annotationIndex][1] 1 ;0
49 20 SEND_VAR ?0 $22:$annotations[$annotationIndex][1] ?1 ;60
50 20 DO_FCALL $23= "is_string" ?0 ;1
51 20 BOOL #19= $23:is_string($annotations[$annotationIndex][1]) ?0 ;0
52 20 JMPZ ?0 #19:is_string($annotations[$annotationIndex][1]) ?58 ;0 >>58 <<46
53 21 FETCH_DIM_R $26= $token 1 ;0
54 21 FETCH_DIM_RW $24= $annotations $annotationIndex ;0
55 21 ASSIGN_CONCAT $24:$annotations[$annotationIndex] 1 ;147
56 21 OP_DATA ?0 $26:$token[1] $27:next($tokens) === false ;0
57 22 JMP ?0 ?58 ?0 ;0 >>58
58 23 FETCH_DIM_R $28= $token 0 ;0 <<52,57
59 23 IS_IDENTICAL #29= $28:$token[0] "ANNOTATION_CONTENT_END" ;0
60 23 JMPZ ?0 #29:$token[0] === "ANNOTATION_CONTENT_END" ?63 ;0 >>63
61 24 ASSIGN $contentEnd true ;0
62 25 JMP ?0 ?63 ?0 ;0 >>63
63 26 GOTO ?0 ?66 1 ;0 <<60,62
64 27 JMP ?0 ?65 ?0 ;0 >>65
65 27 SWITCH_FREE ?0 $2:$token[0] ?0 ;0 <<41,64
66 29 SEND_REF ?0 $tokens ?1 ;60
67 29 DO_FCALL $31= "next" ?0 ;1
68 29 IS_IDENTICAL #32= $31:next($tokens) false ;0
69 29 JMPZ ?0 #32:next($tokens) === false ?72 ;0 >>72
70 30 JMP ?0 ?73 ?19800504 ;0 >>73
71 31 JMP ?0 ?72 ?0 ;0 >>72
72 32 JMP ?0 ?0 ?31 ;0 >>0 <<69,71
*/
$token = current($tokens);
$contentEnd = false;
$annotationIndex++;
$class = substr($token[1], 1);
$class = $this->nameInformation->resolveName($class);
$annotations[$annotationIndex] = array($class, NULL);
goto label66;
$annotations[$annotationIndex][1] = "";
$annotations[$annotationIndex][1] .= $token[1];
$contentEnd = true;
goto label66;
label66:
?>
со свитчами все совсем плохо, на кубике в декоде давно не видел
default: break;