diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/DATS/init.dats | 23 | ||||
-rw-r--r-- | lib/DATS/panic.dats | 24 | ||||
-rw-r--r-- | lib/SATS/init.sats | 4 | ||||
-rw-r--r-- | lib/SATS/panic.sats | 5 |
4 files changed, 47 insertions, 9 deletions
diff --git a/lib/DATS/init.dats b/lib/DATS/init.dats index cfdc12e..c2ae39d 100644 --- a/lib/DATS/init.dats +++ b/lib/DATS/init.dats @@ -1,5 +1,7 @@ #include "share/atspre_staload.hats" staload "lib/SATS/init.sats" +staload "lib/SATS/panic.sats" +staload UN = "prelude/SATS/unsafe.sats" #define ATS_DYNLOADFLAG 0 @@ -20,26 +22,33 @@ in prval () = opt_some p->obj in end + else + panic("Not initialized") end -implement{vt} exec_void$fwork (v) = () +implement{vt} exec_void$fwork (v) = panic("Not overloaded") -implement{vt} {a} exec (r,default) = let +implement{vt} {a} exec (r) = let val (vbox pf | p) = ref_get_viewptr{initializable vt}(r) in if p->initialized then let prval () = opt_unsome p->obj - val a = exec$fwork (p->obj,default) + val out = exec$fwork<vt><a> (p->obj) prval () = opt_some p->obj in - a + out end - else - default + else ( + panic("Not inialized"); + $UN.ptr0_get<a>(the_null_ptr) + ) end -implement{vt} {a} exec$fwork (v,default) = default +implement{vt} {a} exec$fwork (v) = ( + (panic("Not overloaded")); + $UN.ptr0_get<a>(the_null_ptr) +) implement{vt} initialize (r) = let val (vbox pf | p) = ref_get_viewptr{initializable vt}(r) diff --git a/lib/DATS/panic.dats b/lib/DATS/panic.dats new file mode 100644 index 0000000..356eda5 --- /dev/null +++ b/lib/DATS/panic.dats @@ -0,0 +1,24 @@ +staload "lib/SATS/panic.sats" +staload "lib/SATS/writer.sats" + +staload UN = "prelude/SATS/unsafe.sats" + +#define ATS_DYNLOADFLAG 0 + +%{$ + inline void halt() { + while (1){ + __asm__ volatile ("cli ; hlt"); + } + } +%} + +extern fun halt():<!ntm> void = "mac#" + +implement panic_loc(loc,msg) = ( + put_string "KERNEL PANIC:\n "; + put_string loc; + put_string "\n\n "; + put_string msg; + halt(); +) diff --git a/lib/SATS/init.sats b/lib/SATS/init.sats index 9261ca9..69c6c9a 100644 --- a/lib/SATS/init.sats +++ b/lib/SATS/init.sats @@ -6,8 +6,8 @@ fun {vt:viewt@ype} uninitialized (v : opt(vt,false)): initializable vt fun {vt:viewt@ype} exec_void (r: ref(initializable vt)):<!refwrt> void fun {vt:viewt@ype} exec_void$fwork (v : &vt):<!wrt> void -fun {vt:viewt@ype} {a: t@ype} exec (r: ref(initializable vt), default: a):<!refwrt> a -fun {vt:viewt@ype} {a: t@ype} exec$fwork (v : &vt, default: a):<!wrt> a +fun {vt:viewt@ype} {a: t@ype} exec (r: ref(initializable vt)):<!refwrt> a +fun {vt:viewt@ype} {a: t@ype} exec$fwork (v : &vt):<!wrt> a fun {vt:viewt@ype} initialize (r: ref(initializable vt)):<!ref,!wrt> void fun {vt:viewt@ype} initialize$fwork (v: &vt? >> opt(vt,success)):<!wrt> #[success : bool] bool success diff --git a/lib/SATS/panic.sats b/lib/SATS/panic.sats new file mode 100644 index 0000000..123b8da --- /dev/null +++ b/lib/SATS/panic.sats @@ -0,0 +1,5 @@ +staload UN = "prelude/SATS/unsafe.sats" + +fun panic_loc (loc: string, msg: string) :<> void + +macdef panic(msg) = panic_loc($mylocation, ,(msg)) |