本文整理汇总了C#中IronPython.Compiler.Ast.Statement类的典型用法代码示例。如果您正苦于以下问题:C# Statement类的具体用法?C# Statement怎么用?C# Statement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Statement类属于IronPython.Compiler.Ast命名空间,在下文中一共展示了Statement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBodyEndLocation
static SourceLocation GetBodyEndLocation(Statement body)
{
if (body.Parent != null) {
return body.End;
}
return SourceLocation.Invalid;
}
示例2: PythonAst
public PythonAst(Statement body, bool isModule, PythonLanguageFeatures languageFeatures, bool printExpressions) {
ContractUtils.RequiresNotNull(body, "body");
_body = body;
_isModule = isModule;
_printExpressions = printExpressions;
_languageFeatures = languageFeatures;
}
示例3: EnumerateBody
internal static IEnumerable<IScopeNode> EnumerateBody(Statement body)
{
SuiteStatement suite = body as SuiteStatement;
if (suite != null) {
foreach (Statement stmt in suite.Statements) {
ClassDefinition klass = stmt as ClassDefinition;
if (klass != null) {
yield return new ClassScopeNode(klass);
}
FunctionDefinition func = stmt as FunctionDefinition;
if (func != null) {
yield return new FunctionScopeNode(func);
}
}
}
}
示例4: FinishSmallStmt
private Statement FinishSmallStmt(Statement stmt) {
NextToken();
stmt.SetLoc(_globalParent, GetStart(), GetEnd());
return stmt;
}
示例5: FinishParsing
private PythonAst FinishParsing(Statement ret) {
var res = _globalParent;
_globalParent = null;
var lineLocs = _tokenizer.GetLineLocations();
// update line mapping
if (_sourceUnit.HasLineMapping) {
List<int> newLineMapping = new List<int>();
int last = 0;
for (int i = 0; i < lineLocs.Length; i++) {
while (newLineMapping.Count < i) {
newLineMapping.Add(last);
}
last = lineLocs[i] + 1;
newLineMapping.Add(lineLocs[i]);
}
lineLocs = newLineMapping.ToArray();
}
res.ParsingFinished(lineLocs, ret, _languageFeatures);
return res;
}
示例6: Convert
internal static stmt Convert(Statement stmt) {
stmt ast;
if (stmt is FunctionDefinition)
ast = new FunctionDef((FunctionDefinition)stmt);
else if (stmt is ReturnStatement)
ast = new Return((ReturnStatement)stmt);
else if (stmt is AssignmentStatement)
ast = new Assign((AssignmentStatement)stmt);
else if (stmt is AugmentedAssignStatement)
ast = new AugAssign((AugmentedAssignStatement)stmt);
else if (stmt is DelStatement)
ast = new Delete((DelStatement)stmt);
else if (stmt is PrintStatement)
ast = new Print((PrintStatement)stmt);
else if (stmt is ExpressionStatement)
ast = new Expr((ExpressionStatement)stmt);
else if (stmt is ForStatement)
ast = new For((ForStatement)stmt);
else if (stmt is WhileStatement)
ast = new While((WhileStatement)stmt);
else if (stmt is IfStatement)
ast = new If((IfStatement)stmt);
else if (stmt is WithStatement)
ast = new With((WithStatement)stmt);
else if (stmt is RaiseStatement)
ast = new Raise((RaiseStatement)stmt);
else if (stmt is TryStatement)
ast = Convert((TryStatement)stmt);
else if (stmt is AssertStatement)
ast = new Assert((AssertStatement)stmt);
else if (stmt is ImportStatement)
ast = new Import((ImportStatement)stmt);
else if (stmt is FromImportStatement)
ast = new ImportFrom((FromImportStatement)stmt);
else if (stmt is ExecStatement)
ast = new Exec((ExecStatement)stmt);
else if (stmt is GlobalStatement)
ast = new Global((GlobalStatement)stmt);
else if (stmt is ClassDefinition)
ast = new ClassDef((ClassDefinition)stmt);
else if (stmt is BreakStatement)
ast = new Break();
else if (stmt is ContinueStatement)
ast = new Continue();
else if (stmt is EmptyStatement)
ast = new Pass();
else
throw new ArgumentTypeException("Unexpected statement type: " + stmt.GetType());
ast.GetSourceLocation(stmt);
return ast;
}
示例7: ConvertStatements
internal static PythonList ConvertStatements(Statement stmt) {
return ConvertStatements(stmt, false);
}
示例8: IfStatement
public IfStatement(IfStatementTest[] tests, Statement else_) {
_tests = tests;
_else = else_;
}
示例9: IfStatement
public IfStatement(IfStatementTest[] tests, Statement else_)
{
this.tests = tests; this.elseStmt = else_;
}
示例10: 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()
);
}
示例11: ForStatement
public ForStatement(Expression left, Expression list, Statement body, Statement else_) {
_left = left;
_list = list;
_body = body;
_else = else_;
}
示例12: DoAnalyze
private Module DoAnalyze(Modules modules, string name, Statement root)
{
GlobalSuite global = new GlobalSuite(root);
module = new Module(modules, name, global, scopes);
ModuleScope modsc;
module.ModuleScope = modsc = new ModuleScope(module, null, global);
PushScope(modsc);
root.Walk(this);
foreach (FieldAssignment fer in this.fields) {
fer.Infer(module);
}
return module;
}
示例13: RevertStmts
internal static Statement RevertStmts(PythonList stmts)
{
if (stmts.Count == 1)
return ((stmt)stmts[0]).Revert();
Statement[] statements = new Statement[stmts.Count];
for (int i = 0; i < stmts.Count; i++)
statements[i] = ((stmt)stmts[i]).Revert();
return new SuiteStatement(statements);
}
示例14: ClassDefinition
public ClassDefinition(SymbolId name, Expression[] bases, Statement body) {
_name = name;
_bases = bases;
_body = body;
}
示例15: FunctionDefinition
public FunctionDefinition(SymbolId name, Parameter[] parameters, Statement body, SourceUnit sourceUnit) {
_name = name;
_parameters = parameters;
_body = body;
_sourceUnit = sourceUnit;
}