Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/uC++toCFA/uC++toCFA.tex

    r8659435 rde8a0286  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Feb 20 11:19:31 2026
    14 %% Update Count     : 6717
     13%% Last Modified On : Mon Nov 17 11:14:48 2025
     14%% Update Count     : 6677
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    194194
    195195The @choose@ statement provides an implicit @break@ after the @case@ clause for safety.
    196 It is possible to @fallthrough@ label in a @case@ clause to transfer to common code or the @default@ clause.
    197 \begin{cquote}
    198 \begin{tabular}{@{}l|l@{}}
    199 \begin{cfa}
     196It is possible to @break default@ in a @case@ clause to transfer to common code in the @default@ clause.
     197\begin{cquote}
     198\begin{tabular}{@{}l|l@{}}
     199\begin{uC++}
    200200switch ( i ) {
    201   case 3: ... @fallthrough common@;
    202   case 2: if ( ... ) @fallthrough@;
    203   case 1:
    204   common: ... ; // implicit fall through
     201  case 1: ... @break@; // explicit break
     202  case 2: ... @break@; // explicit break
    205203  default: ... ;
    206204}
    207 \end{cfa}
     205\end{uC++}
    208206&
    209207\begin{cfa}
    210208choose ( i ) {
    211   case 3: ... @fallthrough common@; // labelled explicit fallthrough
    212   case 2: if ( ... ) @fallthrough@; // conditional explicit fallthrough
    213   case 1:
    214   common: ... ; // implicit break
     209  case 1: ... ; // implicit break
     210  case 2: ... ; // implicit break
    215211  default: ... ;
    216212}
     
    254250for ( i; @5@ ~ @15@ ~ @2@ ) { ... } // 5 to 14 by 2
    255251for ( i; -2 ~@=@ 10 ~ 3 ) { ... } // -2 to 10 by 3
    256 for ( i; -3 @-@~ 10 ) { ... } // 10 to -2 by -1, not 10 -~= -3
    257 for ( i; 0 @-@~@=@ 10 ) { ... } // 10 to 0 by -1, not 10 -~= 0
     252for ( i; -3 @-@~ 10 ) { ... } // not 10 -~= -3, 10 to -2 by -1
     253for ( i; 0 @-@~@=@ 10 ) { ... } // not 10 -~= 0, 10 to 0 by -1
    258254\end{cfa}
    259255\end{tabular}
     
    912908  public:
    913909};
    914 T t;
    915 uProcessor p[3];
    916910\end{uC++}
    917911&
     
    923917};
    924918void main( @T & t@ ) {
    925         ... @resumeAt( partner, ExceptionInst( E, ... ) )@;
     919        ... @resumeAt( partner, ExceptionInst( E, ... )@ );
    926920        ... @active_thread();@ ...
    927921}
    928 T t;  // create thread object and start thread in main
    929 processor p[3]; // 4 kernel threads including program main
    930 \end{cfa}
     922\end{cfa}
     923\\
     924\multicolumn{2}{@{}l@{}}{\lstinline{T t; // start thread in main routine}}
    931925\end{tabular}
    932926\end{cquote}
     
    10151009        }
    10161010};
    1017 Barrier b{ 3 };
     1011enum { N = 3 };
     1012Barrier b{ N };
    10181013\end{uC++}
    10191014&
     
    10391034        }
    10401035}
    1041 Barrier b{ 3 };
     1036enum { N = 3 };
     1037Barrier b{ N };
    10421038\end{cfa}
    10431039\end{tabular}
     
    11821178
    11831179
    1184 {\lstset{tabsize=4}
     1180{\lstset{tabsize=3}
    11851181\setlength{\tabcolsep}{5pt}
    11861182\begin{tabular}{@{}l|ll@{}}
     
    11901186@Future_ISM@<double> fd;
    11911187struct Msg { int i, j; }; @Future_ISM@<Msg> fm;
     1188struct Stop {}; @Future_ISM@<Stop> fs;
    11921189struct Cont {}; @Future_ISM@<Cont> fc;
    1193 _Exception Stop {};
    11941190
    11951191_Task Worker {
    11961192        void main() {
    1197                 try {
    1198                         for ( ;; ) {
    1199                                 _Select( fi ) { cout << fi() << endl; fi.reset(); }
    1200                                 and _Select( fd ) { cout << fd() << endl; fd.reset(); }
    1201                                 and _Select( fm ) {
    1202                                         cout << fm().i << " " << fm().j << endl; fm.reset();
    1203                                 }
    1204                                 fc( (Cont){} );         // synchronize
    1205                         }
    1206                 } catch( Stop & ) { cout << "stop" << endl;}
    1207         }
     1193
     1194                for ( ;; ) {
     1195                        _Select( fi ) { cout << fi() << endl; fi.reset(); }
     1196                        and _Select( fd ) { cout << fd() << endl; fd.reset(); }
     1197                        and _Select( fm ) {
     1198                                cout << fm().i << " " << fm().j << endl; fm.reset();
     1199                        } or _Select( fs ) { cout << "stop" << endl; break; }
     1200                        fc.delivery( (Cont){} );        // synchronize
     1201                }
     1202        }
     1203
    12081204};
    12091205int main() {
    12101206        Worker worker;
    12111207        for ( int i = 0; i < 10; i += 1 ) {
    1212                 fi( i );   fd( i + 2.5 );   fm( (Msg){ i, 2 } );  // fulfil
     1208                fi( i );   fd( i + 2.5 );   fm( (Msg){ i, 2 } ); // fulfil
    12131209                fc(); fc.reset();                               // synchronize
    12141210        }
    1215         fi( new Stop{} );                               // trigger exception
     1211        fs( (Stop){} );
    12161212} // wait for worker to terminate
    12171213\end{uC++}
     
    12191215\begin{cfa}
    12201216#include <future.hfa>
    1221 @future_rc@( int ) fi;
    1222 @future_rc@( double ) fd;
    1223 struct Msg { int i, j; }; @future_rc@( Msg ) fm;
    1224 struct Cont {}; @future_rc@( Cont ) fc;
    1225 ExceptionDecl( Stop );
    1226 
     1217@future_rc@(int) fi;
     1218@future_rc@(double) fd;
     1219struct Msg { int i, j; }; @future_rc@(Msg) fm;
     1220struct Stop {}; @future_rc@(Stop) fs;
     1221struct Cont {}; @future_rc@(Cont) fc;
     1222ExceptionDecl( Break );
    12271223thread Worker {};
    12281224void main( Worker & ) {
     
    12311227                        waituntil( fi ) { sout | fi(); reset( fi ); }
    12321228                        and waituntil( fd ) { sout | fd(); reset( fd ); }
    1233                         and waituntil( fm ) {
    1234                                 sout | fm().i | fm().j; reset( fm );
     1229                        and waituntil( fm ) { sout | fm().i | fm().j; reset( fm ); }
     1230                        or waituntil( fs ) { sout | "stop";
     1231                                throw ExceptionInst( Break );
    12351232                        }
    12361233                        fc( (Cont){} );         // synchronize
    12371234                }
    1238         } catch( Stop * ) { sout | "stop"; }
    1239 }
    1240 
     1235        } catch( Break * ) {}
     1236}
    12411237int main() {
    12421238        Worker worker;
    12431239        for ( i; 10 ) {
    1244                 fi( i );   fd( i + 2.5 );   fm( (Msg){ i, 2 } );  // fulfil
     1240                fi( i );   fd( i + 2.5 );   fm( (Msg){ i, 2 } ); // fulfil
    12451241                fc(); reset( fc );              // synchronize
    12461242        }
    1247         fi( ExceptionPtr( ExceptionInst( Stop ) ) );
     1243        fs( (Stop){} );
    12481244} // wait for worker to terminate
    12491245\end{cfa}
Note: See TracChangeset for help on using the changeset viewer.