本文整理汇总了C++中UlamValue::incrementPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ UlamValue::incrementPtr方法的具体用法?C++ UlamValue::incrementPtr怎么用?C++ UlamValue::incrementPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UlamValue
的用法示例。
在下文中一共展示了UlamValue::incrementPtr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doBinaryOperationArray
//unlike NodeBinaryOp, NodeBinaryOpCompare has a node type that's different from
// its nodes, where left and right nodes are casted to be the same.
bool NodeBinaryOpCompare::doBinaryOperationArray(s32 lslot, s32 rslot, u32 slots)
{
assert(0); //not implemented yet..TODO return bool.
UlamValue rtnUV;
UTI nuti = getNodeType(); //Bool, same array size as lhs/rhs
UTI luti = m_nodeLeft->getNodeType();
UTI ruti = m_nodeRight->getNodeType();
s32 arraysize = m_state.getArraySize(luti);
assert(arraysize = m_state.getArraySize(nuti)); //node is same array size as lhs/rhs
s32 bitsize = m_state.getBitSize(luti);
UTI scalartypidx = m_state.getUlamTypeAsScalar(luti);
PACKFIT packRtn = m_state.determinePackable(nuti);
if(WritePacked(packRtn))
{
// pack result too. (slot size known ahead of time)
rtnUV = UlamValue::makeAtom(nuti); //accumulate result here
}
// point to base array slots, packedness determines its 'pos'
UlamValue lArrayPtr = UlamValue::makePtr(lslot, EVALRETURN, luti, packRtn, m_state);
UlamValue rArrayPtr = UlamValue::makePtr(rslot, EVALRETURN, ruti, packRtn, m_state);
// to use incrementPtr(), 'pos' depends on packedness
UlamValue lp = UlamValue::makeScalarPtr(lArrayPtr, m_state);
UlamValue rp = UlamValue::makeScalarPtr(rArrayPtr, m_state);
//make immediate result for each element inside loop
for(s32 i = 0; i < arraysize; i++)
{
UlamValue luv = m_state.getPtrTarget(lp);
UlamValue ruv = m_state.getPtrTarget(rp);
u32 ldata = luv.getData(lp.getPtrPos(), bitsize); //'pos' doesn't vary for unpacked
u32 rdata = ruv.getData(rp.getPtrPos(), bitsize); //'pos' doesn't vary for unpacked
if(WritePacked(packRtn))
//use calc position where base [0] is furthest from the end.
appendBinaryOp(rtnUV, ldata, rdata, (BITSPERATOM-(bitsize * (arraysize - i))), bitsize);
else
{
rtnUV = makeImmediateBinaryOp(scalartypidx, ldata, rdata, bitsize);
//cp result UV to stack, -1 (first array element deepest) relative to current frame pointer
m_state.m_nodeEvalStack.storeUlamValueInSlot(rtnUV, -slots + i);
}
assert(lp.incrementPtr(m_state));
assert(rp.incrementPtr(m_state));
} //forloop
if(WritePacked(packRtn))
m_state.m_nodeEvalStack.storeUlamValueInSlot(rtnUV, -1); //store accumulated packed result
return false;
} //end dobinaryoparray
示例2: printPostfixValuesOfVariableDeclarations
// replaces NodeVarDecl:printPostfix to learn the values of Class' storage in center site
void SymbolVariableDataMember::printPostfixValuesOfVariableDeclarations(File * fp, s32 slot, u32 startpos, ULAMCLASSTYPE classtype)
{
UTI vuti = getUlamTypeIdx();
UlamKeyTypeSignature vkey = m_state.getUlamKeyTypeSignatureByIndex(vuti);
UlamType * vut = m_state.getUlamTypeByIndex(vuti);
ULAMCLASSTYPE vclasstype = vut->getUlamClassType();
ULAMTYPE vetyp = vut->getUlamTypeEnum();
fp->write(" ");
if(vclasstype == UC_NOTACLASS)
fp->write(vkey.getUlamKeyTypeSignatureNameAndBitSize(&m_state).c_str());
else
fp->write(vut->getUlamTypeNameBrief().c_str());
fp->write(" ");
fp->write(m_state.m_pool.getDataAsString(getId()).c_str());
s32 arraysize = m_state.getArraySize(vuti);
//scalar has 'size=1'; empty array [0] is still '0'.
s32 size = (arraysize > NONARRAYSIZE ? arraysize : 1);
//output the arraysize (optional), and open paren
if(arraysize > NONARRAYSIZE)
{
fp->write("[");
fp->write_decimal(arraysize);
fp->write("]");
}
else if(arraysize == UNKNOWNSIZE)
{
fp->write("[UNKNOWN]");
}
fp->write("(");
if(vclasstype == UC_QUARK)
{
//outputs the data members, not just the lump value (e.g. SWV::printPostfixValue())
UTI scalarquark = m_state.getUlamTypeAsScalar(vuti);
//printPostfixValuesForClass:
SymbolClass * csym = NULL;
AssertBool isDefined = m_state.alreadyDefinedSymbolClass(scalarquark, csym);
assert(isDefined);
NodeBlockClass * classNode = csym->getClassBlockNode();
assert(classNode);
u32 newstartpos = startpos + getPosOffset();
s32 len = vut->getBitSize();
for(s32 i = 0; i < size; i++)
classNode->printPostfixDataMembersSymbols(fp, slot, newstartpos + len * i, vclasstype);
}
else
{
PACKFIT packFit = m_state.determinePackable(vuti);
assert(WritePacked(packFit)); //has to be to fit in an atom/site;
char * valstr = new char[size * 8 + MAXBITSPERLONG]; //was 32
if(size > 0)
{
//build the string of values (for both scalar and packed array)
UlamValue arrayPtr = UlamValue::makePtr(slot, EVENTWINDOW, vuti, packFit, m_state, startpos + getPosOffset(), getId());
UlamValue nextPtr = UlamValue::makeScalarPtr(arrayPtr, m_state);
UlamValue atval = m_state.getPtrTarget(nextPtr);
s32 len = m_state.getBitSize(vuti);
if(len == UNKNOWNSIZE)
{
sprintf(valstr,"unknown");
for(s32 i = 1; i < size; i++)
{
strcat(valstr,", unknown");
}
}
else if(len <= MAXBITSPERINT)
{
u32 data = atval.getDataFromAtom(nextPtr, m_state);
vut->getDataAsString(data, valstr, 'z'); //'z' -> no preceeding ','
if(vetyp == Unsigned || vetyp == Unary)
strcat(valstr, "u");
for(s32 i = 1; i < size; i++)
{
char tmpstr[8];
AssertBool isNext = nextPtr.incrementPtr(m_state);
assert(isNext);
atval = m_state.getPtrTarget(nextPtr);
data = atval.getDataFromAtom(nextPtr, m_state);
vut->getDataAsString(data, tmpstr, ',');
if(vetyp == Unsigned || vetyp == Unary)
strcat(tmpstr, "u");
strcat(valstr,tmpstr);
}
}
else if(len <= MAXBITSPERLONG)
{
u64 data = atval.getDataLongFromAtom(nextPtr, m_state);
vut->getDataLongAsString(data, valstr, 'z'); //'z' -> no preceeding ','
if(vetyp == Unsigned || vetyp == Unary)
//.........这里部分代码省略.........
示例3: printPostfixValuesOfVariableDeclarations
// replaces NodeVarDecl:printPostfix to learn the values of Class' storage in center site
void SymbolVariableDataMember::printPostfixValuesOfVariableDeclarations(File * fp, s32 slot, u32 startpos, ULAMCLASSTYPE classtype)
{
UTI vuti = getUlamTypeIdx();
UlamKeyTypeSignature vkey = m_state.getUlamKeyTypeSignatureByIndex(vuti);
UlamType * vut = m_state.getUlamTypeByIndex(vuti);
ULAMCLASSTYPE vclasstype = vut->getUlamClass();
fp->write(" ");
if(vclasstype == UC_NOTACLASS)
fp->write(vkey.getUlamKeyTypeSignatureNameAndBitSize(&m_state).c_str());
else
fp->write(vut->getUlamTypeNameBrief().c_str());
fp->write(" ");
fp->write(m_state.m_pool.getDataAsString(getId()).c_str());
s32 arraysize = m_state.getArraySize(vuti);
//scalar has 'size=1'; empty array [0] is still '0'.
s32 size = (arraysize > NONARRAYSIZE ? arraysize : 1);
//output the arraysize (optional), and open paren
if(arraysize > NONARRAYSIZE)
{
fp->write("[");
fp->write_decimal(arraysize);
fp->write("]");
}
else if(arraysize == UNKNOWNSIZE)
{
fp->write("[UNKNOWN]");
}
fp->write("(");
if(vclasstype == UC_QUARK)
{
//printPostfixValuesForClass:
SymbolClass * csym = NULL;
if(m_state.alreadyDefinedSymbolClass(vuti, csym))
{
NodeBlockClass * classNode = csym->getClassBlockNode();
assert(classNode);
SymbolTable * stptr = classNode->getSymbolTablePtr(); //ST of data members
u32 newstartpos = startpos + getPosOffset();
s32 len = vut->getBitSize();
for(s32 i = 0; i < size; i++)
stptr->printPostfixValuesForTableOfVariableDataMembers(fp, slot, newstartpos + len * i, vclasstype);
}
else
{
assert(0); //error!
}
}
else
{
PACKFIT packFit = m_state.determinePackable(vuti);
assert(WritePacked(packFit)); //has to be to fit in an atom/site;
char * valstr = new char[size * 8 + MAXBITSPERLONG]; //was 32
if(size > 0)
{
//simplifying assumption for testing purposes: center site
//Coord c0(0,0);
//u32 slot = c0.convertCoordToIndex();
//build the string of values (for both scalar and packed array)
UlamValue arrayPtr = UlamValue::makePtr(slot, EVENTWINDOW, vuti, packFit, m_state, startpos + getPosOffset(), getId());
UlamValue nextPtr = UlamValue::makeScalarPtr(arrayPtr, m_state);
UlamValue atval = m_state.getPtrTarget(nextPtr);
s32 len = nextPtr.getPtrLen();
assert(len != UNKNOWNSIZE);
if(len <= MAXBITSPERINT)
{
u32 data = atval.getDataFromAtom(nextPtr, m_state);
vut->getDataAsString(data, valstr, 'z'); //'z' -> no preceeding ','
for(s32 i = 1; i < size; i++)
{
char tmpstr[8];
assert(nextPtr.incrementPtr(m_state));
atval = m_state.getPtrTarget(nextPtr);
data = atval.getDataFromAtom(nextPtr, m_state);
vut->getDataAsString(data, tmpstr, ',');
strcat(valstr,tmpstr);
}
}
else if(len <= MAXBITSPERLONG)
{
u64 data = atval.getDataLongFromAtom(nextPtr, m_state);
vut->getDataLongAsString(data, valstr, 'z'); //'z' -> no preceeding ','
for(s32 i = 1; i < size; i++)
{
char tmpstr[8];
assert(nextPtr.incrementPtr(m_state));
atval = m_state.getPtrTarget(nextPtr);
data = atval.getDataLongFromAtom(nextPtr, m_state);
//.........这里部分代码省略.........
示例4: evalToStoreInto
EvalStatus NodeSquareBracket::evalToStoreInto()
{
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();
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();
// constant expression only required for array declaration
u32 offsetdata = offset.getImmediateData(m_state);
s32 offsetInt = m_state.getUlamTypeByIndex(offset.getUlamValueTypeIdx())->getDataAsCs32(offsetdata);
UTI auti = pluv.getPtrTargetType();
UlamType * aut = m_state.getUlamTypeByIndex(auti);
if(aut->isCustomArray())
{
UTI caType = ((UlamTypeClass *) aut)->getCustomArrayType();
UlamType * caut = m_state.getUlamTypeByIndex(caType);
u32 pos = pluv.getPtrPos();
if(caut->getBitSize() > MAXBITSPERINT)
pos = 0;
// itemUV = UlamValue::makeAtom(caType);
//else
// itemUV = UlamValue::makeImmediate(caType, 0, m_state); //quietly skip for now XXX
//use CA type, not the left ident's type
UlamValue scalarPtr = UlamValue::makePtr(pluv.getPtrSlotIndex(),
pluv.getPtrStorage(),
caType,
m_state.determinePackable(caType), //PACKEDLOADABLE
m_state,
pos /* base pos of array */
);
//copy result UV to stack, -1 relative to current frame pointer
assignReturnValuePtrToStack(scalarPtr);
}
else
{
//adjust pos by offset * len, according to its scalar type
UlamValue scalarPtr = UlamValue::makeScalarPtr(pluv, m_state);
if(scalarPtr.incrementPtr(m_state, offsetInt))
//copy result UV to stack, -1 relative to current frame pointer
assignReturnValuePtrToStack(scalarPtr);
else
{
s32 arraysize = m_state.getArraySize(pluv.getPtrTargetType());
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);
evs = ERROR;
}
}
evalNodeEpilog();
return evs;
} //evalToStoreInto