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::MCPPGenerator Meta::MMGenerator 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)

Static Public Member Functions

static int precedence (const mstr &functionName)
static bool isStandardError (const mstr &errorName)
static mstr formatMCode (mnode n, const mstr &indent="", bool squareBraces=false)

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

Meta::MGenerator::MGenerator (  ) 

Constructor.

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

Destructor.


Member Function Documentation

void Meta::MGenerator::createFile ( const mstr fileName,
std::ofstream &  ostr 
)

Create an output file and associate it with an output stream.

Parameters:
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.

Parameters:
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.

Parameters:
fileName Filename to be finalized.
ostr Output stream to finalize.
static mstr Meta::MGenerator::formatMCode ( mnode  n,
const mstr indent = "",
bool  squareBraces = false 
) [static]

Format M code using block indentation.

Parameters:
n M code.
indent Current indentation level.
squareBraces Use square braces instead of parentheses.
bool Meta::MGenerator::isConcise (  )  const

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

Returns:
true if generator is in concise mode.
bool Meta::MGenerator::isDebugBuild (  )  const
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:
functionName The 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::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:

Generated on Wed Mar 24 16:22:42 2010 for AndroMeta by  doxygen 1.6.1