本文整理汇总了C#中System.Reflection.Emit.Label类的典型用法代码示例。如果您正苦于以下问题:C# Label类的具体用法?C# Label怎么用?C# Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Label类属于System.Reflection.Emit命名空间,在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureLabel
internal Label EnsureLabel(CodeGen cg) {
if (!_initialized) {
_label = cg.DefineLabel();
_initialized = true;
}
return _label;
}
示例2: RecordLabels
public override void RecordLabels(ILGenerator gen)
{
base.RecordLabels(gen);
returnLabel = gen.DefineLabel();
returnLabels.Add(returnLabel);
gosubIndex = returnLabels.Count - 1;
}
示例3: AppendGuard
public override void AppendGuard(ILGenerator generator,
MethodInfo method, Label done)
{
generator.Emit(OpCodes.Ldloc_0);
generator.Emit(OpCodes.Call, method);
generator.Emit(OpCodes.Brfalse, done);
}
示例4: ForState
internal ForState(LocalBuilder indexVar, Label beginLabel, Label testLabel, object end)
{
this.indexVar = indexVar;
this.beginLabel = beginLabel;
this.testLabel = testLabel;
this.end = end;
}
示例5: ILForLoop
public ILForLoop(Label conditionLabel, Label startLoopLogicLabel, LocalBuilder counter, LocalBuilder max)
{
ConditionLabel = conditionLabel;
Counter = counter;
Max = max;
StartLoopLogicLabel = startLoopLogicLabel;
}
示例6: WhileInfo
public WhileInfo(string condition, Label beginLabel, Label comparasionLabel) :
this()
{
Condition = condition;
BeginLabel = beginLabel;
ComparasionLabel = comparasionLabel;
}
示例7: OnDefineLabel
protected override Label OnDefineLabel()
{
var result = new Label();
foreach (var ilEmitter in emittersField)
result = ilEmitter.DefineLabel();
return result;
}
示例8: GenerateForBranch
public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
{
Label endLabel = gen.DefineLabel ();
exp1.Generate (gen);
if (exp1 is CodeConditionExpression) {
if (branchCase)
((CodeConditionExpression)exp1).GenerateForBranch (gen, endLabel, false);
else
((CodeConditionExpression)exp1).GenerateForBranch (gen, label, false);
}
else {
exp1.Generate (gen);
if (branchCase)
gen.Emit (OpCodes.Brfalse, endLabel);
else
gen.Emit (OpCodes.Brfalse, label);
}
if (exp2 is CodeConditionExpression) {
if (branchCase)
((CodeConditionExpression)exp2).GenerateForBranch (gen, label, true);
else
((CodeConditionExpression)exp2).GenerateForBranch (gen, label, false);
}
else {
exp2.Generate (gen);
if (branchCase)
gen.Emit (OpCodes.Brtrue, label);
else
gen.Emit (OpCodes.Brfalse, label);
}
gen.MarkLabel(endLabel);
}
示例9: GenerateWriterMethod
public void GenerateWriterMethod(Type obtype, CodeGenContext ctx, ILGenerator il)
{
var getTypeIDMethodInfo = typeof(Serializer).GetMethod("GetTypeID", BindingFlags.NonPublic | BindingFlags.Instance, null,
new Type[] { typeof(object) }, null);
var map = ctx.TypeMap;
// arg0: Serializer, arg1: Stream, arg2: object
var idLocal = il.DeclareLocal(typeof(ushort));
// get TypeID from object's Type
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldarg_2);
il.Emit(OpCodes.Call, getTypeIDMethodInfo);
il.Emit(OpCodes.Stloc_S, idLocal);
// write typeID
il.Emit(OpCodes.Ldarg_1);
il.Emit(OpCodes.Ldloc_S, idLocal);
il.Emit(OpCodes.Call, ctx.GetWriterMethodInfo(typeof(ushort)));
// +1 for 0 (null)
var jumpTable = new Label[map.Count + 1];
jumpTable[0] = il.DefineLabel();
foreach (var kvp in map)
jumpTable[kvp.Value.TypeID] = il.DefineLabel();
il.Emit(OpCodes.Ldloc_S, idLocal);
il.Emit(OpCodes.Switch, jumpTable);
il.Emit(OpCodes.Newobj, Helpers.ExceptionCtorInfo);
il.Emit(OpCodes.Throw);
/* null case */
il.MarkLabel(jumpTable[0]);
il.Emit(OpCodes.Ret);
/* cases for types */
foreach (var kvp in map)
{
var type = kvp.Key;
var data = kvp.Value;
il.MarkLabel(jumpTable[data.TypeID]);
if (data.NeedsInstanceParameter)
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldarg_1);
il.Emit(OpCodes.Ldarg_2);
il.Emit(type.IsValueType ? OpCodes.Unbox_Any : OpCodes.Castclass, type);
il.Emit(OpCodes.Tailcall);
il.Emit(OpCodes.Call, data.WriterMethodInfo);
il.Emit(OpCodes.Ret);
}
}
示例10: Expand
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement)
{
foreach (var rule in KeyRule.Expand(ctx, Expr.GetMember(expression, "Key"), nextStatement))
yield return rule;
foreach (var rule in ValueRule.Expand(ctx, Expr.GetMember(expression, "Value"), nextStatement))
yield return rule;
}
示例11: ExceptionalReturn
public ExceptionalReturn(Label label, LocalBuilder local)
{
if (local == null)
throw new ArgumentNullException("local");
Label = label;
Local = local;
}
示例12: TestLabelEqualityOperators
public void TestLabelEqualityOperators()
{
Label lb1 = new Label();
Label lb2 = new Label();
Assert.True(lb1 == lb2);
Assert.False(lb1 != lb2);
}
示例13: GenerateForBranch
public virtual void GenerateForBranch(ILGenerator gen, Label label, bool jumpCase)
{
Generate (gen);
if (jumpCase)
gen.Emit (OpCodes.Brtrue, label);
else
gen.Emit (OpCodes.Brfalse, label);
}
示例14: EmitBranchFalse
public override void EmitBranchFalse(CodeGen cg, Label label) {
if (_valueIndex == _expressions.Count - 1) {
Emit(cg, _valueIndex);
_expressions[_valueIndex].EmitBranchFalse(cg, label);
} else {
base.EmitBranchFalse(cg, label);
}
}
示例15: Expand
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement)
{
yield return Expr.If(
Expr.NotEqual(Literal as NodeBase, expression),
Expr.Block(
Expr.JumpTo(nextStatement)
)
);
}