Skip to content

Commit

Permalink
to_nat takes only Uint32 as argument. Make it non-polymorphic (#864)
Browse files Browse the repository at this point in the history
* to_nat takes Uint32 only as argument. Make it non-polymorphic

* Review catch: Fix in Gas.ml as well
  • Loading branch information
vaivaswatha committed Jul 3, 2020
1 parent 3b032eb commit 873e7d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/base/BuiltIns.ml
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,7 @@ module ScillaBuiltIns (SR : Rep) (ER : Rep) = struct

let to_nat_arity = 1

let to_nat_type = tfun_typ "'A" @@ fun_typ (tvar "'A") nat_typ

let to_nat_elab sc ts =
match ts with
| [ t ] when is_uint_type t -> elab_tfun_with_args_no_gas sc [ t ]
| _ -> fail0 "Failed to elaborate"
let to_nat_type = fun_typ uint32_typ nat_typ

let to_nat ls _ =
match ls with
Expand Down Expand Up @@ -1371,7 +1366,7 @@ module ScillaBuiltIns (SR : Rep) (ER : Rep) = struct
| Builtin_to_uint32 -> [Uint.to_uint_arity, Uint.to_uint_type, Uint.to_uint_elab Bits32, Uint.to_uint32]
| Builtin_to_uint64 -> [Uint.to_uint_arity, Uint.to_uint_type, Uint.to_uint_elab Bits64, Uint.to_uint64]
| Builtin_to_uint128 -> [Uint.to_uint_arity, Uint.to_uint_type, Uint.to_uint_elab Bits128, Uint.to_uint128]
| Builtin_to_nat -> [Uint.to_nat_arity, Uint.to_nat_type, Uint.to_nat_elab, Uint.to_nat]
| Builtin_to_nat -> [Uint.to_nat_arity, Uint.to_nat_type, elab_id, Uint.to_nat]

[@@@ocamlformat "enable"]

Expand Down
2 changes: 1 addition & 1 deletion src/base/Gas.ml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ module ScillaGas (SR : Rep) (ER : Rep) = struct
(Builtin_to_uint64, [tvar "'A"], int_conversion_coster 64, 4);
(Builtin_to_uint128, [tvar "'A"], int_conversion_coster 128, 4);
(Builtin_to_uint256, [tvar "'A"], int_conversion_coster 256, 4);
(Builtin_to_nat, [tvar "'A"], to_nat_coster, 1);
(Builtin_to_nat, [uint32_typ], to_nat_coster, 1);
]

[@@@ocamlformat "enable"]
Expand Down

0 comments on commit 873e7d7

Please sign in to comment.