コード例 #1
0
 /// <summary>
 /// Parses the specified provider.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="token">The token.</param>
 /// <returns></returns>
 public static LocalVariableSignature Parse(ISignatureContext context, IMetadataProvider provider, TokenTypes token)
 {
     var signature = new LocalVariableSignature();
     signature.LoadSignature(context, provider, token);
     return signature;
 }
コード例 #2
0
        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        public void Run()
        {
            // The size of the code in bytes
            MethodHeader header = new MethodHeader();

            using (Stream code = MethodCompiler.GetInstructionStream())
            {

                // Initalize the instruction, setting the initalize size to 10 times the code stream
                MethodCompiler.InstructionSet = new InstructionSet((int)code.Length * 10);

                // update the base class
                InstructionSet = MethodCompiler.InstructionSet;

                using (BinaryReader reader = new BinaryReader(code))
                {
                    _compiler = MethodCompiler;
                    _method = MethodCompiler.Method;
                    _codeReader = reader;

                    ReadMethodHeader(reader, ref header);
                    //Debug.WriteLine("Decoding " + compiler.Method.ToString());

                    if (0 != header.localsSignature)
                    {
                        StandAloneSigRow row;
                        IMetadataProvider md = _method.Module.Metadata;
                        md.Read(header.localsSignature, out row);

                        LocalVariableSignature localsSignature = new LocalVariableSignature();
                        localsSignature.LoadSignature(this._method, md, row.SignatureBlobIdx);
                        this.MethodCompiler.SetLocalVariableSignature(localsSignature);
                    }

                    /* Decode the instructions */
                    Decode(MethodCompiler, ref header);

                    // When we leave, the operand stack must only contain the locals...
                    //Debug.Assert(_operandStack.Count == _method.Locals.Count);
                    _codeReader = null;
                    _compiler = null;
                }
            }
        }