Classes | Typedefs | Functions | Variables
AESL Compiler

Classes

struct  Aseba::AbstractTreeNode
struct  Aseba::ArithmeticAssignmentNode
struct  Aseba::ArrayReadNode
struct  Aseba::ArrayWriteNode
struct  Aseba::AssignmentNode
struct  Aseba::BinaryArithmeticNode
struct  Aseba::BlockNode
 Node for L"block", i.e. a vector of statements. More...
struct  Aseba::BytecodeElement
 A bytecode element. More...
struct  Aseba::BytecodeVector
 Bytecode array in the form of a dequeue, for construction. More...
struct  Aseba::CallNode
struct  Aseba::CallSubNode
struct  Aseba::CommonDefinitions
 Definitions common to several nodes, such as events or some constants. More...
class  Aseba::Compiler
 Aseba Event Scripting Language compiler. More...
struct  Aseba::EmitNode
struct  Aseba::Error
 Compilation error. More...
class  Aseba::ErrorMessages
 Return error messages based on error ID (needed to translate messages for other applications) More...
struct  Aseba::EventDeclNode
struct  Aseba::FoldedIfWhenNode
struct  Aseba::FoldedWhileNode
struct  Aseba::IfWhenNode
struct  Aseba::ImmediateNode
struct  Aseba::LoadNode
struct  Aseba::MemoryVectorNode
struct  Aseba::NamedValue
 A name - value pair. More...
struct  Aseba::NamedValuesVector
 Generic vector of name - value pairs. More...
struct  Aseba::Node
 An abstract node of syntax tree. More...
struct  Aseba::PreLinkBytecode
 Bytecode use for compilation previous to linking. More...
struct  Aseba::ProgramNode
 Node for L"program", i.e. a block node with some special behaviour later on. More...
struct  Aseba::ReturnNode
struct  Aseba::SourcePos
 Position in a source file or string. First is line, second is column. More...
struct  Aseba::StoreNode
struct  Aseba::SubDeclNode
struct  Aseba::TargetDescription
 Description of target VM. More...
struct  Aseba::TranslatableError
struct  Aseba::TupleVectorNode
struct  Aseba::UnaryArithmeticAssignmentNode
struct  Aseba::UnaryArithmeticNode
struct  Aseba::WhileNode

Typedefs

typedef NamedValue Aseba::ConstantDefinition
 An constant definition is a name - value pair.
typedef NamedValuesVector Aseba::ConstantsDefinitions
 Vector of constants definitions.
typedef NamedValue Aseba::EventDescription
 An event description is a name - value pair.
typedef NamedValuesVector Aseba::EventsDescriptionsVector
 Vector of events descriptions.
typedef std::vector< short int > Aseba::VariablesDataVector
 Vector of data of variables.
typedef std::vector< std::wstring > Aseba::VariablesNamesVector
 Vector of names of variables.

Functions

TranslatableError & Aseba::TranslatableError::arg (int value, int fieldWidth=0, int base=10, wchar_t fillChar= ' ')
TranslatableError & Aseba::TranslatableError::arg (unsigned value, int fieldWidth=0, int base=10, wchar_t fillChar= ' ')
TranslatableError & Aseba::TranslatableError::arg (float value, int fieldWidth=0, int precision=6, wchar_t fillChar= ' ')
TranslatableError & Aseba::TranslatableError::arg (const std::wstring &value)
 Aseba::ArithmeticAssignmentNode::ArithmeticAssignmentNode (const SourcePos &sourcePos, AsebaBinaryOperator op, Node *left, Node *right)
 Constructor.
 Aseba::ArrayReadNode::ArrayReadNode (const SourcePos &sourcePos, unsigned arrayAddr, unsigned arraySize, const std::wstring &arrayName)
 Constructor.
 Aseba::ArrayWriteNode::ArrayWriteNode (const SourcePos &sourcePos, unsigned arrayAddr, unsigned arraySize, const std::wstring &arrayName)
 Constructor.
 Aseba::BinaryArithmeticNode::BinaryArithmeticNode (const SourcePos &sourcePos, AsebaBinaryOperator op, Node *left, Node *right)
 Constructor.
std::wstring Aseba::binaryOperatorToString (AsebaBinaryOperator op)
 Return the string corresponding to the binary operator.
void Aseba::Compiler::buildMaps ()
 Build variables and functions maps.
 Aseba::CallNode::CallNode (const SourcePos &sourcePos, unsigned funcId)
 Constructor.
 Aseba::CallSubNode::CallSubNode (const SourcePos &sourcePos, unsigned subroutineId)
 Constructor.
void Aseba::BytecodeVector::changeStopToRetSub ()
 Change "stop" bytecode to "return from subroutine".
bool Aseba::Compiler::compile (std::wistream &source, BytecodeVector &bytecode, unsigned &allocatedVariablesCount, Error &errorDescription, std::wostream *dump=0)
 Aseba::Compiler::Compiler ()
 Constructor. You must setup a description using setTargetDescription() before any call to compile().
bool Aseba::Compiler::constantExists (const std::wstring &name) const
 Return true if a constant of a given name exists.
bool Aseba::NamedValuesVector::contains (const std::wstring &s, size_t *position=0) const
 Return whether a named-value vector contains a certain value, by iterating.
uint16 Aseba::TargetDescription::crc () const
 Compute the XModem CRC of the description, as defined in AS001 at https://aseba.wikidot.com/asebaspecifications.
virtual Node * Aseba::Node::deepCopy ()
 Return a deep copy of the object (children are also copied)
static const std::wstring Aseba::ErrorMessages::defaultCallback (ErrorCode error)
 Default callback.
void Aseba::BinaryArithmeticNode::deMorganNotRemoval ()
 Recursively apply de Morgan law as long as nodes are logic operations, and then invert comparisons.
void Aseba::Compiler::disassemble (BytecodeVector &bytecode, const PreLinkBytecode &preLinkBytecode, std::wostream &dump) const
 Disassemble a microcontroller bytecode and dump it.
virtual void Aseba::Node::dump (std::wostream &dest, unsigned &indent) const
 Dump this node and the rest of the tree.
virtual void Aseba::TupleVectorNode::dump (std::wostream &dest, unsigned &indent) const
 Dump this node and the rest of the tree.
template<class T >
unsigned int Aseba::editDistance (const T &s1, const T &s2, const unsigned maxDist)
 Compute the edit distance between two vector-style containers, inspired from http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C.2B.2B.
virtual void Aseba::BlockNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::ProgramNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::AssignmentNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::IfWhenNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::FoldedIfWhenNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::WhileNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::FoldedWhileNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::EventDeclNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::EmitNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::SubDeclNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::CallSubNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::BinaryArithmeticNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::UnaryArithmeticNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::ImmediateNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::StoreNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::LoadNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::ArrayWriteNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::ArrayReadNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::CallNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
virtual void Aseba::ReturnNode::emit (PreLinkBytecode &bytecodes) const
 Generate bytecode.
 Aseba::ErrorMessages::ErrorMessages ()
 Aseba::EventDeclNode::EventDeclNode (const SourcePos &sourcePos, unsigned eventId=0)
 Constructor.
void Aseba::Node::expectType (const Node::ReturnType &expected, const Node::ReturnType &type) const
 Check for a specific type, throw an exception otherwise.
EventsMap::const_iterator Aseba::Compiler::findAnyEvent (const std::wstring &name, const SourcePos &pos) const
ConstantsMap::const_iterator Aseba::Compiler::findConstant (const std::wstring &name, const SourcePos &pos) const
 Look for a constant of a given name, and if found, return an iterator; if not, return an exception.
FunctionsMap::const_iterator Aseba::Compiler::findFunction (const std::wstring &name, const SourcePos &pos) const
 Look for a function of a given name, and if found, return an iterator; if not, return an exception.
EventsMap::const_iterator Aseba::Compiler::findGlobalEvent (const std::wstring &name, const SourcePos &pos) const
 Look for a global event of a given name, and if found, return an iterator; if not, return an exception.
template<typename MapType >
MapType::const_iterator Aseba::findInTable (const MapType &map, const std::wstring &name, const SourcePos &pos, const ErrorCode notFoundError, const ErrorCode misspelledError)
 Helper function to find for something in one of the map, using edit-distance to check for candidates if not found.
SubroutineReverseTable::const_iterator Aseba::Compiler::findSubroutine (const std::wstring &name, const SourcePos &pos) const
 Look for a subroutine of a given name, and if found, return an iterator; if not, return an exception.
VariablesMap::const_iterator Aseba::Compiler::findVariable (const std::wstring &name, const SourcePos &pos) const
 Look for a variable of a given name, and if found, return an iterator; if not, return an exception.
void Aseba::PreLinkBytecode::fixup (const Compiler::SubroutineTable &subroutineTable)
static BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromAddExpression (const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)
 Create a binary arithmetic node for add/sub operation op.
static ArithmeticAssignmentNode * Aseba::ArithmeticAssignmentNode::fromArithmeticAssignmentToken (const SourcePos &sourcePos, Compiler::Token::Type token, Node *left, Node *right)
static BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromBinaryExpression (const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)
 Create a binary arithmetic node for or/xor/and operation op.
static BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromComparison (const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)
 Create a binary arithmetic node for comparaison operation op.
static BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromMultExpression (const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)
 Create a binary arithmetic node for mult/div/mod operation op.
static BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromShiftExpression (const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)
 Create a binary arithmetic node for shift operation op.
static AsebaBinaryOperator Aseba::ArithmeticAssignmentNode::getBinaryOperator (Compiler::Token::Type token)
EventAddressesToIdsMap Aseba::BytecodeVector::getEventAddressesToIds () const
 Get the map of event addresses to identifiers.
virtual unsigned Aseba::Node::getStackDepth () const
 Return the stack depth requirement for this node and its children.
virtual unsigned Aseba::FoldedIfWhenNode::getStackDepth () const
 Return the stack depth requirement for this node and its children.
virtual unsigned Aseba::FoldedWhileNode::getStackDepth () const
 Return the stack depth requirement for this node and its children.
virtual unsigned Aseba::BinaryArithmeticNode::getStackDepth () const
 Return the stack depth requirement for this node and its children.
virtual unsigned Aseba::ImmediateNode::getStackDepth () const
 Return the stack depth requirement for this node and its children.
virtual unsigned Aseba::LoadNode::getStackDepth () const
 Return the stack depth requirement for this node and its children.
virtual unsigned Aseba::CallNode::getStackDepth () const
 Return the stack depth requirement for this node and its children.
unsigned short Aseba::BytecodeVector::getTypeOfLast () const
 Return the type of last bytecode element.
unsigned Aseba::BytecodeElement::getWordSize () const
 Return the number of words this element takes in memory.
template<typename T >
bool Aseba::isPOT (T number)
 Return true if number is a power of two.
bool Aseba::Compiler::link (const PreLinkBytecode &preLinkBytecode, BytecodeVector &bytecode)
 Create the final bytecode for a microcontroller.
 Aseba::MemoryVectorNode::MemoryVectorNode (const SourcePos &sourcePos, unsigned arrayAddr, unsigned arraySize, const std::wstring &arrayName)
 Constructor.
virtual Node * Aseba::BlockNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::AssignmentNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::IfWhenNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::FoldedIfWhenNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::WhileNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::FoldedWhileNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::EventDeclNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::EmitNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::SubDeclNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::CallSubNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::BinaryArithmeticNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::UnaryArithmeticNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::ImmediateNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::StoreNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::LoadNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::ArrayWriteNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::ArrayReadNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
virtual Node * Aseba::CallNode::optimize (std::wostream *dump)
 Optimize this node, return the optimized node.
 Aseba::PreLinkBytecode::PreLinkBytecode ()
 Add init event and point to currentBytecode it.
void Aseba::Compiler::setCommonDefinitions (const CommonDefinitions *definitions)
 Set the common definitions, such as events or some constants.
void Aseba::Compiler::setTargetDescription (const TargetDescription *description)
 Set the description of the target as returned by the microcontroller. You must call this function before any call to compile().
static void Aseba::TranslatableError::setTranslateCB (ErrorMessages::ErrorCallback newCB)
template<typename T >
unsigned Aseba::shiftFromPOT (T number)
 If number is a power of two, number = (1 << shift) and this function returns shift, otherwise return value is undefined.
 Aseba::SubDeclNode::SubDeclNode (const SourcePos &sourcePos, unsigned subroutineId)
 Constructor.
Error Aseba::TranslatableError::toError (void)
std::wstring Aseba::SourcePos::toWString () const
 Return the string version of this position.
virtual std::wstring Aseba::IfWhenNode::toWString () const
 Return a string representation of this node.
std::wstring Aseba::Error::toWString () const
 Return a string describing the error.
virtual std::wstring Aseba::FoldedIfWhenNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::WhileNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::FoldedWhileNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::EventDeclNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::EmitNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::SubDeclNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::CallSubNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::BinaryArithmeticNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::UnaryArithmeticNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::ImmediateNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::StoreNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::LoadNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::ArrayWriteNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::ArrayReadNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::CallNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::TupleVectorNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::MemoryVectorNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::ArithmeticAssignmentNode::toWString () const
 Return a string representation of this node.
virtual std::wstring Aseba::UnaryArithmeticAssignmentNode::toWString () const
 Return a string representation of this node.
 Aseba::TranslatableError::TranslatableError (const SourcePos &pos, ErrorCode error)
virtual ReturnType Aseba::Node::typeCheck () const
 Typecheck this node, throw an exception if there is any type violation.
virtual ReturnType Aseba::AssignmentNode::typeCheck () const
 Typecheck this node, throw an exception if there is any type violation.
virtual ReturnType Aseba::IfWhenNode::typeCheck () const
 Typecheck this node, throw an exception if there is any type violation.
virtual ReturnType Aseba::WhileNode::typeCheck () const
 Typecheck this node, throw an exception if there is any type violation.
virtual ReturnType Aseba::BinaryArithmeticNode::typeCheck () const
 Typecheck this node, throw an exception if there is any type violation.
virtual ReturnType Aseba::UnaryArithmeticNode::typeCheck () const
 Typecheck this node, throw an exception if there is any type violation.
std::wstring Aseba::Node::typeName (const Node::ReturnType &type) const
 Return the name of a type.
 Aseba::UnaryArithmeticAssignmentNode::UnaryArithmeticAssignmentNode (const SourcePos &sourcePos, Compiler::Token::Type token, Node *memory)
 Constructor.
 Aseba::UnaryArithmeticNode::UnaryArithmeticNode (const SourcePos &sourcePos, AsebaUnaryOperator op, Node *child)
 Constructor.
std::wstring Aseba::unaryOperatorToString (AsebaUnaryOperator op)
 Return the string corresponding to the unary operator.
bool Aseba::Compiler::verifyStackCalls (PreLinkBytecode &preLinkBytecode)
 Verify that no call path can create a stack overflow.
virtual Aseba::Node::~Node ()
 Destructor, delete all children.

Variables

static const wchar_t * Aseba::error_map [ERROR_END]
static const AsebaBinaryOperator Aseba::ArithmeticAssignmentNode::operatorMap []
static ErrorMessages::ErrorCallback Aseba::TranslatableError::translateCB = NULL

Typedef Documentation

typedef NamedValue Aseba::ConstantDefinition

An constant definition is a name - value pair.

Definition at line 220 of file compiler.h.

typedef NamedValuesVector Aseba::ConstantsDefinitions

Vector of constants definitions.

Definition at line 232 of file compiler.h.

typedef NamedValue Aseba::EventDescription

An event description is a name - value pair.

Definition at line 217 of file compiler.h.

typedef NamedValuesVector Aseba::EventsDescriptionsVector

Vector of events descriptions.

Definition at line 229 of file compiler.h.

typedef std::vector<short int> Aseba::VariablesDataVector

Vector of data of variables.

Definition at line 247 of file compiler.h.

typedef std::vector<std::wstring> Aseba::VariablesNamesVector

Vector of names of variables.

Definition at line 204 of file compiler.h.


Function Documentation

TranslatableError & Aseba::TranslatableError::arg ( int  value,
int  fieldWidth = 0,
int  base = 10,
wchar_t  fillChar = ' ' 
)

Definition at line 218 of file errors.cpp.

TranslatableError & Aseba::TranslatableError::arg ( unsigned  value,
int  fieldWidth = 0,
int  base = 10,
wchar_t  fillChar = ' ' 
)

Definition at line 224 of file errors.cpp.

TranslatableError & Aseba::TranslatableError::arg ( float  value,
int  fieldWidth = 0,
int  precision = 6,
wchar_t  fillChar = ' ' 
)

Definition at line 230 of file errors.cpp.

TranslatableError & Aseba::TranslatableError::arg ( const std::wstring &  value)

Definition at line 236 of file errors.cpp.

Constructor.

Definition at line 198 of file tree-build.cpp.

Aseba::ArrayReadNode::ArrayReadNode ( const SourcePos sourcePos,
unsigned  arrayAddr,
unsigned  arraySize,
const std::wstring &  arrayName 
)

Constructor.

Definition at line 159 of file tree-build.cpp.

Aseba::ArrayWriteNode::ArrayWriteNode ( const SourcePos sourcePos,
unsigned  arrayAddr,
unsigned  arraySize,
const std::wstring &  arrayName 
)

Constructor.

Definition at line 169 of file tree-build.cpp.

Aseba::BinaryArithmeticNode::BinaryArithmeticNode ( const SourcePos sourcePos,
AsebaBinaryOperator  op,
Node left,
Node right 
)

Constructor.

Definition at line 87 of file tree-build.cpp.

Return the string corresponding to the binary operator.

Definition at line 30 of file tree-dump.cpp.

void Aseba::Compiler::buildMaps ( ) [protected]

Build variables and functions maps.

Definition at line 187 of file identifier-lookup.cpp.

Aseba::CallNode::CallNode ( const SourcePos sourcePos,
unsigned  funcId 
)

Constructor.

Definition at line 190 of file tree-build.cpp.

Aseba::CallSubNode::CallSubNode ( const SourcePos sourcePos,
unsigned  subroutineId 
)

Constructor.

Definition at line 79 of file tree-build.cpp.

Change "stop" bytecode to "return from subroutine".

Definition at line 346 of file compiler.cpp.

bool Aseba::Compiler::compile ( std::wistream &  source,
BytecodeVector bytecode,
unsigned &  allocatedVariablesCount,
Error errorDescription,
std::wostream *  dump = 0 
)

Compile a new condition

Parameters:
sourcestream to read the source code from
bytecodedestination array for bytecode
allocatedVariablesCountamount of allocated variables
errorDescriptionerror is copied there on error
dumpstream to send dump messages to
Returns:
returns true on success

Definition at line 115 of file compiler.cpp.

Constructor. You must setup a description using setTargetDescription() before any call to compile().

Definition at line 89 of file compiler.cpp.

bool Aseba::Compiler::constantExists ( const std::wstring &  name) const [protected]

Return true if a constant of a given name exists.

Definition at line 154 of file identifier-lookup.cpp.

bool Aseba::NamedValuesVector::contains ( const std::wstring &  s,
size_t *  position = 0 
) const

Return whether a named-value vector contains a certain value, by iterating.

Definition at line 60 of file identifier-lookup.cpp.

Compute the XModem CRC of the description, as defined in AS001 at https://aseba.wikidot.com/asebaspecifications.

Definition at line 42 of file compiler.cpp.

Node * Aseba::Node::deepCopy ( ) [virtual]

Return a deep copy of the object (children are also copied)

Definition at line 53 of file tree-build.cpp.

const std::wstring Aseba::ErrorMessages::defaultCallback ( ErrorCode  error) [static]

Default callback.

Definition at line 181 of file errors.cpp.

Recursively apply de Morgan law as long as nodes are logic operations, and then invert comparisons.

Definition at line 353 of file tree-optimize.cpp.

void Aseba::Compiler::disassemble ( BytecodeVector bytecode,
const PreLinkBytecode preLinkBytecode,
std::wostream &  dump 
) const [protected]

Disassemble a microcontroller bytecode and dump it.

Definition at line 386 of file compiler.cpp.

void Aseba::Node::dump ( std::wostream &  dest,
unsigned &  indent 
) const [virtual]

Dump this node and the rest of the tree.

Reimplemented in Aseba::TupleVectorNode.

Definition at line 73 of file tree-dump.cpp.

void Aseba::TupleVectorNode::dump ( std::wostream &  dest,
unsigned &  indent 
) const [virtual]

Dump this node and the rest of the tree.

Reimplemented from Aseba::Node.

Definition at line 84 of file tree-dump.cpp.

template<class T >
unsigned int Aseba::editDistance ( const T &  s1,
const T &  s2,
const unsigned  maxDist 
)

Compute the edit distance between two vector-style containers, inspired from http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C.2B.2B.

Definition at line 75 of file identifier-lookup.cpp.

void Aseba::BlockNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Reimplemented in Aseba::ProgramNode.

Definition at line 84 of file tree-emit.cpp.

void Aseba::ProgramNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Reimplemented from Aseba::BlockNode.

Definition at line 90 of file tree-emit.cpp.

void Aseba::AssignmentNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 118 of file tree-emit.cpp.

void Aseba::IfWhenNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 129 of file tree-emit.cpp.

void Aseba::FoldedIfWhenNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 135 of file tree-emit.cpp.

void Aseba::WhileNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 220 of file tree-emit.cpp.

void Aseba::FoldedWhileNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 226 of file tree-emit.cpp.

void Aseba::EventDeclNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 285 of file tree-emit.cpp.

void Aseba::EmitNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 296 of file tree-emit.cpp.

void Aseba::SubDeclNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 309 of file tree-emit.cpp.

void Aseba::CallSubNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 320 of file tree-emit.cpp.

void Aseba::BinaryArithmeticNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 328 of file tree-emit.cpp.

void Aseba::UnaryArithmeticNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 342 of file tree-emit.cpp.

void Aseba::ImmediateNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 350 of file tree-emit.cpp.

void Aseba::StoreNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 386 of file tree-emit.cpp.

void Aseba::LoadNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 374 of file tree-emit.cpp.

void Aseba::ArrayWriteNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 407 of file tree-emit.cpp.

void Aseba::ArrayReadNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 393 of file tree-emit.cpp.

void Aseba::CallNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 420 of file tree-emit.cpp.

void Aseba::ReturnNode::emit ( PreLinkBytecode bytecodes) const [virtual]

Generate bytecode.

Implements Aseba::Node.

Definition at line 462 of file tree-emit.cpp.

Definition at line 33 of file errors.cpp.

Aseba::EventDeclNode::EventDeclNode ( const SourcePos sourcePos,
unsigned  eventId = 0 
)

Constructor.

Definition at line 63 of file tree-build.cpp.

void Aseba::Node::expectType ( const Node::ReturnType expected,
const Node::ReturnType type 
) const

Check for a specific type, throw an exception otherwise.

Definition at line 41 of file tree-typecheck.cpp.

Compiler::EventsMap::const_iterator Aseba::Compiler::findAnyEvent ( const std::wstring &  name,
const SourcePos pos 
) const [protected]

Definition at line 175 of file identifier-lookup.cpp.

Compiler::ConstantsMap::const_iterator Aseba::Compiler::findConstant ( const std::wstring &  name,
const SourcePos pos 
) const [protected]

Look for a constant of a given name, and if found, return an iterator; if not, return an exception.

Definition at line 148 of file identifier-lookup.cpp.

Compiler::FunctionsMap::const_iterator Aseba::Compiler::findFunction ( const std::wstring &  name,
const SourcePos pos 
) const [protected]

Look for a function of a given name, and if found, return an iterator; if not, return an exception.

Definition at line 142 of file identifier-lookup.cpp.

Compiler::EventsMap::const_iterator Aseba::Compiler::findGlobalEvent ( const std::wstring &  name,
const SourcePos pos 
) const [protected]

Look for a global event of a given name, and if found, return an iterator; if not, return an exception.

Definition at line 160 of file identifier-lookup.cpp.

template<typename MapType >
MapType::const_iterator Aseba::findInTable ( const MapType &  map,
const std::wstring &  name,
const SourcePos &  pos,
const ErrorCode  notFoundError,
const ErrorCode  misspelledError 
)

Helper function to find for something in one of the map, using edit-distance to check for candidates if not found.

Definition at line 109 of file identifier-lookup.cpp.

Compiler::SubroutineReverseTable::const_iterator Aseba::Compiler::findSubroutine ( const std::wstring &  name,
const SourcePos pos 
) const [protected]

Look for a subroutine of a given name, and if found, return an iterator; if not, return an exception.

Definition at line 181 of file identifier-lookup.cpp.

Compiler::VariablesMap::const_iterator Aseba::Compiler::findVariable ( const std::wstring &  name,
const SourcePos pos 
) const [protected]

Look for a variable of a given name, and if found, return an iterator; if not, return an exception.

Definition at line 136 of file identifier-lookup.cpp.

void Aseba::PreLinkBytecode::fixup ( const Compiler::SubroutineTable subroutineTable)

Fixup prelinked bytecodes by making sure that each vector is closed correctly, i.e. with a STOP for events and a RET for subroutines

Definition at line 39 of file tree-emit.cpp.

BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromAddExpression ( const SourcePos sourcePos,
Compiler::Token::Type  op,
Node left,
Node right 
) [static]

Create a binary arithmetic node for add/sub operation op.

Definition at line 118 of file tree-build.cpp.

ArithmeticAssignmentNode * Aseba::ArithmeticAssignmentNode::fromArithmeticAssignmentToken ( const SourcePos sourcePos,
Compiler::Token::Type  token,
Node left,
Node right 
) [static]

Definition at line 206 of file tree-build.cpp.

BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromBinaryExpression ( const SourcePos sourcePos,
Compiler::Token::Type  op,
Node left,
Node right 
) [static]

Create a binary arithmetic node for or/xor/and operation op.

Definition at line 140 of file tree-build.cpp.

BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromComparison ( const SourcePos sourcePos,
Compiler::Token::Type  op,
Node left,
Node right 
) [static]

Create a binary arithmetic node for comparaison operation op.

Definition at line 96 of file tree-build.cpp.

BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromMultExpression ( const SourcePos sourcePos,
Compiler::Token::Type  op,
Node left,
Node right 
) [static]

Create a binary arithmetic node for mult/div/mod operation op.

Definition at line 129 of file tree-build.cpp.

BinaryArithmeticNode * Aseba::BinaryArithmeticNode::fromShiftExpression ( const SourcePos sourcePos,
Compiler::Token::Type  op,
Node left,
Node right 
) [static]

Create a binary arithmetic node for shift operation op.

Definition at line 107 of file tree-build.cpp.

Definition at line 211 of file tree-build.cpp.

BytecodeVector::EventAddressesToIdsMap Aseba::BytecodeVector::getEventAddressesToIds ( ) const

Get the map of event addresses to identifiers.

Definition at line 372 of file compiler.cpp.

unsigned Aseba::Node::getStackDepth ( ) const [virtual]

Return the stack depth requirement for this node and its children.

Reimplemented in Aseba::AbstractTreeNode, Aseba::ReturnNode, Aseba::CallNode, Aseba::LoadNode, Aseba::ImmediateNode, Aseba::BinaryArithmeticNode, Aseba::FoldedWhileNode, and Aseba::FoldedIfWhenNode.

Definition at line 75 of file tree-emit.cpp.

unsigned Aseba::FoldedIfWhenNode::getStackDepth ( ) const [virtual]

Return the stack depth requirement for this node and its children.

Reimplemented from Aseba::Node.

Definition at line 210 of file tree-emit.cpp.

unsigned Aseba::FoldedWhileNode::getStackDepth ( ) const [virtual]

Return the stack depth requirement for this node and its children.

Reimplemented from Aseba::Node.

Definition at line 277 of file tree-emit.cpp.

unsigned Aseba::BinaryArithmeticNode::getStackDepth ( ) const [virtual]

Return the stack depth requirement for this node and its children.

Reimplemented from Aseba::Node.

Definition at line 336 of file tree-emit.cpp.

unsigned Aseba::ImmediateNode::getStackDepth ( ) const [virtual]

Return the stack depth requirement for this node and its children.

Reimplemented from Aseba::Node.

Definition at line 368 of file tree-emit.cpp.

unsigned Aseba::LoadNode::getStackDepth ( ) const [virtual]

Return the stack depth requirement for this node and its children.

Reimplemented from Aseba::Node.

Definition at line 380 of file tree-emit.cpp.

unsigned Aseba::CallNode::getStackDepth ( ) const [virtual]

Return the stack depth requirement for this node and its children.

Reimplemented from Aseba::Node.

Definition at line 452 of file tree-emit.cpp.

unsigned short Aseba::BytecodeVector::getTypeOfLast ( ) const

Return the type of last bytecode element.

Definition at line 359 of file compiler.cpp.

Return the number of words this element takes in memory.

Definition at line 70 of file compiler.cpp.

template<typename T >
bool Aseba::isPOT ( number)

Return true if number is a power of two.

Definition at line 32 of file power-of-two.h.

bool Aseba::Compiler::link ( const PreLinkBytecode preLinkBytecode,
BytecodeVector bytecode 
) [protected]

Create the final bytecode for a microcontroller.

Definition at line 288 of file compiler.cpp.

Aseba::MemoryVectorNode::MemoryVectorNode ( const SourcePos sourcePos,
unsigned  arrayAddr,
unsigned  arraySize,
const std::wstring &  arrayName 
)

Constructor.

Definition at line 179 of file tree-build.cpp.

Node * Aseba::BlockNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 34 of file tree-optimize.cpp.

Node * Aseba::AssignmentNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 62 of file tree-optimize.cpp.

Node * Aseba::IfWhenNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 71 of file tree-optimize.cpp.

Node * Aseba::FoldedIfWhenNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 156 of file tree-optimize.cpp.

Node * Aseba::WhileNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 162 of file tree-optimize.cpp.

Node * Aseba::FoldedWhileNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 214 of file tree-optimize.cpp.

Node * Aseba::EventDeclNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 220 of file tree-optimize.cpp.

Node * Aseba::EmitNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 225 of file tree-optimize.cpp.

Node * Aseba::SubDeclNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 237 of file tree-optimize.cpp.

Node * Aseba::CallSubNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 242 of file tree-optimize.cpp.

Node * Aseba::BinaryArithmeticNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 247 of file tree-optimize.cpp.

Node * Aseba::UnaryArithmeticNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 379 of file tree-optimize.cpp.

Node * Aseba::ImmediateNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 430 of file tree-optimize.cpp.

Node * Aseba::StoreNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 440 of file tree-optimize.cpp.

Node * Aseba::LoadNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 435 of file tree-optimize.cpp.

Node * Aseba::ArrayWriteNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 475 of file tree-optimize.cpp.

Node * Aseba::ArrayReadNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 445 of file tree-optimize.cpp.

Node * Aseba::CallNode::optimize ( std::wostream *  dump) [virtual]

Optimize this node, return the optimized node.

Implements Aseba::Node.

Definition at line 505 of file tree-optimize.cpp.

Add init event and point to currentBytecode it.

Definition at line 31 of file tree-emit.cpp.

Set the common definitions, such as events or some constants.

Definition at line 103 of file compiler.cpp.

Set the description of the target as returned by the microcontroller. You must call this function before any call to compile().

Definition at line 97 of file compiler.cpp.

Definition at line 213 of file errors.cpp.

template<typename T >
unsigned Aseba::shiftFromPOT ( number)

If number is a power of two, number = (1 << shift) and this function returns shift, otherwise return value is undefined.

Definition at line 43 of file power-of-two.h.

Aseba::SubDeclNode::SubDeclNode ( const SourcePos sourcePos,
unsigned  subroutineId 
)

Constructor.

Definition at line 71 of file tree-build.cpp.

Definition at line 208 of file errors.cpp.

std::wstring Aseba::SourcePos::toWString ( ) const

Return the string version of this position.

Definition at line 47 of file identifier-lookup.cpp.

std::wstring Aseba::IfWhenNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 102 of file tree-dump.cpp.

std::wstring Aseba::Error::toWString ( ) const

Return a string describing the error.

Return the string version of this error.

Definition at line 190 of file errors.cpp.

std::wstring Aseba::FoldedIfWhenNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 112 of file tree-dump.cpp.

std::wstring Aseba::WhileNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 123 of file tree-dump.cpp.

std::wstring Aseba::FoldedWhileNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 129 of file tree-dump.cpp.

std::wstring Aseba::EventDeclNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 136 of file tree-dump.cpp.

std::wstring Aseba::EmitNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 144 of file tree-dump.cpp.

std::wstring Aseba::SubDeclNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 152 of file tree-dump.cpp.

std::wstring Aseba::CallSubNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 157 of file tree-dump.cpp.

std::wstring Aseba::BinaryArithmeticNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 162 of file tree-dump.cpp.

std::wstring Aseba::UnaryArithmeticNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 169 of file tree-dump.cpp.

std::wstring Aseba::ImmediateNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 176 of file tree-dump.cpp.

std::wstring Aseba::StoreNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 186 of file tree-dump.cpp.

std::wstring Aseba::LoadNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 181 of file tree-dump.cpp.

std::wstring Aseba::ArrayWriteNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 196 of file tree-dump.cpp.

std::wstring Aseba::ArrayReadNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 191 of file tree-dump.cpp.

std::wstring Aseba::CallNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 201 of file tree-dump.cpp.

std::wstring Aseba::TupleVectorNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 209 of file tree-dump.cpp.

std::wstring Aseba::MemoryVectorNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 214 of file tree-dump.cpp.

std::wstring Aseba::ArithmeticAssignmentNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 219 of file tree-dump.cpp.

std::wstring Aseba::UnaryArithmeticAssignmentNode::toWString ( ) const [virtual]

Return a string representation of this node.

Implements Aseba::Node.

Definition at line 226 of file tree-dump.cpp.

Definition at line 202 of file errors.cpp.

Node::ReturnType Aseba::Node::typeCheck ( ) const [virtual]
Node::ReturnType Aseba::AssignmentNode::typeCheck ( ) const [virtual]

Typecheck this node, throw an exception if there is any type violation.

Reimplemented from Aseba::Node.

Definition at line 56 of file tree-typecheck.cpp.

Node::ReturnType Aseba::IfWhenNode::typeCheck ( ) const [virtual]

Typecheck this node, throw an exception if there is any type violation.

Reimplemented from Aseba::Node.

Definition at line 63 of file tree-typecheck.cpp.

Node::ReturnType Aseba::WhileNode::typeCheck ( ) const [virtual]

Typecheck this node, throw an exception if there is any type violation.

Reimplemented from Aseba::Node.

Definition at line 83 of file tree-typecheck.cpp.

Node::ReturnType Aseba::BinaryArithmeticNode::typeCheck ( ) const [virtual]

Typecheck this node, throw an exception if there is any type violation.

Reimplemented from Aseba::Node.

Definition at line 101 of file tree-typecheck.cpp.

Node::ReturnType Aseba::UnaryArithmeticNode::typeCheck ( ) const [virtual]

Typecheck this node, throw an exception if there is any type violation.

Reimplemented from Aseba::Node.

Definition at line 141 of file tree-typecheck.cpp.

std::wstring Aseba::Node::typeName ( const Node::ReturnType type) const

Return the name of a type.

Definition at line 30 of file tree-typecheck.cpp.

Constructor.

Definition at line 217 of file tree-build.cpp.

Constructor.

Definition at line 151 of file tree-build.cpp.

Return the string corresponding to the unary operator.

Definition at line 60 of file tree-dump.cpp.

bool Aseba::Compiler::verifyStackCalls ( PreLinkBytecode preLinkBytecode) [protected]

Verify that no call path can create a stack overflow.

Definition at line 32 of file analysis.cpp.

Aseba::Node::~Node ( ) [virtual]

Destructor, delete all children.

Definition at line 45 of file tree-build.cpp.


Variable Documentation

const wchar_t* Aseba::error_map[ERROR_END] [static]

Definition at line 31 of file errors.cpp.

ErrorMessages::ErrorCallback Aseba::TranslatableError::translateCB = NULL [static]

Definition at line 199 of file compiler.h.



aseba
Author(s): Stéphane Magnenat
autogenerated on Sun Oct 5 2014 23:46:39