diff --git a/src/pystencils/nbackend/ast/kernelfunction.py b/src/pystencils/nbackend/ast/kernelfunction.py index 58f2ddf3652689d8840a6c6e4f8ec033182566dd..e3c91d83c28b15749d4365d8ed5c4125746b74a9 100644 --- a/src/pystencils/nbackend/ast/kernelfunction.py +++ b/src/pystencils/nbackend/ast/kernelfunction.py @@ -46,14 +46,13 @@ class PsKernelParametersSpec: elif var in self.params: continue - - else: - raise PsInternalCompilerError( - "Constrained parameter was neither contained in kernel parameter list " - "nor associated with a kernel array.\n" - f" Parameter: {var}\n" - f" Constraint: {constraint.condition}" - ) + + raise PsInternalCompilerError( + "Constrained parameter was neither contained in kernel parameter list " + "nor associated with a kernel array.\n" + f" Parameter: {var}\n" + f" Constraint: {constraint.condition}" + ) class PsKernelFunction(PsAstNode): diff --git a/src/pystencils/nbackend/kernelcreation/transformations.py b/src/pystencils/nbackend/kernelcreation/transformations.py index c01016d126e929ca2076f8f1d775e7d818394b71..c73fbce73229f2c3cd5bf8da3d1efc0a8e5ff4a0 100644 --- a/src/pystencils/nbackend/kernelcreation/transformations.py +++ b/src/pystencils/nbackend/kernelcreation/transformations.py @@ -19,8 +19,9 @@ NodeT = TypeVar("NodeT", bound=PsAstNode) class EraseAnonymousStructTypes(IdentityMapper): """Lower anonymous struct arrays to a byte-array representation. - Arrays whose element type is an anonymous struct are transformed to arrays with element type UInt(8). - Lookups on accesses into these arrays are transformed using type casts. + For arrays whose element type is an anonymous struct, the struct type is erased from the base pointer, + making it a pointer to uint8_t. + Member lookups on accesses into these arrays are then transformed using type casts. """ def __init__(self, ctx: KernelCreationContext) -> None: diff --git a/src/pystencils/nbackend/kernelcreation/typification.py b/src/pystencils/nbackend/kernelcreation/typification.py index c817bde3f016b72836b4b021f6a4c14e4c404c63..37ed8e8e131587965a20ba1d7d8d9197c66eb48a 100644 --- a/src/pystencils/nbackend/kernelcreation/typification.py +++ b/src/pystencils/nbackend/kernelcreation/typification.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TypeVar, Any, NoReturn +from typing import TypeVar, Any import pymbolic.primitives as pb from pymbolic.mapper import Mapper @@ -10,7 +10,6 @@ from ..types import PsAbstractType, PsNumericType, PsStructType, deconstify from ..typed_expressions import PsTypedVariable, PsTypedConstant, ExprOrConstant from ..arrays import PsArrayAccess from ..ast import PsAstNode, PsBlock, PsExpression, PsAssignment -from ..exceptions import PsInternalCompilerError __all__ = ["Typifier"] @@ -22,40 +21,6 @@ class TypificationError(Exception): NodeT = TypeVar("NodeT", bound=PsAstNode) -class UndeterminedType(PsNumericType): - """Placeholder for types that could not yet be determined by the typifier. - - Instances of this class should never leave the typifier; it is an error if they do. - """ - - def create_constant(self, value: Any) -> Any: - return None - - def _err(self) -> NoReturn: - raise PsInternalCompilerError("Calling UndeterminedType.") - - def create_literal(self, value: Any) -> str: - self._err() - - def is_int(self) -> bool: - self._err() - - def is_sint(self) -> bool: - self._err() - - def is_uint(self) -> bool: - self._err() - - def is_float(self) -> bool: - self._err() - - def __eq__(self, other: object) -> bool: - self._err() - - def c_string(self) -> str: - self._err() - - class DeferredTypedConstant(PsTypedConstant): """Special subclass for constants whose types cannot be determined yet at the time of their creation.