Haanga::getCompiler PHP Method

getCompiler() protected static method

The instance is already set up properly and resetted.
protected static getCompiler ( boolean $checkdir = TRUE ) : Haanga_Compiler_Runtime
$checkdir boolean TRUE @return Haanga_Compiler_Runtime
return Haanga_Compiler_Runtime
    protected static function getCompiler($checkdir = TRUE)
    {
        static $compiler;
        static $has_checkdir = FALSE;
        if (!$compiler) {
            /* Load needed files (to avoid autoload as much as possible) */
            $dir = dirname(__FILE__);
            require_once "{$dir}/Haanga/AST.php";
            require_once "{$dir}/Haanga/Compiler.php";
            require_once "{$dir}/Haanga/Compiler/Runtime.php";
            require_once "{$dir}/Haanga/Compiler/Parser.php";
            require_once "{$dir}/Haanga/Compiler/Tokenizer.php";
            require_once "{$dir}/Haanga/Generator/PHP.php";
            require_once "{$dir}/Haanga/Extension.php";
            require_once "{$dir}/Haanga/Extension/Filter.php";
            require_once "{$dir}/Haanga/Extension/Tag.php";
            /* load compiler (done just once) */
            if (self::$use_autoload) {
                require_once "{$dir}/Haanga/Loader.php";
            }
            $compiler = new Haanga_Compiler_Runtime();
            if (self::$bootstrap) {
                /* call bootstrap hook, just the first time */
                call_user_func(self::$bootstrap);
            }
            if (count(self::$compiler) != 0) {
                foreach (self::$compiler as $opt => $value) {
                    Haanga_Compiler::setOption($opt, $value);
                }
            }
        }
        if ($checkdir && !$has_checkdir) {
            self::checkCacheDir();
            $has_checkdir = TRUE;
        }
        $compiler->reset();
        return $compiler;
    }