예제 #1
0
ASTNode* FunctionStringLength::staticResolution(StaticContext *context)
{
  XPath2MemoryManager *mm = context->getMemoryManager();

  if(_args.empty()) {
    FunctionString *arg = new (mm) FunctionString(VectorOfASTNodes(XQillaAllocator<ASTNode*>(mm)), mm);
    arg->setLocationInfo(this);

    _args.push_back(arg);
  }

  resolveArguments(context);
  return this;
}
예제 #2
0
파일: XQSequence.cpp 프로젝트: kanbang/Colt
ASTNode *XQSequence::staticTypingImpl(StaticContext *context)
{
  _src.clear();

  bool doneOne = false;
  bool possiblyUpdating = true;
  bool nestedSeq = false;
  VectorOfASTNodes::iterator i = _astNodes.begin();

  if(i == _astNodes.end()) {
    _src.possiblyUpdating(true);
  }

  for(; i != _astNodes.end(); ++i) {
    if(_src.isUpdating()) {
      if(!(*i)->getStaticAnalysis().isUpdating() &&
         !(*i)->getStaticAnalysis().isPossiblyUpdating())
        XQThrow(StaticErrorException, X("XQSequence::staticTyping"),
                X("Mixed updating and non-updating operands [err:XUST0001]"));
    }
    else {
      if((*i)->getStaticAnalysis().isUpdating() && !possiblyUpdating)
        XQThrow(StaticErrorException, X("XQSequence::staticTyping"),
                X("Mixed updating and non-updating operands [err:XUST0001]"));
    }

    if(possiblyUpdating)
      possiblyUpdating = (*i)->getStaticAnalysis().isPossiblyUpdating();

    if(!doneOne) {
      doneOne = true;
      _src.getStaticType() = (*i)->getStaticAnalysis().getStaticType();
    } else {
      _src.getStaticType().typeConcat((*i)->getStaticAnalysis().getStaticType());
    }

    if((*i)->getType() == SEQUENCE)
      nestedSeq = true;

    _src.add((*i)->getStaticAnalysis());
  }

  if(context && nestedSeq) {
    XPath2MemoryManager *mm = context->getMemoryManager();
    VectorOfASTNodes newArgs = VectorOfASTNodes(XQillaAllocator<ASTNode*>(mm));
    for(i = _astNodes.begin(); i != _astNodes.end(); ++i) {
      if((*i)->getType() == SEQUENCE) {
        XQSequence *arg = (XQSequence*)*i;
        for(VectorOfASTNodes::iterator j = arg->_astNodes.begin(); j != arg->_astNodes.end(); ++j) {
          newArgs.push_back(*j);
        }
      }
      else {
        newArgs.push_back(*i);
      }
    }
    _astNodes = newArgs;
  }

  // Dissolve ourselves if we have only one child
  if(context && _astNodes.size() == 1) {
    return _astNodes.front();
  }
  return this;
}