Compiles the arg node.

@param \Zicht\Tool\Script\Buffer $buffer
@return void
540241
public function compile(Buffer $buffer)
    {
        $name = explode('.', $this->name);
        $phpName = Util::toPhp($name);

        if ($this->conditional) {
            if ($this->multiple) {
                $buffer->writeln(sprintf('if ($z->isEmpty(%1$s) || array() === $z->get(%1$s)) {', $phpName))->indent(1);
            } else {
                $buffer->writeln(sprintf('if ($z->isEmpty(%s)) {', $phpName))->indent(1);
            }
            if (!$this->nodes[0]) {
                $buffer->writeln(
                    sprintf(
                        'throw new \RuntimeException(\'required variable %s is not defined\');',
                        join('.', $name)
                    )
                );
            }
        }
        if ($this->nodes[0]) {
            $buffer->write('$z->set(')->raw($phpName)->raw(', $z->value(');
            if ($this->multiple) {
                $buffer->raw('(array)(');
            }
            $this->nodes[0]->compile($buffer);
            if ($this->multiple) {
                $buffer->raw(')');
            }
            $buffer->raw('));')->eol();
        }

        if ($this->conditional) {
            $buffer->indent(-1)->writeln('}');
        }
    }
1329553
protected function compileInitialization(Buffer $buffer)
    {
        $configurationLoader = new Configuration\ConfigurationLoader(
            $this->staticConfig,
            new FileLocator(array(getcwd())),
            new Configuration\FileLoader(
                new Configuration\PathDefaultFileLocator(
                    'ZPLUGINPATH',
                    $this->staticPluginPaths
                )
            )
        );

        $compiler = new ContainerCompiler($configurationLoader->processConfiguration(), array());
        $this->phar['container.php'] = $compiler->compileContainerCode();
        $buffer->writeln('$container = require_once \'phar://z.phar/container.php\';');

        foreach ($configurationLoader->getPlugins() as $name => $plugin) {
            $className = get_class($plugin);
            $embeddedFilename = 'plugins/' . $name . '.php';

            $class = new \ReflectionClass($className);

            $this->phar[$embeddedFilename] = file_get_contents($class->getFileName());
            $buffer->write('require_once ')->asPhp('phar://z.phar/' . $embeddedFilename)->raw(';')->eol();
            $buffer->write('$p = new ')->write($className)->raw('();')->eol();
            $buffer->writeln('$p->setContainer($container);');
        }
        $buffer
            ->writeln('Zicht\Tool\Application::$HEADER = \'\';')
            ->write('$app = new Zicht\Tool\Application(')
            ->asPhp($this->appName)
            ->raw(', Zicht\Version\Version::fromString(')
            ->asPhp($this->appVersion)
            ->raw(') ?: new Zicht\Version\Version());')
            ->eol()
        ;
        $buffer->writeln('$app->setContainer($container);');
    }
1221099
function it_compiles_nodes_using_a_generic_solution($node)
    {
        $node->compile($this)->will(function ($args) {
            $args[0]->write('echo $message');
        });

        $this->repr($node)->getSource()->shouldMatch('/echo \$message/');
    }
879392
public function compile()
  {
    if (!$this->enabled || $this->env !== "dev") {
      return;
    }
    foreach ($this->watchers as $name => $watcher) {
      if (isset($this->configs[$name])) {
        foreach ($this->configs[$name] as $configPath) {
          $files = $watcher->getChildren($configPath);
          if ($this->cache->isFresh($configPath, $files)) {
            $watcher->compile($configPath);
            $this->cache->write($configPath, $files);
          }
        }
      }
    }
  }
1121753
public function compile()
    {
        $this->parameterBag->resolve();

        $this->parameterBag = new FrozenParameterBag($this->parameterBag->all());
    }
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");
        }
    }
567503
public function compile(Compiler $compiler): void
    {
        $runtimeErrorClass = RuntimeError::class;
        $suppressedExceptionClass = SuppressedException::class;

        $compiler
            ->write("try {\n")
            ->indent()
            ->write("ob_start();\n\n")
            ->subcompile($this->getNode('body'))
            ->raw("\n")
            ->write("echo ob_get_clean();\n")
            ->outdent()
            ->write("} catch ({$runtimeErrorClass} \$exception) {\n")
            ->indent()
            ->write("ob_end_clean();\n\n")
            ->write("if (\$exception->getPrevious() === null) {\n")
            ->indent()
            ->write("throw \$exception;\n")
            ->outdent()
            ->write("}\n\n")
            ->write("\$suppressedException = new {$suppressedExceptionClass}(\$exception->getPrevious());\n")
            ->outdent()
            ->write("}\n\n");
    }
917861
private function compile() : void
    {
        $this->isCompiled = true;

        if ($this->type === self::TYPE_SIMPLE) {
            $this->compileSimpleTable();
        } else {
            $this->compilePrettyTable();
        }
    }
293513
public function compile($code, $path = null)
    {
        $this->indentLevel    = -1;
        $this->commentsSeen   = [];
        $this->extends        = [];
        $this->extendsMap     = [];
        $this->sourceIndex    = null;
        $this->sourceLine     = null;
        $this->sourceColumn   = null;
        $this->env            = null;
        $this->scope          = null;
        $this->storeEnv       = null;
        $this->charsetSeen    = null;
        $this->shouldEvaluate = null;
        $this->stderr         = fopen('php://stderr', 'w');

        $this->parser = $this->parserFactory($path);
        $tree = $this->parser->parse($code);
        $this->parser = null;

        $this->formatter = new $this->formatter();
        $this->rootBlock = null;
        $this->rootEnv   = $this->pushEnv($tree);

        $this->injectVariables($this->registeredVars);
        $this->compileRoot($tree);
        $this->popEnv();

        $sourceMapGenerator = null;

        if ($this->sourceMap) {
            if (is_object($this->sourceMap) && $this->sourceMap instanceof SourceMapGenerator) {
                $sourceMapGenerator = $this->sourceMap;
                $this->sourceMap = self::SOURCE_MAP_FILE;
            } elseif ($this->sourceMap !== self::SOURCE_MAP_NONE) {
                $sourceMapGenerator = new SourceMapGenerator($this->sourceMapOptions);
            }
        }

        $out = $this->formatter->format($this->scope, $sourceMapGenerator);

        if (! empty($out) && $this->sourceMap && $this->sourceMap !== self::SOURCE_MAP_NONE) {
            $sourceMap    = $sourceMapGenerator->generateJson();
            $sourceMapUrl = null;

            switch ($this->sourceMap) {
                case self::SOURCE_MAP_INLINE:
                    $sourceMapUrl = sprintf('data:application/json,%s', Util::encodeURIComponent($sourceMap));
                    break;

                case self::SOURCE_MAP_FILE:
                    $sourceMapUrl = $sourceMapGenerator->saveMap($sourceMap);
                    break;
            }

            $out .= sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl);
        }

        return $out;
    }
1036753
protected function compileInitialization(Buffer $buffer)
    {
        $buffer->write('$app = new Zicht\Tool\Application(')
            ->asPhp($this->appName)
            ->raw(', Zicht\Version\Version::fromString(')
            ->asPhp($this->appVersion)
            ->raw(') ?: new Zicht\Version\Version(), Zicht\Tool\Configuration\ConfigurationLoader::fromEnv(')->asPhp($this->configFilename)->raw(')')
            ->raw(');')
            ->eol();
    }
484589
public function output($buffer) {
        if (!$buffer && !$this->__result) {
            return '';
        }

        $out = '';
        // Always include the output generated by the expression first
        if ($buffer) {
            $out .= Garp_Cli::lineOut($buffer, null, true, false);
        }

        // And follow-up with the populated result, if any
        if ($this->__result) {
            // Try to format as user-friendly as possible
            $isObjWithToArray = is_object($this->__result) &&
                method_exists($this->__result, 'toArray');
            $this->__result = $isObjWithToArray ? $this->__result->toArray() : $this->__result;
            $this->__result = var_export($this->__result, true);
            $out .= Garp_Cli::lineOut($this->__result, Garp_Cli::BLUE, true, false);
        }

        return $out;
    }
314477
public function appendBits(array $bits, Buffer $buffer)
    {
        $value = 0;
        foreach ($bits as $n => $bit) {
            $bit = $bit ? 1 : 0;
            $value |= $bit << $n;
        }
        $buffer->appendUint8($value);
    }
797526
private function compressBuffer($buffer)
    {
        if (preg_match("/\<html/i",$buffer) == 1 && preg_match("/\<\/html\>/i",$buffer) == 1) {
            $buffer = preg_replace(
                ['/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'],
                ['>', '<', '\\1'],
                $buffer
            );
        }

        return $buffer;
    }
810820
public function fireEvent(string $event): void
    {
        $this->log->debug('Event {event} has been fired.', ['event' => $event]);
        foreach ($this->event_handlers as $handler) {
            /** @var EventHandler $handler */
            if ($event === $handler->getEvent()) {
                $handler->execute();
            }
        }
    }
745335
public function loadBuffer(): void
    {
        if (self::$loaded) {
            return;
        }
        self::$loaded = true;

        foreach (self::$deferred as $class => $ids) {
            /** @var EntityRepository $repo */
            $repo = $this->registry->getRepository($class);
            $qb = $repo->createQueryBuilder('o', 'o.id');
            $entities = $qb->where($qb->expr()->in('o.id', array_values($ids)))
                           ->getQuery()
                           ->getResult();
            foreach ($entities as $entity) {
                if ($entity instanceof NodeInterface) {
                    self::$deferred[$class][$entity->getId()] = $entity;
                }
            }
        }
    }
264228
public function appendProtocolHeader(Buffer $buffer)
    {
        $buffer->append('AMQP');
        $buffer->appendUint8(0);
        $buffer->appendUint8(0);
        $buffer->appendUint8(9);
        $buffer->appendUint8(1);
    }
748458
private function extractLineNumbers($buffer)
    {
        $this->sourcePositions = [0 => 0];
        $prev = 0;

        while (($pos = strpos($buffer, "\n", $prev)) !== false) {
            $this->sourcePositions[] = $pos;
            $prev = $pos + 1;
        }

        $this->sourcePositions[] = strlen($buffer);

        if (substr($buffer, -1) !== "\n") {
            $this->sourcePositions[] = strlen($buffer) + 1;
        }
    }