From 3fc12209b1b1c1ce01ffdd526c6fa86a44c96199 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 18 Jun 2016 08:36:32 +0900 Subject: [PATCH] Add IsDirty tracking to ILInstruction --- .../IL/Instructions/ILInstruction.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs index 191feaffe..5ec4a60ab 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs @@ -105,6 +105,20 @@ namespace ICSharpCode.Decompiler.IL return a; } + public bool IsDirty { get; private set; } + + protected void MakeDirty() + { + for (ILInstruction inst = this; inst != null && !inst.IsDirty; inst = inst.parent) + inst.IsDirty = true; + } + + public void ResetDirty() + { + foreach (ILInstruction inst in Descendants) + inst.IsDirty = false; + } + const InstructionFlags invalidFlags = (InstructionFlags)(-1); InstructionFlags flags = invalidFlags; @@ -499,6 +513,7 @@ namespace ICSharpCode.Decompiler.IL newValue.ChildIndex = index; } InvalidateFlags(); + MakeDirty(); if (refCount > 0) { // The new value may be a subtree of the old value. // We first call AddRef(), then ReleaseRef() to prevent the subtree @@ -537,6 +552,7 @@ namespace ICSharpCode.Decompiler.IL protected internal virtual void InstructionCollectionUpdateComplete() { InvalidateFlags(); + MakeDirty(); } ///