Esempio n. 1
0
def setup_module(module, filename='mini.image'):
    space = objspace.ObjSpace()
    from spyvm.tool.analyseimage import image_dir
    module.mini_image = image_dir.join(filename)
    module.reader = open_miniimage(space)
    reader.initialize()
    module.image = squeakimage.SqueakImage()
    module.image.from_reader(space, reader)
    module.space = space
    module.interp = interpreter.Interpreter(space, image)
    return space, module.interp
def setup():
    from spyvm import objspace
    space = objspace.ObjSpace()
    image = create_testimage(space)
    interp = interpreter.Interpreter(space, image)
    w_selector = interp.perform(space.wrap_string("loopTest"), "asSymbol")
    w_object = model.W_SmallInteger(0)
    s_class = w_object.shadow_of_my_class(space)
    s_method = s_class.lookup(w_selector)
    s_frame = s_method.create_frame(space, w_object, [])
    return interp, s_frame
Esempio n. 3
0
def setup():
    space = objspace.ObjSpace()
    stream = squeakimage.Stream(filename=imagefile)
    image = squeakimage.ImageReader(space, stream).create_image()
    interp = interpreter.Interpreter(space, image)
    w_selector = interp.perform(space.wrap_string("loopTest"), "asSymbol")
    w_object = model.W_SmallInteger(0)
    s_class = w_object.class_shadow(space)
    w_method = s_class.lookup(w_selector)
    s_frame = w_method.create_frame(space, w_object)
    return interp, s_frame
Esempio n. 4
0
    def test_miniloop(self):

        from spyvm import objspace
        space = objspace.ObjSpace()

        image = create_testimage(space)
        interp = interpreter.Interpreter(space, image)
        w_selector = interp.perform(space.wrap_string('loopTest2'), "asSymbol")
        assert isinstance(w_selector, model.W_BytesObject)
        def interp_w():
            interp.perform(model.W_SmallInteger(1000), w_selector)

        self.meta_interp(interp_w, [], listcomp=True, listops=True, backendopt=True, inline=True)
Esempio n. 5
0
import py
import math
import socket
from spyvm import model, shadow
from spyvm.shadow import MethodNotFound
from spyvm import objspace, error, display
from rpython.rlib.rarithmetic import intmask, r_uint

mockclass = objspace.bootstrap_class

space = objspace.ObjSpace()
w_foo = space.wrap_string("foo")
w_bar = space.wrap_string("bar")


def joinbits(values, lengths):
    result = 0
    for each, length in reversed(zip(values, lengths)):
        result = result << length
        result += each
    return result


def test_new():
    w_mycls = mockclass(space, 0)
    w_myinstance = w_mycls.as_class_get_shadow(space).new()
    assert isinstance(w_myinstance, model.W_PointersObject)
    assert w_myinstance.getclass(space).is_same_object(w_mycls)
    assert w_myinstance.shadow_of_my_class(
        space) is w_mycls.as_class_get_shadow(space)
    if len(argv) < idx + 1:
        raise error.Exit("Missing argument after %s" % arg)
    return argv[idx], idx + 1
    
def get_int_parameter(argv, idx, arg):
    param, idx = get_parameter(argv, idx, arg)
    try:
        result = int(param)
    except ValueError, e:
        raise error.Exit("Non-int argument after %s" % arg)
    return result, idx
    
def print_error(str):
    os.write(2, str + os.linesep)
    
prebuilt_space = objspace.ObjSpace()

def safe_entry_point(argv):
    try:
        return entry_point(argv)
    except error.Exit, e:
        print_error("Exited: %s" % e.msg)
        return -1
    except error.SmalltalkException, e:
        print_error("Unhandled %s. Message: %s" % (e.exception_type, e.msg))
        return -1
    except BaseException, e:
        print_error("Exception: %s" % str(e))
        if not objectmodel.we_are_translated():
            import traceback
            traceback.print_exc()