@@ -424,6 +424,13 @@ algorithm
424424 then
425425 ();
426426
427+ // for equation
428+ case DAE . FOR_EQUATION ()
429+ algorithm
430+ (outEqns, outREqns, outIEqns) := lowerEqn(el, inFunctions, outEqns, outREqns, outIEqns, false );
431+ then
432+ ();
433+
427434 // initial array equations
428435 case DAE . INITIAL_ARRAY_EQUATION ()
429436 algorithm
@@ -1356,6 +1363,16 @@ algorithm
13561363 then
13571364 (inEquations,inREquations,eqns);
13581365
1366+ case DAE . FOR_EQUATION (iter = s, range = e1, equations = eqnslst, source = source)
1367+ equation
1368+ // create one backend for-equation for each equation element in the loop
1369+ (eqns, reqns, ieqns) = lowerEqns(eqnslst, functionTree, {}, {}, {}, inInitialization);
1370+ eqns = listAppend(List . map2(eqns, lowerForEquation, s, e1), inEquations);
1371+ reqns = listAppend(List . map2(reqns, lowerForEquation, s, e1), inREquations);
1372+ ieqns = listAppend(List . map2(ieqns, lowerForEquation, s, e1), inIEquations);
1373+ then
1374+ (eqns, reqns, ieqns);
1375+
13591376 // if equation that cannot be translated to if expression but have initial() as condition
13601377 case DAE . IF_EQUATION (condition1 = {DAE . CALL (path= Absyn . IDENT ("initial" ))},equations2= {eqnslst},equations3= {})
13611378 equation
@@ -1425,6 +1442,32 @@ algorithm
14251442 end match;
14261443end lowerEqn;
14271444
1445+ protected
1446+ function lowerForEquation
1447+ "Wrap one equation into a for-equation.
1448+ author: rfranke"
1449+ input BackendDAE . Equation eq;
1450+ input DAE . Ident iter;
1451+ input DAE . Exp range;
1452+ output BackendDAE . Equation forEq;
1453+ protected
1454+ DAE . Exp iterExp, start, stop;
1455+ DAE . Type ty;
1456+ DAE . Exp left, right;
1457+ DAE . ElementSource source;
1458+ BackendDAE . EquationAttributes attr;
1459+ algorithm
1460+ DAE . RANGE (ty= ty, start= start, stop= stop) := range;
1461+ iterExp := DAE . CREF (DAE . CREF_IDENT (iter, ty, {}), ty);
1462+ forEq := match eq
1463+ case BackendDAE . EQUATION (exp= left, scalar= right, source= source, attr= attr)
1464+ then BackendDAE . FOR_EQUATION (iterExp, start, stop, left, right, source, attr);
1465+ else algorithm
1466+ Error . addSourceMessage(Error . INTERNAL_ERROR , {"BackendDAECreate.lowerForEquation: unsupported equation " + BackendDump . equationString(eq)}, sourceInfo());
1467+ then fail();
1468+ end match;
1469+ end lowerForEquation;
1470+
14281471protected function lowerIfEquation
14291472 input list< DAE . Exp > conditions;
14301473 input list< list< DAE . Element >> theneqns;
0 commit comments