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

« back to all changes in this revision

Viewing changes to contrib/Mono.Cecil/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.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:
47
47
 
48
48
                IDictionary m_stackSizes;
49
49
 
 
50
                bool stripped;
 
51
 
 
52
                public bool Stripped {
 
53
                        get { return stripped; }
 
54
                        set { stripped = value; }
 
55
                }
 
56
 
50
57
                public CodeWriter (ReflectionWriter reflectWriter, MemoryBinaryWriter writer)
51
58
                {
52
59
                        m_reflectWriter = reflectWriter;
174
181
                                case OperandType.InlineType :
175
182
                                case OperandType.InlineTok :
176
183
                                        if (instr.Operand is TypeReference)
177
 
                                                WriteToken (m_reflectWriter.GetTypeDefOrRefToken (
178
 
                                                                instr.Operand as TypeReference));
 
184
                                                WriteToken (GetTypeToken ((TypeReference) instr.Operand));
179
185
                                        else if (instr.Operand is GenericInstanceMethod)
180
186
                                                WriteToken (m_reflectWriter.GetMethodSpecToken (instr.Operand as GenericInstanceMethod));
181
187
                                        else if (instr.Operand is MemberReference)
220
226
                        m_codeWriter.BaseStream.Position = pos;
221
227
                }
222
228
 
 
229
                MetadataToken GetTypeToken (TypeReference type)
 
230
                {
 
231
                        return m_reflectWriter.GetTypeDefOrRefToken (type);
 
232
                }
 
233
 
223
234
                MetadataToken GetCallSiteToken (CallSite cs)
224
235
                {
225
236
                        uint sig;
319
330
                {
320
331
                        switch (eh.Type) {
321
332
                        case ExceptionHandlerType.Catch :
322
 
                                WriteToken (eh.CatchType.MetadataToken);
 
333
                                WriteToken (GetTypeToken (eh.CatchType));
323
334
                                break;
324
335
                        case ExceptionHandlerType.Filter :
325
336
                                m_codeWriter.Write ((uint) eh.FilterStart.Offset);
333
344
                public override void VisitVariableDefinitionCollection (VariableDefinitionCollection variables)
334
345
                {
335
346
                        MethodBody body = variables.Container as MethodBody;
336
 
                        if (body == null)
 
347
                        if (body == null || stripped)
337
348
                                return;
338
349
 
339
350
                        uint sig = m_reflectWriter.SignatureWriter.AddLocalVarSig (
357
368
                {
358
369
                        long pos = m_binaryWriter.BaseStream.Position;
359
370
 
360
 
                        if (body.Variables.Count > 0 || body.ExceptionHandlers.Count > 0
 
371
                        if (body.HasVariables || body.HasExceptionHandlers
361
372
                                || m_codeWriter.BaseStream.Length >= 64 || body.MaxStack > 8) {
362
373
 
363
374
                                MethodHeader header = MethodHeader.FatFormat;
364
375
                                if (body.InitLocals)
365
376
                                        header |= MethodHeader.InitLocals;
366
 
                                if (body.ExceptionHandlers.Count > 0)
 
377
                                if (body.HasExceptionHandlers)
367
378
                                        header |= MethodHeader.MoreSects;
368
379
 
369
380
                                m_binaryWriter.Write ((byte) header);
370
381
                                m_binaryWriter.Write ((byte) 0x30); // (header size / 4) << 4
371
382
                                m_binaryWriter.Write ((short) body.MaxStack);
372
383
                                m_binaryWriter.Write ((int) m_codeWriter.BaseStream.Length);
373
 
                                m_binaryWriter.Write (((int) TokenType.Signature | body.LocalVarToken));
 
384
                                // the token should be zero if there are no variables
 
385
                                int token = body.HasVariables ? ((int) TokenType.Signature | body.LocalVarToken) : 0;
 
386
                                m_binaryWriter.Write (token);
374
387
 
375
 
                                WriteExceptionHandlerCollection (body.ExceptionHandlers);
 
388
                                if (body.HasExceptionHandlers)
 
389
                                        WriteExceptionHandlerCollection (body.ExceptionHandlers);
376
390
                        } else
377
391
                                m_binaryWriter.Write ((byte) ((byte) MethodHeader.TinyFormat |
378
392
                                        m_codeWriter.BaseStream.Length << 2));
545
559
                                        break;
546
560
 
547
561
                                IMethodSignature method = (IMethodSignature) instruction.Operand;
548
 
                                int count = method.Parameters.Count;
 
562
                                int count = method.HasParameters ? method.Parameters.Count : 0;
549
563
                                if (method.HasThis && code != OpCodes.Newobj)
550
564
                                        ++count;
551
565