1 | <?php |
||
14 | class Statement |
||
15 | { |
||
16 | /** |
||
17 | * @param Node\Stmt $stmt |
||
18 | * @throws RuntimeException |
||
19 | * @return AbstractCompiler |
||
20 | */ |
||
21 | 50 | protected function factory($stmt) |
|
22 | { |
||
23 | 50 | switch (get_class($stmt)) { |
|
24 | 50 | case Stmt\Break_::class: |
|
25 | 3 | return new Statement\BreakSt(); |
|
26 | 50 | case Stmt\Case_::class: |
|
27 | 3 | return new Statement\CaseSt(); |
|
28 | 50 | case Stmt\Continue_::class: |
|
29 | 1 | return new Statement\ContinueSt(); |
|
30 | 50 | case Stmt\Echo_::class: |
|
31 | 6 | return new Statement\EchoSt(); |
|
32 | 48 | case Stmt\Return_::class: |
|
33 | 34 | return new Statement\ReturnSt(); |
|
34 | 24 | case Stmt\While_::class: |
|
35 | 5 | return new Statement\WhileSt(); |
|
36 | 22 | case Stmt\Switch_::class: |
|
37 | 3 | return new Statement\SwitchSt(); |
|
38 | 22 | case Stmt\If_::class: |
|
39 | 11 | return new Statement\IfSt(); |
|
40 | 17 | case Stmt\ElseIf_::class: |
|
41 | 4 | return new Statement\ElseIfSt(); |
|
42 | 16 | case Stmt\Else_::class: |
|
43 | 2 | return new Statement\ElseSt(); |
|
44 | 15 | case Stmt\Do_::class: |
|
45 | 5 | return new Statement\DoSt(); |
|
46 | 13 | case Stmt\For_::class: |
|
47 | 8 | return new Statement\ForSt(); |
|
48 | 6 | case Stmt\Foreach_::class: |
|
49 | 2 | return new Statement\ForeachSt(); |
|
50 | 6 | case Stmt\TryCatch::class: |
|
51 | 2 | return new Statement\TryCatchSt(); |
|
52 | 6 | case Stmt\Catch_::class: |
|
53 | 2 | return new Statement\CatchSt(); |
|
54 | 5 | case Stmt\Finally_::class: |
|
55 | return new Statement\FinallySt(); |
||
56 | 5 | case Stmt\Throw_::class: |
|
57 | 2 | return new Statement\ThrowSt(); |
|
58 | 4 | case Stmt\Global_::class: |
|
59 | 2 | return new Statement\GlobalSt(); |
|
60 | 3 | case Stmt\Static_::class: |
|
61 | 2 | return new Statement\StaticSt(); |
|
62 | 2 | case Stmt\Declare_::class: |
|
63 | return new Statement\DeclareSt(); |
||
64 | 2 | case Stmt\Const_::class: |
|
65 | return new Statement\ConstSt(); |
||
66 | 2 | case Stmt\Unset_::class: |
|
67 | 1 | return new Statement\UnsetSt(); |
|
68 | 1 | } |
|
69 | |||
70 | 1 | throw new RuntimeException('Unknown statement: ' . get_class($stmt)); |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * @param Node\Stmt $stmt |
||
75 | * @param Context $context |
||
76 | */ |
||
77 | 51 | public function __construct(Node\Stmt $stmt, Context $context) |
|
100 | } |
||
101 |