Skip to content

Commit

Permalink
Fixed RishkaVM::panic() functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed May 13, 2024
1 parent 92dfd74 commit abc0e1e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/rishka_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ bool RishkaVM::isRunning() {
return this->running;
}

void RishkaVM::panic(const char* message) {
this->terminal->print("\r\n");
this->terminal->print(message);
this->terminal->print("\r\n");

this->stopVM();
this->reset();
}

void RishkaVM::reset() {
this->running = false;
this->argv = NULL;
Expand Down
10 changes: 10 additions & 0 deletions src/rishka_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ class RishkaVM final {
*/
bool isRunning();

/**
* @brief Handle a panic situation in the virtual machine.
*
* This function is called to handle a panic situation in the Rishka virtual machine.
* It prints the panic message and performs any necessary cleanup before terminating the program.
*
* @param message The panic message to print.
*/
void panic(const char* message);

/**
* @brief Sets the working directory for the virtual machine.
*
Expand Down

0 comments on commit abc0e1e

Please sign in to comment.