public function compile(Context $context)
{
if ($this->compiled) {
return true;
}
$context->setFilepath($this->filepath);
$this->compiled = true;
$context->clearSymbols();
$context->scopePointer = $this->getPointer();
$context->setScope(null);
if (count($this->statement->stmts) == 0) {
return $context->notice('not-implemented-function', sprintf('Closure %s() is not implemented', $this->name), $this->statement);
}
if (count($this->statement->params) > 0) {
/** @var Node\Param $parameter */
foreach ($this->statement->params as $parameter) {
$type = CompiledExpression::UNKNOWN;
if ($parameter->type) {
if (is_string($parameter->type)) {
$type = Types::getType($parameter->type);
} elseif ($parameter->type instanceof Node\Name) {
$type = CompiledExpression::OBJECT;
}
}
$context->addVariable(new Parameter($parameter->name, null, $type, $parameter->byRef));
}
}
foreach ($this->statement->stmts as $st) {
\PHPSA\nodeVisitorFactory($st, $context);
}
return true;
}