Skip to content

Commit

Permalink
Merge pull request #279 from tomhea/hotfix/small-improvements
Browse files Browse the repository at this point in the history
support keyboard interrupt in fjm_run
  • Loading branch information
tomhea authored Dec 9, 2024
2 parents 5750fa0 + 112ad4b commit 7cc021a
Show file tree
Hide file tree
Showing 2 changed files with 13 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
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

0 comments on commit 7cc021a

Please sign in to comment.