comparison vendor/psy/psysh/src/ExecutionLoop.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents 5fb285c0d0e3
children 129ea1e6d783
comparison
equal deleted inserted replaced
15:e200cb7efeb3 16:c2387f117808
9 * file that was distributed with this source code. 9 * file that was distributed with this source code.
10 */ 10 */
11 11
12 namespace Psy; 12 namespace Psy;
13 13
14 use Psy\Exception\BreakException;
15 use Psy\Exception\ErrorException; 14 use Psy\Exception\ErrorException;
16 use Psy\Exception\ThrowUpException;
17 use Psy\Exception\TypeErrorException;
18 15
19 /** 16 /**
20 * The Psy Shell execution loop. 17 * The Psy Shell execution loop.
21 */ 18 */
22 class ExecutionLoop 19 class ExecutionLoop
30 */ 27 */
31 public function run(Shell $shell) 28 public function run(Shell $shell)
32 { 29 {
33 $this->loadIncludes($shell); 30 $this->loadIncludes($shell);
34 31
35 $closure = new ExecutionClosure($shell); 32 $closure = new ExecutionLoopClosure($shell);
36 33 $closure->execute();
37 do {
38 $shell->beforeLoop();
39
40 try {
41 $shell->getInput();
42 $_ = $closure->execute();
43 $shell->writeReturnValue($_);
44 } catch (BreakException $_e) {
45 $shell->writeException($_e);
46
47 return;
48 } catch (ThrowUpException $_e) {
49 $shell->writeException($_e);
50
51 throw $_e;
52 } catch (\TypeError $_e) {
53 $shell->writeException(TypeErrorException::fromTypeError($_e));
54 } catch (\Error $_e) {
55 $shell->writeException(ErrorException::fromError($_e));
56 } catch (\Exception $_e) {
57 $shell->writeException($_e);
58 }
59
60 $shell->afterLoop();
61 } while (true);
62 } 34 }
63 35
64 /** 36 /**
65 * Load user-defined includes. 37 * Load user-defined includes.
66 * 38 *