当前位置: 首页>>代码示例>>C#>>正文


C# IILGen.Mark方法代码示例

本文整理汇总了C#中IILGen.Mark方法的典型用法代码示例。如果您正苦于以下问题:C# IILGen.Mark方法的具体用法?C# IILGen.Mark怎么用?C# IILGen.Mark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IILGen的用法示例。


在下文中一共展示了IILGen.Mark方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReplayTo

 public void ReplayTo(IILGen target)
 {
     target.Mark(((ILLabel)_label).Label);
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:4,代码来源:CachingILGen.cs

示例2: GenerateSave

 public void GenerateSave(IILGen ilGenerator, Action<IILGen> pushWriter, Action<IILGen> pushCtx,
     Action<IILGen> pushValue, Type saveType)
 {
     var notnull = ilGenerator.DefineLabel();
     var completeFinish = ilGenerator.DefineLabel();
     var notDictionary = ilGenerator.DefineLabel();
     var keyType = saveType.GetGenericArguments()[0];
     var valueType = saveType.GetGenericArguments()[1];
     var typeAsIDictionary = typeof(IDictionary<,>).MakeGenericType(keyType, valueType);
     var typeAsICollection = typeAsIDictionary.GetInterface("ICollection`1");
     var localDict = ilGenerator.DeclareLocal(typeAsIDictionary);
     ilGenerator
         .Do(pushValue)
         .Castclass(typeAsIDictionary)
         .Stloc(localDict)
         .Ldloc(localDict)
         .Brtrue(notnull)
         .Do(pushWriter)
         .Callvirt(() => default(AbstractBufferedWriter).WriteByteZero())
         .Br(completeFinish)
         .Mark(notnull)
         .Do(pushWriter)
         .Ldloc(localDict)
         .Callvirt(typeAsICollection.GetProperty("Count").GetGetMethod())
         .LdcI4(1)
         .Add()
         .Callvirt(() => default(AbstractBufferedWriter).WriteVUInt32(0));
     {
         var typeAsDictionary = typeof(Dictionary<,>).MakeGenericType(keyType, valueType);
         var getEnumeratorMethod = typeAsDictionary.GetMethods()
                 .Single(m => m.Name == "GetEnumerator" && m.ReturnType.IsValueType && m.GetParameters().Length == 0);
         var typeAsIEnumerator = getEnumeratorMethod.ReturnType;
         var currentGetter = typeAsIEnumerator.GetProperty("Current").GetGetMethod();
         var typeKeyValuePair = currentGetter.ReturnType;
         var localEnumerator = ilGenerator.DeclareLocal(typeAsIEnumerator);
         var localPair = ilGenerator.DeclareLocal(typeKeyValuePair);
         var finish = ilGenerator.DefineLabel();
         var next = ilGenerator.DefineLabel();
         ilGenerator
             .Ldloc(localDict)
             .Castclass(typeAsDictionary)
             .Brfalse(notDictionary)
             .Ldloc(localDict)
             .Castclass(typeAsDictionary)
             .Callvirt(getEnumeratorMethod)
             .Stloc(localEnumerator)
             .Try()
             .Mark(next)
             .Ldloca(localEnumerator)
             .Call(typeAsIEnumerator.GetMethod("MoveNext"))
             .Brfalse(finish)
             .Ldloca(localEnumerator)
             .Call(currentGetter)
             .Stloc(localPair);
         _keyDescriptor.GenerateSaveEx(ilGenerator, pushWriter, pushCtx,
             il => il.Ldloca(localPair).Call(typeKeyValuePair.GetProperty("Key").GetGetMethod()), keyType);
         _valueDescriptor.GenerateSaveEx(ilGenerator, pushWriter, pushCtx,
             il => il.Ldloca(localPair).Call(typeKeyValuePair.GetProperty("Value").GetGetMethod()), valueType);
         ilGenerator
             .Br(next)
             .Mark(finish)
             .Finally()
             .Ldloca(localEnumerator)
             .Constrained(typeAsIEnumerator)
             .Callvirt(() => default(IDisposable).Dispose())
             .EndTry()
             .Br(completeFinish);
     }
     {
         var getEnumeratorMethod = typeAsIDictionary.GetInterface("IEnumerable`1").GetMethod("GetEnumerator");
         var typeAsIEnumerator = getEnumeratorMethod.ReturnType;
         var currentGetter = typeAsIEnumerator.GetProperty("Current").GetGetMethod();
         var typeKeyValuePair = currentGetter.ReturnType;
         var localEnumerator = ilGenerator.DeclareLocal(typeAsIEnumerator);
         var localPair = ilGenerator.DeclareLocal(typeKeyValuePair);
         var finish = ilGenerator.DefineLabel();
         var next = ilGenerator.DefineLabel();
         ilGenerator
             .Mark(notDictionary)
             .Ldloc(localDict)
             .Callvirt(getEnumeratorMethod)
             .Stloc(localEnumerator)
             .Try()
             .Mark(next)
             .Ldloc(localEnumerator)
             .Callvirt(() => default(IEnumerator).MoveNext())
             .Brfalse(finish)
             .Ldloc(localEnumerator)
             .Callvirt(currentGetter)
             .Stloc(localPair);
         _keyDescriptor.GenerateSaveEx(ilGenerator, pushWriter, pushCtx, il => il.Ldloca(localPair).Call(typeKeyValuePair.GetProperty("Key").GetGetMethod()), keyType);
         _valueDescriptor.GenerateSaveEx(ilGenerator, pushWriter, pushCtx, il => il.Ldloca(localPair).Call(typeKeyValuePair.GetProperty("Value").GetGetMethod()), valueType);
         ilGenerator
             .Br(next)
             .Mark(finish)
             .Finally()
             .Ldloc(localEnumerator)
             .Callvirt(() => default(IDisposable).Dispose())
             .EndTry()
             .Mark(completeFinish);
//.........这里部分代码省略.........
开发者ID:Bobris,项目名称:BTDB,代码行数:101,代码来源:DictionaryTypeDescriptor.cs


注:本文中的IILGen.Mark方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。