~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodBodyMirror.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
using System;
 
2
using System.Globalization;
2
3
using System.Collections.Generic;
3
4
using System.Text;
4
5
using Mono.Cecil.Cil;
5
6
using Mono.Cecil.Metadata;
6
7
using System.IO;
 
8
using System.Linq;
7
9
using System.Reflection;
8
10
 
9
11
namespace Mono.Debugger.Soft
11
13
        public class MethodBodyMirror : Mirror
12
14
        {
13
15
                MethodMirror method;
14
 
                byte[] il;
 
16
                MethodBodyInfo info;
15
17
 
16
 
                internal MethodBodyMirror (VirtualMachine vm, MethodMirror method, byte[] il) : base (vm, 0) {
 
18
                internal MethodBodyMirror (VirtualMachine vm, MethodMirror method, MethodBodyInfo info) : base (vm, 0) {
17
19
                        this.method = method;
18
 
                        this.il = il;
 
20
                        this.info = info;
19
21
                }
20
22
 
21
23
                public MethodMirror Method {
24
26
                        }
25
27
                }
26
28
 
 
29
                public List<ILExceptionHandler> ExceptionHandlers {
 
30
                        get {
 
31
                                vm.CheckProtocolVersion (2, 18);
 
32
                                return info.clauses.Select (c =>
 
33
                                {
 
34
                                        var handler = new ILExceptionHandler (c.try_offset, c.try_length, (ILExceptionHandlerType) c.flags, c.handler_offset, c.handler_length);
 
35
                                        if (c.flags == ExceptionClauseFlags.None)
 
36
                                                handler.CatchType = vm.GetType (c.catch_type_id);
 
37
                                        else if (c.flags == ExceptionClauseFlags.Filter)
 
38
                                                handler.FilterOffset = c.filter_offset;
 
39
 
 
40
                                        return handler;
 
41
                                }).ToList ();
 
42
                        }
 
43
                }
 
44
 
27
45
                public byte[] GetILAsByteArray () {
28
 
                        return il;
 
46
                        return info.il;
29
47
                }
30
48
 
31
49
                public List<ILInstruction> Instructions {
32
50
                        get {
33
 
                                return ReadCilBody (new BinaryReader (new MemoryStream (il)), il.Length);
 
51
                                return ReadCilBody (new BinaryReader (new MemoryStream (info.il)), info.il.Length);
34
52
                        }
35
53
                }
36
54
 
40
58
                static OpCode [] TwoBytesOpCode = new OpCode [0x1e + 1];
41
59
 
42
60
                // Adapted from Cecil
43
 
            List<ILInstruction> ReadCilBody (BinaryReader br, int code_size)
 
61
                List<ILInstruction> ReadCilBody (BinaryReader br, int code_size)
44
62
                {
45
63
                        long start = br.BaseStream.Position;
46
64
                        ILInstruction last = null;