Skip to content

Commit

Permalink
Updating: very very minorly
Browse files Browse the repository at this point in the history
  • Loading branch information
githwxi committed Sep 9, 2024
1 parent 0420937 commit df77cfb
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 16 deletions.
19 changes: 16 additions & 3 deletions srcgen2/xats2js/srcgen1/xshared/runtime/xats2js_prelude.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Thu 05 Sep 2024 09:36:56 PM EDT
// Sun 08 Sep 2024 07:37:07 PM EDT
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/*
Expand Down Expand Up @@ -685,6 +685,19 @@ XATS2JS_a1sz_lset$at
}
//
////////////////////////////////////////////////////////////////////////.
/*
HX-2024-09-06:
Fri 06 Sep 2024 04:18:38 PM EDT
*/
//
function
XATS2JS_a1sz_make_none
( n )
{
var A = new Array(n)
return A // HX: A = [?, ?, ..., ?]
}
////////////////////////////////////////////////////////////////////////.
//
/*
HX-2024-08-15:
Expand All @@ -696,7 +709,7 @@ XATS2JS_a1sz_make_ncpy
(n, x)
{
var i = 0
var A = new Array(n);
var A = new Array(n)
while (i < n) {
A[i] = (x); i += 1
}
Expand All @@ -708,7 +721,7 @@ XATS2JS_a1sz_make_nfun
(n, f)
{
var i = 0
var A = new Array(n);
var A = new Array(n)
while (i < n) {
A[i] = f(i); i += 1
}
Expand Down
11 changes: 10 additions & 1 deletion srcgen2/xats2js/srcgen1/xshared/runtime/xats2js_xatslib.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Thu 05 Sep 2024 09:36:56 PM EDT
// Sun 08 Sep 2024 07:37:07 PM EDT
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/*
Expand Down Expand Up @@ -296,6 +296,15 @@ XATS2JS_jshsmap_make_nil
//
/////////////////////////////////////////////////////////////////////////
//
function
XATS2JS_jshsmap_search$tst
(map, key)
{
return map.has(key) // HX: bool
}
//
/////////////////////////////////////////////////////////////////////////
//
/*
fun<>
UN_jshsmap_get$at$raw
Expand Down
9 changes: 9 additions & 0 deletions xatslib/DATS/CATS/JS/Hsmap00.cats
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ XATS2JS_jshsmap_make_nil
//
/////////////////////////////////////////////////////////////////////////
//
function
XATS2JS_jshsmap_search$tst
(map, key)
{
return map.has(key) // HX: bool
}
//
/////////////////////////////////////////////////////////////////////////
//
/*
fun<>
UN_jshsmap_get$at$raw
Expand Down
50 changes: 41 additions & 9 deletions xatslib/DATS/CATS/JS/Hsmap00.dats
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,15 @@ jshsmap_forall_f2un
(* ****** ****** *)
//
#extern
fun
<k:t0>
<x:vt>
fun<>
jshsmap_search$tst
{k:t0}{x:vt}
(map: jsm0(k,x), key: k): bool
//
#extern
fun
<k:t0>
<x:vt>
fun<>
jshsmap_search$cpy
{k:t0}{x:vt}
(map: jsm0(k,x), key: k): optn_vt(x)
//
(* ****** ****** *)
Expand Down Expand Up @@ -506,6 +504,24 @@ jshsmap_rlistize
//
#impltmp
<(*tmp*)>
jshsmap_search$tst
(map, key) =
(
XATS2JS_jshsmap_search$tst
(map, key)) where
{
#extern
fun
XATS2JS_jshsmap_search$tst
{k:t0}{x:vt}
(map: jsm0(k,x), key: k): bool = $extnam()
}
//
(* ****** ****** *)
(* ****** ****** *)
//
#impltmp
<(*tmp*)>
UN_jshsmap_get$at$raw
(map, key) =
(
Expand Down Expand Up @@ -575,9 +591,25 @@ jshsmap_getout$opt<>(map, key) }
jshsmap_insert$new
(map, k, x) =
let
val-
~optn_vt_nil() =
jshsmap_insert$opt<>(map, k, x) end
val-false =
jshsmap_search$tst<>(map, k)
in//let
UN_jshsmap_insert$raw<>(map, k, x)
end//let
//
(* ****** ****** *)
//
#impltmp
<(*tmp*)>
jshsmap_insert$opt
(map, k, x) =
(
opt ) where
{
val opt =
jshsmap_getout$opt<>(map, k)
val ( ) =
UN_jshsmap_insert$raw<>(map, k, x) }
//
(* ****** ****** *)
(* ****** ****** *)
Expand Down
15 changes: 15 additions & 0 deletions xatslib/githwxi/DATS/CATS/JS/myobj00.dats
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ hmap_tbox(a:t0) = jshsmap(strn, a)
//
#impltmp
< a: t0 >
hmap_strmize
(map) = jshsmap_strmize(map)
//
(* ****** ****** *)
(* ****** ****** *)
//
#impltmp
< a: t0 >
hmap_make_nil
((*void*)) = jshsmap_make_nil<>()
//
Expand All @@ -32,6 +40,13 @@ hmap_make_nil
//
#impltmp
< a: t0 >
hmap_insert$obj
(map, k0, x0) =
(
jshsmap_insert$opt<>(map, k0, x0))
//
#impltmp
< a: t0 >
hmap_insert$new
(map, k0, x0) =
(
Expand Down
133 changes: 130 additions & 3 deletions xatslib/githwxi/DATS/myobj00.dats
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@ Sat 07 Sep 2024 08:37:22 PM EDT
(* ****** ****** *)
(* ****** ****** *)
//
#abstype
#abstbox
hmap_tbox(a:t0)
#typedef
hmap(a:t0) = hmap_tbox(a)
//
(* ****** ****** *)
(* ****** ****** *)
//
#extern
fun
<a:t0>
hmap_strmize
( map
: hmap(a)): strm_vt@(strn,a)
//
#symload
strmize with hmap_strmize of 1000
//
(* ****** ****** *)
//
#extern
fun
Expand All @@ -32,10 +45,59 @@ hmap_make_nil((*0*)): hmap(a)
#extern
fun
<a:t0>
hmap_insert$opt
( map
: hmap(a)
, k0: strn, x0: a): optn_vt(a)
//
(* ****** ****** *)
//
#extern
fun
<a:t0>
hmap_insert$new
( map
: hmap(a), k0: strn, x0: a): void
//
#impltmp
< a: t0 >
hmap_insert$new
(map, k0, x0) =
(
case+ opt of
| ~optn_vt_nil() => ()
) where
{
val opt =
(
hmap_insert$opt<a>(map, k0, x0))
}
//
(* ****** ****** *)
//
#impltmp
{ a: t0 }
g_ptype
<hmap(a)>() =
(
strn_print"hmap(";
g_ptype<a>();strn_print")")
//
#impltmp
{ a: t0 }
g_print
<hmap(a)>(map) =
(
gseq_print0
<strm_vt(kx)><kx>
(hmap_strmize<a>(map)))
where
{
#typedef kx = (strn, a)
#vwtpdef kxs = strm_vt(kx)
#impltmp
gseq_beg<kxs><kx>() = "hmap(" }
//
(* ****** ****** *)
(* ****** ****** *)
//
Expand Down Expand Up @@ -63,7 +125,7 @@ datatype dtval =
//
(* ****** ****** *)
(* ****** ****** *)

//
#extern
fun<>
dtval_un_sint
Expand Down Expand Up @@ -108,6 +170,59 @@ dtval_un_fxun
(dtv: dtval): (a1sz(dtval))->dtval
//
(* ****** ****** *)
(* ****** ****** *)
//
#impltmp
g_ptype
< dtval >
( (*0*) ) = strn_print<>("dtval")
//
(* ****** ****** *)
//
#impltmp
g_print
< dtval >
( dtv ) =
(
praux(dtv)) where
{
//
fun
praux
(dtv: dtval): void =
let
//
#impltmp
g_print<dtval> = praux
//
in//let
case+ dtv of
//
|DTVunit(ut) =>
(
prints("DTVunit(", ")"))
//
|DTVsint(i0) =>
(
prints("DTVsint(", i0, ")"))
|DTVbool(b0) =>
(
prints("DTVbool(", b0, ")"))
|DTVchar(c0) =>
(
prints("DTVchar(", c0, ")"))
|DTVdflt(f0) =>
(
prints("DTVdflt(", f0, ")"))
|DTVstrn(s0) =>
(
prints("DTVstrn(", s0, ")"))
//
end//let//end-of-[praux(dtv)]
//
}
//
(* ****** ****** *)
//
#impltmp
<(*tmp*)>
Expand Down Expand Up @@ -191,6 +306,17 @@ let val-DTVfxun(fx) = dtv in fx end
//
#extern
fun<>
myobj_make_nil(): myobj
//
#impltmp
<(*tmp*)>
myobj_make_nil
( (*void*) ) = hmap_make_nil<>()
//
(* ****** ****** *)
//
#extern
fun<>
myobj_fmake_fwork
( fwork
: ((strn, dtval)->void)->void): myobj
Expand All @@ -200,7 +326,8 @@ myobj_fmake_fwork
myobj_fmake_fwork
(fwork) =
let
val obj = hmap_make_nil()
val obj =
myobj_make_nil<>((*0*))
in//let
fwork(
lam(k0, x0) =>
Expand Down
3 changes: 3 additions & 0 deletions xatslib/githwxi/HATS/githwxi_dats.hats
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ ATS3_XANADU/xatslib/githwxi/DATS
(* ****** ****** *)
(* ****** ****** *)
#staload "./../DATS/myfil00.dats"
(* ****** ****** *)
#staload "./../DATS/mycsv00.dats"
(* ****** ****** *)
#staload "./../DATS/myobj00.dats"
(* ****** ****** *)
(* ****** ****** *)
(*
HX: for linearly typed interfaces
Expand Down
Loading

0 comments on commit df77cfb

Please sign in to comment.