~ubuntu-branches/ubuntu/lucid/monodevelop/lucid

« back to all changes in this revision

Viewing changes to contrib/Mono.Cecil/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-02-02 11:39:59 UTC
  • mfrom: (1.2.6 upstream) (1.3.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100202113959-s4exdz7er7igylz2
Tags: 2.2.1+dfsg-1
* New upstream release
* debian/control:
  + Standards version 3.8.4 (no changes needed)
* debian/patches/remove_support_for_non_debian_functionality.patch,
  debian/patches/remove_support_for_soft_debugger.patch,
  debian/patches/remove_support_for_moonlight.patch,
  debian/rules:
  + Split patch into two pieces, to make it easier to enable either
    SDB or Moonlight support with a rebuild
* debian/monodevelop-moonlight.install,
  debian/monodevelop-debugger-sdb.install,
  debian/control:
  + Create packaging data for the Soft Debugger addin and Moonlight addin -
    and comment them out of debian/control as we can't provide them on
    Debian for now

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
                        set { m_initLocals = value; }
65
65
                }
66
66
 
67
 
                internal int LocalVarToken {
 
67
                public int LocalVarToken {
68
68
                        get { return m_localVarToken; }
69
69
                        set { m_localVarToken = value; }
70
70
                }
82
82
                        get { return m_instructions; }
83
83
                }
84
84
 
 
85
                public bool HasExceptionHandlers {
 
86
                        get { return m_exceptions != null && m_exceptions.Count > 0; }
 
87
                }
 
88
 
85
89
                public ExceptionHandlerCollection ExceptionHandlers {
86
 
                        get { return m_exceptions; }
 
90
                        get {
 
91
                                if (m_exceptions == null)
 
92
                                        m_exceptions = new ExceptionHandlerCollection (this);
 
93
                                return m_exceptions;
 
94
                        }
 
95
                }
 
96
 
 
97
                public bool HasVariables {
 
98
                        get { return m_variables != null && m_variables.Count > 0; }
87
99
                }
88
100
 
89
101
                public VariableDefinitionCollection Variables {
90
 
                        get { return m_variables; }
 
102
                        get {
 
103
                                if (m_variables == null)
 
104
                                        m_variables = new VariableDefinitionCollection (this);
 
105
                                return m_variables;
 
106
                        }
 
107
                }
 
108
 
 
109
                public bool HasScopes {
 
110
                        get { return m_scopes != null && m_scopes.Count > 0; }
91
111
                }
92
112
 
93
113
                public ScopeCollection Scopes {
94
 
                        get { return m_scopes; }
 
114
                        get {
 
115
                                if (m_scopes == null)
 
116
                                        m_scopes = new ScopeCollection (this);
 
117
                                return m_scopes;
 
118
                        }
95
119
                }
96
120
 
97
121
                public MethodBody (MethodDefinition meth)
98
122
                {
99
123
                        m_method = meth;
 
124
                        // there is always a RET instruction (if a body is present)
100
125
                        m_instructions = new InstructionCollection (this);
101
 
                        m_exceptions = new ExceptionHandlerCollection (this);
102
 
                        m_variables = new VariableDefinitionCollection (this);
103
 
                        m_scopes = new ScopeCollection (this);
104
126
                }
105
127
 
106
128
                internal static Instruction GetInstruction (MethodBody oldBody, MethodBody newBody, Instruction i)
121
143
 
122
144
                        CilWorker worker = nb.CilWorker;
123
145
 
124
 
                        foreach (VariableDefinition var in body.Variables)
125
 
                                nb.Variables.Add (new VariableDefinition (
126
 
                                        var.Name, var.Index, parent,
127
 
                                        context.Import (var.VariableType)));
 
146
                        if (body.HasVariables) {
 
147
                                foreach (VariableDefinition var in body.Variables)
 
148
                                        nb.Variables.Add (new VariableDefinition (
 
149
                                                var.Name, var.Index, parent,
 
150
                                                context.Import (var.VariableType)));
 
151
                        }
128
152
 
129
153
                        foreach (Instruction instr in body.Instructions) {
130
154
                                Instruction ni = new Instruction (instr.OpCode);
189
213
                                        instr.Operand = GetInstruction (body, nb, (Instruction) oldi.Operand);
190
214
                        }
191
215
 
 
216
                        if (!body.HasExceptionHandlers)
 
217
                                return nb;
 
218
 
192
219
                        foreach (ExceptionHandler eh in body.ExceptionHandlers) {
193
220
                                ExceptionHandler neh = new ExceptionHandler (eh.Type);
194
221
                                neh.TryStart = GetInstruction (body, nb, eh.TryStart);
582
609
                public void Accept (ICodeVisitor visitor)
583
610
                {
584
611
                        visitor.VisitMethodBody (this);
585
 
                        m_variables.Accept (visitor);
 
612
                        if (HasVariables)
 
613
                                m_variables.Accept (visitor);
586
614
                        m_instructions.Accept (visitor);
587
 
                        m_exceptions.Accept (visitor);
588
 
                        m_scopes.Accept (visitor);
 
615
                        if (HasExceptionHandlers)
 
616
                                m_exceptions.Accept (visitor);
 
617
                        if (HasScopes)
 
618
                                m_scopes.Accept (visitor);
589
619
 
590
620
                        visitor.TerminateMethodBody (this);
591
621
                }