本文整理汇总了C++中UlamValue::getValAt方法的典型用法代码示例。如果您正苦于以下问题:C++ UlamValue::getValAt方法的具体用法?C++ UlamValue::getValAt怎么用?C++ UlamValue::getValAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UlamValue
的用法示例。
在下文中一共展示了UlamValue::getValAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eval
EvalStatus NodeSquareBracket::eval()
{
assert(m_nodeLeft && m_nodeRight);
UTI nuti = getNodeType();
if(nuti == Nav)
return ERROR;
evalNodeProlog(0); //new current frame pointer
makeRoomForSlots(1); //always 1 slot for ptr
EvalStatus evs = m_nodeLeft->evalToStoreInto();
if(evs != NORMAL)
{
evalNodeEpilog();
return evs;
}
UlamValue pluv = m_state.m_nodeEvalStack.popArg();
UTI ltype = pluv.getPtrTargetType();
//could be a custom array which is a scalar quark. already checked.
UlamType * lut = m_state.getUlamTypeByIndex(ltype);
bool isCustomArray = lut->isCustomArray();
assert(!m_state.isScalar(ltype) || isCustomArray); //already checked, must be array
makeRoomForNodeType(m_nodeRight->getNodeType()); //offset a constant expression
evs = m_nodeRight->eval();
if(evs != NORMAL)
{
evalNodeEpilog();
return evs;
}
UlamValue offset = m_state.m_nodeEvalStack.popArg();
UlamType * offut = m_state.getUlamTypeByIndex(offset.getUlamValueTypeIdx());
s32 offsetInt = 0;
if(offut->isNumericType())
{
// constant expression only required for array declaration
s32 arraysize = m_state.getArraySize(ltype);
u32 offsetdata = offset.getImmediateData(m_state);
offsetInt = offut->getDataAsCs32(offsetdata);
if((offsetInt >= arraysize) && !isCustomArray)
{
Symbol * lsymptr;
u32 lid = 0;
if(getSymbolPtr(lsymptr))
lid = lsymptr->getId();
std::ostringstream msg;
msg << "Array subscript [" << offsetInt << "] exceeds the size (" << arraysize;
msg << ") of array '" << m_state.m_pool.getDataAsString(lid).c_str() << "'";
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
evalNodeEpilog();
return ERROR;
}
}
else if(!isCustomArray)
{
Symbol * lsymptr;
u32 lid = 0;
if(getSymbolPtr(lsymptr))
lid = lsymptr->getId();
std::ostringstream msg;
msg << "Array subscript of array '";
msg << m_state.m_pool.getDataAsString(lid).c_str();
msg << "' requires a numeric type";
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
evalNodeEpilog();
return ERROR;
}
assignReturnValueToStack(pluv.getValAt(offsetInt, m_state));
evalNodeEpilog();
return NORMAL;
} //eval