Rename interpretor to interpreter.
[Faustine.git] / interpreter / symbol.ml
diff --git a/interpreter/symbol.ml b/interpreter/symbol.ml
new file mode 100644 (file)
index 0000000..4d58697
--- /dev/null
@@ -0,0 +1,86 @@
+(**
+       Module: Symbol  
+       Description: Symbols' information in faust.
+       @author WANG Haisheng   
+       Created: 05/08/2013     Modified: 05/08/2013
+*)
+
+open Types;;
+
+exception Symbol_error of string;;
+
+(* MACRO *)
+let delay_memory_length = 100000;;
+let rdtable_memory_length = 100000;;
+let rwtable_memory_length = 100000;;
+let vectorize_memory_length = 1000;;
+
+let dictionary_of_symbol : symbol -> (int * int) * int * string =
+  fun (s : symbol) ->
+    match s with
+    |Add        ->  ((2, 1), 0, "Add")
+    |Sub        ->  ((2, 1), 0, "Sub")         
+    |Mul        ->  ((2, 1), 0, "Mul")
+    |Div        ->  ((2, 1), 0, "Div")
+    |Power       ->  ((2, 1), 0, "Power")
+    |Pass       ->  ((1, 1), 0, "Pass")
+    |Stop       ->  ((1, 0), 0, "Stop")                
+    |And        ->  ((2, 1), 0, "And")
+    |Or         ->  ((2, 1), 0, "Or")
+    |Xor         ->  ((2, 1), 0, "Xor")
+    |Mem        ->  ((1, 1), 0, "Mem")
+    |Delay      ->  ((2, 1), delay_memory_length, "Delay")
+    |Floor      ->  ((1, 1), 0, "Floor")
+    |Ceil       ->  ((1, 1), 0, "Ceil")
+    |Rint       ->  ((1, 1), 0, "Rint")
+    |Int        ->  ((1, 1), 0, "Int")
+    |Float      ->  ((1, 1), 0, "Float")
+    |Sin        ->  ((1, 1), 0, "Sin")
+    |Asin       ->  ((1, 1), 0, "Asin")
+    |Cos        ->  ((1, 1), 0, "Cos")
+    |Acos       ->  ((1, 1), 0, "Acos")
+    |Tan        ->  ((1, 1), 0, "Tan")
+    |Atan       ->  ((1, 1), 0, "Atan")
+    |Atan2      ->  ((2, 1), 0, "Atan2")
+    |Exp        ->  ((1, 1), 0, "Exp")
+    |Sqrt       ->  ((1, 1), 0, "Sqrt")
+    |Ln         ->  ((1, 1), 0, "Ln")
+    |Lg         ->  ((1, 1), 0, "Lg")
+    |Abs         ->  ((1, 1), 0, "Abs")
+    |Mod        ->  ((2, 1), 0, "Mod")
+    |Fmod       ->  ((2, 1), 0, "Fmod")
+    |Remainder          ->  ((2, 1), 0, "Remainder")
+    |Vectorize  ->  ((2, 1), vectorize_memory_length, "Vectorize")
+    |Vconcat    ->  ((2, 1), 0, "Vconcat")
+    |Vpick      ->  ((2, 1), 0, "Vpick")
+    |Serialize  ->  ((1, 1), 0, "Serialize")
+    |Gt         ->  ((2, 1), 0, "Gt")
+    |Lt         ->  ((2, 1), 0, "Lt")
+    |Geq        ->  ((2, 1), 0, "Geq")
+    |Leq        ->  ((2, 1), 0, "Leq")
+    |Eq         ->  ((2, 1), 0, "Eq")
+    |Neq        ->  ((2, 1), 0, "Neq")
+    |Shl         ->  ((2, 1), 0, "shift_left")
+    |Shr         ->  ((2, 1), 0, "shift_right")
+    |Max         ->  ((2, 1), 0, "Max") 
+    |Min         ->  ((2, 1), 0, "Min")
+    |Prefix     ->  ((2, 1), 0, "Prefix")
+    |Select2    ->  ((3, 1), 0, "Select2")
+    |Select3     ->  ((4, 1), 0, "Select3")
+    |Rdtable    ->  ((3, 1), rdtable_memory_length, "Rdtalbe")
+    |Rwtable    ->  ((5, 1), rwtable_memory_length, "Rwtable");;
+
+let dimension_of_symbol : symbol -> int * int =
+  fun (s : symbol) ->
+    match (dictionary_of_symbol s) with
+    | (dimension, delay, name) -> dimension;;
+
+let delay_of_symbol : symbol -> int =
+  fun (s : symbol) ->
+    match (dictionary_of_symbol s) with
+    | (dimension, delay, name) -> delay;;
+
+let string_of_symbol : symbol -> string = 
+  fun (s : symbol) ->
+    match (dictionary_of_symbol s) with
+    | (dimension, delay, name) -> name;;