Esempio n. 1
0
ASTNode* Intersect::staticResolution(StaticContext *context)
{
  XPath2MemoryManager *mm = context->getMemoryManager();

  if(!sortAdded_) {
    sortAdded_ = true;
    // Wrap ourselves in a document order sort
    ASTNode *result = new (mm) XQDocumentOrder(this, mm);
    result->setLocationInfo(this);
    return result->staticResolution(context);
  }

  for(VectorOfASTNodes::iterator i = _args.begin(); i != _args.end(); ++i) {
    SequenceType *seqType = new (mm) SequenceType(new (mm) SequenceType::ItemType(SequenceType::ItemType::TEST_NODE),
                                                  SequenceType::STAR);
    seqType->setLocationInfo(this);

    *i = new (mm) XQTreatAs(*i, seqType, mm);
    (*i)->setLocationInfo(this);

    *i = (*i)->staticResolution(context);
  }

  return this;
}
Esempio n. 2
0
ASTNode *XQLiteral::create(bool value, XPath2MemoryManager* mm, const LocationInfo *location)
{
  ASTNode *result = new (mm) XQLiteral(SchemaSymbols::fgURI_SCHEMAFORSCHEMA,
                                       SchemaSymbols::fgDT_BOOLEAN,
                                       value ? SchemaSymbols::fgATTVAL_TRUE : SchemaSymbols::fgATTVAL_FALSE,
                                       AnyAtomicType::BOOLEAN, mm);
  result->setLocationInfo(location);
  return result;
}
Esempio n. 3
0
ASTNode* FunctionZeroOrOne::staticResolution(StaticContext *context)
{
  XPath2MemoryManager *mm = context->getMemoryManager();

  SequenceType *seqType = new (mm) SequenceType(new (mm) SequenceType::ItemType(SequenceType::ItemType::TEST_ANYTHING),
                                                SequenceType::QUESTION_MARK);
  seqType->setLocationInfo(this);

  ASTNode *result = new (mm) XQTreatAs(_args.front(), seqType, mm, err_FORG0003);
  result->setLocationInfo(this);
  return result->staticResolution(context);
}
Esempio n. 4
0
ASTNode *FunctionRefImpl::createInstance(const FuncFactory *factory, const FunctionSignature *signature,
                                         XPath2MemoryManager *mm, const LocationInfo *location)
{
  VectorOfASTNodes newArgs = VectorOfASTNodes(XQillaAllocator<ASTNode*>(mm));
  if(signature->argSpecs) {
    ArgumentSpecs::const_iterator argsIt = signature->argSpecs->begin();
    for(; argsIt != signature->argSpecs->end(); ++argsIt) {
      assert((*argsIt)->getName() != 0);
      XQVariable *var = new (mm) XQVariable((*argsIt)->getURI(), (*argsIt)->getName(), mm);
      var->setLocationInfo(location);
      newArgs.push_back(var);
    }
  }

  ASTNode *instance = factory->createInstance(newArgs, mm);
  instance->setLocationInfo(location);
  return instance;
}
Esempio n. 5
0
ASTNode *XQLiteral::create(const Item::Ptr &item, DynamicContext *context, XPath2MemoryManager* memMgr,
                           const LocationInfo *location)
{
  if(item->isAtomicValue()) {
    ASTNode *result = 0;

    const AnyAtomicType *atom = (const AnyAtomicType*)item.get();
    switch(atom->getPrimitiveTypeIndex()) {
    case AnyAtomicType::QNAME: {
      const ATQNameOrDerived *qname = (const ATQNameOrDerived*)atom;
      result = new (memMgr) XQQNameLiteral(atom->getTypeURI(), atom->getTypeName(),
                                           qname->getURI(), qname->getPrefix(),
                                           qname->getName(), memMgr);
      break;
    }
    case AnyAtomicType::DECIMAL:
    case AnyAtomicType::DOUBLE:
    case AnyAtomicType::FLOAT: {
      const Numeric *number = (const Numeric*)atom;
      if(number->getState() == Numeric::NUM || (number->getState() == Numeric::NEG_NUM && !number->isZero())) {
        result = new (memMgr) XQNumericLiteral(number->getTypeURI(), number->getTypeName(), number->asMAPM(),
                                               number->getPrimitiveTypeIndex(), memMgr);
        break;
      }
      // Fall through
    }
    default:
      result = new (memMgr) XQLiteral(atom->getTypeURI(), atom->getTypeName(), atom->asString(context),
                                      atom->getPrimitiveTypeIndex(), memMgr);
      break;
    }

    result->setLocationInfo(location);
    return result;
  }
  else {
    XQThrow2(::IllegalArgumentException, X("XQLiteral::create"), X("Cannot create an ASTNode literal for a non atomic item"));
  }
}