@ -4117,6 +4117,7 @@ namespace ICSharpCode.Decompiler.IL
base.CheckInvariant(phase);
Debug.Assert(target.ResultType == StackType.Ref || target.ResultType == StackType.I);
Debug.Assert(value.ResultType == type.GetStackType());
CheckTargetSlot();
}
@ -253,7 +253,8 @@
new OpCode("stobj", "Indirect store (store to ref/pointer)." + Environment.NewLine
+ "Evaluates to the value that was stored (when using type byte/short: evaluates to the truncated value, sign/zero extended back to I4 based on type.GetSign())",
CustomClassName("StObj"), CustomArguments(("target", new[] { "Ref", "I" }), ("value", new[] { "type.GetStackType()" })), HasTypeOperand, MemoryAccess, CustomWriteToButKeepOriginal,
SupportsVolatilePrefix, SupportsUnalignedPrefix, MayThrow, ResultType("type.GetStackType()")),
SupportsVolatilePrefix, SupportsUnalignedPrefix, MayThrow, ResultType("type.GetStackType()"),
CustomInvariant("CheckTargetSlot();")),
new OpCode("box", "Boxes a value.",
Unary, HasTypeOperand, MemoryAccess, MayThrow, ResultType("O")),
@ -68,5 +68,20 @@ namespace ICSharpCode.Decompiler.IL
return true;
/// <summary>
/// called as part of CheckInvariant()
/// </summary>
void CheckTargetSlot()
{
switch (this.Target.OpCode) {
case OpCode.LdElema:
case OpCode.LdFlda:
if (this.Target.HasDirectFlag(InstructionFlags.MayThrow)) {
Debug.Assert(SemanticHelper.IsPure(this.Value.Flags));
break;