Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
 public void add_statement(CCodeNode stmt)
 {
     stmt.line = current_line;
     current_block.add_statement(stmt);
 }
Ejemplo n.º 3
0
 public void add_type_member_definition(CCodeNode node)
 {
     type_member_definition.append(node);
 }
Ejemplo n.º 4
0
 public void add_constant_declaration(CCodeNode node)
 {
     constant_declaration.append(node);
 }
Ejemplo n.º 5
0
 public void add_type_declaration(CCodeNode node)
 {
     type_declaration.append(node);
 }
Ejemplo n.º 6
0
 /// <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);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Prepend the specified statement to the list of statements.
 /// </summary>
 public void prepend_statement(CCodeNode statement)
 {
     statements.Insert(0, statement);
 }
Ejemplo n.º 8
0
 /// <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);
 }