Always inline variable-for-variable lets in Self_mini_c
This commit is contained in:
parent
6acf91a3f2
commit
f2a23029bd
@ -10,13 +10,13 @@ let%expect_test _ =
|
|||||||
[%expect {| 1872 bytes |}] ;
|
[%expect {| 1872 bytes |}] ;
|
||||||
|
|
||||||
run_ligo_good [ "measure-contract" ; contract "multisig.ligo" ; "main" ] ;
|
run_ligo_good [ "measure-contract" ; contract "multisig.ligo" ; "main" ] ;
|
||||||
[%expect {| 1267 bytes |}] ;
|
[%expect {| 1187 bytes |}] ;
|
||||||
|
|
||||||
run_ligo_good [ "measure-contract" ; contract "multisig-v2.ligo" ; "main" ] ;
|
run_ligo_good [ "measure-contract" ; contract "multisig-v2.ligo" ; "main" ] ;
|
||||||
[%expect {| 2959 bytes |}] ;
|
[%expect {| 2886 bytes |}] ;
|
||||||
|
|
||||||
run_ligo_good [ "measure-contract" ; contract "vote.mligo" ; "main" ] ;
|
run_ligo_good [ "measure-contract" ; contract "vote.mligo" ; "main" ] ;
|
||||||
[%expect {| 589 bytes |}] ;
|
[%expect {| 581 bytes |}] ;
|
||||||
|
|
||||||
run_ligo_good [ "compile-parameter" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ;
|
run_ligo_good [ "compile-parameter" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ;
|
||||||
[%expect {| (Left (Left 1)) |}] ;
|
[%expect {| (Left (Left 1)) |}] ;
|
||||||
@ -301,7 +301,6 @@ let%expect_test _ =
|
|||||||
storage
|
storage
|
||||||
(pair (pair (list %auth key) (nat %counter)) (pair (string %id) (nat %threshold))) ;
|
(pair (pair (list %auth key) (nat %counter)) (pair (string %id) (nat %threshold))) ;
|
||||||
code { DUP ;
|
code { DUP ;
|
||||||
DUP ;
|
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
@ -310,20 +309,18 @@ let%expect_test _ =
|
|||||||
SWAP ;
|
SWAP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
CDR ;
|
CDR ;
|
||||||
DIP { DUP } ;
|
DIP 2 { DUP } ;
|
||||||
SWAP ;
|
DIG 2 ;
|
||||||
DIP 3 { DUP } ;
|
|
||||||
DIG 3 ;
|
|
||||||
CAR ;
|
CAR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CDR } ;
|
DIP { DIP { DUP } ; SWAP ; CAR ; CDR } ;
|
||||||
COMPARE ;
|
COMPARE ;
|
||||||
NEQ ;
|
NEQ ;
|
||||||
IF { PUSH string "Counters does not match" ; FAILWITH }
|
IF { PUSH string "Counters does not match" ; FAILWITH }
|
||||||
{ DIP 3 { DUP } ;
|
{ DIP 2 { DUP } ;
|
||||||
DIG 3 ;
|
DIG 2 ;
|
||||||
CDR ;
|
CDR ;
|
||||||
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CAR ; PUSH nat 0 ; SWAP ; PAIR } ;
|
DIP { DIP { DUP } ; SWAP ; CAR ; CAR ; PUSH nat 0 ; SWAP ; PAIR } ;
|
||||||
ITER { SWAP ;
|
ITER { SWAP ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DUP ;
|
DUP ;
|
||||||
@ -343,49 +340,44 @@ let%expect_test _ =
|
|||||||
DIP 2 { DUP } ;
|
DIP 2 { DUP } ;
|
||||||
DIG 2 ;
|
DIG 2 ;
|
||||||
IF_CONS
|
IF_CONS
|
||||||
{ DIP 5 { DUP } ;
|
{ DIP 3 { DUP } ;
|
||||||
DIG 5 ;
|
DIG 3 ;
|
||||||
DIP 4 { DUP } ;
|
|
||||||
DIG 4 ;
|
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DIP { DUP } ; SWAP ; HASH_KEY } ;
|
DIP { DUP ; HASH_KEY } ;
|
||||||
COMPARE ;
|
COMPARE ;
|
||||||
EQ ;
|
EQ ;
|
||||||
IF { DIP 6 { DUP } ;
|
IF { DUP ;
|
||||||
DIG 6 ;
|
DIP { DIP 3 { DUP } ;
|
||||||
DIP 2 { DUP } ;
|
DIG 3 ;
|
||||||
DIG 2 ;
|
|
||||||
DIP { DIP 5 { DUP } ;
|
|
||||||
DIG 5 ;
|
|
||||||
CDR ;
|
CDR ;
|
||||||
DIP { DIP 10 { DUP } ;
|
DIP { DIP 7 { DUP } ;
|
||||||
DIG 10 ;
|
DIG 7 ;
|
||||||
DIP { DIP 12 { DUP } ; DIG 12 ; CAR ; CAR } ;
|
DIP { DIP 9 { DUP } ; DIG 9 ; CAR ; CAR } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DIP 11 { DUP } ; DIG 11 ; CDR ; CAR ; CHAIN_ID ; SWAP ; PAIR } ;
|
DIP { DIP 8 { DUP } ; DIG 8 ; CDR ; CAR ; CHAIN_ID ; SWAP ; PAIR } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
PACK } } ;
|
PACK } } ;
|
||||||
CHECK_SIGNATURE ;
|
CHECK_SIGNATURE ;
|
||||||
IF { DIP 7 { DUP } ;
|
IF { DIP 5 { DUP } ;
|
||||||
DIG 7 ;
|
DIG 5 ;
|
||||||
PUSH nat 1 ;
|
PUSH nat 1 ;
|
||||||
ADD ;
|
ADD ;
|
||||||
DIP { DUP } ;
|
DIP 6 { DUP } ;
|
||||||
SWAP ;
|
DIG 6 ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 2 } }
|
DIP { DROP 2 } }
|
||||||
{ PUSH string "Invalid signature" ; FAILWITH } ;
|
{ PUSH string "Invalid signature" ; FAILWITH } ;
|
||||||
DIP 2 { DUP } ;
|
DIP 6 { DUP } ;
|
||||||
DIG 2 ;
|
DIG 6 ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 3 } }
|
DIP { DROP 2 } }
|
||||||
{ DUP } ;
|
{ DIP 5 { DUP } ; DIG 5 } ;
|
||||||
DIP 4 { DUP } ;
|
DIP 3 { DUP } ;
|
||||||
DIG 4 ;
|
DIG 3 ;
|
||||||
DIP 4 { DUP } ;
|
DIP 3 { DUP } ;
|
||||||
DIG 4 ;
|
DIG 3 ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
CDR ;
|
CDR ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
@ -393,7 +385,7 @@ let%expect_test _ =
|
|||||||
CAR ;
|
CAR ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 4 } }
|
DIP { DROP 3 } }
|
||||||
{ DUP } ;
|
{ DUP } ;
|
||||||
DIP 5 { DUP } ;
|
DIP 5 { DUP } ;
|
||||||
DIG 5 ;
|
DIG 5 ;
|
||||||
@ -427,19 +419,16 @@ let%expect_test _ =
|
|||||||
PAIR ;
|
PAIR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DROP 7 } } ;
|
DIP { DROP 7 } } ;
|
||||||
DIP 3 { DUP } ;
|
DUP ;
|
||||||
DIG 3 ;
|
|
||||||
DIP { DUP } ;
|
|
||||||
SWAP ;
|
|
||||||
CDR ;
|
CDR ;
|
||||||
DIP { DIP 4 { DUP } ; DIG 4 ; CDR ; CDR } ;
|
DIP { DIP 2 { DUP } ; DIG 2 ; CDR ; CDR } ;
|
||||||
COMPARE ;
|
COMPARE ;
|
||||||
LT ;
|
LT ;
|
||||||
IF { PUSH string "Not enough signatures passed the check" ; FAILWITH }
|
IF { PUSH string "Not enough signatures passed the check" ; FAILWITH }
|
||||||
{ DIP 4 { DUP } ;
|
{ DIP 2 { DUP } ;
|
||||||
DIG 4 ;
|
DIG 2 ;
|
||||||
DIP 5 { DUP } ;
|
DIP 3 { DUP } ;
|
||||||
DIG 5 ;
|
DIG 3 ;
|
||||||
CAR ;
|
CAR ;
|
||||||
CDR ;
|
CDR ;
|
||||||
PUSH nat 1 ;
|
PUSH nat 1 ;
|
||||||
@ -448,8 +437,8 @@ let%expect_test _ =
|
|||||||
SWAP ;
|
SWAP ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DUP } ;
|
DIP 3 { DUP } ;
|
||||||
SWAP ;
|
DIG 3 ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 2 } } ;
|
DIP { DROP 2 } } ;
|
||||||
@ -457,14 +446,14 @@ let%expect_test _ =
|
|||||||
DIG 3 ;
|
DIG 3 ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 4 } } ;
|
DIP { DROP 3 } } ;
|
||||||
DIP 2 { DUP } ;
|
DIP { DUP } ;
|
||||||
DIG 2 ;
|
SWAP ;
|
||||||
UNIT ;
|
UNIT ;
|
||||||
EXEC ;
|
EXEC ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 7 } } } |} ]
|
DIP { DROP 5 } } } |} ]
|
||||||
|
|
||||||
let%expect_test _ =
|
let%expect_test _ =
|
||||||
run_ligo_good [ "compile-contract" ; contract "multisig-v2.ligo" ; "main" ] ;
|
run_ligo_good [ "compile-contract" ; contract "multisig-v2.ligo" ; "main" ] ;
|
||||||
@ -557,17 +546,14 @@ let%expect_test _ =
|
|||||||
SWAP ;
|
SWAP ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 2 } }
|
DIP { DROP 2 } }
|
||||||
{ DIP 7 { DUP } ;
|
{ DUP ;
|
||||||
DIG 7 ;
|
|
||||||
DIP { DUP } ;
|
|
||||||
SWAP ;
|
|
||||||
SENDER ;
|
SENDER ;
|
||||||
MEM ;
|
MEM ;
|
||||||
IF { DUP }
|
IF { DIP 7 { DUP } ; DIG 7 }
|
||||||
{ DIP 8 { DUP } ;
|
{ DIP 7 { DUP } ;
|
||||||
|
DIG 7 ;
|
||||||
|
DIP 8 { DUP } ;
|
||||||
DIG 8 ;
|
DIG 8 ;
|
||||||
DIP 9 { DUP } ;
|
|
||||||
DIG 9 ;
|
|
||||||
CDR ;
|
CDR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
@ -577,7 +563,7 @@ let%expect_test _ =
|
|||||||
PUSH nat 1 ;
|
PUSH nat 1 ;
|
||||||
ADD ;
|
ADD ;
|
||||||
SOME ;
|
SOME ;
|
||||||
DIP { DIP 9 { DUP } ; DIG 9 ; CDR ; CAR ; CAR } ;
|
DIP { DIP 8 { DUP } ; DIG 8 ; CDR ; CAR ; CAR } ;
|
||||||
SENDER ;
|
SENDER ;
|
||||||
UPDATE ;
|
UPDATE ;
|
||||||
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
|
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
|
||||||
@ -585,18 +571,18 @@ let%expect_test _ =
|
|||||||
PAIR ;
|
PAIR ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DUP } ;
|
DIP 8 { DUP } ;
|
||||||
SWAP ;
|
DIG 8 ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 2 } } ;
|
DIP { DROP 2 } } ;
|
||||||
DIP 3 { DUP } ;
|
DIP 2 { DUP } ;
|
||||||
DIG 3 ;
|
DIG 2 ;
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP 3 { DUP } ;
|
DIP 2 { DUP } ;
|
||||||
DIG 3 ;
|
DIG 2 ;
|
||||||
PUSH bool True ;
|
PUSH bool True ;
|
||||||
SENDER ;
|
SENDER ;
|
||||||
UPDATE ;
|
UPDATE ;
|
||||||
@ -604,7 +590,7 @@ let%expect_test _ =
|
|||||||
CDR ;
|
CDR ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 3 } } ;
|
DIP { DROP 2 } } ;
|
||||||
DUP ;
|
DUP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
@ -680,18 +666,15 @@ let%expect_test _ =
|
|||||||
SWAP ;
|
SWAP ;
|
||||||
CDR ;
|
CDR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DUP } ;
|
DUP ;
|
||||||
SWAP ;
|
DIP { DIP 11 { DUP } ; DIG 11 } ;
|
||||||
DIP { DUP } ;
|
|
||||||
SWAP ;
|
|
||||||
DIP { DIP 12 { DUP } ; DIG 12 } ;
|
|
||||||
MEM ;
|
MEM ;
|
||||||
IF { DIP 2 { DUP } ;
|
IF { DIP { DUP } ;
|
||||||
DIG 2 ;
|
SWAP ;
|
||||||
DIP 2 { DUP } ;
|
DIP { DUP } ;
|
||||||
DIG 2 ;
|
SWAP ;
|
||||||
DIP { DIP 4 { DUP } ;
|
DIP { DIP 3 { DUP } ;
|
||||||
DIG 4 ;
|
DIG 3 ;
|
||||||
CDR ;
|
CDR ;
|
||||||
CDR ;
|
CDR ;
|
||||||
PUSH nat 1 ;
|
PUSH nat 1 ;
|
||||||
@ -699,30 +682,30 @@ let%expect_test _ =
|
|||||||
SUB ;
|
SUB ;
|
||||||
ABS ;
|
ABS ;
|
||||||
SOME ;
|
SOME ;
|
||||||
DIP { DIP 3 { DUP } ; DIG 3 ; CDR ; CAR ; CAR } } ;
|
DIP { DIP 2 { DUP } ; DIG 2 ; CDR ; CAR ; CAR } } ;
|
||||||
UPDATE ;
|
UPDATE ;
|
||||||
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
|
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DUP } ;
|
DIP 2 { DUP } ;
|
||||||
SWAP ;
|
DIG 2 ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 2 } }
|
DIP { DROP 2 } }
|
||||||
{ DUP } ;
|
{ DIP { DUP } ; SWAP } ;
|
||||||
|
DIP 3 { DUP } ;
|
||||||
|
DIG 3 ;
|
||||||
DIP 4 { DUP } ;
|
DIP 4 { DUP } ;
|
||||||
DIG 4 ;
|
DIG 4 ;
|
||||||
DIP 5 { DUP } ;
|
|
||||||
DIG 5 ;
|
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP 2 { DUP } ;
|
DIP 2 { DUP } ;
|
||||||
DIG 2 ;
|
DIG 2 ;
|
||||||
DIP { DROP ; CDR } ;
|
DIP { DROP ; CDR } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DROP 5 } } ;
|
DIP { DROP 4 } } ;
|
||||||
DIP 4 { DUP } ;
|
DIP 4 { DUP } ;
|
||||||
DIG 4 ;
|
DIG 4 ;
|
||||||
DIP 4 { DUP } ;
|
DIP 4 { DUP } ;
|
||||||
@ -776,30 +759,25 @@ let%expect_test _ =
|
|||||||
SWAP ;
|
SWAP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
PACK ;
|
PACK ;
|
||||||
DIP { DUP } ;
|
DUP ;
|
||||||
SWAP ;
|
DIP { DIP { DUP } ; SWAP ; CAR ; CDR ; CDR } ;
|
||||||
DIP { DUP } ;
|
|
||||||
SWAP ;
|
|
||||||
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CDR ; CDR } ;
|
|
||||||
GET ;
|
GET ;
|
||||||
IF_NONE
|
IF_NONE
|
||||||
{ DUP }
|
{ DIP { DUP } ; SWAP }
|
||||||
{ DUP ;
|
{ DUP ;
|
||||||
PUSH bool False ;
|
PUSH bool False ;
|
||||||
SENDER ;
|
SENDER ;
|
||||||
UPDATE ;
|
UPDATE ;
|
||||||
DIP 4 { DUP } ;
|
DIP { DUP } ;
|
||||||
DIG 4 ;
|
SWAP ;
|
||||||
DIP 2 { DUP } ;
|
|
||||||
DIG 2 ;
|
|
||||||
SIZE ;
|
SIZE ;
|
||||||
DIP { DIP { DUP } ; SWAP ; SIZE } ;
|
DIP { DUP ; SIZE } ;
|
||||||
COMPARE ;
|
COMPARE ;
|
||||||
NEQ ;
|
NEQ ;
|
||||||
IF { DIP 5 { DUP } ;
|
IF { DIP 3 { DUP } ;
|
||||||
DIG 5 ;
|
DIG 3 ;
|
||||||
DIP 6 { DUP } ;
|
DIP 4 { DUP } ;
|
||||||
DIG 6 ;
|
DIG 4 ;
|
||||||
CDR ;
|
CDR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
@ -811,7 +789,7 @@ let%expect_test _ =
|
|||||||
SUB ;
|
SUB ;
|
||||||
ABS ;
|
ABS ;
|
||||||
SOME ;
|
SOME ;
|
||||||
DIP { DIP 6 { DUP } ; DIG 6 ; CDR ; CAR ; CAR } ;
|
DIP { DIP 4 { DUP } ; DIG 4 ; CDR ; CAR ; CAR } ;
|
||||||
SENDER ;
|
SENDER ;
|
||||||
UPDATE ;
|
UPDATE ;
|
||||||
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
|
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
|
||||||
@ -819,26 +797,23 @@ let%expect_test _ =
|
|||||||
PAIR ;
|
PAIR ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DUP } ;
|
DIP 4 { DUP } ;
|
||||||
SWAP ;
|
DIG 4 ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 2 } }
|
DIP { DROP 2 } }
|
||||||
{ DUP } ;
|
{ DIP 3 { DUP } ; DIG 3 } ;
|
||||||
DUP ;
|
DIP { DUP } ;
|
||||||
DUP ;
|
SWAP ;
|
||||||
DIP 4 { DUP } ;
|
|
||||||
DIG 4 ;
|
|
||||||
SIZE ;
|
SIZE ;
|
||||||
PUSH nat 0 ;
|
PUSH nat 0 ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
COMPARE ;
|
COMPARE ;
|
||||||
EQ ;
|
EQ ;
|
||||||
IF { DIP { DUP } ;
|
IF { DUP ;
|
||||||
SWAP ;
|
DIP 4 { DUP } ;
|
||||||
DIP 8 { DUP } ;
|
DIG 4 ;
|
||||||
DIG 8 ;
|
DIP { DIP { DUP } ; SWAP ; CAR ; CDR ; CDR ; NONE (set address) } ;
|
||||||
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CDR ; CDR ; NONE (set address) } ;
|
|
||||||
UPDATE ;
|
UPDATE ;
|
||||||
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
|
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
@ -852,14 +827,14 @@ let%expect_test _ =
|
|||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 2 } }
|
DIP { DROP 2 } }
|
||||||
{ DUP ;
|
{ DUP ;
|
||||||
DIP 2 { DUP } ;
|
DIP { DUP } ;
|
||||||
DIG 2 ;
|
SWAP ;
|
||||||
DIP 9 { DUP } ;
|
DIP 5 { DUP } ;
|
||||||
DIG 9 ;
|
DIG 5 ;
|
||||||
DIP { DIP 6 { DUP } ;
|
DIP { DIP 3 { DUP } ;
|
||||||
DIG 6 ;
|
DIG 3 ;
|
||||||
SOME ;
|
SOME ;
|
||||||
DIP { DIP 3 { DUP } ; DIG 3 ; CAR ; CDR ; CDR } } ;
|
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CDR ; CDR } } ;
|
||||||
UPDATE ;
|
UPDATE ;
|
||||||
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
|
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
@ -868,17 +843,17 @@ let%expect_test _ =
|
|||||||
PAIR ;
|
PAIR ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP } } ;
|
DIP { DROP } } ;
|
||||||
DIP 7 { DUP } ;
|
DIP 5 { DUP } ;
|
||||||
DIG 7 ;
|
DIG 5 ;
|
||||||
DIP 3 { DUP } ;
|
DIP 2 { DUP } ;
|
||||||
DIG 3 ;
|
DIG 2 ;
|
||||||
DIP { DROP ; DUP } ;
|
DIP { DROP ; DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DROP 8 } } ;
|
DIP { DROP 5 } } ;
|
||||||
DUP ;
|
DUP ;
|
||||||
NIL operation ;
|
NIL operation ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 6 } } ;
|
DIP { DROP 5 } } ;
|
||||||
DIP { DROP 2 } } } |} ]
|
DIP { DROP 2 } } } |} ]
|
||||||
|
|
||||||
let%expect_test _ =
|
let%expect_test _ =
|
||||||
@ -892,11 +867,9 @@ let%expect_test _ =
|
|||||||
(pair (timestamp %start_time) (string %title)))
|
(pair (timestamp %start_time) (string %title)))
|
||||||
(pair (set %voters address) (nat %yea))) ;
|
(pair (set %voters address) (nat %yea))) ;
|
||||||
code { DUP ;
|
code { DUP ;
|
||||||
DUP ;
|
|
||||||
CAR ;
|
CAR ;
|
||||||
IF_LEFT
|
IF_LEFT
|
||||||
{ DUP ;
|
{ DUP ;
|
||||||
DUP ;
|
|
||||||
CAR ;
|
CAR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
PUSH nat 0 ;
|
PUSH nat 0 ;
|
||||||
@ -908,7 +881,7 @@ let%expect_test _ =
|
|||||||
PAIR ;
|
PAIR ;
|
||||||
NIL operation ;
|
NIL operation ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 2 } }
|
DIP { DROP } }
|
||||||
{ DUP ;
|
{ DUP ;
|
||||||
DIP { DIP { DUP } ; SWAP ; CDR } ;
|
DIP { DIP { DUP } ; SWAP ; CDR } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
@ -962,7 +935,7 @@ let%expect_test _ =
|
|||||||
NIL operation ;
|
NIL operation ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 4 } } ;
|
DIP { DROP 4 } } ;
|
||||||
DIP { DROP 2 } } } |}]
|
DIP { DROP } } } |}]
|
||||||
|
|
||||||
let%expect_test _ =
|
let%expect_test _ =
|
||||||
run_ligo_good [ "compile-contract" ; contract "implicit.mligo" ; "main" ] ;
|
run_ligo_good [ "compile-contract" ; contract "implicit.mligo" ; "main" ] ;
|
||||||
@ -1111,7 +1084,7 @@ let%expect_test _ =
|
|||||||
let%expect_test _ =
|
let%expect_test _ =
|
||||||
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_toplevel.mligo" ; "main" ] ;
|
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_toplevel.mligo" ; "main" ] ;
|
||||||
[%expect {|
|
[%expect {|
|
||||||
ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8. No free variable allowed in this lambda: variable 'store' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * string ))) : None return\n let rhs#713 = #P in\n let p = rhs#713.0 in\n let s = rhs#713.1 in\n ( LIST_EMPTY() : (type_operator: list(operation)) , store ) ,\n NONE() : (type_operator: option(key_hash)) ,\n 300000000mutez ,\n \"un\")","location":"in file \"create_contract_toplevel.mligo\", line 4, character 35 to line 8, character 8"}
|
ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8. No free variable allowed in this lambda: variable 'store' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * string ))) : None return\n let rhs#723 = #P in\n let p = rhs#723.0 in\n let s = rhs#723.1 in\n ( LIST_EMPTY() : (type_operator: list(operation)) , store ) ,\n NONE() : (type_operator: option(key_hash)) ,\n 300000000mutez ,\n \"un\")","location":"in file \"create_contract_toplevel.mligo\", line 4, character 35 to line 8, character 8"}
|
||||||
|
|
||||||
|
|
||||||
If you're not sure how to fix this error, you can
|
If you're not sure how to fix this error, you can
|
||||||
@ -1124,7 +1097,7 @@ ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8,
|
|||||||
|
|
||||||
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_var.mligo" ; "main" ] ;
|
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_var.mligo" ; "main" ] ;
|
||||||
[%expect {|
|
[%expect {|
|
||||||
ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5. No free variable allowed in this lambda: variable 'a' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * int ))) : None return\n let rhs#716 = #P in\n let p = rhs#716.0 in\n let s = rhs#716.1 in\n ( LIST_EMPTY() : (type_operator: list(operation)) , a ) ,\n NONE() : (type_operator: option(key_hash)) ,\n 300000000mutez ,\n 1)","location":"in file \"create_contract_var.mligo\", line 6, character 35 to line 10, character 5"}
|
ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5. No free variable allowed in this lambda: variable 'a' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * int ))) : None return\n let rhs#726 = #P in\n let p = rhs#726.0 in\n let s = rhs#726.1 in\n ( LIST_EMPTY() : (type_operator: list(operation)) , a ) ,\n NONE() : (type_operator: option(key_hash)) ,\n 300000000mutez ,\n 1)","location":"in file \"create_contract_var.mligo\", line 6, character 35 to line 10, character 5"}
|
||||||
|
|
||||||
|
|
||||||
If you're not sure how to fix this error, you can
|
If you're not sure how to fix this error, you can
|
||||||
|
@ -103,15 +103,21 @@ let occurs_count : expression_variable -> expression -> int =
|
|||||||
- ?
|
- ?
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let should_inline : expression_variable -> expression -> bool =
|
let is_variable : expression -> bool =
|
||||||
fun x e ->
|
fun e ->
|
||||||
occurs_count x e <= 1
|
match e.content with
|
||||||
|
| E_variable _ -> true
|
||||||
|
| _ -> false
|
||||||
|
|
||||||
|
let should_inline : expression_variable -> expression -> expression -> bool =
|
||||||
|
fun x e1 e2 ->
|
||||||
|
occurs_count x e2 <= 1 || is_variable e1
|
||||||
|
|
||||||
let inline_let : bool ref -> expression -> expression =
|
let inline_let : bool ref -> expression -> expression =
|
||||||
fun changed e ->
|
fun changed e ->
|
||||||
match e.content with
|
match e.content with
|
||||||
| E_let_in ((x, _a), should_inline_here, e1, e2) ->
|
| E_let_in ((x, _a), should_inline_here, e1, e2) ->
|
||||||
if is_pure e1 && (should_inline_here || should_inline x e2)
|
if is_pure e1 && (should_inline_here || should_inline x e1 e2)
|
||||||
then
|
then
|
||||||
let e2' = Subst.subst_expression ~body:e2 ~x:x ~expr:e1 in
|
let e2' = Subst.subst_expression ~body:e2 ~x:x ~expr:e1 in
|
||||||
(changed := true ; e2')
|
(changed := true ; e2')
|
||||||
|
Loading…
Reference in New Issue
Block a user