UTI NodeTypeDescriptorSelect::checkAndLabelType() { UTI it = getNodeType(); if(isReadyType()) return it; if(resolveType(it)) { m_ready = true; //set here m_uti = it; //given reset here } setNodeType(it); if(it == Hzy) m_state.setGoAgain(); return getNodeType(); } //checkAndLabelType
bool NodeTypeDescriptorSelect::resolveType(UTI& rtnuti) { bool rtnb = false; if(isReadyType()) { rtnuti = getNodeType(); return true; } // we are in a "chain" of type selects.. assert(m_nodeSelect); UTI seluti = m_nodeSelect->checkAndLabelType(); if(m_nodeSelect->isReadyType()) { UlamType * selut = m_state.getUlamTypeByIndex(seluti); ULAMTYPE seletype = selut->getUlamTypeEnum(); if(seletype == Class) { SymbolClass * csym = NULL; assert(m_state.alreadyDefinedSymbolClass(seluti, csym)); m_state.pushClassContext(seluti, csym->getClassBlockNode(), csym->getClassBlockNode(), false, NULL); // find our id in the "selected" class, must be a typedef at top level Symbol * asymptr = NULL; if(m_state.alreadyDefinedSymbol(m_typeTok.m_dataindex, asymptr)) { if(asymptr->isTypedef()) { UTI auti = asymptr->getUlamTypeIdx(); if(m_state.isComplete(auti)) { rtnuti = auti; //should be mapped already, if necessary rtnb = true; } else if(m_state.isHolder(auti)) { UTI mappedUTI; if(m_state.mappedIncompleteUTI(seluti, auti, mappedUTI)) { std::ostringstream msg; msg << "Substituting Mapped UTI" << mappedUTI << ", "; msg << m_state.getUlamTypeNameBriefByIndex(mappedUTI).c_str(); msg << " for incomplete descriptor type: "; msg << m_state.getUlamTypeNameBriefByIndex(auti).c_str(); msg << "' UTI" << auti << " while labeling class: "; msg << m_state.getUlamTypeNameBriefByIndex(seluti).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG); auti = mappedUTI; } } } else { //error id is not a typedef std::ostringstream msg; msg << "Not a typedef <" << m_state.getTokenDataAsString(&m_typeTok).c_str(); msg << "> in another class, " ;; msg << m_state.getUlamTypeNameBriefByIndex(seluti).c_str(); msg <<" while compiling: "; msg << m_state.getUlamTypeNameBriefByIndex(m_state.getCompileThisIdx()).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WARN); } } else { //error! id not found std::ostringstream msg; msg << "Undefined Typedef <" << m_state.getTokenDataAsString(&m_typeTok).c_str(); msg << "> in another class, " ;; msg << m_state.getUlamTypeNameBriefByIndex(seluti).c_str(); msg <<" while compiling: "; msg << m_state.getUlamTypeNameBriefByIndex(m_state.getCompileThisIdx()).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG); } m_state.popClassContext(); } else { //error has to be a class std::ostringstream msg; msg << "Type selected by <" << m_state.getTokenDataAsString(&m_typeTok).c_str(); msg << "> is NOT another class, " ; msg << m_state.getUlamTypeNameBriefByIndex(seluti).c_str(); msg << ", rather a " << UlamType::getUlamTypeEnumAsString(seletype) << " type,"; msg <<" while compiling: "; msg << m_state.getUlamTypeNameBriefByIndex(m_state.getCompileThisIdx()).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR); } } //else select not ready, so neither are we!! return rtnb; } //resolveType
bool NodeTypeDescriptorSelect::resolveType(UTI& rtnuti) { bool rtnb = false; if(isReadyType()) { rtnuti = getNodeType(); return true; } // we are in a "chain" of type selects.. assert(m_nodeSelect); UTI seluti = m_nodeSelect->checkAndLabelType(); if(m_nodeSelect->isReadyType()) { UlamType * selut = m_state.getUlamTypeByIndex(seluti); ULAMTYPE seletyp = selut->getUlamTypeEnum(); if(seletyp == Class) { SymbolClass * csym = NULL; AssertBool isDefined = m_state.alreadyDefinedSymbolClass(seluti, csym); assert(isDefined); m_state.pushClassContext(seluti, csym->getClassBlockNode(), csym->getClassBlockNode(), false, NULL); // find our id in the "selected" class, must be a typedef at top level Symbol * asymptr = NULL; bool hazyKin = false; if(m_state.alreadyDefinedSymbol(m_typeTok.m_dataindex, asymptr, hazyKin) && !hazyKin) { if(asymptr->isTypedef()) { UTI auti = asymptr->getUlamTypeIdx(); if(m_state.isComplete(auti)) { rtnuti = auti; //should be mapped already, if necessary rtnb = true; } else //t3862 { UTI mappedUTI; if(m_state.mappedIncompleteUTI(seluti, auti, mappedUTI)) { std::ostringstream msg; msg << "Substituting Mapped UTI" << mappedUTI << ", "; msg << m_state.getUlamTypeNameBriefByIndex(mappedUTI).c_str(); msg << " for incomplete descriptor type: '"; msg << m_state.getUlamTypeNameByIndex(auti).c_str(); msg << "' UTI" << auti << " while labeling class: "; msg << m_state.getUlamTypeNameBriefByIndex(seluti).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG); rtnuti = mappedUTI; rtnb = true; } else if(m_state.alreadyDefinedSymbolByAncestor(m_typeTok.m_dataindex, asymptr, hazyKin) && !hazyKin) { if(asymptr->isTypedef()) { rtnuti = asymptr->getUlamTypeIdx(); rtnb = true; } else { //error id is not a typedef std::ostringstream msg; msg << "Not a typedef <" << m_state.getTokenDataAsString(m_typeTok).c_str(); msg << "> in another class ancester, " ;; msg << m_state.getUlamTypeNameBriefByIndex(seluti).c_str(); msg <<" while compiling: "; msg << m_state.getUlamTypeNameBriefByIndex(m_state.getCompileThisIdx()).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WARN); rtnuti = Nav; //? } } else rtnuti = Hzy; if(rtnb) { if(m_state.hasUnknownTypeInThisClassResolver(auti)) { m_state.removeKnownTypeTokenFromThisClassResolver(auti); m_state.cleanupExistingHolder(auti, rtnuti); } else if(m_state.isHolder(rtnuti)) { rtnuti = Hzy; //not so fast!! rtnb = false; } } } //else // { // //incomplete, but not a holder!! yippee (alittle progress) // } } else { //error id is not a typedef std::ostringstream msg; msg << "Not a typedef <" << m_state.getTokenDataAsString(m_typeTok).c_str(); msg << "> in another class, " ;; msg << m_state.getUlamTypeNameBriefByIndex(seluti).c_str(); msg <<" while compiling: "; msg << m_state.getUlamTypeNameBriefByIndex(m_state.getCompileThisIdx()).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WARN); rtnuti = Nav; //? } } else { //error! id not found std::ostringstream msg; msg << "Undefined Typedef <" << m_state.getTokenDataAsString(m_typeTok).c_str(); msg << "> in another class, " ;; msg << m_state.getUlamTypeNameByIndex(seluti).c_str(); msg <<" while compiling: "; msg << m_state.getUlamTypeNameBriefByIndex(m_state.getCompileThisIdx()).c_str(); if(!hazyKin) { MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR); //new rtnuti = Nav; } else { MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG); rtnuti = Hzy; } } m_state.popClassContext(); //restore } else { //error has to be a class std::ostringstream msg; msg << "Type selected by <" << m_state.getTokenDataAsString(m_typeTok).c_str(); msg << "> is NOT another class, " ; msg << m_state.getUlamTypeNameBriefByIndex(seluti).c_str(); msg << ", rather a " << UlamType::getUlamTypeEnumAsString(seletyp) << " type,"; msg <<" while compiling: "; msg << m_state.getUlamTypeNameBriefByIndex(m_state.getCompileThisIdx()).c_str(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR); rtnuti = Nav; } } else rtnuti = Hzy; //else select not ready, so neither are we!! return rtnb; } //resolveType