From a0990a9e820571bc1d490dc3ab8f17513d75c18c Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Mon, 28 Oct 2024 12:14:08 +0100 Subject: [PATCH] More helpful error messages --- src/pystencils/backend/ast/structural.py | 2 +- src/pystencils/backend/emission.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pystencils/backend/ast/structural.py b/src/pystencils/backend/ast/structural.py index e2f202f65..3ae462c41 100644 --- a/src/pystencils/backend/ast/structural.py +++ b/src/pystencils/backend/ast/structural.py @@ -320,7 +320,7 @@ class PsPragma(PsLeafMixIn, PsEmptyLeafMixIn, PsAstNode): Example usage: ``PsPragma("omp parallel for")`` translates to ``#pragma omp parallel for``. Args: - text: The pragmas text, without the ``#pragma``. + text: The pragma's text, without the ``#pragma``. """ __match_args__ = ("text",) diff --git a/src/pystencils/backend/emission.py b/src/pystencils/backend/emission.py index e976159cf..6196d69be 100644 --- a/src/pystencils/backend/emission.py +++ b/src/pystencils/backend/emission.py @@ -50,11 +50,13 @@ from .ast.expressions import ( PsLt, PsGe, PsLe, - PsSubscript + PsSubscript, + PsBufferAcc, ) from .extensions.foreign_ast import PsForeignExpression +from .exceptions import PsInternalCompilerError from .memory import PsSymbol from ..types import PsScalarType, PsArrayType @@ -386,6 +388,12 @@ class CAstPrinter: foreign_code = node.get_code(self.visit(c, pc) for c in children) pc.pop_op() return foreign_code + + case PsBufferAcc(): + raise PsInternalCompilerError( + f"Unable to print C code for buffer access {node}.\n" + f"Buffer accesses must be lowered using the `LowerToC` pass before emission." + ) case _: raise NotImplementedError(f"Don't know how to print {node}") -- GitLab