Mono.Cecil.Rocks.ILParser.CreateContext C# (CSharp) Method

CreateContext() static private method

static private CreateContext ( MethodDefinition method, IILVisitor visitor ) : ParseContext
method MethodDefinition
visitor IILVisitor
return ParseContext
        static ParseContext CreateContext(MethodDefinition method, IILVisitor visitor)
        {
            var code = method.Module.Read (method, (_, reader) => reader.code);
            code.MoveTo (method);

            return new ParseContext {
                Code = code,
                Metadata = code.reader,
                Visitor = visitor,
            };
        }

Usage Example

Beispiel #1
0
        public static void Parse(MethodDefinition method, IILVisitor visitor)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }
            if (visitor == null)
            {
                throw new ArgumentNullException("visitor");
            }
            if (!method.HasBody || !method.HasImage)
            {
                throw new ArgumentException();
            }
            ILParser.ParseContext parseContext = ILParser.CreateContext(method, visitor);
            CodeReader            code         = parseContext.Code;

            code.MoveTo(method.RVA);
            byte num  = code.ReadByte();
            int  num1 = num & 3;

            if (num1 == 2)
            {
                ILParser.ParseCode(num >> 2, parseContext);
                return;
            }
            if (num1 != 3)
            {
                throw new NotSupportedException();
            }
            code.position--;
            ILParser.ParseFatMethod(parseContext);
        }