예제 #1
0
파일: unaryop.py 프로젝트: Debug-Orz/Sypy
 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)
예제 #2
0
 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)
예제 #3
0
    def getclassdef(self, key):
        try:
            return self._classdefs[key]
        except KeyError:
            from pypy.annotation.classdef import ClassDef, FORCE_ATTRIBUTES_INTO_CLASSES
            classdef = ClassDef(self.bookkeeper, self)
            self.bookkeeper.classdefs.append(classdef)
            self._classdefs[key] = classdef

            # forced attributes
            if self.pyobj is not None:
                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 pypy.annotation.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
예제 #4
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
예제 #5
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
예제 #6
0
파일: ll_os.py 프로젝트: chyyuu/pygirl
 def os_utime_normalize_args(s_path, s_times):
     # special handling of the arguments: they can be either
     # [str, (float, float)] or [str, s_None], and get normalized
     # to exactly one of these two.
     if not s_string.contains(s_path):
         raise Exception("os.utime() arg 1 must be a string, got %s" % (
             s_path,))
     case1 = s_None.contains(s_times)
     case2 = s_tuple_of_2_floats.contains(s_times)
     if case1 and case2:
         return [s_string, s_ImpossibleValue] #don't know which case yet
     elif case1:
         return [s_string, s_None]
     elif case2:
         return [s_string, s_tuple_of_2_floats]
     else:
         raise Exception("os.utime() arg 2 must be None or a tuple of "
                         "2 floats, got %s" % (s_times,))
예제 #7
0
 def method_update(dct1, dct2):
     if s_None.contains(dct2):
         return SomeImpossibleValue()
     dct1.dictdef.union(dct2.dictdef)
예제 #8
0
 def method_update(dct1, dct2):
     if s_None.contains(dct2):
         return SomeImpossibleValue()
     dct1.dictdef.union(dct2.dictdef)