Skip to content

Commit

Permalink
support keyboard interrupt in fjm_run
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhea committed Dec 9, 2024
1 parent e754e0c commit bc02373
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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
5 changes: 4 additions & 1 deletion flipjump/utils/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ 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

0 comments on commit bc02373

Please sign in to comment.