예제 #1
0
def setup_module(module, filename='mini.image'):
    space = objspace.ObjSpace()
    module.mini_image = py.magic.autopath().dirpath().dirpath().join(filename)
    module.reader = open_miniimage(space)
    reader.initialize()
    module.image = squeakimage.SqueakImage()
    module.image.from_reader(space, get_reader())
    module.space = space
def tinyBenchmarks():
    from pypy.lang.smalltalk import objspace
    space = objspace.ObjSpace()
    image = create_squeakimage(space)
    interp = interpreter.Interpreter(space)

    w_object = model.W_SmallInteger(0)

    s_class = w_object.shadow_of_my_class(space)
    w_method = s_class.lookup("tinyBenchmarks")

    assert w_method
    w_frame = w_method.create_frame(space, w_object, [])
    interp.store_w_active_context(w_frame)

    counter = 0

    from pypy.lang.smalltalk.interpreter import BYTECODE_TABLE
    return interp
예제 #3
0
def tinyBenchmarks():
    from pypy.lang.smalltalk import objspace
    space = objspace.ObjSpace()
    image = create_squeakimage(space)
    interp = interpreter.Interpreter(space)

    w_object = model.W_SmallInteger(0)

    # Should get this from w_object
    w_smallint_class = image.special(constants.SO_SMALLINTEGER_CLASS)
    s_class = w_object.shadow_of_my_class(space)
    w_method = s_class.lookup("tinyBenchmarks")

    assert w_method
    w_frame = w_method.create_frame(space, w_object, [])
    interp.store_w_active_context(w_frame)

    counter = 0

    from pypy.lang.smalltalk.interpreter import BYTECODE_TABLE
    return interp
예제 #4
0
import py
from pypy.lang.smalltalk import model, interpreter, primitives, shadow
from pypy.lang.smalltalk import objspace

mockclass = objspace.bootstrap_class

space = objspace.ObjSpace()

# expose the bytecode's values as global constants.
# Bytecodes that have a whole range are exposed as global functions:
# call them with an argument 'n' to get the bytecode number 'base + n'.
# XXX hackish
def setup():
    def make_getter(entry):
        def get_opcode_chr(n):
            opcode = entry[0] + n
            assert entry[0] <= opcode <= entry[1]
            return chr(opcode)
        return get_opcode_chr
    for entry in interpreter.BYTECODE_RANGES:
        name = entry[-1].__name__
        if len(entry) == 2:     # no range
            globals()[name] = chr(entry[0])
        else:
            globals()[name] = make_getter(entry)
setup()

def run_with_faked_methods(methods, func):

    # Install faked compiled methods that just invoke the primitive:
    for (w_class, primnum, argsize, methname) in methods: