Exemple #1
0
PlanIter_t FunctionItem::getImplementation(CompilerCB* ccb)
{
  std::vector<PlanIter_t> args;

  expr* dummy = ccb->theEM->
  create_function_item_expr(NULL,
                            NULL,
                            theFunctionItemInfo->theLoc,
                            false,
                            false);
  
  PlanIter_t udfCallIterator = theFunctionItemInfo->theFunction->
  codegen(ccb,
          theFunctionItemInfo->theClosureSctx,
          theFunctionItemInfo->theLoc,
          args,
          *dummy);

  UDFunctionCallIterator* udfIter =
  static_cast<UDFunctionCallIterator*>(udfCallIterator.getp());

  udfIter->setDynamic();
  udfIter->setFunctionItem(this);

  return udfCallIterator;
}
void PrinterVisitor::beginVisit( UDFunctionCallIterator const &i ) {
  thePrinter.startBeginVisit( "UDFunctionCallIterator", ++theId );
  if ( i.theUDF->getSignature().getName() )
    thePrinter.addAttribute( "function", i.theUDF->getSignature().getName()->getStringValue().str() );
  else
    thePrinter.addAttribute( "function", "inline function" );

  if ( i.isCached() )
  {
    if (i.isCacheAcrossSnapshots())
      thePrinter.addBoolAttribute("cached-across-snapshots", true);
    else
      thePrinter.addBoolAttribute("cached", true);
  }

  printCommons( &i, theId );

  if ( i.isCached() && Properties::instance().getCollectProfile() && thePlanState )
  {
    FunctionCallIteratorState const *const pi_state =
      StateTraitsImpl<FunctionCallIteratorState>::getState(
          *thePlanState, i.getStateOffset());

    thePrinter.addIntAttribute( "prof-cache-hits", pi_state->theCacheHits);
    thePrinter.addIntAttribute( "prof-cache-misses", pi_state->theCacheMisses);
  }

  thePrinter.endBeginVisit( theId );
}
Exemple #3
0
/*******************************************************************************
  The getImplementation function assumes the dynChildren vector comes from a
  DynamicFnCallIterator, and as such, the first element of dynChildren is
  the function item itself, so it will be skipped.
********************************************************************************/
PlanIter_t FunctionItem::getImplementation(
    const std::vector<PlanIter_t>& dynChildren,
    CompilerCB* ccb)
{
  std::vector<PlanIter_t> args;
  args.resize(theArgValues.size());

  std::vector<PlanIter_t>::iterator argsIte = args.begin();
  std::vector<PlanIter_t>::iterator ite = theArgValues.begin();
  std::vector<PlanIter_t>::const_iterator ite2 = dynChildren.begin();
  ++ite2; // skip the first child because it's the function item

  for( ; argsIte != args.end(); ++argsIte, ++ite)
  {
    if (*ite != NULL)
    {
      *argsIte = *ite;
      static_cast<PlanStateIteratorWrapper*>(ite->getp())->reset();
    }
    else
    {
      *argsIte = *ite2;
      ++ite2;
    }
  }

  expr* dummy = ccb->theEM->
  create_function_item_expr(NULL,
                            NULL,
                            theFunctionItemInfo->theLoc,
                            false,
                            false);
  
  PlanIter_t udfCallIterator = theFunctionItemInfo->theFunction->
  codegen(ccb,
          theFunctionItemInfo->theClosureSctx,
          theFunctionItemInfo->theLoc,
          args,
          *dummy);

  UDFunctionCallIterator* udfIter =
  static_cast<UDFunctionCallIterator*>(udfCallIterator.getp());

  udfIter->setDynamic();
  udfIter->setFunctionItem(this);

  return udfCallIterator;
}
void PrinterVisitor::beginVisit( UDFunctionCallIterator const &i ) {
  thePrinter.startBeginVisit( "UDFunctionCallIterator", ++theId );
  if ( i.isCached() )
  {
    if (i.isCacheAcrossSnapshots())
      thePrinter.addAttribute("cached-across-snapshots", "true");
    else
      thePrinter.addAttribute("cached", "true");
  }
  if ( i.theUDF->getSignature().getName() )
    thePrinter.addAttribute( "function", i.theUDF->getSignature().getName()->getStringValue().str() );
  else
    thePrinter.addAttribute( "function", "inline function" );
  printCommons( &i, theId );
  thePrinter.endBeginVisit( theId );
}