コード例 #1
0
        /// <summary>
        /// While computing layout, we don't generally compute the full field information. This function is used to
        /// gate how much of field layout to run
        /// </summary>
        /// <param name="fieldStorage">the conceptual location of the field</param>
        /// <param name="loadRequested">what sort of load was requested</param>
        /// <returns></returns>
        internal bool ShouldProcessField(NativeFormat.FieldStorage fieldStorage, FieldLoadState loadRequested)
        {
            if (fieldStorage == (int)NativeFormat.FieldStorage.Instance)
            {
                // Make sure we wanted to load instance fields.
                if ((loadRequested & FieldLoadState.Instance) == FieldLoadState.None)
                {
                    return(false);
                }
            }
            else if ((loadRequested & FieldLoadState.Statics) == FieldLoadState.None)
            {
                // Otherwise the field is a static, and we only want instance fields.
                return(false);
            }

            return(true);
        }
コード例 #2
0
        private static NativeLayoutFieldDesc[] ParseFieldLayout(DefType owningType,
                                                                NativeLayoutInfoLoadContext nativeLayoutInfoLoadContext, NativeParser fieldLayoutParser)
        {
            if (fieldLayoutParser.IsNull)
            {
                return(Empty <NativeLayoutFieldDesc> .Array);
            }

            uint numFields = fieldLayoutParser.GetUnsigned();
            var  fields    = new NativeLayoutFieldDesc[numFields];

            for (int i = 0; i < numFields; i++)
            {
                TypeDesc fieldType = nativeLayoutInfoLoadContext.GetType(ref fieldLayoutParser);
                NativeFormat.FieldStorage storage = (NativeFormat.FieldStorage)fieldLayoutParser.GetUnsigned();
                fields[i] = new NativeLayoutFieldDesc(owningType, fieldType, storage);
            }

            return(fields);
        }