Пример #1
0
/**
 * Prints the prefix part of a type.
 *
 * @param type   The type.
 */
static void intern_print_type_pre(const type_t *const type)
{
	switch (type->kind) {
	case TYPE_ARRAY:           print_array_type_pre(          &type->array);     return;
	case TYPE_ATOMIC:          print_atomic_type(             &type->atomic);    return;
	case TYPE_COMPLEX:         print_complex_type(            &type->atomic);    return;
	case TYPE_COMPOUND_STRUCT: print_compound_type("struct ", &type->compound);  return;
	case TYPE_COMPOUND_UNION:  print_compound_type("union ",  &type->compound);  return;
	case TYPE_ENUM:            print_type_enum(               &type->enumt);     return;
	case TYPE_ERROR:           print_string("<error>");                          return;
	case TYPE_FUNCTION:        print_function_type_pre(       &type->function);  return;
	case TYPE_IMAGINARY:       print_imaginary_type(          &type->atomic);    return;
	case TYPE_POINTER:         print_pointer_type_pre(        &type->pointer);   return;
	case TYPE_REFERENCE:       print_reference_type_pre(      &type->reference); return;
	case TYPE_TYPEDEF:         print_typedef_type_pre(        &type->typedeft);  return;
	case TYPE_TYPEOF:          print_typeof_type_pre(         &type->typeoft);   return;
	case TYPE_VOID:            print_void_type_pre(            type);            return;
	case TYPE_BUILTIN_TEMPLATE: print_template_type_pre(       type);            return;
	}
	print_string("unknown");
}
Пример #2
0
void print_type(const type_t *type)
{
	if (type == NULL) {
		fputs("nil type", out);
		return;
	}

	switch (type->kind) {
	case TYPE_INVALID:
		fputs("invalid", out);
		return;
	case TYPE_TYPEOF: {
		const typeof_type_t *typeof_type = (const typeof_type_t*) type;
		fputs("typeof(", out);
		print_expression(typeof_type->expression);
		fputs(")", out);
		return;
	}
	case TYPE_ERROR:
		fputs("error", out);
		return;
	case TYPE_VOID:
		fputs("void", out);
		return;
	case TYPE_ATOMIC:
		print_atomic_type(&type->atomic);
		return;
	case TYPE_COMPOUND_UNION:
	case TYPE_COMPOUND_STRUCT:
		print_compound_type(&type->compound);
		return;
	case TYPE_FUNCTION:
		print_function_type(&type->function);
		return;
	case TYPE_POINTER:
		print_pointer_type(&type->pointer);
		return;
	case TYPE_ARRAY:
		print_array_type(&type->array);
		return;
	case TYPE_REFERENCE:
		print_type_reference(&type->reference);
		return;
	case TYPE_REFERENCE_TYPE_VARIABLE:
		print_type_reference_variable(&type->reference);
		return;
	case TYPE_BIND_TYPEVARIABLES:
		print_bind_type_variables(&type->bind_typevariables);
		return;
	}
	fputs("unknown", out);
}