Exemplo n.º 1
0
    internal int AlignAndSize(GAlign ga, out int sz)
    {
        if (IsBasic)
        {
            throw new Exception(string.Format("basic type {0} does not have alignment or size", Name));
        }

        ulong v;

        if (layout.TryGetValue(ga, out v))
        {
            sz = (int)(v >> 32);
            return((int)v);
        }

        Close();

        /*
         * Each object starts with a pointer-sized header.
         */
        int addr = ga.SizeRef(OBJECT);
        int ma   = ga.AlignRef(OBJECT);

        foreach (XTypeElt e in orderedContents)
        {
            int a, s;
            a     = e.AlignAndSize(ga, out s);
            addr  = (addr + a - 1) & ~(a - 1);
            addr += s;
            ma    = Math.Max(ma, a);
        }
        sz         = (addr + ma - 1) & ~(ma - 1);
        layout[ga] = ((ulong)sz << 32) | (ulong)(uint)ma;
        return(ma);
    }
Exemplo n.º 2
0
        internal override int AlignAndSizeInner(GAlign ga, out int sz)
        {
            int a = et.AlignAndSize(ga, out sz);

            sz *= size;
            return(a);
        }
Exemplo n.º 3
0
        internal int AlignAndSize(GAlign ga, out int sz)
        {
            ulong v;

            if (layout.TryGetValue(ga, out v))
            {
                sz = (int)(v >> 32);
                return((int)v);
            }
            int a = AlignAndSizeInner(ga, out sz);

            layout[ga] = ((ulong)sz << 32) | (ulong)(uint)a;
            return(a);
        }
Exemplo n.º 4
0
 internal override int AlignAndSizeInner(GAlign ga, out int sz)
 {
     sz = size * ga.SizeRef(ft);
     return(ga.AlignRef(ft));
 }
Exemplo n.º 5
0
 internal override int AlignAndSizeInner(GAlign ga, out int sz)
 {
     return(Embed.AlignAndSize(ga, out sz));
 }
Exemplo n.º 6
0
 internal abstract int AlignAndSizeInner(GAlign ga, out int sz);