Mosa.Compiler.Framework.MosaTypeLayout.ComputeExplicitLayout C# (CSharp) 메소드

ComputeExplicitLayout() 개인적인 메소드

Applies the explicit layout to the given type.
private ComputeExplicitLayout ( MosaType type ) : void
type MosaType The type.
리턴 void
        private void ComputeExplicitLayout(MosaType type)
        {
            Debug.Assert(type != null, @"No type given.");

            //Debug.Assert(type.BaseType.LayoutSize != 0, @"Type size not set for explicit layout.");

            int size = 0;
            foreach (MosaField field in type.Fields)
            {
                if (field.Offset == null)
                    continue;

                int offset = (int)field.Offset.Value;
                fieldOffsets.Add(field, offset);
                size = Math.Max(size, offset + GetFieldSize(field));

                // Explicit layout assigns a physical offset from the start of the structure
                // to the field. We just assign this offset.
                Debug.Assert(fieldSizes[field] != 0, @"Non-static field doesn't have layout!");
            }

            typeSizes.Add(type, (type.ClassSize == null || type.ClassSize == -1) ? size : (int)type.ClassSize);
        }