Exemplo n.º 1
0
        internal sealed override void BuildSignatures(MetaDataOut md)
        {
            if (locals != null)
            {
                localSig.BuildSignatures(md);
                locToken = localSig.Token();
            }
            if (code != null)
            {
                // If the stack depth has not been explicity set, try to work out what is needed.
                if (maxStack == 0)
                {
                    try
                    {
                        // Set the flag to show if the return type is void or other.
                        code.ReturnsVoid = GetRetType().SameType(PrimitiveType.Void);

                        // Calculate the max stack depth
                        maxStack = code.GetMaxStackDepthRequired();
                    }
                    catch (CouldNotFindMaxStackDepth)
                    {
                        // Could not find the depth, assign the default
                        maxStack = DefaultMaxStackDepth;
                    }
                }
                code.CheckCode(locToken, initLocals, maxStack, md);
                textOffset = md.AddCode(code);
                if (Diag.DiagOn)
                {
                    Console.WriteLine("code offset = " + textOffset);
                }
            }
            sig.BuildSignatures(md);
            MemoryStream outSig = new MemoryStream();

            TypeSig(outSig);
            sigIx = md.AddToBlobHeap(outSig.ToArray());
            done  = false;
        }
Exemplo n.º 2
0
        internal override sealed void BuildSignatures(MetaDataOut md)
        {
            if (locals != null)
            {
                localSig.BuildSignatures(md);
                locToken = localSig.Token();
            }
            if (code != null)
            {
                // If the stack depth has not been explicity set, try to work out what is needed.
                if (maxStack == 0)
                {
                    try
                    {

                        // Set the flag to show if the return type is void or other.
                        code.ReturnsVoid = GetRetType().SameType(PrimitiveType.Void);

                        // Calculate the max stack depth
                        maxStack = code.GetMaxStackDepthRequired();
                    }
                    catch (CouldNotFindMaxStackDepth)
                    {
                        // Could not find the depth, assign the default
                        maxStack = DefaultMaxStackDepth;
                    }
                }
                code.CheckCode(locToken, initLocals, maxStack, md);
                textOffset = md.AddCode(code);
                if (Diag.DiagOn) Console.WriteLine("code offset = " + textOffset);
            }
            sig.BuildSignatures(md);
            MemoryStream outSig = new MemoryStream();
            TypeSig(outSig);
            sigIx = md.AddToBlobHeap(outSig.ToArray());
            done = false;
        }