本文整理汇总了C#中Compiler.BranchIfLessOrEqual方法的典型用法代码示例。如果您正苦于以下问题:C# Compiler.BranchIfLessOrEqual方法的具体用法?C# Compiler.BranchIfLessOrEqual怎么用?C# Compiler.BranchIfLessOrEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compiler
的用法示例。
在下文中一共展示了Compiler.BranchIfLessOrEqual方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitReadArray
private void EmitReadArray(Compiler.CompilerContext ctx, Compiler.Local list, Compiler.Local oldArr,
Compiler.Local newArr, IProtoSerializer tail, MethodInfo add, Type listType)
{
Compiler.CodeLabel readPacked = packedWireType == WireType.None ? new Compiler.CodeLabel() : ctx.DefineLabel();
Compiler.CodeLabel @end = ctx.DefineLabel();
if (packedWireType != WireType.None)
{
ctx.LoadReaderWriter();
ctx.LoadValue(typeof(ProtoReader).GetProperty("WireType"));
ctx.LoadValue((int)WireType.String);
ctx.BranchIfEqual(readPacked, false);
}
using (Compiler.Local fieldNumber = new Compiler.Local(ctx, typeof(int)))
{
// int fieldNumber = source.FieldNumber;
ctx.LoadReaderWriter();
ctx.LoadValue(typeof (ProtoReader).GetProperty("FieldNumber"));
ctx.StoreValue(fieldNumber);
using (Compiler.Local readObject = new Compiler.Local(ctx, typeof (bool)))
using (Compiler.Local arrayKey = new Compiler.Local(ctx, typeof (int)))
{
// bool readObject = true;
ctx.LoadValue(true);
ctx.StoreValue(readObject);
// value = value ?? Array.CreateInstance(itemType, 0);
Compiler.CodeLabel @endCreateInstance = ctx.DefineLabel();
ctx.LoadValue(oldArr);
ctx.LoadNullRef();
ctx.TestEqual();
ctx.BranchIfFalse(@endCreateInstance, true);
ctx.LoadValue(itemType);
ctx.LoadValue(0);
ctx.EmitCall(typeof(Array).GetMethod("CreateInstance", new Type[] { typeof(Type), typeof(int) }));
ctx.StoreValue(oldArr);
ctx.MarkLabel(@endCreateInstance);
if (AsReference)
{
using (Compiler.Local objectKey = new Compiler.Local(ctx, typeof(int)))
{
//int objectKey = source.ReadInt32();
ctx.LoadReaderWriter();
ctx.EmitCall(typeof(ProtoReader).GetMethod("ReadInt32"));
ctx.StoreValue(objectKey);
Compiler.CodeLabel @ifNotThere = ctx.DefineLabel();
Compiler.CodeLabel @endIf = ctx.DefineLabel();
//if (objectKey > 0)
ctx.LoadValue(objectKey);
ctx.LoadValue(0);
ctx.BranchIfLessOrEqual(@ifNotThere, true);
// value = source.NetCache.GetKeyedObject(objectKey);
ctx.LoadReaderWriter();
ctx.LoadValue(typeof(ProtoReader).GetProperty("NetCache"));
ctx.LoadValue(objectKey);
ctx.EmitCall(typeof(NetObjectCache).GetMethod("GetKeyedObject"));
ctx.StoreValue(oldArr);
//readObject = false;
ctx.LoadValue(false);
ctx.StoreValue(readObject);
//}
ctx.Branch(@endIf, true);
//else
ctx.MarkLabel(@ifNotThere);
//bool dummy;
//arrayKey = source.NetCache.AddObjectKey(value, out dummy);
using (Compiler.Local dummy = new Compiler.Local(ctx, typeof(bool)))
{
ctx.LoadReaderWriter();
ctx.LoadValue(typeof(ProtoReader).GetProperty("NetCache"));
ctx.LoadValue(oldArr);
ctx.LoadAddress(dummy, typeof(bool));
ctx.EmitCall(typeof(NetObjectCache).GetMethod("AddObjectKey", new Type[] { typeof(object), typeof(bool).MakeByRefType() }));
ctx.StoreValue(arrayKey);
}
ctx.MarkLabel(@endIf);
}
}
else
{
using (Compiler.Local readValue = new Compiler.Local(ctx, typeof(int)))
{
ctx.LoadReaderWriter();
ctx.EmitCall(typeof(ProtoReader).GetMethod("ReadInt32"));
ctx.StoreValue(readValue);
//.........这里部分代码省略.........
示例2: EmitRead
//.........这里部分代码省略.........
ctx.MarkLabel(handlers[i]);
IProtoSerializer tail = tails[i];
Compiler.Local oldValIfNeeded = tail.RequiresOldValue ? locals[i] : null;
ctx.ReadNullCheckedTail(locals[i].Type, tail, oldValIfNeeded);
if (tail.ReturnsValue)
{
if (locals[i].Type.IsValueType)
{
ctx.StoreValue(locals[i]);
}
else
{
Compiler.CodeLabel hasValue = ctx.DefineLabel(), allDone = ctx.DefineLabel();
ctx.CopyValue();
ctx.BranchIfTrue(hasValue, true); // interpret null as "don't assign"
ctx.DiscardValue();
ctx.Branch(allDone, true);
ctx.MarkLabel(hasValue);
ctx.StoreValue(locals[i]);
ctx.MarkLabel(allDone);
}
}
ctx.Branch(@continue, false);
}
ctx.MarkLabel(notRecognised);
ctx.LoadReaderWriter();
ctx.EmitCall(typeof (ProtoReader).GetMethod("SkipField"));
ctx.MarkLabel(@continue);
// j < values.Length
ctx.LoadValue(j);
ctx.LoadValue(members.Length);
ctx.BranchIfGreaterOrEqual(@endWhileLoop, false);
//j++
ctx.LoadValue(j);
ctx.LoadValue(1);
ctx.Add();
ctx.StoreValue(j);
// source.ReadNextFieldHack() > 0
ctx.LoadReaderWriter();
ctx.EmitCall(typeof (ProtoReader).GetMethod("ReadNextFieldHack"));
ctx.LoadValue(0);
ctx.BranchIfLessOrEqual(@endWhileLoop, true);
// field = source.ReadFieldHeader();
ctx.LoadReaderWriter();
ctx.EmitCall(typeof (ProtoReader).GetMethod("ReadFieldHeader"));
ctx.StoreValue(fieldNumber);
ctx.Branch(processField, false);
ctx.MarkLabel(@endWhileLoop);
}
for (int i = 0; i < locals.Length; i++)
{
ctx.LoadValue(locals[i]);
}
ctx.EmitCtor(ctor);
ctx.StoreValue(objValue);
if (issueReferenceDirectives)
{
//source.NetCache.UpdateKeyedObject(tupleKey, oldTuple, result);
ctx.LoadReaderWriter();
ctx.LoadValue(typeof (ProtoReader).GetProperty("NetCache"));
ctx.LoadValue(tupleKey);
ctx.LoadValue(oldTuple);
ctx.LoadValue(objValue);
ctx.CastToObject(ExpectedType);
ctx.EmitCall(typeof (NetObjectCache).GetMethod("UpdateKeyedObject"));
}
if (forceIssueFakeHeader)
{
//source.ReadEndGroupFieldHeaderHack();
ctx.LoadReaderWriter();
ctx.EmitCall(typeof (ProtoReader).GetMethod("ReadEndGroupFieldHeaderHack"));
}
ctx.MarkLabel(@end);
ctx.LoadValue(objValue);
}
finally
{
for (int i = 0; i < locals.Length; i++)
{
if (locals[i] != null)
locals[i].Dispose(); // release for re-use
}
}
}
}