/// <summary> /// </summary> /// <param name="type"> /// </param> /// <param name="asValueType"> /// </param> /// <returns> /// </returns> public static int GetTypeSize(this IType type, ITypeResolver typeResolver, bool asValueType = false) { if (asValueType) { // TODO: do I need to return plain size of structure? if (type.IsPrimitiveType()) { return(SystemTypeSizes[type.Name]); } if (!type.IsStructureType() && !type.IsEnum) { return(LlvmWriter.PointerSize); } } // find index int size; if (!sizeByType.TryGetValue(type.ToString(), out size)) { IList <MemberLocationInfo> membersLayout; size = type.CalculateSize(typeResolver, out membersLayout); sizeByType[type.ToString()] = size; membersLayoutByType[type.ToString()] = membersLayout; } return(size); }
/// <summary> /// </summary> /// <param name="type"> /// </param> /// <param name="asValueType"> /// </param> /// <returns> /// </returns> public static int GetTypeSize(this IType type, bool asValueType = false) { if (asValueType && type.IsPrimitiveType()) { return(SystemTypeSizes[type.Name]); } // find index int size; if (!sizeByType.TryGetValue(type, out size)) { IList <MemberLocationInfo> membersLayout; size = type.CalculateSize(out membersLayout); sizeByType[type] = size; membersLayoutByType[type] = membersLayout; } return(size); }