preprocessor: fix JSON bugs. #1387
parent
a4171ad4ab
commit
e07e393642
|
@ -2600,7 +2600,7 @@ SvarIdentificationStatement::writeJsonOutput(ostream &output) const
|
|||
output << "{"
|
||||
<< "\"equation_number\": " << it->equation << ", "
|
||||
<< "\"restriction_number\": " << it->restriction_nbr << ", "
|
||||
<< "\"variable\": " << symbol_table.getName(it->variable) << ", "
|
||||
<< "\"variable\": \"" << symbol_table.getName(it->variable) << "\", "
|
||||
<< "\"expression\": \"";
|
||||
it->value->writeOutput(output);
|
||||
output << "\"}";
|
||||
|
|
|
@ -5610,15 +5610,15 @@ ExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &efout,
|
|||
|
||||
stringstream ef;
|
||||
ef << "{\"external_function\": {"
|
||||
<< "\"output\": \"TEF_" << indx << "\"";
|
||||
<< "\"external_function_term\": \"TEF_" << indx << "\"";
|
||||
|
||||
if (symb_id == first_deriv_symb_id)
|
||||
ef << ", \"output_d\": \"TEFD_" << indx << "\"";
|
||||
ef << ", \"external_function_term_d\": \"TEFD_" << indx << "\"";
|
||||
|
||||
if (symb_id == second_deriv_symb_id)
|
||||
ef << ", \"output_dd\": \"TEFDD_" << indx << "\"";
|
||||
ef << ", \"external_function_term_dd\": \"TEFDD_" << indx << "\"";
|
||||
|
||||
ef << ", \"function\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
ef << ", \"value\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
writeJsonExternalFunctionArguments(ef, temporary_terms, tef_terms);
|
||||
ef << ")\"}}";
|
||||
efout.push_back(ef.str());
|
||||
|
@ -5944,17 +5944,17 @@ FirstDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &
|
|||
stringstream ef;
|
||||
if (first_deriv_symb_id == eExtFunNotSet)
|
||||
ef << "{\"first_deriv_external_function\": {"
|
||||
<< "\"output\": \"TEFD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex << "\""
|
||||
<< "\"external_function_term\": \"TEFD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex << "\""
|
||||
<< ", \"analytic_derivative\": false"
|
||||
<< ", \"wrt\": " << inputIndex
|
||||
<< ", \"function\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
<< ", \"value\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
else
|
||||
{
|
||||
tef_terms[make_pair(first_deriv_symb_id, arguments)] = (int) tef_terms.size();
|
||||
ef << "{\"first_deriv_external_function\": {"
|
||||
<< "\"output\": \"TEFD_def_" << getIndxInTefTerms(first_deriv_symb_id, tef_terms)
|
||||
<< "\"external_function_term\": \"TEFD_def_" << getIndxInTefTerms(first_deriv_symb_id, tef_terms) << "\""
|
||||
<< ", \"analytic_derivative\": true"
|
||||
<< ", \"function\": \"" << datatree.symbol_table.getName(first_deriv_symb_id) << "(";
|
||||
<< ", \"value\": \"" << datatree.symbol_table.getName(first_deriv_symb_id) << "(";
|
||||
}
|
||||
|
||||
writeJsonExternalFunctionArguments(ef, temporary_terms, tef_terms);
|
||||
|
@ -6303,18 +6303,18 @@ SecondDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string>
|
|||
stringstream ef;
|
||||
if (second_deriv_symb_id == eExtFunNotSet)
|
||||
ef << "{\"second_deriv_external_function\": {"
|
||||
<< "\"output\": \"TEFDD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex1 << "_" << inputIndex2 << "\""
|
||||
<< "\"external_function_term\": \"TEFDD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex1 << "_" << inputIndex2 << "\""
|
||||
<< ", \"analytic_derivative\": false"
|
||||
<< ", \"wrt1\": " << inputIndex1
|
||||
<< ", \"wrt2\": " << inputIndex2
|
||||
<< ", \"function\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
<< ", \"value\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
else
|
||||
{
|
||||
tef_terms[make_pair(second_deriv_symb_id, arguments)] = (int) tef_terms.size();
|
||||
ef << "{\"second_deriv_external_function\": {"
|
||||
<< "\"output\": \"TEFDD_def_" << getIndxInTefTerms(second_deriv_symb_id, tef_terms)
|
||||
<< "\"external_function_term\": \"TEFDD_def_" << getIndxInTefTerms(second_deriv_symb_id, tef_terms) << "\""
|
||||
<< ", \"analytic_derivative\": true"
|
||||
<< ", \"function\": \"" << datatree.symbol_table.getName(second_deriv_symb_id) << "(";
|
||||
<< ", \"value\": \"" << datatree.symbol_table.getName(second_deriv_symb_id) << "(";
|
||||
}
|
||||
|
||||
writeJsonExternalFunctionArguments(ef, temporary_terms, tef_terms);
|
||||
|
|
|
@ -1334,7 +1334,8 @@ ModelTree::writeJsonTemporaryTerms(const temporary_terms_t &tt, const temporary_
|
|||
output << ", ";
|
||||
output << "{\"temporary_term\": \"";
|
||||
(*it)->writeJsonOutput(output, tt, tef_terms);
|
||||
output << " = ";
|
||||
output << "\""
|
||||
<< ", \"value\": \"";
|
||||
(*it)->writeJsonOutput(output, tt2, tef_terms);
|
||||
output << "\"}" << endl;
|
||||
wrote_term = true;
|
||||
|
@ -1567,12 +1568,15 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
|
|||
for (set<int>::const_iterator it = used_local_vars.begin();
|
||||
it != used_local_vars.end(); ++it)
|
||||
{
|
||||
if (it != used_local_vars.begin())
|
||||
output << ", ";
|
||||
int id = *it;
|
||||
expr_t value = local_variables_table.find(id)->second;
|
||||
|
||||
/* We append underscores to avoid name clashes with "g1" or "oo_" (see
|
||||
also VariableNode::writeOutput) */
|
||||
output << "{\"" << symbol_table.getName(id) << "__ = ";
|
||||
output << "{\"variable\": \"" << symbol_table.getName(id) << "__\""
|
||||
<< ", \"value\": \"";
|
||||
value->writeJsonOutput(output, tt, tef_terms);
|
||||
output << "\"}" << endl;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue