| 107 | } |
| 108 | |
| 109 | void DisassemblyView::contextPasteInstructionText() |
| 110 | { |
| 111 | if (!cpu().isCpuPaused()) |
| 112 | { |
| 113 | AsyncDialogs::warning(this, tr("Assemble Error"), tr("Unable to change assembly while core is running")); |
| 114 | return; |
| 115 | } |
| 116 | |
| 117 | // split text in clipboard by new lines |
| 118 | QString clipboardText = QApplication::clipboard()->text(); |
| 119 | std::vector<std::string> newInstructions = StringUtil::splitOnNewLine(clipboardText.toLocal8Bit().constData()); |
| 120 | u32 newInstructionsSize = static_cast<u32>(newInstructions.size()); |
| 121 | |
| 122 | // validate new instructions before pasting them |
| 123 | std::vector<u32> encodedInstructions; |
| 124 | for (u32 instructionIdx = 0; instructionIdx < newInstructionsSize; instructionIdx++) |
| 125 | { |
| 126 | u32 replaceAddress = m_selectedAddressStart + instructionIdx * 4; |
| 127 | u32 encodedInstruction; |
| 128 | std::string errorText; |
| 129 | bool valid = MipsAssembleOpcode(newInstructions[instructionIdx].c_str(), &cpu(), replaceAddress, encodedInstruction, errorText); |
| 130 | if (!valid) |
| 131 | { |
| 132 | AsyncDialogs::warning(this, tr("Assemble Error"), QString("%1 %2").arg(errorText.c_str()).arg(newInstructions[instructionIdx].c_str())); |
| 133 | return; |
| 134 | } |
| 135 | encodedInstructions.push_back(encodedInstruction); |
| 136 | } |
| 137 | |
| 138 | // paste validated instructions |
| 139 | for (u32 instructionIdx = 0; instructionIdx < newInstructionsSize; instructionIdx++) |
| 140 | { |
| 141 | u32 replaceAddress = m_selectedAddressStart + instructionIdx * 4; |
| 142 | setInstructions(replaceAddress, replaceAddress, encodedInstructions[instructionIdx]); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | void DisassemblyView::contextAssembleInstruction() |
| 147 | { |
nothing calls this directly
no test coverage detected