diff options
author | Xander <xander@biltopia.org> | 2023-07-28 00:57:36 +0200 |
---|---|---|
committer | Xander <xander@biltopia.org> | 2023-07-28 00:57:36 +0200 |
commit | 11539792ffcbdba74d6ca63dea2be937d62de7fc (patch) | |
tree | 06d1250dcb064a5192aad0de81d81dab83b025fc /lib/DATS | |
parent | 018d1489e6fc0c6363442033abd674f287e6f5cd (diff) | |
download | ats-os-11539792ffcbdba74d6ca63dea2be937d62de7fc.tar.xz ats-os-11539792ffcbdba74d6ca63dea2be937d62de7fc.zip |
Added template init_exec function
Diffstat (limited to 'lib/DATS')
-rw-r--r-- | lib/DATS/init.dats | 14 | ||||
-rw-r--r-- | lib/DATS/writer.dats | 16 |
2 files changed, 23 insertions, 7 deletions
diff --git a/lib/DATS/init.dats b/lib/DATS/init.dats index 492d5dc..a4c84b3 100644 --- a/lib/DATS/init.dats +++ b/lib/DATS/init.dats @@ -7,3 +7,17 @@ let in @{initialized = false, obj = v}: initializable vt end + + +implement{vt} init_exec (x) = + if x.initialized then + let + prval () = opt_unsome x.obj + val () = init_exec$fwork (x.obj) + prval () = opt_some x.obj + in + end + +implement{vt} init_exec$fwork (v) = () + + diff --git a/lib/DATS/writer.dats b/lib/DATS/writer.dats index d5a327b..b7e9973 100644 --- a/lib/DATS/writer.dats +++ b/lib/DATS/writer.dats @@ -3,6 +3,9 @@ staload "lib/SATS/writer.sats" staload "lib/SATS/init.sats" +// when this .dats file not staloaded I get weird error from template function +staload "lib/DATS/init.dats" + #define ATS_DYNLOADFLAG 0 %{^ @@ -48,6 +51,7 @@ in implement _clear_screen(w) = let fun loop {n : nat | n < N - 1} .<N-n>. (i : int n, w : &writer_t) :<!wrt> void = (put_char('\0', w); if (i < N - 2) then loop(i+1,w)) + val () = w := @{position = 0, color_code = code_value(White,Black)} in loop(0,w); w.position := 0; @@ -103,17 +107,15 @@ in in end end + + implement clear_screen() : void = let val (vbox pf | p) = ref_get_viewptr(writer_ref) + implement init_exec$fwork<writer_t>(v) = _clear_screen(v) in - if p->initialized then - let - prval () = opt_unsome p->obj - val () = _clear_screen(p->obj) - prval () = opt_some p->obj - in - end + if p->initialized then + init_exec (!p) else let prval () = opt_unnone p->obj |