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