本文整理汇总了C#中BlockStatement类的典型用法代码示例。如果您正苦于以下问题:C# BlockStatement类的具体用法?C# BlockStatement怎么用?C# BlockStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockStatement类属于命名空间,在下文中一共展示了BlockStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitBlockWithoutFixingBraces
void VisitBlockWithoutFixingBraces(BlockStatement blockStatement, bool indent)
{
if (indent) {
curIndent.Push(IndentType.Block);
}
VisitChildrenToFormat (blockStatement, child => {
if (child.Role == Roles.LBrace || child.Role == Roles.RBrace) {
return;
}
if (child is Statement) {
FixStatementIndentation(child.StartLocation);
child.AcceptVisitor(this);
} else if (child is Comment) {
child.AcceptVisitor(this);
} else if (child is NewLineNode) {
// ignore
} else {
// pre processor directives at line start, if they are there.
if (child.StartLocation.Column > 1)
FixStatementIndentation(child.StartLocation);
}
});
if (indent) {
curIndent.Pop ();
}
}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:29,代码来源:FormattingVisitor_Statements.cs
示例2: VisitBlockStatement
public override void VisitBlockStatement(BlockStatement blockStatement)
{
base.VisitBlockStatement (blockStatement);
List<Statement> statements = new List<Statement>();
foreach (Statement statement in blockStatement.Statements)
{
bool loop = GetIsLoopStatement (statement);
if (loop)
{
int nodeId = this.blockIds.Dequeue();
this.lineMap[nodeId] = statement.StartLocation.Line;
}
if (this.loopLevel > 0)
{
if (statement is ContinueStatement || statement is BreakStatement)
this.id++;
}
statements.Add (statement.Clone());
if (loop)
this.id++;
}
blockStatement.Statements.Clear();
blockStatement.Statements.AddRange (statements);
}
开发者ID:ermau,项目名称:Instant,代码行数:30,代码来源:IdentifyingVisitor.cs
示例3: ActionFromUsingStatement
CodeAction ActionFromUsingStatement(RefactoringContext context)
{
var initializer = context.GetNode<VariableInitializer>();
if (initializer == null)
return null;
var initializerRR = context.Resolve(initializer) as LocalResolveResult;
if (initializerRR == null)
return null;
var elementType = GetElementType(initializerRR, context);
if (elementType == null)
return null;
var usingStatement = initializer.Parent.Parent as UsingStatement;
if (usingStatement == null)
return null;
return new CodeAction(context.TranslateString("Iterate via foreach"), script => {
var iterator = MakeForeach(new IdentifierExpression(initializer.Name), elementType, context);
if (usingStatement.EmbeddedStatement is EmptyStatement) {
var blockStatement = new BlockStatement();
blockStatement.Statements.Add(iterator);
script.Replace(usingStatement.EmbeddedStatement, blockStatement);
script.FormatText(blockStatement);
} else if (usingStatement.EmbeddedStatement is BlockStatement) {
var anchorNode = usingStatement.EmbeddedStatement.FirstChild;
script.InsertAfter(anchorNode, iterator);
script.FormatText(usingStatement.EmbeddedStatement);
}
});
}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:28,代码来源:IterateViaForeachAction.cs
示例4: VisitBlockStatement
public override object VisitBlockStatement(BlockStatement blockStatement, object data)
{
Push();
object result = base.VisitBlockStatement(blockStatement, data);
Pop();
return result;
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:PrefixFieldsVisitor.cs
示例5: SmallBasicSimpleName
private SmallBasicSimpleName(BlockStatement containingBlock, SmallBasicSimpleName template)
: base(containingBlock, template) {
if (template.rootClass != null)
this.rootClass = (RootClassDeclaration)template.rootClass.MakeShallowCopyFor(containingBlock.ContainingNamespaceDeclaration);
if (template.expressionToInferTargetTypeFrom != null)
this.expressionToInferTargetTypeFrom = template.expressionToInferTargetTypeFrom.MakeCopyFor(containingBlock);
}
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:7,代码来源:Expressions.cs
示例6: Visit
public virtual void Visit(BlockStatement blockStatement)
{
foreach (var xStatement in blockStatement.Statements)
{
xStatement.Dispatch(this);
}
}
开发者ID:Sullux,项目名称:tws,代码行数:7,代码来源:BaseVisitor.cs
示例7: CheckedStatement
/// <summary>
/// Initializes a new instance of the CheckedStatement class.
/// </summary>
/// <param name="tokens">
/// The list of tokens that form the statement.
/// </param>
/// <param name="embeddedStatement">
/// The block statement embedded within this checked statement, if any.
/// </param>
internal CheckedStatement(CsTokenList tokens, BlockStatement embeddedStatement)
: base(StatementType.Checked, tokens)
{
Param.AssertNotNull(tokens, "tokens");
Param.AssertNotNull(embeddedStatement, "embeddedStatement");
this.embeddedStatement = embeddedStatement;
this.AddStatement(embeddedStatement);
}
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:18,代码来源:CheckedStatement.cs
示例8: TransformBlock
Ast.BlockStatement TransformBlock(ILBlock block)
{
Ast.BlockStatement astBlock = new BlockStatement();
if (block != null) {
foreach(ILNode node in block.GetChildren()) {
astBlock.AddRange(TransformNode(node));
}
}
return astBlock;
}
开发者ID:hlesesne,项目名称:ILSpy,代码行数:10,代码来源:AstMethodBodyBuilder.cs
示例9: VisitBlockStatement
public override void VisitBlockStatement(BlockStatement node)
{
VisitChildren(node);
var statements = node.Statements;
for (AstNode child = node.FirstChild, next = null; child != null; child = next) {
next = child.NextSibling;
MangleStatement(statements, child);
}
}
开发者ID:evanw,项目名称:minisharp,代码行数:10,代码来源:Mangle.cs
示例10: MethodBodyMetadata
/// <summary>
/// Initializes a new instance.
/// </summary>
/// <param name="parameters">The metadata of the parameters declared by the method.</param>
/// <param name="localVariables">The metadata of the local variables declared by the method.</param>
/// <param name="body">The block statement representing the method's body.</param>
public MethodBodyMetadata(IEnumerable<VariableMetadata> parameters, IEnumerable<VariableMetadata> localVariables, BlockStatement body)
{
Requires.NotNull(parameters, () => parameters);
Requires.NotNull(localVariables, () => localVariables);
Requires.NotNull(body, () => body);
Parameters = parameters;
LocalVariables = localVariables;
Body = body;
}
开发者ID:cubeme,项目名称:safety-sharp,代码行数:16,代码来源:MethodBodyMetadata.cs
示例11: TryFinally
public void TryFinally()
{
BlockStatement block = new BlockStatement {
new TryCatchStatement {
TryBlock = new BlockStatement {
new GotoStatement("LABEL"),
new AssignmentExpression(new IdentifierExpression("i"), new PrimitiveExpression(1))
},
CatchClauses = {
new CatchClause {
Body = new BlockStatement {
new AssignmentExpression(new IdentifierExpression("i"), new PrimitiveExpression(3))
}
}
},
FinallyBlock = new BlockStatement {
new AssignmentExpression(new IdentifierExpression("j"), new PrimitiveExpression(5))
}
},
new LabelStatement { Label = "LABEL" },
new EmptyStatement()
};
TryCatchStatement tryCatchStatement = (TryCatchStatement)block.Statements.First();
Statement stmt1 = tryCatchStatement.TryBlock.Statements.ElementAt(1);
Statement stmt3 = tryCatchStatement.CatchClauses.Single().Body.Statements.Single();
Statement stmt5 = tryCatchStatement.FinallyBlock.Statements.Single();
LabelStatement label = (LabelStatement)block.Statements.ElementAt(1);
DefiniteAssignmentAnalysis da = CreateDefiniteAssignmentAnalysis(block);
da.Analyze("i");
Assert.AreEqual(0, da.UnassignedVariableUses.Count);
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(tryCatchStatement));
Assert.AreEqual(DefiniteAssignmentStatus.CodeUnreachable, da.GetStatusBefore(stmt1));
Assert.AreEqual(DefiniteAssignmentStatus.CodeUnreachable, da.GetStatusAfter(stmt1));
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(stmt3));
Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(stmt3));
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(stmt5));
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusAfter(stmt5));
Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(tryCatchStatement));
Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusBefore(label));
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusAfter(label));
da.Analyze("j");
Assert.AreEqual(0, da.UnassignedVariableUses.Count);
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(tryCatchStatement));
Assert.AreEqual(DefiniteAssignmentStatus.CodeUnreachable, da.GetStatusBefore(stmt1));
Assert.AreEqual(DefiniteAssignmentStatus.CodeUnreachable, da.GetStatusAfter(stmt1));
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(stmt3));
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusAfter(stmt3));
Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(stmt5));
Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(stmt5));
Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(tryCatchStatement));
Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusBefore(label));
Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(label));
}
开发者ID:mono-soc-2012,项目名称:NRefactory,代码行数:55,代码来源:DefiniteAssignmentTests.cs
示例12: FinallyStatement
/// <summary>
/// Initializes a new instance of the FinallyStatement class.
/// </summary>
/// <param name="tokens">
/// The list of tokens that form the statement.
/// </param>
/// <param name="tryStatement">
/// The try-statement that this finally-statement is embedded to.
/// </param>
/// <param name="embeddedStatement">
/// The statement embedded within the finally-statement.
/// </param>
internal FinallyStatement(CsTokenList tokens, TryStatement tryStatement, BlockStatement embeddedStatement)
: base(StatementType.Finally, tokens)
{
Param.AssertNotNull(tokens, "tokens");
Param.AssertNotNull(tryStatement, "tryStatement");
Param.AssertNotNull(embeddedStatement, "embeddedStatement");
this.tryStatement = tryStatement;
this.embeddedStatement = embeddedStatement;
this.AddStatement(embeddedStatement);
}
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:24,代码来源:FinallyStatement.cs
示例13: IsNotImplemented
bool IsNotImplemented(RefactoringContext context, BlockStatement body)
{
if (body.IsNull)
return true;
if (body.Statements.Count == 1) {
var throwStmt = body.Statements.First () as ThrowStatement;
if (throwStmt != null) {
return context.Resolve (throwStmt.Expression).Type.FullName == "System.NotImplementedException";
}
}
return false;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:12,代码来源:ImplementNotImplementedProperty.cs
示例14: TransformBlock
Ast.BlockStatement TransformBlock(ILBlock block)
{
Ast.BlockStatement astBlock = new BlockStatement();
if (block != null) {
if (block.EntryGoto != null)
astBlock.Add((Statement)TransformExpression(block.EntryGoto));
foreach(ILNode node in block.Body) {
astBlock.AddRange(TransformNode(node));
}
}
return astBlock;
}
开发者ID:stgwilli,项目名称:ILSpy,代码行数:12,代码来源:AstMethodBodyBuilder.cs
示例15: GlslVisitor
public GlslVisitor(BlockStatement block, CustomAttribute attr, DecompilerContext ctx)
: this()
{
_attr = attr;
var trans1 = new ReplaceMethodCallsWithOperators(ctx);
var trans2 = new RenameLocals();
((IAstTransform)trans1).Run(block);
trans2.Run(block);
Result = block.AcceptVisitor(this, 0).ToString();
Result += Environment.NewLine;
}
开发者ID:mono-soc-2011,项目名称:SLSharp,代码行数:13,代码来源:GlslVisitor.cs
示例16: ReplaceJump
static BlockStatement ReplaceJump(JumpStatement jump, BlockStatement block)
{
if (jump.StartOffset < block.StartOffset)
throw new ArgumentOutOfRangeException("jump", "jump should be inside the given block");
if (jump.JumpOffset > block.EndOffset)
throw new ArgumentOutOfRangeException("jump", "jump should be inside the given block");
var newBlock = new BlockStatement();
var ifStatement = new IfStatement(Not(jump.Condition), new BlockStatement()){ StartOffset = jump.StartOffset, EndOffset = jump.JumpOffset };
var inside = false;
foreach (var statement in block)
{
if (statement is IfStatement && statement.Contains(jump.StartOffset.Value) && statement.EndOffset >= jump.JumpOffset)
{
var ifStatement2 = (IfStatement)statement;
var b2 = ReplaceJump(jump, (BlockStatement)ifStatement2.TrueStatement);
var newIfStatement2 = new IfStatement(ifStatement2.Condition, new BlockStatement()){ StartOffset = ifStatement2.StartOffset, EndOffset = ifStatement2.EndOffset };
((BlockStatement)newIfStatement2.TrueStatement).AddStatements((IEnumerable<Statement>)b2);
newBlock.AddStatement(newIfStatement2);
}
else if (statement.StartOffset == jump.StartOffset)
{
inside = true;
}
else if (statement.StartOffset == jump.JumpOffset)
{
if (ifStatement == null)
throw new InvalidOperationException("ifStatement can't be null");
newBlock.AddStatement(ifStatement);
newBlock.AddStatement(statement);
ifStatement = null;
inside = false;
}
else if (inside)
{
((BlockStatement)ifStatement.TrueStatement).AddStatement(statement);
}
else
{
var lastStatement = newBlock.LastOrDefault();
if (lastStatement != null && lastStatement.EndOffset > statement.StartOffset)
{
throw new NotSupportedException("invalid Statement");
}
newBlock.AddStatement(statement);
}
}
return newBlock;
}
开发者ID:scemino,项目名称:nscumm,代码行数:49,代码来源:ReplaceJumpToIf.cs
示例17: Block
public Block(IEmitter emitter, BlockStatement blockStatement)
: base(emitter, blockStatement)
{
this.Emitter = emitter;
this.BlockStatement = blockStatement;
if (this.Emitter.IgnoreBlock == blockStatement)
{
this.AsyncNoBraces = true;
}
if (this.Emitter.NoBraceBlock == blockStatement)
{
this.NoBraces = true;
}
}
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:16,代码来源:Block.cs
示例18: VisitBlockStatement
public override void VisitBlockStatement(BlockStatement blockStatement)
{
base.VisitBlockStatement(blockStatement);
if (blockStatement.Statements.Count == 1)
{
try
{
blockStatement.ReplaceWith(blockStatement.Statements.ElementAt(0));
}
catch (ArgumentException)
{
// Can't simplify this...
}
}
}
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:16,代码来源:SimplifyZeroAndConditionalExpressionsVisitor.cs
示例19: WriteBlock
private void WriteBlock(BlockStatement blockstatement, StringBuilder programBuilder)
{
foreach (Statement statement in blockstatement.StatementList)
{
if (statement is ReturnStatement)
{
WriteReturnStatement(statement as ReturnStatement, programBuilder);
}
else if (statement is ExpressionStatement)
{
WriteExpressionStatemnt(statement as ExpressionStatement, programBuilder);
}
else if (statement is IdDeclarationStatement)
{
WriteIdDeclarationStatement(statement as IdDeclarationStatement, programBuilder);
}
else if (statement is IfStatement)
{
WriteIFStatement(statement as IfStatement, programBuilder);
}
else if (statement is ForStatement)
{
WriteForStatement(statement as ForStatement, programBuilder);
}
else if (statement is WhileStatement)
{
WriteWhileStatement(statement as WhileStatement, programBuilder);
}
else if (statement is DoStatement)
{
WriteDoStatement(statement as DoStatement, programBuilder);
}
else if (statement is SwitchStatement)
{
WriteSwitchStatement(statement as SwitchStatement, programBuilder);
}
else if (statement is BreakStatement)
{
WriteBreakStatement(statement as BreakStatement, programBuilder);
}
}
}
开发者ID:jimmybanegas93,项目名称:CAsGen,代码行数:42,代码来源:Mips32Recompiler.cs
示例20: FixMethodParameters
protected virtual void FixMethodParameters(AstNodeCollection<ParameterDeclaration> parameters, BlockStatement body)
{
/*if (parameters.Count == 0)
{
return;
}
foreach (var p in parameters)
{
string newName = Emitter.FIX_ARGUMENT_NAME + p.Name;
string oldName = p.Name;
VariableDeclarationStatement varState = new VariableDeclarationStatement(p.Type.Clone(), oldName, new CastExpression(p.Type.Clone(), new IdentifierExpression(newName)));
p.Name = newName;
body.InsertChildBefore(body.FirstChild, varState, new Role<VariableDeclarationStatement>("Statement"));
}*/
}
开发者ID:txdv,项目名称:Builder,代码行数:20,代码来源:Inspector.cs
注:本文中的BlockStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论