Zephir\Call::addCallStatusFlag PHP Method

addCallStatusFlag() public method

Add the last-call-status flag to the current symbol table
public addCallStatusFlag ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext
    public function addCallStatusFlag(CompilationContext $compilationContext)
    {
        if (!$compilationContext->symbolTable->hasVariable('ZEPHIR_LAST_CALL_STATUS')) {
            $callStatus = new Variable('int', 'ZEPHIR_LAST_CALL_STATUS', $compilationContext->currentBranch);
            $callStatus->setIsInitialized(true, $compilationContext, array());
            $callStatus->increaseUses();
            $callStatus->setReadOnly(true);
            $compilationContext->symbolTable->addRawVariable($callStatus);
        }
    }

Usage Example

 /**
  *
  * @param array $expression
  * @param Call $call
  * @param CompilationContext $context
  */
 public function optimize(array $expression, Call $call, CompilationContext $context)
 {
     if (!isset($expression['parameters'])) {
         throw new CompilerException("This function requires parameters", $expression);
     }
     if (count($expression['parameters']) != 2) {
         throw new CompilerException("This function only requires two parameter", $expression);
     }
     /**
      * Process the expected symbol to be returned
      */
     $call->processExpectedReturn($context);
     $symbolVariable = $call->getSymbolVariable(true, $context);
     if (!$symbolVariable->isVariable()) {
         throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
     }
     /**
      * Add the last call status to the current symbol table
      */
     $call->addCallStatusFlag($context);
     $context->headersManager->add('kernel/object');
     $symbolVariable->setDynamicTypes('object');
     $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression);
     if ($call->mustInitSymbolVariable()) {
         $symbolVariable->initVariant($context);
     }
     /**
      * Add the last call status to the current symbol table
      */
     $call->addCallStatusFlag($context);
     $symbol = $context->backend->getVariableCode($symbolVariable);
     $context->codePrinter->output('ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(' . $symbol . ', ' . $resolvedParams[0] . ', ' . $resolvedParams[1] . ' TSRMLS_CC);');
     $call->addCallStatusOrJump($context);
     return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
 }
All Usage Examples Of Zephir\Call::addCallStatusFlag