Skip to content
Snippets Groups Projects

Cast integer literals to target type

Merged Daniel Bauer requested to merge hyteg/pystencils:bauerd/long-int into backend-rework
2 files
+ 5
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -484,7 +484,8 @@ class PsIntegerType(PsScalarType, ABC):
@@ -484,7 +484,8 @@ class PsIntegerType(PsScalarType, ABC):
raise PsTypeError(f"Given value {value} is not of required type {np_dtype}")
raise PsTypeError(f"Given value {value} is not of required type {np_dtype}")
unsigned_suffix = "" if self.signed else "u"
unsigned_suffix = "" if self.signed else "u"
# TODO: cast literal to correct type?
# TODO: cast literal to correct type?
return str(value) + unsigned_suffix
long_suffix = "" if self._width <= 32 else "l"
 
return str(value) + unsigned_suffix + long_suffix
def create_constant(self, value: Any) -> Any:
def create_constant(self, value: Any) -> Any:
np_type = self.NUMPY_TYPES[self._width]
np_type = self.NUMPY_TYPES[self._width]
Loading