checkpoint

This commit is contained in:
aljazbrodar. 2025-12-10 17:57:28 +01:00
parent 12421d0e5d
commit 1d357c6c96
48 changed files with 1580 additions and 219 deletions

View file

@ -10,22 +10,66 @@ Executor::Executor(Machine* m) {
}
void Executor::start() {
if (ended) {
emit signalEnded();
return;
}
running = true;
while (running) {
emit signalStarted();
while (running && !ended) {
int pc_before = machine->getPC();
machine->execute();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
int pc_after = machine->getPC();
emit updateRequested(); // signal za posodobitev UI
if (pc_before == pc_after) {
ended = true;
emit signalEnded();
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
void Executor::stop() {
running = false;
emit signalStopped();
emit updateRequested();
}
bool Executor::isRunning() {
return running;
}
void Executor::step() {
machine->execute();
bool Executor::hasEnded() {
return ended;
}
void Executor::resetProgram() {
ended = false;
running = false;
emit signalStopped();
}
void Executor::step() {
if (ended) {
emit signalEnded();
return;
}
emit signalStarted();
int pc_before = machine->getPC();
// Izvedi en ukaz
machine->execute();
int pc_after = machine->getPC();
emit updateRequested();
std::this_thread::sleep_for(std::chrono::milliseconds(50));
emit signalStopped();
std::this_thread::sleep_for(std::chrono::milliseconds(50));
// Če PC ostane isti → neskončna zanka → HALT
if (pc_after == pc_before) {
ended = true;
emit signalEnded();
}
}