System.Xml.Xsl.IlGen.IteratorDescriptor.EnsureNoCache C# (CSharp) Method

EnsureNoCache() public method

If the iterator has been fully cached, then iterate the values one-by-one.
public EnsureNoCache ( ) : void
return void
        public void EnsureNoCache() {
            if (this.storage.IsCached) {
                if (!HasLabelNext) {
                    // If no Next label, this must be a singleton cache
                    EnsureStack();
                    this.helper.LoadInteger(0);
                    this.helper.CallCacheItem(this.storage.ItemStorageType);

                    this.storage = StorageDescriptor.Stack(this.storage.ItemStorageType, false);
                }
                else {
                    // int idx;
                    LocalBuilder locIdx = this.helper.DeclareLocal("$$$idx", typeof(int));
                    Label lblNext;

                    // Make sure cache is not on the stack
                    EnsureNoStack("$$$cache");

                    // idx = -1;
                    this.helper.LoadInteger(-1);
                    this.helper.Emit(OpCodes.Stloc, locIdx);

                    // LabelNext:
                    lblNext = this.helper.DefineLabel();
                    this.helper.MarkLabel(lblNext);

                    // idx++;
                    this.helper.Emit(OpCodes.Ldloc, locIdx);
                    this.helper.LoadInteger(1);
                    this.helper.Emit(OpCodes.Add);
                    this.helper.Emit(OpCodes.Stloc, locIdx);

                    // if (idx >= cache.Count) goto LabelNextCtxt;
                    this.helper.Emit(OpCodes.Ldloc, locIdx);
                    CacheCount();
                    this.helper.Emit(OpCodes.Bge, GetLabelNext());

                    // item = cache[idx];
                    PushValue();
                    this.helper.Emit(OpCodes.Ldloc, locIdx);
                    this.helper.CallCacheItem(this.storage.ItemStorageType);

                    SetIterator(lblNext, StorageDescriptor.Stack(this.storage.ItemStorageType, false));
                }
            }
        }