@@ -1022,6 +1022,11 @@ for ('', 'repeat_') -> $repness {
1022
1022
nqp ::die(" Operation '$ repness$ op_name ' needs 2 or 3 operands" );
1023
1023
}
1024
1024
1025
+ # See if there's an immediate block wanting to be passed the condition.
1026
+ my $ has_im := nqp ::istype(@ operands [1 ], QAST ::Block) &&
1027
+ @ operands [1 ]. blocktype eq ' immediate' &&
1028
+ @ operands [1 ]. arity > 0 ;
1029
+
1025
1030
# Create labels.
1026
1031
my $ while_id := $ qastcomp . unique ($ op_name );
1027
1032
my $ test_lbl := JAST::Label. new ( : name($ while_id ~ ' _test' ) );
@@ -1049,6 +1054,20 @@ for ('', 'repeat_') -> $repness {
1049
1054
my $ cond_res := $ qastcomp . as_jast_in_handler(@ operands [0 ], $ l_handler_id || $ * HANDLER_IDX );
1050
1055
$ testil . append ($ cond_res . jast);
1051
1056
$ * STACK . obtain($ testil , $ cond_res );
1057
+ if $ has_im {
1058
+ my $ im_local := QAST ::Node. unique (' __IM_' );
1059
+ $ * BLOCK . add_local(QAST ::Var. new (
1060
+ : name($ im_local ),
1061
+ : returns(typeobj_from_rttype($ cond_res . type))
1062
+ ));
1063
+ @ operands [1 ]. blocktype(' declaration' );
1064
+ @ operands [1 ] := QAST ::Op. new (
1065
+ : op(' call' ), @ operands [1 ],
1066
+ QAST ::Var. new ( : name($ im_local ), : scope(' local' ) )
1067
+ );
1068
+ $ testil . append (dup_ins($ cond_res . type));
1069
+ $ testil . append (JAST::Instruction. new ( : op(store_ins($ cond_res . type)), $ im_local ));
1070
+ }
1052
1071
1053
1072
# Compile loop body, then do any analysis of result type if
1054
1073
# in non-void context.
0 commit comments