Permalink
Browse files

Fix handling of explicit this call convention.

Based on a patch by 0xd4d.
Fix #87.
  • Loading branch information...
1 parent e174d32 commit a43bc63f8e7668cbdba2dea44dd8465f73781cfb @jbevain committed Jan 30, 2012
Showing with 7 additions and 2 deletions.
  1. +1 −1 Mono.Cecil.Cil/CodeWriter.cs
  2. +5 −0 Mono.Cecil/IMethodSignature.cs
  3. +1 −1 Mono.Cecil/ParameterDefinition.cs
@@ -425,7 +425,7 @@ static void ComputeStackDelta (Instruction instruction, ref int stack_size)
case FlowControl.Call: {
var method = (IMethodSignature) instruction.operand;
stack_size -= (method.HasParameters ? method.Parameters.Count : 0)
- + (method.HasThis && instruction.opcode.Code != Code.Newobj ? 1 : 0);
+ + (method.HasImplicitThis () && instruction.opcode.Code != Code.Newobj ? 1 : 0);
stack_size += (method.ReturnType.etype == ElementType.Void ? 0 : 1)
+ (method.HasThis && instruction.opcode.Code == Code.Newobj ? 1 : 0);
break;
@@ -46,6 +46,11 @@ public interface IMethodSignature : IMetadataTokenProvider {
static partial class Mixin {
+ public static bool HasImplicitThis (this IMethodSignature self)
+ {
+ return self.HasThis && !self.ExplicitThis;
+ }
+
public static void MethodSignatureFullName (this IMethodSignature self, StringBuilder builder)
{
builder.Append ("(");
@@ -54,7 +54,7 @@ public sealed class ParameterDefinition : ParameterReference, ICustomAttributePr
if (method == null)
return -1;
- return method.HasThis ? index + 1 : index;
+ return method.HasImplicitThis () ? index + 1 : index;
}
}

0 comments on commit a43bc63

Please sign in to comment.