public Reg64Enumerable(RegBase r, Type enumType, Boolean bRelaxedTypeMatching) { if (r != null) { // int i = 0; mReg = r; if (bRelaxedTypeMatching) { // in relaxed Type Matching, we only care that n elements in both // enums have the same position and the same name, where n is the // number of enum values in the passed in enumType that overlap enum // values in the register. Array enumValues = Enum.GetValues(enumType); //if (enumValues.Length >= reg.NumBitFields) //{ // throw new Exception( // "Relaxed type matching ONLY makes sense if the new enum is < the registers actual enum."); //} // now we get each enum name at the identical position and make sure there is // an exact name match. //reg.Reset(); //IEnumerator e = reg.GetEnumerator(); //foreach (object enumValue in enumValues) //{ int last = (int)enumValues.GetValue(enumValues.Length - 1); for (int i = mReg.FirstBF; i <= last; i++) { int enumValue = (int)enumValues.GetValue(i); string relaxedName = Enum.GetName(enumType, enumValue); string bitFieldName = Enum.GetName(mReg.BFType, enumValue); if (String.Compare(relaxedName, bitFieldName) != 0) { throw new Exception( string.Format( "Enum ({0}) names don't match in special relaxed case (obfuscation issue?). '{1}' <> '{2}'", enumType, relaxedName, bitFieldName)); } } } else { // normal type matching requires an exact match or an exception is thrown. if (!mReg.BFType.Equals(enumType)) { string s = "Reg enum '" + mReg.BFType.Name + "' does not match "; s += "T type enum '" + enumType.Name + "'"; s += "Reg64<T> constructor error: "; throw new ApplicationException(s); } } //// indexList = new uint[Enum.GetNames(enumType).Length]; // // fill the array with the enum values from the BitField enum. // foreach (int index in Enum.GetValues(enumType)) // { // if (i != index) // throw new Exception("indexes don't match."); // indexList[i++] = (uint)index; // } Reset(); // reset IEnumerable index } }
public Reg64T(RegBase r) : base(r, typeof(TBitFieldEnum)) { }
public Reg64T(RegBase r, Boolean bRelaxedTypeChecking) : base(r, typeof(TBitFieldEnum), bRelaxedTypeChecking) { }
// uint[] indexList; //this array holds each enum value from the enum specifying BitFields // private int m_IEnumerableIndex; public Reg64Enumerable(RegBase r, Type enumType) : this(r, enumType, false) { }