diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/CodeBuilder.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/CodeBuilder.cs index 982540f55d..606e975431 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/CodeBuilder.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/CodeBuilder.cs @@ -52,7 +52,7 @@ public LocalReference DeclareLocal(Type type) return local; } - internal void Generate(IMemberEmitter member, ILGenerator il) + internal void Generate(ILGenerator il) { foreach (var local in locals) { @@ -61,7 +61,7 @@ internal void Generate(IMemberEmitter member, ILGenerator il) foreach (var statement in statements) { - statement.Emit(member, il); + statement.Emit(il); } } } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/ConstructorEmitter.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/ConstructorEmitter.cs index c060b604f7..37ab582ba4 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/ConstructorEmitter.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/ConstructorEmitter.cs @@ -88,7 +88,7 @@ public virtual void Generate() return; } - CodeBuilder.Generate(this, builder.GetILGenerator()); + CodeBuilder.Generate(builder.GetILGenerator()); } } } \ No newline at end of file diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/MethodEmitter.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/MethodEmitter.cs index b508e96f35..442f985977 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/MethodEmitter.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/MethodEmitter.cs @@ -126,7 +126,14 @@ public virtual void EnsureValidCodeBlock() if (ImplementedByRuntime == false && CodeBuilder.IsEmpty) { CodeBuilder.AddStatement(new NopStatement()); - CodeBuilder.AddStatement(new ReturnStatement()); + if (ReturnType == typeof(void)) + { + CodeBuilder.AddStatement(new ReturnStatement()); + } + else + { + CodeBuilder.AddStatement(new ReturnStatement(new DefaultValueExpression(ReturnType))); + } } } @@ -137,7 +144,7 @@ public virtual void Generate() return; } - codeBuilder.Generate(this, builder.GetILGenerator()); + codeBuilder.Generate(builder.GetILGenerator()); } private void DefineParameters(ParameterInfo[] parameters) diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignArgumentStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignArgumentStatement.cs index da70507096..5c4b2a70f8 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignArgumentStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignArgumentStatement.cs @@ -27,10 +27,10 @@ public AssignArgumentStatement(ArgumentReference argument, IExpression expressio this.expression = expression; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(argument, gen); - expression.Emit(member, gen); + expression.Emit(gen); } } } \ No newline at end of file diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignArrayStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignArrayStatement.cs index f8f2923699..b8ea4d599f 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignArrayStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignArrayStatement.cs @@ -29,13 +29,13 @@ public AssignArrayStatement(Reference targetArray, int targetPosition, IExpressi this.value = value; } - public void Emit(IMemberEmitter member, ILGenerator il) + public void Emit(ILGenerator il) { ArgumentsUtil.EmitLoadOwnerAndReference(targetArray, il); il.Emit(OpCodes.Ldc_I4, targetPosition); - value.Emit(member, il); + value.Emit(il); il.Emit(OpCodes.Stelem_Ref); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignStatement.cs index 1a94bbe1c4..4d33b78ac9 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/AssignStatement.cs @@ -27,10 +27,10 @@ public AssignStatement(Reference target, IExpression expression) this.expression = expression; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(target.OwnerReference, gen); - expression.Emit(member, gen); + expression.Emit(gen); target.StoreReference(gen); } } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/BindDelegateExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/BindDelegateExpression.cs index c2b6b5e571..c803eff247 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/BindDelegateExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/BindDelegateExpression.cs @@ -41,9 +41,9 @@ public BindDelegateExpression(Type @delegate, IExpression owner, MethodInfo meth this.owner = owner; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { - owner.Emit(member, gen); + owner.Emit(gen); gen.Emit(OpCodes.Dup); if (methodToBindTo.IsFinal) { diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/BlockStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/BlockStatement.cs index fe1d3f0057..c3526eddf6 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/BlockStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/BlockStatement.cs @@ -26,11 +26,11 @@ public void AddStatement(IStatement statement) statements.Add(statement); } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { foreach (var s in statements) { - s.Emit(member, gen); + s.Emit(gen); } } } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConstructorInvocationStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConstructorInvocationStatement.cs index aa7d56ac5c..be9cfe62e4 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConstructorInvocationStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConstructorInvocationStatement.cs @@ -43,13 +43,13 @@ public ConstructorInvocationStatement(ConstructorInfo method, params IExpression this.args = args; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.Emit(OpCodes.Ldarg_0); foreach (var exp in args) { - exp.Emit(member, gen); + exp.Emit(gen); } gen.Emit(OpCodes.Call, cmethod); diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConvertExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConvertExpression.cs index e70f78ae72..5e90d3930e 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConvertExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ConvertExpression.cs @@ -36,9 +36,9 @@ public ConvertExpression(Type targetType, Type fromType, IExpression right) this.right = right; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { - right.Emit(member, gen); + right.Emit(gen); if (fromType == target) { diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/DefaultValueExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/DefaultValueExpression.cs index e375ac3b01..c4668cf208 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/DefaultValueExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/DefaultValueExpression.cs @@ -27,7 +27,7 @@ public DefaultValueExpression(Type type) this.type = type; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { // TODO: check if this can be simplified by using more of OpCodeUtil and other existing types if (IsPrimitiveOrClass(type)) diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/EndExceptionBlockStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/EndExceptionBlockStatement.cs index a53614669b..f8b9339c83 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/EndExceptionBlockStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/EndExceptionBlockStatement.cs @@ -18,7 +18,7 @@ namespace Castle.DynamicProxy.Generators.Emitters.SimpleAST internal class EndExceptionBlockStatement : IStatement { - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.EndExceptionBlock(); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/FinallyStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/FinallyStatement.cs index a2f630299e..ff2ba63aa5 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/FinallyStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/FinallyStatement.cs @@ -18,7 +18,7 @@ namespace Castle.DynamicProxy.Generators.Emitters.SimpleAST internal class FinallyStatement : IStatement { - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.BeginFinallyBlock(); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/IExpressionOrStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/IExpressionOrStatement.cs index 4ce3602b13..fb5810173f 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/IExpressionOrStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/IExpressionOrStatement.cs @@ -18,6 +18,6 @@ namespace Castle.DynamicProxy.Generators.Emitters.SimpleAST internal interface IExpressionOrStatement { - void Emit(IMemberEmitter member, ILGenerator gen); + void Emit(ILGenerator gen); } } \ No newline at end of file diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/IfNullExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/IfNullExpression.cs index 23f0f1f758..333a732ac2 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/IfNullExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/IfNullExpression.cs @@ -38,7 +38,7 @@ public IfNullExpression(IExpression expression, IExpressionOrStatement ifNull, I this.ifNotNull = ifNotNull; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { if (reference != null) { @@ -46,16 +46,16 @@ public void Emit(IMemberEmitter member, ILGenerator gen) } else if (expression != null) { - expression.Emit(member, gen); + expression.Emit(gen); } var notNull = gen.DefineLabel(); gen.Emit(OpCodes.Brtrue_S, notNull); - ifNull.Emit(member, gen); + ifNull.Emit(gen); gen.MarkLabel(notNull); if (ifNotNull != null) // yeah, I know that reads funny :) { - ifNotNull.Emit(member, gen); + ifNotNull.Emit(gen); } } } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LiteralIntExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LiteralIntExpression.cs index a9a0affde9..3e07dd435c 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LiteralIntExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LiteralIntExpression.cs @@ -25,7 +25,7 @@ public LiteralIntExpression(int value) this.value = value; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { switch (value) { diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LoadArrayElementExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LoadArrayElementExpression.cs index 4dc7394dd2..eaf74fc075 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LoadArrayElementExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LoadArrayElementExpression.cs @@ -35,7 +35,7 @@ public LoadArrayElementExpression(ConstReference index, Reference arrayReference this.returnType = returnType; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(arrayReference, gen); ArgumentsUtil.EmitLoadOwnerAndReference(index, gen); diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LoadRefArrayElementExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LoadRefArrayElementExpression.cs index e7cfd912c4..7e9f6b619b 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LoadRefArrayElementExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/LoadRefArrayElementExpression.cs @@ -32,7 +32,7 @@ public LoadRefArrayElementExpression(ConstReference index, Reference arrayRefere this.arrayReference = arrayReference; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(arrayReference, gen); ArgumentsUtil.EmitLoadOwnerAndReference(index, gen); diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/MethodInvocationExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/MethodInvocationExpression.cs index 02d4526964..4261758eea 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/MethodInvocationExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/MethodInvocationExpression.cs @@ -47,13 +47,13 @@ public MethodInvocationExpression(Reference owner, MethodInfo method, params IEx public bool VirtualCall { get; set; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(owner, gen); foreach (var exp in args) { - exp.Emit(member, gen); + exp.Emit(gen); } if (VirtualCall) diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/MethodTokenExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/MethodTokenExpression.cs index 5ba78705e3..cc70b095a2 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/MethodTokenExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/MethodTokenExpression.cs @@ -30,7 +30,7 @@ public MethodTokenExpression(MethodInfo method) Debug.Assert(method.DeclaringType != null); // DynamicProxy isn't using global methods nor `DynamicMethod` } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.Emit(OpCodes.Ldtoken, method); gen.Emit(OpCodes.Ldtoken, method.DeclaringType); diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewArrayExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewArrayExpression.cs index 73c8ad3386..e6a2524c9f 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewArrayExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewArrayExpression.cs @@ -28,7 +28,7 @@ public NewArrayExpression(int size, Type arrayType) this.arrayType = arrayType; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.Emit(OpCodes.Ldc_I4, size); gen.Emit(OpCodes.Newarr, arrayType); diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewInstanceExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewInstanceExpression.cs index 5919b4eeb7..d5abeff471 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewInstanceExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NewInstanceExpression.cs @@ -35,13 +35,13 @@ public NewInstanceExpression(Type target) arguments = null; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { if (arguments != null) { foreach (var exp in arguments) { - exp.Emit(member, gen); + exp.Emit(gen); } } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NopStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NopStatement.cs index f937c01cf5..2c148a547e 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NopStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NopStatement.cs @@ -18,7 +18,7 @@ namespace Castle.DynamicProxy.Generators.Emitters.SimpleAST internal class NopStatement : IStatement { - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.Emit(OpCodes.Nop); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NullCoalescingOperatorExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NullCoalescingOperatorExpression.cs index 2a20b3190d..7c492a6ae8 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NullCoalescingOperatorExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NullCoalescingOperatorExpression.cs @@ -38,14 +38,14 @@ public NullCoalescingOperatorExpression(IExpression expression, IExpression @def this.@default = @default; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { - expression.Emit(member, gen); + expression.Emit(gen); gen.Emit(OpCodes.Dup); var label = gen.DefineLabel(); gen.Emit(OpCodes.Brtrue_S, label); gen.Emit(OpCodes.Pop); - @default.Emit(member, gen); + @default.Emit(gen); gen.MarkLabel(label); } } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NullExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NullExpression.cs index b7298eeb8e..cdf04957c5 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NullExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/NullExpression.cs @@ -24,7 +24,7 @@ protected NullExpression() { } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.Emit(OpCodes.Ldnull); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/Reference.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/Reference.cs index fb090aa7ee..6064317125 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/Reference.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/Reference.cs @@ -45,7 +45,7 @@ public virtual void Generate(ILGenerator gen) { } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { ArgumentsUtil.EmitLoadOwnerAndReference(this, gen); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ReferencesToObjectArrayExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ReferencesToObjectArrayExpression.cs index e20228fd74..dea87ef9c7 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ReferencesToObjectArrayExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ReferencesToObjectArrayExpression.cs @@ -27,7 +27,7 @@ public ReferencesToObjectArrayExpression(params TypeReference[] args) this.args = args; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { var local = gen.DeclareLocal(typeof(object[])); diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ReturnStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ReturnStatement.cs index e3c97bcdd9..35bd01daf2 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ReturnStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ReturnStatement.cs @@ -35,7 +35,7 @@ public ReturnStatement(IExpression expression) this.expression = expression; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { if (reference != null) { @@ -43,14 +43,7 @@ public void Emit(IMemberEmitter member, ILGenerator gen) } else if (expression != null) { - expression.Emit(member, gen); - } - else - { - if (member.ReturnType != typeof(void)) - { - OpCodeUtil.EmitLoadOpCodeForDefaultValueOfType(gen, member.ReturnType); - } + expression.Emit(gen); } gen.Emit(OpCodes.Ret); diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ThrowStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ThrowStatement.cs index 087b013177..a4c5a9e7a2 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ThrowStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/ThrowStatement.cs @@ -29,14 +29,14 @@ public ThrowStatement(Type exceptionType, string errorMessage) this.errorMessage = errorMessage; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { var ci = exceptionType.GetConstructor(new[] { typeof(string) }); var constRef = new ConstReference(errorMessage); var creationStmt = new NewInstanceExpression(ci, constRef); - creationStmt.Emit(member, gen); + creationStmt.Emit(gen); gen.Emit(OpCodes.Throw); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/TryStatement.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/TryStatement.cs index 3f76651ffd..69eb9bd48e 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/TryStatement.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/TryStatement.cs @@ -18,7 +18,7 @@ namespace Castle.DynamicProxy.Generators.Emitters.SimpleAST internal class TryStatement : IStatement { - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.BeginExceptionBlock(); } diff --git a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/TypeTokenExpression.cs b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/TypeTokenExpression.cs index 6cf3e0c78e..2a390c286c 100644 --- a/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/TypeTokenExpression.cs +++ b/src/Castle.Core/DynamicProxy/Generators/Emitters/SimpleAST/TypeTokenExpression.cs @@ -28,7 +28,7 @@ public TypeTokenExpression(Type type) this.type = type; } - public void Emit(IMemberEmitter member, ILGenerator gen) + public void Emit(ILGenerator gen) { gen.Emit(OpCodes.Ldtoken, type); gen.Emit(OpCodes.Call, TypeMethods.GetTypeFromHandle);