Remove useless constants:
* C_HASH (removed) * C_MAP_GET --replaced--> C_MAP_FIND_OPT * C_MAP_GET_FORCE --replaced--> C_MAP_FIND
This commit is contained in:
parent
8232eecc6e
commit
784c2da81b
@ -7,13 +7,13 @@ let bad_contract basename =
|
||||
|
||||
let%expect_test _ =
|
||||
run_ligo_good [ "measure-contract" ; contract "coase.ligo" ; "main" ] ;
|
||||
[%expect {| 2066 bytes |}] ;
|
||||
[%expect {| 2062 bytes |}] ;
|
||||
|
||||
run_ligo_good [ "measure-contract" ; contract "multisig.ligo" ; "main" ] ;
|
||||
[%expect {| 1093 bytes |}] ;
|
||||
|
||||
run_ligo_good [ "measure-contract" ; contract "multisig-v2.ligo" ; "main" ] ;
|
||||
[%expect {| 2717 bytes |}] ;
|
||||
[%expect {| 2713 bytes |}] ;
|
||||
|
||||
run_ligo_good [ "measure-contract" ; contract "vote.mligo" ; "main" ] ;
|
||||
[%expect {| 642 bytes |}] ;
|
||||
@ -86,7 +86,7 @@ let%expect_test _ =
|
||||
SWAP ;
|
||||
DIP { DUP ; CAR ; CAR } ;
|
||||
GET ;
|
||||
IF_NONE { PUSH string "GET_FORCE" ; FAILWITH } {} ;
|
||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
||||
DUP ;
|
||||
CAR ;
|
||||
DIP { DUP ; CDR ; PUSH nat 1 ; ADD } ;
|
||||
@ -168,7 +168,7 @@ let%expect_test _ =
|
||||
SWAP ;
|
||||
DIP { DUP ; CAR ; CDR } ;
|
||||
GET ;
|
||||
IF_NONE { PUSH string "GET_FORCE" ; FAILWITH } {} ;
|
||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
||||
DUP ;
|
||||
CAR ;
|
||||
SOURCE ;
|
||||
@ -182,7 +182,7 @@ let%expect_test _ =
|
||||
CDR ;
|
||||
DIP { DIP { DUP } ; SWAP ; CAR ; CAR } ;
|
||||
GET ;
|
||||
IF_NONE { PUSH string "GET_FORCE" ; FAILWITH } {} ;
|
||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
||||
DUP ;
|
||||
CDR ;
|
||||
PUSH nat 1 ;
|
||||
@ -262,7 +262,7 @@ let%expect_test _ =
|
||||
CAR ;
|
||||
DIP { DUP } ;
|
||||
GET ;
|
||||
IF_NONE { PUSH string "GET_FORCE" ; FAILWITH } {} ;
|
||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
||||
DUP ;
|
||||
CAR ;
|
||||
SOURCE ;
|
||||
@ -488,7 +488,7 @@ let%expect_test _ =
|
||||
CAR ;
|
||||
SENDER ;
|
||||
GET ;
|
||||
IF_NONE { PUSH string "GET_FORCE" ; FAILWITH } {} ;
|
||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
||||
PUSH nat 1 ;
|
||||
ADD ;
|
||||
SOME ;
|
||||
@ -529,7 +529,7 @@ let%expect_test _ =
|
||||
CAR ;
|
||||
SENDER ;
|
||||
GET ;
|
||||
IF_NONE { PUSH string "GET_FORCE" ; FAILWITH } {} ;
|
||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
||||
PUSH nat 1 ;
|
||||
ADD ;
|
||||
SOME ;
|
||||
@ -572,7 +572,7 @@ let%expect_test _ =
|
||||
CAR ;
|
||||
SENDER ;
|
||||
GET ;
|
||||
IF_NONE { PUSH string "GET_FORCE" ; FAILWITH } {} ;
|
||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
||||
DUP ;
|
||||
DIP { DIP 4 { DUP } ; DIG 4 ; CAR ; CDR ; CAR } ;
|
||||
COMPARE ;
|
||||
@ -768,7 +768,7 @@ let%expect_test _ =
|
||||
CAR ;
|
||||
SENDER ;
|
||||
GET ;
|
||||
IF_NONE { PUSH string "GET_FORCE" ; FAILWITH } {} ;
|
||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
||||
PUSH nat 1 ;
|
||||
SWAP ;
|
||||
SUB ;
|
||||
|
@ -490,7 +490,7 @@ and transpile_annotated_expression (ae:AST.annotated_expression) : expression re
|
||||
)
|
||||
| E_look_up dsi -> (
|
||||
let%bind (ds', i') = bind_map_pair f dsi in
|
||||
return @@ E_constant (C_MAP_GET, [i' ; ds'])
|
||||
return @@ E_constant (C_MAP_FIND_OPT, [i' ; ds'])
|
||||
)
|
||||
| E_sequence (a , b) -> (
|
||||
let%bind a' = transpile_annotated_expression a in
|
||||
|
@ -23,7 +23,7 @@ let is_pure_constant : constant -> bool =
|
||||
| C_NEG | C_OR | C_AND | C_XOR | C_NOT
|
||||
| C_EQ | C_NEQ | C_LT | C_LE | C_GT | C_GE
|
||||
| C_SOME
|
||||
| C_UPDATE | C_MAP_GET | C_MAP_FIND_OPT | C_MAP_ADD | C_MAP_UPDATE
|
||||
| C_UPDATE | C_MAP_FIND_OPT | C_MAP_ADD | C_MAP_UPDATE
|
||||
| C_INT | C_ABS | C_IS_NAT
|
||||
| C_BALANCE | C_AMOUNT | C_ADDRESS | C_NOW | C_SOURCE | C_SENDER | C_CHAIN_ID
|
||||
| C_SET_MEM | C_SET_ADD | C_SET_REMOVE | C_SLICE
|
||||
@ -34,7 +34,7 @@ let is_pure_constant : constant -> bool =
|
||||
| C_ADD | C_SUB |C_MUL|C_DIV|C_MOD
|
||||
(* impure: *)
|
||||
| C_ASSERTION | C_ASSERT_INFERRED
|
||||
| C_MAP_GET_FORCE | C_MAP_FIND
|
||||
| C_MAP_FIND
|
||||
| C_FOLD_WHILE
|
||||
| C_CALL
|
||||
(* TODO... *)
|
||||
|
@ -66,7 +66,7 @@ module Simplify = struct
|
||||
module Pascaligo = struct
|
||||
|
||||
let constants = function
|
||||
| "get_force" -> ok C_MAP_GET_FORCE
|
||||
| "get_force" -> ok C_MAP_FIND
|
||||
| "get_chain_id" -> ok C_CHAIN_ID
|
||||
| "transaction" -> ok C_CALL
|
||||
| "get_contract" -> ok C_CONTRACT
|
||||
@ -109,7 +109,7 @@ module Simplify = struct
|
||||
| "map_fold" -> ok C_MAP_FOLD
|
||||
| "map_remove" -> ok C_MAP_REMOVE
|
||||
| "map_update" -> ok C_MAP_UPDATE
|
||||
| "map_get" -> ok C_MAP_GET
|
||||
| "map_get" -> ok C_MAP_FIND_OPT
|
||||
| "map_mem" -> ok C_MAP_MEM
|
||||
| "sha_256" -> ok C_SHA256
|
||||
| "sha_512" -> ok C_SHA512
|
||||
@ -163,7 +163,6 @@ module Simplify = struct
|
||||
| "Current.failwith" -> ok C_FAILWITH
|
||||
| "failwith" -> ok C_FAILWITH
|
||||
|
||||
| "Crypto.hash" -> ok C_HASH
|
||||
| "Crypto.blake2b" -> ok C_BLAKE2b
|
||||
| "Crypto.sha256" -> ok C_SHA256
|
||||
| "Crypto.sha512" -> ok C_SHA512
|
||||
@ -424,8 +423,6 @@ module Typer = struct
|
||||
| C_LIST_FOLD -> ok @@ failwith "t_list_fold" ;
|
||||
| C_LIST_CONS -> ok @@ failwith "t_list_cons" ;
|
||||
(* MAP *)
|
||||
| C_MAP_GET -> ok @@ failwith "t_map_get" ;
|
||||
| C_MAP_GET_FORCE -> ok @@ failwith "t_map_get_force" ;
|
||||
| C_MAP_ADD -> ok @@ t_map_add ;
|
||||
| C_MAP_REMOVE -> ok @@ t_map_remove ;
|
||||
| C_MAP_UPDATE -> ok @@ t_map_update ;
|
||||
@ -562,16 +559,6 @@ module Typer = struct
|
||||
let default = t_unit () in
|
||||
ok @@ Simple_utils.Option.unopt ~default opt
|
||||
|
||||
let map_get_force = typer_2 "MAP_GET_FORCE" @@ fun i m ->
|
||||
let%bind (src, dst) = bind_map_or (get_t_map , get_t_big_map) m in
|
||||
let%bind _ = assert_type_value_eq (src, i) in
|
||||
ok dst
|
||||
|
||||
let map_get = typer_2 "MAP_GET" @@ fun i m ->
|
||||
let%bind (src, dst) = bind_map_or (get_t_map , get_t_big_map) m in
|
||||
let%bind _ = assert_type_value_eq (src, i) in
|
||||
ok @@ t_option dst ()
|
||||
|
||||
let int : typer = typer_1 "INT" @@ fun t ->
|
||||
let%bind () = assert_t_nat t in
|
||||
ok @@ t_int ()
|
||||
@ -1034,8 +1021,6 @@ module Typer = struct
|
||||
| C_LIST_FOLD -> ok @@ list_fold ;
|
||||
| C_LIST_CONS -> ok @@ list_cons ;
|
||||
(* MAP *)
|
||||
| C_MAP_GET -> ok @@ map_get ;
|
||||
| C_MAP_GET_FORCE -> ok @@ map_get_force ;
|
||||
| C_MAP_ADD -> ok @@ map_add ;
|
||||
| C_MAP_REMOVE -> ok @@ map_remove ;
|
||||
| C_MAP_UPDATE -> ok @@ map_update ;
|
||||
@ -1115,9 +1100,7 @@ module Compiler = struct
|
||||
| C_GE -> ok @@ simple_binary @@ seq [prim I_COMPARE ; prim I_GE]
|
||||
| C_UPDATE -> ok @@ simple_ternary @@ prim I_UPDATE
|
||||
| C_SOME -> ok @@ simple_unary @@ prim I_SOME
|
||||
| C_MAP_GET_FORCE -> ok @@ simple_binary @@ seq [prim I_GET ; i_assert_some_msg (i_push_string "GET_FORCE")]
|
||||
| C_MAP_FIND -> ok @@ simple_binary @@ seq [prim I_GET ; i_assert_some_msg (i_push_string "MAP FIND")]
|
||||
| C_MAP_GET -> ok @@ simple_binary @@ prim I_GET
|
||||
| C_MAP_MEM -> ok @@ simple_binary @@ prim I_MEM
|
||||
| C_MAP_FIND_OPT -> ok @@ simple_binary @@ prim I_GET
|
||||
| C_MAP_ADD -> ok @@ simple_ternary @@ seq [dip (i_some) ; prim I_UPDATE]
|
||||
|
@ -82,8 +82,6 @@ let constant ppf : constant -> unit = function
|
||||
| C_MAP -> fprintf ppf "MAP"
|
||||
| C_MAP_EMPTY -> fprintf ppf "MAP_EMPTY"
|
||||
| C_MAP_LITERAL -> fprintf ppf "MAP_LITERAL"
|
||||
| C_MAP_GET -> fprintf ppf "MAP_GET"
|
||||
| C_MAP_GET_FORCE -> fprintf ppf "MAP_GET_FORCE"
|
||||
| C_MAP_ADD -> fprintf ppf "MAP_ADD"
|
||||
| C_MAP_REMOVE -> fprintf ppf "MAP_REMOVE"
|
||||
| C_MAP_UPDATE -> fprintf ppf "MAP_UPDATE"
|
||||
@ -101,7 +99,6 @@ let constant ppf : constant -> unit = function
|
||||
| C_SHA256 -> fprintf ppf "SHA256"
|
||||
| C_SHA512 -> fprintf ppf "SHA512"
|
||||
| C_BLAKE2b -> fprintf ppf "BLAKE2b"
|
||||
| C_HASH -> fprintf ppf "HASH"
|
||||
| C_HASH_KEY -> fprintf ppf "HASH_KEY"
|
||||
| C_CHECK_SIGNATURE -> fprintf ppf "CHECK_SIGNATURE"
|
||||
| C_CHAIN_ID -> fprintf ppf "CHAIN_ID"
|
||||
|
@ -199,8 +199,6 @@ type constant =
|
||||
| C_MAP
|
||||
| C_MAP_EMPTY
|
||||
| C_MAP_LITERAL
|
||||
| C_MAP_GET
|
||||
| C_MAP_GET_FORCE
|
||||
| C_MAP_ADD
|
||||
| C_MAP_REMOVE
|
||||
| C_MAP_UPDATE
|
||||
@ -218,7 +216,6 @@ type constant =
|
||||
| C_SHA256
|
||||
| C_SHA512
|
||||
| C_BLAKE2b
|
||||
| C_HASH
|
||||
| C_HASH_KEY
|
||||
| C_CHECK_SIGNATURE
|
||||
| C_CHAIN_ID
|
||||
|
Loading…
Reference in New Issue
Block a user