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

ComputeSequentialLayout() 개인적인 메소드

private ComputeSequentialLayout ( MosaType type ) : void
type MosaType
리턴 void
        private void ComputeSequentialLayout(MosaType type)
        {
            Debug.Assert(type != null, @"No type given.");

            if (typeSizes.ContainsKey(type))
                return;

            // Instance size
            int typeSize = 0;

            // Receives the size/alignment
            int packingSize = type.PackingSize ?? NativePointerAlignment;

            if (type.BaseType != null)
            {
                if (!type.IsValueType)
                {
                    typeSize = GetTypeSize(type.BaseType);
                }
            }

            foreach (MosaField field in type.Fields)
            {
                if (!field.IsStatic)
                {
                    // Set the field address
                    fieldOffsets.Add(field, typeSize);

                    int fieldSize = GetFieldSize(field);
                    typeSize += fieldSize;

                    // Pad the field in the type
                    if (packingSize != 0)
                    {
                        int padding = (packingSize - (typeSize % packingSize)) % packingSize;
                        typeSize += padding;
                    }
                }
            }

            typeSizes.Add(type, typeSize);
        }