void PrinterVisitor::beginVisit( LetVarIterator const &i ) { thePrinter.startBeginVisit( "LetVarIterator", ++theId ); if ( i.getVarName() ) thePrinter.addAttribute( "varname", i.getVarName()->getStringValue().c_str() ); if ( i.getTargetPos() > numeric_consts<xs_integer>::zero() ) thePrinter.addAttribute( "targetPos", i.getTargetPos().toString().c_str() ); printCommons( &i, theId ); thePrinter.endBeginVisit( theId ); }
void PrinterVisitor::beginVisit( LetVarIterator const &i ) { thePrinter.startBeginVisit( "LetVarIterator", ++theId ); #ifndef NDEBUG if ( !Properties::instance().getNoTreeIDs() && Properties::instance().getStableIteratorIDs() ) thePrinter.addIntAttribute( "varreference", i.getId() ); #endif if ( i.getVarName() ) thePrinter.addAttribute( "varname", i.getVarName()->getStringValue().c_str() ); if ( i.getTargetPos() > numeric_consts<xs_integer>::zero() ) thePrinter.addIntAttribute( "targetPos", i.getTargetPos() ); printCommons( &i, theId ); thePrinter.endBeginVisit( theId ); }
PlanIter_t op_zorba_sequence_point_access::codegen( CompilerCB* /*cb*/, static_context* aSctx, const QueryLoc& aLoc, std::vector<PlanIter_t>& aArgs, expr& aAnn) const { fo_expr& subseqExpr = static_cast<fo_expr&>(aAnn); const expr* inputExpr = subseqExpr.get_arg(0); const expr* posExpr = subseqExpr.get_arg(1); LetVarIterator* inputVarIter; CtxVarIterator* ctxVarIter; if (posExpr->get_expr_kind() == const_expr_kind) { store::Item* posItem = static_cast<const const_expr*>(posExpr)->get_val(); xs_integer pos( posItem->getIntegerValue() ); if (inputExpr->get_expr_kind() == relpath_expr_kind) { const relpath_expr* pathExpr = static_cast<const relpath_expr*>(inputExpr); csize numSteps = pathExpr->numSteps(); if (pos.sign() > 0 && numSteps == 2) { xs_long pos2; try { pos2 = posItem->getLongValue(); } catch (std::range_error const&) { goto done; } AxisIteratorHelper* input = dynamic_cast<AxisIteratorHelper*>(aArgs[0].getp()); assert(input != NULL); if (input->setTargetPos(pos2 - 1)) return aArgs[0]; } } else if ((inputVarIter = dynamic_cast<LetVarIterator*>(aArgs[0].getp())) != NULL) { const var_expr* inputVar = inputExpr->get_var(); if (inputVar != NULL && (inputVar->get_kind() == var_expr::let_var || inputVar->get_kind() == var_expr::win_var || inputVar->get_kind() == var_expr::non_groupby_var) && inputVarIter->setTargetPos(pos)) { return aArgs[0]; } } else if ((ctxVarIter = dynamic_cast<CtxVarIterator*>(aArgs[0].getp())) != NULL) { if (ctxVarIter->setTargetPos(pos)) return aArgs[0]; } } else if ((inputVarIter = dynamic_cast<LetVarIterator*>(aArgs[0].getp())) != NULL) { const var_expr* inputVar = inputExpr->get_var(); if (inputVar != NULL && (inputVar->get_kind() == var_expr::let_var || inputVar->get_kind() == var_expr::win_var || inputVar->get_kind() == var_expr::non_groupby_var) && inputVarIter->setTargetPosIter(aArgs[1])) { return aArgs[0]; } } else if ((ctxVarIter = dynamic_cast<CtxVarIterator*>(aArgs[0].getp())) != NULL) { if (ctxVarIter->setTargetPosIter(aArgs[1])) return aArgs[0]; } done: return new SequencePointAccessIterator(aSctx, aLoc, aArgs); }