Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support keyboard interrupt in fjm_run #279

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions flipjump/interpretter/fjm_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def run(
return TerminationStatistics(statistics, TerminationCause.RuntimeMemoryError)
except FlipJumpException as fj_exception:
raise fj_exception
except KeyboardInterrupt:
return TerminationStatistics(statistics, TerminationCause.KeyboardInterrupt)
except Exception as unknown_exception:
raise FlipJumpRuntimeException(
"Unknown exception during running an .fjm file, please report this bug"
Expand Down
12 changes: 11 additions & 1 deletion flipjump/utils/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ class TerminationCause(IntEnum):
UnalignedOp = 4
# Finished by trying to read/write something out of the defined memory (probably a bug in the fj-program)
RuntimeMemoryError = 5
# Finished by keyboard interrupt from the user
KeyboardInterrupt = 6

def __str__(self) -> str:
return ['looping', 'EOF', 'ip<2w', 'unaligned-word', 'unaligned-op', 'runtime-memory-error'][self.value]
return [
'looping',
'EOF',
'ip<2w',
'unaligned-word',
'unaligned-op',
'runtime-memory-error',
"keyboard-interrupt",
][self.value]


class PrintTimer:
Expand Down
Loading