Ejemplo n.º 1
0
 def compute_result_annotation(self, type_s, length_s):
     from rpython.translator.cli.query import get_cli_class
     assert type_s.is_constant()
     assert isinstance(length_s, SomeInteger)
     TYPE = type_s.const._INSTANCE
     fullname = '%s.%s[]' % (TYPE._namespace, TYPE._classname)
     cliArray = get_cli_class(fullname)
     return SomeOOInstance(cliArray._INSTANCE)
Ejemplo n.º 2
0
 def compute_result_annotation(self, s_value, s_type):
     if isinstance(s_type.const, ootype.OOType):
         TYPE = s_type.const
     else:
         cliClass = s_type.const
         TYPE = cliClass._INSTANCE
     assert ootype.isSubclass(s_value.ootype, TYPE)
     return SomeOOInstance(TYPE)
Ejemplo n.º 3
0
 def lltype_to_annotation(cls, TYPE):
     if isinstance(TYPE, NativeInstance):
         return SomeOOInstance(TYPE)
     elif TYPE is ootype.Char:
         return SomeChar()
     elif TYPE is ootype.String:
         return SomeString(can_be_None=True)
     else:
         return lltype_to_annotation(TYPE)
Ejemplo n.º 4
0
 def compute_result_annotation(self, type_s, *args_s):
     from rpython.translator.cli.query import get_cli_class
     assert type_s.is_constant()
     TYPE = type_s.const._INSTANCE
     for i, arg_s in enumerate(args_s):
         if TYPE is not arg_s.ootype:
             raise TypeError, 'Wrong type of arg #%d: %s expected, %s found' % \
                   (i, TYPE, arg_s.ootype)
     fullname = '%s.%s[]' % (TYPE._namespace, TYPE._classname)
     cliArray = get_cli_class(fullname)
     return SomeOOInstance(cliArray._INSTANCE)
Ejemplo n.º 5
0
 def compute_result_annotation(self, x_s, type_s):
     assert isinstance(x_s, SomeOOInstance)
     assert isinstance(x_s.ootype, NativeInstance)
     assert type_s.is_constant()
     TYPE = type_s.const
     if isinstance(TYPE, (type, types.ClassType)):
         # it's a user-defined class, so we return SomeInstance
         # can_be_None == True because it can always return None, if it fails
         classdef = self.bookkeeper.getuniqueclassdef(TYPE)
         return SomeInstance(classdef, can_be_None=True)
     elif TYPE in BOXABLE_TYPES:
         return OverloadingResolver.lltype_to_annotation(TYPE)
     elif isinstance(TYPE, ootype.StaticMethod):
         return SomeOOStaticMeth(TYPE)
     elif isinstance(TYPE, ootype.OOType):
         return SomeOOInstance(TYPE)
     else:
         assert False
Ejemplo n.º 6
0
 def getitem((ooinst, index)):
     if ooinst.ootype._isArray:
         return SomeOOInstance(ooinst.ootype._ELEMENT)
     return s_ImpossibleValue
Ejemplo n.º 7
0
 def compute_result_annotation(self, s_value):
     assert isinstance(s_value, annmodel.SomeOOObject)
     assert s_value.ootype is ootype.Object
     return SomeOOInstance(CLR.System.Object._INSTANCE)
Ejemplo n.º 8
0
 def compute_result_annotation(self, s_value):
     from rpython.translator.cli.query import get_cli_class
     cliType = get_cli_class('System.EventHandler')
     return SomeOOInstance(cliType._INSTANCE)
Ejemplo n.º 9
0
 def compute_result_annotation(self, cliClass_s):
     from rpython.translator.cli.query import get_cli_class
     assert cliClass_s.is_constant()
     cliType = get_cli_class('System.Type')
     return SomeOOInstance(cliType._INSTANCE)
Ejemplo n.º 10
0
 def compute_result_annotation(self, exc_s):
     assert isinstance(exc_s, SomeInstance)
     cls = exc_s.classdef.classdesc.pyobj
     assert issubclass(cls, Exception)
     NATIVE_INSTANCE = cls._rpython_hints['NATIVE_INSTANCE']
     return SomeOOInstance(NATIVE_INSTANCE)
Ejemplo n.º 11
0
 def compute_result_annotation(self, x_s):
     can_be_None = getattr(x_s, 'can_be_None', False)
     return SomeOOInstance(CLR.System.Object._INSTANCE,
                           can_be_None=can_be_None)
Ejemplo n.º 12
0
 def simple_call(self, *s_args):
     assert self.is_constant()
     return SomeOOInstance(self.const._INSTANCE)
Ejemplo n.º 13
0
 def compute_result_annotation(self):
     return SomeOOInstance(self.instance._INSTANCE)