get rid of the stream parsing that occurs in the Layer III decoder. BitStream.readFra...
[IRC.git] / Robust / src / Tests / TaskExample.java
1 class Example {
2     flag needoperation;
3     flag needprinting;
4     public Example() {}
5
6    
7     int operation;
8     int x;
9     int y;
10     int z;
11 }
12
13 /* Startup object is generated with the initialstate flag set by the
14  *  system to start the computation up */
15
16 task Startup(StartupObject s {initialstate}) {
17     for(int i=0;i<10;i++) {
18         Example e=new Example() {needoperation};
19         e.x=i;
20         e.y=2;
21         e.operation=i%2;
22     }
23     
24     taskexit(s {!initialstate}); /* Turns initial state flag off, so this task won't refire */
25
26 }
27
28 /* Fails for x=1 */
29
30 task DoOperation(Example e{needoperation}) {
31     e.z=10*e.y/(e.x-1);
32
33     if (e.operation==0)
34         /* Print the result */
35         taskexit(e {!needoperation, needprinting});
36     else
37         /* Don't print the result */
38         taskexit(e {!needoperation});
39 }
40
41 /* Note that we can write arbitrary boolean expressions for flag
42  * expressions.  For example, needprinting && ! needoperation would
43  * also be a legal flag expression */
44
45 task DoPrint(Example e{needprinting}) {
46     System.printInt(e.z);
47     System.printString("\n");
48     taskexit(e {!needprinting});
49 }