コード例 #1
0
ファイル: control.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, argument_count):
    # argument_count does NOT include the receiver.
    # This means that for argument_count == 3 the stack looks like:
    #  3      2       1      Top
    #  Rcvr | Arg 0 | Arg1 | Arg 2
    #
    # Validate that we have a block on the stack and that it received
    # the proper number of arguments:
    w_block_ctx = s_frame.peek(argument_count)

    # XXX need to check this since VALUE is called on all sorts of objects.
    if not w_block_ctx.getclass(interp.space).is_same_object(
            interp.space.w_BlockContext):
        raise PrimitiveFailedError()

    w_block_ctx = assert_pointers(w_block_ctx)
    s_block_ctx = w_block_ctx.as_context_get_shadow(interp.space)

    exp_arg_cnt = s_block_ctx.expected_argument_count()
    if argument_count != exp_arg_cnt:  # exp_arg_cnt doesn't count self
        raise PrimitiveFailedError()

    # Initialize the block stack with the arguments that were
    # pushed.  Also pop the receiver.
    block_args = s_frame.pop_and_return_n(exp_arg_cnt)

    # Reset stack of blockcontext to []
    s_block_ctx.reset_stack()
    s_block_ctx.push_all(block_args)

    s_frame.pop()
    s_block_ctx.reset_pc()
    return s_block_ctx
コード例 #2
0
ファイル: control.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, w_rcvr):
    if not isinstance(w_rcvr, W_CompiledMethod):
        raise PrimitiveFailedError()
    w_class = w_rcvr.compiled_in()
    if w_class:
        w_class = assert_pointers(w_class)
        w_class.as_class_get_shadow(interp.space).flush_method_caches()
    return w_rcvr
コード例 #3
0
ファイル: storage.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, w_cls):
    w_cls = assert_pointers(w_cls)
    s_class = w_cls.as_class_get_shadow(interp.space)
    if s_class.isvariable():
        raise PrimitiveFailedError()
    try:
        return s_class.new()
    except MemoryError:
        raise PrimitiveFailedError
コード例 #4
0
ファイル: storage.py プロジェクト: HPI-SWA-Lab/RSqueak
def func(interp, s_frame, w_cls):
    w_cls = assert_pointers(w_cls)
    s_class = w_cls.as_class_get_shadow(interp.space)
    if s_class.isvariable():
        raise PrimitiveFailedError()
    try:
        return s_class.new()
    except MemoryError:
        raise PrimitiveFailedError
コード例 #5
0
ファイル: control.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, w_context, argcnt):
    # From B.B.: If receiver is a MethodContext, then it becomes
    # the new BlockContext's home context.  Otherwise, the home
    # context of the receiver is used for the new BlockContext.
    # Note that in our impl, MethodContext.w_home == self
    w_context = assert_pointers(w_context)
    s_method_context = w_context.as_context_get_shadow(interp.space).s_home()

    # The block bytecodes are stored inline: so we skip past the
    # bytecodes to invoke this primitive to get to them.
    initialip = s_frame.pc() + 2
    s_new_context = storage_contexts.ContextPartShadow.build_block_context(
            interp.space, s_method_context, argcnt, initialip)
    return s_new_context.w_self()
コード例 #6
0
ファイル: control.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, w_block_ctx, args_w):

    w_block_ctx = assert_pointers(w_block_ctx)
    s_block_ctx = w_block_ctx.as_context_get_shadow(interp.space)
    exp_arg_cnt = s_block_ctx.expected_argument_count()

    if len(args_w) != exp_arg_cnt:
        raise PrimitiveFailedError()

    # Push all the items from the array
    for i in range(exp_arg_cnt):
        s_block_ctx.push(args_w[i])

    # XXX Check original logic. Image does not test this anyway
    # because falls back to value + internal implementation
    s_block_ctx.reset_pc()
    return s_block_ctx
コード例 #7
0
ファイル: control.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, w_rcvr):
    w_rcvr = assert_pointers(w_rcvr)
    s_class = w_rcvr.as_class_get_shadow(interp.space)
    s_class.flush_method_caches()
    return w_rcvr
コード例 #8
0
ファイル: storage.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, w_frame, stackp):
    assert stackp >= 0, "trying to store a negative stackp in STORE_STACKP"
    w_frame = assert_pointers(w_frame)
    w_frame.store(interp.space, constants.CTXPART_STACKP_INDEX,
                  interp.space.wrap_int(stackp))
    return w_frame
コード例 #9
0
ファイル: storage.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, w_rcvr, n0, w_value):
    "Stores a value into a fixed field from the object, and fails otherwise"
    s_class = w_rcvr.class_shadow(interp.space)
    w_rcvr = assert_pointers(w_rcvr)
    n0 = assert_valid_inst_index(interp.space, n0, w_rcvr)
    return primitive_store(interp, s_frame, w_rcvr, n0, w_value)
コード例 #10
0
ファイル: storage.py プロジェクト: swipswaps/RSqueak
def func(interp, s_frame, w_rcvr, n0):
    "Fetches a fixed field from the object, and fails otherwise"
    s_class = w_rcvr.class_shadow(interp.space)
    w_cls = assert_pointers(w_rcvr)
    n0 = assert_valid_inst_index(interp.space, n0, w_rcvr)
    return primitive_fetch(interp, s_frame, w_rcvr, n0)
コード例 #11
0
ファイル: storage.py プロジェクト: HPI-SWA-Lab/RSqueak
def func(interp, s_frame, w_rcvr, n0):
    "Fetches a fixed field from the object, and fails otherwise"
    s_class = w_rcvr.class_shadow(interp.space)
    w_cls = assert_pointers(w_rcvr)
    n0 = assert_valid_inst_index(interp.space, n0, w_rcvr)
    return primitive_fetch(interp, s_frame, w_rcvr, n0)
コード例 #12
0
ファイル: storage.py プロジェクト: HPI-SWA-Lab/RSqueak
def func(interp, s_frame, w_frame, stackp):
    assert stackp >= 0, "trying to store a negative stackp in STORE_STACKP"
    w_frame = assert_pointers(w_frame)
    w_frame.store(interp.space, constants.CTXPART_STACKP_INDEX,
                  interp.space.wrap_int(stackp))
    return w_frame
コード例 #13
0
ファイル: storage.py プロジェクト: HPI-SWA-Lab/RSqueak
def func(interp, s_frame, w_rcvr, n0, w_value):
    "Stores a value into a fixed field from the object, and fails otherwise"
    s_class = w_rcvr.class_shadow(interp.space)
    w_rcvr = assert_pointers(w_rcvr)
    n0 = assert_valid_inst_index(interp.space, n0, w_rcvr)
    return primitive_store(interp, s_frame, w_rcvr, n0, w_value)