本文整理汇总了C#中ICSharpCode.NRefactory.Ast.Statement类的典型用法代码示例。如果您正苦于以下问题:C# Statement类的具体用法?C# Statement怎么用?C# Statement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Statement类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了Statement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:almazik,项目名称:ILSpy,代码行数:27,代码来源:RemoveGotos.cs
示例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;
}
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:StatementBuilder.cs
示例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;
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:16,代码来源:VariableResolver.cs
示例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;
}
}
}
开发者ID:almazik,项目名称:ILSpy,代码行数:19,代码来源:RemoveGotos.cs
示例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;
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:18,代码来源:MethodExtractorBase.cs
示例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
}
开发者ID:almazik,项目名称:ILSpy,代码行数:21,代码来源:RemoveGotos.cs
示例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);
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:31,代码来源:Parser.cs
示例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 {
//.........这里部分代码省略.........
开发者ID:Altaxo,项目名称:Altaxo,代码行数:101,代码来源:Parser.cs
示例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;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:34,代码来源:Parser.cs
示例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;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:54,代码来源:Parser.cs
示例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();
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:33,代码来源:Parser.cs
示例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);
}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:23,代码来源:Parser.cs
示例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);
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:23,代码来源:Parser.cs
示例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);
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:13,代码来源:Parser.cs
示例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;
}
开发者ID:BooMWax,项目名称:SharpDevelop,代码行数:34,代码来源:Parser.cs
示例16: StatementExpr
void StatementExpr(
#line 1799 "cs.ATG"
out Statement stmt) {
#line 1800 "cs.ATG"
Expression expr;
Expr(
#line 1802 "cs.ATG"
out expr);
#line 1805 "cs.ATG"
stmt = new ExpressionStatement(expr);
}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:13,代码来源:Parser.cs
示例17: TryStatement
void TryStatement(
#line 1725 "cs.ATG"
out Statement tryStatement) {
#line 1727 "cs.ATG"
BlockStatement blockStmt = null, finallyStmt = null;
CatchClause catchClause = null;
List<CatchClause> catchClauses = new List<CatchClause>();
Expect(114);
Block(
#line 1732 "cs.ATG"
out blockStmt);
while (la.kind == 56) {
CatchClause(
#line 1734 "cs.ATG"
out catchClause);
#line 1735 "cs.ATG"
if (catchClause != null) catchClauses.Add(catchClause);
}
if (la.kind == 73) {
lexer.NextToken();
Block(
#line 1737 "cs.ATG"
out finallyStmt);
}
#line 1739 "cs.ATG"
tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
if (catchClauses != null) {
foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement;
}
}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:35,代码来源:Parser.cs
示例18: EmbeddedStatement
void EmbeddedStatement(
#line 2297 "VBNET.ATG"
out Statement statement) {
#line 2299 "VBNET.ATG"
Statement embeddedStatement = null;
statement = null;
Expression expr = null;
string name = String.Empty;
List<Expression> p = null;
switch (la.kind) {
case 94: {
lexer.NextToken();
#line 2305 "VBNET.ATG"
ExitType exitType = ExitType.None;
switch (la.kind) {
case 167: {
lexer.NextToken();
#line 2307 "VBNET.ATG"
exitType = ExitType.Sub;
break;
}
case 100: {
lexer.NextToken();
#line 2309 "VBNET.ATG"
exitType = ExitType.Function;
break;
}
case 146: {
lexer.NextToken();
#line 2311 "VBNET.ATG"
exitType = ExitType.Property;
break;
}
case 83: {
lexer.NextToken();
#line 2313 "VBNET.ATG"
exitType = ExitType.Do;
break;
}
case 98: {
lexer.NextToken();
#line 2315 "VBNET.ATG"
exitType = ExitType.For;
break;
}
case 174: {
lexer.NextToken();
#line 2317 "VBNET.ATG"
exitType = ExitType.Try;
break;
}
case 181: {
lexer.NextToken();
#line 2319 "VBNET.ATG"
exitType = ExitType.While;
break;
}
case 155: {
lexer.NextToken();
#line 2321 "VBNET.ATG"
exitType = ExitType.Select;
break;
}
default: SynErr(255); break;
}
#line 2323 "VBNET.ATG"
statement = new ExitStatement(exitType);
break;
}
case 174: {
TryStatement(
#line 2324 "VBNET.ATG"
out statement);
break;
}
case 187: {
lexer.NextToken();
#line 2325 "VBNET.ATG"
ContinueType continueType = ContinueType.None;
if (la.kind == 83 || la.kind == 98 || la.kind == 181) {
if (la.kind == 83) {
lexer.NextToken();
#line 2325 "VBNET.ATG"
continueType = ContinueType.Do;
} else if (la.kind == 98) {
lexer.NextToken();
//.........这里部分代码省略.........
开发者ID:almazik,项目名称:ILSpy,代码行数:101,代码来源:Parser.cs
示例19: CheckNull
public static Statement CheckNull(Statement statement)
{
return statement ?? NullStatement.Instance;
}
开发者ID:pusp,项目名称:o2platform,代码行数:4,代码来源:Statement.cs
示例20: TryStatement
void TryStatement(
#line 2760 "VBNET.ATG"
out Statement tryStatement) {
#line 2762 "VBNET.ATG"
Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
Expect(174);
EndOfStmt();
Block(
#line 2765 "VBNET.ATG"
out blockStmt);
if (la.kind == 58 || la.kind == 88 || la.kind == 97) {
CatchClauses(
#line 2766 "VBNET.ATG"
out catchClauses);
}
if (la.kind == 97) {
lexer.NextToken();
EndOfStmt();
Block(
#line 2767 "VBNET.ATG"
out finallyStmt);
}
Expect(88);
Expect(174);
#line 2770 "VBNET.ATG"
tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
}
开发者ID:almazik,项目名称:ILSpy,代码行数:31,代码来源:Parser.cs
注:本文中的ICSharpCode.NRefactory.Ast.Statement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论