本文整理汇总了C#中IronPython.Compiler.Ast.Statement.Transform方法的典型用法代码示例。如果您正苦于以下问题:C# Statement.Transform方法的具体用法?C# Statement.Transform怎么用?C# Statement.Transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronPython.Compiler.Ast.Statement
的用法示例。
在下文中一共展示了Statement.Transform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformWithLineNumberUpdate
private MSAst.Expression TransformWithLineNumberUpdate(Statement/*!*/ fromStmt) {
// add line number tracking when the line changes... First we see if the
// line number changes and then we transform the body. This prevents the body
// from updating the line info first.
bool updateLine = false;
if (fromStmt.CanThrow && // don't need to update line tracking for statements that can't throw
((_curLine.HasValue && fromStmt.Start.IsValid && _curLine.Value != fromStmt.Start.Line) || // don't need to update unless line has changed
(!_curLine.HasValue && fromStmt.Start.IsValid))) { // do need to update if we don't yet have a valid line
_curLine = fromStmt.Start.Line;
updateLine = true;
}
MSAst.Expression toExpr = fromStmt.Transform(this);
if (toExpr != null && updateLine && Context.SourceUnit.Kind != SourceCodeKind.Expression) {
toExpr = Ast.Block(
UpdateLineNumber(fromStmt.Start.Line),
toExpr
);
}
if (InFinally || InLoop) {
if (!LoopOrFinallyLocations.ContainsKey(fromStmt.Span.Start.Line)) {
LoopOrFinallyLocations.Add(fromStmt.Span.Start.Line, new Dictionary<int, bool>(LoopOrFinallyIds));
}
}
return toExpr;
}
示例2: TransformWithLineNumberUpdate
private MSAst.Expression TransformWithLineNumberUpdate(Statement/*!*/ fromStmt) {
// add line number tracking when the line changes... First we see if the
// line number changes and then we transform the body. This prevents the body
// from updating the line info first.
bool updateLine = false;
if (fromStmt.CanThrow && // don't need to update line tracking for statements that can't throw
((_curLine.HasValue && fromStmt.Start.IsValid && _curLine.Value != fromStmt.Start.Line) || // don't need to update unless line has changed
(!_curLine.HasValue && fromStmt.Start.IsValid))) { // do need to update if we don't yet have a valid line
_curLine = fromStmt.Start.Line;
updateLine = true;
}
MSAst.Expression toExpr = fromStmt.Transform(this);
if (toExpr != null && updateLine) {
toExpr = Ast.Block(
UpdateLineNumber(fromStmt.Start.Line),
toExpr
);
}
return toExpr;
}
示例3: TransformMaybeSingleLineSuite
public MSAst.Expression TransformMaybeSingleLineSuite(Statement body, SourceLocation prevStart) {
MSAst.Expression res;
if (body.Start.Line == prevStart.Line) {
// avoid creating and throwing away as much line number goo as we can...
res = body.Transform(this);
} else {
res = Transform(body);
}
MSAst.BlockExpression block = res as MSAst.BlockExpression;
if (block != null && block.Expressions.Count > 0) {
MSAst.DebugInfoExpression dbgInfo = block.Expressions[0] as MSAst.DebugInfoExpression;
// body on the same line as an if, don't generate a 2nd sequence point
if (dbgInfo != null && dbgInfo.StartLine == prevStart.Line) {
// we remove the debug info based upon how it's generated in DebugStatement.AddDebugInfo which is
// the helper method which adds the debug info.
if (block.Type == typeof(void)) {
Debug.Assert(block.Expressions.Count == 3);
Debug.Assert(block.Expressions[2] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear);
res = block.Expressions[1];
} else {
Debug.Assert(block.Expressions.Count == 4);
Debug.Assert(block.Expressions[3] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear);
Debug.Assert(block.Expressions[1] is MSAst.BinaryExpression && ((MSAst.BinaryExpression)block.Expressions[2]).NodeType == MSAst.ExpressionType.Assign);
res = ((MSAst.BinaryExpression)block.Expressions[1]).Right;
}
}
}
if (res.Type != typeof(void)) {
res = AstUtils.Void(res);
}
return res;
}