示例#1
0
 def getattr(self, name):
     if name == u'length':
         return Integer(len(self.string))
     if name == u'utf8':
         return space.to_uint8array(
             self.string.encode('utf-8'))
     return Object.getattr(self, name)
示例#2
0
 def getattr(self, name):
     map = jit.promote(self.map)
     index = map.getindex(name)
     if index != -1:
         return self.storage[index]
     else:
         return Object.getattr(self, name)
示例#3
0
文件: builtin.py 项目: Eirikur/lever
 def getattr(self, name):
     if name == u"doc":
         return self.doc
     elif name == u"loc":
         source, start, stop = self.source_location
         obj = space.Exnihilo()
         obj.setattr(u"source", space.String(source))
         obj.setattr(u"start", space.Integer(start))
         obj.setattr(u"stop", space.Integer(stop))
         return obj
     elif name == u"spec":
         argc, optional, variadic, varnames, argtypes = self.spec
         varnames = [
             space.String(name.decode('utf-8')) for name in varnames
         ]
         spec = space.Exnihilo()
         spec.setattr(u'argc', space.Integer(rffi.r_long(argc)))
         spec.setattr(u'optional', space.Integer(rffi.r_long(optional)))
         spec.setattr(u'is_variadic', space.boolean(variadic))
         spec.setattr(u'varnames', space.List(list(varnames)))
         if argtypes is not None:
             spec.setattr(u'argtypes', space.List(list(argtypes)))
         else:
             spec.setattr(u'argtypes', space.null)
         return spec
     else:
         return Object.getattr(self, name)
示例#4
0
 def getattr(self, name):
     if name == u'start':
         return self.start
     if name == u'stop':
         return self.stop
     if name == u'step':
         return self.step
     return Object.getattr(self, name)
示例#5
0
文件: module.py 项目: Eirikur/lever
 def getattr(self, name):
     if name == u"link":
         return self.doc
     if name == u"name":
         return self.name
     if name == u"parent":
         return self.parent
     return Object.getattr(self, name)
示例#6
0
文件: slices.py 项目: cheery/lever
 def getattr(self, name):
     if name == u'start':
         return self.start
     if name == u'stop':
         return self.stop
     if name == u'step':
         return self.step
     return Object.getattr(self, name)
示例#7
0
 def getattr(self, index):
     if index == u"arity":
         return space.Integer(self.arity)
     if index == u"default":
         return self.default
     if index == u"doc":
         return self.doc
     if index == u"size":  # Used for ensuring that the gc+sleep can
         a = len(self.multimethod_table)  # bite into the weak references.
         return Integer(a)
     return Object.getattr(self, index)
示例#8
0
文件: module.py 项目: Dohxis/lever
 def getattr(self, name):
     try:
         cell = jit.promote(self.lookup(name))
         if isinstance(cell, FrozenCell):
             return cell.slot
         elif isinstance(cell, MutableCell):
             return cell.slot
         else:
             assert False
     except KeyError:
         return Object.getattr(self, name)
示例#9
0
 def getattr(self, name):
     try:
         cell = jit.promote(self.lookup(name))
         if isinstance(cell, FrozenCell):
             return cell.slot
         elif isinstance(cell, MutableCell):
             return cell.slot
         else:
             assert False
     except KeyError:
         return Object.getattr(self, name)
示例#10
0
 def getattr(self, index):
     try:
         return self.cells[index]
     except KeyError as e:
         try:
             method = self.custom_interface.methods[index]
         except KeyError as e:
             return Object.getattr(self, index)
         if isinstance(method, Property):
             return method.getter.call([self])
         else:
             return BoundMethod(self, index, method)
示例#11
0
 def getattr(self, index):
     try:
         return self.cells[index]
     except KeyError as e:
         try:
             method = self.custom_interface.methods[index]
         except KeyError as e:
             return Object.getattr(self, index)
         if isinstance(method, Property):
             return method.getter.call([self])
         else:
             return BoundMethod(self, index, method)
示例#12
0
 def getattr(self, name):
     map = jit.promote(self.map)
     index = map.getindex(name)
     if index != -1:
         return self.storage[index]
     else:
         method = self.custom_interface.lookup_method(name)
         if method is None:
             return Object.getattr(self, name)
         elif isinstance(method, Property):
             return method.getter.call([self])
         else:
             return BoundMethod(self, name, method)
示例#13
0
文件: module.py 项目: cheery/lever
 def getattr(self, name):
     try:
         cell = jit.promote(self.lookup(name))
         while isinstance(cell, ShadowCell):
             if cell.link is None:
                 return cell.slot
             cell = cell.link
         if isinstance(cell, FrozenCell):
             return cell.slot
         elif isinstance(cell, MutableCell):
             return cell.slot
         else:
             assert False
     except KeyError:
         return Object.getattr(self, name)
示例#14
0
 def getattr(self, name):
     if name == u"get":
         return self.getter
     if name == u"set":
         return self.setter
     return Object.getattr(self, name)
示例#15
0
文件: string.py 项目: cheery/lever
 def getattr(self, name):
     if name == u'length':
         return numbers.Integer(len(self.string))
     return Object.getattr(self, name)
示例#16
0
 def getattr(self, name):
     if name == u'length':
         return Integer(len(self.data))
     return Object.getattr(self, name)
示例#17
0
文件: module.py 项目: Eirikur/lever
 def getattr(self, name):
     try:
         cell = jit.promote(self.lookup(name))
         return cell.getval()
     except KeyError:
         return Object.getattr(self, name)
示例#18
0
 def getattr(self, index):
     if index == u"default":
         return self.default
     return Object.getattr(self, index)
示例#19
0
 def getattr(self, name):
     if name == u'length':
         return Integer(len(self.contents))
     return Object.getattr(self, name)
示例#20
0
 def getattr(self, index):
     if index == u"default":
         return self.default
     return Object.getattr(self, index)
示例#21
0
文件: builtin.py 项目: cheery/lever
 def getattr(self, name):
     if name == u"doc":
         return self.doc
     else:
         return Object.getattr(self, name)
示例#22
0
 def getattr(self, name):
     if name == u"ref":
         return self.ref
     return Object.getattr(self, name)
示例#23
0
def getattr(self, name):
    ref = self.ref
    if not isinstance(ref, CustomObject):
        return Object.getattr(ref, name.string)
    #name = space.cast(name, space.String, u"Id.getattr name").string
    return ref.getattr_direct(name.string)
示例#24
0
 def getattr(self, name):
     if name == u"get":
         return self.getter
     if name == u"set":
         return self.setter
     return Object.getattr(self, name)
示例#25
0
 def getattr(self, name):
     if name == u'length':
         return numbers.Integer(self.length)
     return Object.getattr(self, name)
示例#26
0
文件: errors.py 项目: whitten/lever
 def getattr(self, name):
     if name == u"traceback":
         return self.traceback
     return Object.getattr(self, name)