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

#ifndef ERROR_H
#define ERROR_H

#include "types.h"

// Opaque type for a stack trace
typedef void *StackTrace;

// Prints a message to stderr and stops running
__attribute__((noreturn)) void abort_print(const char *msg);

// Creates a stack trace with a number of frames
StackTrace stacktrace_create(int frames);

// Pushes a frame to the stack trace
void stacktrace_push(StackTrace trace, const char *name);

// Pops the top frame from the stack trace
void stacktrace_pop(StackTrace trace);

// Prints the stacktrace to stderr
void stacktrace_print(StackTrace trace);

#endif