예제 #1
0
파일: pyframe.py 프로젝트: Debug-Orz/Sypy
 def __init__(self, space, code, w_globals, outer_func):
     if not we_are_translated():
         assert type(self) in (space.FrameClass, CPythonFrame), (
             "use space.FrameClass(), not directly PyFrame()")
     self = hint(self, access_directly=True, fresh_virtualizable=True)
     assert isinstance(code, pycode.PyCode)
     self.pycode = code
     eval.Frame.__init__(self, space, w_globals)
     self.locals_stack_w = [None] * (code.co_nlocals + code.co_stacksize)
     
     # Symbolic stack, globals tracker and constraint stack
     self.locals_stack_w_s = [None] * (code.co_nlocals + code.co_stacksize)
     self.w_globals_s = w_globals
     
     self.valuestackdepth = code.co_nlocals
     self.lastblock = None
     make_sure_not_resized(self.locals_stack_w)
     check_nonneg(self.valuestackdepth)
     #
     if space.config.objspace.honor__builtins__:
         self.builtin = space.builtin.pick_builtin(w_globals)
     # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
     # class bodies only have CO_NEWLOCALS.
     self.initialize_frame_scopes(outer_func, code)
     self.f_lineno = code.co_firstlineno
예제 #2
0
파일: codebuf.py 프로젝트: alkorzt/pypy
 def overwrite(self, pos, listofchars):
     make_sure_not_resized(listofchars)
     assert pos + len(listofchars) <= self._size
     for c in listofchars:
         self._data[pos] = c
         pos += 1
     return pos
예제 #3
0
파일: ri386.py 프로젝트: alkorzt/pypy
def packimm32(i):
    lst = [chr(i & 0xFF),
           chr((i >> 8) & 0xFF),
           chr((i >> 16) & 0xFF),
           chr((i >> 24) & 0xFF)]
    make_sure_not_resized(lst)
    return lst
예제 #4
0
파일: pyframe.py 프로젝트: enyst/plexnet
 def pushrevvalues(self, n, values_w): # n should be len(values_w)
     make_sure_not_resized(values_w)
     while True:
         n -= 1
         if n < 0:
             break
         self.pushvalue(values_w[n])
예제 #5
0
파일: codebuf.py 프로젝트: xx312022850/pypy
 def overwrite(self, pos, listofchars):
     make_sure_not_resized(listofchars)
     assert pos + len(listofchars) <= self._size
     for c in listofchars:
         self._data[pos] = c
         pos += 1
     return pos
예제 #6
0
파일: pyframe.py 프로젝트: purepython/pypy
 def pushrevvalues(self, n, values_w):  # n should be len(values_w)
     make_sure_not_resized(values_w)
     while True:
         n -= 1
         if n < 0:
             break
         self.pushvalue(values_w[n])
예제 #7
0
    def __init__(self, space, code, w_globals, outer_func):
        if not we_are_translated():
            assert type(self) in (space.FrameClass, CPythonFrame), (
                "use space.FrameClass(), not directly PyFrame()")
        self = hint(self, access_directly=True, fresh_virtualizable=True)
        assert isinstance(code, pycode.PyCode)
        self.pycode = code
        eval.Frame.__init__(self, space, w_globals)
        self.locals_stack_w = [None] * (code.co_nlocals + code.co_stacksize)

        # Symbolic stack, globals tracker and constraint stack
        self.locals_stack_w_s = [None] * (code.co_nlocals + code.co_stacksize)
        self.w_globals_s = w_globals

        self.valuestackdepth = code.co_nlocals
        self.lastblock = None
        make_sure_not_resized(self.locals_stack_w)
        check_nonneg(self.valuestackdepth)
        #
        if space.config.objspace.honor__builtins__:
            self.builtin = space.builtin.pick_builtin(w_globals)
        # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
        # class bodies only have CO_NEWLOCALS.
        self.initialize_frame_scopes(outer_func, code)
        self.f_lineno = code.co_firstlineno
예제 #8
0
 def __init__(self, opnum, args, result, descr=None):
     make_sure_not_resized(args)
     assert isinstance(opnum, int)
     self.opnum = opnum
     self.args = list(args)
     make_sure_not_resized(self.args)
     assert not isinstance(result, list)
     self.result = result
     self.setdescr(descr)
예제 #9
0
 def __init__(self, space, dim, dtype):
     self.dim = dim
     self.space = space
     # ignore dtype for now
     size = 1
     for el in dim:
         size *= el
     self.storage = [0] * size
     make_sure_not_resized(self.storage)
예제 #10
0
def packimm32(i):
    lst = [
        chr(i & 0xFF),
        chr((i >> 8) & 0xFF),
        chr((i >> 16) & 0xFF),
        chr((i >> 24) & 0xFF)
    ]
    make_sure_not_resized(lst)
    return lst
예제 #11
0
파일: numarray.py 프로젝트: enyst/plexnet
 def __init__(self, space, dim, dtype):
     self.dim = dim
     self.space = space
     # ignore dtype for now
     size = 1
     for el in dim:
         size *= el
     self.storage = [0] * size
     make_sure_not_resized(self.storage)
예제 #12
0
 def __init__(self, space, args_w, kwds_w=None,
              w_stararg=None, w_starstararg=None):
     self.space = space
     assert isinstance(args_w, list)
     self.arguments_w = args_w
     from pypy.rlib.debug import make_sure_not_resized
     make_sure_not_resized(self.arguments_w)
     self.kwds_w = kwds_w
     self.w_stararg = w_stararg
     self.w_starstararg = w_starstararg
예제 #13
0
파일: util.py 프로젝트: njues/Sypy
def args_hash(args):
    make_sure_not_resized(args)
    res = 0x345678
    for arg in args:
        if arg is None:
            y = 17
        else:
            y = arg._get_hash_()
        res = intmask((1000003 * res) ^ y)
    return res
예제 #14
0
def args_hash(args):
    make_sure_not_resized(args)
    res = 0x345678
    for arg in args:
        if arg is None:
            y = 17
        else:
            y = arg._get_hash_()
        res = intmask((1000003 * res) ^ y)
    return res
예제 #15
0
파일: function.py 프로젝트: enyst/plexnet
 def __init__(self, space, code, w_globals=None, defs_w=[], closure=None, forcename=None):
     self.space = space
     self.name = forcename or code.co_name
     self.w_doc = None   # lazily read from code.getdocstring()
     self.code = code       # Code instance
     self.w_func_globals = w_globals  # the globals dictionary
     self.closure   = closure    # normally, list of Cell instances or None
     self.defs_w    = defs_w     # list of w_default's
     make_sure_not_resized(self.defs_w)
     self.w_func_dict = None # filled out below if needed
     self.w_module = None
예제 #16
0
파일: util.py 프로젝트: gorakhargosh/pypy
def args_hash(args):
    make_sure_not_resized(args)
    res = 0x345678
    for arg in args:
        if arg is None:
            y = 17
        elif isinstance(arg, history.Const):
            y = arg._get_hash_()
        else:
            y = compute_identity_hash(arg)
        res = intmask((1000003 * res) ^ y)
    return res
예제 #17
0
 def __init__(self, space, code, w_globals=None, defs_w=[], closure=None,
              forcename=None):
     self.space = space
     self.name = forcename or code.co_name
     self.w_doc = None   # lazily read from code.getdocstring()
     self.code = code       # Code instance
     self.w_func_globals = w_globals  # the globals dictionary
     self.closure   = closure    # normally, list of Cell instances or None
     self.defs_w    = defs_w     # list of w_default's
     make_sure_not_resized(self.defs_w)
     self.w_func_dict = None # filled out below if needed
     self.w_module = None
예제 #18
0
파일: util.py 프로젝트: njues/Sypy
def args_eq(args1, args2):
    make_sure_not_resized(args1)
    make_sure_not_resized(args2)
    if len(args1) != len(args2):
        return False
    for i in range(len(args1)):
        arg1 = args1[i]
        arg2 = args2[i]
        if arg1 is None:
            if arg2 is not None:
                return False
        elif not arg1.same_box(arg2):
            return False
    return True
예제 #19
0
def args_eq(args1, args2):
    make_sure_not_resized(args1)
    make_sure_not_resized(args2)
    if len(args1) != len(args2):
        return False
    for i in range(len(args1)):
        arg1 = args1[i]
        arg2 = args2[i]
        if arg1 is None:
            if arg2 is not None:
                return False
        elif not arg1.same_box(arg2):
            return False
    return True
예제 #20
0
파일: pyframe.py 프로젝트: alkorzt/pypy
 def __init__(self, space, code, w_globals, closure):
     self = hint(self, access_directly=True, fresh_virtualizable=True)
     assert isinstance(code, pycode.PyCode)
     self.pycode = code
     eval.Frame.__init__(self, space, w_globals, code.co_nlocals)
     self.valuestack_w = [None] * code.co_stacksize
     self.valuestackdepth = 0
     self.lastblock = None
     if space.config.objspace.honor__builtins__:
         self.builtin = space.builtin.pick_builtin(w_globals)
     # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
     # class bodies only have CO_NEWLOCALS.
     self.initialize_frame_scopes(closure, code)
     self.fastlocals_w = [None] * self.numlocals
     make_sure_not_resized(self.fastlocals_w)
     self.f_lineno = code.co_firstlineno
예제 #21
0
파일: pyframe.py 프로젝트: xx312022850/pypy
 def __init__(self, space, code, w_globals, closure):
     self = hint(self, access_directly=True, fresh_virtualizable=True)
     assert isinstance(code, pycode.PyCode)
     self.pycode = code
     eval.Frame.__init__(self, space, w_globals, code.co_nlocals)
     self.valuestack_w = [None] * code.co_stacksize
     self.valuestackdepth = 0
     self.lastblock = None
     if space.config.objspace.honor__builtins__:
         self.builtin = space.builtin.pick_builtin(w_globals)
     # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
     # class bodies only have CO_NEWLOCALS.
     self.initialize_frame_scopes(closure, code)
     self.fastlocals_w = [None] * self.numlocals
     make_sure_not_resized(self.fastlocals_w)
     self.f_lineno = code.co_firstlineno
예제 #22
0
파일: VM.py 프로젝트: cfbolz/converge
    def __init__(self, parent, func, pc, max_stack_size, nargs, bc_off, closure):
        self = jit.hint(self, access_directly=True, fresh_virtualizable=True)
        self.parent = parent
        self.stack = [None] * max_stack_size
        debug.make_sure_not_resized(self.stack)
        self.func = func
        self.pc = pc
        self.nargs = nargs # Number of arguments passed to this continuation
        self.bc_off = bc_off # -1 for Py modules
        self.closure = closure
        self.returned = False

        # stackpe always points to the element *after* the end of the stack (this makes a lot of
        # stack-based operations quicker)
        self.stackpe = 0
        # ffp, gfp, and xfp all point *to* the frame they refer to
        self.ffp = self.gfp = self.xfp = -1
예제 #23
0
 def fixedview(self, w_obj, expected_length=-1, unroll=False):
     """ Fast paths
     """
     if isinstance(w_obj, W_TupleObject):
         t = w_obj.wrappeditems
     elif isinstance(w_obj, W_ListObject):
         t = w_obj.wrappeditems[:]
     else:
         if unroll:
             return make_sure_not_resized(ObjSpace.unpackiterable_unroll(
                 self, w_obj, expected_length)[:])
         else:
             return make_sure_not_resized(ObjSpace.unpackiterable(
                 self, w_obj, expected_length)[:])
     if expected_length != -1 and len(t) != expected_length:
         raise self._wrap_expected_length(expected_length, len(t))
     return make_sure_not_resized(t)
예제 #24
0
파일: util.py 프로젝트: gorakhargosh/pypy
def args_eq(args1, args2):
    make_sure_not_resized(args1)
    make_sure_not_resized(args2)
    if len(args1) != len(args2):
        return False
    for i in range(len(args1)):
        arg1 = args1[i]
        arg2 = args2[i]
        if isinstance(arg1, history.Const):
            if arg1.__class__ is not arg2.__class__:
                return False
            if not arg1.same_constant(arg2):
                return False
        else:
            if not arg1 is arg2:
                return False
    return True
예제 #25
0
파일: objspace.py 프로젝트: Debug-Orz/Sypy
 def fixedview(self, w_obj, expected_length=-1, unroll=False):
     """ Fast paths
     """
     if isinstance(w_obj, W_AbstractTupleObject):
         t = w_obj.tolist()
     elif type(w_obj) is W_ListObject:
         if unroll:
             t = w_obj.getitems_unroll()
         else:
             t = w_obj.getitems_fixedsize()
     else:
         if unroll:
             return make_sure_not_resized(ObjSpace.unpackiterable_unroll(
                 self, w_obj, expected_length))
         else:
             return make_sure_not_resized(ObjSpace.unpackiterable(
                 self, w_obj, expected_length)[:])
     if expected_length != -1 and len(t) != expected_length:
         raise self._wrap_expected_length(expected_length, len(t))
     return make_sure_not_resized(t)
예제 #26
0
파일: objspace.py 프로젝트: purepython/pypy
 def fixedview(self, w_obj, expected_length=-1, unroll=False):
     """ Fast paths
     """
     if isinstance(w_obj, W_AbstractTupleObject):
         t = w_obj.tolist()
     elif isinstance(w_obj, W_ListObject):
         if unroll:
             t = w_obj.getitems_unroll()
         else:
             t = w_obj.getitems_fixedsize()
     else:
         if unroll:
             return make_sure_not_resized(ObjSpace.unpackiterable_unroll(
                 self, w_obj, expected_length))
         else:
             return make_sure_not_resized(ObjSpace.unpackiterable(
                 self, w_obj, expected_length)[:])
     if expected_length != -1 and len(t) != expected_length:
         raise self._wrap_expected_length(expected_length, len(t))
     return make_sure_not_resized(t)
예제 #27
0
    def __init__(self,
                 space,
                 args_w,
                 keywords=None,
                 keywords_w=None,
                 w_stararg=None,
                 w_starstararg=None,
                 keyword_names_w=None):
        self.space = space
        assert isinstance(args_w, list)
        self.arguments_w = args_w
        self.keywords = keywords
        self.keywords_w = keywords_w
        self.keyword_names_w = keyword_names_w  # matches the tail of .keywords
        if keywords is not None:
            assert keywords_w is not None
            assert len(keywords_w) == len(keywords)
            assert (keyword_names_w is None
                    or len(keyword_names_w) <= len(keywords))
            make_sure_not_resized(self.keywords)
            make_sure_not_resized(self.keywords_w)

        make_sure_not_resized(self.arguments_w)
        if w_stararg is not None:
            self._combine_starargs_wrapped(w_stararg)
        # if we have a call where **args are used at the callsite
        # we shouldn't let the JIT see the argument matching
        self._dont_jit = (w_starstararg is not None and
                          self._combine_starstarargs_wrapped(w_starstararg))
예제 #28
0
파일: argument.py 프로젝트: enyst/plexnet
    def __init__(self, space, args_w, keywords=None, keywords_w=None,
                 w_stararg=None, w_starstararg=None):
        self.space = space
        assert isinstance(args_w, list)
        self.arguments_w = args_w
        self.keywords = keywords
        self.keywords_w = keywords_w
        if keywords is not None:
            assert keywords_w is not None
            assert len(keywords_w) == len(keywords)
            make_sure_not_resized(self.keywords)
            make_sure_not_resized(self.keywords_w)

        make_sure_not_resized(self.arguments_w)
        if w_stararg is not None or w_starstararg is not None:
            self._combine_wrapped(w_stararg, w_starstararg)
예제 #29
0
    def __init__(self,
                 space,
                 args_w,
                 keywords=None,
                 keywords_w=None,
                 w_stararg=None,
                 w_starstararg=None):
        self.space = space
        assert isinstance(args_w, list)
        self.arguments_w = args_w
        self.keywords = keywords
        self.keywords_w = keywords_w
        if keywords is not None:
            assert keywords_w is not None
            assert len(keywords_w) == len(keywords)
            make_sure_not_resized(self.keywords)
            make_sure_not_resized(self.keywords_w)

        make_sure_not_resized(self.arguments_w)
        if w_stararg is not None or w_starstararg is not None:
            self._combine_wrapped(w_stararg, w_starstararg)
예제 #30
0
파일: argument.py 프로젝트: alkorzt/pypy
    def __init__(self, space, args_w, keywords=None, keywords_w=None,
                 w_stararg=None, w_starstararg=None):
        self.space = space
        assert isinstance(args_w, list)
        self.arguments_w = args_w
        self.keywords = keywords
        self.keywords_w = keywords_w
        if keywords is not None:
            assert keywords_w is not None
            assert len(keywords_w) == len(keywords)
            make_sure_not_resized(self.keywords)
            make_sure_not_resized(self.keywords_w)

        make_sure_not_resized(self.arguments_w)
        if w_stararg is not None or w_starstararg is not None:
            self._combine_wrapped(w_stararg, w_starstararg)
            # if we have a call where * or ** args are used at the callsite
            # we shouldn't let the JIT see the argument matching
            self._dont_jit = True
        else:
            self._dont_jit = False
예제 #31
0
 def __init__(self, space, w_name, bases, w_dict):
     self.name = space.str_w(w_name)
     make_sure_not_resized(bases)
     self.bases_w = bases
     self.w_dict = w_dict
예제 #32
0
 def _init_empty(self, map):
     from pypy.rlib.debug import make_sure_not_resized
     self.map = map
     self.storage = make_sure_not_resized([None] * map.size_estimate())
예제 #33
0
 def __init__(self, space, w_name, bases, w_dict):
     self.name = space.str_w(w_name)
     make_sure_not_resized(bases)
     self.bases_w = bases
     self.w_dict = w_dict
예제 #34
0
 def getitems_unroll(self):
     """Returns a fixed-size list of all items after wrapping them. The JIT
     will fully unroll this function.  """
     l = self.strategy.getitems_unroll(self)
     debug.make_sure_not_resized(l)
     return l
예제 #35
0
파일: ri386.py 프로젝트: alkorzt/pypy
 def __init__(self, byte, extradata):
     self.byte = byte
     self.extradata = extradata
     make_sure_not_resized(extradata)
예제 #36
0
 def __init__(self, space, containing_scope, functions):
     self.space = space
     self.scope = containing_scope
     self.functions = debug.make_sure_not_resized(functions)
예제 #37
0
 def getitems_fixedsize(self):
     """Returns a fixed-size list of all items after wrapping them."""
     l = self.strategy.getitems_fixedsize(self)
     debug.make_sure_not_resized(l)
     return l
예제 #38
0
def packimm8(i):
    if i < 0:
        i += 256
    lst = [chr(i)]
    make_sure_not_resized(lst)
    return lst
예제 #39
0
파일: tupleobject.py 프로젝트: ieure/pypy
 def __init__(w_self, wrappeditems):
     make_sure_not_resized(wrappeditems)
     w_self.wrappeditems = wrappeditems   # a list of wrapped values
예제 #40
0
 def __init__(self, byte, extradata):
     self.byte = byte
     self.extradata = extradata
     make_sure_not_resized(extradata)
예제 #41
0
 def __init__(w_self, wrappeditems):
     make_sure_not_resized(wrappeditems)
     w_self.wrappeditems = wrappeditems  # a list of wrapped values
예제 #42
0
파일: ri386.py 프로젝트: alkorzt/pypy
def packimm8(i):
    if i < 0:
        i += 256
    lst = [chr(i)]
    make_sure_not_resized(lst)
    return lst
예제 #43
0
 def newtuple(self, list_w):
     from pypy.objspace.std.tupletype import wraptuple
     assert isinstance(list_w, list)
     make_sure_not_resized(list_w)
     return wraptuple(self, list_w)
예제 #44
0
 def getitems_unroll(self):
     """Returns a fixed-size list of all items after wrapping them. The JIT
     will fully unroll this function.  """
     l = self.strategy.getitems_unroll(self)
     debug.make_sure_not_resized(l)
     return l
예제 #45
0
 def getitems_fixedsize(self):
     """Returns a fixed-size list of all items after wrapping them."""
     l = self.strategy.getitems_fixedsize(self)
     debug.make_sure_not_resized(l)
     return l
예제 #46
0
 def f():
     result = [1,2,3]
     make_sure_not_resized(result)
     result.append(4)
     return len(result)
예제 #47
0
 def __init__(self, space, dim, dtype):
     self.dim = dim
     self.space = space
     # ignore dtype for now
     self.storage = [0] * dim
     make_sure_not_resized(self.storage)
예제 #48
0
파일: numarray.py 프로젝트: enyst/plexnet
 def __init__(self, space, dim, dtype):
     self.dim = dim
     self.space = space
     # ignore dtype for now
     self.storage = [0] * dim
     make_sure_not_resized(self.storage)
예제 #49
0
파일: rbigint.py 프로젝트: xx312022850/pypy
 def __init__(self, digits=None, sign=0):
     if digits is None or len(digits) == 0:
         digits = [0]
     make_sure_not_resized(digits)
     self.digits = digits
     self.sign = sign
예제 #50
0
파일: mapdict.py 프로젝트: Debug-Orz/Sypy
 def _init_empty(self, map):
     from pypy.rlib.debug import make_sure_not_resized
     self.map = map
     self.storage = make_sure_not_resized([None] * map.size_estimate())
예제 #51
0
 def newtuple(self, list_w):
     from pypy.objspace.std.tupletype import wraptuple
     assert isinstance(list_w, list)
     make_sure_not_resized(list_w)
     return wraptuple(self, list_w)
예제 #52
0
 def f():
     result = [1, 2, 3]
     make_sure_not_resized(result)
     result.append(4)
     return len(result)
예제 #53
0
 def viewiterable(self, w_iterable, expected_length=-1):
     """ More or less the same as unpackiterable, but does not return
     a copy. Please don't modify the result
     """
     return make_sure_not_resized(
         self.unpackiterable(w_iterable, expected_length)[:])