public override void write_declaration(CCodeWriter writer) { foreach (CCodeNode node in children) { node.write_declaration(writer); } }
public override void write(CCodeWriter writer) { container.write_inner(writer); writer.write_string("["); index.write(writer); writer.write_string("]"); }
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(")"); }
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("}"); }
public override void write_combined(CCodeWriter writer) { foreach (CCodeNode node in children) { node.write_combined(writer); } }
public override void write(CCodeWriter writer) { writer.write_indent(); writer.write_string(name); writer.write_string(":"); writer.write_newline(); }
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(); }
public override void write(CCodeWriter writer) { if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.INTERNAL | CCodeModifiers.EXTERN)) == 0) { foreach (CCodeDeclarator decl in declarators) { decl.write_initialization(writer); } } }
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)); } }
public void write(CCodeWriter writer) { if (array) { writer.write_string("["); if (array_length != null) { array_length.write(writer); } writer.write_string("]"); } }
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); } }
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); }
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(); }
public override void write(CCodeWriter writer) { if (!ellipsis) { writer.write_string(type_name); writer.write_string(" "); writer.write_string(name); } else { writer.write_string("..."); } }
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); }
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(); } }
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); } }
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(); }
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(); }
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(); }
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(); }
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(); }
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 override void write(CCodeWriter writer) { writer.write_comment(text); }
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(); }
public override void write(CCodeWriter writer) { writer.write_string(name); }
public override void write(CCodeWriter writer) { writer.write_newline(); }
/// <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); }
/// <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) { }
/// <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);