feat: добавлено выбрасывание исключений в некоторые места
так странно написано потому что я уверен, что будут еще другие исключительные случаи и корнеркейсы, которые я забыл
This commit is contained in:
10
src/vm.py
10
src/vm.py
@ -119,6 +119,11 @@ class VM:
|
|||||||
"""
|
"""
|
||||||
Make one step (only step into)
|
Make one step (only step into)
|
||||||
"""
|
"""
|
||||||
|
if self.pc.value * 4 > len(self.mem) - 4:
|
||||||
|
raise VMException(
|
||||||
|
VMExceptionType.END_OF_MEM,
|
||||||
|
self.pc.value
|
||||||
|
)
|
||||||
opcode = self.mem[self.pc.value * 4]
|
opcode = self.mem[self.pc.value * 4]
|
||||||
opdesc = self._fetch_opcode_desc(opcode)
|
opdesc = self._fetch_opcode_desc(opcode)
|
||||||
args = self._parse_arguments(opdesc)
|
args = self._parse_arguments(opdesc)
|
||||||
@ -148,6 +153,11 @@ class VM:
|
|||||||
self.continue_()
|
self.continue_()
|
||||||
|
|
||||||
def _fetch_opcode_desc(self, opcode: int):
|
def _fetch_opcode_desc(self, opcode: int):
|
||||||
|
if not opcode in OPCODES:
|
||||||
|
raise VMException(
|
||||||
|
VMExceptionType.INVALID_OPCODE,
|
||||||
|
self.pc.value
|
||||||
|
)
|
||||||
return OPCODES[opcode]
|
return OPCODES[opcode]
|
||||||
|
|
||||||
def _parse_arguments(self, opdesc: OpcodeDescription) -> tuple[int, ...]:
|
def _parse_arguments(self, opdesc: OpcodeDescription) -> tuple[int, ...]:
|
||||||
|
|||||||
Reference in New Issue
Block a user