void NodeConstant::genCode(File * fp, UVPass& uvpass) { if(!isReadyConstant()) m_ready = updateConstant(); //sets ready here assert(isReadyConstant()); //must be NodeTerminal::genCode(fp, uvpass); } //genCode
UTI NodeConstant::checkAndLabelType() { UTI it = Nav; bool stubcopy = m_state.isClassAStub(m_state.getCompileThisIdx()); //instantiate, look up in class block; skip if stub copy and already ready. if(!stubcopy && m_constSymbol == NULL) checkForSymbol(); else { stubcopy = m_state.hasClassAStub(m_state.getCompileThisIdx()); //includes ancestors } if(m_constSymbol) { it = m_constSymbol->getUlamTypeIdx(); } else if(isReadyConstant() && stubcopy) { assert(m_state.okUTItoContinue(m_constType)); setNodeType(m_constType); //t3565, t3640, t3641, t3642, t3652 //stub copy case: still wants uti mapping it = NodeTerminal::checkAndLabelType(); } else if(stubcopy) { // still need its symbol for a value // use the member class (unlike checkForSymbol) } // map incomplete UTI if(!m_state.isComplete(it)) //reloads to recheck { std::ostringstream msg; msg << "Incomplete " << prettyNodeName().c_str() << " for type: "; msg << m_state.getUlamTypeNameBriefByIndex(it).c_str(); msg << ", used with constant symbol name '"; msg << m_state.getTokenDataAsString(m_token).c_str() << "'"; MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WAIT); //wait until updateConstant tried. } setNodeType(it); Node::setStoreIntoAble(TBOOL_FALSE); //copy m_constant from Symbol into NodeTerminal parent. if(!isReadyConstant()) m_ready = updateConstant(); //sets ready here if(!isReadyConstant()) { it = Hzy; if(!stubcopy) m_constSymbol = NULL; //lookup again too! (e.g. inherited template instances) m_state.setGoAgain(); } return it; } //checkAndLabelType
EvalStatus NodeConstant::eval() { if(!isReadyConstant()) m_ready = updateConstant(); if(!isReadyConstant()) return ERROR; if(!m_state.isComplete(getNodeType())) return ERROR; return NodeTerminal::eval(); } //eval
bool NodeConstantArray::getArrayValue(BV8K& bvtmp) { bool brtn = false; if(isReadyConstant()) brtn = m_constSymbol->getValue(bvtmp); return brtn; }
//class context set prior to calling us; purpose is to get // the value of this constant from the context before // constant folding happens. bool NodeConstantArray::assignClassArgValueInStubCopy() { // insure current block NNOs match if(m_currBlockNo != m_state.getCurrentBlockNo()) { std::ostringstream msg; msg << "Block NNO " << m_currBlockNo << " for <"; msg << m_state.getTokenDataAsString(m_token).c_str(); msg << "> does not match the current block no "; msg << m_state.getCurrentBlockNo(); msg << "; its value cannot be used in stub copy, with class: "; msg << m_state.getUlamTypeNameBriefByIndex(m_state.getCompileThisIdx()).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG); return false; } if(isReadyConstant()) return true; //nothing to do bool isready = false; Symbol * asymptr = NULL; bool hazyKin = false; if(m_state.alreadyDefinedSymbol(m_token.m_dataindex, asymptr, hazyKin)) { assert(hazyKin); //always hazy, right? if(asymptr->isConstant() && ((SymbolConstantValue *) asymptr)->isReady()) //??? { isready = true; //note: m_constSymbol may be NULL; ok in this circumstance (i.e. stub copy). } } return isready; } //assignClassArgValueInStubCopy
void NodeConstantArray::genCodeToStoreInto(File * fp, UVPass& uvpass) { assert(isReadyConstant()); //must be makeUVPassForCodeGen(uvpass); //******UPDATED GLOBAL; no restore!!!************************** m_state.m_currentObjSymbolsForCodeGen.push_back(m_constSymbol); } //genCodeToStoreInto
FORECAST NodeConstantArray::safeToCastTo(UTI newType) { if(isReadyConstant()) { UlamType * newut = m_state.getUlamTypeByIndex(newType); return newut->safeCast(getNodeType()); } return CAST_HAZY; } //safeToCastTo
void NodeConstantArray::genCode(File * fp, UVPass& uvpass) { assert(isReadyConstant()); //must be //return the ptr for an array; square bracket will resolve down to the immediate data makeUVPassForCodeGen(uvpass); m_state.m_currentObjSymbolsForCodeGen.push_back(m_constSymbol); //*********UPDATED GLOBAL; // UNCLEAR: should this be consistent with constants? Node::genCodeReadIntoATmpVar(fp, uvpass); } //genCode
EvalStatus NodeConstantArray::eval() { if(!isReadyConstant()) return ERROR; UTI nuti = getNodeType(); if(!m_state.isComplete(nuti)) return ERROR; if(((SymbolConstantValue *) m_constSymbol)->getConstantStackFrameAbsoluteSlotIndex() == 0) return NOTREADY; evalNodeProlog(0); //new current node eval frame pointer, t3897 UlamValue rtnUVPtr = makeUlamValuePtr(); Node::assignReturnValueToStack(rtnUVPtr); evalNodeEpilog(); return NORMAL; } //eval
UTI NodeConstantArray::checkAndLabelType() { UTI it = Nav; bool stubcopy = m_state.isClassAStub(m_state.getCompileThisIdx()); //instantiate, look up in class block; skip if stub copy and already ready. if(!stubcopy && m_constSymbol == NULL) checkForSymbol(); else stubcopy = m_state.hasClassAStub(m_state.getCompileThisIdx()); //includes ancestors if(m_constSymbol) it = m_constSymbol->getUlamTypeIdx(); else if(stubcopy) { assert(m_state.okUTItoContinue(m_constType)); setNodeType(m_constType); //t3565, t3640, t3641, t3642, t3652 //stub copy case: still wants uti mapping it = m_constType; } // map incomplete UTI if(!m_state.isComplete(it)) //reloads to recheck { UTI mappedUTI = it; if(m_state.findaUTIAlias(it, mappedUTI)) { std::ostringstream msg; msg << "REPLACE " << prettyNodeName().c_str() << " for type: "; msg << m_state.getUlamTypeNameBriefByIndex(it).c_str(); msg << ", used with alias type: "; msg << m_state.getUlamTypeNameBriefByIndex(it).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG); it = mappedUTI; } if(!m_state.isComplete(it)) //reloads to recheck { std::ostringstream msg; msg << "Incomplete " << prettyNodeName().c_str() << " for type: "; msg << m_state.getUlamTypeNameBriefByIndex(it).c_str(); msg << ", used with constant symbol name '"; msg << m_state.getTokenDataAsString(m_token).c_str() << "'"; MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WAIT); //wait until updateConstant tried. } } setNodeType(it); Node::setStoreIntoAble(TBOOL_FALSE); if(!isReadyConstant()) { it = Hzy; if(!stubcopy) m_constSymbol = NULL; //lookup again too! (e.g. inherited template instances) m_state.setGoAgain(); } return it; } //checkAndLabelType
FORECAST NodeConstant::safeToCastTo(UTI newType) { if(isReadyConstant()) return NodeTerminal::safeToCastTo(newType); return CAST_HAZY; } //safeToCastTo
const char * NodeConstant::getName() { if(isReadyConstant()) return NodeTerminal::getName(); return m_state.getTokenDataAsString(m_token).c_str(); }