DoxyGen Documentation

struct AbstractTreeNode
#include <tree.h>

Virtual class for abstraction nodes abort() if you try to typeCheck(), optimize() or emit() to force correct expansion into regular Aseba nodes.

Inherits from Aseba::Node

Subclassed by Aseba::ArithmeticAssignmentNode, Aseba::MemoryVectorNode, Aseba::TupleVectorNode, Aseba::UnaryArithmeticAssignmentNode

Public Functions

AbstractTreeNode(const SourcePos &sourcePos)

Constructor.

Node *expandAbstractNodes(std::wostream *dump) = 0

Second pass to expand “abstract” nodes into more concrete ones.

Generically traverse the tree, expand the children, and perform garbagge collection.

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

struct ArithmeticAssignmentNode
#include <tree.h>

Node for operations like “vector (op)= something” Will expand to “vector = vector (op) something” children[0] is a MemoryVectorNode children[1] is whatever Node for the right operand.

Inherits from Aseba::AbstractTreeNode

Public Functions

ArithmeticAssignmentNode(const SourcePos &sourcePos, AsebaBinaryOperator op, Node *left, Node *right)

Constructor.

ArithmeticAssignmentNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

void checkVectorSize() const

Check the consistency in vectors’ size.

Node *expandAbstractNodes(std::wostream *dump)

Expand “left (op)= right” to “left = left (op) right”.

Node *expandVectorialNodes(std::wostream *dump, Compiler *compiler = nullptr, unsigned int index = 0)

Third pass to expand vectorial operations into mutliple scalar ones.

Generic implementation for non-vectorial nodes.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

AsebaBinaryOperator op

operator

Public Static Functions

ArithmeticAssignmentNode *fromArithmeticAssignmentToken(const SourcePos &sourcePos, Compiler::Token::Type token, Node *left, Node *right)

Protected Static Functions

AsebaBinaryOperator getBinaryOperator(Compiler::Token::Type token)

Protected Static Attributes

const AsebaBinaryOperator operatorMap = { ASEBA_OP_ADD, ASEBA_OP_SUB, ASEBA_OP_MULT, ASEBA_OP_DIV, ASEBA_OP_MOD, ASEBA_OP_SHIFT_LEFT, ASEBA_OP_SHIFT_RIGHT, ASEBA_OP_BIT_OR, ASEBA_OP_BIT_XOR, ASEBA_OP_BIT_AND }
struct ArrayReadNode
#include <tree.h>

Node for reading from an array.

children[0] is the index in the array

Inherits from Aseba::Node

Public Functions

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

Constructor.

ArrayReadNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

unsigned getVectorAddr() const

return the address of the left-most operand, or E_NOVAL if none

unsigned getVectorSize() const

return the children’s size, check for equal size, or E_NOVAL if no child

Public Members

unsigned arrayAddr

address of the first element of the array

unsigned arraySize

size of the array, might be used to assert compile-time access checks

std::wstring arrayName

name of the array (for debug)

struct ArrayWriteNode
#include <tree.h>

Node for writing to an array.

Value to store is supposed to be on the stack already children[0] is the index in the array

Inherits from Aseba::Node

Public Functions

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

Constructor.

ArrayWriteNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

unsigned getVectorAddr() const

return the address of the left-most operand, or E_NOVAL if none

unsigned getVectorSize() const

return the children’s size, check for equal size, or E_NOVAL if no child

Public Members

unsigned arrayAddr

address of the first element of the array

unsigned arraySize

size of the array, might be used to assert compile-time access checks

std::wstring arrayName

name of the array (for debug)

struct AsebaLocalEventDescription
#include <natives.h>

Description of a local event.

Public Members

const char *name

name of the function

const char *doc

documentation of the local event

struct AsebaNativeFunctionArgumentDescription
#include <natives.h>

Description of an argument of a native function.

Public Members

int16_t size

size of the argument in number of values; if negative, template parameter

const char *name

name of the argument

struct AsebaNativeFunctionDescription
#include <natives.h>

Description of a native function.

Public Members

const char *name

name of the function

const char *doc

documentation of the function

AsebaNativeFunctionArgumentDescription arguments[]

arguments, terminated by an element of size 0

struct AsebaVariableDescription
#include <natives.h>

Description of a variable.

Public Members

uint16_t size

size of the variable

const char *name

name of the variable

struct AsebaVMDescription
#include <natives.h>

Description of all variable.

Public Members

const char *name

name of the microcontroller

AsebaVariableDescription variables[]

named variables, terminated by a variable of size 0

struct AsebaVMState
#include <vm.h>

This structure contains the state of the Aseba VM.

This is the required and the sufficient data for the VM to run. This is not sufficient for the compiler to build bytecode, as there is no description of variable names and sizes nor description of native function. For this, a description corresponding to the actual target must be provided to the compiler. ALL fields of this structure have to be initialized correctly for aseba to work. An initial call to AsebaVMInitStep must be done prior to any call to AsebaVMPeriodicStep or AsebaVMEventStep.

Public Members

uint16_t nodeId
uint16_t bytecodeSize

total amount of bytecode space

uint16_t *bytecode

bytecode space of size bytecodeSize

uint16_t variablesSize

total amount of variables space

int16_t *variables

variables of size variableCount

uint16_t stackSize

depth of execution stack

int16_t *stack

execution stack of size stackSize

uint16_t flags
uint16_t pc
int16_t sp
uint16_t breakpoints[ASEBA_MAX_BREAKPOINTS]
uint16_t breakpointsCount
struct AssignmentNode
#include <tree.h>

Node for assignation.

children[0] is store code children[1] expression to store

Inherits from Aseba::Node

Public Functions

AssignmentNode(const SourcePos &sourcePos)

Constructor.

AssignmentNode(const SourcePos &sourcePos, Node *left, Node *right)

Constructor.

AssignmentNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

void checkVectorSize() const

Check the consistency in vectors’ size.

Node *expandVectorialNodes(std::wostream *dump, Compiler *compiler = nullptr, unsigned int index = 0)

Assignment between vectors is expanded into multiple scalar assignments.

Node::ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

struct BinaryArithmeticNode
#include <tree.h>

Node for binary arithmetic.

children[0] is left expression children[1] is right expression

Inherits from Aseba::Node

Public Functions

BinaryArithmeticNode(const SourcePos &sourcePos)
BinaryArithmeticNode(const SourcePos &sourcePos, AsebaBinaryOperator op, Node *left, Node *right)

Constructor.

BinaryArithmeticNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

void deMorganNotRemoval()

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

Node::ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

AsebaBinaryOperator op

operator

Public Static Functions

BinaryArithmeticNode *fromComparison(const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)

Create a binary arithmetic node for comparaison operation op.

BinaryArithmeticNode *fromShiftExpression(const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)

Create a binary arithmetic node for shift operation op.

BinaryArithmeticNode *fromAddExpression(const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)

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

BinaryArithmeticNode *fromMultExpression(const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)

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

BinaryArithmeticNode *fromBinaryExpression(const SourcePos &sourcePos, Compiler::Token::Type op, Node *left, Node *right)

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

struct BlockNode
#include <tree.h>

Node for L”block”, i.e. a vector of statements.

Inherits from Aseba::Node

Subclassed by Aseba::ProgramNode

Public Functions

BlockNode(const SourcePos &sourcePos)

Constructor.

BlockNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

struct BytecodeElement
#include <compiler.h>

A bytecode element.

Public Functions

BytecodeElement()
BytecodeElement(unsigned short bytecode)
BytecodeElement(unsigned short bytecode, unsigned short line)
operator unsigned short() const
unsigned getWordSize() const

Return the number of words this element takes in memory.

Public Members

unsigned short bytecode = {0xffff}
unsigned short line = {0}

bytecode itself

line in source code

struct BytecodeVector
#include <compiler.h>

Bytecode array in the form of a dequeue, for construction.

Inherits from std::deque< BytecodeElement >

Public Types

typedef std::map<unsigned, unsigned> EventAddressesToIdsMap

A map of event addresses to identifiers.

Public Functions

BytecodeVector()

Constructor.

void push_back(const BytecodeElement &be)
void changeStopToRetSub()

Change “stop” bytecode to “return from subroutine”.

unsigned short getTypeOfLast() const

Return the type of last bytecode element.

BytecodeVector::EventAddressesToIdsMap getEventAddressesToIds() const

Get the map of event addresses to identifiers.

Public Members

unsigned maxStackDepth = {0}

maximum depth of the stack used by all the computations of the bytecode

unsigned callDepth = {0}

for callable bytecode (i.e.

subroutines), used in analysis of stack check

unsigned lastLine = {0}

last line added, normally equal *this[this->size()-1].line, but may differ for instance on loops

struct CallNode
#include <tree.h>

Node for calling a native function may have children for pushing constants somewhere.

Inherits from Aseba::Node

Public Functions

CallNode(const SourcePos &sourcePos, unsigned funcId)

Constructor.

CallNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

unsigned funcId

identifier of the function to be called

std::vector<unsigned> templateArgs

sizes of templated arguments

struct CallSubNode
#include <tree.h>

Node for L”callsub” no children.

Inherits from Aseba::Node

Public Functions

CallSubNode(const SourcePos &sourcePos, std::wstring subroutineName)

Constructor.

CallSubNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

Node::ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

std::wstring subroutineName

the subroutine to call

unsigned subroutineId
struct CommonDefinitions
#include <compiler.h>

Definitions common to several nodes, such as events or some constants.

Public Functions

void clear()

Clear all the content.

Public Members

EventsDescriptionsVector events

All defined events.

ConstantsDefinitions constants

All globally defined constants.

class Compiler
#include <compiler.h>

Aseba Event Scripting Language compiler.

Public Types

using SubroutineTable = std::vector<SubroutineDescriptor>

Lookup table for subroutines id => (name, address, line)

typedef std::map<std::wstring, unsigned> SubroutineReverseTable

Reverse Lookup table for subroutines name => id.

using ImplementedEvents = std::set<unsigned int>

Lookup table to keep track of implemented events.

typedef std::map<std::wstring, int> ConstantsMap

Lookup table for constant name => value.

typedef std::map<std::wstring, unsigned> EventsMap

Lookup table for event name => id.

Public Functions

Compiler()

Constructor.

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

void 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().

const TargetDescription *getTargetDescription() const
const VariablesMap *getVariablesMap() const
const SubroutineTable *getSubroutineTable() const
void setCommonDefinitions(const CommonDefinitions *definitions)

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

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

Compile a new condition.

Return
returns true on success
Parameters
  • source: stream to read the source code from
  • bytecode: destination array for bytecode
  • allocatedVariablesCount: amount of allocated variables
  • errorDescription: error is copied there on error
  • dump: stream to send dump messages to

void setTranslateCallback(ErrorMessages::ErrorCallback newCB)

Public Static Functions

static std::wstring translate(ErrorCode error)
bool isKeyword(const std::wstring &word)

Return whether a string is a language keyword.

Protected Functions

void internalCompilerError() const

There is a bug in the compiler, ask for a bug report.

void expect(const Token::Type &type) const

Check if next token is of type, produce an exception otherwise.

unsigned expectUInt12Literal() const

Check if next token is an unsigned 12 bits integer literal.

If so, return it, if not, throw an exception

unsigned expectUInt16Literal() const

Check if next token is an unsigned 16 bits integer literal.

If so, return it, if not, throw an exception

unsigned expectPositiveInt16Literal() const

Check if next token is the positive part of a 16 bits signed integer literal.

If so, return it, if not, throw an exception

int expectAbsoluteInt16Literal(bool negative) const

Check if next token is the absolute part of a 16 bits signed integer literal.

If so, return it, if not, throw an exception

unsigned expectPositiveConstant() const

Check if next toxen is a valid positive part of a 16 bits signed integer constant.

int expectConstant() const

Check if next toxen is a valid 16 bits signed integer constant.

unsigned expectPositiveInt16LiteralOrConstant() const

Check and return either the positive part of a 16 bits signed integer or the value of a valid constant.

int expectInt16Literal()

Check and return a 16 bits signed integer.

int expectInt16LiteralOrConstant()

Check and return either a 16 bits signed integer or the value of a valid constant.

unsigned expectGlobalEventId() const

Check if next token is a known global event identifier.

unsigned expectAnyEventId() const

Check if next token is a known local or global event identifier.

std::wstring eventName(unsigned eventId) const

Return the name of an event given its identifier.

template <int length>
bool isOneOf(const Token::Type types[length]) const

Return true if next token is of the following types.

template <int length>
void expectOneOf(const Token::Type types[length]) const

Check if next token is of one of the following types, produce an exception otherwise.

void freeTemporaryMemory()
unsigned allocateTemporaryMemory(const SourcePos varPos, const unsigned size)
AssignmentNode *allocateTemporaryVariable(const SourcePos varPos, Node *rValue)
VariablesMap::const_iterator 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.

FunctionsMap::const_iterator 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.

Compiler::ConstantsMap::const_iterator 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.

Compiler::EventsMap::const_iterator 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.

Compiler::EventsMap::const_iterator findAnyEvent(const std::wstring &name, const SourcePos &pos) const
Compiler::SubroutineReverseTable::const_iterator 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.

bool constantExists(const std::wstring &name) const

Return true if a constant of a given name exists.

void buildMaps()

Build variables and functions maps.

void tokenize(std::wistream &source)

Parse source and build tokens vector.

Parameters
  • source: source code

wchar_t getNextCharacter(std::wistream &source, SourcePos &pos)
bool testNextCharacter(std::wistream &source, SourcePos &pos, wchar_t test, Token::Type tokenIfTrue)
void dumpTokens(std::wostream &dest) const

Debug print of tokens.

bool verifyStackCalls(PreLinkBytecode &preLinkBytecode)

Verify that no call path can create a stack overflow.

bool link(const PreLinkBytecode &preLinkBytecode, BytecodeVector &bytecode)

Create the final bytecode for a microcontroller.

void disassemble(BytecodeVector &bytecode, const PreLinkBytecode &preLinkBytecode, std::wostream &dump) const

Disassemble a microcontroller bytecode and dump it.

Node *parseProgram()

Parse “program” grammar element.

Node *parseStatement()

Parse “statement” grammar element.

Node *parseBlockStatement()

Parse “block statement” grammar element.

Node *parseReturn()

Parse “return statement” grammar element.

void parseConstDef()

Parse “const def” elements.

Node *parseVarDef()

Parse “var def” grammar element.

AssignmentNode *parseVarDefInit(MemoryVectorNode *lValue)
Node *parseAssignment()

Parse “assignment” grammar element.

Node *parseIfWhen(bool edgeSensitive)

Parse “if” grammar element.

Node *parseFor()

Parse “for” grammar element.

Node *parseWhile()

Parse “while” grammar element.

Node *parseOnEvent()

Parse “onevent” grammar element.

Node *parseEmit(bool shorterArgsAllowed = false)

Parse “event” grammar element.

Node *parseSubDecl()

Parse “sub” grammar element, declaration of subroutine.

Node *parseCallSub()

Parse “subcall” grammar element, call of subroutine.

Node *parseOr()

Parse “or” grammar element.

Node *parseAnd()

Parse “and” grammar element.

Node *parseNot()

Parse “not” grammar element.

Node *parseCondition()

Parse “condition” grammar element.

Node *parseBinaryOrExpression()

Parse “binary or” grammar element.

Node *parseBinaryXorExpression()

Parse “binary xor” grammar element.

Node *parseBinaryAndExpression()

Parse “binary and” grammar element.

Node *parseShiftExpression()

Parse “shift_expression” grammar element.

Node *parseAddExpression()

Parse “add_expression” grammar element.

Node *parseMultExpression()

Parse “mult_expression” grammar element.

Node *parseUnaryExpression()

Parse “unary_expression” grammar element.

Node *parseFunctionCall()

Parse “function_call” grammar element.

TupleVectorNode *parseTupleVector(bool compatibility = false)

Parse “[ …. ]” grammar element.

Node *parseConstantAndVariable()
MemoryVectorNode *parseVariable()
unsigned parseVariableDefSize()
Node *tryParsingConstantExpression(SourcePos pos, int &constantResult)

Use parseBinaryOrExpression() and try to reduce the result into an integer If successful, return nullptr and the integer in constantResult If unsuccessful, return the parsed tree (constantResult useless in this case)

int expectConstantExpression(SourcePos pos, Node *tree)

This is a generalization of expectPositiveInt16LiteralOrConstant() Try to reduce the expression into a single figure, if not raise an exception The tree pointed by “tree” is deleted during execution, not safe to use it after.

Protected Attributes

std::deque<Token> tokens

parsed tokens

VariablesMap variablesMap

variables lookup

ImplementedEvents implementedEvents

list of implemented events

FunctionsMap functionsMap

functions lookup

ConstantsMap constantsMap

constants map

EventsMap globalEventsMap

global-events map

EventsMap allEventsMap

all-events map

SubroutineTable subroutineTable

subroutine lookup

SubroutineReverseTable subroutineReverseTable

subroutine reverse lookup

unsigned freeVariableIndex

index pointing to the first free variable

unsigned endVariableIndex

(endMemory - endVariableIndex) is pointing to the first free variable at the end

const TargetDescription *targetDescription

description of the target VM

const CommonDefinitions *commonDefinitions

common definitions, such as events or some constants

ErrorMessages translator

Friends

friend Aseba::Compiler::AssignmentNode
friend Aseba::Compiler::CallSubNode
struct EmitNode
#include <tree.h>

Node for L”emit”.

may have children for pushing constants somewhere

Inherits from Aseba::Node

Public Functions

EmitNode(const SourcePos &sourcePos)

Constructor.

EmitNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

unsigned eventId

id of event to emit

unsigned arrayAddr

address of the first element of the array to send

unsigned arraySize

size of the array to send.

0 if event has no argument

struct Error
#include <compiler.h>

Compilation error.

Subclassed by Aseba::TranslatableError

Public Functions

Error(const SourcePos &pos, std::wstring message)

Create an error at pos.

Error()

Create an empty error.

std::wstring toWString() const

Return a string describing the error.

Return the string version of this error.

Public Members

SourcePos pos

position of error in source string

std::wstring message = L"not defined"

message

struct ErrorMessages
#include <compiler.h>

Return error messages based on error ID (needed to translate messages for other applications)

Public Types

using ErrorCallback = const std::wstring (*)(ErrorCode)

Type of the callback.

Public Functions

ErrorMessages()

Public Static Functions

const std::wstring defaultCallback(ErrorCode error)

Default callback.

struct EventDeclNode
#include <tree.h>

Node for L”onevent” no children.

Inherits from Aseba::Node

Public Functions

EventDeclNode(const SourcePos &sourcePos, unsigned eventId = 0)

Constructor.

EventDeclNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

unsigned eventId

the event id associated with this context

struct FoldedIfWhenNode
#include <tree.h>

Node for L”if” and L”when” with operator folded inside.

children[0] is left part of expression children[1] is right part of expression children[2] is true block children[3] is false block

Inherits from Aseba::Node

Public Functions

FoldedIfWhenNode(const SourcePos &sourcePos)

Constructor.

FoldedIfWhenNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

void checkVectorSize() const

Check the consistency in vectors’ size.

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

AsebaBinaryOperator op

operator

bool edgeSensitive

if true, true block is triggered only if previous comparison was false (“when” block).

If false, true block is triggered every time comparison is true

unsigned endLine

line of end keyword

struct FoldedWhileNode
#include <tree.h>

Node for L”while” with operator folded inside.

children[0] is left part of expression children[1] is right part of expression children[2] is block

Inherits from Aseba::Node

Public Functions

FoldedWhileNode(const SourcePos &sourcePos)

Constructor.

FoldedWhileNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

void checkVectorSize() const

Check the consistency in vectors’ size.

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

AsebaBinaryOperator op

operator

struct IfWhenNode
#include <tree.h>

Node for L”if” and L”when”.

children[0] is expression children[1] is true block children[2] is false block

Inherits from Aseba::Node

Public Functions

IfWhenNode(const SourcePos &sourcePos)

Constructor.

IfWhenNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

void checkVectorSize() const

Check the consistency in vectors’ size.

Node::ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

bool edgeSensitive

if true, true block is triggered only if previous comparison was false (“when” block).

If false, true block is triggered every time comparison is true

unsigned endLine

line of end keyword

struct ImmediateNode
#include <tree.h>

Node for pushing immediate value on stack.

Might generate either Small Immediate or Large Immediate bytecode depending on the range of value no children

Inherits from Aseba::Node

Public Functions

ImmediateNode(const SourcePos &sourcePos, int value)

Constructor.

ImmediateNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

Node *expandVectorialNodes(std::wostream *dump, Compiler *compiler = nullptr, unsigned int index = 0)

Expand into a copy of itself.

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

unsigned getVectorSize() const

return the children’s size, check for equal size, or E_NOVAL if no child

Public Members

int value

value to push on stack

struct LoadNativeArgNode
#include <tree.h>

Node for loading the address of the argument of a native function that is not known at compile time, but that does exist in memory.

Inherits from Aseba::Node

Public Functions

LoadNativeArgNode(MemoryVectorNode *memoryNode, unsigned tempAddr)

Constructor, delete the provided memoryNode.

LoadNativeArgNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

unsigned tempAddr

address of temporary (end of memory) for stack value duplication

unsigned arrayAddr

address of the first element of the array

unsigned arraySize

size of the array, might be used to assert compile-time access checks

std::wstring arrayName

name of the array (for debug)

struct LoadNode
#include <tree.h>

Node for loading a variable on stack.

no children

Inherits from Aseba::Node

Public Functions

LoadNode(const SourcePos &sourcePos, unsigned varAddr)

Constructor.

LoadNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

unsigned getVectorAddr() const

return the address of the left-most operand, or E_NOVAL if none

unsigned getVectorSize() const

return the children’s size, check for equal size, or E_NOVAL if no child

Public Members

unsigned varAddr

address of variable to load from

struct MemoryVectorNode
#include <tree.h>

Node for accessing a memory as a vector, in read or write operations If write == true, will expand to StoreNode or ArrayWriteNode If write == false, will expand to LoadNode or ArrayReadNode children[0] is an optional index If children[0] is a TupleVectorNode of one elements (int), it will be foo[x] If children[0] is a TupleVectorNode of two elements (int), it will be foo[x:y] If children[0] is another type of node, it will be foo[whatever] If children[0] doesn’t exist, access to the full array is considered.

Inherits from Aseba::AbstractTreeNode

Public Functions

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

Constructor.

MemoryVectorNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

Node *expandAbstractNodes(std::wostream *dump)

Dummy function, the node will be expanded during the vectorial pass.

Node *expandVectorialNodes(std::wostream *dump, Compiler *compiler = nullptr, unsigned int index = 0)

Expand to memory[index].

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

unsigned getVectorAddr() const

return the compile-time base address of the memory range, taking into account an immediate index foo[n] or foo[n:m] return E_NOVAL if foo[expr]

unsigned getVectorSize() const

return the vector’s length

bool isAddressStatic() const

return whether this node accesses a static address

virtual void setWrite(bool write)

Public Members

unsigned arrayAddr

address of the first element of the array

unsigned arraySize

size of the array, might be used to assert compile-time access checks

std::wstring arrayName

name of the array (for debug)

bool write

expand to a node for storing or loading data?

struct NamedValue
#include <compiler.h>

A name - value pair.

Public Functions

NamedValue(std::wstring name, int value)

Create a filled pair.

Public Members

std::wstring name

name part of the pair

int value

value part of the pair

struct NamedValuesVector
#include <compiler.h>

Generic vector of name - value pairs.

Inherits from std::vector< NamedValue >

Public Functions

bool contains(const std::wstring &s, size_t *position = nullptr) const

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

struct Node
#include <tree.h>

An abstract node of syntax tree.

Subclassed by Aseba::AbstractTreeNode, Aseba::ArrayReadNode, Aseba::ArrayWriteNode, Aseba::AssignmentNode, Aseba::BinaryArithmeticNode, Aseba::BlockNode, Aseba::CallNode, Aseba::CallSubNode, Aseba::EmitNode, Aseba::EventDeclNode, Aseba::FoldedIfWhenNode, Aseba::FoldedWhileNode, Aseba::IfWhenNode, Aseba::ImmediateNode, Aseba::LoadNativeArgNode, Aseba::LoadNode, Aseba::ReturnNode, Aseba::StoreNode, Aseba::SubDeclNode, Aseba::UnaryArithmeticNode, Aseba::WhileNode

Public Types

enum ReturnType

A type a node can return.

Values:

UNIT = 0
BOOL
INT
enum MemoryErrorCode

Values:

E_NOVAL = UINT_MAX
using NodesVector = std::vector<Node *>

Vector for children of a node.

Public Functions

Node(const SourcePos &sourcePos)

Constructor.

Node &operator=(const Node&)
Node(Node&&)
Node &operator=(Node &&rhs)
~Node()

Destructor, delete all children.

virtual Node *shallowCopy() const = 0

Return a shallow copy of the object (children point to the same objects)

Node *deepCopy() const

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

void checkVectorSize() const

Check the consistency in vectors’ size.

Node *expandAbstractNodes(std::wostream *dump)

Second pass to expand “abstract” nodes into more concrete ones.

Generically traverse the tree, expand the children, and perform garbagge collection.

Node *expandVectorialNodes(std::wostream *dump, Compiler *compiler = nullptr, unsigned int index = 0)

Third pass to expand vectorial operations into mutliple scalar ones.

Generic implementation for non-vectorial nodes.

Node::ReturnType typeCheck(Compiler *compiler)

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

virtual Node *optimize(std::wostream *dump) = 0

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

virtual void emit(PreLinkBytecode &bytecodes) const = 0

Generate bytecode.

virtual std::wstring toWString() const = 0

Return a string representation of this node.

virtual std::wstring toNodeName() const = 0

Return a string representation of the name of this node.

void dump(std::wostream &dest, unsigned &indent) const

Dump this node and the rest of the tree.

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

Return the name of a type.

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

Check for a specific type, throw an exception otherwise.

unsigned getVectorAddr() const

return the address of the left-most operand, or E_NOVAL if none

unsigned getVectorSize() const

return the children’s size, check for equal size, or E_NOVAL if no child

Public Members

NodesVector children

children of this node

SourcePos sourcePos

position is source

Protected Functions

Node(const Node&)
struct PreLinkBytecode
#include <compiler.h>

Bytecode use for compilation previous to linking.

Public Types

typedef std::map<unsigned, BytecodeVector> EventsBytecode

Map of events id to event bytecode.

typedef std::map<unsigned, BytecodeVector> SubroutinesBytecode

Map of routines id to routine bytecode.

Public Functions

PreLinkBytecode()

Add init event and point to currentBytecode it.

void 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

Public Members

EventsBytecode events

bytecode for events

SubroutinesBytecode subroutines

bytecode for routines

BytecodeVector *current

pointer to bytecode being constructed

struct ProgramNode
#include <tree.h>

Node for L”program”, i.e. a block node with some special behaviour later on.

Inherits from Aseba::BlockNode

Public Functions

ProgramNode(const SourcePos &sourcePos)

Constructor.

ProgramNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

Node *expandVectorialNodes(std::wostream *dump, Compiler *compiler = nullptr, unsigned int index = 0)

This is the root node, take in charge the tree creation / deletion.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

struct ReturnNode
#include <tree.h>

Node for returning from an event or subroutine has no children, just a jump of 0 offset that will be resolved at link time.

Inherits from Aseba::Node

Public Functions

ReturnNode(const SourcePos &sourcePos)
ReturnNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

unsigned getStackDepth() const

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

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

struct SourcePos
#include <compiler.h>

Position in a source file or string. First is line, second is column.

Public Functions

SourcePos(unsigned character, unsigned row, unsigned column)
SourcePos()
std::wstring toWString() const

Return the string version of this position.

Public Members

unsigned character = {0}

position in source text

unsigned row = {0}

line in source text

unsigned column = {0}

column in source text

bool valid = {false}

true if character, row and column hold valid values

struct StoreNode
#include <tree.h>

Node for storing a variable from stack.

no children

Inherits from Aseba::Node

Public Functions

StoreNode(const SourcePos &sourcePos, unsigned varAddr)

Constructor.

StoreNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

unsigned getVectorAddr() const

return the address of the left-most operand, or E_NOVAL if none

unsigned getVectorSize() const

return the children’s size, check for equal size, or E_NOVAL if no child

Public Members

unsigned varAddr

address of variable to store to

struct SubDeclNode
#include <tree.h>

Node for L”sub” no children.

Inherits from Aseba::Node

Public Functions

SubDeclNode(const SourcePos &sourcePos, unsigned subroutineId)

Constructor.

SubDeclNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

unsigned subroutineId

the associated subroutine

struct SubroutineDescriptor
#include <compiler.h>

Description of a subroutine.

Public Functions

SubroutineDescriptor(std::wstring name, unsigned address, unsigned line)

Public Members

std::wstring name
unsigned address
unsigned line
struct Token
#include <compiler.h>

A token is a parsed element of inputs.

Public Types

enum Type

Values:

TOKEN_END_OF_STREAM = 0
TOKEN_STR_when
TOKEN_STR_emit
TOKEN_STR_hidden_emit
TOKEN_STR_for
TOKEN_STR_in
TOKEN_STR_step
TOKEN_STR_while
TOKEN_STR_do
TOKEN_STR_if
TOKEN_STR_then
TOKEN_STR_else
TOKEN_STR_elseif
TOKEN_STR_end
TOKEN_STR_var
TOKEN_STR_const
TOKEN_STR_call
TOKEN_STR_sub
TOKEN_STR_callsub
TOKEN_STR_onevent
TOKEN_STR_abs
TOKEN_STR_return
TOKEN_STRING_LITERAL
TOKEN_INT_LITERAL
TOKEN_PAR_OPEN
TOKEN_PAR_CLOSE
TOKEN_BRACKET_OPEN
TOKEN_BRACKET_CLOSE
TOKEN_COLON
TOKEN_COMMA
TOKEN_ASSIGN
TOKEN_OP_OR
TOKEN_OP_AND
TOKEN_OP_NOT
TOKEN_OP_EQUAL
TOKEN_OP_NOT_EQUAL
TOKEN_OP_BIGGER
TOKEN_OP_BIGGER_EQUAL
TOKEN_OP_SMALLER
TOKEN_OP_SMALLER_EQUAL
TOKEN_OP_ADD
TOKEN_OP_NEG
TOKEN_OP_MULT
TOKEN_OP_DIV
TOKEN_OP_MOD
TOKEN_OP_SHIFT_LEFT
TOKEN_OP_SHIFT_RIGHT
TOKEN_OP_BIT_OR
TOKEN_OP_BIT_XOR
TOKEN_OP_BIT_AND
TOKEN_OP_BIT_NOT
TOKEN_OP_ADD_EQUAL
TOKEN_OP_NEG_EQUAL
TOKEN_OP_MULT_EQUAL
TOKEN_OP_DIV_EQUAL
TOKEN_OP_MOD_EQUAL
TOKEN_OP_SHIFT_LEFT_EQUAL
TOKEN_OP_SHIFT_RIGHT_EQUAL
TOKEN_OP_BIT_OR_EQUAL
TOKEN_OP_BIT_XOR_EQUAL
TOKEN_OP_BIT_AND_EQUAL
TOKEN_OP_PLUS_PLUS
TOKEN_OP_MINUS_MINUS

Public Functions

Token()
Token(Type type, SourcePos pos = SourcePos (), const std::wstring &value = L"")

Construct a new token of given type and value.

const std::wstring typeName() const

Return the name of the type of this token.

std::wstring toWString() const

Return a string representation of the token.

operator Type() const

Public Members

Aseba::Compiler::Token::Type TOKEN_END_OF_STREAM

type of this token

std::wstring sValue

string version of the value

int iValue = {0}

int version of the value, 0 if not applicable

SourcePos pos

position of token in source code

struct TranslatableError

Inherits from Aseba::Error

Public Functions

TranslatableError()
TranslatableError(const SourcePos &pos, ErrorCode error)
TranslatableError &arg(int value, int fieldWidth = 0, int base = 10, wchar_t fillChar = ' ')
TranslatableError &arg(long int value, int fieldWidth = 0, int base = 10, wchar_t fillChar = ' ')
TranslatableError &arg(unsigned value, int fieldWidth = 0, int base = 10, wchar_t fillChar = ' ')
TranslatableError &arg(float value, int fieldWidth = 0, int precision = 6, wchar_t fillChar = ' ')
TranslatableError &arg(const std::wstring &value)
Error toError()

Public Members

WFormatableString message

Public Static Functions

void setTranslateCB(ErrorMessages::ErrorCallback newCB)

Public Static Attributes

ErrorMessages::ErrorCallback translateCB = nullptr
struct TupleVectorNode
#include <tree.h>

Node for assembling values into an array children[x] is the x-th Node to be assembled.

Inherits from Aseba::AbstractTreeNode

Public Functions

TupleVectorNode(const SourcePos &sourcePos)

Constructor.

TupleVectorNode(const SourcePos &sourcePos, int value)
TupleVectorNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

Node *expandAbstractNodes(std::wostream *dump)

Dummy function, the node will be expanded during the vectorial pass.

Node *expandVectorialNodes(std::wostream *dump, Compiler *compiler = nullptr, unsigned int index = 0)

Expand to vector[index].

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

void dump(std::wostream &dest, unsigned &indent) const

Dump this node and the rest of the tree.

unsigned getVectorSize() const

return the children’s size, check for equal size, or E_NOVAL if no child

bool isImmediateVector() const
int getImmediateValue(unsigned index) const

return the n-th vector’s element

virtual void addImmediateValue(int value)
struct UnaryArithmeticAssignmentNode
#include <tree.h>

Node for operations like “vector(op)”, may be ++ or Will expand to “vector (op)= [1,…,1]” children[0] is a MemoryVectorNode.

Inherits from Aseba::AbstractTreeNode

Public Functions

UnaryArithmeticAssignmentNode(const SourcePos &sourcePos, Compiler::Token::Type token, Node *memory)

Constructor.

UnaryArithmeticAssignmentNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

Node *expandAbstractNodes(std::wostream *dump)

Expand “vector (opop)” to “vector (op)= 1”, and then call for the expansion of this last expression.

Node *expandVectorialNodes(std::wostream *dump, Compiler *compiler = nullptr, unsigned int index = 0)

Third pass to expand vectorial operations into mutliple scalar ones.

Generic implementation for non-vectorial nodes.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

AsebaBinaryOperator arithmeticOp

operator

struct UnaryArithmeticNode
#include <tree.h>

Node for unary arithmetic children[0] is the expression to negate.

Inherits from Aseba::Node

Public Functions

UnaryArithmeticNode(const SourcePos &sourcePos)

Constructor.

UnaryArithmeticNode(const SourcePos &sourcePos, AsebaUnaryOperator op, Node *child)

Constructor.

UnaryArithmeticNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

Node::ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

Public Members

AsebaUnaryOperator op

operator

struct WhileNode
#include <tree.h>

Node for L”while”.

children[0] is expression children[1] is block

Inherits from Aseba::Node

Public Functions

WhileNode(const SourcePos &sourcePos)

Constructor.

WhileNode *shallowCopy() const

Return a shallow copy of the object (children point to the same objects)

void checkVectorSize() const

Check the consistency in vectors’ size.

Node::ReturnType typeCheck(Compiler *compiler)

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

Node *optimize(std::wostream *dump)

Optimize this node, return the optimized node.

void emit(PreLinkBytecode &bytecodes) const

Generate bytecode.

std::wstring toWString() const

Return a string representation of this node.

std::wstring toNodeName() const

Return a string representation of the name of this node.

namespace Aseba

Typedefs

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

Vector of names of variables.

using Aseba::EventDescription = typedef NamedValue

An event description is a name - value pair.

using Aseba::ConstantDefinition = typedef NamedValue

An constant definition is a name - value pair.

using Aseba::EventsDescriptionsVector = typedef NamedValuesVector

Vector of events descriptions.

using Aseba::ConstantsDefinitions = typedef NamedValuesVector

Vector of constants definitions.

Enums

enum ErrorCode

Values:

ERROR_BROKEN_TARGET = 0
ASEBA_ERROR_STACK_OVERFLOW
ERROR_SCRIPT_TOO_BIG
ERROR_VARIABLE_NOT_DEFINED
ERROR_VARIABLE_NOT_DEFINED_GUESS
ERROR_FUNCTION_NOT_DEFINED
ERROR_FUNCTION_NOT_DEFINED_GUESS
ERROR_CONSTANT_NOT_DEFINED
ERROR_CONSTANT_NOT_DEFINED_GUESS
ERROR_EVENT_NOT_DEFINED
ERROR_EVENT_NOT_DEFINED_GUESS
ERROR_EMIT_LOCAL_EVENT
ERROR_SUBROUTINE_NOT_DEFINED
ERROR_SUBROUTINE_NOT_DEFINED_GUESS
ERROR_LINE
ERROR_COL
ERROR_UNBALANCED_COMMENT_BLOCK
ERROR_SYNTAX
ERROR_INVALID_IDENTIFIER
ERROR_INVALID_HEXA_NUMBER
ERROR_INVALID_BINARY_NUMBER
ERROR_NUMBER_INVALID_BASE
ERROR_IN_NUMBER
ERROR_INTERNAL
ERROR_EXPECTING
ERROR_UINT12_OUT_OF_RANGE
ERROR_UINT16_OUT_OF_RANGE
ERROR_PINT16_OUT_OF_RANGE
ERROR_INT16_OUT_OF_RANGE
ERROR_PCONSTANT_OUT_OF_RANGE
ERROR_CONSTANT_OUT_OF_RANGE
ERROR_EXPECTING_ONE_OF
ERROR_NOT_ENOUGH_TEMP_SPACE
ERROR_MISPLACED_VARDEF
ERROR_EXPECTING_IDENTIFIER
ERROR_CONST_ALREADY_DEFINED
ERROR_VAR_ALREADY_DEFINED
ERROR_VAR_CONST_COLLISION
ERROR_UNDEFINED_SIZE
ERROR_NOT_ENOUGH_SPACE
ERROR_EXPECTING_ASSIGNMENT
ERROR_FOR_NULL_STEPS
ERROR_FOR_START_HIGHER_THAN_END
ERROR_FOR_START_LOWER_THAN_END
ERROR_FOR_INVALID_INC_END_INDEX
ERROR_FOR_INVALID_DEC_END_INDEX
ERROR_EVENT_ALREADY_IMPL
ERROR_EVENT_ARG_TOO_BIG
ERROR_EVENT_WRONG_ARG_SIZE
ERROR_SUBROUTINE_ALREADY_DEF
ERROR_INDEX_EXPECTING_CONSTANT
ERROR_INDEX_WRONG_END
ERROR_SIZE_IS_NEGATIVE
ERROR_SIZE_IS_NULL
ERROR_NOT_CONST_EXPR
ERROR_FUNCTION_HAS_NO_ARG
ERROR_FUNCTION_NO_ENOUGH_ARG
ERROR_FUNCTION_WRONG_ARG_SIZE
ERROR_FUNCTION_WRONG_ARG_SIZE_TEMPLATE
ERROR_FUNCTION_TOO_MANY_ARG
ERROR_UNARY_ARITH_BUILD_UNEXPECTED
ERROR_INCORRECT_LEFT_VALUE
ERROR_ARRAY_OUT_OF_BOUND
ERROR_ARRAY_SIZE_MISMATCH
ERROR_IF_VECTOR_CONDITION
ERROR_WHILE_VECTOR_CONDITION
ERROR_ARRAY_ILLEGAL_ACCESS
ERROR_INFINITE_LOOP
ERROR_DIVISION_BY_ZERO
ERROR_ABS_NOT_POSSIBLE
ERROR_ARRAY_OUT_OF_BOUND_READ
ERROR_ARRAY_OUT_OF_BOUND_WRITE
ERROR_EXPECTING_TYPE
ERROR_EXPECTING_CONDITION
ERROR_TOKEN_END_OF_STREAM
ERROR_TOKEN_STR_when
ERROR_TOKEN_STR_emit
ERROR_TOKEN_STR_hidden_emit
ERROR_TOKEN_STR_for
ERROR_TOKEN_STR_in
ERROR_TOKEN_STR_step
ERROR_TOKEN_STR_while
ERROR_TOKEN_STR_do
ERROR_TOKEN_STR_if
ERROR_TOKEN_STR_then
ERROR_TOKEN_STR_else
ERROR_TOKEN_STR_elseif
ERROR_TOKEN_STR_end
ERROR_TOKEN_STR_var
ERROR_TOKEN_STR_const
ERROR_TOKEN_STR_call
ERROR_TOKEN_STR_sub
ERROR_TOKEN_STR_callsub
ERROR_TOKEN_STR_onevent
ERROR_TOKEN_STR_abs
ERROR_TOKEN_STR_return
ERROR_TOKEN_STRING_LITERAL
ERROR_TOKEN_INT_LITERAL
ERROR_TOKEN_PAR_OPEN
ERROR_TOKEN_PAR_CLOSE
ERROR_TOKEN_BRACKET_OPEN
ERROR_TOKEN_BRACKET_CLOSE
ERROR_TOKEN_COLON
ERROR_TOKEN_COMMA
ERROR_TOKEN_ASSIGN
ERROR_TOKEN_OP_OR
ERROR_TOKEN_OP_AND
ERROR_TOKEN_OP_NOT
ERROR_TOKEN_OP_BIT_OR
ERROR_TOKEN_OP_BIT_XOR
ERROR_TOKEN_OP_BIT_AND
ERROR_TOKEN_OP_BIT_NOT
ERROR_TOKEN_OP_BIT_OR_EQUAL
ERROR_TOKEN_OP_BIT_XOR_EQUAL
ERROR_TOKEN_OP_BIT_AND_EQUAL
ERROR_TOKEN_OP_EQUAL
ERROR_TOKEN_OP_NOT_EQUAL
ERROR_TOKEN_OP_BIGGER
ERROR_TOKEN_OP_BIGGER_EQUAL
ERROR_TOKEN_OP_SMALLER
ERROR_TOKEN_OP_SMALLER_EQUAL
ERROR_TOKEN_OP_SHIFT_LEFT
ERROR_TOKEN_OP_SHIFT_RIGHT
ERROR_TOKEN_OP_SHIFT_LEFT_EQUAL
ERROR_TOKEN_OP_SHIFT_RIGHT_EQUAL
ERROR_TOKEN_OP_ADD
ERROR_TOKEN_OP_NEG
ERROR_TOKEN_OP_ADD_EQUAL
ERROR_TOKEN_OP_NEG_EQUAL
ERROR_TOKEN_OP_PLUS_PLUS
ERROR_TOKEN_OP_MINUS_MINUS
ERROR_TOKEN_OP_MULT
ERROR_TOKEN_OP_DIV
ERROR_TOKEN_OP_MOD
ERROR_TOKEN_OP_MULT_EQUAL
ERROR_TOKEN_OP_DIV_EQUAL
ERROR_TOKEN_OP_MOD_EQUAL
ERROR_TOKEN_UNKNOWN
ERROR_UNKNOWN_ERROR
ERROR_END

Functions

template <class T>
unsigned int 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.

template <typename MapType>
MapType::const_iterator 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.

template <typename T>
bool isPOT(T number)

Return true if number is a power of two.

template <typename T>
unsigned shiftFromPOT(T number)

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

std::wstring binaryOperatorToString(AsebaBinaryOperator op)

Return the string corresponding to the binary operator.

std::wstring unaryOperatorToString(AsebaUnaryOperator op)

Return the string corresponding to the unary operator.

static void addImmediateToBytecodes(int value, const SourcePos &sourcePos, PreLinkBytecode &bytecodes)
static bool matchNameInMemoryVector(const Node *root, std::wstring name)

Variables

const wchar_t *error_map[ERROR_END]
file analysis.cpp
#include “compiler.h”#include “common/consts.h”#include <cassert>#include <iostream>
file compiler.cpp
#include “compiler.h”#include “tree.h”#include “errors_code.h”#include “common/consts.h”#include “common/utils/utils.h”#include “common/utils/FormatableString.h”#include <cassert>#include <cstdlib>#include <sstream>#include <iostream>#include <fstream>#include <iomanip>#include <memory>#include <limits>#include <iterator>
file compiler.h
#include <utility>#include <vector>#include <deque>#include <string>#include <map>#include <set>#include <istream>#include “errors_code.h”#include “common/types.h”#include “common/msg/TargetDescription.h”#include “common/utils/FormatableString.h”
file errors.cpp
#include “errors_code.h”#include “compiler.h”#include <sstream>#include <string>
file errors_code.h
file identifier-lookup.cpp
#include “compiler.h”#include “tree.h”#include “common/consts.h”#include “common/utils/FormatableString.h”#include <cassert>#include <cstdlib>#include <sstream>#include <iostream>#include <fstream>#include <iomanip>#include <memory>#include <limits>#include <algorithm>#include <malloc.h>

Functions for quick lookup of identifiers (variables, events, subroutines, native functions, constants) using maps.

file lexer.cpp
#include “compiler.h”#include “common/utils/FormatableString.h”#include “common/utils/utils.h”#include <cstdlib>#include <sstream>#include <ostream>#include <cctype>#include <cstdio>#include <cwctype>#include <locale>
file mainpage.dox
file natives.c
#include “common/consts.h”#include “common/types.h”#include “natives.h”#include <string.h>#include <assert.h>

Functions

int16_t aseba_atan2(int16_t y, int16_t x)
int16_t aseba_sin(int16_t angle)
int16_t aseba_cos(int16_t angle)
int16_t aseba_sqrt(int16_t num)
void aseba_comb_sort(int16_t *input, uint16_t size)
void AsebaNative_veccopy(AsebaVMState *vm)

Function to copy a vector.

void AsebaNative_vecfill(AsebaVMState *vm)

Function to fill all the elements of a vector to a specific value.

void AsebaNative_vecaddscalar(AsebaVMState *vm)

Function to add a scalar to each element of a vector.

void AsebaNative_vecadd(AsebaVMState *vm)

Function to add two vectors.

void AsebaNative_vecsub(AsebaVMState *vm)

Function to substract two vectors.

void AsebaNative_vecmul(AsebaVMState *vm)

Function to multiply two vectors elements by elements.

void AsebaNative_vecdiv(AsebaVMState *vm)

Function to divide two vectors elements by elements.

void AsebaNative_vecmin(AsebaVMState *vm)

Function to take the element by element minimum.

void AsebaNative_vecmax(AsebaVMState *vm)

Function to take the element by element maximum.

void AsebaNative_vecclamp(AsebaVMState *vm)

Function to clamp a vector of values element by element.

void AsebaNative_vecdot(AsebaVMState *vm)

Function to perform a dot product on a vector.

void AsebaNative_vecstat(AsebaVMState *vm)

Function to perform statistics on a vector.

void AsebaNative_vecargbounds(AsebaVMState *vm)

Function to get indices of the bounds of a vector.

void AsebaNative_vecsort(AsebaVMState *vm)

Function to sort a vector.

void AsebaNative_mathmuldiv(AsebaVMState *vm)

Function to perform dest = (a*b)/c in 32 bits.

void AsebaNative_mathatan2(AsebaVMState *vm)

Function to perform atan2.

void AsebaNative_mathsin(AsebaVMState *vm)

Function to perform sin.

void AsebaNative_mathcos(AsebaVMState *vm)

Function to perform cos.

void AsebaNative_mathrot2(AsebaVMState *vm)

Function to perform the rotation of a vector.

void AsebaNative_mathsqrt(AsebaVMState *vm)

Function to perform sqrt.

void AsebaNative_vecnonzerosequence(AsebaVMState *vm)

Function to get the middle index of the largest sequence of non-zero elements.

void AsebaSetRandomSeed(uint16_t seed)

Functon to set the seed of random generator.

uint16_t AsebaGetRandom()

Functon to get a random number.

void AsebaNative_rand(AsebaVMState *vm)

Function to get a 16-bit signed random number.

static void deque_shift(AsebaVMState *vm, uint16_t dq, uint16_t dq_capacity, uint16_t target, int16_t last, int16_t delta)
static void deque_throw_exception(AsebaVMState *vm)
void AsebaNative_deqsize(AsebaVMState *vm)

Function that reports size of deque dest in size.

static void _AsebaNative_deqget(AsebaVMState *vm, uint16_t dest, uint16_t deque, uint16_t index_val, uint16_t dest_length, uint16_t deque_length)
void AsebaNative_deqget(AsebaVMState *vm)

Function that copies index-th len-dest elements of deque src to dest.

void AsebaNative_deqset(AsebaVMState *vm)

Function that copies len-src elements of src to index-th position of deque dest.

static void _AsebaNative_deqinsert(AsebaVMState *vm, uint16_t deque, uint16_t src, uint16_t index_val, uint16_t deque_length, uint16_t src_length)
void AsebaNative_deqinsert(AsebaVMState *vm)

Function that copies len-src elements of src before index-th position of deque dest.

static void _AsebaNative_deqerase(AsebaVMState *vm, uint16_t deque, uint16_t index_val, uint16_t len_val, uint16_t deque_length)
void AsebaNative_deqerase(AsebaVMState *vm)

Function that erases len elements from deque dest starting from index-th position.

void AsebaNative_deqpushfront(AsebaVMState *vm)

Function that copies len-src elements of src before the front of deque dest.

void AsebaNative_deqpushback(AsebaVMState *vm)

Function that copies len-src elements of src after the end of deque dest.

void AsebaNative_deqpopfront(AsebaVMState *vm)

Function that erases len elements from deque dest starting at the front.

void AsebaNative_deqpopback(AsebaVMState *vm)

Function that erases len elements from deque dest starting from the end.

Variables

const int16_t aseba_atan_table[20 *8+1] = { 652, 735, 816, 896, 977, 1058, 1139, 1218, 1300, 1459, 1620, 1777, 1935, 2093, 2250, 2403, 2556, 2868, 3164, 3458, 3748, 4029, 4307, 4578, 4839, 5359, 5836, 6290, 6720, 7126, 7507, 7861, 8203, 8825, 9357, 9839, 10260, 10640, 10976, 11281, 11557, 12037, 12425, 12755, 13036, 13277, 13486, 13671, 13837, 14112, 14331, 14514, 14666, 14796, 14907, 15003, 15091, 15235, 15348, 15441, 15519, 15585, 15642, 15691, 15736, 15808, 15865, 15912, 15951, 15984, 16013, 16037, 16060, 16096, 16125, 16148, 16168, 16184, 16199, 16211, 16222, 16240, 16255, 16266, 16276, 16284, 16292, 16298, 16303, 16312, 16320, 16325, 16331, 16334, 16338, 16341, 16344, 16348, 16352, 16355, 16357, 16360, 16361, 16363, 16364, 16366, 16369, 16369, 16371, 16372, 16373, 16373, 16375, 16375, 16377, 16376, 16378, 16378, 16378, 16379, 16379, 16380, 16380, 16380, 16382, 16381, 16381, 16381, 16382, 16382, 16382, 16382, 16382, 16382, 16384, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384}
const int16_t aseba_sin_table[128+1] = { 0, 403, 804, 1207, 1608, 2010, 2411, 2812, 3212, 3612, 4011, 4411, 4808, 5206, 5603, 5998, 6393, 6787, 7180, 7572, 7962, 8352, 8740, 9127, 9513, 9896, 10279, 10660, 11040, 11417, 11794, 12167, 12540, 12911, 13279, 13646, 14010, 14373, 14733, 15091, 15447, 15801, 16151, 16500, 16846, 17190, 17531, 17869, 18205, 18538, 18868, 19196, 19520, 19842, 20160, 20476, 20788, 21097, 21403, 21706, 22006, 22302, 22595, 22884, 23171, 23453, 23732, 24008, 24279, 24548, 24812, 25073, 25330, 25583, 25833, 26078, 26320, 26557, 26791, 27020, 27246, 27467, 27684, 27897, 28106, 28311, 28511, 28707, 28899, 29086, 29269, 29448, 29622, 29792, 29957, 30117, 30274, 30425, 30572, 30715, 30852, 30985, 31114, 31238, 31357, 31471, 31581, 31686, 31786, 31881, 31972, 32057, 32138, 32215, 32285, 32352, 32413, 32470, 32521, 32569, 32610, 32647, 32679, 32706, 32728, 32746, 32758, 32766, 32767, }
const AsebaNativeFunctionDescription AsebaNativeDescription_veccopy = {"math.copy", "copies src to dest element by element", {{-1, "dest"}, {-1, "src"}, {0, 0}}}

Description of AsebaNative_veccopy.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecfill = {"math.fill", "fills dest with constant value", {{-1, "dest"}, {1, "value"}, {0, 0}}}

Description of AsebaNative_vecfill.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecaddscalar = { "math.addscalar", "add scalar to each element of src and store result to dest", {{-1, "dest"}, {-1, "src"}, {1, "scalar"}, {0, 0}}}

Description of AsebaNative_vecaddscalar.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecadd = { "math.add", "adds src1 and src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecadd.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecsub = { "math.sub", "substracts src2 from src1 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecsub.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmul = { "math.mul", "multiplies src1 and src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecadd.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecdiv = { "math.div", "divides src1 by src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecsub.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmin = { "math.min", "writes the minimum of src1 and src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecmin.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmax = { "math.max", "writes the maximum of src1 and src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecsmax.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecclamp = { "math.clamp", "clamp src to low/high bounds into dest, element by element", {{-1, "dest"}, {-1, "src"}, {-1, "low"}, {-1, "high"}, {0, 0}}}

Description of AsebaNative_vecclamp.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecdot = { "math.dot", "writes the dot product of src1 and src2 to dest, after a shift", {{1, "dest"}, {-1, "src1"}, {-1, "src2"}, {1, "shift"}, {0, 0}}}

Description of AsebaNative_vecdot.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecstat = { "math.stat", "performs statistics on src", {{-1, "src"}, {1, "min"}, {1, "max"}, {1, "mean"}, {0, 0}}}

Description of AsebaNative_vecstat.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecargbounds = { "math.argbounds", "get the indices (argmin, argmax) of the limit values of src", {{-1, "src"}, {1, "argmin"}, {1, "argmax"}, {0, 0}}}

Description of AsebaNative_vecargbounds.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecsort = {"math.sort", "sort array in place", {{-1, "array"}, {0, 0}}}

Description of AsebaNative_vecsort.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathmuldiv = { "math.muldiv", "performs dest = (a*b)/c in 32 bits element by element", {{-1, "dest"}, {-1, "a"}, {-1, "b"}, {-1, "c"}, {0, 0}}}

Description of AsebaNative_mathmuldiv.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathatan2 = { "math.atan2", "performs dest = atan2(y,x) element by element", {{-1, "dest"}, {-1, "y"}, {-1, "x"}, {0, 0}}}

Description of AsebaNative_mathatan2.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathsin = {"math.sin", "performs dest = sin(x) element by element", {{-1, "dest"}, {-1, "x"}, {0, 0}}}

Description of AsebaNative_mathsin.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathcos = {"math.cos", "performs dest = cos(x) element by element", {{-1, "dest"}, {-1, "x"}, {0, 0}}}

Description of AsebaNative_mathcos.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathrot2 = {"math.rot2", "rotates v of angle a to dest", {{2, "dest"}, {2, "v"}, {1, "a"}, {0, 0}}}

Description of AsebaNative_mathrot2.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathsqrt = {"math.sqrt", "performs dest = sqrt(x) element by element", {{-1, "dest"}, {-1, "x"}, {0, 0}}}

Description of AsebaNative_mathsqrt.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecnonzerosequence = { "math.nzseq", "write to dest the middle index of the largest sequence of non-zero elements from src, -1 if " "not found or if smaller than minLength", {{1, "dest"}, {-1, "src"}, {1, "minLength"}, {0, 0}}}

Description of AsebaNative_vecnonzerosequence.

uint16_t rnd_state
const AsebaNativeFunctionDescription AsebaNativeDescription_rand = {"math.rand", "fill array with random values", {{-1, "dest"}, {0, 0}}}

Description of AsebaNative_rand.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqsize = {"deque.size", "report size of dest", {{-1, "deque"}, {1, "size"}, {0, 0}}}

Description of AsebaNative_deqsize.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqget = { "deque.get", "fill dest from deque at index", {{-1, "deque"}, {-2, "dest"}, {1, "index"}, {0, 0}}}

Description of AsebaNative_deqget.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqset = { "deque.set", "copies src to deque at index", {{-1, "deque"}, {-2, "src"}, {1, "index"}, {0, 0}}}

Description of AsebaNative_deqset.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqinsert = { "deque.insert", "shift deque at index by len(src) and insert src", {{-1, "deque"}, {-2, "src"}, {1, "index"}, {0, 0}}}

Description of AsebaNative_deqinsert.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqerase = { "deque.erase", "shift deque at index by len to erase", {{-1, "deque"}, {1, "index"}, {1, "len"}, {0, 0}}}

Description of AsebaNative_deqerase.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpushfront = {"deque.push_front", "insert src before the front of deque", {{-1, "deque"}, {-2, "src"}, {0, 0}}}

Description of AsebaNative_deqpushfront.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpushback = {"deque.push_back", "insert src after the back of deque", {{-1, "deque"}, {-2, "src"}, {0, 0}}}

Description of AsebaNative_deqpushback.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpopfront = { "deque.pop_front", "fill dest from front of deque then erase elements", {{-1, "deque"}, {-2, "dest"}, {0, 0}}}

Description of AsebaNative_deqpopfront.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpopback = { "deque.pop_back", "fill dest from back of deque then erase elements", {{-1, "deque"}, {-2, "dest"}, {0, 0}}}

Description of AsebaNative_deqpopback.

file natives.h
#include “common/types.h”#include “vm.h”

Definition of standard natives functions for Aseba Virtual Machine.

Defines

ASEBA_NATIVES_STD_COUNT

Embedded targets must know the size of ASEBA_NATIVES_STD_FUNCTIONS without having to compute them by hand, please update this when adding a new function.

ASEBA_NATIVES_STD_FUNCTIONS

snippet to include standard native functions

ASEBA_NATIVES_STD_DESCRIPTIONS

snippet to include descriptions of standard native functions

Typedefs

typedef void (*AsebaNativeFunctionPointer)(AsebaVMState *vm)

Signature of a native function.

Functions

static int16_t AsebaNativePopArg(AsebaVMState *vm)

Return an argument on the stack, including the value of template parameters.

void AsebaNative_veccopy(AsebaVMState *vm)

Function to copy a vector.

void AsebaNative_vecfill(AsebaVMState *vm)

Function to fill all the elements of a vector to a specific value.

void AsebaNative_vecaddscalar(AsebaVMState *vm)

Function to add a scalar to each element of a vector.

void AsebaNative_vecadd(AsebaVMState *vm)

Function to add two vectors.

void AsebaNative_vecsub(AsebaVMState *vm)

Function to substract two vectors.

void AsebaNative_vecmul(AsebaVMState *vm)

Function to multiply two vectors elements by elements.

void AsebaNative_vecdiv(AsebaVMState *vm)

Function to divide two vectors elements by elements.

void AsebaNative_vecmin(AsebaVMState *vm)

Function to take the element by element minimum.

void AsebaNative_vecmax(AsebaVMState *vm)

Function to take the element by element maximum.

void AsebaNative_vecclamp(AsebaVMState *vm)

Function to clamp a vector of values element by element.

void AsebaNative_vecdot(AsebaVMState *vm)

Function to perform a dot product on a vector.

void AsebaNative_vecstat(AsebaVMState *vm)

Function to perform statistics on a vector.

void AsebaNative_vecargbounds(AsebaVMState *vm)

Function to get indices of the bounds of a vector.

void AsebaNative_vecsort(AsebaVMState *vm)

Function to sort a vector.

void AsebaNative_mathmuldiv(AsebaVMState *vm)

Function to perform dest = (a*b)/c in 32 bits.

void AsebaNative_mathatan2(AsebaVMState *vm)

Function to perform atan2.

void AsebaNative_mathsin(AsebaVMState *vm)

Function to perform sin.

void AsebaNative_mathcos(AsebaVMState *vm)

Function to perform cos.

void AsebaNative_mathrot2(AsebaVMState *vm)

Function to perform the rotation of a vector.

void AsebaNative_mathsqrt(AsebaVMState *vm)

Function to perform sqrt.

void AsebaNative_vecnonzerosequence(AsebaVMState *vm)

Function to get the middle index of the largest sequence of non-zero elements.

void AsebaSetRandomSeed(uint16_t seed)

Functon to set the seed of random generator.

uint16_t AsebaGetRandom()

Functon to get a random number.

void AsebaNative_rand(AsebaVMState *vm)

Function to get a 16-bit signed random number.

void AsebaNative_deqsize(AsebaVMState *vm)

Function that reports size of deque dest in size.

void AsebaNative_deqget(AsebaVMState *vm)

Function that copies index-th len-dest elements of deque src to dest.

void AsebaNative_deqset(AsebaVMState *vm)

Function that copies len-src elements of src to index-th position of deque dest.

void AsebaNative_deqinsert(AsebaVMState *vm)

Function that copies len-src elements of src before index-th position of deque dest.

void AsebaNative_deqerase(AsebaVMState *vm)

Function that erases len elements from deque dest starting from index-th position.

void AsebaNative_deqpushfront(AsebaVMState *vm)

Function that copies len-src elements of src before the front of deque dest.

void AsebaNative_deqpushback(AsebaVMState *vm)

Function that copies len-src elements of src after the end of deque dest.

void AsebaNative_deqpopfront(AsebaVMState *vm)

Function that erases len elements from deque dest starting at the front.

void AsebaNative_deqpopback(AsebaVMState *vm)

Function that erases len elements from deque dest starting from the end.

Variables

const AsebaNativeFunctionDescription AsebaNativeDescription_veccopy

Description of AsebaNative_veccopy.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecfill

Description of AsebaNative_vecfill.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecaddscalar

Description of AsebaNative_vecaddscalar.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecadd

Description of AsebaNative_vecadd.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecsub

Description of AsebaNative_vecsub.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmul

Description of AsebaNative_vecadd.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecdiv

Description of AsebaNative_vecsub.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmin

Description of AsebaNative_vecmin.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmax

Description of AsebaNative_vecsmax.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecclamp

Description of AsebaNative_vecclamp.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecdot

Description of AsebaNative_vecdot.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecstat

Description of AsebaNative_vecstat.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecargbounds

Description of AsebaNative_vecargbounds.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecsort

Description of AsebaNative_vecsort.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathmuldiv

Description of AsebaNative_mathmuldiv.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathatan2

Description of AsebaNative_mathatan2.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathsin

Description of AsebaNative_mathsin.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathcos

Description of AsebaNative_mathcos.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathrot2

Description of AsebaNative_mathrot2.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathsqrt

Description of AsebaNative_mathsqrt.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecnonzerosequence

Description of AsebaNative_vecnonzerosequence.

const AsebaNativeFunctionDescription AsebaNativeDescription_rand

Description of AsebaNative_rand.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqsize

Description of AsebaNative_deqsize.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqget

Description of AsebaNative_deqget.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqset

Description of AsebaNative_deqset.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqinsert

Description of AsebaNative_deqinsert.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqerase

Description of AsebaNative_deqerase.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpushfront

Description of AsebaNative_deqpushfront.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpushback

Description of AsebaNative_deqpushback.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpopfront

Description of AsebaNative_deqpopfront.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpopback

Description of AsebaNative_deqpopback.

file parser.cpp
#include “compiler.h”#include “tree.h”#include “common/utils/FormatableString.h”#include “common/utils/utils.h”#include <memory>#include <valarray>#include <iostream>#include <cassert>#include <typeinfo>#include <algorithm>

Defines

IS_ONE_OF(array)
EXPECT_ONE_OF(array)
STRICT
file power-of-two.h
file tree-build.cpp
#include “tree.h”#include <cstdlib>#include <iostream>#include <utility>
file tree-dump.cpp
#include “tree.h”#include “common/utils/FormatableString.h”#include <ostream>
file tree-emit.cpp
#include “tree.h”#include “common/utils/utils.h”#include <cassert>#include <cstdlib>#include <algorithm>#include <iterator>
file tree-expand.cpp
#include “compiler.h”#include “tree.h”#include “common/utils/utils.h”#include “common/utils/FormatableString.h”#include <cassert>#include <memory>#include <iostream>
file tree-optimize.cpp
#include “tree.h”#include “power-of-two.h”#include “common/utils/FormatableString.h”#include “common/utils/utils.h”#include <cassert>#include <cstdlib>
file tree-typecheck.cpp
#include “tree.h”#include “common/utils/FormatableString.h”#include <cstdlib>
file tree.h
#include “compiler.h”#include “common/consts.h”#include “common/utils/FormatableString.h”#include <vector>#include <string>#include <ostream>#include <climits>#include <cassert>#include <iostream>
file vm.c
#include “common/consts.h”#include “common/types.h”#include “vm.h”#include <string.h>

Implementation of standard natives functions for Aseba Virtual Machine.

Implementation of Aseba Virtual Machine.

Defines

GET_BIT(v, b)

Return true if bit b of v is 1.

BIT_SET(v, b)

Set bit b of v to 1.

BIT_CLR(v, b)

Set bit b of v to 0.

Functions

void AsebaVMSendExecutionStateChanged(AsebaVMState *vm)

Send an execution state changed message.

void AsebaVMInit(AsebaVMState *vm)

Setup the execution status of the VM.

This is not sufficient to have a working VM. nodeId and bytecode, variables, and stack along with their sizes must be set outside this function. The content of the variable array is zeroed by this function.

uint16_t AsebaVMGetEventAddress(AsebaVMState *vm, uint16_t event)

Return the starting address of an event, or 0 if the event is not handled.

uint16_t AsebaVMSetupEvent(AsebaVMState *vm, uint16_t event)

Setup VM to execute an event.

If event is not handled, VM is not ready for run. Return the starting address of the event, or 0 if the event is not handled.

static int16_t AsebaVMDoBinaryOperation(AsebaVMState *vm, int16_t valueOne, int16_t valueTwo, uint16_t op)
static int16_t AsebaVMDoUnaryOperation(AsebaVMState *vm, int16_t value, uint16_t op)
void AsebaVMStep(AsebaVMState *vm)

Execute one bytecode of the current VM thread.

VM must be ready for run otherwise trashes may occur.

void AsebaVMEmitNodeSpecificError(AsebaVMState *vm, const char *message)

Can be called by glue code (including native functions), to stop vm and emit a node specific error.

uint16_t AsebaVMCheckBreakpoint(AsebaVMState *vm)

Execute on bytecode of the current VM thread and check for potential breakpoints.

Return 1 if breakpoint was seen, 0 otherwise. VM must be ready for run otherwise trashes may occur.

void AsebaDebugBareRun(AsebaVMState *vm, uint16_t stepsLimit)

Run without support of breakpoints.

Check ASEBA_VM_EVENT_RUNNING_MASK to exit on interrupts or stepsLimit if > 0.

void AsebaDebugBreakpointRun(AsebaVMState *vm, uint16_t stepsLimit)

Run with support of breakpoints.

Also check ASEBA_VM_EVENT_RUNNING_MASK to exit on interrupts.

uint16_t AsebaVMRun(AsebaVMState *vm, uint16_t stepsLimit)

Run the VM depending on the current execution mode.

Either run or step, depending of the current mode. If stepsLimit > 0, execute at maximim stepsLimit Return 1 if anything was executed, 0 otherwise.

uint8_t AsebaVMSetBreakpoint(AsebaVMState *vm, uint16_t pc)

Set a breakpoint at a specific location.

uint16_t AsebaVMClearBreakpoint(AsebaVMState *vm, uint16_t pc)

Clear the breakpoint at a specific location.

void AsebaVMClearBreakpoints(AsebaVMState *vm)

Clear all breakpoints.

static void AsebaVMResetWhenFlags(AsebaVMState *vm)

Reset all when flags in their default states in the bytecode.

void AsebaVMDebugMessage(AsebaVMState *vm, uint16_t id, uint16_t *data, uint16_t dataLength)

Execute a debug action from a debug message.

dataLength is given in number of uint16_t.

uint16_t AsebaVMShouldDropPacket(AsebaVMState *vm, uint16_t source, const uint8_t *data)

Return non-zero if VM will ignore the packet, 0 otherwise.

file vm.h
#include “common/types.h”

Definition of Aseba Virtual Machine.

Defines

AsebaMaskSet(v, m)

Set the part masked by m of v to 1.

AsebaMaskClear(v, m)

Set the part masked by m of v to 0.

AsebaMaskIsSet(v, m)

Returns true if the part masked by m of v is 1.

AsebaMaskIsClear(v, m)

Returns true if the part masked by m of v is 0.

AsebaSendMessageWords(vm, type, data, size)

Enums

enum [anonymous]

Values:

ASEBA_MAX_BREAKPOINTS = 16

maximum number of simultaneous breakpoints the target supports

enum AsebaAssertReason

Possible causes of AsebaAssert.

Values:

ASEBA_ASSERT_UNKNOWN = 0
ASEBA_ASSERT_UNKNOWN_UNARY_OPERATOR
ASEBA_ASSERT_UNKNOWN_BINARY_OPERATOR
ASEBA_ASSERT_UNKNOWN_BYTECODE
ASEBA_ASSERT_STACK_OVERFLOW
ASEBA_ASSERT_STACK_UNDERFLOW
ASEBA_ASSERT_OUT_OF_VARIABLES_BOUNDS
ASEBA_ASSERT_OUT_OF_BYTECODE_BOUNDS
ASEBA_ASSERT_STEP_OUT_OF_RUN
ASEBA_ASSERT_BREAKPOINT_OUT_OF_BYTECODE_BOUNDS
ASEBA_ASSERT_EMIT_BUFFER_TOO_LONG

Functions

void AsebaVMInit(AsebaVMState *vm)

Setup the execution status of the VM.

This is not sufficient to have a working VM. nodeId and bytecode, variables, and stack along with their sizes must be set outside this function. The content of the variable array is zeroed by this function.

uint16_t AsebaVMGetEventAddress(AsebaVMState *vm, uint16_t event)

Return the starting address of an event, or 0 if the event is not handled.

uint16_t AsebaVMSetupEvent(AsebaVMState *vm, uint16_t event)

Setup VM to execute an event.

If event is not handled, VM is not ready for run. Return the starting address of the event, or 0 if the event is not handled.

uint16_t AsebaVMRun(AsebaVMState *vm, uint16_t stepsLimit)

Run the VM depending on the current execution mode.

Either run or step, depending of the current mode. If stepsLimit > 0, execute at maximim stepsLimit Return 1 if anything was executed, 0 otherwise.

void AsebaVMDebugMessage(AsebaVMState *vm, uint16_t id, uint16_t *data, uint16_t dataLength)

Execute a debug action from a debug message.

dataLength is given in number of uint16_t.

void AsebaVMEmitNodeSpecificError(AsebaVMState *vm, const char *message)

Can be called by glue code (including native functions), to stop vm and emit a node specific error.

uint16_t AsebaVMShouldDropPacket(AsebaVMState *vm, uint16_t source, const uint8_t *data)

Return non-zero if VM will ignore the packet, 0 otherwise.

void AsebaSendMessage(AsebaVMState *vm, uint16_t id, const void *data, uint16_t size)

Called by AsebaStep if there is a message (not an user event) to send.

size is given in number of bytes.

void AsebaSendVariables(AsebaVMState *vm, uint16_t start, uint16_t length)

Called by AsebaVMDebugMessage when some variables must be sent efficiently.

void AsebaSendDescription(AsebaVMState *vm)

Called by AsebaVMDebugMessage when VM must send its description on the network.

void AsebaNativeFunction(AsebaVMState *vm, uint16_t id)

Called by AsebaStep to perform a native function call.

void AsebaWriteBytecode(AsebaVMState *vm)

Called by AsebaVMDebugMessage when VM must write its bytecode to flash, write an empty function to leave feature unsupported.

void AsebaResetIntoBootloader(AsebaVMState *vm)

Called by AsebaVMDebugMessage when VM must restart the node and enter to the bootloader, write an empty function to leave feature unsupported.

void AsebaPutVmToSleep(AsebaVMState *vm)

Called by AsebaVMDebugMessage when VM must put to node in deep sleep.

Write an empty function to leave feature unsupported

void __attribute__((weak))

Called by AsebaVMDebugMessage when VM is going to be run.

Called by AsebaVMEmitNodeSpecificError to be notified when VM hit an execution error Is also called for wrong array access or division by 0 with message == NULL.

Called by AsebaVMDebugMessage when VM is being resetted.

void AsebaAssert(AsebaVMState *vm, AsebaAssertReason reason)

If ASEBA_ASSERT is defined, this function is called when an error arise.

Variables

void const char* message
group compiler

Typedefs

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

Vector of names of variables.

using Aseba::EventDescription = typedef NamedValue

An event description is a name - value pair.

using Aseba::ConstantDefinition = typedef NamedValue

An constant definition is a name - value pair.

using Aseba::EventsDescriptionsVector = typedef NamedValuesVector

Vector of events descriptions.

using Aseba::ConstantsDefinitions = typedef NamedValuesVector

Vector of constants definitions.

Variables

const wchar_t *error_map[ERROR_END]
ErrorMessages::ErrorCallback translateCB = nullptr
const AsebaBinaryOperator operatorMap = { ASEBA_OP_ADD, ASEBA_OP_SUB, ASEBA_OP_MULT, ASEBA_OP_DIV, ASEBA_OP_MOD, ASEBA_OP_SHIFT_LEFT, ASEBA_OP_SHIFT_RIGHT, ASEBA_OP_BIT_OR, ASEBA_OP_BIT_XOR, ASEBA_OP_BIT_AND }
group vm

Glue logic must implement:

if (debug command queue is not empty)
    execute debug command
else if (executing a thread)
    run VM
else if (event queue is not empty)
    fetch event
    run VM
else
    sleep until something happens

Defines

ASEBA_NATIVES_STD_COUNT

Embedded targets must know the size of ASEBA_NATIVES_STD_FUNCTIONS without having to compute them by hand, please update this when adding a new function.

ASEBA_NATIVES_STD_FUNCTIONS

snippet to include standard native functions

ASEBA_NATIVES_STD_DESCRIPTIONS

snippet to include descriptions of standard native functions

GET_BIT(v, b)

Return true if bit b of v is 1.

BIT_SET(v, b)

Set bit b of v to 1.

BIT_CLR(v, b)

Set bit b of v to 0.

AsebaMaskSet(v, m)

Set the part masked by m of v to 1.

AsebaMaskClear(v, m)

Set the part masked by m of v to 0.

AsebaMaskIsSet(v, m)

Returns true if the part masked by m of v is 1.

AsebaMaskIsClear(v, m)

Returns true if the part masked by m of v is 0.

AsebaSendMessageWords(vm, type, data, size)

Typedefs

typedef void (*AsebaNativeFunctionPointer)(AsebaVMState *vm)

Signature of a native function.

Enums

enum [anonymous]

Values:

ASEBA_MAX_BREAKPOINTS = 16

maximum number of simultaneous breakpoints the target supports

enum AsebaAssertReason

Possible causes of AsebaAssert.

Values:

ASEBA_ASSERT_UNKNOWN = 0
ASEBA_ASSERT_UNKNOWN_UNARY_OPERATOR
ASEBA_ASSERT_UNKNOWN_BINARY_OPERATOR
ASEBA_ASSERT_UNKNOWN_BYTECODE
ASEBA_ASSERT_STACK_OVERFLOW
ASEBA_ASSERT_STACK_UNDERFLOW
ASEBA_ASSERT_OUT_OF_VARIABLES_BOUNDS
ASEBA_ASSERT_OUT_OF_BYTECODE_BOUNDS
ASEBA_ASSERT_STEP_OUT_OF_RUN
ASEBA_ASSERT_BREAKPOINT_OUT_OF_BYTECODE_BOUNDS
ASEBA_ASSERT_EMIT_BUFFER_TOO_LONG

Variables

const int16_t aseba_atan_table[20 *8+1] = { 652, 735, 816, 896, 977, 1058, 1139, 1218, 1300, 1459, 1620, 1777, 1935, 2093, 2250, 2403, 2556, 2868, 3164, 3458, 3748, 4029, 4307, 4578, 4839, 5359, 5836, 6290, 6720, 7126, 7507, 7861, 8203, 8825, 9357, 9839, 10260, 10640, 10976, 11281, 11557, 12037, 12425, 12755, 13036, 13277, 13486, 13671, 13837, 14112, 14331, 14514, 14666, 14796, 14907, 15003, 15091, 15235, 15348, 15441, 15519, 15585, 15642, 15691, 15736, 15808, 15865, 15912, 15951, 15984, 16013, 16037, 16060, 16096, 16125, 16148, 16168, 16184, 16199, 16211, 16222, 16240, 16255, 16266, 16276, 16284, 16292, 16298, 16303, 16312, 16320, 16325, 16331, 16334, 16338, 16341, 16344, 16348, 16352, 16355, 16357, 16360, 16361, 16363, 16364, 16366, 16369, 16369, 16371, 16372, 16373, 16373, 16375, 16375, 16377, 16376, 16378, 16378, 16378, 16379, 16379, 16380, 16380, 16380, 16382, 16381, 16381, 16381, 16382, 16382, 16382, 16382, 16382, 16382, 16384, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384}
const int16_t aseba_sin_table[128+1] = { 0, 403, 804, 1207, 1608, 2010, 2411, 2812, 3212, 3612, 4011, 4411, 4808, 5206, 5603, 5998, 6393, 6787, 7180, 7572, 7962, 8352, 8740, 9127, 9513, 9896, 10279, 10660, 11040, 11417, 11794, 12167, 12540, 12911, 13279, 13646, 14010, 14373, 14733, 15091, 15447, 15801, 16151, 16500, 16846, 17190, 17531, 17869, 18205, 18538, 18868, 19196, 19520, 19842, 20160, 20476, 20788, 21097, 21403, 21706, 22006, 22302, 22595, 22884, 23171, 23453, 23732, 24008, 24279, 24548, 24812, 25073, 25330, 25583, 25833, 26078, 26320, 26557, 26791, 27020, 27246, 27467, 27684, 27897, 28106, 28311, 28511, 28707, 28899, 29086, 29269, 29448, 29622, 29792, 29957, 30117, 30274, 30425, 30572, 30715, 30852, 30985, 31114, 31238, 31357, 31471, 31581, 31686, 31786, 31881, 31972, 32057, 32138, 32215, 32285, 32352, 32413, 32470, 32521, 32569, 32610, 32647, 32679, 32706, 32728, 32746, 32758, 32766, 32767, }
const AsebaNativeFunctionDescription AsebaNativeDescription_veccopy = {"math.copy", "copies src to dest element by element", {{-1, "dest"}, {-1, "src"}, {0, 0}}}

Description of AsebaNative_veccopy.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecfill = {"math.fill", "fills dest with constant value", {{-1, "dest"}, {1, "value"}, {0, 0}}}

Description of AsebaNative_vecfill.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecaddscalar = { "math.addscalar", "add scalar to each element of src and store result to dest", {{-1, "dest"}, {-1, "src"}, {1, "scalar"}, {0, 0}}}

Description of AsebaNative_vecaddscalar.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecadd = { "math.add", "adds src1 and src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecadd.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecsub = { "math.sub", "substracts src2 from src1 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecsub.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmul = { "math.mul", "multiplies src1 and src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecadd.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecdiv = { "math.div", "divides src1 by src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecsub.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmin = { "math.min", "writes the minimum of src1 and src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecmin.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmax = { "math.max", "writes the maximum of src1 and src2 to dest, element by element", {{-1, "dest"}, {-1, "src1"}, {-1, "src2"}, {0, 0}}}

Description of AsebaNative_vecsmax.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecclamp = { "math.clamp", "clamp src to low/high bounds into dest, element by element", {{-1, "dest"}, {-1, "src"}, {-1, "low"}, {-1, "high"}, {0, 0}}}

Description of AsebaNative_vecclamp.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecdot = { "math.dot", "writes the dot product of src1 and src2 to dest, after a shift", {{1, "dest"}, {-1, "src1"}, {-1, "src2"}, {1, "shift"}, {0, 0}}}

Description of AsebaNative_vecdot.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecstat = { "math.stat", "performs statistics on src", {{-1, "src"}, {1, "min"}, {1, "max"}, {1, "mean"}, {0, 0}}}

Description of AsebaNative_vecstat.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecargbounds = { "math.argbounds", "get the indices (argmin, argmax) of the limit values of src", {{-1, "src"}, {1, "argmin"}, {1, "argmax"}, {0, 0}}}

Description of AsebaNative_vecargbounds.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecsort = {"math.sort", "sort array in place", {{-1, "array"}, {0, 0}}}

Description of AsebaNative_vecsort.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathmuldiv = { "math.muldiv", "performs dest = (a*b)/c in 32 bits element by element", {{-1, "dest"}, {-1, "a"}, {-1, "b"}, {-1, "c"}, {0, 0}}}

Description of AsebaNative_mathmuldiv.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathatan2 = { "math.atan2", "performs dest = atan2(y,x) element by element", {{-1, "dest"}, {-1, "y"}, {-1, "x"}, {0, 0}}}

Description of AsebaNative_mathatan2.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathsin = {"math.sin", "performs dest = sin(x) element by element", {{-1, "dest"}, {-1, "x"}, {0, 0}}}

Description of AsebaNative_mathsin.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathcos = {"math.cos", "performs dest = cos(x) element by element", {{-1, "dest"}, {-1, "x"}, {0, 0}}}

Description of AsebaNative_mathcos.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathrot2 = {"math.rot2", "rotates v of angle a to dest", {{2, "dest"}, {2, "v"}, {1, "a"}, {0, 0}}}

Description of AsebaNative_mathrot2.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathsqrt = {"math.sqrt", "performs dest = sqrt(x) element by element", {{-1, "dest"}, {-1, "x"}, {0, 0}}}

Description of AsebaNative_mathsqrt.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecnonzerosequence = { "math.nzseq", "write to dest the middle index of the largest sequence of non-zero elements from src, -1 if " "not found or if smaller than minLength", {{1, "dest"}, {-1, "src"}, {1, "minLength"}, {0, 0}}}

Description of AsebaNative_vecnonzerosequence.

uint16_t rnd_state
const AsebaNativeFunctionDescription AsebaNativeDescription_rand = {"math.rand", "fill array with random values", {{-1, "dest"}, {0, 0}}}

Description of AsebaNative_rand.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqsize = {"deque.size", "report size of dest", {{-1, "deque"}, {1, "size"}, {0, 0}}}

Description of AsebaNative_deqsize.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqget = { "deque.get", "fill dest from deque at index", {{-1, "deque"}, {-2, "dest"}, {1, "index"}, {0, 0}}}

Description of AsebaNative_deqget.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqset = { "deque.set", "copies src to deque at index", {{-1, "deque"}, {-2, "src"}, {1, "index"}, {0, 0}}}

Description of AsebaNative_deqset.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqinsert = { "deque.insert", "shift deque at index by len(src) and insert src", {{-1, "deque"}, {-2, "src"}, {1, "index"}, {0, 0}}}

Description of AsebaNative_deqinsert.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqerase = { "deque.erase", "shift deque at index by len to erase", {{-1, "deque"}, {1, "index"}, {1, "len"}, {0, 0}}}

Description of AsebaNative_deqerase.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpushfront = {"deque.push_front", "insert src before the front of deque", {{-1, "deque"}, {-2, "src"}, {0, 0}}}

Description of AsebaNative_deqpushfront.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpushback = {"deque.push_back", "insert src after the back of deque", {{-1, "deque"}, {-2, "src"}, {0, 0}}}

Description of AsebaNative_deqpushback.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpopfront = { "deque.pop_front", "fill dest from front of deque then erase elements", {{-1, "deque"}, {-2, "dest"}, {0, 0}}}

Description of AsebaNative_deqpopfront.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpopback = { "deque.pop_back", "fill dest from back of deque then erase elements", {{-1, "deque"}, {-2, "dest"}, {0, 0}}}

Description of AsebaNative_deqpopback.

const AsebaNativeFunctionDescription AsebaNativeDescription_veccopy

Description of AsebaNative_veccopy.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecfill

Description of AsebaNative_vecfill.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecaddscalar

Description of AsebaNative_vecaddscalar.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecadd

Description of AsebaNative_vecadd.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecsub

Description of AsebaNative_vecsub.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmul

Description of AsebaNative_vecadd.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecdiv

Description of AsebaNative_vecsub.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmin

Description of AsebaNative_vecmin.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecmax

Description of AsebaNative_vecsmax.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecclamp

Description of AsebaNative_vecclamp.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecdot

Description of AsebaNative_vecdot.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecstat

Description of AsebaNative_vecstat.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecargbounds

Description of AsebaNative_vecargbounds.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecsort

Description of AsebaNative_vecsort.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathmuldiv

Description of AsebaNative_mathmuldiv.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathatan2

Description of AsebaNative_mathatan2.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathsin

Description of AsebaNative_mathsin.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathcos

Description of AsebaNative_mathcos.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathrot2

Description of AsebaNative_mathrot2.

const AsebaNativeFunctionDescription AsebaNativeDescription_mathsqrt

Description of AsebaNative_mathsqrt.

const AsebaNativeFunctionDescription AsebaNativeDescription_vecnonzerosequence

Description of AsebaNative_vecnonzerosequence.

const AsebaNativeFunctionDescription AsebaNativeDescription_rand

Description of AsebaNative_rand.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqsize

Description of AsebaNative_deqsize.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqget

Description of AsebaNative_deqget.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqset

Description of AsebaNative_deqset.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqinsert

Description of AsebaNative_deqinsert.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqerase

Description of AsebaNative_deqerase.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpushfront

Description of AsebaNative_deqpushfront.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpushback

Description of AsebaNative_deqpushback.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpopfront

Description of AsebaNative_deqpopfront.

const AsebaNativeFunctionDescription AsebaNativeDescription_deqpopback

Description of AsebaNative_deqpopback.

void const char* message
dir aseba
dir compiler
dir vm
page index