@@ -64,6 +64,7 @@ import {
6464 TypeParametersExpression ,
6565 TypedIdentifier ,
6666 id ,
67+ tArrowFunctionExpression ,
6768 tBinaryExpression ,
6869 tCodeAsIs ,
6970 tComment ,
@@ -778,7 +779,28 @@ export function loadBoolTrue(slice: Slice): Bool {
778779 let currentParamOutside = storeParametersOutside [ 0 ] ;
779780 let currentParamInside = storeParametersInside [ 0 ] ;
780781 if ( subExprInfo . loadExpr ) {
781- result . loadExpr = loadTupleExpr ( arrayLength , subExprInfo . loadExpr ) ;
782+ // Special handling for arrays of Cell references - use loadRef() instead of asCell()
783+ if ( fieldType . value . kind == 'TLBCellType' ) {
784+ result . loadExpr = tFunctionCall (
785+ tMemberExpression (
786+ tFunctionCall ( tMemberExpression ( id ( 'Array' ) , id ( 'from' ) ) , [
787+ tFunctionCall (
788+ tMemberExpression ( tFunctionCall ( id ( 'Array' ) , [ arrayLength ] ) , id ( 'keys' ) ) ,
789+ [ ] ,
790+ ) ,
791+ ] ) ,
792+ id ( 'map' ) ,
793+ ) ,
794+ [
795+ tArrowFunctionExpression (
796+ [ ] ,
797+ [ tReturnStatement ( tFunctionCall ( tMemberExpression ( id ( theSlice ) , id ( 'loadRef' ) ) , [ ] ) ) ] ,
798+ ) ,
799+ ] ,
800+ ) ;
801+ } else {
802+ result . loadExpr = loadTupleExpr ( arrayLength , subExprInfo . loadExpr ) ;
803+ }
782804 }
783805 if (
784806 currentParamOutside &&
@@ -787,16 +809,44 @@ export function loadBoolTrue(slice: Slice): Bool {
787809 subExprInfo . storeStmtOutside
788810 ) {
789811 if ( subExprInfo . storeFunctionExpr && subExprInfo . storeStmtInside ) {
790- result . storeStmtOutside = storeTupleStmt (
791- currentParamOutside ,
792- subExprInfo . storeStmtInside ,
793- subExprInfo . typeParamExpr ,
794- ) ;
795- result . storeStmtInside = storeTupleStmt (
796- currentParamInside ,
797- subExprInfo . storeStmtInside ,
798- subExprInfo . typeParamExpr ,
799- ) ;
812+ // Special handling for arrays of Cell references - use storeRef() instead of storeSlice()
813+ if ( fieldType . value . kind == 'TLBCellType' ) {
814+ result . storeStmtOutside = tExpressionStatement (
815+ tFunctionCall ( tMemberExpression ( currentParamOutside , id ( 'forEach' ) ) , [
816+ tArrowFunctionExpression (
817+ [ tTypedIdentifier ( id ( 'arg' ) , id ( 'Cell' ) ) ] ,
818+ [
819+ tExpressionStatement (
820+ tFunctionCall ( tMemberExpression ( id ( theCell ) , id ( 'storeRef' ) ) , [ id ( 'arg' ) ] ) ,
821+ ) ,
822+ ] ,
823+ ) ,
824+ ] ) ,
825+ ) ;
826+ result . storeStmtInside = tExpressionStatement (
827+ tFunctionCall ( tMemberExpression ( currentParamInside , id ( 'forEach' ) ) , [
828+ tArrowFunctionExpression (
829+ [ tTypedIdentifier ( id ( 'arg' ) , id ( 'Cell' ) ) ] ,
830+ [
831+ tExpressionStatement (
832+ tFunctionCall ( tMemberExpression ( id ( theCell ) , id ( 'storeRef' ) ) , [ id ( 'arg' ) ] ) ,
833+ ) ,
834+ ] ,
835+ ) ,
836+ ] ) ,
837+ ) ;
838+ } else {
839+ result . storeStmtOutside = storeTupleStmt (
840+ currentParamOutside ,
841+ subExprInfo . storeStmtInside ,
842+ subExprInfo . typeParamExpr ,
843+ ) ;
844+ result . storeStmtInside = storeTupleStmt (
845+ currentParamInside ,
846+ subExprInfo . storeStmtInside ,
847+ subExprInfo . typeParamExpr ,
848+ ) ;
849+ }
800850 }
801851 }
802852 if ( subExprInfo . typeParamExpr ) {
0 commit comments