Browse Source

Fix some bugs that were just introduced while adding the ResolveResults.

pull/728/head
Daniel Grunwald 11 years ago
parent
commit
b8098e63ba
  1. 9
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

9
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -390,7 +390,11 @@ namespace ICSharpCode.Decompiler.CSharp
var parameterType = cecilMapper.GetType(parameterDefinition.ParameterType); var parameterType = cecilMapper.GetType(parameterDefinition.ParameterType);
arguments[i] = arguments[i].ConvertTo(parameterType, this); arguments[i] = arguments[i].ConvertTo(parameterType, this);
} }
if (inst.OpCode == OpCode.NewObj) {
rr = new ResolveResult(cecilMapper.GetType(inst.Method.DeclaringType)); rr = new ResolveResult(cecilMapper.GetType(inst.Method.DeclaringType));
} else {
rr = new ResolveResult(cecilMapper.GetType(inst.Method.ReturnType));
}
} }
var argumentExpressions = arguments.Skip(firstParamIndex).Select(arg => arg.Expression); var argumentExpressions = arguments.Skip(firstParamIndex).Select(arg => arg.Expression);
@ -412,13 +416,16 @@ namespace ICSharpCode.Decompiler.CSharp
// we can deference the managed reference by stripping away the 'ref' // we can deference the managed reference by stripping away the 'ref'
var result = target.UnwrapChild(((DirectionExpression)target.Expression).Expression); var result = target.UnwrapChild(((DirectionExpression)target.Expression).Expression);
result = result.ConvertTo(type, this); result = result.ConvertTo(type, this);
} result.Expression.AddAnnotation(inst); // add LdObj in addition to the existing ILInstruction annotation
return result;
} else {
// Cast pointer type if necessary: // Cast pointer type if necessary:
target = target.ConvertTo(new PointerType(type), this); target = target.ConvertTo(new PointerType(type), this);
return new UnaryOperatorExpression(UnaryOperatorType.Dereference, target.Expression) return new UnaryOperatorExpression(UnaryOperatorType.Dereference, target.Expression)
.WithILInstruction(inst) .WithILInstruction(inst)
.WithRR(new ResolveResult(type)); .WithRR(new ResolveResult(type));
} }
}
protected internal override ConvertedExpression VisitUnboxAny(UnboxAny inst) protected internal override ConvertedExpression VisitUnboxAny(UnboxAny inst)
{ {

Loading…
Cancel
Save