本文整理汇总了C#中IronPython.Compiler.Ast.Statement类的典型用法代码示例。如果您正苦于以下问题:C# Statement类的具体用法?C# Statement怎么用?C# Statement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Statement类属于IronPython.Compiler.Ast命名空间,在下文中一共展示了Statement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetBodyEndLocation
static SourceLocation GetBodyEndLocation(Statement body)
{
if (body.Parent != null) {
return body.End;
}
return SourceLocation.Invalid;
}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:7,代码来源:PythonMethodOrClassBodyRegion.cs
示例2: PythonAst
public PythonAst(Statement body, bool isModule, PythonLanguageFeatures languageFeatures, bool printExpressions) {
ContractUtils.RequiresNotNull(body, "body");
_body = body;
_isModule = isModule;
_printExpressions = printExpressions;
_languageFeatures = languageFeatures;
}
开发者ID:jcteague,项目名称:ironruby,代码行数:8,代码来源:PythonAst.cs
示例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);
}
}
}
}
开发者ID:TerabyteX,项目名称:main,代码行数:17,代码来源:AstScopeNode.cs
示例4: FinishSmallStmt
private Statement FinishSmallStmt(Statement stmt) {
NextToken();
stmt.SetLoc(_globalParent, GetStart(), GetEnd());
return stmt;
}
开发者ID:bdoot,项目名称:IronLanguages,代码行数:5,代码来源:Parser.cs
示例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;
}
开发者ID:bdoot,项目名称:IronLanguages,代码行数:22,代码来源:Parser.cs
示例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;
}
开发者ID:rchandrashekara,项目名称:main,代码行数:53,代码来源:_ast.cs
示例7: ConvertStatements
internal static PythonList ConvertStatements(Statement stmt) {
return ConvertStatements(stmt, false);
}
开发者ID:rchandrashekara,项目名称:main,代码行数:3,代码来源:_ast.cs
示例8: IfStatement
public IfStatement(IfStatementTest[] tests, Statement else_) {
_tests = tests;
_else = else_;
}
开发者ID:techarch,项目名称:ironruby,代码行数:4,代码来源:IfStatement.cs
示例9: IfStatement
public IfStatement(IfStatementTest[] tests, Statement else_)
{
this.tests = tests; this.elseStmt = else_;
}
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:Statements.cs
示例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()
);
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:50,代码来源:ForStatement.cs
示例11: ForStatement
public ForStatement(Expression left, Expression list, Statement body, Statement else_) {
_left = left;
_list = list;
_body = body;
_else = else_;
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:6,代码来源:ForStatement.cs
示例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;
}
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:17,代码来源:Analyzer.cs
示例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);
}
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:_ast.cs
示例14: ClassDefinition
public ClassDefinition(SymbolId name, Expression[] bases, Statement body) {
_name = name;
_bases = bases;
_body = body;
}
开发者ID:tnachen,项目名称:ironruby,代码行数:5,代码来源:ClassDefinition.cs
示例15: FunctionDefinition
public FunctionDefinition(SymbolId name, Parameter[] parameters, Statement body, SourceUnit sourceUnit) {
_name = name;
_parameters = parameters;
_body = body;
_sourceUnit = sourceUnit;
}
开发者ID:octavioh,项目名称:ironruby,代码行数:6,代码来源:FunctionDefinition.cs
示例16: WithStatement
private List<YieldTarget> yieldTargets; // = new List<YieldTarget>();
#endregion Fields
#region Constructors
public WithStatement(Expression contextManager, Expression var, Statement body)
{
this.contextManager = contextManager;
this.var = var;
this.body = body;
}
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:12,代码来源:Statements.cs
示例17: ForStatement
public ForStatement(Expression lhs, Expression list, Statement body, Statement else_)
{
this.lhs = lhs; this.list = list;
this.body = body; this.elseStmt = else_;
}
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:5,代码来源:Statements.cs
示例18: FunctionDefinition
public FunctionDefinition(SymbolId name, Expression[] parameters, Expression[] defaults, FunctionAttributes flags, Statement body, string sourceFile)
: base(body)
{
this.name = name;
this.parameters = parameters;
this.defaults = defaults;
this.flags = flags;
this.decorators = null;
this.filename = sourceFile;
}
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:10,代码来源:FuncDef.cs
示例19: IfStatementTest
public IfStatementTest(Expression test, Statement body)
{
this.test = test; this.body = body;
}
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:Statements.cs
示例20: WhileStatement
public WhileStatement(Expression test, Statement body, Statement else_) {
_test = test;
_body = body;
_else = else_;
}
开发者ID:octavioh,项目名称:ironruby,代码行数:5,代码来源:WhileStatement.cs
注:本文中的IronPython.Compiler.Ast.Statement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论