1 #!/usr/local/bin/rune -x
3 # Demonstrate global elements in classes, procedures, and compound
10 alias stdio.File *stdout = stdio.stdout;
15 global const int c1 = 1;
16 global const int c2 = 2;
17 global const int c3 = 3;
22 typedef int myint_t = 99;
24 class Fx1 { # 4 + (4 pad) + 40 + 8
39 # note that ( 7 ) is not compound, but Rune will always cast a non-compound
40 # expression to compound in the resolver if the resolver needs a compound
41 # expression. (7) initializes the 'y', not the 'x', because 'x' is a
42 # global field within the object and thus out-of-band (even though the
43 # object itself is being declared as a global, multiple instances of the
44 # object will share 'x').
46 (global int x = 2, int y = 6) A = ( 7 );
50 Fx1 fx1 = ( 1, &fx2, ( 2, ( 3 ) ) );
51 Fx1 fxx = ( puref1(1), purefx2(), ( puref1(2), ( puref1(3) ) ) );
55 const int xsize = 8192;
56 const int xmask = (xsize - 1);
60 main(int ac, char **av)
67 Test t4 = ( 8, 9, 10 );
72 stdout->show("fx1 should be (1, 2, 3): ",
73 fx1.f1data, fx1.f2obj.f2data, fx1.f2obj.f3obj.f3data);
74 stdout->show("sizeof(A) should be 4:", sizeof(A));
75 stdout->show("A.x should be 2:", A.x);
76 stdout->show("A.y should be 7:", A.y);
77 stdout->show("B should be 8:", B);
78 stdout->show("C should be 99:", C);
79 stdout->show("t1.a should be 3:", t1.a);
80 stdout->show("t1.c should be 4:", t1.c);
81 stdout->show("t2.a should be 2:", t2.a);
82 stdout->show("t3.z should be 99:", t3.z);
83 stdout->show("t4.z should be 10:", t4.z);
84 stdout->show("xsize should be 8192:", xsize);
85 stdout->show("xmask should be 8191:", xmask);
86 stdout->show("t4.z should be 10:", t4.z);