| 131 | } |
| 132 | |
| 133 | MainWindow::debug_basic_status_t MainWindow::debugBasicPrgmLookup(bool allowSwitch, int *idx) { |
| 134 | if (m_basicClearCache) { |
| 135 | debugBasicClearCache(); |
| 136 | } |
| 137 | |
| 138 | char name[10]; |
| 139 | if (!debug_get_executing_basic_prgm(name)) { |
| 140 | debugBasicClearEdits(); |
| 141 | return DBG_BASIC_NO_EXECUTING_PRGM; |
| 142 | } |
| 143 | |
| 144 | // find the program in memory |
| 145 | const uint32_t begPC = mem_peek_long(DBG_BASIC_BEGPC); |
| 146 | const uint32_t endPC = mem_peek_long(DBG_BASIC_ENDPC); |
| 147 | if (endPC < begPC) { |
| 148 | return DBG_BASIC_NO_EXECUTING_PRGM; |
| 149 | } |
| 150 | |
| 151 | uint32_t prgmSize = endPC - begPC + 1; |
| 152 | const char *prgmBytesPtr = static_cast<const char *>(phys_mem_ptr(static_cast<uint32_t>(begPC), prgmSize)); |
| 153 | if (!prgmBytesPtr) { |
| 154 | return DBG_BASIC_NO_EXECUTING_PRGM; |
| 155 | } |
| 156 | |
| 157 | calc_var_type_t type = static_cast<calc_var_type_t>(name[0]); |
| 158 | QString var_name = QString(calc_var_name_to_utf8(reinterpret_cast<uint8_t*>(&name[1]), strlen(&name[1]), true)); |
| 159 | |
| 160 | int index = 0; |
| 161 | |
| 162 | if (type == CALC_VAR_TYPE_TEMP_PROG || |
| 163 | type == CALC_VAR_TYPE_EQU || |
| 164 | name[1] == '$') { |
| 165 | |
| 166 | if (!m_basicShowTempParser) { |
| 167 | return DBG_BASIC_NO_EXECUTING_PRGM; |
| 168 | } |
| 169 | } else if (name[1] == '\0') { |
| 170 | // empty name happens during Input for some reason |
| 171 | return DBG_BASIC_NO_EXECUTING_PRGM; |
| 172 | } else { |
| 173 | // lookup in map to see if we've already parsed this file |
| 174 | auto basicPrgmIter = m_basicPrgmsMap.constFind(var_name); |
| 175 | if (basicPrgmIter != m_basicPrgmsMap.constEnd()) { |
| 176 | index = *basicPrgmIter; |
| 177 | } else { |
| 178 | index = m_basicPrgmsOriginalBytes.count(); |
| 179 | m_basicPrgmsMap[var_name] = index; |
| 180 | m_basicPrgmsOriginalBytes.push_back(QByteArray()); |
| 181 | m_basicPrgmsOriginalCode.push_back(QString()); |
| 182 | //m_basicPrgmsFormattedCode.push_back(QString()); |
| 183 | m_basicPrgmsTokensMap.push_back(QList<token_highlight_t>()); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | debug_basic_status_t status = DBG_BASIC_NEED_REFRESH; |
| 188 | // check if the original program data matches |
| 189 | if (prgmSize == (uint32_t)m_basicPrgmsOriginalBytes[index].size() && |
| 190 | !memcmp(m_basicPrgmsOriginalBytes[index].constData(), prgmBytesPtr, prgmSize)) { |
nothing calls this directly
no test coverage detected