Bug fixed in preprocessor for new primitives.
[Faustine.git] / interpretor / 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
73 let dimension_of_symbol : symbol -> int * int =
74 fun (s : symbol) ->
75 match (dictionary_of_symbol s) with
76 | (dimension, delay, name) -> dimension;;
77
78 let delay_of_symbol : symbol -> int =
79 fun (s : symbol) ->
80 match (dictionary_of_symbol s) with
81 | (dimension, delay, name) -> delay;;
82
83 let string_of_symbol : symbol -> string =
84 fun (s : symbol) ->
85 match (dictionary_of_symbol s) with
86 | (dimension, delay, name) -> name;;