aboutsummaryrefslogtreecommitdiff
path: root/lib/DATS/init.dats
diff options
context:
space:
mode:
authorXander <xander@biltopia.org>2023-08-08 22:17:40 +0200
committerXander <xander@biltopia.org>2023-08-08 22:17:40 +0200
commit245f24890cd78304cf0fd397dda8e72b0a7fbe6b (patch)
tree7210e4d4489b7281fb9213745b4776846402103b /lib/DATS/init.dats
parentcef3f6bdddfe768e7a1a84edcec76c11c1634941 (diff)
downloadats-os-245f24890cd78304cf0fd397dda8e72b0a7fbe6b.tar.xz
ats-os-245f24890cd78304cf0fd397dda8e72b0a7fbe6b.zip
more refactoring and implemented exec_init
Diffstat (limited to 'lib/DATS/init.dats')
-rw-r--r--lib/DATS/init.dats31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/DATS/init.dats b/lib/DATS/init.dats
index c2ae39d..206dc6f 100644
--- a/lib/DATS/init.dats
+++ b/lib/DATS/init.dats
@@ -26,7 +26,25 @@ in
panic("Not initialized")
end
-implement{vt} exec_void$fwork (v) = panic("Not overloaded")
+//NOTE: lot of duplicate code
+implement{vt} exec_init (r) = let
+ val (vbox pf | p) = ref_get_viewptr{initializable vt}(r)
+in
+ if p->initialized then
+ let
+ prval () = opt_unsome p->obj
+ val () = exec_void$fwork<vt>(p->obj)
+ prval () = opt_some p->obj
+ in
+ end
+ else (
+ $effmask_ref(initialize<vt>(r));
+ if p->initialized then
+ $effmask_ref(exec_void<vt>(r))
+ else
+ panic("Not inialized");
+ )
+end
implement{vt} {a} exec (r) = let
val (vbox pf | p) = ref_get_viewptr{initializable vt}(r)
@@ -45,10 +63,6 @@ in
)
end
-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)
@@ -59,10 +73,3 @@ in
val () = p->initialized := initialize$fwork(p->obj)
in end
end
-
-implement{vt} initialize$fwork (v) = let
- prval () = opt_none v
-in
- false
-end
-