public override void write(CCodeWriter writer) { // the last reachable statement CCodeNode last_statement = null; writer.write_begin_block(); foreach (CCodeNode statement in statements) { statement.write_declaration(writer); // determine last reachable statement if (statement is CCodeLabel || statement is CCodeCaseStatement) { last_statement = null; } else if (statement is CCodeReturnStatement || statement is CCodeGotoStatement || statement is CCodeContinueStatement || statement is CCodeBreakStatement) { last_statement = statement; } } foreach (CCodeNode statement in statements) { statement.write(writer); // only output reachable code if (statement == last_statement) { break; } } writer.write_end_block(); if (!suppress_newline) { writer.write_newline(); } }
public void add_statement(CCodeNode stmt) { stmt.line = current_line; current_block.add_statement(stmt); }
public void add_type_member_definition(CCodeNode node) { type_member_definition.append(node); }
public void add_constant_declaration(CCodeNode node) { constant_declaration.append(node); }
public void add_type_declaration(CCodeNode node) { type_declaration.append(node); }
/// <summary> /// Append the specified statement to the list of statements. /// </summary> public void add_statement(CCodeNode statement) { /* allow generic nodes to include comments */ statements.Add(statement); }
/// <summary> /// Prepend the specified statement to the list of statements. /// </summary> public void prepend_statement(CCodeNode statement) { statements.Insert(0, statement); }
/// <summary> /// Appends the specified code node to this code fragment. /// /// <param name="node">a C code node</param> /// </summary> public void append(CCodeNode node) { children.Add(node); }