本文整理汇总了C++中UlamType::getUlamTypeClassNameBrief方法的典型用法代码示例。如果您正苦于以下问题:C++ UlamType::getUlamTypeClassNameBrief方法的具体用法?C++ UlamType::getUlamTypeClassNameBrief怎么用?C++ UlamType::getUlamTypeClassNameBrief使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UlamType
的用法示例。
在下文中一共展示了UlamType::getUlamTypeClassNameBrief方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printTypeAndName
void NodeVarRef::printTypeAndName(File * fp)
{
UTI vuti = m_varSymbol->getUlamTypeIdx();
UlamKeyTypeSignature vkey = m_state.getUlamKeyTypeSignatureByIndex(vuti);
UlamType * vut = m_state.getUlamTypeByIndex(vuti);
if(m_state.isConstantRefType(vuti))
fp->write(" constant"); //t41242,3
fp->write(" ");
if(vut->getUlamTypeEnum() != Class)
{
fp->write(vkey.getUlamKeyTypeSignatureNameAndBitSize(&m_state).c_str());
fp->write("&"); //<--the only difference!!!
}
else
fp->write(vut->getUlamTypeClassNameBrief(vuti).c_str()); //includes any &
fp->write(" ");
fp->write(getName());
s32 arraysize = m_state.getArraySize(vuti);
if(arraysize > NONARRAYSIZE)
{
fp->write("[");
fp->write_decimal(arraysize);
fp->write("]");
}
else if(arraysize == UNKNOWNSIZE)
{
fp->write("[UNKNOWN]");
}
} //printTypeAndName
示例2: safeToCastTo
FORECAST NodeVarRef::safeToCastTo(UTI newType)
{
assert(m_nodeInitExpr);
UTI nuti = getNodeType();
//cast RHS if necessary and safe
//insure lval is same bitsize/arraysize
// if classes, safe to cast a subclass to any of its superclasses
FORECAST rscr = CAST_CLEAR;
if(UlamType::compare(nuti, newType, m_state) != UTIC_SAME)
{
UlamType * nut = m_state.getUlamTypeByIndex(nuti);
UlamType * newt = m_state.getUlamTypeByIndex(newType);
rscr = m_nodeInitExpr->safeToCastTo(nuti);
if((nut->getUlamTypeEnum() == Class))
{
if(rscr != CAST_CLEAR)
{
//e.g. error/t3792, error/t3616
std::ostringstream msg;
msg << "Incompatible class types ";
msg << nut->getUlamTypeClassNameBrief(nuti).c_str();
msg << " and ";
msg << m_state.getUlamTypeNameBriefByIndex(newType).c_str();
msg << " used to initialize reference '" << getName() <<"'";
if(rscr == CAST_HAZY)
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG);
else
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
}
}
else if(m_state.isAtom(nuti))
{
//atoms init from a quark ref could use .atomof
// "clear" when complete, not the same as "bad".
if(rscr != CAST_CLEAR)
{
std::ostringstream msg;
msg << "Reference atom variable " << getName() << "'s type ";
msg << nut->getUlamTypeNameBrief().c_str();
msg << ", and its initial value type ";
msg << m_state.getUlamTypeNameBriefByIndex(newType).c_str();
msg << ", are incompatible";
if(newt->isAltRefType() && newt->getUlamClassType() == UC_QUARK)
msg << "; .atomof may help";
if(rscr == CAST_HAZY)
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG);
else
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
}
}
else
{
//primitives must be EXACTLY the same size (for initialization);
// "clear" when complete, not the same as "bad". (t3614, t3694)
if(rscr != CAST_CLEAR)
{
std::ostringstream msg;
msg << "Reference variable " << getName() << "'s type ";
msg << m_state.getUlamTypeNameBriefByIndex(nuti).c_str();
msg << ", and its initial value type ";
msg << m_state.getUlamTypeNameBriefByIndex(newType).c_str();
msg << ", are incompatible";
if(rscr == CAST_HAZY)
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG);
else
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
}
else if(m_nodeInitExpr->isAConstant() && !m_state.isConstantRefType(nuti))
{
std::ostringstream msg;
msg << "Initial value of non-constant reference variable: " << getName();
msg << " is constant";
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR); //error/t41255
rscr = CAST_BAD;
}
}
}
//okay to explicitly cast rhs to reference type, e.g. if(a is Foo) QW& qref = (Foo &) a;
return rscr;
} //safeToCastTo