Browse Source

Allow changes to ILVariable.Type as long as StackType stays the same.

pull/728/head
Siegfried Pammer 9 years ago
parent
commit
7aa1d46178
  1. 17
      ICSharpCode.Decompiler/IL/ILVariable.cs

17
ICSharpCode.Decompiler/IL/ILVariable.cs

@ -49,9 +49,20 @@ namespace ICSharpCode.Decompiler.IL
public class ILVariable public class ILVariable
{ {
public readonly VariableKind Kind; public readonly VariableKind Kind;
public readonly IType Type;
public readonly StackType StackType; public readonly StackType StackType;
IType type;
public IType Type {
get {
return type;
}
internal set {
if (value.GetStackType() != StackType)
throw new ArgumentException($"Expected stack-type: {StackType} may not be changed. Found: {value.GetStackType()}");
type = value;
}
}
/// <summary> /// <summary>
/// The index of the local variable or parameter (depending on Kind) /// The index of the local variable or parameter (depending on Kind)
/// </summary> /// </summary>
@ -145,7 +156,7 @@ namespace ICSharpCode.Decompiler.IL
if (type == null) if (type == null)
throw new ArgumentNullException("type"); throw new ArgumentNullException("type");
this.Kind = kind; this.Kind = kind;
this.Type = type; this.type = type;
this.StackType = type.GetStackType(); this.StackType = type.GetStackType();
this.Index = index; this.Index = index;
if (kind == VariableKind.Parameter) if (kind == VariableKind.Parameter)
@ -155,7 +166,7 @@ namespace ICSharpCode.Decompiler.IL
public ILVariable(VariableKind kind, IType type, StackType stackType, int index) public ILVariable(VariableKind kind, IType type, StackType stackType, int index)
{ {
this.Kind = kind; this.Kind = kind;
this.Type = type; this.type = type;
this.StackType = stackType; this.StackType = stackType;
this.Index = index; this.Index = index;
if (kind == VariableKind.Parameter) if (kind == VariableKind.Parameter)

Loading…
Cancel
Save