CompileDES  3.13
Executable-Code Generation from Synchronised libFAUDES Automata

Code-generation common base. More...

#include <cgp_codegenerator.h>

Inheritance diagram for CodeGenerator:
Inheritance graph

Classes

struct  ActionAddress
 Compiled record per action-address. More...
 
struct  FlagExpression
 Compiled record per input flag-expression. More...
 
struct  LineAddress
 Compiled record per input line. More...
 
class  Registration
 Registration class. More...
 
class  TimerAction
 Compiled record per event on how it affects timers. More...
 
struct  TimerConfiguration
 Compiled record per timer acting. More...
 

Public Types

enum  OutSink { CONSOLE , FILE , STRING }
 

Protected Member Functions

virtual void DoCompile (void)
 virtual hook to input parameter compilation
 
virtual void DoGenerate (void)=0
 pure virtual interface to code generation
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read the configuration from TokenReader, see faudes Type for public wrappers. More...
 
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Writes the configuration to TokenWriter, see faudes Type for public wrappers. More...
 
virtual void DoReadTargetConfiguration (TokenReader &rTr)
 Reads global configuration from TokenReader, excl. More...
 
virtual void DoWriteTargetConfiguration (TokenWriter &rTw) const
 Write global configuration to TokenWriter, excl. More...
 

Protected Attributes

std::string mName
 faudes object name (aka project name)
 
std::vector< TimedGenerator > mGenerators
 list of executors
 
std::vector< std::string > mGeneratorNames
 list of filenames when generator are read from file
 
cgEventSet mAlphabet
 event configuration by attributes
 
int mWordSize
 compressed boolean capacity of target type word
 
int mIntegerSize
 compressed boolean capacity of target type integer
 
std::map< Idx, int > mEventBitAddress
 mapping from faudes event idx to bit address (descending priority, range 0 . More...
 
std::map< int, Idx > mEventFaudesIdx
 mapping from bit address to faudes event idx

 
int mLastInputEvent
 highest bit-address with input (or timer) event (-1 for none)
 
int mLastOutputEvent
 highest bit-address with output event (-1 for none)
 
std::vector< std::map< Idx, int > > mStateVectorAddress
 mapping from faudes state idx to vector index
 
std::vector< std::map< int, Idx > > mStateFaudesIndex
 mapping from vector state idx to faudes index
 
std::vector< bool > mUsingVectorAddressStates
 configuration of state indexing per generator
 
std::vector< std::vector< int > > mTransitionVector
 compiled transition-sets, represented as vectors of integers with 0 as separator
 
EventSet mUsedEvents
 configured events that are referred to by some generator
 
EventSet mOutputEvents
 used events that are configured as outputs
 
EventSet mInputEvents
 used events that are configured as inputs (incl timer)
 
EventSet mInternalEvents
 used events that are configured as internal events (excl. More...
 
std::map< std::string, LineAddressmLines
 input event generation
 
std::map< std::string, FlagExpressionmFlags
 input event generation
 
std::map< std::string, TimerConfigurationmTimers
 timer definitions
 
std::map< std::string, ActionAddressmActionAddresses
 action addresses
 
std::map< std::string, TimerActionmTimerActions
 timer actions by event name
 
int mVerbLevel
 diagnpstic-output level

 
std::string mOutMode
 output file name (base)
 
char mMuteMode
 current output mode
 
bool mMuteComments
 mute comments
 
std::string mRecentMutedComment
 recent muted comment

 
std::ostream * pOutStream
 output stream
 
std::ostream * pErrStream
 error stream
 

Configuration – Generators

Generators are internally organised as a vector. There is a programatic read-only interface with Size() and At() as well as Begin() and End() iterators. Insert methods amount to a "push_back". Individual removal of generators is currently not supported, use Clear() for a consistent reset.

typedef std::vector< TimedGenerator >::const_iterator Iterator
 Iterator for read-only access of generators.
 
Idx Size (void) const
 Number of generators.
 
void Insert (const std::string &file)
 Add a Generator from file. More...
 
void Insert (const TimedGenerator &rGen)
 Add a generator by reference. More...
 
const TimedGenerator & At (int i) const
 Direct access for read-only access of generators.
 
Iterator Begin (void) const
 Begin-iterator for read-only access of generators.
 
Iterator End (void) const
 End-iterator for read-only access of generators.
 

Compiled Data – Eventsets

Faudes-EventSets are alternatively represented as boolean vectors. Each individual event has a bit-address to specify the location of the corresponding boolean value in the vector. By convention, bit-addresses start with 0. To facilitate event scheduling, events are ordered by descending priority. Implicitly, this also associates with each event a consecutive target event index, starting with 1.

Example for an overall amount of 9 events and the faudes and the event set {3,6,9}

 faudes Idx:    1 4 5 6 3 2 8 9 7   (typically this is consecutive but not ordered by priority)
 target Idx:    1 2 3 4 5 6 7 8 9   (consecutive and ordered by priority)
 bit-address:   0 1 2 3 4 5 6 7 8   (corresponding bit address)
 vector value:  0 0 0 1 1 0 0 1 0   (vector for the set {3,6,9})

Regarding efficiency of the generated code, the target platform typically represent boolean vectors as as word-arrays. Continuing the above example for a word-size of 4bits we obtain the correspondence.

 bit-address:   0  1  2  3  4  5  6  7  8  -  -  -
 word index:   [  word 0  ][  word 1  ][   word 2  ]   (reading "lsb on left hand side")


typedef unsigned long word_t
 Code-generator internal data type of target words.
 
std::vector< int > mWordAddressVector
 Look-up table to map a bit-address to the word-index.
 
std::vector< word_tmBitMaskVector
 Look-up table to map a bit-address to the word-bitmask.
 
virtual int EventTargetIdx (Idx idx)
 Get target event Idx from faudes Idx (use bit-address + 1)
 
virtual int EventTargetIdx (const std::string &ev)
 Get target event Idx from faudes name (use bit-address + 1)
 
int EventBitAddress (Idx idx)
 Get event bit-address from faudes Idx (consecutive, starts at 0)
 
Idx EventFaudesIdx (int idx)
 Get faudes Idx from target Idx (aka from bit-address + 1)
 
std::vector< bool > EventBitMask (Idx idx)
 Get vector representation for a single faudes event Idx.
 
std::vector< bool > EventBitMask (const EventSet &eset)
 Get vector representation for faudes event set.
 
int EventBitMaskSize (void)
 Get overall number of events.
 
word_t WordFromBitVector (const std::vector< bool > &vect, int wordindex)
 Extract individual word from boolean vector.
 
std::vector< word_tWordVectorFromBitVector (const std::vector< bool > &vect)
 Convert boolean vector to word array.
 

Compiled Data – Generation of Events by Input Lines, Flags and Timers

For each line-level that is relevant for edge detection, a record is kept that accumulates all events that an edge of the respective line must generate. The data set is formally implemented as map with the line address as the key. Similarly, a record for event triggering flag-expressions and timers is kept. For the actual data structures, see LineAddress, FlagExpression and TimerConfiguration, respectively.

typedef std::map< std::string, LineAddress >::iterator LineIterator
 Access to line records by iterator.
 
typedef std::map< std::string, FlagExpression >::iterator FlagIterator
 Access to flag records by iterator.
 
typedef std::map< std::string, TimerConfiguration >::iterator TimerIterator
 Access to timer records by iterator.
 
LineIterator LinesBegin ()
 Access to line records by iterator.
 
LineIterator LinesEnd ()
 Access to line records by iterator.
 
FlagIterator FlagsBegin ()
 Access to flag records by iterator.
 
FlagIterator FlagsEnd ()
 Access to flag records by iterator.
 
TimerIterator TimersBegin ()
 Access to timer records by iterator.
 
TimerIterator TimersEnd ()
 Access to timer records by iterator.
 

Compiled Data – Effects of Events to Output Lines, Flags and Timers

For each abstract target address listed in an action we maintain a record whether it is set or cleared (i.e. interpreted as an address of a boolean type) or executed (i.e. whether is is an an address of a function or an assignment expression, depending on what the target supports). Similarly, we record on a per event basis, which timers are to be started/stoped/reset.

typedef std::map< std::string, ActionAddress >::iterator ActionAddressIterator
 Access to action record by iterator.
 
typedef std::map< std::string, TimerAction >::iterator TimerActionIterator
 Access to timer records by iterator.
 
ActionAddressIterator ActionAddressesBegin ()
 Access to action addresses by iterator.
 
ActionAddressIterator ActionAddressesEnd ()
 Access to action addresses by iterator.
 
TimerActionIterator TimerActionsBegin ()
 Access to timer records by iterator.
 
TimerActionIterator TimerActionsEnd ()
 Access to timer records by iterator.
 

Basic Class Maintenance

Basic class maintenance methods to construct/destruct CodeGenerator objects and compile the configuration to an alternative representation. Note that the interface for file i/o of configuration data is inherited from faudes::Type.

 CodeGenerator (void)
 Constructor.
 
virtual ~CodeGenerator (void)
 Destructor.
 
virtual void Clear (void)
 Clear all data. More...
 
virtual void Name (const std::string &rName)
 Set objects's name (reimplementing base faudes::Type) More...
 
virtual const std::string & Name (void) const
 Get objects's name (reimplementing base faudes::Type) More...
 
virtual void Compile (void)
 Compile input data for alternative representation. More...
 
static std::string VersionString (void)
 Version (refers to macro COMPILEDES_VERSION, defined in cgp_codegenerator.h)
 

Configuration – Alphabet

The overall alphabet amounts to the union of all provided generator alphabets, augmented by the event attributes for execution semantics; see cgEventSet for details. The external interface provides symbolic name and index look-up, both referring to the faudes-global symbol table and faudes event indices. There are also setters/getters to edit individual attributes. attribute type.

Idx EventIndex (const std::string &rName) const
 Faudes-event index lookup. More...
 
std::string EventName (Idx index) const
 Faudes-event name lookup. More...
 
const AttributeCodeGeneratorEventEventAttribute (Idx ev) const
 Event configuration attribute lookup. More...
 
void EventAttribute (Idx ev, const AttributeCodeGeneratorEvent &attr)
 Set event attribute. More...
 
void Alphabet (const cgEventSet &rAlphabet)
 Set all event attributes. More...
 
const cgEventSetAlphabet (void) const
 Access alphabet (incl event attributes) More...
 

Compiled Data – Transition Relation

As an optional form of representation, transition relations are compiled to integer vectors. Each state corresponds to a particular segment of the vector to hold pairs or events and successor states. The end of each Segment is flagged by the invalid event index zero.

Example for {q1-(1)->q1; q1-(3)->q2; q2-(1)->q3; q3-(4)->q3; q3-(2)->q1; q3-(1)->q2};

Vector index:      0  1  2  3  4  5  6  7  8  9  10 11 12 13 14
Current state:     q1             q2       q3
Successor/Event:   ev q1 ev q2 || ev q3 || ev q3 ev q1 ev q2 ||
Vector value:      1  0  3  5  0  1  8  0  4  8  2  0  1  5  0

Note that the event indices are target indices (priority sorted, starting from 1, consecutive). When this scheme is used, it implicitly defines target state indices to be transition-vector indices (starting by 0, however non-consecutive).

As a variation, one may maintaine the original state indices by using an indirect andress scheme. This option is useful when the original state indices are relevant fo state-update hooks an symbolic state names. Example:

Vector index:      0  1  2  3  4  5  6  7  8  9  10 11 12 13 14
Current state:     q1             q2       q3
Successor/Event:   ev q1 ev q2 || ev q3 || ev q3 ev q1 ev q2 ||
Transition vector: 1  1  3  2  0  1  3  0  4  3  2  1  1  2  0
Address vector:    0  0  5  8
const std::vector< int > & TransitionVector (size_t git)
 Get target state index (refer to vector representation as default, overload in CodePrimitives)
 
virtual int StateTargetIdx (size_t git, Idx idx)
 Get target state index (refer to vector representation as default, overload in CodePrimitives)
 
virtual Idx StateFaudesIdx (size_t git, int idx)
 Get faudes state index (refer to vector representation as default, overload in CodePrimitives)
 

Code Generation Interface

Although the base class does not generate any code, it provides a common external interface, i.e., a GodeGenerator application may uniformly generate code regardless of the particular target; see also compiledes.cpp. In support of derived classes, CodeGenerator also provides an interface for the output of the actual code either to console, a string or a file.

virtual void Generate (void)
 Generate code. More...
 
void Verbose (int level, std::ostream *altout=0)
 Set verbosity level. More...
 
virtual void OutputMode (const std::string &mode)
 Set code output mode. More...
 
std::string OutputMode (void)
 Report code output mode. More...
 
virtual std::ostream & Output (void)
 Output stream. More...
 
const std::string & OutputString (void)
 Get accumulated output as string. More...
 
void OutputString (const std::string &strbuf)
 Set output to string. More...
 
virtual void MuteMode (char mode)
 Set current mute mode. More...
 
virtual void MuteCond (char mode)
 Set mode condition. More...
 
virtual void LineFeed (int lines=1)
 LineFeed (convenience support for derived classes)
 
virtual std::string LineCount (void)
 LineFeed (convenience support for derived classes)
 
virtual void IndentInc ()
 Indentation (convenience support for derived classes)
 
virtual void IndentDec ()
 Indentation (convenience support for derived classes)
 
virtual void Comment (const std::string &text)
 Write a comment (reimplement in derived classes, call base)
 
std::string RecentComment (void)
 Recent muted comment (convenience support for derived classes)
 
virtual void XmlTextEscape (bool on)
 XmlTextEscape (escape "<", ">", "&", "\"" and "'")
 
virtual void XmlCdataEscape (bool on)
 XmlCdataEscape (escape "]]>")
 
virtual void MuteComments (bool on)
 Mute comments (convenience support for derived classes)
 
virtual void MuteVspace (bool on)
 Mute empty lines (convenience support for derived classes)
 

Code-Generator Registry

Derived classes register via a static registration mechanism to provide an application-invokable constructor. The static registry records the constructor with a std::string typename as identifier. The purpose of this mechanism is to instantiate derived classes by their identifier at runtime.E.g.

Code-generation common base.
static CodeGenerator * New(const std::string &type)
Instantiate by identifier (returns 0 on unknown class)

instantiates a CodeGenerator object of the type registered by "iec". See the command-line tool compiledes.cpp for a relevant use case.

Registration can be conveniently triggered by instantiation of a CodeGenerator::Registration object via the provided macro. E.g. in the source that defines the class IecCodeGenerator

FAUDES_REGISTERCODEGENERATOR("iec",IecCodeGenerator);
#define FAUDES_REGISTERCODEGENERATOR(ftype, ctype)
Class registration macro.

is used to register the respective class with the identifier "iec".

static void Register (const std::string &type, CodeGenerator *(*newcg)(void))
 Insert derived class in the registry. More...
 
static std::vector< std::string > Registry (void)
 Access registry contents. More...
 
static CodeGeneratorNew (const std::string &type)
 Instantiate by identifier (returns 0 on unknown class) More...
 

Detailed Description

The code-generator base class maintains the configuration data common to libFAUDES code generators. To this end, the configuration consists of

  • a list of generators
  • event attributes to specify execution semantics per event

The CodeGenerator implements file i/o of its configuration via the FAUDES type interface Read()/Write() and provides the virtual member functions DoReadTargetConfiguration()/DoWriteTargetConfiguration() for derived classes to add additional configuration features.

There is also a programatic interface to Insert(Generator&) generators and to access individual generators with At(). Likewise, there are setters and getters to access event attributes; see also AttributeCodeGeneratorEvent.

The CodeGenerator provides the method Compile() to convert the configuration data to an alternative representation tailored for code generation. E.g., it extracts a map of line levels to be monitored for edge detection by collecting all lines used by any event. The base class currently implements the below data structures, which can be extended for derived classes my the virtual member-function interface DoCompile().

  • map configuration events to consecutive target event indices ordered by execution priority
  • translate sets of configuration events to boolean vectors or bit-mask word-arrays.
  • map configuration state indices to consecutive target state indices
  • collection of all relevant input line addresses with associated trigger configuration
  • collection of all relevant flags used in exec-triggers
  • a collection of all addresses relevant for output actions

Code generation is triggered by Generate() with the virtual interface DoGenerate(). In this base class, DoGenerate() does nothing, i.e., to obtain a functional code generator, re-implement the method DoGenerate() in a derived class. See CodePrimitives() for the next level of specialisation.

Technical Detail: we use faudes Type as base for serialisation only. Assignment and copy constructor are not implemented.

File format by example. See also AttributeCodeGeneratorEvent for the configuration of individual events.

 <CodeGenerator name="blink">

 % 1. specify generators (either explicitly or by filename)
 <Generators>
 <Generator name="blink1">
 [.. libFAUDES generator format ..]
 </Generator>
 [.. more generators ..]
 </Generators>

 % 2. specify event configuration
 <EventConfiguration>
 <Event name="led_on">
 [.. event attribute in AttributeCodeGeneratorEvent format ..]
 </Event>
 [.. more events ..]
 </EventConfiguration>

 % 3. target specific configuration
 <TargetConfiguration>
 [.. as provided by derived classes ..]
 </TargetConfiguration>

 </CodeGenerator>

Definition at line 106 of file cgp_codegenerator.h.


Class Documentation

◆ CodeGenerator::ActionAddress

struct CodeGenerator::ActionAddress

Definition at line 538 of file cgp_codegenerator.h.

Class Members
string mAddress target address as specified in configuration
bool mSetClr is a set/clr type of address
bool mExe is an executable type of address

◆ CodeGenerator::FlagExpression

struct CodeGenerator::FlagExpression

Definition at line 489 of file cgp_codegenerator.h.

Class Members
string mAddress target expression to represent the line value
EventSet mEvents events to trigger on positive evaluation

◆ CodeGenerator::LineAddress

struct CodeGenerator::LineAddress

Definition at line 472 of file cgp_codegenerator.h.

Class Members
string mAddress
int mBitAddress target expression to represent line value
EventSet mPosEvents bit-address of buffer for edge detection (consecutive)
EventSet mNegEvents events to trigger on positive edge
EventSet mPosStatics events to trigger on negative edge
EventSet mNegStatics events to trigger on high power on
bool mStatic events to trigger on low power on

◆ CodeGenerator::TimerConfiguration

struct CodeGenerator::TimerConfiguration

Definition at line 504 of file cgp_codegenerator.h.

Class Members
string mAddress target address prefix to maintain timer state
string mElapseEvent event to trigger on timer elapse
string mInitialValue target representation of initial value
EventSet mStartEvents start events as in AttributeCodeGeneratorEvent
EventSet mStopEvents stop events as in AttributeCodeGeneratorEvent
EventSet mResetEvents reset events as in AttributeCodeGeneratorEvent

Member Function Documentation

◆ Clear()

void CodeGenerator::Clear ( void  )
virtual

Derived classes must implement this to reset ALL configuration data to consistent defaults.

Reimplemented in PlcoxmlCodeGenerator, KinetisCodeGenerator, Iec61131stCodeGenerator, GebtoolsCodeGenerator, EmbeddedcCodeGenerator, CodePrimitives, and ATmegaCodeGenerator.

Definition at line 69 of file cgp_codegenerator.cpp.

◆ Name() [1/2]

virtual void CodeGenerator::Name ( const std::string &  rName)
inlinevirtual
Parameters
rNameName

Definition at line 156 of file cgp_codegenerator.h.

◆ Name() [2/2]

virtual const std::string& CodeGenerator::Name ( void  ) const
inlinevirtual
Returns
Name of generator

Definition at line 164 of file cgp_codegenerator.h.

◆ Compile()

void CodeGenerator::Compile ( void  )
virtual

The designated hook for reimplementation is the also virtual "DoCompile()". Do not reimplement Compile() itself, since is resets internal data structures.

Definition at line 259 of file cgp_codegenerator.cpp.

◆ Insert() [1/2]

void CodeGenerator::Insert ( const std::string &  file)

This method uses the Generator's read to find the first generator in the specified file.

Parameters
fileFile to read
Exceptions
Exception
  • non-deterministic generator (id 501)
  • token mismatch (id 502)
  • IO errors (id 1)

Definition at line 79 of file cgp_codegenerator.cpp.

◆ Insert() [2/2]

void CodeGenerator::Insert ( const TimedGenerator &  rGen)

A copy of the references generator will be inserted to the internal data-structures.

Parameters
rGenGenerator to add
Exceptions
Exception
  • non-deterministic generator (id 501)

Definition at line 93 of file cgp_codegenerator.cpp.

◆ EventIndex()

Idx CodeGenerator::EventIndex ( const std::string &  rName) const
inline
Parameters
rNameName of event to lookup
Returns
Valid index or 0 if non-existent

Definition at line 278 of file cgp_codegenerator.h.

◆ EventName()

std::string CodeGenerator::EventName ( Idx  index) const
inline
Parameters
indexIndex of event to look up
Returns
Name or empty std::string if non-existent

Definition at line 289 of file cgp_codegenerator.h.

◆ EventAttribute() [1/2]

const AttributeCodeGeneratorEvent& CodeGenerator::EventAttribute ( Idx  ev) const
Parameters
ev
Returns
Reference to respective attribute

◆ EventAttribute() [2/2]

void CodeGenerator::EventAttribute ( Idx  ev,
const AttributeCodeGeneratorEvent attr 
)
Parameters
evEvent index
attrNew attribute
Exceptions
ExceptionIndex not found in EventSymbolMap (id 42)

◆ Alphabet() [1/2]

void CodeGenerator::Alphabet ( const cgEventSet rAlphabet)

Any previous attributes are removed. Any events not in rAlphabet will have the default attribute attached (which is priority 0)

Parameters
rAlphabetEventSet with AttributeCodeGeneratorEvent data

◆ Alphabet() [2/2]

const cgEventSet& CodeGenerator::Alphabet ( void  ) const
inline
Returns
Overall alphabet

Definition at line 331 of file cgp_codegenerator.h.

◆ Generate()

void CodeGenerator::Generate ( void  )
virtual

doxygen group

This method sets up the output stream and triggers actual code generation by invoking the virtual method DoGenerate(). To adapt output facilities, reimplement Generate() to set up the protected variable pOutStream appropriately, then invoke the base class method. To adapt code-generation, reimplement DoGenerate() or, preferably, its building blocks; see also Implementation Outline.

Must invoke Compile() before Generate()

Definition at line 665 of file cgp_codegenerator.cpp.

◆ Verbose()

void CodeGenerator::Verbose ( int  level,
std::ostream *  altout = 0 
)

Progress report and compilation details are forwarded to std::cerr by default. Supported levels are "0<>warnings only", "1<>verbose", "2<>very verbose". Diagnostic outpost is conveniently organised by the macros FCG_VERB0,FCG_VERB1 and FCG_VERB2 defined at the top of this file.

Definition at line 645 of file cgp_codegenerator.cpp.

◆ OutputMode() [1/2]

virtual void CodeGenerator::OutputMode ( const std::string &  mode)
inlinevirtual

Code can be output to the console (mode="std::cout"), a string buffer (mode=="std::string") or a file (mode amounts to the filename). The default behaviour is console output. Code generators that produce multiple output files will interprete a provided file name as base and append appropriate suffixes.

Code generators that only support specific output modes should reimplement this virtual function to enforce the respective constrains and/or to issue warning messages,

Parameters
filebase(Base)name of output file(s)

Definition at line 651 of file cgp_codegenerator.h.

◆ OutputMode() [2/2]

std::string CodeGenerator::OutputMode ( void  )
inline

See the corresponding setter OutputFile(const std::string&)

Definition at line 660 of file cgp_codegenerator.h.

◆ Output()

std::ostream & CodeGenerator::Output ( void  )
virtual

This stream is setup by Generate() to operate in the specified mode. To this end, CodeGenerator uses a filtered stream that provides various features like line counting, XML escape, and mute modes to support multi-pass code generation. The interface to these extra features is via the CodeGenerator class. For the standard C++ formating features, Output() is a plain std::ostream reference.

Derived classes may use more advanced output facilities, however, they are meant to reimplement at least line count and mute by the interface via the class CodeGenerator.

Definition at line 691 of file cgp_codegenerator.cpp.

◆ OutputString() [1/2]

const std::string & CodeGenerator::OutputString ( void  )

Returns the output generatedd so far as string. This is only functional when initialised with output mode "std::string".

Technical Note: the return value is a reference to an object owned by the internal output buffer; the reference becomes invalid at the next invokation of Generate() or at the destruction of the base class object.

Definition at line 695 of file cgp_codegenerator.cpp.

◆ OutputString() [2/2]

void CodeGenerator::OutputString ( const std::string &  strbuf)

Overwrites any output generated so far. This is only functional when initialised with output mode "std::string".

Definition at line 701 of file cgp_codegenerator.cpp.

◆ MuteMode()

void CodeGenerator::MuteMode ( char  mode)
virtual

Subsequent output is muted if the current mute condition does not match the mute mode. The default mute mode is '*' and matches any mute condition; see below MuteCond(char). Setting a mode other than '*' mutes the output until the condition matches the mode; see also MuteCond(char).

By convention, low-level output-generating functions use MuteCond(char) to insist in a particular global mute state which in turn is set via MuteMode(char) by some higher level function that controls a larger code fragment. This mechanism is meant to faciltate simple multi-pass code generation; see GebtoolsCodeGenerator for an example.

Definition at line 708 of file cgp_codegenerator.cpp.

◆ MuteCond()

void CodeGenerator::MuteCond ( char  mode)
virtual

Subsequent output is muted if the current mute mode does not match the condition. The default behaviour is the condition '*' which matches any mode, so no muting takes place. See also MuteMode(char).

Definition at line 716 of file cgp_codegenerator.cpp.

◆ Register()

void CodeGenerator::Register ( const std::string &  type,
CodeGenerator *(*)(void)  newcg 
)
static
Parameters
typeIdentifier of class to register
newcgFunction to instantiate object of derived class

Definition at line 48 of file cgp_codegenerator.cpp.

◆ Registry()

std::vector< std::string > CodeGenerator::Registry ( void  )
static
Returns
Registered CodeGenerator identifiers.

Definition at line 54 of file cgp_codegenerator.cpp.

◆ New()

CodeGenerator * CodeGenerator::New ( const std::string &  type)
static
Parameters
typeIdentifier of class to instantiate
Returns
New CodeGenerator object (NULL if unknown identifier)

Definition at line 63 of file cgp_codegenerator.cpp.

◆ DoRead()

void CodeGenerator::DoRead ( TokenReader &  rTr,
const std::string &  rLabel = "",
const Type *  pContext = 0 
)
protectedvirtual

The label argument is ignored, we use the hardcoded section "CodeGenerator". The context argument is ignored. This method calls the virtual hook DoReadTargetConfiguration() to be reimplemented by derived classes.

Parameters
rTrTokenReader to read from
rLabelSection to read
pContextRead context to provide contextual information
Exceptions
Exception
  • IO error (id 1)

Definition at line 151 of file cgp_codegenerator.cpp.

◆ DoWrite()

void CodeGenerator::DoWrite ( TokenWriter &  rTw,
const std::string &  rLabel = "",
const Type *  pContext = 0 
) const
protectedvirtual

The label argument is ignored, we use the hardcoded section "CodeGenerator". The context argument is ignored. This method calls the virtual hook DoWriteTargetConfiguration() to be reimplemented by derived classes.

Parameters
rTwTokenWriter to write to
rLabelSection to write
pContextRead context to provide contextual information
Exceptions
Exception
  • IO error (id 2)

Definition at line 219 of file cgp_codegenerator.cpp.

◆ DoReadTargetConfiguration()

void CodeGenerator::DoReadTargetConfiguration ( TokenReader &  rTr)
protectedvirtual

label

Parameters
rTrTokenReader to read from
Exceptions
Exception
  • token mismatch (id 502)
  • IO error (id 1)

Reimplemented in PlcoxmlCodeGenerator, KinetisCodeGenerator, Iec61131stCodeGenerator, GebtoolsCodeGenerator, EmbeddedcCodeGenerator, CodePrimitives, and ATmegaCodeGenerator.

Definition at line 109 of file cgp_codegenerator.cpp.

◆ DoWriteTargetConfiguration()

void CodeGenerator::DoWriteTargetConfiguration ( TokenWriter &  rTw) const
protectedvirtual

label

Parameters
rTwReference to TokenWriter
Exceptions
Exception
  • IO errors (id 2)

Reimplemented in PlcoxmlCodeGenerator, KinetisCodeGenerator, Iec61131stCodeGenerator, GebtoolsCodeGenerator, EmbeddedcCodeGenerator, CodePrimitives, and ATmegaCodeGenerator.

Definition at line 196 of file cgp_codegenerator.cpp.

Member Data Documentation

◆ mEventBitAddress

std::map<Idx,int> CodeGenerator::mEventBitAddress
protected

. #-1)

Definition at line 862 of file cgp_codegenerator.h.

◆ mInternalEvents

EventSet CodeGenerator::mInternalEvents
protected

timers)

Definition at line 895 of file cgp_codegenerator.h.


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