本文整理汇总了C#中ICSharpCode.NRefactory.Ast.Statement类的典型用法代码示例。如果您正苦于以下问题:C# Statement类的具体用法?C# Statement怎么用?C# Statement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Statement类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了Statement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExitBlockStatement
// Get the statement that will be executed once the given block exits by the end brace
// May return null
public static INode ExitBlockStatement(Statement statement)
{
if (statement == null) throw new ArgumentNullException();
// When an 'if' body is finished the execution continues with the
// next statement after the 'if' statement
if (statement is IfElseStatement) {
return GetNextStatement((IfElseStatement)statement);
}
// When a 'for' body is finished the execution continues by:
// Iterator; Condition; Body
if (statement is ForStatement) {
ForStatement forLoop = statement as ForStatement;
if (forLoop.Iterator.Count > 0) {
return forLoop.Iterator[0];
} else if (!forLoop.Condition.IsNull) {
return forLoop.Condition;
} else {
return EnterBlockStatement((Statement)forLoop.EmbeddedStatement.Children.First);
}
}
return null;
}
示例2: AddStatement
public static void AddStatement(this BlockStatement block, Statement statement)
{
if (block == null)
throw new ArgumentNullException("block");
if (statement == null)
throw new ArgumentNullException("statement");
block.AddChild(statement);
statement.Parent = block;
}
示例3: FindType
public TypeReference FindType(string name, Statement currentStatement)
{
INode node = currentStatement;
while ((node = node.Parent) != null) {
foreach (INode childNode in node.Children) {
LocalVariableDeclaration varDecl = childNode as LocalVariableDeclaration;
if (varDecl != null) {
foreach (VariableDeclaration var in varDecl.Variables) {
if (nameComparer.Equals(var.Name, name))
return var.TypeReference;
}
}
}
}
return null;
}
示例4: GetNextStatement
// Get the next statement that will be executed after this one
// May return null
public static INode GetNextStatement(Statement statement)
{
if (statement == null) throw new ArgumentNullException();
Statement next = (Statement)statement.Next();
if (next != null) {
return EnterBlockStatement(next);
} else {
if (statement.Parent is BlockStatement &&
statement.Parent.Parent is Statement) {
return ExitBlockStatement((Statement)statement.Parent.Parent);
} else {
return null;
}
}
}
示例5: CreateCaller
protected static Statement CreateCaller(AttributedNode parent, MethodDeclaration method, VariableDeclaration returnVariable)
{
Statement caller;
InvocationExpression expr = new InvocationExpression(new IdentifierExpression(method.Name), CreateArgumentExpressions(method.Parameters));
if (method.TypeReference.Type != "System.Void") {
TypeReference parentType = GetParentReturnType(parent);
if (method.TypeReference == parentType)
caller = new ReturnStatement(expr);
else {
returnVariable.Initializer = expr;
caller = new LocalVariableDeclaration(returnVariable);
}
} else {
caller = new ExpressionStatement(expr);
}
return caller;
}
示例6: EnterBlockStatement
// Get the first statement that will be executed in the given block
public static INode EnterBlockStatement(Statement statement)
{
if (statement == null) throw new ArgumentNullException();
// For loop starts as follows: Initializers; Condition; Body
if (statement is ForStatement) {
ForStatement forLoop = statement as ForStatement;
if (forLoop.Initializers.Count > 0) {
return forLoop.Initializers[0];
} else if (!forLoop.Condition.IsNull) {
return forLoop.Condition;
} else if (forLoop.EmbeddedStatement is BlockStatement &&
forLoop.EmbeddedStatement.Children.Count > 0) {
statement = (Statement)forLoop.EmbeddedStatement.Children.First;
return EnterBlockStatement(statement); // Simplify again
}
}
return statement; // Can not simplify
}
示例7: TryStatement
void TryStatement(
//#line 3589 "VBNET.ATG"
out Statement tryStatement) {
//#line 3591 "VBNET.ATG"
Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
Expect(218);
EndOfStmt();
Block(
//#line 3594 "VBNET.ATG"
out blockStmt);
if (la.kind == 75 || la.kind == 113 || la.kind == 123) {
CatchClauses(
//#line 3595 "VBNET.ATG"
out catchClauses);
}
if (la.kind == 123) {
lexer.NextToken();
EndOfStmt();
Block(
//#line 3596 "VBNET.ATG"
out finallyStmt);
}
Expect(113);
Expect(218);
//#line 3599 "VBNET.ATG"
tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
}
示例8: EmbeddedStatement
void EmbeddedStatement(
//#line 3070 "VBNET.ATG"
out Statement statement) {
//#line 3072 "VBNET.ATG"
Statement embeddedStatement = null;
statement = null;
Expression expr = null;
string name = String.Empty;
List<Expression> p = null;
Location startLocation = la.Location;
if (la.kind == 120) {
lexer.NextToken();
//#line 3080 "VBNET.ATG"
ExitType exitType = ExitType.None;
switch (la.kind) {
case 210: {
lexer.NextToken();
//#line 3082 "VBNET.ATG"
exitType = ExitType.Sub;
break;
}
case 127: {
lexer.NextToken();
//#line 3084 "VBNET.ATG"
exitType = ExitType.Function;
break;
}
case 186: {
lexer.NextToken();
//#line 3086 "VBNET.ATG"
exitType = ExitType.Property;
break;
}
case 108: {
lexer.NextToken();
//#line 3088 "VBNET.ATG"
exitType = ExitType.Do;
break;
}
case 124: {
lexer.NextToken();
//#line 3090 "VBNET.ATG"
exitType = ExitType.For;
break;
}
case 218: {
lexer.NextToken();
//#line 3092 "VBNET.ATG"
exitType = ExitType.Try;
break;
}
case 231: {
lexer.NextToken();
//#line 3094 "VBNET.ATG"
exitType = ExitType.While;
break;
}
case 197: {
lexer.NextToken();
//#line 3096 "VBNET.ATG"
exitType = ExitType.Select;
break;
}
default: SynErr(298); break;
}
//#line 3098 "VBNET.ATG"
statement = new ExitStatement(exitType);
} else if (la.kind == 218) {
TryStatement(
//#line 3099 "VBNET.ATG"
out statement);
} else if (la.kind == 89) {
lexer.NextToken();
//#line 3100 "VBNET.ATG"
ContinueType continueType = ContinueType.None;
if (la.kind == 108 || la.kind == 124 || la.kind == 231) {
if (la.kind == 108) {
lexer.NextToken();
//#line 3100 "VBNET.ATG"
continueType = ContinueType.Do;
} else if (la.kind == 124) {
lexer.NextToken();
//#line 3100 "VBNET.ATG"
continueType = ContinueType.For;
} else {
//.........这里部分代码省略.........
示例9: WithStatement
void WithStatement(
#line 3225 "VBNET.ATG"
out Statement withStatement) {
#line 3227 "VBNET.ATG"
Statement blockStmt = null;
Expression expr = null;
Expect(218);
#line 3230 "VBNET.ATG"
Location start = t.Location;
Expr(
#line 3231 "VBNET.ATG"
out expr);
EndOfStmt();
#line 3233 "VBNET.ATG"
withStatement = new WithStatement(expr);
withStatement.StartLocation = start;
Block(
#line 3236 "VBNET.ATG"
out blockStmt);
#line 3238 "VBNET.ATG"
((WithStatement)withStatement).Body = (BlockStatement)blockStmt;
Expect(100);
Expect(218);
#line 3241 "VBNET.ATG"
withStatement.EndLocation = t.Location;
}
示例10: LocalDeclarationStatement
void LocalDeclarationStatement(
#line 2724 "VBNET.ATG"
out Statement statement) {
#line 2726 "VBNET.ATG"
ModifierList m = new ModifierList();
LocalVariableDeclaration localVariableDeclaration;
bool dimfound = false;
while (la.kind == 75 || la.kind == 92 || la.kind == 189) {
if (la.kind == 75) {
lexer.NextToken();
#line 2732 "VBNET.ATG"
m.Add(Modifiers.Const, t.Location);
} else if (la.kind == 189) {
lexer.NextToken();
#line 2733 "VBNET.ATG"
m.Add(Modifiers.Static, t.Location);
} else {
lexer.NextToken();
#line 2734 "VBNET.ATG"
dimfound = true;
}
}
#line 2737 "VBNET.ATG"
if(dimfound && (m.Modifier & Modifiers.Const) != 0) {
Error("Dim is not allowed on constants.");
}
if(m.isNone && dimfound == false) {
Error("Const, Dim or Static expected");
}
localVariableDeclaration = new LocalVariableDeclaration(m.Modifier);
localVariableDeclaration.StartLocation = t.Location;
VariableDeclarator(
#line 2748 "VBNET.ATG"
localVariableDeclaration.Variables);
while (la.kind == 12) {
lexer.NextToken();
VariableDeclarator(
#line 2749 "VBNET.ATG"
localVariableDeclaration.Variables);
}
#line 2751 "VBNET.ATG"
statement = localVariableDeclaration;
}
示例11: Block
void Block(
#line 2680 "VBNET.ATG"
out Statement stmt) {
#line 2683 "VBNET.ATG"
BlockStatement blockStmt = new BlockStatement();
/* in snippet parsing mode, t might be null */
if (t != null) blockStmt.StartLocation = t.EndLocation;
compilationUnit.BlockStart(blockStmt);
while (StartOf(22) ||
#line 2689 "VBNET.ATG"
IsEndStmtAhead()) {
if (
#line 2689 "VBNET.ATG"
IsEndStmtAhead()) {
Expect(100);
EndOfStmt();
#line 2689 "VBNET.ATG"
compilationUnit.AddChild(new EndStatement());
} else {
Statement();
EndOfStmt();
}
}
#line 2694 "VBNET.ATG"
stmt = blockStmt;
if (t != null) blockStmt.EndLocation = t.EndLocation;
compilationUnit.BlockEnd();
}
示例12: ResourceAcquisition
void ResourceAcquisition(
#line 1783 "cs.ATG"
out Statement stmt) {
#line 1785 "cs.ATG"
stmt = null;
Expression expr;
if (
#line 1790 "cs.ATG"
IsLocalVarDecl()) {
LocalVariableDecl(
#line 1790 "cs.ATG"
out stmt);
} else if (StartOf(6)) {
Expr(
#line 1791 "cs.ATG"
out expr);
#line 1795 "cs.ATG"
stmt = new ExpressionStatement(expr);
} else SynErr(204);
}
示例13: ResourceAcquisition
void ResourceAcquisition(
//#line 1763 "cs.ATG"
out Statement stmt) {
//#line 1765 "cs.ATG"
stmt = null;
Expression expr;
if (
//#line 1770 "cs.ATG"
IsLocalVarDecl()) {
LocalVariableDecl(
//#line 1770 "cs.ATG"
out stmt);
} else if (StartOf(6)) {
Expr(
//#line 1771 "cs.ATG"
out expr);
//#line 1775 "cs.ATG"
stmt = new ExpressionStatement(expr);
} else SynErr(202);
}
示例14: StatementExpr
void StatementExpr(
//#line 1779 "cs.ATG"
out Statement stmt) {
//#line 1780 "cs.ATG"
Expression expr;
Expr(
//#line 1782 "cs.ATG"
out expr);
//#line 1785 "cs.ATG"
stmt = new ExpressionStatement(expr);
}
示例15: WithStatement
void WithStatement(
#line 3577 "VBNET.ATG"
out Statement withStatement) {
#line 3579 "VBNET.ATG"
Statement blockStmt = null;
Expression expr = null;
Expect(236);
#line 3582 "VBNET.ATG"
Location start = t.Location;
Expr(
#line 3583 "VBNET.ATG"
out expr);
EndOfStmt();
#line 3585 "VBNET.ATG"
withStatement = new WithStatement(expr);
withStatement.StartLocation = start;
Block(
#line 3588 "VBNET.ATG"
out blockStmt);
#line 3590 "VBNET.ATG"
((WithStatement)withStatement).Body = (BlockStatement)blockStmt;
Expect(115);
Expect(236);
#line 3593 "VBNET.ATG"
withStatement.EndLocation = t.Location;
}