public void Dispose() { // Write the cache back out to backing storage foreach (var(name, local) in _cache.OrderByDescending(a => SegmentIndex(a.Key))) { if (_mutated.Contains(name)) { var skip = _emitter.DefineLabel(); var dirty = _cacheDirty[name]; _emitter.LoadLocal(dirty); _emitter.BranchIfFalse(skip); _emitter.LoadLocal(local.Local); _emitter.EmitCoerce(local.Type, StackType.YololValue); EmitStoreValue(name); _emitter.MarkLabel(skip); } local.Local.Dispose(); } // Dispose the locals foreach (var local in _cacheDirty) { local.Value.Dispose(); } }
private void IdentityConversionTest <T>() { var type = typeof(T).ToStackType(); var emitter = Emit <Func <T, T> > .NewDynamicMethod(strictBranchVerification : true); var optim = new OptimisingEmitter <Func <T, T> >(emitter); optim.EmitCoerce(type, type); Assert.AreEqual(0, optim.InstructionCount); }