本文整理汇总了C#中IronPython.Compiler.Ast.AstGenerator.TransformLoopBody方法的典型用法代码示例。如果您正苦于以下问题:C# AstGenerator.TransformLoopBody方法的具体用法?C# AstGenerator.TransformLoopBody怎么用?C# AstGenerator.TransformLoopBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronPython.Compiler.Ast.AstGenerator
的用法示例。
在下文中一共展示了AstGenerator.TransformLoopBody方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform
internal override MSAst.Expression Transform(AstGenerator ag) {
// Temporary variable for the IEnumerator object
MSAst.ParameterExpression enumerator = ag.GetTemporary("foreach_enumerator", typeof(IEnumerator));
// Only the body is "in the loop" for the purposes of break/continue
// The "else" clause is outside
MSAst.LabelTarget breakLabel, continueLabel;
MSAst.Expression body = ag.TransformLoopBody(_body, _left.Start, out breakLabel, out continueLabel);
if (body == null) {
// error recovery
return null;
}
return TransformForStatement(ag, enumerator, _list, _left, body, _else, Span, _header, breakLabel, continueLabel);
}
示例2: Transform
internal override MSAst.Expression Transform(AstGenerator ag) {
// Only the body is "in the loop" for the purposes of break/continue
// The "else" clause is outside
MSAst.LabelTarget breakLabel, continueLabel;
MSAst.Expression body = ag.TransformLoopBody(_body, out breakLabel, out continueLabel);
return AstUtils.While(
ag.AddDebugInfo(
ag.TransformAndDynamicConvert(_test, typeof(bool)),
Header
),
body,
ag.Transform(_else),
breakLabel,
continueLabel
);
}
示例3: Transform
internal override MSAst.Expression Transform(AstGenerator ag) {
// Only the body is "in the loop" for the purposes of break/continue
// The "else" clause is outside
MSAst.LabelTarget breakLabel, continueLabel;
ConstantExpression constTest = _test as ConstantExpression;
if (constTest != null && constTest.Value is int) {
// while 0: / while 1:
int val = (int)constTest.Value;
if (val == 0) {
// completely optimize the loop away
if (_else == null) {
return MSAst.Expression.Empty();
} else {
return ag.Transform(_else);
}
}
MSAst.Expression test = MSAst.Expression.Constant(true);
MSAst.Expression res = AstUtils.While(
test,
ag.TransformLoopBody(_body, SourceLocation.Invalid, out breakLabel, out continueLabel),
ag.Transform(_else),
breakLabel,
continueLabel
);
if (_test.Start.Line != _body.Start.Line) {
res = ag.AddDebugInfo(res, _test.Span);
}
return res;
}
return AstUtils.While(
ag.AddDebugInfo(
ag.TransformAndDynamicConvert(_test, typeof(bool)),
Header
),
ag.TransformLoopBody(_body, _test.Start, out breakLabel, out continueLabel),
ag.Transform(_else),
breakLabel,
continueLabel
);
}