00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00026
00036
00037
00038 #ifndef _XST_PAIR_H_INCLUDED_
00039 #define _XST_PAIR_H_INCLUDED_
00040
00041 namespace cttl_impl {
00042
00043
00060 template< typename LhsT, typename RhsT >
00061 struct xst_pair : public xtl_op_base_binary< LhsT, RhsT > {
00062
00063
00064 template< typename D > friend struct xst_lambda_wrap;
00065
00066
00067 template< typename L, typename R > friend struct xst_pair;
00068
00069
00070 template< typename D, typename T > friend struct xst_translator;
00071
00072 enum {
00074 const_value_ = LhsT::const_value_,
00075
00077 depth_ = LhsT::depth_ + 1,
00078
00080 capacity_ = LhsT::capacity_ + RhsT::capacity_,
00081
00083 primitive_id_ = LhsT::primitive_id_
00084 };
00085
00087 typedef typename LhsT::value_T value_T;
00088
00090 typedef typename LhsT::dereferenced_value_T dereferenced_value_T;
00091
00093 typedef LhsT left_T;
00094
00096 typedef RhsT right_T;
00097
00099 typedef xst_pair< LhsT, RhsT > reference_T;
00100
00102 xst_pair( LhsT const& lhs_expr_, RhsT const& rhs_expr_ )
00103 : xtl_op_base_binary< LhsT, RhsT >( lhs_expr_, rhs_expr_ )
00104 {
00105 }
00106
00108 xst_pair()
00109 : xtl_op_base_binary< LhsT, RhsT >( LhsT(), RhsT() )
00110 {
00111 }
00112
00114 xst_pair( xst_pair< LhsT, RhsT > const& other_ )
00115 : xtl_op_base_binary< LhsT, RhsT >( other_.m_expr_lhs, other_.m_expr_rhs )
00116 {
00117 }
00118
00120 reference_T make_reference() const
00121 {
00122 return *this;
00123 }
00124
00126 template< typename SubscriptLambdaT >
00127 dereferenced_value_T& dereferenced_value( xst_lambda_wrap< SubscriptLambdaT > subscript_ )
00128 {
00129
00130
00131 return this->m_expr_lhs.dereferenced_value( subscript_ );
00132 }
00133
00135 left_T& left_lambda()
00136 {
00137 return this->m_expr_lhs;
00138 }
00139
00141 left_T const& left_lambda() const
00142 {
00143 return this->m_expr_lhs;
00144 }
00145
00147 right_T& right_lambda()
00148 {
00149 return this->m_expr_rhs;
00150 }
00151
00153 right_T const& right_lambda() const
00154 {
00155 return this->m_expr_rhs;
00156 }
00157
00159
00161
00163 template< typename FunctorT >
00164 void traverse_bottom_up( FunctorT& functor_ )
00165 {
00166 this->m_expr_rhs.traverse_bottom_up( functor_ );
00167 this->m_expr_lhs.traverse_bottom_up( functor_ );
00168 }
00169
00171 template< typename FunctorT >
00172 void traverse_top_down( FunctorT& functor_ )
00173 {
00174 this->m_expr_lhs.traverse_top_down( functor_ );
00175 this->m_expr_rhs.traverse_top_down( functor_ );
00176 }
00177
00179 template< typename FunctorT >
00180 void traverse_bottom_up( FunctorT& functor_ ) const
00181 {
00182 this->m_expr_rhs.traverse_bottom_up( functor_ );
00183 this->m_expr_lhs.traverse_bottom_up( functor_ );
00184 }
00185
00187 template< typename FunctorT >
00188 void traverse_top_down( FunctorT& functor_ ) const
00189 {
00190 this->m_expr_lhs.traverse_top_down( functor_ );
00191 this->m_expr_rhs.traverse_top_down( functor_ );
00192 }
00193
00195 template< typename FunctorT >
00196 void subscript_top_down( FunctorT& functor_ ) const
00197 {
00198
00199
00200
00201
00202
00203
00204 xsubscript_top_down_descend< depth_ - 2 >( functor_ );
00205 }
00206
00208 template< typename FunctorT >
00209 void subscript_bottom_up( FunctorT& functor_ ) const
00210 {
00211
00212 xsubscript_bottom_up_descend< depth_ - 2 >( functor_ );
00213 }
00214
00216
00218
00231 template<
00232 int LocationT,
00233 typename InputValueT
00234 >
00235 void
00236 push(
00237 xst_lambda_wrap< xst_const_scalar< LocationT > >,
00238 InputValueT const& data_
00239 )
00240 {
00241 xpush_descend< depth_ - LocationT - 1 >( data_ );
00242 }
00243
00245 template<
00246 typename SubscriptLeftLambdaLhsT,
00247 int LocationT,
00248 typename InputValueT
00249 >
00250 void
00251 push(
00252 xst_lambda_wrap<
00253 xst_pair<
00254 SubscriptLeftLambdaLhsT,
00255 xst_lambda_wrap< xst_const_scalar< LocationT > >
00256 >
00257 > subscript_,
00258 InputValueT const& data_
00259 )
00260 {
00261 xpush_sub_rotate(
00262 subscript_.left_lambda(),
00263 xst_const_scalar< LocationT >(),
00264 data_
00265 );
00266 }
00267
00269 template<
00270 int LocationT
00271 >
00272 void
00273 pop(
00274 xst_lambda_wrap< xst_const_scalar< LocationT > >
00275 )
00276
00277 {
00278 xpop_descend< depth_ - LocationT - 1 >();
00279 }
00280
00282 template<
00283 typename SubscriptLeftLambdaLhsT,
00284 int LocationT
00285 >
00286 void
00287 pop(
00288 xst_lambda_wrap<
00289 xst_pair<
00290 SubscriptLeftLambdaLhsT,
00291 xst_lambda_wrap< xst_const_scalar< LocationT > >
00292 >
00293 > subscript_
00294 )
00295
00296 {
00297 xpop_sub_rotate(
00298 subscript_.left_lambda(),
00299 xst_const_scalar< LocationT >()
00300 );
00301 }
00302
00303
00305 template< int LocationT >
00306 value_T const& top( xst_lambda_wrap< xst_const_scalar< LocationT > > ) const
00307 {
00308 return xtop_descend< depth_ - LocationT - 1 >();
00309 }
00310
00312 template<
00313 typename SubscriptLeftLambdaLhsT,
00314 int LocationT
00315 >
00316 value_T const& top(
00317 xst_lambda_wrap<
00318 xst_pair<
00319 SubscriptLeftLambdaLhsT,
00320 xst_lambda_wrap< xst_const_scalar< LocationT > >
00321 >
00322 > subscript_
00323 )
00324 const
00325 {
00326 return xtop_sub_rotate(
00327 subscript_.left_lambda(),
00328 xst_const_scalar< LocationT >()
00329 );
00330 }
00331
00332
00334 template< int LocationT >
00335 value_T& top( xst_lambda_wrap< xst_const_scalar< LocationT > > )
00336 {
00337 return xtop_descend< depth_ - LocationT - 1 >();
00338 }
00339
00341 template<
00342 typename SubscriptLeftLambdaLhsT,
00343 int LocationT
00344 >
00345 value_T& top(
00346 xst_lambda_wrap<
00347 xst_pair<
00348 SubscriptLeftLambdaLhsT,
00349 xst_lambda_wrap< xst_const_scalar< LocationT > >
00350 >
00351 > subscript_
00352 )
00353
00354 {
00355 return xtop_sub_rotate(
00356 subscript_.left_lambda(),
00357 xst_const_scalar< LocationT >()
00358 );
00359 }
00360
00361
00363 template<
00364 int LocationT
00365 >
00366 size_t
00367 size(
00368 xst_lambda_wrap< xst_const_scalar< LocationT > >
00369 )
00370 const
00371 {
00372 return xsize_descend< depth_ - LocationT - 1 >();
00373 }
00374
00376 template<
00377 typename SubscriptLeftLambdaLhsT,
00378 int LocationT
00379 >
00380 size_t
00381 size(
00382 xst_lambda_wrap<
00383 xst_pair<
00384 SubscriptLeftLambdaLhsT,
00385 xst_lambda_wrap< xst_const_scalar< LocationT > >
00386 >
00387 > subscript_
00388 )
00389 const
00390 {
00391 return xsize_sub_rotate(
00392 subscript_.left_lambda(),
00393 xst_const_scalar< LocationT >()
00394 );
00395 }
00396
00397
00399 template<
00400 int LocationT
00401 >
00402 std::stack< value_T >*
00403 stack_ptr(
00404 xst_lambda_wrap< xst_const_scalar< LocationT > >
00405 )
00406
00407 {
00408 return xstack_ptr_descend< depth_ - LocationT - 1 >();
00409 }
00410
00412 template<
00413 typename SubscriptLeftLambdaLhsT,
00414 int LocationT
00415 >
00416 std::stack< value_T >*
00417 stack_ptr(
00418 xst_lambda_wrap<
00419 xst_pair<
00420 SubscriptLeftLambdaLhsT,
00421 xst_lambda_wrap< xst_const_scalar< LocationT > >
00422 >
00423 > subscript_
00424 )
00425
00426 {
00427 return xstack_ptr_sub_rotate(
00428 subscript_.left_lambda(),
00429 xst_const_scalar< LocationT >()
00430 );
00431 }
00432
00433
00435 template<
00436 int LocationT
00437 >
00438 std::stack< value_T > const*
00439 stack_ptr(
00440 xst_lambda_wrap< xst_const_scalar< LocationT > >
00441 )
00442 const
00443 {
00444 return xstack_ptr_descend< depth_ - LocationT - 1 >();
00445 }
00446
00448 template<
00449 typename SubscriptLeftLambdaLhsT,
00450 int LocationT
00451 >
00452 std::stack< value_T > const*
00453 stack_ptr(
00454 xst_lambda_wrap<
00455 xst_pair<
00456 SubscriptLeftLambdaLhsT,
00457 xst_lambda_wrap< xst_const_scalar< LocationT > >
00458 >
00459 > subscript_
00460 )
00461 const
00462 {
00463 return xstack_ptr_sub_rotate(
00464 subscript_.left_lambda(),
00465 xst_const_scalar< LocationT >()
00466 );
00467 }
00468
00469
00471 template<
00472 typename SubscriptLeftLambdaLhsT,
00473 int LocationT
00474 >
00475 void
00476 update(
00477 xst_lambda_wrap<
00478 xst_pair<
00479 SubscriptLeftLambdaLhsT,
00480 xst_lambda_wrap< xst_const_scalar< LocationT > >
00481 >
00482 > program_
00483 )
00484
00485 {
00486 xupdate_sub_rotate(
00487 program_.left_lambda(),
00488 xst_const_scalar< LocationT >()
00489 );
00490 }
00491
00492
00493 #ifdef CTTL_LAMBDA_REFLECTION
00494
00495 typedef typename LhsT::reflection_T lhs_reflection_T;
00496
00498 typedef typename RhsT::reflection_T rhs_reflection_T;
00499
00501 typedef xst_pair< rhs_reflection_T, lhs_reflection_T > reflection_T;
00502
00504 reflection_T reflection() const
00505 {
00506 return reflection_T( this->m_expr_rhs.reflection(), this->m_expr_lhs.reflection() );
00507 }
00508 #endif // CTTL_LAMBDA_REFLECTION
00509
00510 private:
00512
00514
00516 template< int LocationT, typename InputValueT >
00517 void xpush_at_location( InputValueT const& data_ )
00518 {
00519 xpush_descend< depth_ - LocationT - 1 >( data_ );
00520 }
00521
00523 template< int LocationT >
00524 void xpop_at_location()
00525 {
00526 xpop_descend< depth_ - LocationT - 1 >();
00527 }
00528
00530 template< int LocationT >
00531 value_T const& xtop_at_location() const
00532 {
00533 return xtop_descend< depth_ - LocationT - 1 >();
00534 }
00535
00537
00539
00540 template< int LocationT, typename InputValueT >
00541 void xpush_descend( InputValueT const& data_ )
00542 {
00543 if ( LocationT )
00544 this->m_expr_lhs.xpush_descend< LocationT - 1 >( data_ );
00545 else
00546 this->m_expr_rhs.xpush_at_location< LocationT >( data_ );
00547 }
00548
00550 template< int LocationT >
00551 void xpop_descend()
00552 {
00553 if ( LocationT )
00554 this->m_expr_lhs.xpop_descend< LocationT - 1 >();
00555 else
00556 this->m_expr_rhs.xpop_at_location< LocationT >();
00557 }
00558
00560 template< int LocationT >
00561 value_T const& xtop_descend() const
00562 {
00563 if ( LocationT )
00564 return this->m_expr_lhs.xtop_descend< LocationT - 1 >();
00565
00566 return this->m_expr_rhs.xtop_at_location< LocationT >();
00567 }
00568
00570
00572
00574 template< int LocationT, typename FunctorT >
00575 void xsubscript_top_down_descend( FunctorT& functor_ ) const
00576 {
00577 if ( LocationT ) {
00578
00579 this->m_expr_lhs.xsubscript_top_down_descend< LocationT - 1>( functor_ );
00580
00581 this->m_expr_rhs.xsubscript_top_down_subtree_switch( const_scalar( LocationT + 1 ), functor_ );
00582 return;
00583 }
00584
00585
00586 this->m_expr_lhs.xsubscript_top_down_subtree_switch( const_scalar( LocationT ), functor_ );
00587 this->m_expr_rhs.xsubscript_top_down_subtree_switch( const_scalar( LocationT + 1 ), functor_ );
00588 }
00589
00591 template< typename SubscriptLambdaT, typename FunctorT >
00592 void xsubscript_top_down_subtree_switch( SubscriptLambdaT subscript_, FunctorT& functor_ ) const
00593 {
00594
00595
00596
00597
00598
00599
00600 xsubscript_top_down_subtree_descend< depth_ - 2 >( subscript_, functor_ );
00601 }
00602
00604 template< int LocationT, typename SubscriptLambdaT, typename FunctorT >
00605 void xsubscript_top_down_subtree_descend( SubscriptLambdaT subscript_, FunctorT& functor_ ) const
00606 {
00607 typedef
00608 xst_pair<
00609 SubscriptLambdaT,
00610 const_scalar_type( LocationT )
00611 >
00612 lhs_pair_T;
00613 typedef xst_lambda_wrap< lhs_pair_T > lhs_subscript_lambda_T;
00614
00615 typedef
00616 xst_pair<
00617 SubscriptLambdaT,
00618 const_scalar_type( LocationT + 1 )
00619 >
00620 rhs_pair_T;
00621 typedef xst_lambda_wrap< rhs_pair_T > rhs_subscript_lambda_T;
00622
00623 if ( LocationT ) {
00624
00625 this->m_expr_lhs.xsubscript_top_down_subtree_descend< LocationT - 1 >( subscript_, functor_ );
00626
00627 this->m_expr_rhs.xsubscript_top_down_subtree_switch( rhs_subscript_lambda_T( rhs_pair_T( subscript_, const_scalar( LocationT + 1 ) ) ), functor_ );
00628 return;
00629 }
00630
00631
00632 this->m_expr_lhs.xsubscript_top_down_subtree_switch( lhs_subscript_lambda_T( lhs_pair_T( subscript_, const_scalar( LocationT ) ) ), functor_ );
00633 this->m_expr_rhs.xsubscript_top_down_subtree_switch( rhs_subscript_lambda_T( rhs_pair_T( subscript_, const_scalar( LocationT + 1 ) ) ), functor_ );
00634 }
00635
00637 template< int LocationT, typename FunctorT >
00638 void xsubscript_bottom_up_descend( FunctorT& functor_ ) const
00639 {
00640 if ( LocationT ) {
00641
00642
00643 this->m_expr_rhs.xsubscript_bottom_up_subtree_switch( const_scalar( LocationT + 1 ), functor_ );
00644 this->m_expr_lhs.xsubscript_bottom_up_descend< LocationT - 1>( functor_ );
00645 return;
00646 }
00647
00648
00649 this->m_expr_rhs.xsubscript_bottom_up_subtree_switch( const_scalar( LocationT + 1 ), functor_ );
00650 this->m_expr_lhs.xsubscript_bottom_up_subtree_switch( const_scalar( LocationT ), functor_ );
00651 }
00652
00654 template< typename SubscriptLambdaT, typename FunctorT >
00655 void xsubscript_bottom_up_subtree_switch( SubscriptLambdaT subscript_, FunctorT& functor_ ) const
00656 {
00657
00658 xsubscript_bottom_up_subtree_descend< depth_ - 2 >( subscript_, functor_ );
00659 }
00660
00662 template< int LocationT, typename SubscriptLambdaT, typename FunctorT >
00663 void xsubscript_bottom_up_subtree_descend( SubscriptLambdaT subscript_, FunctorT& functor_ ) const
00664 {
00665 typedef
00666 xst_pair<
00667 SubscriptLambdaT,
00668 const_scalar_type( LocationT )
00669 >
00670 lhs_pair_T;
00671 typedef xst_lambda_wrap< lhs_pair_T > lhs_subscript_lambda_T;
00672
00673 typedef
00674 xst_pair<
00675 SubscriptLambdaT,
00676 const_scalar_type( LocationT + 1 )
00677 >
00678 rhs_pair_T;
00679 typedef xst_lambda_wrap< rhs_pair_T > rhs_subscript_lambda_T;
00680
00681 if ( LocationT ) {
00682
00683
00684 this->m_expr_rhs.xsubscript_bottom_up_subtree_switch( rhs_subscript_lambda_T( rhs_pair_T( subscript_, const_scalar( LocationT + 1 ) ) ), functor_ );
00685 this->m_expr_lhs.xsubscript_bottom_up_subtree_descend< LocationT - 1 >( subscript_, functor_ );
00686 return;
00687 }
00688
00689
00690 this->m_expr_rhs.xsubscript_bottom_up_subtree_switch( rhs_subscript_lambda_T( rhs_pair_T( subscript_, const_scalar( LocationT + 1 ) ) ), functor_ );
00691 this->m_expr_lhs.xsubscript_bottom_up_subtree_switch( lhs_subscript_lambda_T( lhs_pair_T( subscript_, const_scalar( LocationT ) ) ), functor_ );
00692 }
00693
00694
00696 template<
00697 int LocationT,
00698 typename SubscriptRightLambdaT,
00699 typename InputValueT
00700 >
00701 void
00702 xpush_sub_rotate(
00703 xst_lambda_wrap< xst_const_scalar< LocationT > >,
00704 SubscriptRightLambdaT rhs_subscript_,
00705 InputValueT const& data_
00706 )
00707 {
00708 typedef
00709 xst_pair<
00710 SubscriptRightLambdaT,
00711 xst_const_scalar< LocationT >
00712 >
00713 pair_final_T;
00714
00715 xpush_sub_split(
00716 pair_final_T(
00717 rhs_subscript_,
00718 xst_const_scalar< LocationT >()
00719 ),
00720 data_
00721 );
00722 }
00723
00725 template<
00726 typename SubscriptLeftLambdaLhsT,
00727 int LocationT,
00728 typename SubscriptRightLambdaT,
00729 typename InputValueT
00730 >
00731 void
00732 xpush_sub_rotate(
00733 xst_lambda_wrap<
00734 xst_pair<
00735 SubscriptLeftLambdaLhsT,
00736 xst_lambda_wrap< xst_const_scalar< LocationT > >
00737 >
00738 > lhs_subscript_,
00739 SubscriptRightLambdaT rhs_subscript_,
00740 InputValueT const& data_
00741 )
00742 {
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774 typedef
00775 xst_pair<
00776 SubscriptRightLambdaT,
00777 xst_const_scalar< LocationT >
00778 >
00779 pair_internal_T;
00780
00781 xpush_sub_rotate(
00782 lhs_subscript_.left_lambda(),
00783 pair_internal_T(
00784 rhs_subscript_,
00785 xst_const_scalar< LocationT >()
00786 ),
00787 data_
00788 );
00789 }
00790
00792 template< typename SubscriptLambdaT, typename InputValueT >
00793 void xpush_sub_split( SubscriptLambdaT subscript_, InputValueT const& data_ )
00794 {
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804 if ( SubscriptLambdaT::depth_ == 1 ) {
00805
00806
00807
00808 xpush_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >( data_ );
00809
00810 } else {
00811
00812
00813
00814 xpush_sub_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >( subscript_.left_lambda(), data_ );
00815 }
00816 }
00817
00819 template< int LocationT, typename SubscriptLambdaT, typename InputValueT >
00820 void xpush_sub_descend( SubscriptLambdaT subscript_, InputValueT const& data_ )
00821 {
00822
00823 if ( LocationT ) {
00824
00825 this->m_expr_lhs.xpush_sub_descend< LocationT - 1 >( subscript_, data_ );
00826
00827 } else {
00828
00829 this->m_expr_rhs.xpush_sub_split( subscript_, data_ );
00830 }
00831 }
00832
00834 template<
00835 int LocationT,
00836 typename SubscriptRightLambdaT
00837 >
00838 void
00839 xpop_sub_rotate(
00840 xst_lambda_wrap< xst_const_scalar< LocationT > >,
00841 SubscriptRightLambdaT rhs_subscript_
00842 )
00843
00844 {
00845 typedef
00846 xst_pair<
00847 SubscriptRightLambdaT,
00848 xst_const_scalar< LocationT >
00849 >
00850 pair_final_T;
00851
00852 xpop_sub_split(
00853 pair_final_T(
00854 rhs_subscript_,
00855 xst_const_scalar< LocationT >()
00856 )
00857 );
00858 }
00859
00861 template<
00862 typename SubscriptLeftLambdaLhsT,
00863 int LocationT,
00864 typename SubscriptRightLambdaT
00865 >
00866 void
00867 xpop_sub_rotate(
00868 xst_lambda_wrap<
00869 xst_pair<
00870 SubscriptLeftLambdaLhsT,
00871 xst_lambda_wrap< xst_const_scalar< LocationT > >
00872 >
00873 > lhs_subscript_,
00874 SubscriptRightLambdaT rhs_subscript_
00875 )
00876
00877 {
00878 typedef
00879 xst_pair<
00880 SubscriptRightLambdaT,
00881 xst_const_scalar< LocationT >
00882 >
00883 pair_internal_T;
00884
00885 xpop_sub_rotate(
00886 lhs_subscript_.left_lambda(),
00887 pair_internal_T(
00888 rhs_subscript_,
00889 xst_const_scalar< LocationT >()
00890 )
00891 );
00892 }
00893
00895 template< typename SubscriptLambdaT >
00896 void xpop_sub_split( SubscriptLambdaT subscript_ )
00897 {
00898
00899 if ( SubscriptLambdaT::depth_ == 1 ) {
00900
00901
00902
00903 xpop_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >();
00904
00905 } else {
00906
00907
00908
00909 xpop_sub_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >( subscript_.left_lambda() );
00910 }
00911 }
00912
00913
00915 template< int LocationT, typename SubscriptLambdaT >
00916 void xpop_sub_descend( SubscriptLambdaT subscript_ )
00917 {
00918
00919 if ( LocationT ) {
00920
00921 this->m_expr_lhs.xpop_sub_descend< LocationT - 1 >( subscript_ );
00922
00923 } else {
00924
00925 this->m_expr_rhs.xpop_sub_split( subscript_ );
00926 }
00927 }
00928
00930 template<
00931 int LocationT,
00932 typename SubscriptRightLambdaT
00933 >
00934 value_T const& xtop_sub_rotate(
00935 xst_lambda_wrap< xst_const_scalar< LocationT > >,
00936 SubscriptRightLambdaT rhs_subscript_
00937 )
00938 const
00939 {
00940 typedef
00941 xst_pair<
00942 SubscriptRightLambdaT,
00943 xst_const_scalar< LocationT >
00944 >
00945 pair_final_T;
00946
00947 return xtop_sub_split(
00948 pair_final_T(
00949 rhs_subscript_,
00950 xst_const_scalar< LocationT >()
00951 )
00952 );
00953 }
00954
00956 template<
00957 typename SubscriptLeftLambdaLhsT,
00958 int LocationT,
00959 typename SubscriptRightLambdaT
00960 >
00961 value_T const& xtop_sub_rotate(
00962 xst_lambda_wrap<
00963 xst_pair<
00964 SubscriptLeftLambdaLhsT,
00965 xst_lambda_wrap< xst_const_scalar< LocationT > >
00966 >
00967 > lhs_subscript_,
00968 SubscriptRightLambdaT rhs_subscript_
00969 )
00970 const
00971 {
00972 typedef
00973 xst_pair<
00974 SubscriptRightLambdaT,
00975 xst_const_scalar< LocationT >
00976 >
00977 pair_internal_T;
00978
00979 return xtop_sub_rotate(
00980 lhs_subscript_.left_lambda(),
00981 pair_internal_T(
00982 rhs_subscript_,
00983 xst_const_scalar< LocationT >()
00984 )
00985 );
00986 }
00987
00989 template< typename SubscriptLambdaT >
00990 value_T const& xtop_sub_split( SubscriptLambdaT subscript_ ) const
00991 {
00992
00993 if ( SubscriptLambdaT::depth_ == 1 ) {
00994
00995
00996
00997 return xtop_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >();
00998
00999 } else {
01000
01001
01002
01003 return xtop_sub_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >( subscript_.left_lambda() );
01004 }
01005 }
01006
01007
01009 template< int LocationT, typename SubscriptLambdaT >
01010 value_T const& xtop_sub_descend( SubscriptLambdaT subscript_ ) const
01011 {
01012
01013 if ( LocationT ) {
01014
01015 return this->m_expr_lhs.xtop_sub_descend< LocationT - 1 >( subscript_ );
01016
01017 } else {
01018
01019 return this->m_expr_rhs.xtop_sub_split( subscript_ );
01020 }
01021 }
01022
01023
01025
01027
01029 template< int LocationT >
01030 value_T& xtop_at_location()
01031 {
01032 return xtop_descend< depth_ - LocationT - 1 >();
01033 }
01034
01036 template< int LocationT >
01037 value_T& xtop_descend()
01038 {
01039 if ( LocationT )
01040 return this->m_expr_lhs.xtop_descend< LocationT - 1 >();
01041 else
01042 return this->m_expr_rhs.xtop_at_location< LocationT >();
01043 }
01044
01046
01048
01050 template<
01051 int LocationT,
01052 typename SubscriptRightLambdaT
01053 >
01054 value_T& xtop_sub_rotate(
01055 xst_lambda_wrap< xst_const_scalar< LocationT > >,
01056 SubscriptRightLambdaT rhs_subscript_
01057 )
01058
01059 {
01060 typedef
01061 xst_pair<
01062 SubscriptRightLambdaT,
01063 xst_const_scalar< LocationT >
01064 >
01065 pair_final_T;
01066
01067 return xtop_sub_split(
01068 pair_final_T(
01069 rhs_subscript_,
01070 xst_const_scalar< LocationT >()
01071 )
01072 );
01073 }
01074
01076 template<
01077 typename SubscriptLeftLambdaLhsT,
01078 int LocationT,
01079 typename SubscriptRightLambdaT
01080 >
01081 value_T& xtop_sub_rotate(
01082 xst_lambda_wrap<
01083 xst_pair<
01084 SubscriptLeftLambdaLhsT,
01085 xst_lambda_wrap< xst_const_scalar< LocationT > >
01086 >
01087 > lhs_subscript_,
01088 SubscriptRightLambdaT rhs_subscript_
01089 )
01090
01091 {
01092 typedef
01093 xst_pair<
01094 SubscriptRightLambdaT,
01095 xst_const_scalar< LocationT >
01096 >
01097 pair_internal_T;
01098
01099 return xtop_sub_rotate(
01100 lhs_subscript_.left_lambda(),
01101 pair_internal_T(
01102 rhs_subscript_,
01103 xst_const_scalar< LocationT >()
01104 )
01105 );
01106 }
01107
01109 template< typename SubscriptLambdaT >
01110 value_T& xtop_sub_split( SubscriptLambdaT subscript_ )
01111 {
01112
01113 if ( SubscriptLambdaT::depth_ == 1 ) {
01114
01115
01116
01117 return xtop_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >();
01118
01119 } else {
01120
01121
01122
01123 return xtop_sub_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >( subscript_.left_lambda() );
01124 }
01125 }
01126
01127
01129 template< int LocationT, typename SubscriptLambdaT >
01130 value_T& xtop_sub_descend( SubscriptLambdaT subscript_ )
01131 {
01132
01133 if ( LocationT ) {
01134
01135 return this->m_expr_lhs.xtop_sub_descend< LocationT - 1 >( subscript_ );
01136
01137 } else {
01138
01139 return this->m_expr_rhs.xtop_sub_split( subscript_ );
01140 }
01141 }
01142
01143
01145
01147
01149 template< int LocationT >
01150 size_t xsize_at_location() const
01151 {
01152 return xsize_descend< depth_ - LocationT - 1 >();
01153 }
01154
01156 template< int LocationT >
01157 size_t xsize_descend() const
01158 {
01159 if ( LocationT )
01160 return this->m_expr_lhs.xsize_descend< LocationT - 1 >();
01161 else
01162 return this->m_expr_rhs.xsize_at_location< LocationT >();
01163 }
01164
01166 template<
01167 int LocationT,
01168 typename SubscriptRightLambdaT
01169 >
01170 size_t
01171 xsize_sub_rotate(
01172 xst_lambda_wrap< xst_const_scalar< LocationT > >,
01173 SubscriptRightLambdaT rhs_subscript_
01174 )
01175 const
01176 {
01177 typedef
01178 xst_pair<
01179 SubscriptRightLambdaT,
01180 xst_const_scalar< LocationT >
01181 >
01182 pair_final_T;
01183
01184 return xsize_sub_split(
01185 pair_final_T(
01186 rhs_subscript_,
01187 xst_const_scalar< LocationT >()
01188 )
01189 );
01190 }
01191
01193 template<
01194 typename SubscriptLeftLambdaLhsT,
01195 int LocationT,
01196 typename SubscriptRightLambdaT
01197 >
01198 size_t
01199 xsize_sub_rotate(
01200 xst_lambda_wrap<
01201 xst_pair<
01202 SubscriptLeftLambdaLhsT,
01203 xst_lambda_wrap< xst_const_scalar< LocationT > >
01204 >
01205 > lhs_subscript_,
01206 SubscriptRightLambdaT rhs_subscript_
01207 )
01208 const
01209 {
01210 typedef
01211 xst_pair<
01212 SubscriptRightLambdaT,
01213 xst_const_scalar< LocationT >
01214 >
01215 pair_internal_T;
01216
01217 return xsize_sub_rotate(
01218 lhs_subscript_.left_lambda(),
01219 pair_internal_T(
01220 rhs_subscript_,
01221 xst_const_scalar< LocationT >()
01222 )
01223 );
01224 }
01225
01227 template< typename SubscriptLambdaT >
01228 size_t xsize_sub_split( SubscriptLambdaT subscript_ ) const
01229 {
01230
01231 if ( SubscriptLambdaT::depth_ == 1 ) {
01232
01233
01234
01235 return xsize_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >();
01236
01237 } else {
01238
01239
01240
01241 return xsize_sub_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >( subscript_.left_lambda() );
01242 }
01243 }
01244
01245
01247 template< int LocationT, typename SubscriptLambdaT >
01248 size_t xsize_sub_descend( SubscriptLambdaT subscript_ ) const
01249 {
01250
01251 if ( LocationT ) {
01252
01253 return this->m_expr_lhs.xsize_sub_descend< LocationT - 1 >( subscript_ );
01254
01255 } else {
01256
01257 return this->m_expr_rhs.xsize_sub_split( subscript_ );
01258 }
01259 }
01260
01261
01263
01265
01267 template< int LocationT >
01268 std::stack< value_T >* xstack_ptr_at_location()
01269 {
01270 return xstack_ptr_descend< depth_ - LocationT - 1 >();
01271 }
01272
01274 template< int LocationT >
01275 std::stack< value_T >* xstack_ptr_descend()
01276 {
01277 if ( LocationT )
01278 return this->m_expr_lhs.xstack_ptr_descend< LocationT - 1 >();
01279 else
01280 return this->m_expr_rhs.xstack_ptr_at_location< LocationT >();
01281 }
01282
01283
01285 template<
01286 int LocationT,
01287 typename SubscriptRightLambdaT
01288 >
01289 std::stack< value_T >*
01290 xstack_ptr_sub_rotate(
01291 xst_lambda_wrap< xst_const_scalar< LocationT > >,
01292 SubscriptRightLambdaT rhs_subscript_
01293 )
01294
01295 {
01296 typedef
01297 xst_pair<
01298 SubscriptRightLambdaT,
01299 xst_const_scalar< LocationT >
01300 >
01301 pair_final_T;
01302
01303 return xstack_ptr_sub_split(
01304 pair_final_T(
01305 rhs_subscript_,
01306 xst_const_scalar< LocationT >()
01307 )
01308 );
01309 }
01310
01312 template<
01313 typename SubscriptLeftLambdaLhsT,
01314 int LocationT,
01315 typename SubscriptRightLambdaT
01316 >
01317 std::stack< value_T >*
01318 xstack_ptr_sub_rotate(
01319 xst_lambda_wrap<
01320 xst_pair<
01321 SubscriptLeftLambdaLhsT,
01322 xst_lambda_wrap< xst_const_scalar< LocationT > >
01323 >
01324 > lhs_subscript_,
01325 SubscriptRightLambdaT rhs_subscript_
01326 )
01327
01328 {
01329 typedef
01330 xst_pair<
01331 SubscriptRightLambdaT,
01332 xst_const_scalar< LocationT >
01333 >
01334 pair_internal_T;
01335
01336 return xstack_ptr_sub_rotate(
01337 lhs_subscript_.left_lambda(),
01338 pair_internal_T(
01339 rhs_subscript_,
01340 xst_const_scalar< LocationT >()
01341 )
01342 );
01343 }
01344
01346 template< typename SubscriptLambdaT >
01347 std::stack< value_T >* xstack_ptr_sub_split( SubscriptLambdaT subscript_ )
01348 {
01349
01350 if ( SubscriptLambdaT::depth_ == 1 ) {
01351
01352
01353
01354 return xstack_ptr_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >();
01355
01356 } else {
01357
01358
01359
01360 return xstack_ptr_sub_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >( subscript_.left_lambda() );
01361 }
01362 }
01363
01364
01366 template< int LocationT, typename SubscriptLambdaT >
01367 std::stack< value_T >* xstack_ptr_sub_descend( SubscriptLambdaT subscript_ )
01368 {
01369
01370 if ( LocationT ) {
01371
01372 return this->m_expr_lhs.xstack_ptr_sub_descend< LocationT - 1 >( subscript_ );
01373
01374 } else {
01375
01376 return this->m_expr_rhs.xstack_ptr_sub_split( subscript_ );
01377 }
01378 }
01379
01380
01382
01384
01386 template< int LocationT >
01387 std::stack< value_T > const* xstack_ptr_at_location() const
01388 {
01389 return xstack_ptr_descend< depth_ - LocationT - 1 >();
01390 }
01391
01393 template< int LocationT >
01394 std::stack< value_T > const* xstack_ptr_descend() const
01395 {
01396 if ( LocationT )
01397 return this->m_expr_lhs.xstack_ptr_descend< LocationT - 1 >();
01398 else
01399 return this->m_expr_rhs.xstack_ptr_at_location< LocationT >();
01400 }
01401
01402
01404 template<
01405 int LocationT,
01406 typename SubscriptRightLambdaT
01407 >
01408 std::stack< value_T > const*
01409 xstack_ptr_sub_rotate(
01410 xst_lambda_wrap< xst_const_scalar< LocationT > >,
01411 SubscriptRightLambdaT rhs_subscript_
01412 )
01413 const
01414 {
01415 typedef
01416 xst_pair<
01417 SubscriptRightLambdaT,
01418 xst_const_scalar< LocationT >
01419 >
01420 pair_final_T;
01421
01422 return xstack_ptr_sub_split(
01423 pair_final_T(
01424 rhs_subscript_,
01425 xst_const_scalar< LocationT >()
01426 )
01427 );
01428 }
01429
01431 template<
01432 typename SubscriptLeftLambdaLhsT,
01433 int LocationT,
01434 typename SubscriptRightLambdaT
01435 >
01436 std::stack< value_T > const*
01437 xstack_ptr_sub_rotate(
01438 xst_lambda_wrap<
01439 xst_pair<
01440 SubscriptLeftLambdaLhsT,
01441 xst_lambda_wrap< xst_const_scalar< LocationT > >
01442 >
01443 > lhs_subscript_,
01444 SubscriptRightLambdaT rhs_subscript_
01445 )
01446 const
01447 {
01448 typedef
01449 xst_pair<
01450 SubscriptRightLambdaT,
01451 xst_const_scalar< LocationT >
01452 >
01453 pair_internal_T;
01454
01455 return xstack_ptr_sub_rotate(
01456 lhs_subscript_.left_lambda(),
01457 pair_internal_T(
01458 rhs_subscript_,
01459 xst_const_scalar< LocationT >()
01460 )
01461 );
01462 }
01463
01465 template< typename SubscriptLambdaT >
01466 std::stack< value_T > const* xstack_ptr_sub_split( SubscriptLambdaT subscript_ ) const
01467 {
01468
01469 if ( SubscriptLambdaT::depth_ == 1 ) {
01470
01471
01472
01473 return xstack_ptr_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >();
01474
01475 } else {
01476
01477
01478
01479 return xstack_ptr_sub_descend< depth_ - SubscriptLambdaT::right_T::const_value_ - 1 >( subscript_.left_lambda() );
01480 }
01481 }
01482
01483
01485 template< int LocationT, typename SubscriptLambdaT >
01486 std::stack< value_T > const* xstack_ptr_sub_descend( SubscriptLambdaT subscript_ ) const
01487 {
01488
01489 if ( LocationT ) {
01490
01491 return this->m_expr_lhs.xstack_ptr_sub_descend< LocationT - 1 >( subscript_ );
01492
01493 } else {
01494
01495 return this->m_expr_rhs.xstack_ptr_sub_split( subscript_ );
01496 }
01497 }
01498
01499
01501
01503
01505 template<
01506 int LocationT,
01507 typename SubscriptRightLambdaT
01508 >
01509 void
01510 xupdate_sub_rotate(
01511 xst_lambda_wrap< xst_const_scalar< LocationT > >,
01512 SubscriptRightLambdaT rhs_program_
01513 )
01514
01515 {
01516
01517 typedef
01518 xst_pair<
01519 SubscriptRightLambdaT,
01520 xst_const_scalar< LocationT >
01521 >
01522 pair_final_T;
01523
01524 xupdate_sub_split(
01525 pair_final_T(
01526 rhs_program_,
01527 xst_const_scalar< LocationT >()
01528 )
01529 );
01530 }
01531
01533 template<
01534 typename SubscriptLeftLambdaLhsT,
01535 int LocationT,
01536 typename SubscriptRightLambdaT
01537 >
01538 void
01539 xupdate_sub_rotate(
01540 xst_lambda_wrap<
01541 xst_pair<
01542 SubscriptLeftLambdaLhsT,
01543 xst_lambda_wrap< xst_const_scalar< LocationT > >
01544 >
01545 > lhs_program_,
01546 SubscriptRightLambdaT rhs_program_
01547 )
01548
01549 {
01550 typedef
01551 xst_pair<
01552 SubscriptRightLambdaT,
01553 xst_const_scalar< LocationT >
01554 >
01555 pair_internal_T;
01556
01557 xupdate_sub_rotate(
01558 lhs_program_.left_lambda(),
01559 pair_internal_T(
01560 rhs_program_,
01561 xst_const_scalar< LocationT >()
01562 )
01563 );
01564 }
01565
01567 template< typename SubscriptLambdaT >
01568 void xupdate_sub_split( SubscriptLambdaT program_ )
01569 {
01570 program_.xinstruction_opcode( *this );
01571 }
01572
01573
01575 template< typename TargetLambdaT >
01576 void xinstruction_opcode( TargetLambdaT& lambda_ )
01577 {
01578
01579 this->m_expr_lhs.xinstruction_1st< RhsT::const_value_ >( lambda_ );
01580 }
01581
01582
01584 template< int OpcodeT, typename TargetLambdaT >
01585 void xinstruction_1st( TargetLambdaT& lambda_ )
01586 {
01587 if ( xst_instruction_traits< OpcodeT >::length_ == 1 ) {
01588
01589 xst_instruction_1_operand< RhsT::const_value_, OpcodeT >::instruction( lambda_ );
01590
01591
01592 this->m_expr_lhs.xinstruction_opcode( lambda_ );
01593
01594 } else if ( xst_instruction_traits< OpcodeT >::length_ == 2 ) {
01595
01596 this->m_expr_lhs.xinstruction_2nd< OpcodeT, RhsT::const_value_ >( lambda_ );
01597
01598 } else {
01599 assert( false );
01600 }
01601 }
01602
01603
01605 template< int OpcodeT, int FirstOperandT, typename TargetLambdaT >
01606 void xinstruction_2nd( TargetLambdaT& lambda_ )
01607 {
01608
01609 xst_instruction_2_operand< FirstOperandT, RhsT::const_value_, OpcodeT >::instruction( lambda_ );
01610
01611
01612 this->m_expr_lhs.xinstruction_opcode( lambda_ );
01613 }
01614
01615
01616 };
01617
01618
01619 }
01620
01621
01622 #endif //_XST_PAIR_H_INCLUDED_