Newer
Older
Tardis / lang / error.c
// SPDX-License-Identifier: MIT
// Copyright (c) 2023 John Watts and the LuminaSensum contributors

#include "error.h"
#include <stdio.h>
#include <stdlib.h>

// Aborts the program with a message
__attribute__((noreturn)) void abort_msg(VmState state, const char *msg) {
	(void)state;
	fprintf(stderr, "ERROR: %s\n", msg);
	abort();
}

// Aborts the program if a value is true
void abort_if(VmState state, int value, const char *msg) {
	if (value) {
		abort_msg(state, msg);
	}
}