Create a new compiler instance by name or return the previous
instance with the same name.

@param string $compiler name

@return NodeCompilerInterface
12543
private function getNamedCompiler($compiler)
    {
        if (!isset($this->namedCompilers[$compiler])) {
            $this->namedCompilers[$compiler] = new $compiler($this);
        }

        return $this->namedCompilers[$compiler];
    }
952542
public function compile($args, $compiler)
    {
        // check and get attributes
        $_attr = $this->getAttributes($compiler, $args);

        list($openTag, $nocache) = $this->closeTag($compiler, array('section'));
        $this->openTag($compiler, 'sectionelse', array('sectionelse', $nocache));

        return "<?php endfor; else: ?>";
    }
1083438
public function compile(Twig_Compiler $compiler)
    {
        $compiler->addDebugInfo($this);

        $compiler->write("\$context['__cms_component_params'] = [];\n");

        for ($i = 1; $i < count($this->getNode('nodes')); $i++) {
            $compiler->write("\$context['__cms_component_params']['".$this->getAttribute('names')[$i-1]."'] = ");
            $compiler->subcompile($this->getNode('nodes')->getNode($i));
            $compiler->write(";\n");
        }

        $compiler
            ->write("echo \$this->env->getExtension('Cms\Twig\Extension')->componentFunction(")
            ->subcompile($this->getNode('nodes')->getNode(0))
            ->write(", \$context['__cms_component_params']")
            ->write(");\n")
        ;

        $compiler->write("unset(\$context['__cms_component_params']);\n");
    }
266801
public function compile(array $expression, CompilationContext $compilationContext)
    {
        if (!isset($expression['parameters'])) {
            throw new CompilerException("Invalid 'parameters' for new-type", $expression);
        }

        switch ($expression['internal-type']) {
            case 'array':
                $compilationContext->headersManager->add('kernel/array');
                $functionName = 'create_array';
                break;

            case 'string':
                $compilationContext->headersManager->add('kernel/string');
                $functionName = 'create_string';
                break;

            default:
                throw new CompilerException('Cannot build instance of type', $expression);
        }

        $builder = new FunctionCallBuilder(
            $functionName,
            $expression['parameters'],
            1,
            $expression['file'],
            $expression['line'],
            $expression['char']
        );

        /**
         * Implicit type coercing.
         */
        $castBuilder = new CastOperatorBuilder($expression['internal-type'], $builder);

        $expression = new Expression($castBuilder->get());
        $expression->setReadOnly($this->readOnly);

        try {
            return $expression->compile($compilationContext);
        } catch (Exception $e) {
            throw new CompilerException($e->getMessage(), $expression, $e->getCode(), $e);
        }
    }
647439
protected function createCompiler(OutputInterface $output)
    {
        $logger   = $this->createConsoleLogger($output);
        $compiler = new Compiler($logger);

        return $compiler;
    }
702086
def get_compiler(compiler, **compiler_attrs):
    """"""
    if compiler is None or isinstance(compiler, str):
        cc = ccompiler.new_compiler(compiler=compiler, verbose=0)
        customize_compiler(cc)
        if cc.compiler_type == 'mingw32':
            customize_mingw(cc)
    else:
        cc = compiler
        customize_gcc(cc)

    for name, val in compiler_attrs.items():
        setattr(cc, name, val)

    return cc
9244
public function compile($args, $compiler)
    {
        $_attr = $this->getAttributes($compiler, $args);
        if ($_attr['nocache'] === true) {
            $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
        }
        // this tag does not return compiled code
        $compiler->has_code = true;

        return $compiler->smarty->right_delimiter;
    }
1373636
public function compile($args, $compiler)
    {
        // check and get attributes
        $_attr = $this->getAttributes($compiler, $args);

        // compile always as nocache
        $compiler->tag_nocache = true;

        // display debug template
        $_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl); ?>";

        return $_output;
    }
169901
protected function pickCompiler($definition)
    {
        foreach ($this->compilers as $i => $compiler) {
            if ($compiler->supports($definition)) {
                if (0 != $i) {
                    // Move compiler to top to improve next pick
                    unset($this->compilers[$i]);
                    array_unshift($this->compilers, $compiler);
                }

                return $this->compilers[0];
            }
        }

        throw new \RuntimeException('No compiler is able to work with the resource');
    }
152964
public function compile(Twig_Compiler $compiler)
    {
        $name = $this->getAttribute('name');
        $reference = $this->getAttribute('reference');
        $variable = $this->getAttribute('variable');
        $offset = $this->getAttribute('offset');
        $offset = ($offset === null || $offset === false || strval(intval($offset)) != $offset ? 'null' : $offset);

        if ($variable) {
            $compiler
                ->addDebugInfo($this)
                ->write("if (!\$this->env->getExtension('defer')->contains('{$reference}', '$name|' . \$context['{$variable}'])) {\n")
                ->indent()
                    ->write("\$this->env->getExtension('defer')->cache('{$reference}', \$this->renderBlock('{$name}', \$context, \$blocks), '$name|' . \$context['{$variable}'], {$offset});\n")
                ->outdent()
                ->write("}\n")
            ;

            return;
        }
        if ($this->getAttribute('unique')) {
            $compiler
                ->addDebugInfo($this)
                ->write("if (!\$this->env->getExtension('defer')->contains('{$reference}', '{$name}')) {\n")
                ->indent()
                    ->write("\$this->env->getExtension('defer')->cache('{$reference}', \$this->renderBlock('{$name}', \$context, \$blocks), '{$name}', {$offset});\n")
                ->outdent()
                ->write("}\n")
            ;

            return;
        }
        $compiler
            ->addDebugInfo($this)
            ->write("\$this->env->getExtension('defer')->cache('{$reference}', \$this->renderBlock('{$name}', \$context, \$blocks), null, {$offset});\n")
        ;
    }
164181
public function compile(Twig_Compiler $compiler)
    {
        $compiler
            ->addDebugInfo($this)
            ->write('')
            ->subcompile($this->getNode('var'))
            ->raw(' = ')
        ;

        if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) {
            $compiler->raw("\$this");
        } else {
            $compiler
                ->raw('$this->env->loadTemplate(')
                ->subcompile($this->getNode('expr'))
                ->raw(")")
            ;
        }

        $compiler->raw(";\n");
    }
1046375
public function compile(\Twig_Compiler $compiler)
    {
        $compiler->addDebugInfo($this);

        $compiler
            ->raw('ob_start();' . PHP_EOL)
            ->subcompile($this->getNode('source'))
            ->raw('$source = ob_get_contents();' . PHP_EOL)
            ->raw('ob_clean();' . PHP_EOL)
            ->raw('echo $this->env->getExtension(\'highlight_extension\')->highlight(' . PHP_EOL)
            ->raw('   $source,' . PHP_EOL)
            ->raw('   \'' . $this->getNode('lexer')->getAttribute('name') . '\' ' . PHP_EOL)
            ->raw(');' . PHP_EOL);
    }
412167
public function createParser($name)
    {
        $parser = new Parser();

        $parser->setServer($this->createServer($name));

        $compiler = new Compiler(
            $parser->getServer()->getStartMultiLine(),
            $parser->getServer()->getEndMultiLine(),
            $parser->getServer()->getSimpleDirective()
        );

        $parser->setCompiler($compiler);

        return $parser;
    }
1076133
public function compile(Compiler $compiler)
    {
        $compiler->addDebugInfo($this);

        $compiler
            ->write('throw new \RuntimeException(')
            ->subcompile($this->getNode('message'))
            ->write(', ')
            ->write($this->getAttribute('code') ?: 500)
            ->write(");\n");
    }
1245198
public function create($className, $filePath)
    {
        $compiler = new CompilerFile($this->config, new AliasManager(), $this->filesystem);

        $compiler->setClassName($className);
        $compiler->setFilePath($filePath);
        $compiler->setLogger($this->logger);

        return $compiler;
    }
977981
public function compile($args, $compiler)
    {
        static $_is_legal_scope = array('local' => true, 'parent' => true, 'root' => true, 'global' => true);
        // check and get attributes
        $_attr = $this->getAttributes($compiler, $args);

        if ($_attr['nocache'] === true) {
            $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
        }

        // save possible attributes
        $conf_file = $_attr['file'];
        if (isset($_attr['section'])) {
            $section = $_attr['section'];
        } else {
            $section = 'null';
        }
        $scope = 'local';
        // scope setup
        if (isset($_attr['scope'])) {
            $_attr['scope'] = trim($_attr['scope'], "'\"");
            if (isset($_is_legal_scope[$_attr['scope']])) {
                $scope = $_attr['scope'];
            } else {
                $compiler->trigger_template_error('illegal value for "scope" attribute', $compiler->lex->taglineno);
            }
        }
        // create config object
        $_output = "<?php  \$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty, \$_smarty_tpl);";
        $_output .= "\$_config->loadConfigVars($section, '$scope'); ?>";

        return $_output;
    }
1254991
public function compile(Compiler $compiler)
    {
        $compiler->addDebugInfo($this);

        $compiler->write("\$assets = \\Grav\\Common\\Grav::instance()['assets'];\n");

        if ($this->getNode('attributes') !== null) {
            $compiler
                ->write('$attributes = ')
                ->subcompile($this->getNode('attributes'))
                ->raw(";\n")
                ->write("if (!is_array(\$attributes)) {\n")
                ->indent()
                ->write("throw new UnexpectedValueException('{% {$this->tagName} with x %}: x is not an array');\n")
                ->outdent()
                ->write("}\n");
        } else {
            $compiler->write('$attributes = [];' . "\n");
        }

        if ($this->getNode('group') !== null) {
            $compiler
                ->write("\$attributes['group'] = ")
                ->subcompile($this->getNode('group'))
                ->raw(";\n")
                ->write("if (!is_string(\$attributes['group'])) {\n")
                ->indent()
                ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');\n")
                ->outdent()
                ->write("}\n");
        }

        if ($this->getNode('priority') !== null) {
            $compiler
                ->write("\$attributes['priority'] = (int)(")
                ->subcompile($this->getNode('priority'))
                ->raw(");\n");
        }

        if ($this->getNode('file') !== null) {
            $compiler
                ->write('$assets->addCss(')
                ->subcompile($this->getNode('file'))
                ->raw(", \$attributes);\n");
        } else {
            $compiler
                ->write("ob_start();\n")
                ->subcompile($this->getNode('body'))
                ->write('$content = ob_get_clean();' . "\n")
                ->write("\$assets->addInlineCss(\$content, \$attributes);\n");
        }
    }