1 | <?php |
||
16 | class ScriptCreator |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $script = ''; |
||
22 | |||
23 | /** |
||
24 | * @var Opcodes |
||
25 | */ |
||
26 | private $opcodes; |
||
27 | |||
28 | /** |
||
29 | * @var Math |
||
30 | */ |
||
31 | private $math; |
||
32 | |||
33 | /** |
||
34 | * @param Math $math |
||
35 | * @param Opcodes $opcodes |
||
36 | * @param BufferInterface|null $buffer |
||
37 | */ |
||
38 | 1857 | public function __construct(Math $math, Opcodes $opcodes, BufferInterface $buffer = null) |
|
47 | |||
48 | /** |
||
49 | * @param array $sequence |
||
50 | * @return $this |
||
51 | */ |
||
52 | 117 | public function sequence(array $sequence) |
|
72 | |||
73 | /** |
||
74 | * Add an opcode to the script |
||
75 | * |
||
76 | * @param string $name |
||
77 | * @return $this |
||
78 | */ |
||
79 | 399 | public function op($name) |
|
85 | |||
86 | /** |
||
87 | * Push data into the stack. |
||
88 | * |
||
89 | * @param $data |
||
90 | * @return $this |
||
91 | * @throws \Exception |
||
92 | */ |
||
93 | 435 | public function push(BufferInterface $data) |
|
123 | |||
124 | /** |
||
125 | * @param int $n |
||
126 | * @return $this |
||
127 | */ |
||
128 | public function int($n) |
||
140 | |||
141 | /** |
||
142 | * @param Serializable $object |
||
143 | * @return $this |
||
144 | */ |
||
145 | public function pushSerializable(Serializable $object) |
||
150 | |||
151 | /** |
||
152 | * @param Serializable[] $serializable |
||
153 | * @return $this |
||
154 | */ |
||
155 | public function pushSerializableArray(array $serializable) |
||
163 | |||
164 | /** |
||
165 | * @param ScriptInterface $script |
||
166 | * @return $this |
||
167 | */ |
||
168 | 123 | public function concat(ScriptInterface $script) |
|
173 | |||
174 | /** |
||
175 | * @return ScriptInterface |
||
176 | */ |
||
177 | 1851 | public function getScript() |
|
181 | } |
||
182 |