The Translator translates
switch/case
structures toif/then/else
structures for simulation and code generation needs:if (expression == key_value) actions;
● If thebreak
statement occurs in the action, control is transferred out of theif/then/else
statement byif
(expression
==
key_value)
actions
.
● If thebreak
statement does not occur in case body, the nextif/then/else
statement expression contains the previous expression and the current expression.All default actions are concatenated as a sequence of actions and run if all the
if/
then/else
expressions areFALSE
.The following table shows the translation of a switch case.
switch_c (X)
{
case_c 1:
Y++;
case_c 2:
Y=Y+2;
X++;
break;
case_c 3:
FOO1(Y);
FOO2(Y);
break;
default :
DEF_ACTION(X);
};
if ( X==1 )
{
Y = (Y + 1);
}
if ((X==1)||(X==2))
{
Y = (Y + 2);
X = (X + 1);
}
else
{
if ( X==3 )
{
FOO1(Y);
FOO2(Y);
}
else
{
DEF_ACTION(X);
}
}