Pre-compiles a Zephir file.

Generates the IR and perform basic validations.

@param Compiler $compiler

@throws CompilerException
@throws IllegalStateException
@throws ParseException
497260
public function preCompile(Compiler $compiler)
    {
        $ir = $this->genIR($compiler);

        if (isset($ir['type']) && 'error' == $ir['type']) {
            throw new ParseException($ir['message'], $ir);
        }

        /**
         * Compilation context stores common objects required by compilation entities.
         */
        $compilationContext = new CompilationContext();

        /*
         * Set global compiler in the compilation context
         */
        $compilationContext->compiler = $compiler;

        /*
         * Set global config in the compilation context
         */
        $compilationContext->config = $this->config;

        /*
         * Set global logger in the compilation context
         */
        $compilationContext->logger = $this->logger;

        /*
         * Alias manager
         */
        $compilationContext->aliasManager = $this->aliasManager;

        $compilationContext->backend = $compiler->backend;

        /**
         * Traverse the top level statements looking for the namespace.
         */
        $namespace = null;

        foreach ($ir as $topStatement) {
            switch ($topStatement['type']) {
                case 'namespace':
                    if (null !== $namespace) {
                        throw new CompilerException('The namespace must be defined just one time', $topStatement);
                    }
                    $namespace = $topStatement['name'];
                    $this->namespace = $namespace;
                    if (!preg_match('/^[A-Z]/', $namespace)) {
                        throw new CompilerException(
                            "Namespace '{$namespace}' must be in camelized-form",
                            $topStatement
                        );
                    }
                    break;

                case 'cblock':
                    $this->headerCBlocks[] = $topStatement['value'];
                    break;

                case 'function':
                    $statements = null;
                    if (isset($topStatement['statements'])) {
                        $statements = new StatementsBlock($topStatement['statements']);
                    }

                    $parameters = null;
                    if (isset($topStatement['parameters'])) {
                        $parameters = new ClassMethodParameters($topStatement['parameters']);
                    }

                    $returnType = null;
                    if (isset($topStatement['return-type'])) {
                        $returnType = $topStatement['return-type'];
                    }

                    // Just do the precompilation of the function
                    $functionDefinition = new FunctionDefinition(
                        $namespace,
                        $topStatement['name'],
                        $parameters,
                        $statements,
                        $returnType,
                        $topStatement
                    );
                    $functionDefinition->preCompile($compilationContext);
                    $this->addFunction($compiler, $functionDefinition, $topStatement);
                    break;
            }
        }

        if (!$namespace) {
            throw new CompilerException('A namespace is required', isset($topStatement) ? $topStatement : null);
        }

        // Set namespace and flag as global, if before namespace declaration
        foreach ($this->functionDefinitions as $funcDef) {
            if (null == $funcDef->getNamespace()) {
                $funcDef->setGlobal(true);
                $funcDef->setNamespace($this->config->get('namespace'));
            }
        }

        $name = null;
        $class = false;
        $interface = false;
        $lastComment = null;

        foreach ($ir as $topStatement) {
            switch ($topStatement['type']) {
                case 'class':
                    if ($class || $interface) {
                        throw new CompilerException(
                            'More than one class/interface defined in the same file',
                            $topStatement
                        );
                    }
                    $class = true;
                    $name = $topStatement['name'];
                    $this->preCompileClass($compilationContext, $namespace, $topStatement, $lastComment);
                    $this->originalNode = $topStatement;
                    $lastComment = null;
                    break;

                case 'interface':
                    if ($class || $interface) {
                        throw new CompilerException(
                            'More than one class/interface defined in the same file',
                            $topStatement
                        );
                    }
                    $interface = true;
                    $name = $topStatement['name'];
                    $this->preCompileInterface($namespace, $topStatement, $lastComment);
                    $this->originalNode = $topStatement;
                    $lastComment = null;
                    break;

                case 'use':
                    if ($interface || $class) {
                        throw new CompilerException(
                            'Aliasing must be done before declaring any class or interface',
                            $topStatement
                        );
                    }
                    $this->aliasManager->add($topStatement);
                    break;

                case 'comment':
                    $lastComment = $topStatement;
                    break;
            }
        }

        if (!$class && !$interface) {
            throw new CompilerException(
                'Every file must contain at least a class or an interface',
                isset($topStatement) ? $topStatement : null
            );
        }

        if (!$this->external) {
            $expectedPath = strtolower(
                str_replace('\\', \DIRECTORY_SEPARATOR, $namespace).\DIRECTORY_SEPARATOR.$name.'.zep'
            );

            if (strtolower($this->filePath) != $expectedPath) {
                $className = $namespace.'\\'.$name;

                throw new CompilerException(
                    sprintf(
                        "Unexpected class name '%s' in file: '%s', expected: '%s'",
                        $className,
                        $this->filePath,
                        $expectedPath
                    )
                );
            }
        }

        if ($compilationContext->classDefinition) {
            if ($extendsClass = $compilationContext->classDefinition->getExtendsClass()) {
                $compiler->isClass($extendsClass);
            }
            if ($interfaces = $compilationContext->classDefinition->getImplementedInterfaces()) {
                foreach ($interfaces as $interface) {
                    $compiler->isInterface($interface);
                }
            }
        }

        $this->ir = $ir;
    }
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: ?>";
    }
820924
public function compile(Twig_Compiler $compiler)
    {
        $compiler->addDebugInfo($this);

        list($msg, $vars) = $this->compileString($this->getNode('body'));

        if (null !== $this->getNode('plural')) {
            list($msg1, $vars1) = $this->compileString($this->getNode('plural'));

            $vars = array_merge($vars, $vars1);
        }

        // Modified row to work with WordPress.
        $function = null === $this->getNode('plural') ? '__' : '_n';

        if (null !== $notes = $this->getNode('notes')) {
            $message = trim($notes->getAttribute('data'));

            // line breaks are not allowed cause we want a single line comment
            $message = str_replace(array("\n", "\r"), ' ', $message);
            $compiler->write("// notes: {$message}\n");
        }

        if ($vars) {
            $compiler
                ->write('echo strtr('.$function.'(')
                ->subcompile($msg)
            ;

            if (null !== $this->getNode('plural')) {
                $compiler
                    ->raw(', ')
                    ->subcompile($msg1)
                    ->raw(', abs(')
                    ->subcompile($this->getNode('count'))
                    ->raw(')')
                ;
            }

            $compiler->raw('), array(');

            foreach ($vars as $var) {
                if ('count' === $var->getAttribute('name')) {
                    $compiler
                        ->string('%count%')
                        ->raw(' => abs(')
                        ->subcompile($this->getNode('count'))
                        ->raw('), ')
                    ;
                } else {
                    $compiler
                        ->string('%'.$var->getAttribute('name').'%')
                        ->raw(' => ')
                        ->subcompile($var)
                        ->raw(', ')
                    ;
                }
            }

            $compiler->raw("));\n");
        } else {
            if (null !== $this->getNode('plural')) {
                $compiler
                    ->write('echo sprintf( '.$function.'(')
                    ->subcompile($msg)
                ;

                $compiler
                    ->raw(', ')
                    ->subcompile($msg1)
                    ->raw(', abs(')
                    ->subcompile($this->getNode('count'))
                    ->raw(')')
                ;
            } else {
                $compiler
                    ->write('echo '.$function.'(')
                    ->subcompile($msg)
                ;
            }

            $theme  = wp_get_theme();
            $domain = $theme->get('TextDomain');
            $compiler->raw(', "' . $domain . '"');

            if (null !== $this->getNode('plural')) {
                $compiler->raw(') , ')
                    ->subcompile($this->getNode('count'));
            }

            $compiler->raw(");\n");
        }
    }
98021
public function compile(Twig_Compiler $compiler)
    {
        $compiler
            ->addDebugInfo($this)
            ->write("echo \$this->env->getExtension('Cms\Twig\Extension')->startBlock(")
            ->raw("'".$this->getAttribute('name')."'")
            ->write(");\n")
        ;

        $isOverwrite = strtolower($this->getAttribute('endType')) == 'overwrite';

        $compiler->subcompile($this->getNode('body'));

        $compiler
            ->addDebugInfo($this)
            ->write("echo \$this->env->getExtension('Cms\Twig\Extension')->endBlock(")
            ->raw($isOverwrite ? 'false' : 'true')
            ->write(");\n")
        ;
    }
235168
public function compile(\Twig_Compiler $compiler)
    {
        $name = $this->getAttribute('name');
        $parentName = $this->getAttribute('parent_name');

        if ($this->getAttribute('is_closure')) {
            $this->compileClosureBlock($compiler, $parentName, $name);
        } elseif (!empty($this->getAttribute('loop'))) {
            $this->compileLoopBlock($compiler);
        } elseif ($this->getAttribute('is_root')) {
            $this->compileMasterBlock($compiler);
        } else {
            $this->compileChildBlock($compiler);
        }
    }
1015190
public function compile(Compiler $compiler)
    {
        $compiler->raw('[');
        $this->compileArguments($compiler);
        $compiler->raw(']');
    }
545660
public function processFilesets(SassTaskCompiler $compiler): void
    {
        foreach ($this->filesets as $fs) {
            $ds = $fs->getDirectoryScanner($this->project);
            $files = $ds->getIncludedFiles();
            $dir = $fs->getDir($this->project)->getPath();

            // If output path isn't defined then set it to the path of our fileset.
            $specifiedOutputPath = (strlen($this->outputpath) > 0);
            if ($specifiedOutputPath === false) {
                $this->outputpath = $dir;
            }

            foreach ($files as $file) {
                $fullFilePath = $dir . DIRECTORY_SEPARATOR . $file;
                $this->pathInfo = pathinfo($file);

                $run = true;
                switch (strtolower($this->pathInfo['extension'])) {
                    case 'scss':
                    case 'sass':
                        break;
                    default:
                        $this->log('Ignoring ' . $file, Project::MSG_DEBUG);
                        $run = false;
                }

                if ($run
                    && ($this->extfilter === ''
                        || $this->extfilter === $this->pathInfo['extension'])
                ) {
                    $outputFile = $this->buildOutputFilePath();
                    $compiler->compile($fullFilePath, $outputFile, $this->failonerror);
                }
            }
        }
    }
1186487
public function compile(\Twig_Compiler $compiler)
    {
        $compiler->addDebugInfo($this);

        $compiler
            ->write('$highlighter = \Ramsey\Twig\CodeBlock\Highlighter\HighlighterFactory::getHighlighter(')
            ->string($this->getHighlighterName())
            ->raw(', ')
            ->repr($this->getHighlighterArgs())
            ->raw(");\n");

        $compiler
            ->write('$highlightedCode = $highlighter->highlight(')
            ->string($this->getNode('body')->getAttribute('data'))
            ->raw(', ')
            ->repr($this->attributes)
            ->raw(");\n");

        if ($this->hasAttribute('format') && strtolower($this->getAttribute('format')) === 'html') {
            $classnames = 'code-highlight-figure';
            if ($this->hasAttribute('class')) {
                $classnames .= ' ' . $this->getAttribute('class');
            }

            $compiler
                ->write('$figcaption = ')
                ->string($this->getFigcaption())
                ->raw(";\n")
                ->write('echo sprintf(')
                ->raw('"<figure class=\"' . $classnames . '\">%s%s</figure>\n",')
                ->raw(' $figcaption, $highlightedCode')
                ->raw(");\n");
        } else {
            $compiler->write('echo $highlightedCode;' . "\n");
        }
    }
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");
    }
1031393
public function compile(\Twig_Compiler $compiler)
	{
		$compiler
			->addDebugInfo($this)
			->write('return ');
		// check for an expression to return.
		if ($this->hasNode('expr')) {
			$compiler->subcompile($this->getNode('expr'));
		}
		else // Return '' if there isn't one
		{
			$compiler->raw('""');
		}

		$compiler->raw(";\n");
	}
83005
public function compile(Twig_Compiler $compiler)
    {
        $attrib = $this->getAttribute('name');
        $includeExtras = strtolower(trim($attrib)) == 'extras';

        $compiler
            ->addDebugInfo($this)
            ->write("\$_minify = ".CombineAssets::class."::instance()->useMinify;" . PHP_EOL);

        if ($includeExtras) {
            $compiler
                ->write("if (\$_minify) {" . PHP_EOL)
                ->indent()
                    ->write("echo '<script src=\"'. Request::getBasePath()
                    .'/modules/system/assets/js/framework.combined-min.js\"></script>'.PHP_EOL;" . PHP_EOL)
                ->outdent()
                ->write("}" . PHP_EOL)
                ->write("else {" . PHP_EOL)
                ->indent()
                    ->write("echo '<script src=\"'. Request::getBasePath()
                    .'/modules/system/assets/js/framework.js\"></script>'.PHP_EOL;" . PHP_EOL)
                    ->write("echo '<script src=\"'. Request::getBasePath()
                    .'/modules/system/assets/js/framework.extras.js\"></script>'.PHP_EOL;" . PHP_EOL)
                ->outdent()
                ->write("}" . PHP_EOL)
                ->write("echo '<link rel=\"stylesheet\" property=\"stylesheet\" href=\"'. Request::getBasePath()
                    .'/modules/system/assets/css/framework.extras'.(\$_minify ? '-min' : '').'.css\">'.PHP_EOL;" . PHP_EOL)
            ;
        }
        else {
            $compiler->write("echo '<script src=\"'. Request::getBasePath()
                .'/modules/system/assets/js/framework'.(\$_minify ? '-min' : '').'.js\"></script>'.PHP_EOL;" . PHP_EOL)
            ;
        }

        $compiler->write('unset($_minify);' . PHP_EOL);
    }
1271419
public function compile(\Twig_Compiler $compiler)
    {
        $compiler->addDebugInfo($this);
		
        $compiler->write("try {\n")->indent();		
		
        $compiler
             ->write("\Cetera\Application::getInstance()->getWidget(")
             ->subcompile($this->getNode('expr'));
			 
		if ($this->getNode('variables'))
		{
			 $compiler
				 ->raw(', ')
				 ->subcompile($this->getNode('variables'));
		}
				 
        $compiler->raw(")->display();\n");	

        $compiler
                ->outdent()
                ->write("} catch (\\Exception \$e) {\n")
                ->indent()
                //->write("echo '<div class=\"callout alert\">'.\$e->getMessage().'</div>';\n")
				->write("echo '<!-- '.\$e->getMessage().' -->';\n")
                ->outdent()
                ->write("}\n\n")
        ;		 

    }
584182
public function compile($args, $compiler)
    {
        // check and get attributes
        $_attr = $this->getAttributes($compiler, $args);
        // never compile as nocache code
        $compiler->suppressNocacheProcessing = true;
        $compiler->tag_nocache = true;
        $_smarty_tpl = $compiler->template;
        $_name = null;
        $_script = null;

        $_output = '<?php ';
        // save posible attributes
        eval('$_name = ' . $_attr['name'] . ';');
        if (isset($_attr['assign'])) {
            // output will be stored in a smarty variable instead of being displayed
            $_assign = $_attr['assign'];
            // create variable to make shure that the compiler knows about its nocache status
            $compiler->template->tpl_vars[trim($_attr['assign'], "'")] = new Smarty_Variable(null, true);
        }
        if (isset($_attr['script'])) {
            // script which must be included
            $_function = "smarty_insert_{$_name}";
            $_smarty_tpl = $compiler->template;
            $_filepath = false;
            eval('$_script = ' . $_attr['script'] . ';');
            if (!isset($compiler->smarty->security_policy) && file_exists($_script)) {
                $_filepath = $_script;
            } else {
                if (isset($compiler->smarty->security_policy)) {
                    $_dir = $compiler->smarty->security_policy->trusted_dir;
                } else {
                    $_dir = $compiler->smarty->trusted_dir;
                }
                if (!empty($_dir)) {
                    foreach ((array) $_dir as $_script_dir) {
                        $_script_dir = rtrim($_script_dir, '/\\') . DS;
                        if (file_exists($_script_dir . $_script)) {
                            $_filepath = $_script_dir . $_script;
                            break;
                        }
                    }
                }
            }
            if ($_filepath == false) {
                $compiler->trigger_template_error("{insert} missing script file '{$_script}'", $compiler->lex->taglineno);
            }
            // code for script file loading
            $_output .= "require_once '{$_filepath}' ;";
            require_once $_filepath;
            if (!is_callable($_function)) {
                $compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'", $compiler->lex->taglineno);
            }
        } else {
            $_filepath = 'null';
            $_function = "insert_{$_name}";
            // function in PHP script ?
            if (!is_callable($_function)) {
                // try plugin
                if (!$_function = $compiler->getPlugin($_name, 'insert')) {
                    $compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", $compiler->lex->taglineno);
                }
            }
        }
        // delete {insert} standard attributes
        unset($_attr['name'], $_attr['assign'], $_attr['script'], $_attr['nocache']);
        // convert attributes into parameter array string
        $_paramsArray = array();
        foreach ($_attr as $_key => $_value) {
            $_paramsArray[] = "'$_key' => $_value";
        }
        $_params = 'array(' . implode(", ", $_paramsArray) . ')';
        // call insert
        if (isset($_assign)) {
            if ($_smarty_tpl->caching) {
                $_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}',{$_assign});?>";
            } else {
                $_output .= "\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl), true);?>";
            }
        } else {
            $compiler->has_output = true;
            if ($_smarty_tpl->caching) {
                $_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}');?>";
            } else {
                $_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>";
            }
        }

        return $_output;
    }
618479
public function compile(ExpressCompiler $compiler, $flags = 0)
	{
		try
		{
			$helper = $this->getHelper($compiler);
			$field = $compiler->nextField('h');
			
			$compiler->write("\t\t" . 'if(' . $field . ' === NULL) {' . "\n");
			
			$compiler->write("\t\ttry {\n");
			
			$compiler->write("\t\t" . $field . ' = $this->renderer->getHelper(');
			$compiler->write(var_export($this->namespace, true) . ', ' . var_export($this->name, true));
			$compiler->write(");\n");
			$compiler->write("\t\t" . $field . "->bindContext(\$this->context);\n");
			
			$bound = [];
			
			// Setup helper arguments:
			foreach($this->attributes as $attr)
			{
				$name = preg_replace_callback("'-([a-z0-9])'", function(array $m) {
					return strtoupper($m[1]);
				}, $attr->getName());
				
				if(false !== strpos($name, ':'))
				{
					continue;
				}
				
				$dynamic = $attr->isExpressionCallback() || $attr->isDynamic();
				$pass = $helper->isPassthroughAttribute($name);
				
				$bound[$name] = true;
				
				if($pass)
				{
					// Dealing with passthrough attributes.
					
					if($dynamic)
					{
						// Dynamic value passthrough attribute, use ArrayAccess to set compiled closure.
						
						$compiler->write("\t\t" . $field . "[" . var_export($attr->getName(), true));
						$compiler->write("] = function() {\n\t\t\ttry {\n\t\t\treturn ");
						
						$exp = '';
						
						foreach($attr as $i => $sub)
						{
							if($i != 0)
							{
								$compiler->write(' . ');
							}
								
							$compiler->write($sub->compile($compiler, self::FLAG_RAW));
							
							if($sub instanceof ExpressionNode)
							{
								$exp .= $sub->getExpression();
							}
							elseif($sub instanceof TextNode)
							{
								$exp .= $sub->getText();
							}
						}
						
						$compiler->write(";\n\t\t\t} catch(\ExpressViewException \$ex) {\n");
						$compiler->write("\t\t\t\tthrow \$ex;\n");
						$compiler->write("\t\t\t} catch(\Exception \$ex) {\n");
						$compiler->write("\t\t\t\tthrow new ExpressViewException(");
						$compiler->write(var_export(sprintf('Unable to evaluate attribute "%s" in view helper "%s" using expression "%s"', $name, $this->namespace . ':' . $this->name, $exp), true));
						$compiler->write(", \$this->getResource(), {$this->line}, \$ex);\n");
						$compiler->write("\t\t\t}\n\t\t};\n");
					}
					else
					{
						// Static passthrough attribute.
						
						$sub = $compiler->createCompiler();
						$attr->compile($sub);
						
						$compiler->write("\t\t" . $field . "[" . var_export($attr->getName(), true));
						$compiler->write("] = " . var_export($sub->getOutputBuffer(), true) . ";\n");
					}
				}
				else
				{
					if($dynamic)
					{
						// Dynamic and expression attributes are assembled into a string and returned:
					
						$compiler->write("\t\t" . $field . '->setAttr(' . var_export($name, true));
						$compiler->write(", function(\$inspect = false) {\n\t\t\ttry {\n\t\t\treturn ");
					
						$childNodes = iterator_to_array($attr->getIterator());
						$inspectable = false;
						$exp = '';
						
						if(count($childNodes) == 1)
						{
							if($childNodes[0] instanceof ExpressionNode)
							{
								$chain = $childNodes[0]->getExpression()->getNode();
								
								if($chain instanceof AccessorChain)
								{
									$inspectable = true;
								}
							}
						}
						
						if($inspectable)
						{
							$compiler->write('$inspect ? ');
							$compiler->write($chain->compile($compiler->getExpressionContextFactory(), '$this->exp', 'inspectValue'));
							$compiler->write(' : ');
							$compiler->write($chain->compile($compiler->getExpressionContextFactory(), '$this->exp'));
							
							$exp .= $childNodes[0]->getExpression();
						}
						else
						{
							foreach($childNodes as $i => $sub)
							{
								if($i != 0)
								{
									$compiler->write(' . ');
								}
									
								$compiler->write($sub->compile($compiler, self::FLAG_RAW));
								
								if($sub instanceof ExpressionNode)
								{
									$exp .= $sub->getExpression();
								}
								elseif($sub instanceof TextNode)
								{
									$exp .= $sub->getText();
								}
							}
						}
						
						$compiler->write(";\n\t\t\t} catch(\ExpressViewException \$ex) {\n");
						$compiler->write("\t\t\t\tthrow \$ex;\n");
						$compiler->write("\t\t\t} catch(\Exception \$ex) {\n");
						$compiler->write("\t\t\t\tthrow new ExpressViewException(");
						$compiler->write(var_export(sprintf('Unable to evaluate attribute "%s" in view helper "%s" using expression "%s"', $name, $this->namespace . ':' . $this->name, $exp), true));
						$compiler->write(", \$this->getResource(), {$this->line}, \$ex);\n");
						$compiler->write("\t\t\t}\n\t\t});\n");
					}
					else
					{
						// Static attributes are set as property values:
					
						$sub = $compiler->createCompiler();
						$attr->compile($sub);
					
						$compiler->write("\t\t" . $field . '->' . $name . ' = ');
						$compiler->write(var_export($sub->getOutputBuffer(), true) . ";\n");
					}
				}
			}
			
			$compiler->write("\t\t" . $field . "->bindAttr([");
			
			foreach(array_keys($bound) as $i => $key)
			{
				if($i != 0)
				{
					$compiler->write(', ');
				}
				
				$compiler->write(var_export($key, true) . ' => true');
			}
	
			$compiler->write("]);\n");
			
			if(!empty($this->childNodes))
			{
				if($helper instanceof CompositeViewHelperInterface)
				{
					$helpers = [];
	
					foreach($this->childNodes as $node)
					{
						if(!$node instanceof HelperNode)
						{
							continue;
						}
						
						$helpers[] = $node->compile($compiler, self::FLAG_NO_OUTPUT);
					}
					
					$compiler->write("\t\t" . $field . '->setNestedNodes([' . "\n");
					$compiler->write("\t\t" . implode(', ', $helpers) . "\n");
					$compiler->write("\t\t]);\n");
				}
				else
				{
					$compiler->write("\t\t" . $field . '->setNestedNodes([function(OutputBuffer $out) {' . "\n");
					
					foreach($this->childNodes as $node)
					{
						$node->compile($compiler);
					}
					
					$compiler->write("\n\t\t}]);\n");
				}
			}
			
			$compiler->write("\t\t} catch(ExpressViewException \$ex) {\n");
			$compiler->write("\t\t\tthrow \$ex;\n");
			$compiler->write("\t\t} catch(\\Exception \$ex) {\n");
			$compiler->write("\t\t\tthrow new ExpressViewException(");
			$compiler->write(var_export('Unable to instantiate view helper "' . $this->namespace . ':' . $this->name . '"', true));
			$compiler->write(", \$this->getResource(), {$this->line}, \$ex);\n");
			$compiler->write("\t\t}\n");
			
			$compiler->write("\t\t}\n");
			
			if(!($flags & self::FLAG_NO_OUTPUT))
			{
				$compiler->write("\t\ttry {\n");
				$compiler->write("\t\t" . $field . '->__invoke($out);' . "\n");
				$compiler->write("\t\t} catch(ExpressViewException \$ex) {\n");
				$compiler->write("\t\t\tthrow \$ex;\n");
				$compiler->write("\t\t} catch(\\Exception \$ex) {\n");
				$compiler->write("\t\t\tthrow new ExpressViewException(");
				$compiler->write(var_export('Unable to invoke view helper "' . $this->namespace . ':' . $this->name . '"', true));
				$compiler->write(", \$this->getResource(), {$this->line}, \$ex);\n");
				$compiler->write("\t\t}\n");
			}
			
			return $field;
		}
		catch(ExpressViewException $e)
		{
			throw $e;
		}
		catch(\Exception $e)
		{
			throw new ExpressViewException(sprintf('Unable to compile view helper "%s" in namespace "%s"', $this->name, $this->namespace), $compiler->getResource(), $this->line, $e);
		}
	}
1062356
public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
    {
        $rparams = $compiler->getRealParams($params);
        $cparams = $compiler->getCompiledParams($params);

        $compiler->setScope($rparams['var']);

        $pre = Compiler::PHP_OPEN . 'if (' . $cparams['var'] . ')' . "\n{\n" . '$_with' . (self::$cnt) . ' = $this->setScope("' . $rparams['var'] . '");' . "\n/* -- start with output */\n" . Compiler::PHP_CLOSE;

        $post = Compiler::PHP_OPEN . "\n/* -- end with output */\n" . '$this->setScope($_with' . (self::$cnt ++) . ', true);' . "\n}\n" . Compiler::PHP_CLOSE;

        if (isset($params['hasElse'])) {
            $post .= $params['hasElse'];
        }

        return $pre . $content . $post;
    }
12543
private function getNamedCompiler($compiler)
    {
        if (!isset($this->namedCompilers[$compiler])) {
            $this->namedCompilers[$compiler] = new $compiler($this);
        }

        return $this->namedCompilers[$compiler];
    }
499621
public function genIR(Compiler $compiler)
    {
        $normalizedPath = $this->filesystem->normalizePath($this->filePath);

        // TODO: JS => JSON
        $compilePath = "{$normalizedPath}.js";
        $zepRealPath = realpath($this->filePath);

        if ($this->filesystem->exists($compilePath)) {
            $modificationTime = $this->filesystem->modificationTime($compilePath);
            if ($modificationTime < filemtime($zepRealPath)) {
                $this->filesystem->delete($compilePath);
                if (false != $this->filesystem->exists($compilePath.'.php')) {
                    $this->filesystem->delete($compilePath.'.php');
                }
            }
        }

        $ir = null;
        if (false == $this->filesystem->exists($compilePath)) {
            $parser = $compiler->getParserManager()->getParser();
            $ir = $parser->parse($zepRealPath);
            $this->filesystem->write($compilePath, json_encode($ir, JSON_PRETTY_PRINT));
        }

        if (false == $this->filesystem->exists($compilePath.'.php')) {
            if (empty($ir)) {
                $ir = json_decode($this->filesystem->read($compilePath), true);
            }

            $data = '<?php return '.var_export($ir, true).';';
            $this->filesystem->write($compilePath.'.php', $data);
        }

        $contents = $this->filesystem->requireFile($compilePath.'.php');

        if (false == \is_array($contents)) {
            throw new IllegalStateException(
                sprintf(
                    'Generating the intermediate representation for the file "%s" was failed.',
                    realpath($this->filePath)
                )
            );
        }

        return $contents;
    }