Beispiel #1
0
 def visitSubscript(self, node, ctype=None):
     
     value = self.visit(node.value)
     slice = self.visit(node.slice)
     
     if is_slice(slice):
         ctype = value.ctype
     else:
         ctype = derefrence(value.ctype)
     ctx = node.ctx
     subscr = cast.CSubscript(value, slice, ctx, ctype)
     
     return subscr
Beispiel #2
0
    def visitSubscript(self, node, ctype=None):

        value = self.visit(node.value)
        slice = self.visit(node.slice)

        if is_slice(slice):
            ctype = value.ctype
        else:
            ctype = derefrence(value.ctype)
        ctx = node.ctx
        subscr = cast.CSubscript(value, slice, ctx, ctype)

        return subscr
Beispiel #3
0
def getattrtype(ctype, attr):
    '''
    Get the ctype of an attribute on a ctype 
    '''
    if isclass(ctype) and issubclass(ctype, _ctypes.Structure):
        return get_struct_attr(ctype, attr)
        
    elif ismodule(ctype):
        return getattr(ctype, attr)
    elif isinstance(ctype, cl.contextual_memory):
        if ctype.ndim == 0:
            return getattrtype(ctype.ctype, attr)
        else:
            return getattr(ctype, attr)
    elif is_vetor_type(ctype):
        return derefrence(ctype)
#        raise NotImplementedError("is_vetor_type", ctype, attr, derefrence(ctype))
    elif hasattr(ctype, attr):
        return getattr(ctype, attr)
    else:
        raise CLAttributeError("type %r has no attribute %r" % (ctype, attr))
Beispiel #4
0
def getattrtype(ctype, attr):
    '''
    Get the ctype of an attribute on a ctype 
    '''
    if isclass(ctype) and issubclass(ctype, _ctypes.Structure):
        return get_struct_attr(ctype, attr)

    elif ismodule(ctype):
        return getattr(ctype, attr)
    elif isinstance(ctype, cl.contextual_memory):
        if ctype.ndim == 0:
            return getattrtype(ctype.ctype, attr)
        else:
            return getattr(ctype, attr)
    elif is_vetor_type(ctype):
        return derefrence(ctype)


#        raise NotImplementedError("is_vetor_type", ctype, attr, derefrence(ctype))
    elif hasattr(ctype, attr):
        return getattr(ctype, attr)
    else:
        raise CLAttributeError("type %r has no attribute %r" % (ctype, attr))