Exemple #1
0
def SETUP_EXCEPT(ctx: _VSContext, instruction: dis.Instruction):
    """
    Sets a context up for an except.
    """
    # Update the exception pointer with the calculated offset.
    # This is where we will jump to if an error is encountered.
    ctx.exc_next_pointer = get_instruction_index_by_offset(ctx, instruction)

    return ctx
Exemple #2
0
def POP_EXCEPT(ctx: _VSContext, instruction: dis.Instruction):
    """
    Pops an except block.
    """
    # Here, we can make several assumptions:
    # 1) The exception has been handled.
    # 2) We can empty the exception state.
    # 3) The function can continue on as normal.

    # This means the exception state is cleared, handling_exception is removed, and it is safe to jump forward as
    # appropriate.
    ctx._exception_state = None
    ctx._handling_exception = False

    # Also, remove the exception pointer.
    # That way, it won't try to safely handle an exception that happens later on.
    ctx.exc_next_pointer = None

    return ctx