VariableReferenceNode GetStatementEndNode(VariableReferenceNode currentNode, Statement statement) { var expressions = statement.AcceptVisitor(getExpr); VariableReferenceNode endNode; ExpressionNodeCreationVisitor.CreateNode(references, resolver, expressions, currentNode, out endNode); return(endNode); }
object ConvertStatementInternal(Statement stmt) { Statement oldStatement = currentStatement; currentStatement = stmt; try { return stmt.AcceptVisitor(this, null); } finally { currentStatement = oldStatement; } }
/// <summary> /// Generates the code for the statement node. /// </summary> /// <param name="node">The statement node.</param> public void GenerateCode(Statement node) { try { node.AcceptVisitor(this); } catch (AnalizeException e) { generator.SwallowException(e); } }
object ConvertStatementInternal(Statement stmt) { Statement oldStatement = currentStatement; currentStatement = stmt; try { return(stmt.AcceptVisitor(this, null)); } finally { currentStatement = oldStatement; } }
ControlFlowNode HandleEmbeddedStatement(Statement embeddedStatement, ControlFlowNode source) { if (embeddedStatement == null || embeddedStatement.IsNull) { return(source); } ControlFlowNode bodyStart = builder.CreateStartNode(embeddedStatement); if (source != null) { Connect(source, bodyStart); } return(embeddedStatement.AcceptVisitor(this, bodyStart)); }
public IList <ControlFlowNode> BuildControlFlowGraph(Statement statement, CSharpAstResolver resolver, CancellationToken cancellationToken = default(CancellationToken)) { if (statement == null) { throw new ArgumentNullException("statement"); } if (resolver == null) { throw new ArgumentNullException("resolver"); } NodeCreationVisitor nodeCreationVisitor = new NodeCreationVisitor(); nodeCreationVisitor.builder = this; try { this.nodes = new List <ControlFlowNode>(); this.labels = new Dictionary <string, ControlFlowNode>(); this.gotoStatements = new List <ControlFlowNode>(); this.rootStatement = statement; this.resolver = resolver; this.cancellationToken = cancellationToken; ControlFlowNode entryPoint = CreateStartNode(statement); statement.AcceptVisitor(nodeCreationVisitor, entryPoint); // Resolve goto statements: foreach (ControlFlowNode gotoStmt in gotoStatements) { string label = ((GotoStatement)gotoStmt.NextStatement).Label; ControlFlowNode labelNode; if (labels.TryGetValue(label, out labelNode)) { nodeCreationVisitor.Connect(gotoStmt, labelNode, ControlFlowEdgeType.Jump); } } AnnotateLeaveEdgesWithTryFinallyBlocks(); return(nodes); } finally { this.nodes = null; this.labels = null; this.gotoStatements = null; this.rootStatement = null; this.resolver = null; this.cancellationToken = CancellationToken.None; } }
B.MacroStatement CreateMacro(INode node, string name, Statement embedded, params Expression[] arguments) { B.MacroStatement macro = new B.MacroStatement(GetLexicalInfo(node)); macro.Name = name; ConvertExpressions(arguments, macro.Arguments); if (embedded is BlockStatement) { macro.Body = ConvertBlock((BlockStatement)embedded); } else { macro.Body = new B.Block(); macro.Body.Add((B.Statement)embedded.AcceptVisitor(this, null)); } return(macro); }
internal IList <ControlFlowNode> BuildControlFlowGraph(Statement statement, Func <AstNode, CancellationToken, ResolveResult> resolver, CSharpTypeResolveContext typeResolveContext, CancellationToken cancellationToken) { NodeCreationVisitor nodeCreationVisitor = new NodeCreationVisitor(); nodeCreationVisitor.builder = this; try { this.nodes = new List <ControlFlowNode>(); this.labels = new Dictionary <string, ControlFlowNode>(); this.gotoStatements = new List <ControlFlowNode>(); this.rootStatement = statement; this.resolver = resolver; this.typeResolveContext = typeResolveContext; this.cancellationToken = cancellationToken; ControlFlowNode entryPoint = CreateStartNode(statement); statement.AcceptVisitor(nodeCreationVisitor, entryPoint); // Resolve goto statements: foreach (ControlFlowNode gotoStmt in gotoStatements) { string label = ((GotoStatement)gotoStmt.NextStatement).Label; ControlFlowNode labelNode; if (labels.TryGetValue(label, out labelNode)) { nodeCreationVisitor.Connect(gotoStmt, labelNode, ControlFlowEdgeType.Jump); } } AnnotateLeaveEdgesWithTryFinallyBlocks(); return(nodes); } finally { this.nodes = null; this.labels = null; this.gotoStatements = null; this.rootStatement = null; this.resolver = null; this.typeResolveContext = null; this.cancellationToken = CancellationToken.None; } }
void WriteEmbeddedStatement(Statement embeddedStatement) { if (embeddedStatement.IsNull) { NewLine(); return; } BlockStatement block = embeddedStatement as BlockStatement; if (block != null) { VisitBlockStatement(block); } else { NewLine(); formatter.Indent(); embeddedStatement.AcceptVisitor(this); formatter.Unindent(); } }
public JsBlockStatement Compile(Statement statement) { SetRegion(statement.GetRegion()); try { _result = new List<JsStatement>(); statement.AcceptVisitor(this); if (_result.Count == 1 && _result[0] is JsBlockStatement) return (JsBlockStatement)_result[0]; else return JsStatement.Block(_result); } catch (Exception ex) { _errorReporter.InternalError(ex); return JsStatement.EmptyBlock; } }
/// <summary> /// Writes an embedded statement. /// </summary> /// <param name="embeddedStatement">The statement to write.</param> /// <param name="nlp">Determines whether a trailing newline should be written following a block. /// Non-blocks always write a trailing newline.</param> /// <remarks> /// Blocks may or may not write a leading newline depending on StatementBraceStyle. /// Non-blocks always write a leading newline. /// </remarks> protected virtual void WriteEmbeddedStatement(Statement embeddedStatement, NewLinePlacement nlp = NewLinePlacement.NewLine) { if (embeddedStatement.IsNull) { NewLine(); return; } BlockStatement block = embeddedStatement as BlockStatement; if (block != null) { WriteBlock(block, policy.StatementBraceStyle); if (nlp == NewLinePlacement.SameLine) { Space(); // if not a trailing newline, then at least a trailing space } else { NewLine(); } } else { NewLine(); writer.Indent(); embeddedStatement.AcceptVisitor(this); writer.Unindent(); } }
private void WriteEmbeddedStatement(Statement statement) { var blockStatement = statement as BlockStatement; if (blockStatement != null) { VisitBlockStatement(blockStatement); } else { Formatter.WriteLine(); Formatter.Indent(); statement.AcceptVisitor(this); Formatter.Unindent(); } }
public JsBlockStatement Compile(Statement statement) { _filename = statement.GetRegion().FileName; try { _result = new List<JsStatement>(); statement.AcceptVisitor(this); if (_result.Count == 1 && _result[0] is JsBlockStatement) return (JsBlockStatement)_result[0]; else return new JsBlockStatement(_result); } catch (Exception ex) { _errorReporter.InternalError(ex, _filename, _location); return new JsBlockStatement(); } }
bool IsRecursive(Statement statement) { return(recursiveDetectorVisitor != null && statement.AcceptVisitor(recursiveDetectorVisitor)); }
B.MacroStatement CreateMacro(INode node, string name, Statement embedded, params Expression[] arguments) { B.MacroStatement macro = new B.MacroStatement(GetLexicalInfo(node)); macro.Name = name; ConvertExpressions(arguments, macro.Arguments); if (embedded is BlockStatement) { macro.Body = ConvertBlock((BlockStatement)embedded); } else { macro.Body = new B.Block(); macro.Body.Add((B.Statement)embedded.AcceptVisitor(this, null)); } return macro; }