Added test cases for at-expressions.
[voodoo-lang.git] / test / vtable.voo
blob6a7f1d55d2956f1d5c6c3ee18615305559a605ad
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