xref: /illumos-gate/usr/src/common/ficl/test/ooptest.fr (revision 6e6545bfaed3bab9ce836ee82d1abd8f2edba89a)
1\ OOP test stuff
2
3only
4also oop definitions
5
6object subclass c-aggregate
7c-byte obj: m0
8c-byte obj: m1
9c-4byte obj: m2
10c-2byte obj: m3
11end-class
12
13object --> sub class1
14
15cell: .a
16cell: .b
17: init
18	locals| class inst |
19	0 inst class --> .a !
20	1 inst class --> .b !
21;
22end-class
23
24class1 --> new c1inst
25
26class1 --> sub class2
27cell: .c
28cell: .d
29
30: init
31	locals| class inst |
32	inst class --> super --> init
33	2 inst class --> .c !
34	3 inst class --> .d !
35;
36end-class
37
38class2 --> new c2inst
39
40object subclass c-list
41c-list ref: link
42c-ref  obj: payload
43end-class
44
45\ test stuff from ficl.html
46.( metaclass methods ) cr
47metaclass --> methods
48
49cr .( c-foo class ) cr
50object --> sub c-foo
51cell: m_cell1
52    4 chars: m_chars
53    : init   ( inst class -- )
54        locals| class inst |
55        0 inst class --> m_cell1 !
56        inst class --> m_chars 4 0 fill
57        ." initializing an instance of c_foo at " inst x. cr
58    ;
59end-class
60
61.( c-foo instance methods... ) cr
62c-foo --> new foo-instance
63cr
64foo-instance --> methods
65foo-instance --> pedigree
66cr
67foo-instance 2dup
68    --> methods
69    --> pedigree
70cr
71c-foo --> see init
72cr
73foo-instance --> class --> see init
74