MicroModelicaCCompiler  4.5.3
MicroModelica::IR::Range Class Reference

#include <index.hpp>

Collaboration diagram for MicroModelica::IR::Range:

Public Member Functions

 Range ()
 
 Range (AST_Equation_For eqf, RANGE::Type type=RANGE::For)
 
 Range (AST_Statement_For stf, RANGE::Type type=RANGE::For, bool from_event=false)
 
 Range (Util::Variable var, RANGE::Type type=RANGE::For)
 
 Range (AST_Expression exp)
 
 Range (SB::Set set, int offset, std::vector< std::string > vars=std::vector< std::string >(), Option< Range > orig_range=Option< Range >())
 
 ~Range ()=default
 
int size () const
 
bool isEmpty () const
 
RangeDefinitionTable definition () const
 
int dim () const
 
std::string print (bool range=false, bool c_index=false, bool convert_params=false) const
 
std::string end () const
 
std::string indexes () const
 
std::vector< std::string > getIndexes () const
 
std::vector< std::string > getInitValues () const
 
void addLocalVariables () const
 
void addRangeLocalVariables () const
 
int rowSize (int dim) const
 
std::string block (int dim=-1) const
 
int pos (std::string var)
 
std::string iterator (int dim, bool range_idx=false)
 
std::string iterator (std::string var, int dim, bool range_idx=false)
 
std::string getPrintDimensionVarsString () const
 
std::string getDimensionVarsString (bool range=false) const
 
std::vector< std::string > getDimensionVars (bool range=false) const
 
std::string getDimensionVar (int i, bool range=false) const
 
bool intersect (Range other)
 
void applyUsage (Index usage)
 
bool checkUsage (Index usage, Index def)
 
std::string in (ExpressionList exps)
 
std::string in (std::vector< std::string > exps)
 
map< std::string, AST_Expression > initExps ()
 
void replace (Index ife_usage, Index ifr_usage=Index())
 
void generate (SB::Set set, int offset, std::vector< std::string > vars, std::vector< Expression > begin_exps=std::vector< Expression >(), std::vector< Expression > end_exps=std::vector< Expression >())
 
bool fixed () const
 
void merge (Range other)
 
bool hasMergedDims () const
 
bool isDimensionVar (std::string var)
 
void update (int offset)
 
void update (Range other)
 

Protected Member Functions

void generate (Util::Variable var)
 
void generate (AST_Expression exp)
 
void generate (SB::Set set, int offset, std::vector< std::string > vars, Option< Range > orig_range)
 
void updateRangeDefinition (std::string index_def, RangeDefinition def, int pos)
 
void addRangeVariables (int i, string index) const
 
bool isVariable (std::string var)
 
bool testExpression (AST_Expression exp)
 
Expression getExp (std::vector< Expression > exps, size_t pos)
 
bool checkRangeVariable (string var, set< string > &added_vars, vector< string > &old_keys, int &pos)
 
bool checkRangeVariables (string ife_idx, string ifr_idx, set< string > &added_vars, vector< string > &old_keys, int &pos)
 

Private Member Functions

void setRangeDefinition (AST_ForIndexList fil, bool from_event=false)
 

Private Attributes

RangeDefinitionTable _ranges
 
ModelTable< std::string, int > _index_pos
 
int _size
 
RANGE::Type _type
 
std::vector< int > _row_size
 
bool _fixed
 
bool _merged_dims
 

Friends

std::ostream & operator<< (std::ostream &out, const Range &r)
 

Detailed Description

Definition at line 164 of file index.hpp.

Constructor & Destructor Documentation

◆ Range() [1/6]

MicroModelica::IR::Range::Range ( )

Definition at line 282 of file index.cpp.

◆ Range() [2/6]

MicroModelica::IR::Range::Range ( AST_Equation_For  eqf,
RANGE::Type  type = RANGE::For 
)

Definition at line 284 of file index.cpp.

References generate().

Here is the call graph for this function:

◆ Range() [3/6]

MicroModelica::IR::Range::Range ( AST_Statement_For  stf,
RANGE::Type  type = RANGE::For,
bool  from_event = false 
)

Definition at line 290 of file index.cpp.

References generate().

Here is the call graph for this function:

◆ Range() [4/6]

MicroModelica::IR::Range::Range ( Util::Variable  var,
RANGE::Type  type = RANGE::For 
)

Definition at line 297 of file index.cpp.

References _index_pos, _ranges, ModelTable< Key, Value >::insert(), and pos().

Here is the call graph for this function:

◆ Range() [5/6]

MicroModelica::IR::Range::Range ( AST_Expression  exp)

Definition at line 302 of file index.cpp.

◆ Range() [6/6]

MicroModelica::IR::Range::Range ( SB::Set  set,
int  offset,
std::vector< std::string >  vars = std::vector< std::string >(),
Option< Range orig_range = OptionRange >() 
)

◆ ~Range()

MicroModelica::IR::Range::~Range ( )
default

Member Function Documentation

◆ addLocalVariables()

void MicroModelica::IR::Range::addLocalVariables ( ) const

Definition at line 634 of file index.cpp.

References MicroModelica::Util::ModelConfig::addLocalSymbol(), getDimensionVar(), and MicroModelica::Util::ModelConfig::instance().

Here is the call graph for this function:

◆ addRangeLocalVariables()

void MicroModelica::IR::Range::addRangeLocalVariables ( ) const

Definition at line 646 of file index.cpp.

References _row_size, and dim().

Here is the call graph for this function:

◆ addRangeVariables()

void MicroModelica::IR::Range::addRangeVariables ( int  i,
string  index 
) const
protected

Definition at line 657 of file index.cpp.

References dim(), and size().

Referenced by getDimensionVars().

Here is the call graph for this function:

◆ applyUsage()

void MicroModelica::IR::Range::applyUsage ( Index  usage)

◆ block()

string MicroModelica::IR::Range::block ( int  dim = -1) const

Definition at line 672 of file index.cpp.

Referenced by getDimensionVar().

◆ checkRangeVariable()

bool MicroModelica::IR::Range::checkRangeVariable ( string  var,
set< string > &  added_vars,
vector< string > &  old_keys,
int &  pos 
)
protected

Definition at line 810 of file index.cpp.

References isVariable(), and pos().

Here is the call graph for this function:

◆ checkRangeVariables()

bool MicroModelica::IR::Range::checkRangeVariables ( string  ife_idx,
string  ifr_idx,
set< string > &  added_vars,
vector< string > &  old_keys,
int &  pos 
)
protected

Definition at line 828 of file index.cpp.

◆ checkUsage()

bool MicroModelica::IR::Range::checkUsage ( Index  usage,
Index  def 
)

Definition at line 745 of file index.cpp.

◆ definition()

RangeDefinitionTable MicroModelica::IR::Range::definition ( ) const
inline

Definition at line 177 of file index.hpp.

Referenced by update(), and MicroModelica::IR::VariableUsage::VariableUsage().

◆ dim()

int MicroModelica::IR::Range::dim ( ) const

Definition at line 906 of file index.cpp.

Referenced by addRangeLocalVariables(), and addRangeVariables().

◆ end()

string MicroModelica::IR::Range::end ( ) const

Definition at line 559 of file index.cpp.

Referenced by getExp(), and testExpression().

◆ fixed()

bool MicroModelica::IR::Range::fixed ( ) const

Definition at line 894 of file index.cpp.

◆ generate() [1/4]

void MicroModelica::IR::Range::generate ( AST_Expression  exp)
protected

Definition at line 394 of file index.cpp.

◆ generate() [2/4]

void MicroModelica::IR::Range::generate ( SB::Set  set,
int  offset,
std::vector< std::string >  vars,
Option< Range orig_range 
)
protected

◆ generate() [3/4]

void MicroModelica::IR::Range::generate ( SB::Set  set,
int  offset,
std::vector< std::string >  vars,
std::vector< Expression begin_exps = std::vector< Expression >(),
std::vector< Expression end_exps = std::vector< Expression >() 
)

Referenced by Range().

◆ generate() [4/4]

void MicroModelica::IR::Range::generate ( Util::Variable  var)
protected

Definition at line 383 of file index.cpp.

◆ getDimensionVar()

string MicroModelica::IR::Range::getDimensionVar ( int  i,
bool  range = false 
) const

Definition at line 546 of file index.cpp.

References block().

Referenced by addLocalVariables(), getIndexes(), and in().

Here is the call graph for this function:

◆ getDimensionVars()

vector< string > MicroModelica::IR::Range::getDimensionVars ( bool  range = false) const

Definition at line 536 of file index.cpp.

References addRangeVariables().

Referenced by MicroModelica::IR::JacGenerator::guard(), and MicroModelica::IR::JacGenerator::init().

Here is the call graph for this function:

◆ getDimensionVarsString()

string MicroModelica::IR::Range::getDimensionVarsString ( bool  range = false) const

Definition at line 526 of file index.cpp.

◆ getExp()

◆ getIndexes()

vector< string > MicroModelica::IR::Range::getIndexes ( ) const

Definition at line 622 of file index.cpp.

References MicroModelica::Util::ModelConfig::addLocalSymbol(), getDimensionVar(), MicroModelica::Util::ModelConfig::instance(), and ModelTable< Key, Value >::key().

Referenced by replace().

Here is the call graph for this function:

◆ getInitValues()

vector< string > MicroModelica::IR::Range::getInitValues ( ) const

Definition at line 609 of file index.cpp.

References indexes(), and ModelTable< Key, Value >::key().

Here is the call graph for this function:

◆ getPrintDimensionVarsString()

string MicroModelica::IR::Range::getPrintDimensionVarsString ( ) const

Definition at line 516 of file index.cpp.

◆ hasMergedDims()

bool MicroModelica::IR::Range::hasMergedDims ( ) const

Definition at line 908 of file index.cpp.

◆ in() [1/2]

string MicroModelica::IR::Range::in ( ExpressionList  exps)

Definition at line 765 of file index.cpp.

References getDimensionVar(), and size().

Referenced by MicroModelica::IR::JacGenerator::dependencyPrologue(), and testExpression().

Here is the call graph for this function:

◆ in() [2/2]

std::string MicroModelica::IR::Range::in ( std::vector< std::string >  exps)

◆ indexes()

string MicroModelica::IR::Range::indexes ( ) const

Definition at line 598 of file index.cpp.

Referenced by getInitValues().

◆ initExps()

map< std::string, AST_Expression > MicroModelica::IR::Range::initExps ( )

Definition at line 799 of file index.cpp.

◆ intersect()

bool MicroModelica::IR::Range::intersect ( Range  other)

◆ isDimensionVar()

bool MicroModelica::IR::Range::isDimensionVar ( std::string  var)

Definition at line 514 of file index.cpp.

◆ isEmpty()

bool MicroModelica::IR::Range::isEmpty ( ) const

Definition at line 797 of file index.cpp.

References ModelTable< Key, Value >::insert().

Here is the call graph for this function:

◆ isVariable()

bool MicroModelica::IR::Range::isVariable ( std::string  var)
protected

Definition at line 414 of file index.cpp.

Referenced by checkRangeVariable(), and getExp().

◆ iterator() [1/2]

string MicroModelica::IR::Range::iterator ( int  dim,
bool  range_idx = false 
)

Definition at line 488 of file index.cpp.

◆ iterator() [2/2]

std::string MicroModelica::IR::Range::iterator ( std::string  var,
int  dim,
bool  range_idx = false 
)

◆ merge()

void MicroModelica::IR::Range::merge ( Range  other)

Definition at line 896 of file index.cpp.

◆ pos()

int MicroModelica::IR::Range::pos ( std::string  var)

Definition at line 685 of file index.cpp.

Referenced by checkRangeVariable(), getExp(), Range(), and testExpression().

◆ print()

string MicroModelica::IR::Range::print ( bool  range = false,
bool  c_index = false,
bool  convert_params = false 
) const

Definition at line 569 of file index.cpp.

◆ replace()

void MicroModelica::IR::Range::replace ( Index  ife_usage,
Index  ifr_usage = Index() 
)

Definition at line 843 of file index.cpp.

References getIndexes().

Here is the call graph for this function:

◆ rowSize()

int MicroModelica::IR::Range::rowSize ( int  dim) const

Definition at line 663 of file index.cpp.

◆ setRangeDefinition()

void MicroModelica::IR::Range::setRangeDefinition ( AST_ForIndexList  fil,
bool  from_event = false 
)
private

Definition at line 342 of file index.cpp.

◆ size()

int MicroModelica::IR::Range::size ( ) const

Definition at line 795 of file index.cpp.

References _ranges.

Referenced by addRangeVariables(), in(), and testExpression().

◆ testExpression()

bool MicroModelica::IR::Range::testExpression ( AST_Expression  exp)
protected

Definition at line 325 of file index.cpp.

References AST_ListAt(), AST_ListFirst(), current_element, end(), in(), pos(), and size().

Here is the call graph for this function:

◆ update() [1/2]

◆ update() [2/2]

void MicroModelica::IR::Range::update ( Range  other)

Definition at line 726 of file index.cpp.

◆ updateRangeDefinition()

void MicroModelica::IR::Range::updateRangeDefinition ( std::string  index_def,
RangeDefinition  def,
int  pos 
)
protected

Definition at line 313 of file index.cpp.

References MicroModelica::Util::Error::add(), EM_IR, EM_VARIABLE_NOT_FOUND, MicroModelica::Util::ER_Error, and MicroModelica::Util::Error::instance().

Referenced by getExp().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const Range r 
)
friend

Definition at line 910 of file index.cpp.

Member Data Documentation

◆ _fixed

bool MicroModelica::IR::Range::_fixed
private

Definition at line 235 of file index.hpp.

◆ _index_pos

ModelTable<std::string, int> MicroModelica::IR::Range::_index_pos
private

Definition at line 231 of file index.hpp.

Referenced by Range().

◆ _merged_dims

bool MicroModelica::IR::Range::_merged_dims
private

Definition at line 236 of file index.hpp.

◆ _ranges

RangeDefinitionTable MicroModelica::IR::Range::_ranges
private

◆ _row_size

std::vector<int> MicroModelica::IR::Range::_row_size
private

Definition at line 234 of file index.hpp.

Referenced by addRangeLocalVariables().

◆ _size

int MicroModelica::IR::Range::_size
private

Definition at line 232 of file index.hpp.

◆ _type

RANGE::Type MicroModelica::IR::Range::_type
private

Definition at line 233 of file index.hpp.


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