Пример #1
0
 def _setup_repr(self):
     InstanceRepr._setup_repr(self)
     flds = self.allinstancefields.keys()
     flds.remove('__class__')
     if self.is_parent:
         if flds:
             raise TyperError("%r is a base class of an UnboxedValue,"
                              "so it cannot have fields: %r" % (
                 self.classdef, flds))
     else:
         if len(flds) != 1:
             raise TyperError("%r must have exactly one field: %r" % (
                 self.classdef, flds))
         self.specialfieldname = flds[0]
Пример #2
0
 def ll_str(self, i):
     if lltype.cast_ptr_to_int(i) & 1:
         from rpython.rtyper.lltypesystem import rstr
         from rpython.rtyper.rint import signed_repr
         llstr1 = signed_repr.ll_str(ll_unboxed_to_int(i))
         return rstr.ll_strconcat(rstr.unboxed_instance_str_prefix,
                   rstr.ll_strconcat(llstr1,
                                     rstr.unboxed_instance_str_suffix))
     else:
         return InstanceRepr.ll_str(self, i)
Пример #3
0
 def __init__(self, rtyper, classdef, unboxedclassdef):
     InstanceRepr.__init__(self, rtyper, classdef)
     self.unboxedclassdef = unboxedclassdef
     self.is_parent = unboxedclassdef is not classdef