本文整理汇总了C++中UlamType::getArraySize方法的典型用法代码示例。如果您正苦于以下问题:C++ UlamType::getArraySize方法的具体用法?C++ UlamType::getArraySize怎么用?C++ UlamType::getArraySize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UlamType
的用法示例。
在下文中一共展示了UlamType::getArraySize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getArrayValueAsString
bool SymbolWithValue::getArrayValueAsString(std::string& vstr)
{
BV8K dval;
bool oktoprint = getValueReadyToPrint(dval);
if(!oktoprint) return false;
UTI tuti = getUlamTypeIdx();
UlamType * tut = m_state.getUlamTypeByIndex(tuti);
if(tut->getTotalBitSize() == 0)
{
vstr = "10"; //empty array
return true;
}
//get the number of bits for this type into u64
// convert to a lex-number as a string, applying type specifics
// return the completed string of all the array values in arg vstr.
std::ostringstream tovstr;
s32 bs = tut->getBitSize();
s32 arraysize = tut->getArraySize();
for(s32 i=0; i < arraysize; i++)
{
u64 thisval = dval.ReadLong(i * bs, bs); //pos and len
std::string str;
convertValueToALexString(thisval, tuti, str, m_state);
tovstr << str;
}
vstr = tovstr.str();
return true;
} //getArrayValueAsString
示例2: generateCodedVariableDeclarations
// replaced by NodeVarDecl:genCode to leverage the declaration order preserved by the parse tree.
void SymbolVariableDataMember::generateCodedVariableDeclarations(File * fp, ULAMCLASSTYPE classtype)
{
assert(classtype == UC_ELEMENT); //really?
UTI vuti = getUlamTypeIdx();
UlamType * vut = m_state.getUlamTypeByIndex(vuti);
ULAMCLASSTYPE vclasstype = vut->getUlamClassType();
m_state.indentUlamCode(fp);
fp->write(vut->getUlamTypeMangledName().c_str()); //for C++
if(vclasstype == UC_QUARK) //called on classtype elements only
{
fp->write("<");
fp->write_decimal(getPosOffset());
fp->write(">");
}
fp->write(" ");
fp->write(getMangledName().c_str());
#if 0
s32 arraysize = vut->getArraySize();
if(arraysize > NONARRAYSIZE)
{
fp->write("[");
fp->write_decimal(arraysize);
fp->write("]");
}
else if(arraysize == UNKNOWNSIZE)
{
fp->write("[UNKNOWN]");
}
#endif
fp->write(";"); GCNL;
} //generateCodedVariableDeclarations
示例3: getArrayItemValue
bool SymbolWithValue::getArrayItemValue(u32 item, u64& rtnitem)
{
if(isReady())
{
UTI suti = getUlamTypeIdx();
UlamType * sut = m_state.getUlamTypeByIndex(suti);
u32 bs = sut->getBitSize();
s32 arrsize = sut->getArraySize();
assert(bs <= MAXBITSPERLONG);
assert((arrsize >= 0) && (item < (u32) arrsize));
//no casting!
rtnitem = m_constantValue.ReadLong(item * bs, bs);
return true;
}
return false;
}
示例4: getArrayItemInitValue
bool SymbolWithValue::getArrayItemInitValue(u32 item, u32& rtnitem)
{
assert(hasInitValue());
if(isInitValueReady())
{
UTI suti = getUlamTypeIdx();
UlamType * sut = m_state.getUlamTypeByIndex(suti);
u32 bs = sut->getBitSize();
s32 arrsize = sut->getArraySize();
assert(bs <= MAXBITSPERINT);
assert((arrsize >= 0) && (item < (u32) arrsize));
//no casting!
rtnitem = m_initialValue.Read(item * bs, bs);
return true;
}
return false;
}
示例5: checkAndLabelType
UTI NodeMemberSelect::checkAndLabelType()
{
assert(m_nodeLeft && m_nodeRight);
UTI luti = m_nodeLeft->checkAndLabelType(); //side-effect
TBOOL lstor = m_nodeLeft->getStoreIntoAble();
if(lstor != TBOOL_TRUE)
{
//e.g. funcCall is not storeintoable even if its return value is.
std::ostringstream msg;
msg << "Member selected must be a valid lefthand side: '";
msg << m_nodeLeft->getName();
msg << "' requires a variable; may be a casted function call";
if(lstor == TBOOL_HAZY)
{
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WAIT);
setNodeType(Hzy);
m_state.setGoAgain();
return Hzy;
}
else
{
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
setNodeType(Nav);
return Nav;
}
} //done
if(!m_state.isComplete(luti))
{
std::ostringstream msg;
msg << "Member selected is incomplete class: ";
msg << m_state.getUlamTypeNameBriefByIndex(luti).c_str();
msg << ", check and label fails this time around";
if(luti == Nav)
{
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
setNodeType(Nav);
}
else
{
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WAIT);
setNodeType(Hzy);
m_state.setGoAgain(); //since no error msg
}
return getNodeType();
} //done
UlamType * lut = m_state.getUlamTypeByIndex(luti);
ULAMCLASSTYPE classtype = lut->getUlamClassType();
if(((classtype == UC_NOTACLASS) && (lut->getUlamTypeEnum() != Holder)) || !lut->isScalar())
{
// must be a scalar 'Class' type, (e.g. error/t3815)
// doesn't complete checkandlabel for rhs (e.g. funccall is NULL, no eval)
std::ostringstream msg;
msg << "Member selected must be a Class, not type: ";
msg << m_state.getUlamTypeNameBriefByIndex(luti).c_str();
if(classtype != UC_NOTACLASS)
msg << "[" << lut->getArraySize() << "]";
if(m_state.isAtom(luti))
msg << "; suggest using a Conditional-As";
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
setNodeType(Nav);
return Nav;
} //done
std::string className = m_state.getUlamTypeNameBriefByIndex(luti); //help me debug
SymbolClass * csym = NULL;
AssertBool isDefined = m_state.alreadyDefinedSymbolClass(luti, csym);
assert(isDefined);
NodeBlockClass * memberClassNode = csym->getClassBlockNode();
assert(memberClassNode); //e.g. forgot the closing brace on quark definition
assert(m_state.okUTItoContinue(memberClassNode->getNodeType())); //t41010
//set up compiler state to use the member class block for symbol searches
m_state.pushClassContextUsingMemberClassBlock(memberClassNode);
UTI rightType = m_nodeRight->checkAndLabelType();
//clear up compiler state to no longer use the member class block for symbol searches
m_state.popClassContext();
setNodeType(rightType); //set Nav if error (t3513)
if(m_state.okUTItoContinue(rightType))
{
//based on righthand side
Node::setStoreIntoAble(m_nodeRight->getStoreIntoAble());
//base reference-ability on righthand side (t41085)
Node::setReferenceAble(m_nodeRight->getReferenceAble());
}
return getNodeType();
} //checkAndLabelType