public function register($name, FunctionData $func) { $name = strtolower($name); if (isset($this->functions[$name])) { throw new \RuntimeException("Function {$name} already defined"); } $func->setName($name); $this->functions[$name] = $func; }
public function execute(OpArray $opArray, array &$symbolTable = array(), FunctionData $function = null, array $args = array(), Zval $result = null, Objects\ClassInstance $ci = null) { $shutdownScope = $this->shutdown; if ($this->shutdown == self::FINISHED_SHUTDOWN) { return; } $opArray->registerExecutor($this); $scope = new ExecuteData($this, $opArray, $function); $scope->arguments = $args; $scope->ci = $ci; $preExecute = $this->preExecute; $postExecute = $this->postExecute; if ($this->current) { $scope->parent = $this->current; } $this->current = $scope; if ($symbolTable || $function) { $scope->symbolTable =& $symbolTable; } else { $scope->symbolTable =& $this->executorGlobals->symbolTable; } $scope->returnValue = $result ?: Zval::ptrFactory(); if ($function && $function->isByRef()) { $scope->returnValue->makeRef(); } while ($this->shutdown == $shutdownScope && $scope->opLine) { if ($preExecute) { call_user_func($preExecute, $scope); } $ret = $scope->opLine->execute($scope); if ($postExecute) { call_user_func($postExecute, $scope, $ret); } if ($this->shutdown == $shutdownScope && $this->executorGlobals->timeLimit && $this->executorGlobals->timeLimitEnd < time()) { $limit = $this->executorGlobals->timeLimit; $message = sprintf('Maximum execution time of %d second%s exceeded', $limit, $limit == 1 ? '' : 's'); $this->errorHandler->handle($this, E_ERROR, $message, $opArray->getFileName(), $scope->opLine->lineno, '', false); return; } switch ($ret) { case self::DO_RETURN: $this->current = $this->current->parent; return; case self::DO_SHUTDOWN: $this->shutdown(); return; } } if ($this->shutdown) { return; } die('Should never reach this point!'); }