<commit_before>#!/usr/bin/env node

var argv = require('optimist').argv,
    Shade = require('..'),
    usage = "node ./js2glsl.js script.js [-p]";

(function (args) {

    var fs = require("fs"),
        path = require("path"),
        GLSLCompiler = require("../src/generate/glsl/compiler").GLSLCompiler,
        filename = args._[0];


    if (!filename) {
        console.log(usage);
        process.exit(0);
    }

    var ctx = filename.replace(/\.[^/.]+$/, "") + "-context.json";

    var code = (function () {

        var contextData = {};
        if (fs.existsSync(ctx)) {
            console.log("Found context file: " + ctx);
            var contextData = JSON.parse(fs.readFileSync(ctx, "utf-8"));
        }
        var data = fs.readFileSync(filename, "utf-8");
        var opt = { inject: contextData, loc: true, implementation: "xml3d-glsl-forward"};
        var aast = Shade.parseAndInferenceExpression(data, opt);
        //return require("../src/generate/glsl/generate.js").generate(aast);
        return new GLSLCompiler().compileFragmentShader(aast, {useStatic: true});
    }());

    if (args.p) {
        console.log(code);
    } else {
        console.log(code);

    }

}(argv));<commit_msg>Tools: Adapt to new return type of GLSLCompiler::compileFragmentShader<commit_after>#!/usr/bin/env node

var argv = require('optimist').argv,
    Shade = require('..'),
    usage = "node ./js2glsl.js script.js [-p]";

(function (args) {

    var fs = require("fs"),
        path = require("path"),
        GLSLCompiler = require("../src/generate/glsl/compiler").GLSLCompiler,
        filename = args._[0];


    if (!filename) {
        console.log(usage);
        process.exit(0);
    }

    var ctx = filename.replace(/\.[^/.]+$/, "") + "-context.json";

    var code = (function () {

        var contextData = {};
        if (fs.existsSync(ctx)) {
            console.log("Found context file: " + ctx);
            var contextData = JSON.parse(fs.readFileSync(ctx, "utf-8"));
        }
        var data = fs.readFileSync(filename, "utf-8");
        var opt = { inject: contextData, loc: true, implementation: "xml3d-glsl-forward"};
        var aast = Shade.parseAndInferenceExpression(data, opt);
        //return require("../src/generate/glsl/generate.js").generate(aast);
        return new GLSLCompiler().compileFragmentShader(aast, {useStatic: true});
    }());

    if (args.p) {
        console.log(code.source);
    } else {
        console.log(code.source);

    }

}(argv));
{'fraction_non_alphanumeric': 0.17858569716340392, 'fraction_numerical': 0.004794246903715541, 'mean_word_length': 2.4395604395604398, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '717763', 'n_tokens_mistral': 800, 'n_tokens_neox': 776, 'n_words': 156}