Made parser able to report multiple errors per call, using new Voodoo::Parser::Multip...
[voodoo-lang.git] / test / vtable.voo
blob33d911cff0636fc6ef8c934e67819c1ed1eed0c1
1 #### Function table
3 section data
4 footext:
5 string "foo called with n = %d\n\x00"
6 bartext:
7 string "bar called with n = %d\n\x00"
8 baztext:
9 string "baz called with n = %d\n\x00"
11 vtable:
12 word foo
13 word bar
14 word baz
16 section functions
17 import printf
18 export main
20 main:
21 function argc argv
22     call testloop 2
23     return 0
24 end function
26 testloop:
27 function n
28     let func get-word vtable n
29     call func n
30     ifeq n 0
31         return 0
32     else
33         set n sub n 1
34         tail-call testloop n
35     end if
36 end function
38 foo:
39 function n
40     call printf footext n
41     return 0
42 end function
44 bar:
45 function n
46     call printf bartext n
47     return 0
48 end function
50 baz:
51 function n
52     call printf baztext n
53     return 0
54 end function