Ejemplo n.º 1
0
 def getattr(self, name):
     if name == u"doc":
         return self.doc
     elif name == u"loc":
         unit = self.function.unit
         trace = TraceEntry(0, unit.sources, self.function.sourcemap,
                            unit.path)
         name, col0, lno0, col1, lno1 = trace.pc_location()
         start = space.Exnihilo()
         start.setattr(u"col", space.Integer(col0))
         start.setattr(u"lno", space.Integer(lno0))
         stop = space.Exnihilo()
         stop.setattr(u"col", space.Integer(col1))
         stop.setattr(u"lno", space.Integer(lno1))
         obj = space.Exnihilo()
         obj.setattr(u"source", name)
         obj.setattr(u"start", start)
         obj.setattr(u"stop", stop)
         return obj
     elif name == u"spec":
         spec = space.Exnihilo()
         spec.setattr(u'argc',
                      space.Integer(rffi.r_long(self.function.argc)))
         spec.setattr(
             u'optional',
             space.Integer(
                 rffi.r_long(self.function.topc - self.function.argc)))
         spec.setattr(u'is_variadic',
                      space.boolean(self.function.flags & 1 == 1))
         spec.setattr(u'varnames', self.function.varnames)
         return spec
     else:
         return space.Object.getattr(self, name)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
def sourceloc_introspection(pc, function):
    trace = TraceEntry(pc, function.unit.sources, function.sourcemap,
                       function.unit.path)
    name, col0, lno0, col1, lno1 = trace.pc_location()
    start = space.Exnihilo()
    start.setattr(u"col", space.Integer(col0))
    start.setattr(u"lno", space.Integer(lno0))
    stop = space.Exnihilo()
    stop.setattr(u"col", space.Integer(col1))
    stop.setattr(u"lno", space.Integer(lno1))
    obj = space.Exnihilo()
    obj.setattr(u"source", name)
    obj.setattr(u"start", start)
    obj.setattr(u"stop", stop)
    return obj
Ejemplo n.º 4
0
 def log(self, which, obj):
     entry = space.Exnihilo()
     entry.setattr(u"type", space.String(which))
     entry.setattr(u"value", obj)
     for logger in list(self.loggers):
         if logger.closed:
             self.loggers.remove(logger)
         else:
             logger.append(entry)
     return len(self.loggers)
Ejemplo n.º 5
0
def excs_introspection(excs):
    out = []
    for exc in excs:
        o = space.Exnihilo()
        o.setattr(u"start", space.Integer(rffi.r_long(exc.start)))
        o.setattr(u"stop", space.Integer(rffi.r_long(exc.stop)))
        o.setattr(u"label", space.Integer(rffi.r_long(exc.label)))
        o.setattr(u"reg", space.Integer(rffi.r_long(exc.reg)))
        out.append(o)
    return space.List(out)
Ejemplo n.º 6
0
 def log(self, which, obj):
     entry = space.Exnihilo()
     entry.setattr(u"type", space.String(which))
     entry.setattr(u"value", obj)
     if core.g.ec.get(
     ) is not self.ec:  # TODO: Fix this using 'async' signaling?
         return 0  #  user logs are not getting
         #  cross-thread log messages.
     for logger in list(self.loggers):
         if logger.closed:
             self.loggers.remove(logger)
         else:
             logger.append(entry)
     return len(self.loggers)
Ejemplo n.º 7
0
 def getattr(self, name):
     if name == u"doc":
         return self.doc
     elif name == u"loc":
         return sourceloc_introspection(0, self.function)
     elif name == u"spec":
         spec = space.Exnihilo()
         spec.setattr(u'argc',
                      space.Integer(rffi.r_long(self.function.argc)))
         spec.setattr(
             u'optional',
             space.Integer(
                 rffi.r_long(self.function.topc - self.function.argc)))
         spec.setattr(u'is_variadic',
                      space.boolean(self.function.flags & 1 == 1))
         spec.setattr(u'varnames', self.function.varnames)
         return spec
     elif name == u"code":
         return Introspection(self)
     else:
         return space.Object.getattr(self, name)