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

compileFunction() protected method

protected compileFunction ( Function_ $func )
$func PHPCfg\Op\Stmt\Function_
    protected function compileFunction(Op\Stmt\Function_ $func)
    {
        $this->state->freeFlags = [];
        $this->state->functionHeaders[] = "PHP_FUNCTION({$func->name->value});";
        $this->state->functionEntry[] = "PHP_FE({$func->name->value}, arginfo_{$func->name->value})";
        $this->state->argInfo[] = $this->generateArgInfo($func);
        $code = "PHP_FUNCTION({$func->name->value}) {\n";
        $zpp = "";
        $required = 0;
        $optional = false;
        $total = 0;
        foreach ($func->params as $param) {
            $total++;
            if (!$optional && !$param->defaultVar) {
                $required++;
            } elseif (!$optional) {
                $zpp .= "\t\tZ_PARAM_OPTIONAL\n";
                $optional = true;
            }
            $zpp .= "\t\t" . $this->compileZppDecl($param) . "\n";
            $code .= $this->clearDecl("\t");
        }
        $this->state->freeFlags = [];
        // Do not generate free flags for parameters
        $code .= "\tZEND_PARSE_PARAMETERS_START({$required}, {$total})\n{$zpp}\tZEND_PARSE_PARAMETERS_END();\n";
        $body = $this->compileBody($func->stmts, "\t");
        $code .= $this->clearDecl("\t");
        $code .= $body;
        $code .= "\tfree-all-vars\n}\n";
        $this->state->functions[] = $this->handleFrees($code);
    }