/** * @param ArrayContainer $input * @param ArrayContainer $output * @param MemoryContainer $memory * @param ArrayContainer $program */ public function prepareResponse(ArrayContainer $input, ArrayContainer $output, MemoryContainer $memory, ArrayContainer $program) { $this->variables['input'] = implode(array_map([$this, "formatCharacter"], $input->getArray())); $this->variables['output'] = implode(array_map([$this, "formatCharacter"], $output->getArray())); $this->variables['memory'] = $memory->getArray(); $this->variables['program'] = implode($program->getArray()); }
public function run() { $commandFactory = new CommandFactory($this->input, $this->output, $this->memory, $this->program, $this->loop); while ($command = $this->program->getValue()) { if ($command === 0) { break; } $commandClass = $commandFactory->getCommand($command); if ($commandClass instanceof Command) { $commandClass->execute(); } $this->program->incrementPointer(); } $this->response->prepareResponse($this->input, $this->output, $this->memory, $this->program); $this->response->processResponse(); }
public function execute() { $this->output->setValue($this->memory->getValue()); $this->output->incrementPointer(); }
public function execute() { $this->memory->setValue($this->input->getValue()); }