Rune - Pass-through -O[n], drop more insns in RAS
[rune.git] / tests / cmp2.d
1 #!/usr/local/bin/rune -x
2 #
3 #       Demonstrate the use of lvalue scope.  lvalue scope may be applied
4 #       to individual procedural arguments or to the return value.  It
5 #       causes the caller to pass the object by reference instead of by
6 #       value, allowing the procedure to modify the contents of the
7 #       object.
8 #
9 #       This feature is most often used when implementing operators that
10 #       require lvalues, such as "++" and "&=", but it can be used to
11 #       great effect with normal procedures as well.
12
13 limport "sys";
14 import "stdio";
15
16 class Fubar {
17         Fubar   *next;
18
19         destructor method void shootme()
20         {
21                 this.next = NULL;
22         }
23 }
24
25 Fubar Fu;
26 Fubar *root = &Fu;
27
28 int
29 main(int ac, char **av)
30 {
31         Fubar *fu;
32
33         fu = root->next;
34
35         stdio.stdout->format("abc" "def\n");
36         stdio.stdout->format("%s\n", `xxxyyy"abc"'xyz'\n` "qqq\n");
37         stdio.stdout->format(`"abc" "def\n"` "\n");
38         fu.new();
39         fu->next.new();
40 }