本文整理汇总了C++中Index::exp方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::exp方法的具体用法?C++ Index::exp怎么用?C++ Index::exp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::exp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process_for_equations
void process_for_equations(Modelica::MMO_Class &mmo_class) {
EquationList &equations = mmo_class.equations_ref().equations_ref();
EquationList new_equations;
foreach_ (Equation &e, equations) {
if (is<ForEq>(e)) {
ForEq feq = boost::get<ForEq>(e);
IndexList il = feq.range().indexes();
ERROR_UNLESS(il.size() == 1,
"process_for_equations:\n"
"forIndexList with more than 1 forIndex are not supported yet\n");
Index in = il.front();
Name variable = in.name();
OptExp ind = in.exp();
ERROR_UNLESS(ind, "for-equation's index with implicit range not supported yet\n");
Expression exp = ind.get();
ForIndexIterator *forIndexIter = NULL;
if (is<Range>(exp)) {
forIndexIter = new RangeIterator(get<Range>(exp),mmo_class.syms_ref());
} else if (is<Brace>(exp)) {
forIndexIter = new BraceIterator(get<Brace>(exp),mmo_class.syms_ref());
} else {
ERROR("For Iterator not supported");
}
while (forIndexIter->hasNext()) {
Real index_val = forIndexIter->next();
foreach_ (Equation eq, feq.elements())
new_equations.push_back(instantiate_equation(eq, variable, index_val, mmo_class.syms_ref()));
}
delete forIndexIter;
} else {
// Not a for eq
new_equations.push_back(e);
}
}
mmo_class.equations_ref().equations_ref()=new_equations;
}