Skip to content

Commit a327ab4

Browse files
committed
#2897 Implement continue statements in MetaModelica
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22782 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent b33cd4c commit a327ab4

23 files changed

+90
-3
lines changed

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4720,6 +4720,10 @@ algorithm
47204720
then
47214721
traverseStmts(xs, func, extraArg);
47224722

4723+
case (((DAE.STMT_CONTINUE(source = _))::xs),_,extraArg)
4724+
then
4725+
traverseStmts(xs, func, extraArg);
4726+
47234727
// MetaModelica extension. KS
47244728
case (((DAE.STMT_FAILURE(body=stmts))::xs),_,extraArg)
47254729
equation

Compiler/FrontEnd/Absyn.mo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ uniontype Algorithm "The Algorithm type describes one algorithm statement in an
576576
list<AlgorithmItem> elseBody;
577577
end ALG_TRY;
578578

579+
record ALG_CONTINUE
580+
end ALG_CONTINUE;
581+
579582
end Algorithm;
580583

581584
public
@@ -2395,6 +2398,9 @@ algorithm
23952398
case (ALG_BREAK(), _, _, arg)
23962399
then (inAlg, arg);
23972400

2401+
case (ALG_CONTINUE(), _, _, arg)
2402+
then (inAlg, arg);
2403+
23982404
case (ALG_FAILURE(algs1), _, _, arg)
23992405
equation
24002406
(algs1, arg) = traverseAlgorithmItemListBidir(algs1, enterFunc, exitFunc, arg);

Compiler/FrontEnd/Algorithm.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ algorithm
880880
case DAE.STMT_NORETCALL(source=source) then source;
881881
case DAE.STMT_RETURN(source=source) then source;
882882
case DAE.STMT_BREAK(source=source) then source;
883+
case DAE.STMT_CONTINUE(source=source) then source;
883884
case DAE.STMT_FAILURE(source=source) then source;
884885
else
885886
equation

Compiler/FrontEnd/CheckModel.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ algorithm
538538
case(DAE.STMT_NORETCALL(exp = _), _, _) then iht;
539539
case(DAE.STMT_RETURN(_), _, _) then iht;
540540
case(DAE.STMT_BREAK(_), _, _) then iht;
541+
case(DAE.STMT_CONTINUE(_), _, _) then iht;
541542
case(DAE.STMT_ARRAY_INIT(name=_), _, _) then iht;
542543
// MetaModelica extension. KS
543544
case(DAE.STMT_FAILURE(body = stmts), _, _)

Compiler/FrontEnd/DAE.mo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,10 @@ uniontype Statement "There are four kinds of statements:
696696
ElementSource source "the origin of the component/equation/algorithm" ;
697697
end STMT_BREAK;
698698

699+
record STMT_CONTINUE
700+
ElementSource source "the origin of the component/equation/algorithm" ;
701+
end STMT_CONTINUE;
702+
699703
record STMT_ARRAY_INIT "For function initialization"
700704
String name;
701705
Type ty;

Compiler/FrontEnd/DAEUtil.mo

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4318,6 +4318,9 @@ algorithm
43184318
case (x as DAE.STMT_BREAK(source=_),_,_,extraArg)
43194319
then (x::{},extraArg);
43204320

4321+
case (x as DAE.STMT_CONTINUE(source=_),_,_,extraArg)
4322+
then (x::{},extraArg);
4323+
43214324
// MetaModelica extension. KS
43224325
case (DAE.STMT_FAILURE(body=stmts, source = source),_,_,extraArg)
43234326
equation
@@ -4524,6 +4527,11 @@ algorithm
45244527
(xs_1, extraArg) = traverseDAEStmts(xs, func, extraArg);
45254528
then (x::xs_1,extraArg);
45264529

4530+
case (((x as DAE.STMT_CONTINUE(source=_))::xs),_,extraArg)
4531+
equation
4532+
(xs_1, extraArg) = traverseDAEStmts(xs, func, extraArg);
4533+
then (x::xs_1,extraArg);
4534+
45274535
// MetaModelica extension. KS
45284536
case (((DAE.STMT_FAILURE(body=stmts, source = source))::xs),_,extraArg)
45294537
equation

Compiler/FrontEnd/InstSection.mo

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,13 @@ algorithm
26272627
then
26282628
(cache,{stmt});
26292629

2630+
case (cache,_,_,_,_,SCode.ALG_CONTINUE( info = info),source,_,_,_,_)
2631+
equation
2632+
source = DAEUtil.addElementSourceFileInfo(source, info);
2633+
stmt = DAE.STMT_CONTINUE(source);
2634+
then
2635+
(cache,{stmt});
2636+
26302637
// return
26312638
case (cache,_,_,_,ClassInf.FUNCTION(path=_),SCode.ALG_RETURN( info = info),source,_,_,_,_)
26322639
equation

Compiler/FrontEnd/InstUtil.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8934,6 +8934,7 @@ algorithm
89348934
then ((false,false,unbound));
89358935
case (DAE.STMT_BREAK(source=_),_,(_,_,unbound)) then ((true,false,unbound));
89368936
case (DAE.STMT_RETURN(source=_),_,(_,_,unbound)) then ((true,true,unbound));
8937+
case (DAE.STMT_CONTINUE(source=_),_,(_,_,unbound)) then ((false,false,unbound));
89378938
case (DAE.STMT_ARRAY_INIT(name=_),_,_) then inUnbound;
89388939
case (DAE.STMT_FAILURE(body=stmts),_,(_,_,unbound))
89398940
equation

Compiler/FrontEnd/SCode.mo

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ public uniontype Statement "The Statement type describes one algorithm statement
421421
Absyn.Info info;
422422
end ALG_TRY;
423423

424+
record ALG_CONTINUE
425+
Comment comment;
426+
Absyn.Info info;
427+
end ALG_CONTINUE;
428+
424429
end Statement;
425430

426431
// common prefixes to elements
@@ -2083,6 +2088,9 @@ algorithm
20832088
case ALG_BREAK(_,info)
20842089
then Absyn.ALGORITHMITEM(Absyn.ALG_BREAK(),NONE(),info);
20852090

2091+
case ALG_CONTINUE(_,info)
2092+
then Absyn.ALGORITHMITEM(Absyn.ALG_CONTINUE(),NONE(),info);
2093+
20862094
case ALG_FAILURE(body,_,info)
20872095
equation
20882096
algs1 = List.map(body,statementToAlgorithmItem);
@@ -3105,6 +3113,7 @@ algorithm
31053113
case ALG_BREAK(info = info) then info;
31063114
case ALG_FAILURE(info = info) then info;
31073115
case ALG_TRY(info = info) then info;
3116+
case ALG_CONTINUE(info = info) then info;
31083117
else
31093118
equation
31103119
Error.addInternalError("SCode.getStatementInfo failed");

Compiler/FrontEnd/SCodeUtil.mo

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ algorithm
909909
stmts2 = translateClassdefAlgorithmitems(elseBody);
910910
then SCode.ALG_TRY(stmts1,stmts2,comment,info);
911911

912+
case (Absyn.ALG_CONTINUE(),_,_)
913+
then SCode.ALG_CONTINUE(comment,info);
914+
912915
/*
913916
case (_,comment,info)
914917
equation

0 commit comments

Comments
 (0)