Esempio n. 1
0
 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)
Esempio n. 2
0
 def len(self):
     from rpython.annotator.bookkeeper import getbookkeeper
     length = self.ll_ptrtype._example()._fixedlength()
     if length is None:
         return SomeObject.len(self)
     else:
         return getbookkeeper().immutablevalue(length)
Esempio n. 3
0
 def simple_call(self, *s_args):
     from rpython.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)
Esempio n. 4
0
File: dotnet.py Progetto: sota/pypy
 def simple_call(self, *s_args):
     from rpython.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)
Esempio n. 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
Esempio n. 6
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
Esempio n. 7
0
 def op_contains(self, s_element):
     if s_element.is_constant() and s_element.const == "\0":
         r = SomeBool()
         bk = getbookkeeper()
         op = bk._find_current_op(opname="contains", arity=2, pos=0, s_type=self)
         knowntypedata = {}
         add_knowntypedata(knowntypedata, False, [op.args[0]], self.nonnulify())
         r.set_knowntypedata(knowntypedata)
         return r
     else:
         return SomeObject.op_contains(self, s_element)
Esempio n. 8
0
 def len(self):
     position = getbookkeeper().position_key
     s_item = self.listdef.read_item(position)
     if isinstance(s_item, SomeImpossibleValue):
         return immutablevalue(0)
     return SomeObject.len(self)
Esempio n. 9
0
 def len(self):
     s_item = self.listdef.read_item()
     if isinstance(s_item, SomeImpossibleValue):
         return immutablevalue(0)
     return SomeObject.len(self)
Esempio n. 10
0
 def len(self):
     if self._is_empty():
         return immutablevalue(0)
     return SomeObject.len(self)
Esempio n. 11
0
 def len(self):
     s_item = self.listdef.read_item()
     if isinstance(s_item, SomeImpossibleValue):
         return immutablevalue(0)
     return SomeObject.len(self)
Esempio n. 12
0
 def len(self):
     if self._is_empty():
         return immutablevalue(0)
     return SomeObject.len(self)
Esempio n. 13
0
 def len(p):
     length = p.ll_ptrtype._example()._fixedlength()
     if length is None:
         return SomeObject.len(p)
     else:
         return immutablevalue(length)
Esempio n. 14
0
 def len(self):
     position = getbookkeeper().position_key
     s_item = self.listdef.read_item(position)
     if isinstance(s_item, SomeImpossibleValue):
         return immutablevalue(0)
     return SomeObject.len(self)
Esempio n. 15
0
 def len(self):
     position = getbookkeeper().position_key
     if self._is_empty(position):
         return immutablevalue(0)
     return SomeObject.len(self)
Esempio n. 16
0
 def len(dct):
     if dct._is_empty():
         return immutablevalue(0)
     return SomeObject.len(dct)
Esempio n. 17
0
 def len(self):
     position = getbookkeeper().position_key
     if self._is_empty(position):
         return immutablevalue(0)
     return SomeObject.len(self)