Exemple #1
0
def RETURN_VALUE(ctx: _VSContext, instruction: dis.Instruction):
    """
    Returns a value.

    This will set the state of the context.
    """
    ctx._result = ctx.pop()
    ctx.state = VSCtxState.FINISHED

    ctx._handling_exception = False

    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