ASTNode *FunctionDoc::staticTypingImpl(StaticContext *context) { _src.clear(); if(_args[0]->getStaticAnalysis().getStaticType().getMin() == 0) _src.getStaticType() = StaticType(StaticType::DOCUMENT_TYPE, 0, 1); else _src.getStaticType() = StaticType(StaticType::DOCUMENT_TYPE, 1, 1); _src.setProperties(StaticAnalysis::DOCORDER | StaticAnalysis::GROUPED | StaticAnalysis::PEER | StaticAnalysis::SUBTREE | StaticAnalysis::ONENODE); _src.availableDocumentsUsed(true); return calculateSRCForArguments(context); }
ASTNode *XQStep::staticTypingImpl(StaticContext *context) { _src.clear(); if(context && !context->getContextItemType().containsType(StaticType::ITEM_TYPE)) { XQThrow(DynamicErrorException,X("XQStep::staticTyping"), X("It is an error for the context item to be undefined when using it [err:XPDY0002]")); } _src.setProperties(getAxisProperties(axis_)); _src.contextItemUsed(true); bool isExact; nodeTest_->getStaticType(_src.getStaticType(), context, isExact, this); _src.getStaticType().multiply(0, StaticType::UNLIMITED); switch(axis_) { case SELF: if(context) _src.getStaticType().typeNodeIntersect(context->getContextItemType()); break; case ATTRIBUTE: _src.getStaticType().typeNodeIntersect(StaticType(StaticType::ATTRIBUTE_TYPE, 0, StaticType::UNLIMITED)); break; case NAMESPACE: _src.getStaticType().typeNodeIntersect(StaticType(StaticType::NAMESPACE_TYPE, 0, StaticType::UNLIMITED)); break; case CHILD: case DESCENDANT: case FOLLOWING: case FOLLOWING_SIBLING: case PRECEDING: case PRECEDING_SIBLING: _src.getStaticType().typeNodeIntersect(StaticType(StaticType::ELEMENT_TYPE | StaticType::TEXT_TYPE | StaticType::PI_TYPE | StaticType::COMMENT_TYPE, 0, StaticType::UNLIMITED)); break; case ANCESTOR: case PARENT: _src.getStaticType().typeNodeIntersect(StaticType(StaticType::DOCUMENT_TYPE | StaticType::ELEMENT_TYPE, 0, StaticType::UNLIMITED)); break; case DESCENDANT_OR_SELF: case ANCESTOR_OR_SELF: // Could be any type break; } return this; }
ASTNode *FunctionDayFromDate::staticTypingImpl(StaticContext *context) { _src.clear(); _src.getStaticType() = StaticType(StaticType::DECIMAL_TYPE, 0, 1); return calculateSRCForArguments(context, /*checkTimezone*/true); }
void XQGlobalVariable::staticTyping(StaticContext* context, StaticTyper *styper) { VariableTypeStore* varStore = context->getVariableTypeStore(); if(m_Value != NULL) { XQUserFunction::staticTypeFunctionCalls(m_Value, context, styper); m_Value = m_Value->staticTyping(context, styper); _src.copy(m_Value->getStaticAnalysis()); if(m_Value->getStaticAnalysis().isUpdating()) { XQThrow(StaticErrorException,X("XQGlobalVariable::staticTyping"), X("It is a static error for the initializing expression of a global variable " "to be an updating expression [err:XUST0001]")); } } if(m_Value == 0 || !required_) { if(m_Type != 0) { bool isPrimitive; m_Type->getStaticType(_src.getStaticType(), context, isPrimitive, m_Type); } else { _src.getStaticType() = StaticType(StaticType::ITEM_TYPE, 0, StaticType::UNLIMITED); } } varStore->declareGlobalVar(m_szURI, m_szLocalName, _src); }
ASTNode *XQAtomize::staticTypingImpl(StaticContext *context) { _src.clear(); _src.getStaticType() = expr_->getStaticAnalysis().getStaticType(); _src.add(expr_->getStaticAnalysis()); if(expr_->getStaticAnalysis().isUpdating()) { XQThrow(StaticErrorException,X("XQAtomize::staticTyping"), X("It is a static error for an atomized expression " "to be an updating expression [err:XUST0001]")); } if(_src.getStaticType().isType(StaticType::FUNCTION_TYPE) && _src.getStaticType().getMin() > 0) { XMLBuffer buf; buf.set(X("Sequence does not match type (xs:anyAtomicType | node())*")); buf.append(X(" - the expression has a static type of ")); _src.getStaticType().typeToBuf(buf); buf.append(X(" [err:XPTY0004]")); XQThrow(XPath2TypeMatchException, X("XQAtomize::staticTyping"), buf.getRawBuffer()); } if(!_src.getStaticType().containsType(StaticType::NODE_TYPE|StaticType::FUNCTION_TYPE)) { // If the expression has no nodes, this function does nothing return substitute(expr_); } if(doPSVI_) { _src.getStaticType().substitute(StaticType::ELEMENT_TYPE | StaticType::ATTRIBUTE_TYPE, StaticType(StaticType::ANY_ATOMIC_TYPE, 0, StaticType::UNLIMITED)); } else { _src.getStaticType().substitute(StaticType::ELEMENT_TYPE | StaticType::ATTRIBUTE_TYPE, StaticType::UNTYPED_ATOMIC_TYPE); } _src.getStaticType().substitute(StaticType::DOCUMENT_TYPE | StaticType::TEXT_TYPE, StaticType::UNTYPED_ATOMIC_TYPE); _src.getStaticType().substitute(StaticType::NAMESPACE_TYPE | StaticType::COMMENT_TYPE | StaticType::PI_TYPE, StaticType::STRING_TYPE); // Remove function types _src.getStaticType() &= StaticType(StaticType::NODE_TYPE | StaticType::ANY_ATOMIC_TYPE, 0, StaticType::UNLIMITED); return this; }
ASTNode *FunctionAdjustTimeToTimezone::staticTypingImpl(StaticContext *context) { _src.clear(); _src.getStaticType() = StaticType(StaticType::TIME_TYPE, 0, 1); if(getNumArgs() == 1) { _src.implicitTimezoneUsed(true); } return calculateSRCForArguments(context); }
ASTNode *FunctionParseXML::staticTypingImpl(StaticContext *context) { _src.clear(); _src.setProperties(StaticAnalysis::DOCORDER | StaticAnalysis::GROUPED | StaticAnalysis::PEER | StaticAnalysis::SUBTREE | StaticAnalysis::ONENODE); _src.getStaticType() = StaticType(StaticType::DOCUMENT_TYPE, 0, 1); _src.creative(true); return calculateSRCForArguments(context); }
void DObject::CheckIfSerialized () const { if (!(ObjectFlags & OF_SerialSuccess)) { I_Error ( "BUG: %s::Serialize\n" "(or one of its superclasses) needs to call\n" "Super::Serialize\n", StaticType()->TypeName.GetChars()); } }
ASTNode *FunctionDocument::staticTypingImpl(StaticContext *context) { _src.clear(); _src.setProperties(StaticAnalysis::DOCORDER | StaticAnalysis::GROUPED | StaticAnalysis::PEER | StaticAnalysis::SUBTREE | StaticAnalysis::ONENODE); // TBD Change if we support fragment identifiers - jpcs _src.getStaticType() = StaticType(StaticType::DOCUMENT_TYPE, 0, StaticType::UNLIMITED); _src.availableDocumentsUsed(true); return calculateSRCForArguments(context); }
void SequenceType::getStaticType(StaticType &st, const StaticContext *context, bool &isExact, const LocationInfo *location) const { if(m_pItemType == 0) { st = StaticType(); isExact = true; } else { m_pItemType->getStaticType(st, context, isExact, location); switch(m_nOccurrence) { case EXACTLY_ONE: break; case STAR: st.multiply(0, StaticType::UNLIMITED); break; case PLUS: st.multiply(1, StaticType::UNLIMITED); break; case QUESTION_MARK: st.multiply(0, 1); break; } } }
ASTNode *ArithmeticOperator::staticTypingImpl(StaticContext *context) { _src.clear(); bool emptyArgument = false; for(VectorOfASTNodes::iterator i = _args.begin(); i != _args.end(); ++i) { if((*i)->getStaticAnalysis().isUpdating()) { XQThrow(StaticErrorException,X("ArithmeticOperator::staticTyping"), X("It is a static error for an operand of an operator " "to be an updating expression [err:XUST0001]")); } if((*i)->getStaticAnalysis().getStaticType().getMin() == 0) emptyArgument = true; _src.add((*i)->getStaticAnalysis()); if((*i)->isDateOrTimeAndHasNoTimezone(context)) _src.implicitTimezoneUsed(true); } _src.getStaticType() = StaticType(); calculateStaticType(); if(!emptyArgument && _src.getStaticType().getMax() == 0) { XMLBuffer errMsg; errMsg.set(X("The operator ")); errMsg.append(_opName); errMsg.append(X(" has been called on invalid operand types [err:XPTY0004]")); XQThrow(XPath2ErrorException,X("ArithmeticOperator::staticResolution"), errMsg.getRawBuffer()); } if(emptyArgument) _src.getStaticType().setCardinality(0, 1); else _src.getStaticType().setCardinality(1, 1); return this; }
ASTNode *XQContentSequence::staticTypingImpl(StaticContext *context) { _src.clear(); _src.copy(expr_->getStaticAnalysis()); if(!expr_->getStaticAnalysis().getStaticType().containsType(StaticType::DOCUMENT_TYPE|StaticType::ANY_ATOMIC_TYPE)) { ASTNode *pChild = expr_; // Not needed if the wrapped expression is a DOM_CONSTRUCTOR if(pChild->getType() == ASTNode::DOM_CONSTRUCTOR || (pChild->getType() == ASTNode::NAMESPACE_BINDING && ((XQNamespaceBinding*)pChild)->getExpression()->getType() == ASTNode::DOM_CONSTRUCTOR)) { return expr_; } } _src.getStaticType().substitute(StaticType::ANY_ATOMIC_TYPE, StaticType::TEXT_TYPE); _src.getStaticType().substitute(StaticType::DOCUMENT_TYPE, StaticType(StaticType::ELEMENT_TYPE | StaticType::TEXT_TYPE | StaticType::PI_TYPE | StaticType::COMMENT_TYPE, 0, StaticType::UNLIMITED)); _src.creative(true); return this; }
FunctionCompare::FunctionCompare(const VectorOfASTNodes &args, XPath2MemoryManager* memMgr) : ConstantFoldingFunction(name, minArgs, maxArgs, "string?,string?,string", args, memMgr) { _src.getStaticType() = StaticType(StaticType::DECIMAL_TYPE, 0, 1); }
FunctionStringToCodepoints::FunctionStringToCodepoints(const VectorOfASTNodes &args, XPath2MemoryManager* memMgr) : ConstantFoldingFunction(name, minArgs, maxArgs, "string?", args, memMgr) // 1 argument { _src.getStaticType() = StaticType(StaticType::DECIMAL_TYPE, 0, StaticType::UNLIMITED); }
FunctionRound::FunctionRound(const VectorOfASTNodes &args, XPath2MemoryManager* memMgr) : NumericFunction(name, minArgs, maxArgs, "anyAtomicType?", args, memMgr) { _src.getStaticType() = StaticType(StaticType::NUMERIC_TYPE, 0, 1); }
FunctionYearsFromDuration::FunctionYearsFromDuration(const VectorOfASTNodes &args, XPath2MemoryManager* memMgr) : ConstantFoldingFunction(name, minArgs, maxArgs, "duration?", args, memMgr) { _src.getStaticType() = StaticType(StaticType::DECIMAL_TYPE, 0, 1); }
void SequenceType::ItemType::getStaticType(StaticType &st, const StaticContext *context, bool &isExact, const LocationInfo *location) const { if(this == NULL) { st = StaticType(); isExact = true; return; } switch(m_nTestType) { case TEST_ANYTHING: { st = StaticType::ITEM_TYPE; isExact = true; break; } case TEST_ATOMIC_TYPE: { st = StaticType::create(m_TypeURI, m_pType->getName(), context, isExact); break; } case TEST_DOCUMENT: { st = StaticType::DOCUMENT_TYPE; if(m_pName == NULL && m_pType == NULL) isExact = true; else isExact = false; break; } case TEST_ELEMENT: { st = StaticType::ELEMENT_TYPE; if(m_pName == NULL && m_pType == NULL) isExact = true; else isExact = false; break; } case TEST_ATTRIBUTE: { st = StaticType::ATTRIBUTE_TYPE; if(m_pName == NULL && m_pType == NULL) isExact = true; else isExact = false; break; } case TEST_PI: { st = StaticType::PI_TYPE; if(m_pName == NULL && m_pType == NULL) isExact = true; else isExact = false; break; } case TEST_SCHEMA_ELEMENT: { st = StaticType::ELEMENT_TYPE; isExact = false; break; } case TEST_SCHEMA_ATTRIBUTE: { st = StaticType::ATTRIBUTE_TYPE; isExact = false; break; } case TEST_SCHEMA_DOCUMENT: { st = StaticType::DOCUMENT_TYPE; isExact = false; break; } case TEST_COMMENT: { st = StaticType::COMMENT_TYPE; isExact = true; break; } case TEST_TEXT: { st = StaticType::TEXT_TYPE; isExact = true; break; } case TEST_NODE: { st = StaticType::NODE_TYPE; isExact = true; break; } case TEST_FUNCTION: { if(returnType_ == 0) { st = StaticType::FUNCTION_TYPE; isExact = true; } else { StaticType ret; returnType_->getStaticType(ret, context, isExact, location); isExact = isExact && argTypes_->size() == 0; st = StaticType(context->getMemoryManager(), (unsigned int)argTypes_->size(), ret); } break; } } }