<commit_before>abstract class Shader {
    protected vertex_shader: WebGLShader;
    protected fragment_shader: WebGLShader;
    protected program: WebGLProgram;
    protected gl_context: WebGLRenderingContext;

    protected compileProgram(vertex_shader_source :string, fragment_shader_source :string) :void {

        // Load and compile vertex shader.
        this.vertex_shader = this.gl_context.createShader( this.gl_context.VERTEX_SHADER );
        this.gl_context.shaderSource( this.vertex_shader, vertex_shader_source );
        this.gl_context.compileShader( this.vertex_shader );
        if ( !this.gl_context.getShaderParameter(this.vertex_shader, this.gl_context.COMPILE_STATUS) ) {
            let msg = "Vertex shader failed to compile.  The error log is:"
            + "<pre>" + this.gl_context.getShaderInfoLog( this.vertex_shader ) + "</pre>";
            throw new Error(msg);
        }

        this.fragment_shader = this.gl_context.createShader( this.gl_context.FRAGMENT_SHADER );
        this.gl_context.shaderSource( this.fragment_shader, fragment_shader_source );
        this.gl_context.compileShader( this.fragment_shader );
        if ( !this.gl_context.getShaderParameter(this.fragment_shader, this.gl_context.COMPILE_STATUS) ) {
            let msg = "Fragment shader failed to compile.  The error log is:"
            + "<pre>" + this.gl_context.getShaderInfoLog( this.fragment_shader ) + "</pre>";
            alert( msg );
            return null;
        }

        let program = this.gl_context.createProgram();
        this.gl_context.attachShader( program, this.vertex_shader );
        this.gl_context.attachShader( program, this.fragment_shader );
        this.gl_context.linkProgram( program );
        
        if ( !this.gl_context.getProgramParameter(program, this.gl_context.LINK_STATUS) ) {
            var msg = "Shader program failed to link.  The error log is:"
                + "<pre>" + this.gl_context.getProgramInfoLog( program ) + "</pre>";
            alert( msg );
            return null;
        }

        return program;
    }
}
export default Shader;<commit_msg>abstract Shader class capable of loading any pair of shaders.<commit_after>abstract class Shader {
    protected vertex_shader: WebGLShader;
    protected fragment_shader: WebGLShader;
    protected program: WebGLProgram;
    protected gl_context: WebGLRenderingContext;

    constructor(vertex_shader_source: string, fragment_shader_source: string) {
        // Load and compile vertex shader.
        this.vertex_shader = this.gl_context.createShader(this.gl_context.VERTEX_SHADER);
        this.gl_context.shaderSource(this.vertex_shader, vertex_shader_source);
        this.gl_context.compileShader(this.vertex_shader);
        if (!this.gl_context.getShaderParameter(this.vertex_shader, this.gl_context.COMPILE_STATUS)) {
            let msg = "Vertex shader failed to compile.  The error log is:"
                + "<pre>" + this.gl_context.getShaderInfoLog(this.vertex_shader) + "</pre>";
            throw new Error(msg);
        }

        // Load and compile fragment shader.
        this.fragment_shader = this.gl_context.createShader(this.gl_context.FRAGMENT_SHADER);
        this.gl_context.shaderSource(this.fragment_shader, fragment_shader_source);
        this.gl_context.compileShader(this.fragment_shader);
        if (!this.gl_context.getShaderParameter(this.fragment_shader, this.gl_context.COMPILE_STATUS)) {
            let msg = "Fragment shader failed to compile.  The error log is:"
                + "<pre>" + this.gl_context.getShaderInfoLog(this.fragment_shader) + "</pre>";
            throw new Error(msg);
        }

        // Link program
        this.program = this.gl_context.createProgram();
        this.gl_context.attachShader(this.program, this.vertex_shader);
        this.gl_context.attachShader(this.program, this.fragment_shader);
        this.gl_context.linkProgram(this.program);

        if (!this.gl_context.getProgramParameter(this.program, this.gl_context.LINK_STATUS)) {
            var msg = "Shader program failed to link.  The error log is:"
                + "<pre>" + this.gl_context.getProgramInfoLog(this.program) + "</pre>";
            throw new Error(msg);
        }
    }
}
export default Shader;
{'fraction_non_alphanumeric': 0.10093457943925234, 'fraction_numerical': 0.0, 'mean_word_length': 2.971243042671614, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3928944', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1226, 'n_words': 242}