|
AndroMeta
2.0.0
|
Base class for code generators which convert M code to various target languages. More...
#include <MGenerator.h>
Public Member Functions | |
| MGenerator () | |
| virtual | ~MGenerator () |
| void | createFile (const mstr &fileName, std::ofstream &ostr) |
| void | finalizeFile (const mstr &fileName, std::ofstream &ostr) |
| void | setTarget (const mstr &target) |
| const mstr & | target () const |
| void | setDirectory (const mstr &dir) |
| const mstr & | directory () const |
| void | setDebugBuild (bool debug) |
| bool | isDebugBuild () const |
| bool | isConcise () const |
| void | setConcise (bool flag) |
| void | error (mnode n, const mstr &msg, bool warn=false) |
| int | status () const |
| void | setStatus (int status) |
| void | setMessagePrefix (const mstr &prefix) |
| virtual void | clear ()=0 |
Static Public Member Functions | |
| static int | precedence (const mstr &functionName) |
| static bool | isStandardError (const mstr &errorName) |
| static mstr | formatMCode (mnode n, const mstr &indent="") |
Base class for code generators which convert M code to various target languages.
The MGenerator provides various features which facilitate the conversion of M code to target languages. Code generation is highly language specific, however this class addresses issues common to most generators such as managing code files, operator precedence, and various common options that control the generation process.
Constructor.
| virtual Meta::MGenerator::~MGenerator | ( | ) | [virtual] |
Destructor.
| virtual void Meta::MGenerator::clear | ( | ) | [pure virtual] |
Interface to clear the generators inputs.
Implemented in Meta::MMLGenerator.
| void Meta::MGenerator::createFile | ( | const mstr & | fileName, |
| std::ofstream & | ostr | ||
| ) |
Create an output file and associate it with an output stream.
| fileName | Filename to create in the target directory. |
| ostr | Output stream that the generator will write to. |
| const mstr& Meta::MGenerator::directory | ( | ) | const |
Get the project target directory in which source files are generated.
| void Meta::MGenerator::error | ( | mnode | n, |
| const mstr & | msg, | ||
| bool | warn = false |
||
| ) |
Display an error or warning message with filename and line number.
| n | The node from which to extract filename and line number. |
| msg | Error or warning message. |
| warn | true if this is warning message and not an error. An error sets status to non-zero while a warning does not change status. |
| void Meta::MGenerator::finalizeFile | ( | const mstr & | fileName, |
| std::ofstream & | ostr | ||
| ) |
Finalize a file and output stream. Output files are not written directly to the target directory, they are first finalized in a temporary location and moved to the target directory whenever changes occur. This was designed with the make command in mind such that only those files with actual code changes get updated and recompiled.
| fileName | Filename to be finalized. |
| ostr | Output stream to finalize. |
| static mstr Meta::MGenerator::formatMCode | ( | mnode | n, |
| const mstr & | indent = "" |
||
| ) | [static] |
Format M code using block indentation.
| n | M code. |
| indent | Current indentation level. |
| bool Meta::MGenerator::isConcise | ( | ) | const |
Concise mode does not write out numerics to their full precision.
| bool Meta::MGenerator::isDebugBuild | ( | ) | const |
| static bool Meta::MGenerator::isStandardError | ( | const mstr & | errorName | ) | [static] |
| static int Meta::MGenerator::precedence | ( | const mstr & | functionName | ) | [static] |
Get the relative precedence of a function/operator.
| functionName | The M function name, e.g: "Pow" or "Add" |
| void Meta::MGenerator::setConcise | ( | bool | flag | ) |
Set concise mode. If concise, then do not write out numerics to their full precision.
| void Meta::MGenerator::setDebugBuild | ( | bool | debug | ) |
Set debug build mnode (for generators where this is appropriate).
| void Meta::MGenerator::setDirectory | ( | const mstr & | dir | ) |
Set the project target directory in which source files are generated.
| void Meta::MGenerator::setMessagePrefix | ( | const mstr & | prefix | ) |
Set a message to be prepended to error and warning messages. Default is empty string.
| void Meta::MGenerator::setStatus | ( | int | status | ) |
Set the status of the generation process.
| void Meta::MGenerator::setTarget | ( | const mstr & | target | ) |
Set the target executable.
| int Meta::MGenerator::status | ( | ) | const |
| const mstr& Meta::MGenerator::target | ( | ) | const |
Get the target executable.
1.7.6.1