本文整理汇总了C#中CodeGen.PushTargets方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.PushTargets方法的具体用法?C# CodeGen.PushTargets怎么用?C# CodeGen.PushTargets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.PushTargets方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit(CodeGen cg)
{
if (_statement == null) {
throw new InvalidOperationException("Incomplete LabelStatement");
}
Label label = cg.DefineLabel();
Label label2 = cg.DefineLabel();
cg.MarkLabel(label2);
cg.PushTargets(label, label2, this);
_statement.Emit(cg);
cg.MarkLabel(label);
cg.PopTargets();
}
示例2: Emit
public override void Emit(CodeGen cg) {
Label startTarget = cg.DefineLabel();
Label breakTarget = cg.DefineLabel();
Label continueTarget = cg.DefineLabel();
cg.MarkLabel(startTarget);
cg.PushTargets(breakTarget, continueTarget, this);
_body.Emit(cg);
cg.MarkLabel(continueTarget);
// TODO: Check if we need to emit position somewhere else also.
//cg.EmitPosition(Start, _header);
_test.Emit(cg);
cg.Emit(OpCodes.Brtrue, startTarget);
cg.PopTargets();
cg.MarkLabel(breakTarget);
}
示例3: Emit
internal override void Emit(CodeGen cg)
{
Label eol = cg.DefineLabel();
Label breakTarget = cg.DefineLabel();
Label continueTarget = cg.DefineLabel();
cg.EmitPosition(Start, header);
list.Emit(cg);
cg.EmitCall(typeof(Ops), "GetEnumeratorForIteration");
Slot iter;
if (cg.IsGenerator()) {
iter = cg.Names.GetTempSlot("iter", typeof(IEnumerator));
} else {
iter = cg.GetLocalTmp(typeof(IEnumerator));
}
iter.EmitSet(cg);
cg.MarkLabel(continueTarget);
iter.EmitGet(cg);
cg.EmitCall(typeof(IEnumerator), "MoveNext");
cg.Emit(OpCodes.Brfalse, eol);
cg.PushTargets(breakTarget, continueTarget);
iter.EmitGet(cg);
cg.EmitCall(typeof(IEnumerator).GetProperty("Current").GetGetMethod());
lhs.EmitSet(cg);
body.Emit(cg);
cg.Emit(OpCodes.Br, continueTarget);
cg.PopTargets();
cg.MarkLabel(eol);
if (elseStmt != null) {
elseStmt.Emit(cg);
}
cg.MarkLabel(breakTarget);
if (!cg.IsGenerator()) {
cg.FreeLocalTmp(iter);
}
}
示例4: Emit
public override void Emit(CodeGen cg)
{
Nullable<Label> firstTime = null;
Label eol = cg.DefineLabel();
Label breakTarget = cg.DefineLabel();
Label continueTarget = cg.DefineLabel();
if (_increment != null) {
firstTime = cg.DefineLabel();
cg.Emit(OpCodes.Br, firstTime.Value);
}
if (_header.IsValid) {
//cg.EmitPosition(Start, _header);
}
cg.MarkLabel(continueTarget);
if (_increment != null) {
_increment.EmitAs(cg, typeof(void));
cg.MarkLabel(firstTime.Value);
}
if (_test != null) {
_test.Emit(cg);
cg.Emit(OpCodes.Brfalse, eol);
}
cg.PushTargets(breakTarget, continueTarget, this);
_body.Emit(cg);
cg.Emit(OpCodes.Br, continueTarget);
cg.PopTargets();
cg.MarkLabel(eol);
if (_else != null) {
_else.Emit(cg);
}
cg.MarkLabel(breakTarget);
}
示例5: Emit
public override void Emit(CodeGen cg)
{
//cg.EmitPosition(Start, _header);
Label breakTarget = cg.DefineLabel();
Label defaultTarget = breakTarget;
Label[] labels = new Label[_cases.Count];
// Create all labels
for (int i = 0; i < _cases.Count; i++) {
labels[i] = cg.DefineLabel();
// Default case.
if (_cases[i].IsDefault) {
// Set the default target
defaultTarget = labels[i];
}
}
// Emit the test value
_testValue.Emit(cg);
// Check if jmp table can be emitted
if (!TryEmitJumpTable(cg, labels, defaultTarget)) {
// There might be scenario(s) where the jmp table is not emitted
// Emit the switch as conditional branches then
EmitConditionalBranches(cg, labels);
}
// If "default" present, execute default code, else exit the switch
cg.Emit(OpCodes.Br, defaultTarget);
cg.PushTargets(breakTarget, cg.BlockContinueLabel, this);
// Emit the bodies
for (int i = 0; i < _cases.Count; i++) {
// First put the corresponding labels
cg.MarkLabel(labels[i]);
// And then emit the Body!!
_cases[i].Body.Emit(cg);
}
cg.PopTargets();
cg.MarkLabel(breakTarget);
}