Пример #1
0
 public override void write_declaration(CCodeWriter writer)
 {
     foreach (CCodeNode node in children)
     {
         node.write_declaration(writer);
     }
 }
Пример #2
0
 public override void write(CCodeWriter writer)
 {
     container.write_inner(writer);
     writer.write_string("[");
     index.write(writer);
     writer.write_string("]");
 }
Пример #3
0
        public override void write(CCodeWriter writer)
        {
            call.write_inner(writer);
            writer.write_string(" (");

            bool first = true;

            foreach (CCodeExpression expr in arguments)
            {
                if (!first)
                {
                    writer.write_string(", ");
                }
                else
                {
                    first = false;
                }

                if (expr != null)
                {
                    expr.write(writer);
                }
            }

            writer.write_string(")");
        }
Пример #4
0
        public override void write(CCodeWriter writer)
        {
            writer.write_string("{");

            bool first = true;

            foreach (CCodeExpression expr in initializers)
            {
                if (!first)
                {
                    writer.write_string(", ");
                }
                else
                {
                    first = false;
                }

                if (expr != null)
                {
                    expr.write(writer);
                }
            }

            writer.write_string("}");
        }
Пример #5
0
 public override void write_combined(CCodeWriter writer)
 {
     foreach (CCodeNode node in children)
     {
         node.write_combined(writer);
     }
 }
Пример #6
0
 public override void write(CCodeWriter writer)
 {
     writer.write_indent();
     writer.write_string(name);
     writer.write_string(":");
     writer.write_newline();
 }
Пример #7
0
 public override void write(CCodeWriter writer)
 {
     if (!writer.bol)
     {
         writer.write_newline();
     }
     writer.write_string("#line %d \"%s\"".printf(line_number, filename));
     writer.write_newline();
 }
Пример #8
0
 public override void write(CCodeWriter writer)
 {
     if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.INTERNAL | CCodeModifiers.EXTERN)) == 0)
     {
         foreach (CCodeDeclarator decl in declarators)
         {
             decl.write_initialization(writer);
         }
     }
 }
Пример #9
0
        public override void write_declaration(CCodeWriter writer)
        {
            writer.write_string("(*");
            writer.write_string(name);
            writer.write_string(") (");

            bool has_args         = (modifiers.HasFlag(CCodeModifiers.PRINTF) || modifiers.HasFlag(CCodeModifiers.SCANF));
            int  i                = 0;
            int  format_arg_index = -1;
            int  args_index       = -1;

            foreach (CCodeParameter param in parameters)
            {
                if (i > 0)
                {
                    writer.write_string(", ");
                }
                param.write(writer);
                if (param.modifiers.HasFlag(CCodeModifiers.FORMAT_ARG))
                {
                    format_arg_index = i;
                }
                if (has_args && param.ellipsis)
                {
                    args_index = i;
                }
                else if (has_args && param.type_name == "va_list" && format_arg_index < 0)
                {
                    format_arg_index = i - 1;
                }
                i++;
            }

            writer.write_string(")");

            if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
            {
                writer.write_string(" G_GNUC_DEPRECATED");
            }

            if (modifiers.HasFlag(CCodeModifiers.PRINTF))
            {
                format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index);
                writer.write_string(" G_GNUC_PRINTF(%d,%d)".printf(format_arg_index, args_index + 1));
            }
            else if (modifiers.HasFlag(CCodeModifiers.SCANF))
            {
                format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index);
                writer.write_string(" G_GNUC_SCANF(%d,%d)".printf(format_arg_index, args_index + 1));
            }
            else if (format_arg_index >= 0)
            {
                writer.write_string(" G_GNUC_FORMAT(%d)".printf(format_arg_index + 1));
            }
        }
Пример #10
0
 public void write(CCodeWriter writer)
 {
     if (array)
     {
         writer.write_string("[");
         if (array_length != null)
         {
             array_length.write(writer);
         }
         writer.write_string("]");
     }
 }
Пример #11
0
		public override void write(CCodeWriter writer) {
			writer.write_string(name);
			if (modifiers.HasFlag(CCodeModifiers.DEPRECATED)) {
				// FIXME Requires GCC 6.0 to work at this place
				// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47043
				//writer.write_string (" G_GNUC_DEPRECATED");
			}
			if (value != null) {
				writer.write_string(" = ");
				value.write(writer);
			}
		}
Пример #12
0
 public override void write(CCodeWriter writer)
 {
     inner.write_inner(writer);
     if (is_pointer)
     {
         writer.write_string("->");
     }
     else
     {
         writer.write_string(".");
     }
     writer.write_string(member_name);
 }
Пример #13
0
 public override void write(CCodeWriter writer)
 {
     writer.write_string("G_GNUC_BEGIN_");
     writer.write_string(section_type.ToString());
     writer.write_newline();
     foreach (CCodeNode node in get_children())
     {
         node.write_combined(writer);
     }
     writer.write_string("G_GNUC_END_");
     writer.write_string(section_type.ToString());
     writer.write_newline();
 }
Пример #14
0
 public override void write(CCodeWriter writer)
 {
     if (!ellipsis)
     {
         writer.write_string(type_name);
         writer.write_string(" ");
         writer.write_string(name);
     }
     else
     {
         writer.write_string("...");
     }
 }
Пример #15
0
        public override void write(CCodeWriter writer)
        {
            left.write(writer);

            writer.write_string(" ");

            if (Operator == CCodeAssignmentOperator.BITWISE_OR)
            {
                writer.write_string("|");
            }
            else if (Operator == CCodeAssignmentOperator.BITWISE_AND)
            {
                writer.write_string("&");
            }
            else if (Operator == CCodeAssignmentOperator.BITWISE_XOR)
            {
                writer.write_string("^");
            }
            else if (Operator == CCodeAssignmentOperator.ADD)
            {
                writer.write_string("+");
            }
            else if (Operator == CCodeAssignmentOperator.SUB)
            {
                writer.write_string("-");
            }
            else if (Operator == CCodeAssignmentOperator.MUL)
            {
                writer.write_string("*");
            }
            else if (Operator == CCodeAssignmentOperator.DIV)
            {
                writer.write_string("/");
            }
            else if (Operator == CCodeAssignmentOperator.PERCENT)
            {
                writer.write_string("%");
            }
            else if (Operator == CCodeAssignmentOperator.SHIFT_LEFT)
            {
                writer.write_string("<<");
            }
            else if (Operator == CCodeAssignmentOperator.SHIFT_RIGHT)
            {
                writer.write_string(">>");
            }

            writer.write_string("= ");

            right.write(writer);
        }
Пример #16
0
        public override void write_initialization(CCodeWriter writer)
        {
            if (initializer != null && !init0)
            {
                writer.write_indent(line);

                writer.write_string(name);
                writer.write_string(" = ");
                initializer.write(writer);

                writer.write_string(";");
                writer.write_newline();
            }
        }
Пример #17
0
        public override void write_declaration(CCodeWriter writer)
        {
            writer.write_string(name);

            if (declarator_suffix != null)
            {
                declarator_suffix.write(writer);
            }

            if (initializer != null && init0)
            {
                writer.write_string(" = ");
                initializer.write(writer);
            }
        }
Пример #18
0
 public override void write(CCodeWriter writer)
 {
     writer.write_indent();
     writer.write_string("#define ");
     writer.write_string(name);
     writer.write_string(" ");
     if (replacement != null)
     {
         writer.write_string(replacement);
     }
     else
     {
         replacement_expression.write_inner(writer);
     }
     writer.write_newline();
 }
Пример #19
0
 public override void write(CCodeWriter writer)
 {
     writer.write_indent();
     writer.write_string("#ifndef ");
     writer.write_string(define);
     writer.write_newline();
     writer.write_string("#define ");
     writer.write_string(define);
     writer.write_newline();
     foreach (CCodeNode node in get_children())
     {
         node.write_combined(writer);
     }
     writer.write_indent();
     writer.write_string("#endif");
     writer.write_newline();
 }
Пример #20
0
 public override void write(CCodeWriter writer)
 {
     writer.write_indent();
     writer.write_string("#include ");
     if (local)
     {
         writer.write_string("\"");
         writer.write_string(filename);
         writer.write_string("\"");
     }
     else
     {
         writer.write_string("<");
         writer.write_string(filename);
         writer.write_string(">");
     }
     writer.write_newline();
 }
Пример #21
0
        public override void write_declaration(CCodeWriter writer)
        {
            writer.write_indent();
            writer.write_string("typedef ");

            writer.write_string(type_name);

            writer.write_string(" ");

            declarator.write_declaration(writer);

            if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
            {
                writer.write_string(" G_GNUC_DEPRECATED");
            }

            writer.write_string(";");
            writer.write_newline();
        }
Пример #22
0
        public override void write(CCodeWriter writer)
        {
            writer.write_string("struct ");
            writer.write_string(name);
            writer.write_begin_block();
            foreach (CCodeDeclaration decl in declarations)
            {
                decl.write_declaration(writer);
            }

            writer.write_end_block();
            if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
            {
                writer.write_string(" G_GNUC_DEPRECATED");
            }
            writer.write_string(";");
            writer.write_newline();
            writer.write_newline();
        }
Пример #23
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();
            }
        }
Пример #24
0
 public override void write(CCodeWriter writer)
 {
     writer.write_comment(text);
 }
Пример #25
0
        public override void write(CCodeWriter writer)
        {
            writer.write_indent(line);
            if (modifiers.HasFlag(CCodeModifiers.INTERNAL))
            {
                writer.write_string("G_GNUC_INTERNAL ");
            }
            if (modifiers.HasFlag(CCodeModifiers.STATIC))
            {
                writer.write_string("static ");
            }
            if (modifiers.HasFlag(CCodeModifiers.INLINE))
            {
                writer.write_string("inline ");
            }
            writer.write_string(return_type);
            writer.write_string(" ");
            writer.write_string(name);
            writer.write_string(" (");

            bool has_args         = (modifiers.HasFlag(CCodeModifiers.PRINTF) || modifiers.HasFlag(CCodeModifiers.SCANF));
            int  i                = 0;
            int  format_arg_index = -1;
            int  args_index       = -1;

            foreach (CCodeParameter param in parameters)
            {
                if (i > 0)
                {
                    writer.write_string(", ");
                }
                param.write(writer);
                if (param.modifiers.HasFlag(CCodeModifiers.FORMAT_ARG))
                {
                    format_arg_index = i;
                }
                if (has_args && param.ellipsis)
                {
                    args_index = i;
                }
                else if (has_args && param.type_name == "va_list" && format_arg_index < 0)
                {
                    format_arg_index = i - 1;
                }
                i++;
            }
            if (i == 0)
            {
                writer.write_string("void");
            }

            writer.write_string(")");

            if (is_declaration)
            {
                if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
                {
                    writer.write_string(" G_GNUC_DEPRECATED");
                }

                if (modifiers.HasFlag(CCodeModifiers.PRINTF))
                {
                    format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index);
                    writer.write_string(" G_GNUC_PRINTF(%d,%d)".printf(format_arg_index, args_index + 1));
                }
                else if (modifiers.HasFlag(CCodeModifiers.SCANF))
                {
                    format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index);
                    writer.write_string(" G_GNUC_SCANF(%d,%d)".printf(format_arg_index, args_index + 1));
                }
                else if (format_arg_index >= 0)
                {
                    writer.write_string(" G_GNUC_FORMAT(%d)".printf(format_arg_index + 1));
                }

                if (modifiers.HasFlag(CCodeModifiers.CONST))
                {
                    writer.write_string(" G_GNUC_CONST");
                }
                if (modifiers.HasFlag(CCodeModifiers.UNUSED))
                {
                    writer.write_string(" G_GNUC_UNUSED");
                }

                if (modifiers.HasFlag(CCodeModifiers.CONSTRUCTOR))
                {
                    writer.write_string(" __attribute__((constructor))");
                }
                else if (modifiers.HasFlag(CCodeModifiers.DESTRUCTOR))
                {
                    writer.write_string(" __attribute__((destructor))");
                }

                writer.write_string(";");
            }
            else
            {
                block.write(writer);
                writer.write_newline();
            }
            writer.write_newline();
        }
Пример #26
0
 public override void write(CCodeWriter writer)
 {
     writer.write_string(name);
 }
Пример #27
0
 public override void write(CCodeWriter writer)
 {
     writer.write_newline();
 }
Пример #28
0
 /// <summary>
 /// Writes declaration and implementation combined for this code node and
 /// all children with the specified C code writer.
 ///
 /// <param name="writer">a C code writer</param>
 /// </summary>
 public virtual void write_combined(CCodeWriter writer)
 {
     write_declaration(writer);
     write(writer);
 }
Пример #29
0
 /// <summary>
 /// Writes declaration for this code node with the specified C code
 /// writer if necessary.
 ///
 /// <param name="writer">a C code writer</param>
 /// </summary>
 public virtual void write_declaration(CCodeWriter writer)
 {
 }
Пример #30
0
 /// <summary>
 /// Writes this code node and all children with the specified C code
 /// writer.
 ///
 /// <param name="writer">a C code writer</param>
 /// </summary>
 public abstract void write(CCodeWriter writer);