예제 #1
0
파일: unaryop.py 프로젝트: yuyichao/pypy
 def method_join(self, s_list):
     if s_None.contains(s_list):
         return SomeImpossibleValue()
     s_item = s_list.listdef.read_item()
     if s_None.contains(s_item):
         if isinstance(self, SomeUnicodeString):
             return immutablevalue(u"")
         return immutablevalue("")
     no_nul = self.no_nul and s_item.no_nul
     return self.basestringclass(no_nul=no_nul)
예제 #2
0
 def method_join(self, s_list):
     if s_None.contains(s_list):
         return SomeImpossibleValue()
     s_item = s_list.listdef.read_item()
     if s_None.contains(s_item):
         if isinstance(self, SomeUnicodeString):
             return immutablevalue(u"")
         return immutablevalue("")
     no_nul = self.no_nul and s_item.no_nul
     return self.basestringclass(no_nul=no_nul)
예제 #3
0
파일: unaryop.py 프로젝트: charred/pypy
 def method_join(str, s_list):
     if s_None.contains(s_list):
         return SomeImpossibleValue()
     getbookkeeper().count("str_join", str)
     s_item = s_list.listdef.read_item()
     if s_None.contains(s_item):
         if isinstance(str, SomeUnicodeString):
             return immutablevalue(u"")
         return immutablevalue("")
     no_nul = str.no_nul and s_item.no_nul
     return str.basestringclass(no_nul=no_nul)
예제 #4
0
    def _init_classdef(self):
        classdef = ClassDef(self.bookkeeper, self)
        self.bookkeeper.classdefs.append(classdef)
        self.classdef = classdef

        # forced attributes
        cls = self.pyobj
        if cls in FORCE_ATTRIBUTES_INTO_CLASSES:
            for name, s_value in FORCE_ATTRIBUTES_INTO_CLASSES[cls].items():
                classdef.generalize_attr(name, s_value)
                classdef.find_attribute(name).modified(classdef)

        # register all class attributes as coming from this ClassDesc
        # (as opposed to prebuilt instances)
        classsources = {}
        for attr in self.classdict:
            classsources[attr] = self    # comes from this ClassDesc
        classdef.setup(classsources)
        # look for a __del__ method and annotate it if it's there
        if '__del__' in self.classdict:
            from rpython.annotator.model import s_None, SomeInstance
            s_func = self.s_read_attribute('__del__')
            args_s = [SomeInstance(classdef)]
            s = self.bookkeeper.emulate_pbc_call(classdef, s_func, args_s)
            assert s_None.contains(s)
        return classdef
예제 #5
0
    def getclassdef(self, key):
        try:
            return self._classdefs[key]
        except KeyError:
            from rpython.annotator.classdef import (
                ClassDef, FORCE_ATTRIBUTES_INTO_CLASSES)
            classdef = ClassDef(self.bookkeeper, self)
            self.bookkeeper.classdefs.append(classdef)
            self._classdefs[key] = classdef

            # forced attributes
            cls = self.pyobj
            if cls in FORCE_ATTRIBUTES_INTO_CLASSES:
                for name, s_value in FORCE_ATTRIBUTES_INTO_CLASSES[cls].items(
                ):
                    classdef.generalize_attr(name, s_value)
                    classdef.find_attribute(name).modified(classdef)

            # register all class attributes as coming from this ClassDesc
            # (as opposed to prebuilt instances)
            classsources = {}
            for attr in self.classdict:
                classsources[attr] = self  # comes from this ClassDesc
            classdef.setup(classsources)
            # look for a __del__ method and annotate it if it's there
            if '__del__' in self.classdict:
                from rpython.annotator.model import s_None, SomeInstance
                s_func = self.s_read_attribute('__del__')
                args_s = [SomeInstance(classdef)]
                s = self.bookkeeper.emulate_pbc_call(classdef, s_func, args_s)
                assert s_None.contains(s)
            return classdef
예제 #6
0
파일: unaryop.py 프로젝트: yuyichao/pypy
 def next(self):
     if s_None.contains(self.s_container):
         return s_ImpossibleValue     # so far
     if self.variant == ("enumerate",):
         s_item = self.s_container.getanyitem()
         return SomeTuple((SomeInteger(nonneg=True), s_item))
     variant = self.variant
     if variant == ("reversed",):
         variant = ()
     return self.s_container.getanyitem(*variant)
예제 #7
0
 def next(self):
     if s_None.contains(self.s_container):
         return s_ImpossibleValue  # so far
     if self.variant == ("enumerate", ):
         s_item = self.s_container.getanyitem()
         return SomeTuple((SomeInteger(nonneg=True), s_item))
     variant = self.variant
     if variant == ("reversed", ):
         variant = ()
     return self.s_container.getanyitem(*variant)
예제 #8
0
 def compute_result_annotation(self, s_obj):
     if s_None.contains(s_obj):
         return s_obj
     assert isinstance(s_obj, (SomeString, SomeUnicodeString))
     if s_obj.no_nul:
         return s_obj
     new_s_obj = SomeObject.__new__(s_obj.__class__)
     new_s_obj.__dict__ = s_obj.__dict__.copy()
     new_s_obj.no_nul = True
     return new_s_obj
예제 #9
0
파일: rstring.py 프로젝트: Qointum/pypy
 def compute_result_annotation(self, s_obj):
     if s_None.contains(s_obj):
         return s_obj
     assert isinstance(s_obj, (SomeString, SomeUnicodeString))
     if s_obj.no_nul:
         return s_obj
     new_s_obj = SomeObject.__new__(s_obj.__class__)
     new_s_obj.__dict__ = s_obj.__dict__.copy()
     new_s_obj.no_nul = True
     return new_s_obj
예제 #10
0
파일: unaryop.py 프로젝트: Mu-L/pypy
 def next(self):
     position = getbookkeeper().position_key
     if s_None.contains(self.s_container):
         return s_ImpossibleValue     # so far
     if self.variant and self.variant[0] == "enumerate":
         s_item = self.s_container.getanyitem(position)
         return SomeTuple((SomeInteger(nonneg=True), s_item))
     variant = self.variant
     if variant == ("reversed",):
         variant = ()
     return self.s_container.getanyitem(position, *variant)
예제 #11
0
파일: debug.py 프로젝트: GaussDing/pypy
    def compute_result_annotation(self, s_arg):
        from rpython.annotator.model import SomeList, s_None
        from rpython.annotator.model import SomeChar, SomeUnicodeCodePoint
        from rpython.annotator.model import SomeImpossibleValue

        if s_None.contains(s_arg):
            return s_arg  # only None: just return
        assert isinstance(s_arg, SomeList)
        if not isinstance(s_arg.listdef.listitem.s_value, (SomeChar, SomeUnicodeCodePoint, SomeImpossibleValue)):
            raise NotAListOfChars
        return s_arg
예제 #12
0
파일: debug.py 프로젝트: sota/pypy-old
 def compute_result_annotation(self, s_arg):
     from rpython.annotator.model import SomeList, s_None
     from rpython.annotator.model import SomeChar, SomeUnicodeCodePoint
     from rpython.annotator.model import SomeImpossibleValue
     if s_None.contains(s_arg):
         return s_arg  # only None: just return
     assert isinstance(s_arg, SomeList)
     if not isinstance(
             s_arg.listdef.listitem.s_value,
         (SomeChar, SomeUnicodeCodePoint, SomeImpossibleValue)):
         raise NotAListOfChars
     return s_arg
예제 #13
0
파일: debug.py 프로젝트: Qointum/pypy
 def compute_result_annotation(self, s_arg):
     from rpython.annotator.model import SomeList, s_None
     if s_None.contains(s_arg):
         return s_arg    # only None: just return
     assert isinstance(s_arg, SomeList)
     # the logic behind it is that we try not to propagate
     # make_sure_not_resized, when list comprehension is not on
     if self.bookkeeper.annotator.translator.config.translation.list_comprehension_operations:
         s_arg.listdef.never_resize()
     else:
         from rpython.annotator.annrpython import log
         log.WARNING('make_sure_not_resized called, but has no effect since list_comprehension is off')
     return s_arg
예제 #14
0
 def compute_result_annotation(self, s_arg):
     from rpython.annotator.model import SomeList, s_None
     if s_None.contains(s_arg):
         return s_arg  # only None: just return
     assert isinstance(s_arg, SomeList)
     # the logic behind it is that we try not to propagate
     # make_sure_not_resized, when list comprehension is not on
     if self.bookkeeper.annotator.translator.config.translation.list_comprehension_operations:
         s_arg.listdef.never_resize()
     else:
         from rpython.annotator.annrpython import log
         log.WARNING(
             'make_sure_not_resized called, but has no effect since list_comprehension is off'
         )
     return s_arg
예제 #15
0
파일: unaryop.py 프로젝트: yuyichao/pypy
 def method_update(dct1, dct2):
     if s_None.contains(dct2):
         return SomeImpossibleValue()
     dct1.dictdef.union(dct2.dictdef)
예제 #16
0
 def method_update(dct1, dct2):
     if s_None.contains(dct2):
         return SomeImpossibleValue()
     dct1.dictdef.union(dct2.dictdef)