PHPSA\Compiler\Expression\Assign::compileVariableDeclaration PHP Method

compileVariableDeclaration() protected method

protected compileVariableDeclaration ( CompiledExpression $variableName, CompiledExpression $value, Context $context )
$variableName PHPSA\CompiledExpression
$value PHPSA\CompiledExpression
$context PHPSA\Context
    protected function compileVariableDeclaration(CompiledExpression $variableName, CompiledExpression $value, Context $context)
    {
        switch ($variableName->getType()) {
            case CompiledExpression::STRING:
                break;
            default:
                $context->debug('Unexpected type of Variable name after compile');
                return new CompiledExpression();
        }
        $symbol = $context->getSymbol($variableName->getValue());
        if ($symbol) {
            $symbol->modify($value->getType(), $value->getValue());
            $context->modifyReferencedVariables($symbol, $value->getType(), $value->getValue());
        } else {
            $symbol = new \PHPSA\Variable($variableName->getValue(), $value->getValue(), $value->getType(), $context->getCurrentBranch());
            $context->addVariable($symbol);
        }
        $symbol->incSets();
    }