private uint GetEnumTypeIndex(TypeDesc type) { System.Diagnostics.Debug.Assert(type.IsEnum, "GetEnumTypeIndex was called with wrong type"); DefType defType = type as DefType; System.Diagnostics.Debug.Assert(defType != null, "GetEnumTypeIndex was called with non def type"); List <FieldDesc> fieldsDescriptors = new List <FieldDesc>(); foreach (var field in defType.GetFields()) { if (field.IsLiteral) { fieldsDescriptors.Add(field); } } EnumTypeDescriptor enumTypeDescriptor = new EnumTypeDescriptor { ElementCount = (ulong)fieldsDescriptors.Count, ElementType = PrimitiveTypeDescriptor.GetPrimitiveTypeIndex(defType.UnderlyingType), Name = _objectWriter.GetMangledName(type), }; EnumRecordTypeDescriptor[] typeRecords = new EnumRecordTypeDescriptor[enumTypeDescriptor.ElementCount]; for (int i = 0; i < fieldsDescriptors.Count; ++i) { FieldDesc field = fieldsDescriptors[i]; EnumRecordTypeDescriptor recordTypeDescriptor; recordTypeDescriptor.Value = GetEnumRecordValue(field); recordTypeDescriptor.Name = field.Name; typeRecords[i] = recordTypeDescriptor; } uint typeIndex = _objectWriter.GetEnumTypeIndex(enumTypeDescriptor, typeRecords); return(typeIndex); }
private uint GetVariableTypeIndex(TypeDesc type, bool needsCompleteIndex) { uint variableTypeIndex = 0; if (type.IsPrimitive) { variableTypeIndex = PrimitiveTypeDescriptor.GetPrimitiveTypeIndex(type); } else { type = DebuggerCanonicalize(type); if ((type.IsDefType && !type.IsValueType) || type.IsArray) { // The type index of a variable/field of a reference type is wrapped // in a pointer, as these fields are really pointer fields, and the data is on the heap variableTypeIndex = 0; if (_knownReferenceWrappedTypes.TryGetValue(type, out variableTypeIndex)) { return(variableTypeIndex); } else { uint typeindex = GetTypeIndex(type, false); PointerTypeDescriptor descriptor = new PointerTypeDescriptor(); descriptor.ElementType = typeindex; descriptor.Is64Bit = Is64Bit ? 1 : 0; descriptor.IsConst = 0; descriptor.IsReference = 1; variableTypeIndex = _objectWriter.GetPointerTypeIndex(descriptor); _knownReferenceWrappedTypes[type] = variableTypeIndex; return(variableTypeIndex); } } else if (type.IsEnum) { // Enum's use the LF_ENUM record as the variable type index, but it is required to also emit a regular structure record for them. if (_enumTypes.TryGetValue(type, out variableTypeIndex)) { return(variableTypeIndex); } variableTypeIndex = GetEnumTypeIndex(type); GetTypeIndex(type, false); // Ensure regular structure record created } variableTypeIndex = GetTypeIndex(type, needsCompleteIndex); } return(variableTypeIndex); }
public uint GetVariableTypeIndex(TypeDesc type, bool needsCompleteIndex) { uint typeIndex = 0; if (type.IsPrimitive) { typeIndex = PrimitiveTypeDescriptor.GetPrimitiveTypeIndex(type); } else { typeIndex = _userDefinedTypeDescriptor.GetTypeIndex(type, needsCompleteIndex); } return(typeIndex); }
public uint GetPrimitiveTypeIndex(TypeDesc type) { Debug.Assert(type.IsPrimitive, "it is not a primitive type"); // OBJWRITER-TODO: Remove this workaround when objwriter will be updated (see https://github.com/dotnet/corert/issues/5177) try { return(GetPrimitiveTypeIndex(_nativeObjectWriter, (int)type.Category)); } catch { if (_nodeFactory.Target.OperatingSystem == TargetOS.Windows) { return(PrimitiveTypeDescriptor.GetPrimitiveTypeIndex(type)); } return(0); } }
uint ITypesDebugInfoWriter.GetPrimitiveTypeIndex(TypeDesc type) { return(PrimitiveTypeDescriptor.GetPrimitiveTypeIndex(type)); }