Ticket #3178: stmt.mo

File stmt.mo, 885 bytes (added by Per Östlund, 10 years ago)
Line 
1encapsulated package InstSection
2 uniontype Statement
3 record ALG_WHEN_A
4 list<list<Statement>> branches;
5 SourceInfo info;
6 end ALG_WHEN_A;
7
8 record STMT_WHEN
9 list<Statement> statementLst;
10 Option<Statement> elseWhen;
11 end STMT_WHEN;
12 end Statement;
13
14 function instStatement
15 input Statement inStatement;
16 output list<Statement> outStatements;
17 algorithm
18 outStatements := match inStatement
19 local
20 list<Statement> sstmts;
21 Option<Statement> when_stmt_opt;
22 Statement when_stmt;
23
24 case ALG_WHEN_A()
25 algorithm
26 when_stmt_opt := NONE();
27
28 for b in inStatement.branches loop
29 when_stmt := STMT_WHEN(b, when_stmt_opt);
30 when_stmt_opt := SOME(when_stmt);
31 end for;
32 then
33 {when_stmt};
34
35 end match;
36 end instStatement;
37end InstSection;