Library/CompilerFile.php
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;
    }
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;
    }
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 ; }
Compiles the file generating a JSON intermediate representation.

@param Compiler $compiler

@throws ParseException
@throws IllegalStateException if the intermediate representation is not of type 'array'

@return array
Compiles the file generating a JSON intermediate representation .