ivy-diag is used for generating and emitting diagnostic messages during compilation.
27 lines
619 B
C
27 lines
619 B
C
#include "write.h"
|
|
|
|
#include <ivy/diag.h>
|
|
|
|
extern struct diag_writer pretty_writer;
|
|
|
|
static const struct diag_writer *writers[] = {
|
|
[IVY_DIAG_FORMAT_PRETTY] = &pretty_writer,
|
|
};
|
|
static const size_t nr_writers = sizeof writers / sizeof writers[0];
|
|
|
|
enum ivy_status diag_write(
|
|
struct ivy_diag_ctx *ctx, struct ivy_diag *diag,
|
|
enum ivy_diag_format format, struct ivy_diag_stream *stream)
|
|
{
|
|
if (format < 0 || format >= nr_writers) {
|
|
return IVY_ERR_INVALID_VALUE;
|
|
}
|
|
|
|
const struct diag_writer *writer = writers[format];
|
|
if (!writer) {
|
|
return IVY_ERR_INVALID_VALUE;
|
|
}
|
|
|
|
return writer->write(ctx, diag, stream);
|
|
}
|