AndroMeta  2.0.0
Public Member Functions | Static Public Member Functions
Meta::MGenerator Class Reference

Base class for code generators which convert M code to various target languages. More...

#include <MGenerator.h>

Inheritance diagram for Meta::MGenerator:
Meta::MProcessor Meta::MMLGenerator

List of all members.

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 mstrtarget () const
void setDirectory (const mstr &dir)
const mstrdirectory () 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="")

Detailed Description

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 & Destructor Documentation

Constructor.

virtual Meta::MGenerator::~MGenerator ( ) [virtual]

Destructor.


Member Function Documentation

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.

Parameters:
fileNameFilename to create in the target directory.
ostrOutput stream that the generator will write to.

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.

Parameters:
nThe node from which to extract filename and line number.
msgError or warning message.
warntrue 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.

Parameters:
fileNameFilename to be finalized.
ostrOutput stream to finalize.
static mstr Meta::MGenerator::formatMCode ( mnode  n,
const mstr indent = "" 
) [static]

Format M code using block indentation.

Parameters:
nM code.
indentCurrent indentation level.

Concise mode does not write out numerics to their full precision.

Returns:
true if generator is in concise mode.
Returns:
Whether debug build mode is enabled (for generators where this is appropriate).
static bool Meta::MGenerator::isStandardError ( const mstr errorName) [static]
Returns:
True if this is a standard error/exception type, e.g: "MParamError"
static int Meta::MGenerator::precedence ( const mstr functionName) [static]

Get the relative precedence of a function/operator.

Parameters:
functionNameThe M function name, e.g: "Pow" or "Add"
Returns:
a positve integer giving the relative precedence of functionName, with lower values indicating higher precedence.
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
Returns:
The current status of the generation process with 0 indicating no error.
const mstr& Meta::MGenerator::target ( ) const

Get the target executable.


The documentation for this class was generated from the following file: