ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
ctor
deferred_resn
demangler
enum
forall-pointer-decay
gc_noraii
jacob/cs343-translation
jenkins-sandbox
memory
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
string
with_gc
|
Last change
on this file since 51b73452 was 51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago |
|
initial commit
|
-
Property mode
set to
100644
|
|
File size:
790 bytes
|
| Line | |
|---|
| 1 | #include <uC++.h>
|
|---|
| 2 | #include <uIOStream.h>
|
|---|
| 3 |
|
|---|
| 4 | uRaiseEvent R1 {
|
|---|
| 5 | public:
|
|---|
| 6 | int &i;
|
|---|
| 7 | R1( int &i ) : i(i) {}
|
|---|
| 8 | };
|
|---|
| 9 | uInitEvent( R1 );
|
|---|
| 10 |
|
|---|
| 11 | uRaiseEvent R2 {
|
|---|
| 12 | public:
|
|---|
| 13 | int &i;
|
|---|
| 14 | R2( int &i ) : i(i) {}
|
|---|
| 15 | };
|
|---|
| 16 | uInitEvent( R2 );
|
|---|
| 17 |
|
|---|
| 18 | void f( int &i );
|
|---|
| 19 | void g( int &i );
|
|---|
| 20 |
|
|---|
| 21 | void h1( R1 &r ) {
|
|---|
| 22 | r.i -= 1;
|
|---|
| 23 | uCout << "h1, i:" << r.i << endl;
|
|---|
| 24 | f( r.i );
|
|---|
| 25 | }
|
|---|
| 26 | void h2( R2 &r ) {
|
|---|
| 27 | r.i -= 2;
|
|---|
| 28 | uCout << "h2, i:" << r.i << endl;
|
|---|
| 29 | g( r.i );
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | void f( int &i ) {
|
|---|
| 33 | i -= 1;
|
|---|
| 34 | uCout << "f, i:" << i << endl;
|
|---|
| 35 | if ( i > 0 ) {
|
|---|
| 36 | try <R1,h1><R2,h2> {
|
|---|
| 37 | if ( i % 2 != 0 ) uRaise R2(i);
|
|---|
| 38 | g( i );
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 | void g( int &i ) {
|
|---|
| 43 | i -= 1;
|
|---|
| 44 | uCout << "g, i:" << i << endl;
|
|---|
| 45 | if ( i > 0 ) {
|
|---|
| 46 | try <R1,h1><R2,h2> {
|
|---|
| 47 | f( i );
|
|---|
| 48 | uRaise R1(i);
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|
| 52 | void uMain::main() {
|
|---|
| 53 | int i = 20;
|
|---|
| 54 | f( i );
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | // Local Variables: //
|
|---|
| 58 | // tab-width: 4 //
|
|---|
| 59 | // End: //
|
|---|
| 60 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.