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