aboutsummaryrefslogtreecommitdiff
path: root/lib/DATS/init.dats
diff options
context:
space:
mode:
authorXander <xander@biltopia.org>2023-07-28 21:38:35 +0200
committerXander <xander@biltopia.org>2023-07-28 21:38:35 +0200
commitb78762c92afee705e618f29f89897db8b45df3dd (patch)
tree90833dc90cd3b58ee84d19357fb1d945d40823ec /lib/DATS/init.dats
parentc6ad352a25b6b1d45e56090ccc0432d123b043bc (diff)
downloadats-os-b78762c92afee705e618f29f89897db8b45df3dd.tar.xz
ats-os-b78762c92afee705e618f29f89897db8b45df3dd.zip
optional implementation of multboot 1
Diffstat (limited to 'lib/DATS/init.dats')
-rw-r--r--lib/DATS/init.dats48
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