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