AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
autopas::RuleSyntax::CodeGenerationContext Class Reference

A CodeGenerationContext keeps track of the needed stack size of the program, the mapping from variables to stack ddresses, the currently known lists, and the configuration patterns with they indices in the program encountered so far. More...

#include <RuleBasedProgramTree.h>

Public Member Functions

 CodeGenerationContext (std::map< std::string, std::pair< const Define *, size_t > > initialAddressEnvironment)
 Constructs a CodeGenerationContext.
 
 ~CodeGenerationContext ()
 Destructor.
 
void allocateStack (size_t num)
 Allocates the given number of MemoryCells on the stack.
 
void freeStack (size_t num)
 Frees the given number of MemoryCells on the stack.
 
void addLocalVariable (const Define &definition)
 Adds a local variable definition that can be used in the program later.
 
void addGlobalVariable (const Define &definition)
 Adds a global variable definition that can be used in the program later.
 
size_t addressOf (const std::string &name) const
 
const DefinedefinitionOf (const std::string &name) const
 
auto getMaxStackSize () const
 
void addList (const std::string &name, const DefineList *list)
 Adds a list definition that can be used later in the program.
 
const DefineListgetList (const std::string &name)
 
size_t addConfigurationOrder (const ConfigurationOrder &configurationOrder)
 Adds a configuration order and assigns it an index that can be used to refer to it later.
 
const std::vector< ConfigurationOrder > & getConfigurationOrders () const
 
ConfigurationPattern smallerConfigurationPatternByIndex (size_t idx) const
 
size_t getNumLocalVariables () const
 

Detailed Description

A CodeGenerationContext keeps track of the needed stack size of the program, the mapping from variables to stack ddresses, the currently known lists, and the configuration patterns with they indices in the program encountered so far.

Constructor & Destructor Documentation

◆ CodeGenerationContext()

autopas::RuleSyntax::CodeGenerationContext::CodeGenerationContext ( std::map< std::string, std::pair< const Define *, size_t > >  initialAddressEnvironment)
explicit

Constructs a CodeGenerationContext.

Parameters
initialAddressEnvironmentThe predefined variables with their definition and stack address.

Member Function Documentation

◆ addConfigurationOrder()

size_t autopas::RuleSyntax::CodeGenerationContext::addConfigurationOrder ( const ConfigurationOrder configurationOrder)

Adds a configuration order and assigns it an index that can be used to refer to it later.

Parameters
configurationOrderThe new configuration order.
Returns
The index of the new configuration order.

◆ addGlobalVariable()

void autopas::RuleSyntax::CodeGenerationContext::addGlobalVariable ( const Define definition)

Adds a global variable definition that can be used in the program later.

Parameters
definitionThe definition to add.

◆ addList()

void autopas::RuleSyntax::CodeGenerationContext::addList ( const std::string &  name,
const DefineList list 
)

Adds a list definition that can be used later in the program.

Parameters
nameThe name of the list.
listThe list definition.

◆ addLocalVariable()

void autopas::RuleSyntax::CodeGenerationContext::addLocalVariable ( const Define definition)

Adds a local variable definition that can be used in the program later.

Parameters
definitionThe definition to add.

◆ addressOf()

size_t autopas::RuleSyntax::CodeGenerationContext::addressOf ( const std::string &  name) const
Parameters
nameThe name of a variable.
Returns
the address of the variable on the stack.

◆ allocateStack()

void autopas::RuleSyntax::CodeGenerationContext::allocateStack ( size_t  num)

Allocates the given number of MemoryCells on the stack.

Parameters
numThe number of cells to allocate.

◆ definitionOf()

const Define * autopas::RuleSyntax::CodeGenerationContext::definitionOf ( const std::string &  name) const
Parameters
nameThe name of a variable.
Returns
The definition of the variable.

◆ freeStack()

void autopas::RuleSyntax::CodeGenerationContext::freeStack ( size_t  num)

Frees the given number of MemoryCells on the stack.

Parameters
numThe number of cells to free.

◆ getConfigurationOrders()

const std::vector< ConfigurationOrder > & autopas::RuleSyntax::CodeGenerationContext::getConfigurationOrders ( ) const
Returns
All configuration orders.

◆ getList()

const DefineList * autopas::RuleSyntax::CodeGenerationContext::getList ( const std::string &  name)
Parameters
nameThe name of a defined list.
Returns
the definition of the list with the given name.

◆ getMaxStackSize()

auto autopas::RuleSyntax::CodeGenerationContext::getMaxStackSize ( ) const
inline
Returns
the maximum needed stack size of the program.

◆ getNumLocalVariables()

size_t autopas::RuleSyntax::CodeGenerationContext::getNumLocalVariables ( ) const
Returns
The number of local variables.

◆ smallerConfigurationPatternByIndex()

ConfigurationPattern autopas::RuleSyntax::CodeGenerationContext::smallerConfigurationPatternByIndex ( size_t  idx) const
Parameters
idxAn index of a configuration order.
Returns
The smaller pattern of the configuration order with the given index.

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