示例#1
0
文件: descr.py 项目: cimarieta/usp
def get_field_descr(gccache, STRUCT, fieldname):
    cache = gccache._cache_field
    try:
        return cache[STRUCT][fieldname]
    except KeyError:
        offset, size = symbolic.get_field_token(STRUCT, fieldname,
                                                gccache.translate_support_code)
        FIELDTYPE = getattr(STRUCT, fieldname)
        flag = get_type_flag(FIELDTYPE)
        name = '%s.%s' % (STRUCT._name, fieldname)
        index_in_parent = heaptracker.get_fielddescr_index_in(STRUCT, fieldname)
        is_pure = STRUCT._immutable_field(fieldname) != False
        fielddescr = FieldDescr(name, offset, size, flag, index_in_parent,
                                is_pure)
        cachedict = cache.setdefault(STRUCT, {})
        cachedict[fieldname] = fielddescr
        if STRUCT is rclass.OBJECT:
            vtable = lltype.nullptr(rclass.OBJECT_VTABLE)
        else:
            vtable = heaptracker.get_vtable_for_gcstruct(gccache, STRUCT)
        fielddescr.parent_descr = get_size_descr(gccache, STRUCT, vtable)
        return fielddescr
示例#2
0
def get_field_descr(gccache, STRUCT, fieldname):
    cache = gccache._cache_field
    try:
        return cache[STRUCT][fieldname]
    except KeyError:
        offset, size = symbolic.get_field_token(STRUCT, fieldname,
                                                gccache.translate_support_code)
        FIELDTYPE = getattr(STRUCT, fieldname)
        flag = get_type_flag(FIELDTYPE)
        name = '%s.%s' % (STRUCT._name, fieldname)
        index_in_parent = heaptracker.get_fielddescr_index_in(STRUCT, fieldname)
        is_pure = STRUCT._immutable_field(fieldname) != False
        fielddescr = FieldDescr(name, offset, size, flag, index_in_parent,
                                is_pure)
        cachedict = cache.setdefault(STRUCT, {})
        cachedict[fieldname] = fielddescr
        if STRUCT is rclass.OBJECT:
            vtable = lltype.nullptr(rclass.OBJECT_VTABLE)
        else:
            vtable = heaptracker.get_vtable_for_gcstruct(gccache, STRUCT)
        fielddescr.parent_descr = get_size_descr(gccache, STRUCT, vtable)
        return fielddescr
示例#3
0
 def __init__(self, S, fieldname):
     self.S = S
     self.fieldname = fieldname
     self.FIELD = getattr(S, fieldname)
     self.index = heaptracker.get_fielddescr_index_in(S, fieldname)
     self._is_pure = S._immutable_field(fieldname)