@@ -558,7 +558,7 @@ export function loadBoolTrue(slice: Slice): Bool {
558558 ctx . storeStatements . push ( storeRefObjectStmt ( currentCell , ctx , field ) ) ;
559559 } ) ;
560560 } else if ( field . subFields . length == 0 ) {
561- let fieldInfo = this . handleType ( field , field . fieldType , true , ctx , slicePrefix , 0 ) ;
561+ let fieldInfo = this . handleType ( field , field . fieldType , true , ctx , slicePrefix , 0 , false ) ;
562562 if ( fieldInfo . loadExpr ) {
563563 addLoadProperty ( field . name , fieldInfo . loadExpr , fieldInfo . typeParamExpr , ctx ) ;
564564 }
@@ -581,6 +581,7 @@ export function loadBoolTrue(slice: Slice): Bool {
581581 ctx : ConstructorContext ,
582582 slicePrefix : Array < number > ,
583583 argIndex : number ,
584+ isConditional : boolean = false ,
584585 ) : FieldInfoType {
585586 let currentSlice = getCurrentSlice ( slicePrefix , 'slice' ) ;
586587 let currentCell = getCurrentSlice ( slicePrefix , 'cell' ) ;
@@ -748,16 +749,26 @@ export function loadBoolTrue(slice: Slice): Bool {
748749 result . typeParamExpr = id ( typeName ) ;
749750 if ( isField ) {
750751 result . loadExpr = tFunctionCall ( id ( 'load' + typeName ) , [ id ( theSlice ) ] ) ;
751- result . storeStmtOutside = storeExpressionNamedType ( typeName , storeParametersOutside , currentCell ) ;
752- result . storeStmtInside = storeExpressionNamedType ( typeName , storeParametersInside , currentCell ) ;
752+ result . storeStmtOutside = storeExpressionNamedType (
753+ typeName ,
754+ storeParametersOutside ,
755+ currentCell ,
756+ isConditional ,
757+ ) ;
758+ result . storeStmtInside = storeExpressionNamedType (
759+ typeName ,
760+ storeParametersInside ,
761+ currentCell ,
762+ isConditional ,
763+ ) ;
753764 } else {
754765 result . loadExpr = id ( 'load' + typeName ) ;
755766 result . storeStmtOutside = tExpressionStatement ( id ( 'store' + typeName ) ) ;
756767 }
757768 } else if ( fieldType . kind == 'TLBCondType' ) {
758769 let subExprInfo : FieldInfoType ;
759770 let conditionExpr : Expression ;
760- subExprInfo = this . handleType ( field , fieldType . value , true , ctx , slicePrefix , argIndex ) ;
771+ subExprInfo = this . handleType ( field , fieldType . value , true , ctx , slicePrefix , argIndex , true ) ;
761772 conditionExpr = convertToAST ( fieldType . condition , ctx . constructor ) ;
762773 if ( subExprInfo . typeParamExpr ) {
763774 result . typeParamExpr = tUnionTypeExpression ( [ subExprInfo . typeParamExpr , id ( 'undefined' ) ] ) ;
@@ -768,14 +779,32 @@ export function loadBoolTrue(slice: Slice): Bool {
768779 let currentParamOutside = storeParametersOutside [ 0 ] ;
769780 let currentParamInside = storeParametersInside [ 0 ] ;
770781 if ( currentParamOutside && currentParamInside && subExprInfo . storeStmtOutside ) {
771- result . storeStmtOutside = storeExprCond ( currentParamOutside , subExprInfo . storeStmtOutside ) ;
772- result . storeStmtInside = storeExprCond ( currentParamInside , subExprInfo . storeStmtOutside ) ;
782+ let storeConditionExpr : Expression | undefined ;
783+ if ( fieldType . condition ) {
784+ let objectParam = id ( ctx . typeName ) ;
785+ storeConditionExpr = convertToAST ( fieldType . condition , ctx . constructor , objectParam ) ;
786+ }
787+ result . storeStmtOutside = storeExprCond (
788+ currentParamOutside ,
789+ subExprInfo . storeStmtOutside ,
790+ storeConditionExpr ,
791+ ) ;
792+ if ( storeConditionExpr && fieldType . condition ) {
793+ const storeConditionExprInside = convertToAST ( fieldType . condition , ctx . constructor , id ( 'arg' ) ) ;
794+ result . storeStmtInside = storeExprCond (
795+ currentParamInside ,
796+ subExprInfo . storeStmtOutside ,
797+ storeConditionExprInside ,
798+ ) ;
799+ } else {
800+ result . storeStmtInside = storeExprCond ( currentParamInside , subExprInfo . storeStmtOutside ) ;
801+ }
773802 }
774803 } else if ( fieldType . kind == 'TLBMultipleType' ) {
775804 let arrayLength : Expression ;
776805 let subExprInfo : FieldInfoType ;
777806 arrayLength = convertToAST ( fieldType . times , ctx . constructor ) ;
778- subExprInfo = this . handleType ( field , fieldType . value , false , ctx , slicePrefix , argIndex ) ;
807+ subExprInfo = this . handleType ( field , fieldType . value , false , ctx , slicePrefix , argIndex , false ) ;
779808 let currentParamOutside = storeParametersOutside [ 0 ] ;
780809 let currentParamInside = storeParametersInside [ 0 ] ;
781810 if ( subExprInfo . loadExpr ) {
@@ -1002,8 +1031,8 @@ export function loadBoolTrue(slice: Slice): Bool {
10021031 result . loadFunctionExpr = returnSliceFunc ( ) ;
10031032 }
10041033 result . typeParamExpr = id ( exprForParam . paramType ) ;
1005- result . storeStmtOutside = storeExprForParam ( theCell , exprForParam , storeParametersOutside ) ;
1006- result . storeStmtInside = storeExprForParam ( theCell , exprForParam , storeParametersInside ) ;
1034+ result . storeStmtOutside = storeExprForParam ( theCell , exprForParam , storeParametersOutside , isConditional ) ;
1035+ result . storeStmtInside = storeExprForParam ( theCell , exprForParam , storeParametersInside , isConditional ) ;
10071036 }
10081037
10091038 if ( result . loadExpr && ! result . loadFunctionExpr ) {
0 commit comments