Skip to content

Commit

Permalink
Use appropriate type for helper variables introduced for named argume…
Browse files Browse the repository at this point in the history
…nts.
  • Loading branch information
dgrunwald committed Mar 9, 2019
1 parent b0309ca commit 40b6f0c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,18 @@ public void RunTransforms(IEnumerable<IILTransform> transforms, ILTransformConte

public ILVariable RegisterVariable(VariableKind kind, IType type, string name = null)
{
var variable = new ILVariable(kind, type);
return RegisterVariable(kind, type, type.GetStackType(), name);
}

public ILVariable RegisterVariable(VariableKind kind, StackType stackType, string name = null)
{
var type = Method.Compilation.FindType(stackType.ToKnownTypeCode());
return RegisterVariable(kind, type, stackType, name);
}

ILVariable RegisterVariable(VariableKind kind, IType type, StackType stackType, string name = null)
{
var variable = new ILVariable(kind, type, stackType);
if (string.IsNullOrWhiteSpace(name)) {
name = "I_" + (helperVariableCount++);
variable.HasGeneratedName = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal static void IntroduceNamedArgument(ILInstruction arg, ILTransformContex
{
var call = (CallInstruction)arg.Parent;
Debug.Assert(context.Function == call.Ancestors.OfType<ILFunction>().First());
var v = context.Function.RegisterVariable(VariableKind.NamedArgument, arg.InferType(context.TypeSystem));
var v = context.Function.RegisterVariable(VariableKind.NamedArgument, arg.ResultType);
context.Step($"Introduce named argument '{v.Name}'", arg);
if (!(call.Parent is Block namedArgBlock) || namedArgBlock.Kind != BlockKind.CallWithNamedArgs) {
// create namedArgBlock:
Expand Down

0 comments on commit 40b6f0c

Please sign in to comment.