فهرست منبع

added set_thread_flags + EXC_KILL

Nicolas Cannasse 2 سال پیش
والد
کامیت
a2fa213c27
3فایلهای تغییر یافته به همراه9 افزوده شده و 0 حذف شده
  1. 6 0
      src/gc.c
  2. 1 0
      src/hl.h
  3. 2 0
      src/std/error.c

+ 6 - 0
src/gc.c

@@ -1288,6 +1288,11 @@ HL_API void hl_gc_set_flags( int f ) {
 	gc_flags = f;
 }
 
+HL_API void hl_set_thread_flags( int flags, int mask ) {
+	hl_thread_info *t = hl_get_thread();
+	t->flags = (t->flags & ~mask) | flags;
+}
+
 HL_API void hl_gc_profile( bool b ) {
 	if( b )
 		gc_flags |= GC_PROFILE;
@@ -1419,3 +1424,4 @@ DEFINE_PRIM(_I32, gc_get_flags, _NO_ARG);
 DEFINE_PRIM(_VOID, gc_set_flags, _I32);
 DEFINE_PRIM(_DYN, debug_call, _I32 _DYN);
 DEFINE_PRIM(_VOID, blocking, _BOOL);
+DEFINE_PRIM(_VOID, set_thread_flags, _I32 _I32);

+ 1 - 0
src/hl.h

@@ -903,6 +903,7 @@ struct _hl_trap_ctx {
 #define HL_EXC_IS_THROW		4
 #define HL_THREAD_INVISIBLE	16
 #define HL_THREAD_PROFILER_PAUSED 32
+#define HL_EXC_KILL			64
 #define HL_TREAD_TRACK_SHIFT 16
 
 #define HL_TRACK_ALLOC		1

+ 2 - 0
src/std/error.c

@@ -92,6 +92,8 @@ HL_PRIM void hl_throw( vdynamic *v ) {
 	hl_thread_info *t = hl_get_thread();
 	hl_trap_ctx *trap = t->trap_current;
 	bool call_handler = false;
+	if( t->flags & HL_EXC_KILL )
+		hl_fatal("Exception Occured");
 	if( !(t->flags & HL_EXC_RETHROW) )
 		t->exc_stack_count = capture_stack_func(t->exc_stack_trace, HL_EXC_MAX_STACK);
 	t->exc_value = v;