public static string ReplaceConstants(DissasemblyConstants genConstants, DissasemblyConstants refConstants, string genData)
 {
     genData = genData.Replace($"{genConstants.Name} ", $"shadergenprefix{refConstants.Name}shadergensuffix ");
     genData = genData.Replace($"{genConstants.Name}.", $"shadergenprefix{refConstants.Name}shadergensuffix.");
     genData = genData.Replace($"{genConstants.Name}\n", $"shadergenprefix{refConstants.Name}shadergensuffix\n");
     return(genData);
 }
        public static Dictionary <string, DissasemblyConstants> GetConstants(string data, string version)
        {
            var startIndex    = data.IndexOf(version) + 7;
            var trimmedString = data.Substring(startIndex);
            var endIndex      = trimmedString.IndexOf("dcl_") - 5;

            if (endIndex < 0)
            {
                return(null);
            }
            var constantsBlock = trimmedString.Substring(0, endIndex);

            constantsBlock = constantsBlock.Replace("    def ", "");
            List <string> registerConstants = constantsBlock.Split('\n').ToList();
            Dictionary <string, DissasemblyConstants> constantsMapping = new Dictionary <string, DissasemblyConstants>();

            for (int i = 0; i < registerConstants.Count; i++)
            {
                var register     = registerConstants[i];
                var regConstants = register.Split(',').ToList();
                if (regConstants.Count == 0)
                {
                    continue;
                }
                var name = regConstants[0];
                regConstants.RemoveAt(0);
                constantsMapping[name] = new DissasemblyConstants(name, i, regConstants[0], regConstants[1], regConstants[2], regConstants[3]);
            }

            return(constantsMapping);
        }
 public static string RebuildConstants(DissasemblyConstants constant)
 {
     return($"{constant.X}, {constant.Y}, {constant.Z}, {constant.W}");
 }