User Manual first draft.
[Faustine.git] / interpreter / symbol.ml
1 (**
2 Module: Symbol
3 Description: Symbols' information in faust.
4 @author WANG Haisheng
5 Created: 05/08/2013 Modified: 05/08/2013
6 *)
7
8 open Types;;
9
10 exception Symbol_error of string;;
11
12 (* MACRO *)
13 let delay_memory_length = 100000;;
14 let rdtable_memory_length = 100000;;
15 let rwtable_memory_length = 100000;;
16 let vectorize_memory_length = 1000;;
17
18 let dictionary_of_symbol : symbol -> (int * int) * int * string =
19 fun (s : symbol) ->
20 match s with
21 |Add -> ((2, 1), 0, "Add")
22 |Sub -> ((2, 1), 0, "Sub")
23 |Mul -> ((2, 1), 0, "Mul")
24 |Div -> ((2, 1), 0, "Div")
25 |Power -> ((2, 1), 0, "Power")
26 |Pass -> ((1, 1), 0, "Pass")
27 |Stop -> ((1, 0), 0, "Stop")
28 |And -> ((2, 1), 0, "And")
29 |Or -> ((2, 1), 0, "Or")
30 |Xor -> ((2, 1), 0, "Xor")
31 |Mem -> ((1, 1), 0, "Mem")
32 |Delay -> ((2, 1), delay_memory_length, "Delay")
33 |Floor -> ((1, 1), 0, "Floor")
34 |Ceil -> ((1, 1), 0, "Ceil")
35 |Rint -> ((1, 1), 0, "Rint")
36 |Int -> ((1, 1), 0, "Int")
37 |Float -> ((1, 1), 0, "Float")
38 |Sin -> ((1, 1), 0, "Sin")
39 |Asin -> ((1, 1), 0, "Asin")
40 |Cos -> ((1, 1), 0, "Cos")
41 |Acos -> ((1, 1), 0, "Acos")
42 |Tan -> ((1, 1), 0, "Tan")
43 |Atan -> ((1, 1), 0, "Atan")
44 |Atan2 -> ((2, 1), 0, "Atan2")
45 |Exp -> ((1, 1), 0, "Exp")
46 |Sqrt -> ((1, 1), 0, "Sqrt")
47 |Ln -> ((1, 1), 0, "Ln")
48 |Lg -> ((1, 1), 0, "Lg")
49 |Abs -> ((1, 1), 0, "Abs")
50 |Mod -> ((2, 1), 0, "Mod")
51 |Fmod -> ((2, 1), 0, "Fmod")
52 |Remainder -> ((2, 1), 0, "Remainder")
53 |Vectorize -> ((2, 1), vectorize_memory_length, "Vectorize")
54 |Vconcat -> ((2, 1), 0, "Vconcat")
55 |Vpick -> ((2, 1), 0, "Vpick")
56 |Serialize -> ((1, 1), 0, "Serialize")
57 |Gt -> ((2, 1), 0, "Gt")
58 |Lt -> ((2, 1), 0, "Lt")
59 |Geq -> ((2, 1), 0, "Geq")
60 |Leq -> ((2, 1), 0, "Leq")
61 |Eq -> ((2, 1), 0, "Eq")
62 |Neq -> ((2, 1), 0, "Neq")
63 |Shl -> ((2, 1), 0, "shift_left")
64 |Shr -> ((2, 1), 0, "shift_right")
65 |Max -> ((2, 1), 0, "Max")
66 |Min -> ((2, 1), 0, "Min")
67 |Prefix -> ((2, 1), 0, "Prefix")
68 |Select2 -> ((3, 1), 0, "Select2")
69 |Select3 -> ((4, 1), 0, "Select3")
70 |Rdtable -> ((3, 1), rdtable_memory_length, "Rdtalbe")
71 |Rwtable -> ((5, 1), rwtable_memory_length, "Rwtable")
72 |Button -> ((0, 1), 0, "Button")
73 |Checkbox -> ((0, 1), 0, "Checkbox")
74 |Vslider -> ((0, 1), 0, "Vslider")
75 |Hslider -> ((0, 1), 0, "Hslider")
76 |Vgroup -> ((0, 1), 0, "Vgroup")
77 |Hgroup -> ((0, 1), 0, "Hgroup")
78 |Tgroup -> ((0, 1), 0, "Tgroup")
79 |Hbargraph -> ((0, 1), 0, "Hbargraph")
80 |Vbargraph -> ((0, 1), 0, "Vbargraph")
81 |Nentry -> ((0, 1), 0, "Nentry")
82 |Attach -> ((2, 1), 0, "Attach") ;;
83
84 let dimension_of_symbol : symbol -> int * int =
85 fun (s : symbol) ->
86 match (dictionary_of_symbol s) with
87 | (dimension, delay, name) -> dimension;;
88
89 let delay_of_symbol : symbol -> int =
90 fun (s : symbol) ->
91 match (dictionary_of_symbol s) with
92 | (dimension, delay, name) -> delay;;
93
94 let string_of_symbol : symbol -> string =
95 fun (s : symbol) ->
96 match (dictionary_of_symbol s) with
97 | (dimension, delay, name) -> name;;