@@ -64,6 +64,7 @@ import {
6464 TypeParametersExpression ,
6565 TypedIdentifier ,
6666 id ,
67+ tArrowFunctionExpression ,
6768 tBinaryExpression ,
6869 tCodeAsIs ,
6970 tComment ,
@@ -778,7 +779,24 @@ 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 ( tMemberExpression ( tFunctionCall ( id ( 'Array' ) , [ arrayLength ] ) , id ( 'keys' ) ) , [ ] ) ,
788+ ] ) ,
789+ id ( 'map' ) ,
790+ ) ,
791+ [
792+ tArrowFunctionExpression ( [ ] , [
793+ tReturnStatement ( tFunctionCall ( tMemberExpression ( id ( theSlice ) , id ( 'loadRef' ) ) , [ ] ) ) ,
794+ ] ) ,
795+ ] ,
796+ ) ;
797+ } else {
798+ result . loadExpr = loadTupleExpr ( arrayLength , subExprInfo . loadExpr ) ;
799+ }
782800 }
783801 if (
784802 currentParamOutside &&
@@ -787,16 +805,38 @@ export function loadBoolTrue(slice: Slice): Bool {
787805 subExprInfo . storeStmtOutside
788806 ) {
789807 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- ) ;
808+ // Special handling for arrays of Cell references - use storeRef() instead of storeSlice()
809+ if ( fieldType . value . kind == 'TLBCellType' ) {
810+ result . storeStmtOutside = tExpressionStatement (
811+ tFunctionCall ( tMemberExpression ( currentParamOutside , id ( 'forEach' ) ) , [
812+ tArrowFunctionExpression ( [ tTypedIdentifier ( id ( 'arg' ) , id ( 'Cell' ) ) ] , [
813+ tExpressionStatement (
814+ tFunctionCall ( tMemberExpression ( id ( theCell ) , id ( 'storeRef' ) ) , [ id ( 'arg' ) ] ) ,
815+ ) ,
816+ ] ) ,
817+ ] ) ,
818+ ) ;
819+ result . storeStmtInside = tExpressionStatement (
820+ tFunctionCall ( tMemberExpression ( currentParamInside , id ( 'forEach' ) ) , [
821+ tArrowFunctionExpression ( [ tTypedIdentifier ( id ( 'arg' ) , id ( 'Cell' ) ) ] , [
822+ tExpressionStatement (
823+ tFunctionCall ( tMemberExpression ( id ( theCell ) , id ( 'storeRef' ) ) , [ id ( 'arg' ) ] ) ,
824+ ) ,
825+ ] ) ,
826+ ] ) ,
827+ ) ;
828+ } else {
829+ result . storeStmtOutside = storeTupleStmt (
830+ currentParamOutside ,
831+ subExprInfo . storeStmtInside ,
832+ subExprInfo . typeParamExpr ,
833+ ) ;
834+ result . storeStmtInside = storeTupleStmt (
835+ currentParamInside ,
836+ subExprInfo . storeStmtInside ,
837+ subExprInfo . typeParamExpr ,
838+ ) ;
839+ }
800840 }
801841 }
802842 if ( subExprInfo . typeParamExpr ) {
0 commit comments