/// <summary> /// Look up a specified StructType, and creates it with the specified /// list of struct fields if an instance doesn't already exist. /// </summary> /// <param name="name">StructType name.</param> /// <param name="fields">List of fields for the created structure.</param> /// <returns>StructType instance.</returns> public StructType GetStructType(string name, StructField[] fields) { StructType ST = GetStructType(name); if (ST != null) { bool allFieldsMatch = ST.Fields.Length == fields.Length; if (allFieldsMatch) { for (int i = 0; i < ST.Fields.Length; ++i) { if (ST.Fields[i] != fields[i]) { allFieldsMatch = false; break; } } } if (allFieldsMatch) return ST; else throw new HlslDomException("Redefinition of existing struct type!"); } StructType newST = new StructType(name, fields); sStructTypes.Add(newST); return newST; }
/// <summary> /// Constructs a StructType. Do not use directly, create StructType instances through the TypeRegistry. /// </summary> /// <param name="name">Structure name.</param> /// <param name="fields">Structure fields.</param> public StructType(string name, StructField[] fields) { Name = name; Fields = fields; }