diff options
Diffstat (limited to 'lib/DATS/init.dats')
-rw-r--r-- | lib/DATS/init.dats | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/lib/DATS/init.dats b/lib/DATS/init.dats index a4c84b3..cfdc12e 100644 --- a/lib/DATS/init.dats +++ b/lib/DATS/init.dats @@ -1,3 +1,4 @@ +#include "share/atspre_staload.hats" staload "lib/SATS/init.sats" #define ATS_DYNLOADFLAG 0 @@ -9,15 +10,50 @@ in end -implement{vt} init_exec (x) = - if x.initialized then +implement{vt} exec_void (r) = let + val (vbox pf | p) = ref_get_viewptr{initializable vt}(r) +in + if p->initialized then let - prval () = opt_unsome x.obj - val () = init_exec$fwork (x.obj) - prval () = opt_some x.obj + prval () = opt_unsome p->obj + val () = exec_void$fwork (p->obj) + prval () = opt_some p->obj in end +end -implement{vt} init_exec$fwork (v) = () +implement{vt} exec_void$fwork (v) = () + +implement{vt} {a} exec (r,default) = 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) + prval () = opt_some p->obj + in + a + end + else + default +end +implement{vt} {a} exec$fwork (v,default) = default + +implement{vt} initialize (r) = let + val (vbox pf | p) = ref_get_viewptr{initializable vt}(r) +in + if (not p->initialized) then + let + prval () = opt_unnone p->obj + val () = p->initialized := initialize$fwork(p->obj) + in end +end + +implement{vt} initialize$fwork (v) = let + prval () = opt_none v +in + false +end |