當前位置: 首頁>>代碼示例>>Python>>正文


Python model.SomeObject類代碼示例

本文整理匯總了Python中pypy.annotation.model.SomeObject的典型用法代碼示例。如果您正苦於以下問題:Python SomeObject類的具體用法?Python SomeObject怎麽用?Python SomeObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SomeObject類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: union

 def union((obj1, obj2)):
     if obj1 == obj2:
         return obj1
     else:
         result = SomeObject()
         if obj1.knowntype == obj2.knowntype and obj1.knowntype != object:
             result.knowntype = obj1.knowntype
         is_type_of1 = getattr(obj1, 'is_type_of', None)
         is_type_of2 = getattr(obj2, 'is_type_of', None)
         if obj1.is_immutable_constant() and obj2.is_immutable_constant() and obj1.const == obj2.const:
             result.const = obj1.const
             is_type_of = {}
             if is_type_of1:
                 for v in is_type_of1:
                     is_type_of[v] = True
             if is_type_of2:
                 for v in is_type_of2:
                     is_type_of[v] = True
             if is_type_of:
                 result.is_type_of = is_type_of.keys()
         else:
             if is_type_of1 and is_type_of1 == is_type_of2:
                 result.is_type_of = is_type_of1
         # try to preserve the origin of SomeObjects
         if obj1 == result:
             result = obj1
         elif obj2 == result:
             result = obj2
         unioncheck(result)
         return result
開發者ID:alkorzt,項目名稱:pypy,代碼行數:30,代碼來源:binaryop.py

示例2: newtuple

 def newtuple(self, items_s):
     if len(items_s) == 1 and items_s[0] is Ellipsis:
         res = SomeObject()   # hack to get a SomeObject as the *arg
         res.from_ellipsis = True
         return res
     else:
         return SomeTuple(items_s)
開發者ID:Debug-Orz,項目名稱:Sypy,代碼行數:7,代碼來源:bookkeeper.py

示例3: annotationoftype

def annotationoftype(t, bookkeeper=False):
    from pypy.rpython import extregistry

    """The most precise SomeValue instance that contains all
    objects of type t."""
    assert isinstance(t, (type, types.ClassType))
    if t is bool:
        return SomeBool()
    elif t is int:
        return SomeInteger()
    elif t is float:
        return SomeFloat()
    elif issubclass(t, str): # py.lib uses annotated str subclasses
        return SomeString()
    elif t is unicode:
        return SomeUnicodeString()
    elif t is list:
        return SomeList(MOST_GENERAL_LISTDEF)
    elif t is dict:
        return SomeDict(MOST_GENERAL_DICTDEF)
    # can't do tuple
    elif t is types.NoneType:
        return s_None
    elif bookkeeper and extregistry.is_registered_type(t, bookkeeper.policy):
        entry = extregistry.lookup_type(t, bookkeeper.policy)
        return entry.compute_annotation_bk(bookkeeper)
    elif bookkeeper and t.__module__ != '__builtin__' and t not in bookkeeper.pbctypes:
        classdef = bookkeeper.getuniqueclassdef(t)
        return SomeInstance(classdef)
    else:
        o = SomeObject()
        if t != object:
            o.knowntype = t
        return o
開發者ID:Debug-Orz,項目名稱:Sypy,代碼行數:34,代碼來源:signature.py

示例4: newtuple

 def newtuple(self, items_s):
     if items_s == [Ellipsis]:
         res = SomeObject()   # hack to get a SomeObject as the *arg
         res.from_ellipsis = True
         return res
     else:
         return SomeTuple(items_s)
開發者ID:alkorzt,項目名稱:pypy,代碼行數:7,代碼來源:bookkeeper.py

示例5: find_method

 def find_method(obj, name):
     "Look for a special-case implementation for the named method."
     type_analyser = builtin.EXTERNAL_TYPE_ANALYZERS[obj.knowntype]
     if name in type_analyser:
         analyser = type_analyser[name]
         return SomeBuiltin(analyser, obj, name)
     return SomeObject.find_method(obj, name)
開發者ID:TheDunn,項目名稱:flex-pypy,代碼行數:7,代碼來源:unaryop.py

示例6: simple_call

 def simple_call(self, *s_args):
     from pypy.translator.cli.query import get_cli_class
     DELEGATE = get_cli_class('System.Delegate')._INSTANCE
     if ootype.isSubclass(self.ootype, DELEGATE):
         s_invoke = self.getattr(immutablevalue('Invoke'))
         return s_invoke.simple_call(*s_args)
     else:
         # cannot call a non-delegate
         return SomeObject.simple_call(self, *s_args)
開發者ID:alkorzt,項目名稱:pypy,代碼行數:9,代碼來源:dotnet.py

示例7: compute_result_annotation

 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
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例8: getattr

 def getattr(p, s_attr):
     if s_attr.is_constant() and isinstance(s_attr.const, str):
         # XXX kill with extfunctable.py
         if p.knowntype in builtin.EXTERNAL_TYPE_ANALYZERS:
             return SomeObject.getattr(p, s_attr)
         
         attr = s_attr.const
         entry = extregistry.lookup_type(p.knowntype)
         s_value = entry.get_field_annotation(p.knowntype, attr)
         return s_value
     else:
         return SomeObject()
開發者ID:TheDunn,項目名稱:flex-pypy,代碼行數:12,代碼來源:unaryop.py

示例9: getattr

 def getattr(s_array, s_attr):
     s = None
     if s_attr.is_constant() and isinstance(s_attr.const, str):
         attr = s_attr.const
         if attr == 'shape':
             s = SomeTuple([SomeInteger()]*s_array.ndim)
         elif attr == 'ndim':
             s = SomeInteger()
         elif attr == 'dtype':
             s = SomeChar()
     if s is None:
         return SomeObject.getattr(s_array, s_attr)
     return s
開發者ID:alkorzt,項目名稱:pypy,代碼行數:13,代碼來源:aarray.py

示例10: len

 def len(p):
     length = p.ll_ptrtype._example()._fixedlength()
     if length is None:
         return SomeObject.len(p)
     else:
         return immutablevalue(length)
開發者ID:,項目名稱:,代碼行數:6,代碼來源:

示例11: len

 def len(dct):
     s_key = dct.dictdef.read_key()
     s_value = dct.dictdef.read_value()
     if isinstance(s_key, SomeImpossibleValue) or isinstance(s_value, SomeImpossibleValue):
         return immutablevalue(0)
     return SomeObject.len(dct)
開發者ID:TheDunn,項目名稱:flex-pypy,代碼行數:6,代碼來源:unaryop.py


注:本文中的pypy.annotation.model.SomeObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。