Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Mono.Cecil.Cil/CodeWriter.cs')
-rw-r--r--Mono.Cecil.Cil/CodeWriter.cs40
1 files changed, 15 insertions, 25 deletions
diff --git a/Mono.Cecil.Cil/CodeWriter.cs b/Mono.Cecil.Cil/CodeWriter.cs
index 6ce8452..c103824 100644
--- a/Mono.Cecil.Cil/CodeWriter.cs
+++ b/Mono.Cecil.Cil/CodeWriter.cs
@@ -1,29 +1,11 @@
//
-// CodeWriter.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Licensed under the MIT/X11 license.
//
using System;
@@ -424,10 +406,18 @@ namespace Mono.Cecil.Cil {
switch (instruction.opcode.FlowControl) {
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);
- stack_size += (method.ReturnType.etype == ElementType.Void ? 0 : 1)
- + (method.HasThis && instruction.opcode.Code == Code.Newobj ? 1 : 0);
+ // pop 'this' argument
+ if (method.HasImplicitThis() && instruction.opcode.Code != Code.Newobj)
+ stack_size--;
+ // pop normal arguments
+ if (method.HasParameters)
+ stack_size -= method.Parameters.Count;
+ // pop function pointer
+ if (instruction.opcode.Code == Code.Calli)
+ stack_size--;
+ // push return value
+ if (method.ReturnType.etype != ElementType.Void || instruction.opcode.Code == Code.Newobj)
+ stack_size++;
break;
}
default: