From 72733a200c43ef6b7a75071d39c4f5f6d094712e Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 25 Jan 2018 13:42:49 -0600 Subject: [PATCH 1/4] CodeBuilder.raise_: pass through error_mesage --- dagrt/language.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dagrt/language.py b/dagrt/language.py index 484ad17..e1ea63f 100644 --- a/dagrt/language.py +++ b/dagrt/language.py @@ -1153,9 +1153,9 @@ class CodeBuilder(object): self.fence() self._add_inst_to_context(ExitStep()) - def raise_(self, error): + def raise_(self, error_condition, error_message=None): self.fence() - self._add_inst_to_context(Raise(error)) + self._add_inst_to_context(Raise(error_condition, error_message)) def state_transition(self, next_state): self.fence() -- GitLab From 41be1bc7938f7b281272423aba4708cf7425e607 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 25 Jan 2018 13:43:13 -0600 Subject: [PATCH 2/4] CodeBuilder.if_: parse lhs/rhs of comparison --- dagrt/language.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dagrt/language.py b/dagrt/language.py index e1ea63f..e2cede5 100644 --- a/dagrt/language.py +++ b/dagrt/language.py @@ -891,17 +891,24 @@ class CodeBuilder(object): @contextmanager def if_(self, *condition_arg): """Create a new block that is conditionally executed.""" + from dagrt.expression import parse + if len(condition_arg) == 1: condition = condition_arg[0] - from dagrt.expression import parse - if isinstance(condition, str): condition = parse(condition) elif len(condition_arg) == 3: + lhs, cond, rhs = condition_arg + + if isinstance(lhs, str): + lhs = parse(lhs) + if isinstance(rhs, str): + rhs = parse(lhs) + from pymbolic.primitives import Comparison - condition = Comparison(*condition_arg) + condition = Comparison(lhs, cond, rhs) else: raise ValueError("Unrecognized condition expression") -- GitLab From e933529fd757d44e995027b207e86389c9a0f911 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 25 Jan 2018 13:44:25 -0600 Subject: [PATCH 3/4] Disable printing of full error message for the moment --- dagrt/codegen/fortran.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index 8c665cd..f2a96e2 100644 --- a/dagrt/codegen/fortran.py +++ b/dagrt/codegen/fortran.py @@ -2232,10 +2232,11 @@ class CodeGenerator(StructuredCodeGenerator): inst.component_id)),))) def emit_inst_Raise(self, inst): + # FIXME: Reenable emitting full error message + # TBD: Quoting of quotes, extra-long lines + self.emit("! " + inst.error_message) self.emit("write (dagrt_stderr,*) " - "'{condition}: {message}'".format( - condition=inst.error_condition.__name__, - message=inst.error_message)) + "'{condition}'".format(condition=inst.error_condition.__name__)) self.emit("stop") def emit_inst_FailStep(self, inst): -- GitLab From 9f5980e9cb1c9015f84fd3d15e4fb78ed61844b9 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 25 Jan 2018 13:47:30 -0600 Subject: [PATCH 4/4] Fix: Disable printing of full error message for the moment --- dagrt/codegen/fortran.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index f2a96e2..83cfaab 100644 --- a/dagrt/codegen/fortran.py +++ b/dagrt/codegen/fortran.py @@ -2234,7 +2234,9 @@ class CodeGenerator(StructuredCodeGenerator): def emit_inst_Raise(self, inst): # FIXME: Reenable emitting full error message # TBD: Quoting of quotes, extra-long lines - self.emit("! " + inst.error_message) + if inst.error_message: + self.emit("! " + inst.error_message) + self.emit("write (dagrt_stderr,*) " "'{condition}'".format(condition=inst.error_condition.__name__)) self.emit("stop") -- GitLab