/** * Prints the postfix part of a reference type. * * @param type The reference type. */ static void print_reference_type_post(const reference_type_t *type) { type_t const *const refers_to = type->refers_to; if (refers_to->kind == TYPE_ARRAY || refers_to->kind == TYPE_FUNCTION) print_char(')'); intern_print_type_post(refers_to); }
/** * Prints the postfix part of a pointer type. * * @param type The pointer type. */ static void print_pointer_type_post(const pointer_type_t *type) { type_t const *const points_to = type->points_to; if (points_to->kind == TYPE_ARRAY || points_to->kind == TYPE_FUNCTION) print_char(')'); intern_print_type_post(points_to); }
void print_type_ext(const type_t *const type, const symbol_t *symbol, const scope_t *parameters) { intern_print_type_pre(type); if (symbol != NULL) { print_char(' '); print_string(symbol->string); } if (type->kind == TYPE_FUNCTION) { print_function_type_post(&type->function, parameters); } else { intern_print_type_post(type); } }
/** * Prints the postfix part of an array type. * * @param type The array type. */ static void print_array_type_post(const array_type_t *type) { print_char('['); if (type->is_static) { print_string("static "); } print_type_qualifiers(type->base.qualifiers, QUAL_SEP_END); if (type->size_expression != NULL && (print_implicit_array_size || !type->has_implicit_size)) { print_expression(type->size_expression); } print_char(']'); intern_print_type_post(type->element_type); }
/** * Print the second part (the postfix) of a type. * * @param type The type to print. */ static void print_function_type_post(const function_type_t *type, const scope_t *parameters) { print_string("("); bool first = true; if (parameters == NULL) { function_parameter_t *parameter = type->parameters; for( ; parameter != NULL; parameter = parameter->next) { if (first) { first = false; } else { print_string(", "); } print_type(parameter->type); } } else { entity_t *parameter = parameters->entities; for (; parameter != NULL; parameter = parameter->base.next) { if (parameter->kind != ENTITY_PARAMETER) continue; if (first) { first = false; } else { print_string(", "); } const type_t *const param_type = parameter->declaration.type; if (param_type == NULL) { print_string(parameter->base.symbol->string); } else { print_type_ext(param_type, parameter->base.symbol, NULL); } } } if (type->variadic) { if (first) { first = false; } else { print_string(", "); } print_string("..."); } if (first && !type->unspecified_parameters) { print_string("void"); } print_string(")"); intern_print_type_post(type->return_type); }
/** * Print the second part (the postfix) of a type. * * @param type The type to print. */ static void print_function_type_post(const function_type_t *type, const scope_t *parameters) { print_char('('); separator_t sep = { "", ", " }; if (parameters == NULL) { function_parameter_t *parameter = type->parameters; for ( ; parameter != NULL; parameter = parameter->next) { print_string(sep_next(&sep)); print_type(parameter->type); } } else { for (entity_t const *parameter = parameters->first_entity; parameter != NULL; parameter = parameter->base.next) { if (parameter->kind != ENTITY_PARAMETER) continue; print_string(sep_next(&sep)); const type_t *const param_type = parameter->declaration.type; if (param_type == NULL) { print_string(parameter->base.symbol->string); } else { print_type_ext(param_type, parameter->base.symbol, NULL); } } } if (type->variadic) { print_string(sep_next(&sep)); print_string("..."); } if (sep_at_first(&sep) && !type->unspecified_parameters) { print_string("void"); } print_char(')'); print_modifiers(type->modifiers); intern_print_type_post(type->return_type); }