added test for if to test_voodoo_translator
[antimony.git] / test / test_voodoo_translator.voo
blob276d4b8007481490f99d05abdcbb516e10344571
1 section data
3 argc_str: string "argc"
4 argv_str: string "argv"
5 answer_str: string "answer"
6 call_str: string "call"
7 eq_str: string "eq"
8 equals_str: string "="
9 function_str: string "function"
10 functions_str: string "functions"
11 if_str: string "if"
12 main_str: string "main"
13 n_str: string "n"
14 return_str: string "return"
15 section_str: string "section"
16 the_answer_str: string "the_answer"
17 var_str: string "var"
20 section functions
21 export main
22 import array block \
23     init_voodoo_translator init_voodoo_writer intern make_blob \
24     make_voodoo_translator sb_init standard_output \
25     voodoo_translator_translate voodoo_translator_write
27 align
28 main:
29 function argc argv
30     call sb_init
31     call init_voodoo_writer
32     call init_voodoo_translator
34     let voodoo call make_voodoo_translator
36     let argc_b call make_blob argc_str 4
37     let argc_sym call intern argc_b
38     let argv_b call make_blob argv_str 4
39     let argv_sym call intern argv_b
40     let call_b call make_blob call_str 4
41     let call call intern call_b
42     let eq_b call make_blob equals_str 2
43     let eq call intern eq_b
44     let equals_b call make_blob equals_str 1
45     let equals call intern equals_b
46     let functions_b call make_blob functions_str 9
47     let functions call intern functions_b
48     let if_b call make_blob if_str 2
49     let if call intern if_b
50     let main_b call make_blob main_str 4
51     let main_sym call intern main_b
52     let var_b call make_blob var_str 3
53     let var call intern var_b
54     let section_b call make_blob section_str 7
55     let section call intern section_b
57     let the_answer_b call make_blob the_answer_str 10
58     let the_answer call intern the_answer_b
59     let items auto-words 4
60     set-word items 0 var
61     set-word items 1 the_answer
62     set-word items 2 equals
63     set-word items 3 169
64     let code call array 4 items
65     call voodoo_translator_translate voodoo code
67     set-word items 0 section
68     set-word items 1 functions
69     set code call array 2 items
70     call voodoo_translator_translate voodoo code
72     let answer_b call make_blob answer_str 6
73     let answer call intern answer_b
74     let function_b call make_blob function_str 8
75     let function call intern function_b
76     let return_b call make_blob return_str 6
77     let return call intern return_b
79     let code_items auto-words 5
81     set-word code_items 0 function
82     set-word code_items 1 answer
84     set-word items 0 return
85     set-word items 1 69
86     let stmt call array 2 items
88     set-word items 0 stmt
89     set stmt call array 1 items
90     set stmt call block stmt
91     set-word code_items 2 stmt
93     set code call array 3 code_items
94     call voodoo_translator_translate voodoo code
96     set-word items 0 call
97     set-word items 1 answer
98     set stmt call array 2 items
100     set-word items 0 if
101     set-word items 1 argc_sym
102     set-word items 2 stmt
103     set stmt call array 3 items
104     set-word items 0 stmt
105     set stmt call array 1 items
106     set stmt call block stmt
108     set-word code_items 0 function
109     set-word code_items 1 main_sym
110     set-word code_items 2 argc_sym
111     set-word code_items 3 argv_sym
112     set-word code_items 4 stmt
113     set code call array 5 code_items
114     call voodoo_translator_translate voodoo code
116     let stream standard_output
117     call voodoo_translator_write voodoo stream
119     return 0
120 end function