本文整理汇总了C++中UlamType::explicitlyCastable方法的典型用法代码示例。如果您正苦于以下问题:C++ UlamType::explicitlyCastable方法的具体用法?C++ UlamType::explicitlyCastable怎么用?C++ UlamType::explicitlyCastable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UlamType
的用法示例。
在下文中一共展示了UlamType::explicitlyCastable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAndLabelType
UTI NodeCast::checkAndLabelType()
{
// unlike the other nodes, nodecast knows its type at construction time;
// this is for checking for errors, before eval happens.
u32 errorsFound = 0;
UTI tobeType = getNodeType();
UTI nodeType = isExplicitCast() ? m_node->checkAndLabelType() : m_node->getNodeType(); //user cast if explicit
if(m_nodeTypeDesc)
{
//might be a mapped uti for instantiated template class
tobeType = m_nodeTypeDesc->checkAndLabelType();
setNodeType(tobeType); //overrides type set at parse time
if(!m_nodeTypeDesc->isReadyType())
{
std::ostringstream msg;
msg << "Cannot cast to nonready type: " ;
msg << m_state.getUlamTypeNameBriefByIndex(tobeType).c_str();
msg << " (UTI" << tobeType << ")";
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG);
errorsFound++;
}
}
UlamType * tobe = m_state.getUlamTypeByIndex(tobeType);
if(!m_state.isComplete(tobeType))
{
std::ostringstream msg;
msg << "Cannot cast to incomplete type: " ;
msg << m_state.getUlamTypeNameBriefByIndex(tobeType).c_str();
msg << " (UTI" << tobeType << ")";
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG);
errorsFound++;
}
else if(tobeType == Nav)
{
std::ostringstream msg;
msg << "Cannot cast " << m_state.getUlamTypeNameBriefByIndex(nodeType).c_str();
msg << " to not-a-valid type";
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
errorsFound++;
}
else if(tobe->getUlamClass() != UC_NOTACLASS && m_state.getUlamTypeByIndex(nodeType)->getUlamClass() == UC_NOTACLASS)
{
if(nodeType != UAtom)
{
std::ostringstream msg;
msg << "Cannot cast ";
msg << m_state.getUlamTypeNameBriefByIndex(nodeType).c_str();
msg << " to " << m_state.getUlamTypeNameBriefByIndex(tobeType).c_str();
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
errorsFound++;
}
}
else if(isExplicitCast())
{
FORECAST scr = tobe->explicitlyCastable(nodeType);
if(scr != CAST_CLEAR)
{
std::ostringstream msg;
msg << "Cannot explicitly cast ";
msg << m_state.getUlamTypeNameBriefByIndex(nodeType).c_str();
msg << " to type: " << m_state.getUlamTypeNameBriefByIndex(tobeType).c_str();
if(tobe->getUlamTypeEnum() == Bool)
msg << "; Consider using a comparison operator";
if(scr == CAST_HAZY)
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG);
else
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
errorsFound++;
}
}
if(errorsFound == 0) //else
{
if(!m_state.isScalar(tobeType))
{
MSG(getNodeLocationAsString().c_str(),
"Array casts currently not supported", ERR);
errorsFound++;
if(m_state.isScalar(nodeType))
{
MSG(getNodeLocationAsString().c_str(),
"Consider implementing array casts: Cannot cast scalar into array", ERR);
errorsFound++;
}
else if(m_state.getArraySize(tobeType) != m_state.getArraySize(nodeType))
{
MSG(getNodeLocationAsString().c_str(),
"Consider implementing array casts: Array sizes differ", ERR);
errorsFound++;
}
}
else
{
//to be scalar type
if(!m_state.isScalar(nodeType))
{
MSG(getNodeLocationAsString().c_str(),
//.........这里部分代码省略.........