repo.or.cz
/
voodoo-lang.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
New Environment class. Tests pass on AMD64
[voodoo-lang.git]
/
test
/
vtable.voo
blob
33d911cff0636fc6ef8c934e67819c1ed1eed0c1
1
#### Function table
2
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"
10
11
vtable:
12
word foo
13
word bar
14
word baz
15
16
section functions
17
import printf
18
export main
19
20
main:
21
function argc argv
22
call testloop 2
23
return 0
24
end function
25
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
37
38
foo:
39
function n
40
call printf footext n
41
return 0
42
end function
43
44
bar:
45
function n
46
call printf bartext n
47
return 0
48
end function
49
50
baz:
51
function n
52
call printf baztext n
53
return 0
54
end function