From 297f86a90ec81ef8f806bd25b85e11728c60c2dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 24 Jun 2022 16:43:16 +0200
Subject: [PATCH] NumConstNode::write{Bytecode,Json}Output(): check for
 temporary terms, as is done for MATLAB output

---
 src/ExprNode.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/ExprNode.cc b/src/ExprNode.cc
index 33ce6721..a295ba11 100644
--- a/src/ExprNode.cc
+++ b/src/ExprNode.cc
@@ -461,7 +461,10 @@ NumConstNode::writeJsonOutput(ostream &output,
                               const deriv_node_temp_terms_t &tef_terms,
                               bool isdynamic) const
 {
-  output << datatree.num_constants.get(id);
+  if (temporary_terms.contains(const_cast<NumConstNode *>(this)))
+    output << "T" << idx;
+  else
+    output << datatree.num_constants.get(id);
 }
 
 bool
@@ -482,7 +485,8 @@ NumConstNode::writeBytecodeOutput(BytecodeWriter &code_file, bool lhs_rhs,
                                   const temporary_terms_idxs_t &temporary_terms_idxs, bool dynamic, bool steady_dynamic,
                                   const deriv_node_temp_terms_t &tef_terms) const
 {
-  code_file << FLDC_{datatree.num_constants.getDouble(id)};
+  if (!checkIfTemporaryTermThenWriteBytecode(code_file, temporary_terms, temporary_terms_idxs, dynamic))
+    code_file << FLDC_{datatree.num_constants.getDouble(id)};
 }
 
 void
-- 
GitLab