From 65ba3a1651bd2012484bccce451fec966cf752aa Mon Sep 17 00:00:00 2001 From: Hongwei Date: Mon, 16 Sep 2024 00:52:49 -0400 Subject: [PATCH] Updating: very very minorly --- prelude/HATS/prelude_JS_dats.hats | 2 + srcgen2/HATS/xatsopt_dats.hats | 2 +- .../xats2js/srcgen1/UTIL/xats2js_jsemit.dats | 2 +- .../githwxi/DATS/CATS/JS/NODE/myfil00.cats | 23 ++++++ .../githwxi/DATS/CATS/JS/NODE/myfil00.dats | 39 ++++++++++ xatslib/githwxi/DATS/myfil00.dats | 75 ++++++++++++++----- xatslib/githwxi/DATS/myobj00.dats | 10 +++ .../githwxi/TEST/CATS/JS/test07_myobj00.dats | 1 + 8 files changed, 132 insertions(+), 22 deletions(-) diff --git a/prelude/HATS/prelude_JS_dats.hats b/prelude/HATS/prelude_JS_dats.hats index b26bdb371..cc1fd00d1 100644 --- a/prelude/HATS/prelude_JS_dats.hats +++ b/prelude/HATS/prelude_JS_dats.hats @@ -30,6 +30,8 @@ Sun 14 Jul 2024 12:14:49 PM EDT "prelude/DATS/CATS/JS/char000.dats" #staload _ = "prelude/DATS/CATS/JS/gint000.dats" +#staload _ = +"prelude/DATS/CATS/JS/gflt000.dats" // (* ****** ****** *) (* ****** ****** *) diff --git a/srcgen2/HATS/xatsopt_dats.hats b/srcgen2/HATS/xatsopt_dats.hats index 7c4dcb367..6b76846c1 100644 --- a/srcgen2/HATS/xatsopt_dats.hats +++ b/srcgen2/HATS/xatsopt_dats.hats @@ -56,7 +56,7 @@ srcgen1\ #staload "\ srcgen1\ -/xatslib/githwxi/DATS/CATS/JS/Node/basics0.dats" +/xatslib/githwxi/DATS/CATS/JS/NODE/basics0.dats" // // #endif // end of [ifdef(_XATSOPT_JS_)] // diff --git a/srcgen2/xats2js/srcgen1/UTIL/xats2js_jsemit.dats b/srcgen2/xats2js/srcgen1/UTIL/xats2js_jsemit.dats index 8dfdeb2a4..4288c7aa5 100644 --- a/srcgen2/xats2js/srcgen1/UTIL/xats2js_jsemit.dats +++ b/srcgen2/xats2js/srcgen1/UTIL/xats2js_jsemit.dats @@ -130,7 +130,7 @@ srcgen1\ "\ srcgen1\ /prelude\ -/DATS/CATS/JS/Node/process.dats" +/DATS/CATS/JS/NODE/process.dats" (* ****** ****** *) (* ****** ****** *) // diff --git a/xatslib/githwxi/DATS/CATS/JS/NODE/myfil00.cats b/xatslib/githwxi/DATS/CATS/JS/NODE/myfil00.cats index ccadf2546..e286b17c3 100644 --- a/xatslib/githwxi/DATS/CATS/JS/NODE/myfil00.cats +++ b/xatslib/githwxi/DATS/CATS/JS/NODE/myfil00.cats @@ -56,6 +56,29 @@ XATS2JS_NODE_myfil00$fpath_readall$fwork } // ////////////////////////////////////////////////////////////////////////. +// +function +XATS2JS_NODE_myfil00$FILR_close + ( filr ) +{ + return filr.end() // HX: [filr] needs to be a stream! +} +// +////////////////////////////////////////////////////////////////////////. +// +function +XATS2JS_NODE_myfil00$fpath_createWrite$fwork + (fpath, work) +{ + try { + work(XATS2JS_NODE_fs.createWriteStream(fpath)) + } catch (error) { + console.log + (`XATS2JS_NODE_myfil00$fpath_createWrite$fwork(error): fpath = ${fpath}`) + } +} +// +////////////////////////////////////////////////////////////////////////. ////////////////////////////////////////////////////////////////////////. // end of [ATS3/XANADU_xatslib_githwxi_DATS_CATS_JS_NODE_myfil00.cats] ////////////////////////////////////////////////////////////////////////. diff --git a/xatslib/githwxi/DATS/CATS/JS/NODE/myfil00.dats b/xatslib/githwxi/DATS/CATS/JS/NODE/myfil00.dats index f0d554228..5b0069a96 100644 --- a/xatslib/githwxi/DATS/CATS/JS/NODE/myfil00.dats +++ b/xatslib/githwxi/DATS/CATS/JS/NODE/myfil00.dats @@ -7,6 +7,12 @@ Some simple stuff for handling files *) (* ****** ****** *) (* ****** ****** *) +// +#include +"xatslib\ +/libcats/HATS/libcats_dats.hats" +// +(* ****** ****** *) #staload "./../../../myfil00.dats" (* ****** ****** *) (* ****** ****** *) @@ -35,6 +41,39 @@ XATS2JS_NODE_myfil00$fpath_readall$fwork (* ****** ****** *) (* ****** ****** *) // +#impltmp +<(*tmp*)> +myfil00$FILR_close + ( filr ) = +( +XATS2JS_NODE_myfil00$FILR_close + ( filr )) where +{ +#extern +fun +XATS2JS_NODE_myfil00$FILR_close + (filr: FILR(*HX:it is a stream*)): void = $extnam() +} +// +(* ****** ****** *) +// +#impltmp +<(*tmp*)> +myfil00$fpath_createWrite$fwork + (fpath, work) = +( +XATS2JS_NODE_myfil00$fpath_createWrite$fwork + (fpath, work)) where +{ +#extern +fun +XATS2JS_NODE_myfil00$fpath_createWrite$fwork + (fpath: strn, work: (FILR)->void): void = $extnam() +} +// +(* ****** ****** *) +(* ****** ****** *) +// (* ****** ****** *)(* ****** ****** *)(* ****** ****** *) (* ****** ****** *)(* ****** ****** *)(* ****** ****** *) diff --git a/xatslib/githwxi/DATS/myfil00.dats b/xatslib/githwxi/DATS/myfil00.dats index f09eb32ed..18cc8e9ef 100644 --- a/xatslib/githwxi/DATS/myfil00.dats +++ b/xatslib/githwxi/DATS/myfil00.dats @@ -11,19 +11,9 @@ Some simple stuff for handling files "prelude/SATS/unsfx00.sats" (* ****** ****** *) (* ****** ****** *) -#staload -"./../../libcats/DATS/gbas000.dats" -(* ****** ****** *) -(* ****** ****** *) -// -fun<> -myfil00$FILR_close - (filr: FILR): void -// -fun<> -myfil00$fpath_open$opt - (fpath: strn): FILRopt_vt -// +#include +"xatslib\ +/libcats/HATS/libcats_dats.hats" (* ****** ****** *) (* ****** ****** *) // @@ -67,22 +57,64 @@ end//let // #extern fun<> -myfil00_output(): void +myfil00_output + ( (*void*) ): void +// +(* ****** ****** *) // #extern fun<> -myfil00$myfil_make$opt_stdout - (fpath: strn): bool(*succ/fail*) +myfil00$FILR_close + (filr: FILR): void +// +(* ****** ****** *) +// +#extern +fun<> +myfil00$fpath_createWrite$opt + (fpath: strn): FILRopt_vt +#extern +fun<> +myfil00$fpath_createWrite$fwork + (fpath: strn, work: (FILR)->void): void +// +(* ****** ****** *) // #impltmp -myfil00$myfil_make$opt_stdout +<(*tmp*)> +myfil00$fpath_createWrite$opt (fpath) = let // -val opt = -myfil00$fpath_open$opt(fpath) +#vwtpdef +r0 = // res +optn_vt(FILR) +// +var r0: r0 = +optn_vt_nil((*0*)) +val p0 = $addr(r0) // in//let +myfil00$fpath_createWrite$fwork +( +fpath, +lam(cs) => +$UN.p2tr_set(p0, optn_vt_cons(cs))); r0 +end//let +// +(* ****** ****** *) +// +#extern +fun<> // HX: succ/fail: true/false +myfil00$myfil_make$opt_stdout(fpath: strn): bool +// +(* ****** ****** *) +(* ****** ****** *) +// +#impltmp +myfil00$myfil_make$opt_stdout + (fpath) = +( // case+ opt of | ~ @@ -102,7 +134,10 @@ val () = where{ #impltmp g_stdout<>() = out } } ) // -end(*let*)//end-of-[myfil00$myfil_make$opt_stdout(...)] +) where +{ + val opt = myfil00$fpath_createWrite$opt(fpath) +}(*where*)//end-of-[myfil00$myfil_make$opt_stdout(...)] // (* ****** ****** *) (* ****** ****** *) diff --git a/xatslib/githwxi/DATS/myobj00.dats b/xatslib/githwxi/DATS/myobj00.dats index 8e96b938c..547369c56 100644 --- a/xatslib/githwxi/DATS/myobj00.dats +++ b/xatslib/githwxi/DATS/myobj00.dats @@ -228,9 +228,19 @@ case+ dtv of |DTVa1sz(a0) => ( prints("DTVa1sz(", a0, ")")) +// |DTVhmap(hm) => +(* +HX-2024-09-16: +Handling recursion is tricky! +*) +(* ( +HX-2024-09-16: BUGGY!!! prints("DTVhmap(", hm, ")")) +*) +(prints + ("DTVhmap(", type(hm), ")")) // |DTVf1un(f1) => ( diff --git a/xatslib/githwxi/TEST/CATS/JS/test07_myobj00.dats b/xatslib/githwxi/TEST/CATS/JS/test07_myobj00.dats index f238b780c..a048ccd31 100644 --- a/xatslib/githwxi/TEST/CATS/JS/test07_myobj00.dats +++ b/xatslib/githwxi/TEST/CATS/JS/test07_myobj00.dats @@ -24,6 +24,7 @@ Sat 07 Sep 2024 02:40:27 PM EDT // (* ****** ****** *) (* ****** ****** *) +// #include "srcgen2\ /prelude/HATS/prelude_JS_dats.hats"