preprocessor: write JSON output for original model when writing after transform pass
parent
170d90bd84
commit
3938381e99
|
@ -849,11 +849,12 @@ format. If @code{parse} is passed, then the output will be written after the
|
||||||
parsing step in a file called @file{@var{FILENAME}.mod}. If @code{transform} is
|
parsing step in a file called @file{@var{FILENAME}.mod}. If @code{transform} is
|
||||||
passed, the JSON output of the transformed model (maximum lead of 1, minimum
|
passed, the JSON output of the transformed model (maximum lead of 1, minimum
|
||||||
lag of -1, expectation operators substituted, etc.) will be written after the
|
lag of -1, expectation operators substituted, etc.) will be written after the
|
||||||
transform pass in a file called @file{@var{FILENAME}.mod}. And if
|
transform pass in a file called @file{@var{FILENAME}.mod} and the original,
|
||||||
@code{compute} is passed, the output is written after the computing pass. Here,
|
untransformed model will be written in @file{@var{FILENAME}_original.mod}. And
|
||||||
the transformed model is written to @file{@var{FILENAME}.mod}, the original
|
if @code{compute} is passed, the output is written after the computing
|
||||||
model is written to @file{@var{FILENAME}_original.mod}, and the dynamic and
|
pass. Here, the transformed model is written to @file{@var{FILENAME}.mod}, the
|
||||||
static files are written to @file{@var{FILENAME}_dynamic.mod} and
|
original model is written to @file{@var{FILENAME}_original.mod}, and the
|
||||||
|
dynamic and static files are written to @file{@var{FILENAME}_dynamic.mod} and
|
||||||
@file{@var{FILENAME}_static.mod}.
|
@file{@var{FILENAME}_static.mod}.
|
||||||
|
|
||||||
@item jsonstdout
|
@item jsonstdout
|
||||||
|
|
|
@ -1270,7 +1270,7 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF
|
||||||
if (json == parsing || json == checkpass)
|
if (json == parsing || json == checkpass)
|
||||||
symbol_table.freeze();
|
symbol_table.freeze();
|
||||||
|
|
||||||
writeJsonOutputParsingCheck(basename, json_output_mode);
|
writeJsonOutputParsingCheck(basename, json_output_mode, json == transformpass);
|
||||||
|
|
||||||
if (json == parsing || json == checkpass)
|
if (json == parsing || json == checkpass)
|
||||||
symbol_table.unfreeze();
|
symbol_table.unfreeze();
|
||||||
|
@ -1302,7 +1302,7 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode) const
|
ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass) const
|
||||||
{
|
{
|
||||||
ostringstream output;
|
ostringstream output;
|
||||||
output << "{" << endl;
|
output << "{" << endl;
|
||||||
|
@ -1325,8 +1325,21 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
||||||
}
|
}
|
||||||
output << "}" << endl;
|
output << "}" << endl;
|
||||||
|
|
||||||
|
ostringstream original_model_output;
|
||||||
|
original_model_output << "";
|
||||||
|
if (transformpass)
|
||||||
|
{
|
||||||
|
original_model_output << "{";
|
||||||
|
original_model.writeJsonOriginalModelOutput(original_model_output);
|
||||||
|
original_model_output << "}" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (json_output_mode == standardout)
|
if (json_output_mode == standardout)
|
||||||
cout << output.str();
|
{
|
||||||
|
cout << output.str();
|
||||||
|
if (!original_model_output.str().empty())
|
||||||
|
cout << original_model_output.str();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ofstream jsonOutputFile;
|
ofstream jsonOutputFile;
|
||||||
|
@ -1350,6 +1363,29 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
||||||
|
|
||||||
jsonOutputFile << output.str();
|
jsonOutputFile << output.str();
|
||||||
jsonOutputFile.close();
|
jsonOutputFile.close();
|
||||||
|
|
||||||
|
if (!original_model_output.str().empty())
|
||||||
|
{
|
||||||
|
if (basename.size())
|
||||||
|
{
|
||||||
|
string fname(basename);
|
||||||
|
fname += "_original.json";
|
||||||
|
jsonOutputFile.open(fname.c_str(), ios::out | ios::binary);
|
||||||
|
if (!jsonOutputFile.is_open())
|
||||||
|
{
|
||||||
|
cerr << "ERROR: Can't open file " << fname << " for writing" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cerr << "ERROR: Missing file name" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonOutputFile << original_model_output.str();
|
||||||
|
jsonOutputFile.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ private:
|
||||||
//! Warnings Encountered
|
//! Warnings Encountered
|
||||||
WarningConsolidation &warnings;
|
WarningConsolidation &warnings;
|
||||||
//! Functions used in writing of JSON outut. See writeJsonOutput
|
//! Functions used in writing of JSON outut. See writeJsonOutput
|
||||||
void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode) const;
|
void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass) const;
|
||||||
void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonprintderivdetail) const;
|
void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonprintderivdetail) const;
|
||||||
void writeJsonFileHelper(string &fname, ostringstream &output) const;
|
void writeJsonFileHelper(string &fname, ostringstream &output) const;
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue