Skip to content

Commit

Permalink
rename ref primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim committed Sep 22, 2024
1 parent f04cb93 commit 50c974d
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion jscomp/ml/rec_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ let build_unguarded_env : Ident.t list -> Env.env =
let is_ref : Types.value_description -> bool = function
| {
Types.val_kind =
Types.Val_prim { Primitive.prim_name = "%makemutable"; prim_arity = 1 };
Types.Val_prim { Primitive.prim_name = "%makeref"; prim_arity = 1 };
} ->
true
| _ -> false
Expand Down
6 changes: 3 additions & 3 deletions jscomp/ml/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ let primitives_table =
("%loc_MODULE", Ploc Loc_MODULE);

(* BEGIN Triples for ref data type *)
("%bs_ref_setfield0", Psetfield (0, Lambda.ref_field_set_info));
("%bs_ref_field0", Pfield (0, Lambda.ref_field_info));
("%makemutable", Pmakeblock Lambda.ref_tag_info);
("%makeref", Pmakeblock Lambda.ref_tag_info);
("%refset", Psetfield (0, Lambda.ref_field_set_info));
("%refget", Pfield (0, Lambda.ref_field_info));

("%incr", Poffsetref 1);
("%decr", Poffsetref (-1));
Expand Down
2 changes: 1 addition & 1 deletion jscomp/others/belt_internals.resi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ external lsr: (int, int) => int = "%lsrint"
external lxor: (int, int) => int = "%xorint"
external asr: (int, int) => int = "%asrint"
type ref<'a> = {mutable contents: 'a}
external ref: 'a => ref<'a> = "%makemutable"
external ref: 'a => ref<'a> = "%makeref"

external \"||": (bool, bool) => bool = "%sequor"
external \"&&": (bool, bool) => bool = "%sequand"
Expand Down
2 changes: 1 addition & 1 deletion jscomp/runtime/bs_stdlib_mini.resi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ external lsr: (int, int) => int = "%lsrint"
external lxor: (int, int) => int = "%xorint"
external asr: (int, int) => int = "%asrint"
type ref<'a> = {mutable contents: 'a}
external ref: 'a => ref<'a> = "%makemutable"
external ref: 'a => ref<'a> = "%makeref"

external \"||": (bool, bool) => bool = "%sequor"
external \"&&": (bool, bool) => bool = "%sequand"
Expand Down
1 change: 1 addition & 0 deletions jscomp/runtime/list.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FIXME:
// This exists for compatibility reason.
// Move this into Pervasives or Core

1 change: 1 addition & 0 deletions jscomp/runtime/map.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FIXME:
// This exists for compatibility reason.
// Move this into Pervasives or Core

1 change: 1 addition & 0 deletions jscomp/runtime/set.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FIXME:
// This exists for compatibility reason.
// Move this into Pervasives or Core

6 changes: 3 additions & 3 deletions jscomp/stdlib-406/pervasives.res
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ external snd: (('a, 'b)) => 'b = "%field1"
/* References */

type ref<'a> = {mutable contents: 'a}
external ref: 'a => ref<'a> = "%makemutable"
external \"!": ref<'a> => 'a = "%bs_ref_field0"
external \":=": (ref<'a>, 'a) => unit = "%bs_ref_setfield0"
external ref: 'a => ref<'a> = "%makeref"
external \"!": ref<'a> => 'a = "%refget"
external \":=": (ref<'a>, 'a) => unit = "%refset"
external incr: ref<int> => unit = "%incr"
external decr: ref<int> => unit = "%decr"

Expand Down
6 changes: 3 additions & 3 deletions jscomp/stdlib-406/pervasives.resi
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,17 @@ type int32 = int
type ref<'a> = {mutable contents: 'a}

/** Return a fresh reference containing the given value. */
external ref: 'a => ref<'a> = "%makemutable"
external ref: 'a => ref<'a> = "%makeref"

/** [!r] returns the current contents of reference [r].
Equivalent to [fun r -> r.contents].
Unary operator at precedence level 11/11.*/
external \"!": ref<'a> => 'a = "%bs_ref_field0"
external \"!": ref<'a> => 'a = "%refget"

/** [r := a] stores the value of [a] in reference [r].
Equivalent to [fun r v -> r.contents <- v].
Right-associative operator at precedence level 1/11. */
external \":=": (ref<'a>, 'a) => unit = "%bs_ref_setfield0"
external \":=": (ref<'a>, 'a) => unit = "%refset"

/** Increment the integer contained in the given reference.
Equivalent to [fun r -> r := succ !r]. */
Expand Down
6 changes: 3 additions & 3 deletions jscomp/test/test_per.res
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ external snd: (('a, 'b)) => 'b = "%field1"
/* References */

type ref<'a> = {mutable contents: 'a}
external ref: 'a => ref<'a> = "%makemutable"
external \"!": ref<'a> => 'a = "%bs_ref_field0"
external \":=": (ref<'a>, 'a) => unit = "%bs_ref_setfield0"
external ref: 'a => ref<'a> = "%makeref"
external \"!": ref<'a> => 'a = "%refget"
external \":=": (ref<'a>, 'a) => unit = "%refset"
external incr: ref<int> => unit = "%incr"
external decr: ref<int> => unit = "%decr"

0 comments on commit 50c974d

Please sign in to comment.