本文整理汇总了C#中IronPython.Compiler.Ast.Expression.TransformSet方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.TransformSet方法的具体用法?C# Expression.TransformSet怎么用?C# Expression.TransformSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronPython.Compiler.Ast.Expression
的用法示例。
在下文中一共展示了Expression.TransformSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformFor
internal static MSAst.Expression TransformFor(ScopeStatement parent, MSAst.ParameterExpression enumerator,
Expression list, Expression left, MSAst.Expression body,
Statement else_, SourceSpan span, SourceLocation header,
MSAst.LabelTarget breakLabel, MSAst.LabelTarget continueLabel, bool isStatement) {
// enumerator, isDisposable = Dynamic(GetEnumeratorBinder, list)
MSAst.Expression init = Ast.Assign(
enumerator,
new PythonDynamicExpression1<KeyValuePair<IEnumerator, IDisposable>>(
Binders.UnaryOperationBinder(
parent.GlobalParent.PyContext,
PythonOperationKind.GetEnumeratorForIteration
),
parent.GlobalParent.CompilationMode,
AstUtils.Convert(list, typeof(object))
)
);
// while enumerator.MoveNext():
// left = enumerator.Current
// body
// else:
// else
MSAst.Expression ls = AstUtils.Loop(
parent.GlobalParent.AddDebugInfo(
Ast.Call(
Ast.Property(
enumerator,
typeof(KeyValuePair<IEnumerator, IDisposable>).GetProperty("Key")
),
typeof(IEnumerator).GetMethod("MoveNext")
),
left.Span
),
null,
Ast.Block(
left.TransformSet(
SourceSpan.None,
Ast.Call(
Ast.Property(
enumerator,
typeof(KeyValuePair<IEnumerator, IDisposable>).GetProperty("Key")
),
typeof(IEnumerator).GetProperty("Current").GetGetMethod()
),
PythonOperationKind.None
),
body,
isStatement ? UpdateLineNumber(parent.GlobalParent.IndexToLocation(list.StartIndex).Line) : AstUtils.Empty(),
AstUtils.Empty()
),
else_,
breakLabel,
continueLabel
);
return Ast.Block(
init,
Ast.TryFinally(
ls,
Ast.Call(AstMethods.ForLoopDispose, enumerator)
)
);
}
示例2: TransformForStatement
internal static MSAst.Expression TransformForStatement(AstGenerator ag, MSAst.ParameterExpression enumerator,
Expression list, Expression left, MSAst.Expression body,
Statement else_, SourceSpan span, SourceLocation header,
MSAst.LabelTarget breakLabel, MSAst.LabelTarget continueLabel) {
// enumerator = PythonOps.GetEnumeratorForIteration(list)
MSAst.Expression init = Ast.Assign(
enumerator,
ag.Operation(
typeof(IEnumerator),
PythonOperationKind.GetEnumeratorForIteration,
ag.TransformAsObject(list)
)
);
// while enumerator.MoveNext():
// left = enumerator.Current
// body
// else:
// else
MSAst.Expression ls = AstUtils.Loop(
ag.AddDebugInfo(Ast.Call(
enumerator,
typeof(IEnumerator).GetMethod("MoveNext")
), left.Span),
null,
Ast.Block(
left.TransformSet(
ag,
SourceSpan.None,
Ast.Call(
enumerator,
typeof(IEnumerator).GetProperty("Current").GetGetMethod()
),
PythonOperationKind.None
),
body,
ag.UpdateLineNumber(list.Start.Line),
AstUtils.Empty()
),
ag.Transform(else_),
breakLabel,
continueLabel
);
return Ast.Block(
init,
ls,
AstUtils.Empty()
);
}