Example #1
0
        public void Read(MethodBody body, InstructionMapper mapper)
        {
            var method_token = body.Method.MetadataToken;

            PdbFunction function;
            if (!functions.TryGetValue (method_token.ToUInt32 (), out function))
                return;

            ReadSequencePoints (function, mapper);
            ReadScopeAndLocals (function.scopes, null, body, mapper);

            if (!string.IsNullOrEmpty (function.iteratorClass))
                body.IteratorType = body.Method.DeclaringType.GetNestedType (function.iteratorClass);

            if (function.iteratorScopes != null)
                foreach (Microsoft.Cci.ILocalScope scope in function.iteratorScopes)
                {
                    InstructionRange range = new InstructionRange ();
                    SetInstructionRange (body, mapper, range, scope.Offset, scope.Length);
                    body.IteratorScopes.Add (range);
                }
        }
Example #2
0
        static void SetInstructionRange(MethodBody body, InstructionMapper mapper,	InstructionRange range, uint offset, uint length)
        {
            range.Start = mapper ((int) offset);
            range.End   = mapper ((int)(offset + length));

            if (range.End == null) range.End = body.Instructions[body.Instructions.Count - 1];
            else                   range.End = range.End.Previous;
        }