From 96a316f42350c08ac92a8e3ccdb9b14b7d18de83 Mon Sep 17 00:00:00 2001 From: effectfully Date: Thu, 25 Jul 2024 07:01:19 +0200 Subject: [PATCH] [Plinth] [Builtins] Fix 'writeBits' --- .../src/PlutusTx/Compiler/Builtins.hs | 8 + .../test/Plugin/Debug/9.6/fib.pir.golden | 152 +++++++++--------- .../test/Plugin/Debug/9.6/letFun.pir.golden | 70 ++++---- .../writeBits-integerToByteString.eval.golden | 1 + .../test/Plugin/Primitives/Spec.hs | 5 + .../Plugin/Profiling/9.6/addInt.pir.golden | 8 +- .../Plugin/Profiling/9.6/addInt3.eval.golden | 2 +- .../Profiling/9.6/argMismatch1.eval.golden | 12 +- .../Profiling/9.6/argMismatch2.eval.golden | 2 +- .../Plugin/Profiling/9.6/fact4.eval.golden | 72 ++++----- .../test/Plugin/Profiling/9.6/fib.pir.golden | 16 +- .../Plugin/Profiling/9.6/fib4.eval.golden | 148 ++++++++--------- .../test/Plugin/Profiling/9.6/id.eval.golden | 2 +- .../Plugin/Profiling/9.6/idCode.pir.golden | 4 +- .../Plugin/Profiling/9.6/letInFun.eval.golden | 20 +-- .../Profiling/9.6/letInFunMoreArg.eval.golden | 24 +-- .../Profiling/9.6/letRecInFun.eval.golden | 56 +++---- .../Plugin/Profiling/9.6/swap.eval.golden | 2 +- .../Profiling/9.6/typeclass.eval.golden | 24 +-- plutus-tx/src/PlutusTx/Builtins.hs | 8 +- plutus-tx/src/PlutusTx/Builtins/HasOpaque.hs | 12 ++ plutus-tx/src/PlutusTx/Builtins/Internal.hs | 8 + 22 files changed, 346 insertions(+), 310 deletions(-) create mode 100644 plutus-tx-plugin/test/Plugin/Primitives/9.6/writeBits-integerToByteString.eval.golden diff --git a/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs b/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs index 297f3297d41..7799bd8c604 100644 --- a/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs +++ b/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs @@ -228,6 +228,8 @@ builtinNames = [ , 'Builtins.head , 'Builtins.tail , 'Builtins.chooseList + , 'Builtins.mkNilInteger + , 'Builtins.mkNilBool , 'Builtins.mkNilData , 'Builtins.mkNilPairData , 'Builtins.mkCons @@ -332,6 +334,12 @@ defineBuiltinTerms = do -- Text constant defineBuiltinTerm annMayInline 'Builtins.emptyString $ PIR.mkConstant annMayInline ("" :: Text) + -- List constants + defineBuiltinTerm annMayInline 'Builtins.mkNilInteger $ + PIR.mkConstant annMayInline ([] @Integer) + defineBuiltinTerm annMayInline 'Builtins.mkNilBool $ + PIR.mkConstant annMayInline ([] @Bool) + -- The next two constants are 48 bytes long, so in fact we may not want to inline them. defineBuiltinTerm annMayInline 'Builtins.bls12_381_G1_compressed_generator $ PIR.mkConstant annMayInline BLS12_381.G1.compressed_generator diff --git a/plutus-tx-plugin/test/Plugin/Debug/9.6/fib.pir.golden b/plutus-tx-plugin/test/Plugin/Debug/9.6/fib.pir.golden index 7be80da7b1c..53808c671c1 100644 --- a/plutus-tx-plugin/test/Plugin/Debug/9.6/fib.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Debug/9.6/fib.pir.golden @@ -9,7 +9,7 @@ (strict) (vardecl { no-src-span } - addInteger-538 + addInteger-544 (fun { no-src-span } (con { no-src-span } integer) @@ -27,7 +27,7 @@ (nonstrict) (vardecl { no-src-span } - addInteger-543 + addInteger-549 (fun { no-src-span } (con { no-src-span } integer) @@ -40,7 +40,7 @@ ) (lam { no-src-span } - x-539 + x-545 (con { no-src-span } integer) (let { no-src-span } @@ -48,12 +48,12 @@ (termbind { no-src-span } (strict) - (vardecl { no-src-span } x-541 (con { no-src-span } integer)) - { no-src-span } x-539 + (vardecl { no-src-span } x-547 (con { no-src-span } integer)) + { no-src-span } x-545 ) (lam { no-src-span } - y-540 + y-546 (con { no-src-span } integer) (let { no-src-span } @@ -61,17 +61,17 @@ (termbind { no-src-span } (strict) - (vardecl { no-src-span } y-542 (con { no-src-span } integer)) - { no-src-span } y-540 + (vardecl { no-src-span } y-548 (con { no-src-span } integer)) + { no-src-span } y-546 ) [ { no-src-span } [ { no-src-span } - { no-src-span } addInteger-538 - { no-src-span } x-541 + { no-src-span } addInteger-544 + { no-src-span } x-547 ] - { no-src-span } y-542 + { no-src-span } y-548 ] ) ) @@ -82,11 +82,11 @@ { no-src-span } (datatype { no-src-span } - (tyvardecl { no-src-span } Bool-528 ({ no-src-span } type)) + (tyvardecl { no-src-span } Bool-534 ({ no-src-span } type)) - Bool_match-531 - (vardecl { no-src-span } True-529 { no-src-span } Bool-528) - (vardecl { no-src-span } False-530 { no-src-span } Bool-528) + Bool_match-537 + (vardecl { no-src-span } True-535 { no-src-span } Bool-534) + (vardecl { no-src-span } False-536 { no-src-span } Bool-534) ) ) (termbind @@ -94,7 +94,7 @@ (strict) (vardecl { no-src-span } - equalsInteger-527 + equalsInteger-533 (fun { no-src-span } (con { no-src-span } integer) @@ -112,18 +112,18 @@ (strict) (vardecl { no-src-span } - ifThenElse-525 + ifThenElse-531 (all { no-src-span } - a-526 + a-532 ({ no-src-span } type) (fun { no-src-span } (con { no-src-span } bool) (fun { no-src-span } - { no-src-span } a-526 - (fun { no-src-span } { no-src-span } a-526 { no-src-span } a-526) + { no-src-span } a-532 + (fun { no-src-span } { no-src-span } a-532 { no-src-span } a-532) ) ) ) @@ -135,20 +135,20 @@ (nonstrict) (vardecl { no-src-span } - equalsInteger-537 + equalsInteger-543 (fun { no-src-span } (con { no-src-span } integer) (fun { no-src-span } (con { no-src-span } integer) - { no-src-span } Bool-528 + { no-src-span } Bool-534 ) ) ) (lam { no-src-span } - x-532 + x-538 (con { no-src-span } integer) (let { no-src-span } @@ -156,12 +156,12 @@ (termbind { no-src-span } (strict) - (vardecl { no-src-span } x-534 (con { no-src-span } integer)) - { no-src-span } x-532 + (vardecl { no-src-span } x-540 (con { no-src-span } integer)) + { no-src-span } x-538 ) (lam { no-src-span } - y-533 + y-539 (con { no-src-span } integer) (let { no-src-span } @@ -169,21 +169,21 @@ (termbind { no-src-span } (strict) - (vardecl { no-src-span } y-535 (con { no-src-span } integer)) - { no-src-span } y-533 + (vardecl { no-src-span } y-541 (con { no-src-span } integer)) + { no-src-span } y-539 ) (termbind { no-src-span } (strict) - (vardecl { no-src-span } b-536 (con { no-src-span } bool)) + (vardecl { no-src-span } b-542 (con { no-src-span } bool)) [ { no-src-span } [ { no-src-span } - { no-src-span } equalsInteger-527 - { no-src-span } x-534 + { no-src-span } equalsInteger-533 + { no-src-span } x-540 ] - { no-src-span } y-535 + { no-src-span } y-541 ] ) [ @@ -194,14 +194,14 @@ { no-src-span } { { no-src-span } - { no-src-span } ifThenElse-525 - { no-src-span } Bool-528 + { no-src-span } ifThenElse-531 + { no-src-span } Bool-534 } - { no-src-span } b-536 + { no-src-span } b-542 ] - { no-src-span } True-529 + { no-src-span } True-535 ] - { no-src-span } False-530 + { no-src-span } False-536 ] ) ) @@ -213,7 +213,7 @@ (strict) (vardecl { no-src-span } - subtractInteger-519 + subtractInteger-525 (fun { no-src-span } (con { no-src-span } integer) @@ -231,7 +231,7 @@ (nonstrict) (vardecl { no-src-span } - subtractInteger-524 + subtractInteger-530 (fun { no-src-span } (con { no-src-span } integer) @@ -244,7 +244,7 @@ ) (lam { no-src-span } - x-520 + x-526 (con { no-src-span } integer) (let { no-src-span } @@ -252,12 +252,12 @@ (termbind { no-src-span } (strict) - (vardecl { no-src-span } x-522 (con { no-src-span } integer)) - { no-src-span } x-520 + (vardecl { no-src-span } x-528 (con { no-src-span } integer)) + { no-src-span } x-526 ) (lam { no-src-span } - y-521 + y-527 (con { no-src-span } integer) (let { no-src-span } @@ -265,17 +265,17 @@ (termbind { no-src-span } (strict) - (vardecl { no-src-span } y-523 (con { no-src-span } integer)) - { no-src-span } y-521 + (vardecl { no-src-span } y-529 (con { no-src-span } integer)) + { no-src-span } y-527 ) [ { no-src-span } [ { no-src-span } - { no-src-span } subtractInteger-519 - { no-src-span } x-522 + { no-src-span } subtractInteger-525 + { no-src-span } x-528 ] - { no-src-span } y-523 + { no-src-span } y-529 ] ) ) @@ -290,7 +290,7 @@ (nonstrict) (vardecl { no-src-span } - fib-544 + fib-550 (fun { no-src-span } (con { no-src-span } integer) @@ -299,7 +299,7 @@ ) (lam { no-src-span } - n-545 + n-551 (con { no-src-span } integer) (let { test/Plugin/Debug/Spec.hs:46:15-55:72 } @@ -309,10 +309,10 @@ (strict) (vardecl { test/Plugin/Debug/Spec.hs:46:15-55:72 } - n-546 + n-552 (con { test/Plugin/Debug/Spec.hs:46:15-55:72 } integer) ) - { test/Plugin/Debug/Spec.hs:46:15-55:72 } n-545 + { test/Plugin/Debug/Spec.hs:46:15-55:72 } n-551 ) { { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } @@ -325,15 +325,15 @@ [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } - Bool_match-531 + Bool_match-537 [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } - equalsInteger-537 + equalsInteger-543 { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:47:43-47:43 } - n-546 + n-552 ] (con { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:47:45-47:45 } @@ -344,7 +344,7 @@ ] (all { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } - dead-547 + dead-553 ({ test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } type) (con @@ -355,7 +355,7 @@ } (abs { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } - dead-548 + dead-554 ({ test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } type) (con @@ -367,7 +367,7 @@ ] (abs { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } - dead-549 + dead-555 ({ test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } type) { @@ -381,15 +381,15 @@ [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } - Bool_match-531 + Bool_match-537 [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } - equalsInteger-537 + equalsInteger-543 { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:50:51-50:51 } - n-546 + n-552 ] (con { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:50:53-50:53 } @@ -400,7 +400,7 @@ ] (all { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } - dead-550 + dead-556 ({ test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } type) (con @@ -411,7 +411,7 @@ } (abs { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } - dead-551 + dead-557 ({ test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } type) (con @@ -423,7 +423,7 @@ ] (abs { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } - dead-552 + dead-558 ({ test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } type) [ @@ -431,19 +431,19 @@ [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72 } - addInteger-543 + addInteger-549 [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:54:37-54:72 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:54:37-54:72 } - fib-544 + fib-550 [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:54:37-54:72, test/Plugin/Debug/Spec.hs:54:42-54:71 } [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:54:37-54:72, test/Plugin/Debug/Spec.hs:54:42-54:71 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:54:37-54:72, test/Plugin/Debug/Spec.hs:54:42-54:71 } - subtractInteger-524 + subtractInteger-530 { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:54:37-54:72, test/Plugin/Debug/Spec.hs:54:42-54:71, test/Plugin/Debug/Spec.hs:54:68-54:68 } - n-546 + n-552 ] (con { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:54:37-54:72, test/Plugin/Debug/Spec.hs:54:42-54:71, test/Plugin/Debug/Spec.hs:54:70-54:70 } @@ -456,15 +456,15 @@ [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:55:37-55:72 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:55:37-55:72 } - fib-544 + fib-550 [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:55:37-55:72, test/Plugin/Debug/Spec.hs:55:42-55:71 } [ { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:55:37-55:72, test/Plugin/Debug/Spec.hs:55:42-55:71 } { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:55:37-55:72, test/Plugin/Debug/Spec.hs:55:42-55:71 } - subtractInteger-524 + subtractInteger-530 { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:55:37-55:72, test/Plugin/Debug/Spec.hs:55:42-55:71, test/Plugin/Debug/Spec.hs:55:68-55:68 } - n-546 + n-552 ] (con { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72, test/Plugin/Debug/Spec.hs:53:33-55:72, test/Plugin/Debug/Spec.hs:55:37-55:72, test/Plugin/Debug/Spec.hs:55:42-55:71, test/Plugin/Debug/Spec.hs:55:70-55:70 } @@ -478,28 +478,28 @@ ] (all { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } - dead-553 + dead-559 ({ test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } type) { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72, test/Plugin/Debug/Spec.hs:50:25-55:72 } - dead-553 + dead-559 ) } ) ] (all { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } - dead-554 + dead-560 ({ test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } type) { test/Plugin/Debug/Spec.hs:46:15-55:72, test/Plugin/Debug/Spec.hs:47:17-55:72 } - dead-554 + dead-560 ) } ) ) ) - { test/Plugin/Debug/Spec.hs:45:9-57:9 } fib-544 + { test/Plugin/Debug/Spec.hs:45:9-57:9 } fib-550 ) ) ) \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Debug/9.6/letFun.pir.golden b/plutus-tx-plugin/test/Plugin/Debug/9.6/letFun.pir.golden index e3ff78c1481..acfa5ab236a 100644 --- a/plutus-tx-plugin/test/Plugin/Debug/9.6/letFun.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Debug/9.6/letFun.pir.golden @@ -8,11 +8,11 @@ { no-src-span } (datatype { no-src-span } - (tyvardecl { no-src-span } Bool-445 ({ no-src-span } type)) + (tyvardecl { no-src-span } Bool-451 ({ no-src-span } type)) - Bool_match-448 - (vardecl { no-src-span } True-446 { no-src-span } Bool-445) - (vardecl { no-src-span } False-447 { no-src-span } Bool-445) + Bool_match-454 + (vardecl { no-src-span } True-452 { no-src-span } Bool-451) + (vardecl { no-src-span } False-453 { no-src-span } Bool-451) ) ) (termbind @@ -20,7 +20,7 @@ (strict) (vardecl { no-src-span } - equalsInteger-444 + equalsInteger-450 (fun { no-src-span } (con { no-src-span } integer) @@ -38,18 +38,18 @@ (strict) (vardecl { no-src-span } - ifThenElse-442 + ifThenElse-448 (all { no-src-span } - a-443 + a-449 ({ no-src-span } type) (fun { no-src-span } (con { no-src-span } bool) (fun { no-src-span } - { no-src-span } a-443 - (fun { no-src-span } { no-src-span } a-443 { no-src-span } a-443) + { no-src-span } a-449 + (fun { no-src-span } { no-src-span } a-449 { no-src-span } a-449) ) ) ) @@ -61,20 +61,20 @@ (nonstrict) (vardecl { no-src-span } - equalsInteger-454 + equalsInteger-460 (fun { no-src-span } (con { no-src-span } integer) (fun { no-src-span } (con { no-src-span } integer) - { no-src-span } Bool-445 + { no-src-span } Bool-451 ) ) ) (lam { no-src-span } - x-449 + x-455 (con { no-src-span } integer) (let { no-src-span } @@ -82,12 +82,12 @@ (termbind { no-src-span } (strict) - (vardecl { no-src-span } x-451 (con { no-src-span } integer)) - { no-src-span } x-449 + (vardecl { no-src-span } x-457 (con { no-src-span } integer)) + { no-src-span } x-455 ) (lam { no-src-span } - y-450 + y-456 (con { no-src-span } integer) (let { no-src-span } @@ -95,21 +95,21 @@ (termbind { no-src-span } (strict) - (vardecl { no-src-span } y-452 (con { no-src-span } integer)) - { no-src-span } y-450 + (vardecl { no-src-span } y-458 (con { no-src-span } integer)) + { no-src-span } y-456 ) (termbind { no-src-span } (strict) - (vardecl { no-src-span } b-453 (con { no-src-span } bool)) + (vardecl { no-src-span } b-459 (con { no-src-span } bool)) [ { no-src-span } [ { no-src-span } - { no-src-span } equalsInteger-444 - { no-src-span } x-451 + { no-src-span } equalsInteger-450 + { no-src-span } x-457 ] - { no-src-span } y-452 + { no-src-span } y-458 ] ) [ @@ -120,14 +120,14 @@ { no-src-span } { { no-src-span } - { no-src-span } ifThenElse-442 - { no-src-span } Bool-445 + { no-src-span } ifThenElse-448 + { no-src-span } Bool-451 } - { no-src-span } b-453 + { no-src-span } b-459 ] - { no-src-span } True-446 + { no-src-span } True-452 ] - { no-src-span } False-447 + { no-src-span } False-453 ] ) ) @@ -136,7 +136,7 @@ ) (lam { no-src-span } - ds-455 + ds-461 (con { no-src-span } integer) (let { test/Plugin/Debug/Spec.hs:38:9-38:87 } @@ -146,14 +146,14 @@ (strict) (vardecl { test/Plugin/Debug/Spec.hs:38:9-38:87 } - ds-457 + ds-463 (con { test/Plugin/Debug/Spec.hs:38:9-38:87 } integer) ) - { test/Plugin/Debug/Spec.hs:38:9-38:87 } ds-455 + { test/Plugin/Debug/Spec.hs:38:9-38:87 } ds-461 ) (lam { no-src-span } - ds-456 + ds-462 (con { no-src-span } integer) (let { test/Plugin/Debug/Spec.hs:38:9-38:87 } @@ -163,22 +163,22 @@ (strict) (vardecl { test/Plugin/Debug/Spec.hs:38:9-38:87 } - ds-458 + ds-464 (con { test/Plugin/Debug/Spec.hs:38:9-38:87 } integer) ) - { test/Plugin/Debug/Spec.hs:38:9-38:87 } ds-456 + { test/Plugin/Debug/Spec.hs:38:9-38:87 } ds-462 ) [ { test/Plugin/Debug/Spec.hs:38:9-38:87, test/Plugin/Debug/Spec.hs:38:44-38:86, test/Plugin/Debug/Spec.hs:38:54-38:79 } [ { test/Plugin/Debug/Spec.hs:38:9-38:87, test/Plugin/Debug/Spec.hs:38:44-38:86, test/Plugin/Debug/Spec.hs:38:54-38:79 } { test/Plugin/Debug/Spec.hs:38:9-38:87, test/Plugin/Debug/Spec.hs:38:44-38:86, test/Plugin/Debug/Spec.hs:38:54-38:79 } - equalsInteger-454 + equalsInteger-460 { test/Plugin/Debug/Spec.hs:38:9-38:87, test/Plugin/Debug/Spec.hs:38:44-38:86, test/Plugin/Debug/Spec.hs:38:54-38:79, test/Plugin/Debug/Spec.hs:38:77-38:77 } - ds-457 + ds-463 ] { test/Plugin/Debug/Spec.hs:38:9-38:87, test/Plugin/Debug/Spec.hs:38:44-38:86, test/Plugin/Debug/Spec.hs:38:54-38:79, test/Plugin/Debug/Spec.hs:38:79-38:79 } - ds-458 + ds-464 ] ) ) diff --git a/plutus-tx-plugin/test/Plugin/Primitives/9.6/writeBits-integerToByteString.eval.golden b/plutus-tx-plugin/test/Plugin/Primitives/9.6/writeBits-integerToByteString.eval.golden new file mode 100644 index 00000000000..aaac7478dd5 --- /dev/null +++ b/plutus-tx-plugin/test/Plugin/Primitives/9.6/writeBits-integerToByteString.eval.golden @@ -0,0 +1 @@ +#00000000002b \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Primitives/Spec.hs b/plutus-tx-plugin/test/Plugin/Primitives/Spec.hs index 457e08b47a9..1fabfd93a7a 100644 --- a/plutus-tx-plugin/test/Plugin/Primitives/Spec.hs +++ b/plutus-tx-plugin/test/Plugin/Primitives/Spec.hs @@ -74,6 +74,7 @@ primitives = testNested "Primitives" . pure $ testNestedGhc , goldenPir "deconstructorData2" deconstructData2 , goldenUEval "deconstructData2" [ toUPlc deconstructData2, toUPlc constructData2 ] , goldenUEval "deconstructData3" [ toUPlc deconstructData3, toUPlc constructData3 ] + , goldenUEval "writeBits-integerToByteString" [ writeBitsIntegerToByteString ] ] string :: CompiledCode Builtins.BuiltinString @@ -190,3 +191,7 @@ deconstructData3 = plc (Proxy @"deconstructData2") (\(d :: Builtins.BuiltinData) matchData1 :: CompiledCode (Builtins.BuiltinData -> Maybe Integer) matchData1 = plc (Proxy @"matchData1") (\(d :: Builtins.BuiltinData) -> (Builtins.matchData d (\_ _ -> Nothing) (const Nothing) (const Nothing) (Just) (const Nothing))) + +writeBitsIntegerToByteString :: CompiledCode (P.BuiltinByteString) +writeBitsIntegerToByteString = plc (Proxy @"writeBitsIntegerToByteString") + (P.writeBits (P.integerToByteString Builtins.BigEndian 6 15) [0, 2, 5] [True, False, True]) diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden index b714fb429ee..d77b76dda76 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden @@ -13,9 +13,9 @@ program in trace {unit -> integer} - "entering addInteger-129" + "entering addInteger-131" (\(thunk : unit) -> - trace {integer} "exiting addInteger-129" (addInteger x y)) + trace {integer} "exiting addInteger-131" (addInteger x y)) () ~addInt : integer -> integer -> integer = \(x : integer) -> @@ -24,9 +24,9 @@ program in trace {unit -> integer -> integer} - "entering addInt-126" + "entering addInt-128" (\(thunk : unit) -> - trace {integer -> integer} "exiting addInt-126" (addInteger x)) + trace {integer -> integer} "exiting addInt-128" (addInteger x)) () in addInt) \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden index 9bd01c9535d..66b848fa868 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden @@ -1 +1 @@ -[entering addInt-126, exiting addInt-126] \ No newline at end of file +[entering addInt-128, exiting addInt-128] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden index 14e3e61691c..19f028f27ca 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden @@ -1,6 +1,6 @@ -[ entering runIdentity-129 -, exiting runIdentity-129 -, entering newtypeFunction-137 -, exiting newtypeFunction-137 -, entering `$fFoldableIdentity`-131 -, exiting `$fFoldableIdentity`-131 ] \ No newline at end of file +[ entering runIdentity-131 +, exiting runIdentity-131 +, entering newtypeFunction-139 +, exiting newtypeFunction-139 +, entering `$fFoldableIdentity`-133 +, exiting `$fFoldableIdentity`-133 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden index b0bc86d7306..866a739a4c8 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden @@ -1 +1 @@ -[entering obscuredFunction-127, exiting obscuredFunction-127] \ No newline at end of file +[entering obscuredFunction-129, exiting obscuredFunction-129] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden index 0d688af7c21..33f55c5979c 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden @@ -1,36 +1,36 @@ -[ entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-150 -, exiting subtractInteger-150 -, entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-150 -, exiting subtractInteger-150 -, entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-150 -, exiting subtractInteger-150 -, entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-150 -, exiting subtractInteger-150 -, entering fact-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fact-126 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 -, exiting fact-126 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 -, exiting fact-126 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 -, exiting fact-126 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 -, exiting fact-126 ] \ No newline at end of file +[ entering fact-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering subtractInteger-152 +, exiting subtractInteger-152 +, entering fact-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering subtractInteger-152 +, exiting subtractInteger-152 +, entering fact-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering subtractInteger-152 +, exiting subtractInteger-152 +, entering fact-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering subtractInteger-152 +, exiting subtractInteger-152 +, entering fact-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, exiting fact-128 +, entering multiplyInteger-146 +, exiting multiplyInteger-146 +, exiting fact-128 +, entering multiplyInteger-146 +, exiting multiplyInteger-146 +, exiting fact-128 +, entering multiplyInteger-146 +, exiting multiplyInteger-146 +, exiting fact-128 +, entering multiplyInteger-146 +, exiting multiplyInteger-146 +, exiting fact-128 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden index 6df2672558c..c53e980e4c4 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden @@ -13,9 +13,9 @@ program in trace {unit -> integer} - "entering addInteger-148" + "entering addInteger-150" (\(thunk : unit) -> - trace {integer} "exiting addInteger-148" (addInteger x y)) + trace {integer} "exiting addInteger-150" (addInteger x y)) () data Bool | Bool_match where True : Bool @@ -33,11 +33,11 @@ program in trace {unit -> Bool} - "entering equalsInteger-133" + "entering equalsInteger-135" (\(thunk : unit) -> trace {Bool} - "exiting equalsInteger-133" + "exiting equalsInteger-135" (let !b : bool = equalsInteger x y in @@ -55,11 +55,11 @@ program in trace {unit -> integer} - "entering subtractInteger-154" + "entering subtractInteger-156" (\(thunk : unit) -> trace {integer} - "exiting subtractInteger-154" + "exiting subtractInteger-156" (subtractInteger x y)) () in @@ -71,11 +71,11 @@ program in trace {unit -> integer} - "entering fib-126" + "entering fib-128" (\(thunk : unit) -> trace {integer} - "exiting fib-126" + "exiting fib-128" (Bool_match (equalsInteger n 0) {all dead. integer} diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden index dd4c4ebeacf..693c65f8713 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden @@ -1,74 +1,74 @@ -[ entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering addInteger-148 -, exiting addInteger-148 -, exiting fib-126 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering addInteger-148 -, exiting addInteger-148 -, exiting fib-126 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering fib-126 -, entering equalsInteger-133 -, exiting equalsInteger-133 -, exiting fib-126 -, entering addInteger-148 -, exiting addInteger-148 -, exiting fib-126 -, entering addInteger-148 -, exiting addInteger-148 -, exiting fib-126 ] \ No newline at end of file +[ entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, exiting fib-128 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, exiting fib-128 +, entering addInteger-150 +, exiting addInteger-150 +, exiting fib-128 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, exiting fib-128 +, entering addInteger-150 +, exiting addInteger-150 +, exiting fib-128 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, exiting fib-128 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering fib-128 +, entering equalsInteger-135 +, exiting equalsInteger-135 +, exiting fib-128 +, entering addInteger-150 +, exiting addInteger-150 +, exiting fib-128 +, entering addInteger-150 +, exiting addInteger-150 +, exiting fib-128 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden index b44a413ba8b..5e31f19d924 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden @@ -1 +1 @@ -[entering id-127, exiting id-127, entering id-127, exiting id-127] \ No newline at end of file +[entering id-129, exiting id-129, entering id-129, exiting id-129] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden index 7bb5394e1a3..e8874d71960 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden @@ -6,8 +6,8 @@ program \(x : a) -> trace {unit -> a} - "entering id-127" - (\(thunk : unit) -> trace {a} "exiting id-127" x) + "entering id-129" + (\(thunk : unit) -> trace {a} "exiting id-129" x) () in id {integer} (id {integer} 1)) \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden index 55db6efde8c..e598b91086d 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden @@ -1,10 +1,10 @@ -[ entering f-138 -, entering addInteger-132 -, exiting addInteger-132 -, exiting f-138 -, entering f-138 -, entering addInteger-132 -, exiting addInteger-132 -, exiting f-138 -, entering addInteger-132 -, exiting addInteger-132 ] \ No newline at end of file +[ entering f-140 +, entering addInteger-134 +, exiting addInteger-134 +, exiting f-140 +, entering f-140 +, entering addInteger-134 +, exiting addInteger-134 +, exiting f-140 +, entering addInteger-134 +, exiting addInteger-134 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden index dcf5f62de33..42995b25478 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden @@ -1,12 +1,12 @@ -[ entering f-140 -, entering addInteger-134 -, exiting addInteger-134 -, exiting f-140 -, entering f-140 -, entering addInteger-134 -, exiting addInteger-134 -, exiting f-140 -, entering addInteger-134 -, exiting addInteger-134 -, entering multiplyInteger-142 -, exiting multiplyInteger-142 ] \ No newline at end of file +[ entering f-142 +, entering addInteger-136 +, exiting addInteger-136 +, exiting f-142 +, entering f-142 +, entering addInteger-136 +, exiting addInteger-136 +, exiting f-142 +, entering addInteger-136 +, exiting addInteger-136 +, entering multiplyInteger-144 +, exiting multiplyInteger-144 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden index 29dd653b9b7..dce946b6315 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden @@ -1,28 +1,28 @@ -[ entering f-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering f-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering f-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering f-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, exiting f-128 -, entering addInteger-146 -, exiting addInteger-146 -, exiting f-128 -, entering addInteger-146 -, exiting addInteger-146 -, exiting f-128 -, entering addInteger-146 -, exiting addInteger-146 -, exiting f-128 ] \ No newline at end of file +[ entering f-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-154 +, exiting subtractInteger-154 +, entering f-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-154 +, exiting subtractInteger-154 +, entering f-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-154 +, exiting subtractInteger-154 +, entering f-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, exiting f-130 +, entering addInteger-148 +, exiting addInteger-148 +, exiting f-130 +, entering addInteger-148 +, exiting addInteger-148 +, exiting f-130 +, entering addInteger-148 +, exiting addInteger-148 +, exiting f-130 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden index 95ccf2e19ca..ea3312abd43 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden @@ -1 +1 @@ -[entering swap-133, exiting swap-133] \ No newline at end of file +[entering swap-135, exiting swap-135] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden index fe995dbadbe..5698abc5173 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden @@ -1,12 +1,12 @@ -[ entering useTypeclass-135 -, entering methodA-149 -, exiting methodA-149 -, entering addInteger-142 -, exiting addInteger-142 -, entering methodB-160 -, exiting methodB-160 -, entering subtractInteger-172 -, exiting subtractInteger-172 -, entering addInteger-142 -, exiting addInteger-142 -, exiting useTypeclass-135 ] \ No newline at end of file +[ entering useTypeclass-137 +, entering methodA-151 +, exiting methodA-151 +, entering addInteger-144 +, exiting addInteger-144 +, entering methodB-162 +, exiting methodB-162 +, entering subtractInteger-174 +, exiting subtractInteger-174 +, entering addInteger-144 +, exiting addInteger-144 +, exiting useTypeclass-137 ] \ No newline at end of file diff --git a/plutus-tx/src/PlutusTx/Builtins.hs b/plutus-tx/src/PlutusTx/Builtins.hs index 6b439ae23fb..65a6fc6ecf9 100644 --- a/plutus-tx/src/PlutusTx/Builtins.hs +++ b/plutus-tx/src/PlutusTx/Builtins.hs @@ -108,9 +108,10 @@ module PlutusTx.Builtins ( , toOpaque , fromBuiltin , toBuiltin + -- * Logical + , ByteOrder (..) , integerToByteString , byteStringToInteger - -- * Logical , andByteString , orByteString , xorByteString @@ -350,7 +351,7 @@ remainderInteger x y = fromOpaque (BI.remainderInteger (toOpaque x) (toOpaque y) {-# INLINABLE greaterThanInteger #-} -- | Check whether one 'Integer' is greater than another. greaterThanInteger :: Integer -> Integer -> Bool -greaterThanInteger x y = BI.ifThenElse (BI.lessThanEqualsInteger x y ) False True +greaterThanInteger x y = BI.ifThenElse (BI.lessThanEqualsInteger x y) False True {-# INLINABLE greaterThanEqualsInteger #-} -- | Check whether one 'Integer' is greater than or equal to another. @@ -636,6 +637,7 @@ bls12_381_finalVerify a b = fromOpaque (BI.bls12_381_finalVerify a b) byteOrderToBool :: ByteOrder -> Bool byteOrderToBool BigEndian = True byteOrderToBool LittleEndian = False +{-# INLINABLE byteOrderToBool #-} -- | Convert a 'BuiltinInteger' into a 'BuiltinByteString', as described in -- [CIP-121](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0121). @@ -823,7 +825,7 @@ writeBits :: [Integer] -> [Bool] -> BuiltinByteString -writeBits bs ixes bits = BI.writeBits bs (toBuiltin ixes) (toBuiltin bits) +writeBits bs ixes bits = BI.writeBits bs (toOpaque ixes) (toOpaque bits) -- | Given a length (first argument) and a byte (second argument), produce a 'BuiltinByteString' of -- that length, with that byte in every position. Will error if given a negative length, or a second diff --git a/plutus-tx/src/PlutusTx/Builtins/HasOpaque.hs b/plutus-tx/src/PlutusTx/Builtins/HasOpaque.hs index f0a643ce192..13e28652e18 100644 --- a/plutus-tx/src/PlutusTx/Builtins/HasOpaque.hs +++ b/plutus-tx/src/PlutusTx/Builtins/HasOpaque.hs @@ -204,6 +204,18 @@ instance HasFromOpaque BuiltinBool Bool where fromOpaque b = ifThenElse b True False {-# INLINABLE fromOpaque #-} +instance HasToOpaque [BuiltinInteger] (BuiltinList BuiltinInteger) where + toOpaque = goList where + goList :: [BuiltinInteger] -> BuiltinList BuiltinInteger + goList [] = mkNilInteger + goList (d:ds) = mkCons (toOpaque d) (goList ds) + {-# INLINABLE toOpaque #-} +instance HasToOpaque [Bool] (BuiltinList BuiltinBool) where + toOpaque = goList where + goList :: [Bool] -> BuiltinList BuiltinBool + goList [] = mkNilBool + goList (d:ds) = mkCons (toOpaque d) (goList ds) + {-# INLINABLE toOpaque #-} instance HasToOpaque [BuiltinData] (BuiltinList BuiltinData) where toOpaque = goList where goList :: [BuiltinData] -> BuiltinList BuiltinData diff --git a/plutus-tx/src/PlutusTx/Builtins/Internal.hs b/plutus-tx/src/PlutusTx/Builtins/Internal.hs index 690d899a92b..8960ded91f4 100644 --- a/plutus-tx/src/PlutusTx/Builtins/Internal.hs +++ b/plutus-tx/src/PlutusTx/Builtins/Internal.hs @@ -403,6 +403,14 @@ chooseList :: BuiltinList a -> b -> b -> b chooseList (BuiltinList []) b1 _ = b1 chooseList (BuiltinList (_:_)) _ b2 = b2 +{-# NOINLINE mkNilInteger #-} +mkNilInteger :: BuiltinList BuiltinInteger +mkNilInteger = BuiltinList [] + +{-# NOINLINE mkNilBool #-} +mkNilBool :: BuiltinList BuiltinBool +mkNilBool = BuiltinList [] + {-# NOINLINE mkNilData #-} mkNilData :: BuiltinUnit -> BuiltinList BuiltinData mkNilData _ = BuiltinList []