vm: support exceptions

Implement 3 new instructions: TRY,ENDTRY,ENDFINALLY.
1. TRY marks the start of the block where exceptions are catched.
    It has 2 arguments which are relative offsets of exception handler
    and the end of the whole try/catch construction.
2. ENDTRY denotes either end of try or catch block.
3. ENDFINALLY denotes end of finally block which is executed
    irregardless of whether an exception has occured.
This commit is contained in:
Evgenii Stratonikov 2020-07-22 12:05:46 +03:00
parent c0d7b9d234
commit 797324cb04
6 changed files with 415 additions and 139 deletions

View file

@ -68,9 +68,14 @@ const (
CALLA Opcode = 0x36
// Exceptions
ABORT Opcode = 0x37
ASSERT Opcode = 0x38
THROW Opcode = 0x3A
ABORT Opcode = 0x37
ASSERT Opcode = 0x38
THROW Opcode = 0x3A
TRY Opcode = 0x3B
TRYL Opcode = 0x3C // TRY_L
ENDTRY Opcode = 0x3D
ENDTRYL Opcode = 0x3E // ENDTRY_L
ENDFINALLY Opcode = 0x3F
RET Opcode = 0x40
SYSCALL Opcode = 0x41