<commit_before><?php

namespace Macchiato;

use \JSContext;
use \RuntimeException;

class CoffeeScript {
    private $_compilerCtx;

    public function __construct($coffeePath = 'coffee-script.js') {
        $this->_compilerCtx = $this->createCompilerContext($coffeePath);
    }

    protected function loadCoffeeScript($coffeePath) {
        if (($compilerSource = file_get_contents($coffeePath)) === false) {
            throw new RuntimeException('Unable to load the CoffeeScript compiler library');
        }
        return $compilerSource;
    }

    public function createContext() {
        return new SpiderMonkeyContext();
    }

    protected function createCompilerContext($coffeePath) {
        $compilerSource = $this->loadCoffeeScript($coffeePath);
        $compilerCtx = $this->createContext();
        $compilerCtx->evaluateString("$compilerSource\nnull");
        return $compilerCtx;
    }

    public function getCompilerContext() {
        return $this->_compilerCtx;
    }

    public function compile($code) {
        $compilerCtx = $this->getCompilerContext();
        $compilerCtx->registerVariable('___USRSRC___', $code);
        $script = 'CoffeeScript.compile(___USRSRC___, { bare: true });';
        $compiled = $compilerCtx->evaluateString($script);
        if ($compiled === false) {
            throw new RuntimeException('Unable to compile the provided CoffeeScript code');
        }
        return $compiled;
    }

    public function execute($code, JavaScriptContextInterface $context = null) {
        $context = $context ?: $this->createContext();
        return $context->evaluateString($this->compile($code));
    }

    public function compileFile($path) {
        if (($code = file_get_contents($path)) === false) {
            throw new RuntimeException("Unable to load the CoffeeScript file at $path");
        }
        return $this->compile($code);
    }

    public function executeFile($path, JavaScriptContextInterface $context = null) {
        $context = $context ?: $this->createContext();
        return $context->evaluateString($this->compileFile($path));
    }
}
<commit_msg>Remove an useless use directive.<commit_after><?php

namespace Macchiato;

use \RuntimeException;

class CoffeeScript {
    private $_compilerCtx;

    public function __construct($coffeePath = 'coffee-script.js') {
        $this->_compilerCtx = $this->createCompilerContext($coffeePath);
    }

    protected function loadCoffeeScript($coffeePath) {
        if (($compilerSource = file_get_contents($coffeePath)) === false) {
            throw new RuntimeException('Unable to load the CoffeeScript compiler library');
        }
        return $compilerSource;
    }

    public function createContext() {
        return new SpiderMonkeyContext();
    }

    protected function createCompilerContext($coffeePath) {
        $compilerSource = $this->loadCoffeeScript($coffeePath);
        $compilerCtx = $this->createContext();
        $compilerCtx->evaluateString("$compilerSource\nnull");
        return $compilerCtx;
    }

    public function getCompilerContext() {
        return $this->_compilerCtx;
    }

    public function compile($code) {
        $compilerCtx = $this->getCompilerContext();
        $compilerCtx->registerVariable('___USRSRC___', $code);
        $script = 'CoffeeScript.compile(___USRSRC___, { bare: true });';
        $compiled = $compilerCtx->evaluateString($script);
        if ($compiled === false) {
            throw new RuntimeException('Unable to compile the provided CoffeeScript code');
        }
        return $compiled;
    }

    public function execute($code, JavaScriptContextInterface $context = null) {
        $context = $context ?: $this->createContext();
        return $context->evaluateString($this->compile($code));
    }

    public function compileFile($path) {
        if (($code = file_get_contents($path)) === false) {
            throw new RuntimeException("Unable to load the CoffeeScript file at $path");
        }
        return $this->compile($code);
    }

    public function executeFile($path, JavaScriptContextInterface $context = null) {
        $context = $context ?: $this->createContext();
        return $context->evaluateString($this->compileFile($path));
    }
}

{'fraction_non_alphanumeric': 0.1236218625381187, 'fraction_numerical': 0.0, 'mean_word_length': 3.184494602551521, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4529030', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1102, 'n_words': 250}