<commit_before>﻿using System;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using IIS.SLSharp.Annotations;
using IIS.SLSharp.Diagnostics;
using IIS.SLSharp.Reflection;
using IIS.SLSharp.Runtime;
using IIS.SLSharp.Textures;
using IIS.SLSharp.Translation;
using Mono.Cecil;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System.Collections.Generic;
using FieldAttributes = System.Reflection.FieldAttributes;
using MethodAttributes = System.Reflection.MethodAttributes;
using TypeAttributes = System.Reflection.TypeAttributes;

namespace IIS.SLSharp.Shaders
{
    /// <summary>
    /// Base class of which all typed GLSL shaders derive of
    /// </summary>
    public abstract class Shader : ShaderDefinition, IDisposable
    {
        private const BindingFlags BindingFlagsAny =
            BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;

        [ReflectionMarker(ReflectionToken.ShaderName)]
        public int Name { get; private set; }

        public static bool DebugMode { get; set; }

        private readonly string _uniforms;

        private readonly string _varyings;

        private readonly string _ins;

        private readonly string _outs;

        private readonly string _ffuns;

        private readonly string _vfuns;

        private readonly string _fentry;

        private readonly string _ventry;

        private bool _vsCompiled;

        private bool _fsCompiled;

        private static int _quadVbo;

        private static int _refCount;

        private static readonly ShaderDebugger _debugger = new ShaderDebugger();

        private readonly List<int> _objects = new List<int>();

        private TypeDefinition _shader;

#if DEBUG

        /// <summary>
        /// Dumps the GLSL shader to a file for debugging purposes
        /// </summary>
        /// <param name="type">The shader type that is to be dumped</param>
        /// <param name="s">The shader source to be dumped</param>
        private void Dump(ShaderType type, string s)
        {
            var fn = GetType().Name + "." + type;

            using (var f = new StreamWriter(fn, false))
                f.Write(s);<commit_msg>Made Shader._shader readonly.<commit_after>﻿using System;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using IIS.SLSharp.Annotations;
using IIS.SLSharp.Diagnostics;
using IIS.SLSharp.Reflection;
using IIS.SLSharp.Runtime;
using IIS.SLSharp.Textures;
using IIS.SLSharp.Translation;
using Mono.Cecil;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System.Collections.Generic;
using FieldAttributes = System.Reflection.FieldAttributes;
using MethodAttributes = System.Reflection.MethodAttributes;
using TypeAttributes = System.Reflection.TypeAttributes;

namespace IIS.SLSharp.Shaders
{
    /// <summary>
    /// Base class of which all typed GLSL shaders derive of
    /// </summary>
    public abstract class Shader : ShaderDefinition, IDisposable
    {
        private const BindingFlags BindingFlagsAny =
            BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;

        [ReflectionMarker(ReflectionToken.ShaderName)]
        public int Name { get; private set; }

        public static bool DebugMode { get; set; }

        private readonly string _uniforms;

        private readonly string _varyings;

        private readonly string _ins;

        private readonly string _outs;

        private readonly string _ffuns;

        private readonly string _vfuns;

        private readonly string _fentry;

        private readonly string _ventry;

        private bool _vsCompiled;

        private bool _fsCompiled;

        private static int _quadVbo;

        private static int _refCount;

        private static readonly ShaderDebugger _debugger = new ShaderDebugger();

        private readonly List<int> _objects = new List<int>();

        private readonly TypeDefinition _shader;

#if DEBUG

        /// <summary>
        /// Dumps the GLSL shader to a file for debugging purposes
        /// </summary>
        /// <param name="type">The shader type that is to be dumped</param>
        /// <param name="s">The shader source to be dumped</param>
        private void Dump(ShaderType type, string s)
        {
            var fn = GetType().Name + "." + type;

            using (var f = new StreamWriter(fn, false))
                f.Write(s);
{'fraction_non_alphanumeric': 0.08140290106083568, 'fraction_numerical': 0.0, 'mean_word_length': 2.8758389261744965, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6586101', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1181, 'n_words': 388}