PHPCompiler\Backend\PHP7\PECL::getVarName PHP Method

getVarName() protected method

protected getVarName ( Operand $var )
$var PHPCfg\Operand
    protected function getVarName(Operand $var)
    {
        if ($var instanceof Operand\Literal) {
            switch ($this->mapToCType($var->type)) {
                case 'zend_bool':
                case 'zend_long':
                    return (int) $var->value;
                case 'double':
                    // TODO: make this locale independent
                    return sprintf("%d", $var->value);
                case 'zend_string*':
                    if (!isset($this->state->stringConstants[$var->value])) {
                        $this->state->stringConstants[$var->value] = new \StdClass();
                        $this->state->stringConstants[$var->value]->value = $var->value;
                        $this->state->stringConstants[$var->value]->idx = count($this->state->stringConstants) - 1;
                    }
                    return $this->state->uppername . '_G(string_constants)[' . $this->state->stringConstants[$var->value]->idx . ']';
                default:
                    throw new \RuntimeException("Unknown type provided for literal: {$var->type}");
            }
        } elseif (!$this->state->scope->contains($var)) {
            $this->state->scope[$var] = count($this->state->scope) + 1;
            $varName = "v" . $this->state->scope[$var];
            $type = $this->mapToCType($var->type);
            $this->state->decl[] = "{$type} {$varName};";
            switch ($type) {
                case 'zend_string*':
                case 'HashTable*':
                    $this->state->decl[] = "zend_bool free_{$varName} = 0;";
                    $this->state->freeFlags[$varName] = $type;
            }
            return $varName;
        }
        return 'v' . $this->state->scope[$var];
    }