/** * Print the first part (the prefix) of a type. * * @param type The type to print. */ static void print_function_type_pre(const function_type_t *type) { switch (type->linkage) { case LINKAGE_C: if (dialect.cpp) print_string("extern \"C\" "); break; case LINKAGE_CXX: if (!dialect.cpp) print_string("extern \"C++\" "); break; } print_type_qualifiers(type->base.qualifiers, QUAL_SEP_END); intern_print_type_pre(type->return_type); cc_kind_t cc = type->calling_convention; restart: switch (cc) { case CC_CDECL: print_string(" __cdecl"); break; case CC_STDCALL: print_string(" __stdcall"); break; case CC_FASTCALL: print_string(" __fastcall"); break; case CC_THISCALL: print_string(" __thiscall"); break; case CC_DEFAULT: if (default_calling_convention != CC_CDECL) { /* show the default calling convention if its not cdecl */ cc = default_calling_convention; goto restart; } break; } }
/** * Prints the prefix part of a reference type. * * @param type The reference type. */ static void print_reference_type_pre(const reference_type_t *type) { type_t const *const refers_to = type->refers_to; intern_print_type_pre(refers_to); if (refers_to->kind == TYPE_ARRAY || refers_to->kind == TYPE_FUNCTION) print_string(" ("); print_char('&'); }
/** * Prints the prefix part of a pointer type. * * @param type The pointer type. */ static void print_pointer_type_pre(const pointer_type_t *type) { type_t const *const points_to = type->points_to; intern_print_type_pre(points_to); if (points_to->kind == TYPE_ARRAY || points_to->kind == TYPE_FUNCTION) print_string(" ("); print_char('*'); print_type_qualifiers(type->base.qualifiers, QUAL_SEP_START); }
/** * Prints the prefix part of a pointer type. * * @param type The pointer type. */ static void print_pointer_type_pre(const pointer_type_t *type) { type_t const *const points_to = type->points_to; if (type->base.qualifiers & TYPE_QUALIFIER_CONST) { print_string("*const "); } else { print_string("*mut "); } intern_print_type_pre(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 prefix part of a pointer type. * * @param type The pointer type. */ static void print_pointer_type_pre(const pointer_type_t *type) { type_t const *const points_to = type->points_to; intern_print_type_pre(points_to); if (points_to->kind == TYPE_ARRAY || points_to->kind == TYPE_FUNCTION) print_string(" ("); variable_t *const variable = type->base_variable; if (variable != NULL) { print_string(" __based("); print_string(variable->base.base.symbol->string); print_string(") "); } print_char('*'); print_type_qualifiers(type->base.qualifiers, QUAL_SEP_START); }
/** * Prints the prefix part of an array type. * * @param type The array type. */ static void print_array_type_pre(const array_type_t *type) { intern_print_type_pre(type->element_type); }