Skip to content
Snippets Groups Projects

Indexed domain kernel

Merged Markus Holzer requested to merge holzer/pystencils:IndexedDomainKernel into master
1 file
+ 15
7
Compare changes
  • Side-by-side
  • Inline
+ 15
7
@@ -189,16 +189,17 @@ class VectorType(AbstractType):
@@ -189,16 +189,17 @@ class VectorType(AbstractType):
class PointerType(AbstractType):
class PointerType(AbstractType):
def __init__(self, base_type: BasicType, const: bool = False, restrict: bool = True):
def __init__(self, base_type: BasicType, const: bool = False, restrict: bool = True, double_pointer: bool = False):
self._base_type = base_type
self._base_type = base_type
self.const = const
self.const = const
self.restrict = restrict
self.restrict = restrict
 
self.double_pointer = double_pointer
def __getnewargs__(self):
def __getnewargs__(self):
return self.base_type, self.const, self.restrict
return self.base_type, self.const, self.restrict, self.double_pointer
def __getnewargs_ex__(self):
def __getnewargs_ex__(self):
return (self.base_type, self.const, self.restrict), {}
return (self.base_type, self.const, self.restrict, self.double_pointer), {}
@property
@property
def alias(self):
def alias(self):
@@ -210,18 +211,25 @@ class PointerType(AbstractType):
@@ -210,18 +211,25 @@ class PointerType(AbstractType):
@property
@property
def item_size(self):
def item_size(self):
return self.base_type.item_size
if self.double_pointer:
 
return 8
 
else:
 
return self.base_type.item_size
def __eq__(self, other):
def __eq__(self, other):
if not isinstance(other, PointerType):
if not isinstance(other, PointerType):
return False
return False
else:
else:
return (self.base_type, self.const, self.restrict) == (other.base_type, other.const, other.restrict)
return ((self.base_type, self.const, self.restrict, self.double_pointer) ==
 
(other.base_type, other.const, other.restrict, other.double_pointer))
def __str__(self):
def __str__(self):
restrict_str = "RESTRICT" if self.restrict else ""
restrict_str = "RESTRICT" if self.restrict else ""
const_str = "const" if self.const else ""
const_str = "const" if self.const else ""
return f'{str(self.base_type)} * {restrict_str} {const_str}'
if self.double_pointer:
 
return f'{str(self.base_type)} ** {restrict_str} {const_str}'
 
else:
 
return f'{str(self.base_type)} * {restrict_str} {const_str}'
def __repr__(self):
def __repr__(self):
return str(self)
return str(self)
@@ -230,7 +238,7 @@ class PointerType(AbstractType):
@@ -230,7 +238,7 @@ class PointerType(AbstractType):
return str(self)
return str(self)
def __hash__(self):
def __hash__(self):
return hash((self._base_type, self.const, self.restrict))
return hash((self._base_type, self.const, self.restrict, self.double_pointer))
class StructType(AbstractType):
class StructType(AbstractType):
Loading