Login
7 branches 0 tags
Ben (Win10) Better array out-of-bounds exception message 10386d0 3 years ago 600 Commits
nujel / lib / exception.h
#ifndef NUJEL_LIB_EXCEPTION
#define NUJEL_LIB_EXCEPTION

#include "nujel.h"
#include <setjmp.h>

extern jmp_buf exceptionTarget;
extern lVal *exceptionValue;
extern int exceptionTargetDepth;

extern bool breakQueued;

void  lExceptionThrowRaw    (lVal *v) NORETURN;
void  lExceptionThrow       (const char *symbol, const char *error) NORETURN;
void  lExceptionThrowVal    (const char *symbol, const char *error, lVal *v) NORETURN;
void  lExceptionThrowValClo (const char *symbol, const char *error, lVal *v, lClosure *c) NORETURN;
void *lExceptionTryExit     (void *(*body)(void *,void *), void *a, void *b);
void *lExceptionTryCatch    (void *(*body)(void *,void *), void *a, void *b, void (*handler)(lVal *exceptionValue));

static inline void lCheckBreak(){
        if(!breakQueued){return;}
	breakQueued = false;
	lExceptionThrow(":break","A break has been triggered");
}

#endif